import{DbBuildError as n}from"../common/error";import{AbstractCommand as u,AggregateCommand as c}from"./AbstractCommand";var m=function(){function a(t,i){if(i===void 0){i=""}this.data=t;this.prefix=i}a.prototype.stringify=function(){var t=this;if(this.data instanceof u){if(!(this.data instanceof c)){throw n.invalidCommand("Command \u4E0D\u662F\u805A\u5408\u64CD\u4F5C")}return this.data.stringify()}if(this.data===null||this.data instanceof Date){return this.data}if(Array.isArray(this.data)){return this.data.map(function(f,h){return new a(f,"".concat(t.prefix,".$.").concat(h)).stringify()})}switch(typeof this.data){case"number":return this.data;case"boolean":return this.data;case"string":return this.data;case"bigint":return this.data;case"function":throw n.invalidParam(this.prefix,"\u4E0D\u652F\u6301\u51FD\u6570");case"symbol":throw n.invalidParam(this.prefix,"\u4E0D\u652F\u6301 symbol");case"undefined":return this.data;default:{var i={};for(var r in this.data){var e=this.prefix?"".concat(this.prefix,".").concat(r):r;var o=this.data[r];var d=new a(o,e);var s=d.stringify();if(s!==void 0){i[r]=s}}return i}}};a.prototype.toJSON=function(){var t=this.stringify();if(t===void 0){throw n.invalidParam(this.prefix,"\u4E0D\u652F\u6301 undefined")}return t};return a}();export{m as AggregateRequest};