"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.UpdateRequest=void 0;var error_1=require("../common/error");var AbstractCommand_1=require("./AbstractCommand");var Operator_1=require("./Operator");var Geo_1=require("../mongo-builder/Geo");var UpdateRequest=function(){function r(e,s){if(s===void 0){s=""}this.data=e;this.prefix=s}r.prototype.stringify=function(e){e=e||new Operator_1.Operator;for(var s in this.data){var t=this.prefix?"".concat(this.prefix,".").concat(s):s;var i=this.data[s];var n=typeof i;if(i instanceof AbstractCommand_1.AbstractCommand){if(!(i instanceof AbstractCommand_1.UpdateCommand)){throw error_1.DbBuildError.invalidCommand("Command \u4E0D\u662F\u66F4\u65B0\u64CD\u4F5C")}if(i instanceof AbstractCommand_1.QueryUpdateCommand){e.mergeOperator(i.operator,i.stringifyWithKey(t))}else{e.applyOperator(i.operator,t,i.stringify())}}else if(i instanceof Geo_1.Geometry){e.set(t,i.toJSON())}else if(i instanceof Date){e.set(t,i)}else if(n==="number"){e.set(t,i)}else if(n==="boolean"){e.set(t,i)}else if(n==="string"){e.set(t,i)}else if(n==="bigint"){e.set(t,i)}else if(n==="function"){throw error_1.DbBuildError.invalidParam(t,"\u4E0D\u652F\u6301\u51FD\u6570")}else if(n==="symbol"){throw error_1.DbBuildError.invalidParam(t,"\u4E0D\u652F\u6301 symbol")}else if(n==="undefined"){}else if(i===null){e.set(t,i)}else if(Array.isArray(i)){e.set(t,i)}else{var f=new r(i,t);f.stringify(e)}}return e};r.prototype.toJSON=function(){var e=this.stringify();return e.emit()};return r}();exports.UpdateRequest=UpdateRequest;