@cloudbase/js-sdk 3.9.0 → 3.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- !function(){"use strict";var t={198:function(t,e,n){var r,o=this&&this.__extends||(r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},r(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__assign||function(){return i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},i.apply(this,arguments)},a=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function s(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}c((r=r.apply(t,e||[])).next())})},s=this&&this.__generator||function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.registerDatabase=void 0;var c=n(954),u=n(701),l=n(877),f={filterRes:function(t){return delete(t=l.utils.promoteGatewayError(t)).header,delete t.statusCode,t},flattenResData:function(t){if("object"==typeof t.data&&null!==t.data){var e=i(i({},t),t.data);return delete e.data,e}return t},safeParseEJSON:function(t){if("string"!=typeof t)return t;try{return u.EJSON.parse(t)}catch(e){return t}},parseEJSONParam:function(t){if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(e){return t}},toLegacyRegExp:function(t){if(!t||"object"!=typeof t)return t;if(t.$regularExpression&&"object"==typeof t.$regularExpression){var e=t.$regularExpression;return{$regex:e.pattern,$options:e.options}}if(Array.isArray(t))return t.map(function(t){return f.toLegacyRegExp(t)});var n={};for(var r in t)n[r]=f.toLegacyRegExp(t[r]);return n},parseWriteParam:function(t){return f.toLegacyRegExp(f.parseEJSONParam(t))},buildQueryParams:function(t){return Object.entries(t).filter(function(t){t[0];var e=t[1];return null!=e&&""!==e}).map(function(t){var e=t[0],n=t[1],r="object"==typeof n?JSON.stringify(n):String(n);return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(r))}).join("&")},getUrlPrefix:function(t){var e=(null==t?void 0:t.instance)||"(default)",n=(null==t?void 0:t.database)||"(default)";return"/database/instances/".concat(e,"/databases/").concat(n)},"database.queryDocument":function(t,e){var n,r,o,c,l,d,p;return a(this,void 0,Promise,function(){var a,h,y,v;return s(this,function(s){switch(s.label){case 0:return a=!!(null===(r=null===(n=t.query)||void 0===n?void 0:n._id)||void 0===r?void 0:r.$eq),h=f.buildQueryParams(i({projection:t.projection,transactionId:t.transactionId},a?{}:{offset:null!==(o=t.offset)&&void 0!==o?o:0,limit:null!==(c=t.limit)&&void 0!==c?c:100,order:t.order,query:t.query?u.EJSON.stringify(t.query,{relaxed:!1}):void 0})),y="".concat(f.getUrlPrefix(t),"/collections/").concat(t.collectionName,"/documents?").concat(h),a&&(y="".concat(f.getUrlPrefix(t),"/collections/").concat(t.collectionName,"/documents/").concat((null===(l=t.query._id)||void 0===l?void 0:l.$eq)||t.query._id,"?").concat(h)),[4,this.gateWay({url:y,method:"GET"},e)];case 1:return(v=s.sent()).data=f.safeParseEJSON(JSON.stringify(v.data)),!a||v.code||(null===(d=v.data)||void 0===d?void 0:d.code)?(v.code||(null===(p=v.data)||void 0===p?void 0:p.code)?v=i(i({},v),{data:i(i({},v.data),{list:[]})}):Array.isArray(v.data)?v=i(i({},v),{data:{list:v.data}}):v.data&&!Array.isArray(v.data.list)&&(v=i(i({},v),{data:i(i({},v.data),{list:[]})})),[2,f.filterRes(v)]):[2,i(i({},v),{data:{list:[v.data]}})]}})})},"database.addDocument":function(t,e){var n,r,o;return a(this,void 0,Promise,function(){var a;return s(this,function(s){switch(s.label){case 0:return[4,this.gateWay({url:"".concat(f.getUrlPrefix(t),"/collections/").concat(t.collectionName,"/documents"),method:"POST",data:i({data:Array.isArray(t.data)?t.data:[t.data]},t.transactionId&&{transactionId:t.transactionId})},e)];case 1:return a=s.sent(),Array.isArray(t.data)?a=i(i({},a),{data:i({ids:(null===(n=a.data)||void 0===n?void 0:n.insertedIds)||[]},a.data)}):(null===(o=null===(r=a.data)||void 0===r?void 0:r.insertedIds)||void 0===o?void 0:o[0])&&(a=i(i({},a),{data:i({_id:a.data.insertedIds[0]},a.data)})),[2,f.filterRes(a)]}})})},"database.updateDocument":function(t,e){return a(this,void 0,Promise,function(){var n;return s(this,function(r){switch(r.label){case 0:return[4,this.gateWay({url:"".concat(f.getUrlPrefix(t),"/collections/").concat(t.collectionName,"/documents"),method:"PATCH",data:i({query:t.query,data:t.data,multi:!!t.multi,upsert:!!t.upsert,replaceMode:!!t.replaceMode},t.transactionId&&{transactionId:t.transactionId})},e)];case 1:return n=r.sent(),[2,f.filterRes(n)]}})})},"database.deleteDocument":function(t,e){return a(this,void 0,Promise,function(){var n;return s(this,function(r){switch(r.label){case 0:return[4,this.gateWay({url:"".concat(f.getUrlPrefix(t),"/collections/").concat(t.collectionName,"/documents/remove"),method:"POST",data:i({query:t.query,multi:!!t.multi},t.transactionId&&{transactionId:t.transactionId})},e)];case 1:return n=r.sent(),[2,f.filterRes(n)]}})})},"database.countDocument":function(t,e){return a(this,void 0,Promise,function(){var n,r;return s(this,function(o){switch(o.label){case 0:return n=f.buildQueryParams({count:!0,query:t.query?u.EJSON.stringify(t.query,{relaxed:!1}):void 0}),[4,this.gateWay({url:"".concat(f.getUrlPrefix(t),"/collections/").concat(t.collectionName,"/documents?").concat(n),method:"GET"},e)];case 1:return r=o.sent(),[2,f.filterRes(r)]}})})},"database.addCollection":function(t,e){return a(this,void 0,Promise,function(){var n;return s(this,function(r){switch(r.label){case 0:return[4,this.gateWay({url:"".concat(f.getUrlPrefix(t),"/collections"),method:"POST",data:{collectionName:t.collectionName}},e)];case 1:return n=r.sent(),[2,f.filterRes(n)]}})})},"database.aggregate":function(t,e){var n;return a(this,void 0,Promise,function(){var r,o;return s(this,function(i){switch(i.label){case 0:return r=t.stages.map(function(t){var e,n;try{var r="string"==typeof t.stageValue?JSON.parse(t.stageValue):t.stageValue;return(e={})[t.stageKey]=u.EJSON.serialize(r),e}catch(e){return(n={})[t.stageKey]=t.stageValue,n}}),[4,this.gateWay({url:"".concat(f.getUrlPrefix(t),"/collections/").concat(t.collectionName,"/documents/aggregations"),method:"POST",data:{pipeline:r}},e)];case 1:return o=i.sent(),Array.isArray(null===(n=o.data)||void 0===n?void 0:n.list)&&(o.data.list=JSON.stringify(o.data.list.map(function(t){return JSON.stringify(t)}))),[2,f.filterRes(o)]}})})},"database.startTransaction":function(t,e){return a(this,void 0,void 0,function(){var n;return s(this,function(r){switch(r.label){case 0:return[4,this.gateWay({url:"".concat(f.getUrlPrefix(t),"/transactions"),method:"POST"},e)];case 1:return n=r.sent(),[2,f.filterRes(f.flattenResData(n))]}})})},"database.commitTransaction":function(t,e){return a(this,void 0,void 0,function(){var n;return s(this,function(r){switch(r.label){case 0:return[4,this.gateWay({url:"".concat(f.getUrlPrefix(t),"/transactions/").concat(t.transactionId,"/commit"),method:"POST"},e)];case 1:return n=r.sent(),[2,f.filterRes(n)]}})})},"database.abortTransaction":function(t,e){return a(this,void 0,void 0,function(){var n;return s(this,function(r){switch(r.label){case 0:return[4,this.gateWay({url:"".concat(f.getUrlPrefix(t),"/transactions/").concat(t.transactionId,"/rollback"),method:"POST"},e)];case 1:return n=r.sent(),[2,f.filterRes(n)]}})})},"database.getInTransaction":function(t,e){var n;return a(this,void 0,void 0,function(){var r;return s(this,function(o){switch(o.label){case 0:return[4,f["database.queryDocument"].call(this,t,e)];case 1:return"object"==typeof(r=o.sent()).data&&null!==r.data?(null===(n=r.data)||void 0===n?void 0:n.code)?[2,f.flattenResData(r)]:[2,i(i({},r),{data:JSON.stringify(r.data)})]:[2,r]}})})},"database.updateDocInTransaction":function(t,e){return a(this,void 0,void 0,function(){var n;return s(this,function(r){switch(r.label){case 0:return t.data=f.safeParseEJSON(t.data),[4,f["database.updateDocument"].call(this,t,e)];case 1:return n=r.sent(),[2,f.flattenResData(n)]}})})},"database.deleteDocInTransaction":function(t,e){return a(this,void 0,void 0,function(){var n;return s(this,function(r){switch(r.label){case 0:return[4,f["database.deleteDocument"].call(this,t,e)];case 1:return n=r.sent(),[2,f.flattenResData(n)]}})})},"database.insertDocInTransaction":function(t,e){var n;return a(this,void 0,Promise,function(){var r,o;return s(this,function(a){switch(a.label){case 0:return t.data=f.safeParseEJSON(t.data),[4,f["database.addDocument"].call(this,t,e)];case 1:return"object"==typeof(r=a.sent()).data&&null!==r.data?(o=!!(null===(n=r.data)||void 0===n?void 0:n._id),r=i(i(i({},r),{inserted:o?1:0,ok:o?1:0}),r.data)):r=i({inserted:0,ok:0},r),delete r.data,[2,r]}})})},"database.runCommands":function(t,e){return a(this,void 0,Promise,function(){var n;return s(this,function(r){switch(r.label){case 0:return[4,this.gateWay({url:"".concat(f.getUrlPrefix(t),"/commands"),method:"POST",data:i({commands:u.EJSON.serialize(t.commands)},t.transactionId&&{transactionId:t.transactionId})},e)];case 1:"object"==typeof(n=r.sent()).data&&null!==n.data&&(delete(n=i(i({},n),n.data)).data,delete n.request_id);try{n=u.EJSON.deserialize(n)}catch(t){}return[2,f.filterRes(n)]}})})},"database.getDocument":function(t,e){var n;return a(this,void 0,Promise,function(){var r,o;return s(this,function(a){switch(a.label){case 0:return(r=i({},t)).query=f.parseEJSONParam(r.query),r.order=f.parseEJSONParam(r.order),r.projection=f.parseEJSONParam(r.projection),[4,f["database.queryDocument"].call(this,r,e)];case 1:return o=a.sent(),Array.isArray(null===(n=o.data)||void 0===n?void 0:n.list)&&(o.data.list=o.data.list.map(function(t){return u.EJSON.stringify(t,{relaxed:!1})})),[2,o]}})})},"database.insertDocument":function(t,e){return a(this,void 0,Promise,function(){var n;return s(this,function(r){return(n=i({},t)).data=Array.isArray(n.data)?n.data.map(function(t){return f.parseWriteParam(t)}):f.parseWriteParam(n.data),[2,f["database.addDocument"].call(this,n,e)]})})},"database.modifyDocument":function(t,e){return a(this,void 0,Promise,function(){var n;return s(this,function(r){return(n=i({},t)).query=f.parseEJSONParam(n.query),n.data=f.parseEJSONParam(n.data),[2,f["database.updateDocument"].call(this,n,e)]})})},"database.removeDocument":function(t,e){return a(this,void 0,Promise,function(){var n;return s(this,function(r){return(n=i({},t)).query=f.parseEJSONParam(n.query),[2,f["database.deleteDocument"].call(this,n,e)]})})},"database.calculateDocument":function(t,e){return a(this,void 0,Promise,function(){var n;return s(this,function(r){return(n=i({},t)).query=f.parseEJSONParam(n.query),[2,f["database.countDocument"].call(this,n,e)]})})},"database.aggregateDocuments":function(t,e){var n;return a(this,void 0,Promise,function(){var r,o;return s(this,function(a){switch(a.label){case 0:return r=i({},t),Array.isArray(r.stages)&&(r.stages=r.stages.map(function(t){return i(i({},t),{stageValue:f.parseEJSONParam(t.stageValue)})})),[4,f["database.aggregate"].call(this,r,e)];case 1:if(o=a.sent(),"string"==typeof(null===(n=o.data)||void 0===n?void 0:n.list))try{o.data.list=JSON.parse(o.data.list)}catch(t){}return[2,o]}})})}},d={name:"database",entity:{database:function(t){var e;if(void 0!==t&&"Object"!==Object.prototype.toString.call(t).slice(8,-1))throw l.utils.createCloudbaseError({code:"INVALID_PARAM",msg:"dbConfig must be an object"},null===(e=this.config)||void 0===e?void 0:e.errorFactory);var n=this.platform,r=n.adapter,u=n.runtime,d=function(t){function e(e){return t.call(this,e)||this}return o(e,t),e.prototype.send=function(e,n,r){var o,i,c,u;return a(this,void 0,void 0,function(){var a,d,p;return s(this,function(s){switch(s.label){case 0:return a=null,d=r&&"number"==typeof r.timeout?{timeout:r.timeout}:void 0,"GATEWAY"===this.config.endPointMode&&f[e]?[4,f[e].call(this,n,d)]:[3,2];case 1:return a=s.sent(),[3,4];case 2:return[4,t.prototype.send.call(this,e,n,void 0,d)];case 3:a=s.sent(),s.label=4;case 4:if(p=l.utils.resolveThrow(null!==(c=null===(i=null===(o=this.config)||void 0===o?void 0:o._fromApp)||void 0===i?void 0:i.config)&&void 0!==c?c:this.config),a&&a.code&&p)throw l.utils.createCloudbaseError({code:a.code,msg:a.message||a.data&&a.data.message||"",requestId:a.requestId},null===(u=this.config)||void 0===u?void 0:u.errorFactory);return[2,a]}})})},e}(this.request.constructor);return c.Db.reqClass=d,c.Db.getAccessToken=this.authInstance?this.authInstance.getAccessToken.bind(this.authInstance):function(){return""},c.Db.runtime=u,this.wsClientClass&&(c.Db.wsClass=r.wsClass,c.Db.wsClientClass=this.wsClientClass),c.Db.ws||(c.Db.ws=null),new(function(t){function e(e){return t.call(this,e)||this}return o(e,t),e.prototype.runCommands=function(t){return a(this,void 0,Promise,function(){return s(this,function(e){return[2,c.Db.createRequest(this.config).send("database.runCommands",t)]})})},e}(c.Db))(i(i(i({},this.config),{_fromApp:this}),t))}}};try{cloudbase.registerComponent(d)}catch(t){}function p(t){try{t.registerComponent(d)}catch(t){console.warn(t)}}e.registerDatabase=p;try{window.registerDatabase=p}catch(t){}},563:function(t,e,n){var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),a=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&o(e,t,n);return i(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.useDefaultAdapter=e.useAdapters=e.RUNTIME=void 0;var s,c=a(n(92)),u=n(962);!function(t){t.WEB="web",t.WX_MP="wx_mp"}(s=e.RUNTIME||(e.RUNTIME={})),e.useAdapters=function(t,e){for(var n=0,o=(0,u.isArray)(t)?t:[t];n<o.length;n++){var i=o[n],a=i.isMatch,s=i.genAdapter,c=i.runtime;if(a())return{adapter:r({isMatch:a},s(e)),runtime:c}}},e.useDefaultAdapter=function(){return{adapter:r({},c.genAdapter()),runtime:s.WEB}}},92:function(t,e,n){var r,o=this&&this.__extends||(r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},r(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__assign||function(){return i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},i.apply(this,arguments)},a=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function s(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}c((r=r.apply(t,e||[])).next())})},s=this&&this.__generator||function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.WebRequest=e.genAdapter=void 0;var c=n(764),u=n(962),l=n(464),f=function(t){function e(e){var n=t.call(this)||this,r=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return n.timeout=r||0,n.timeoutMsg=o||"请求超时",n.restrictedMethods=i||["get","post","upload","download"],n}return o(e,t),e.prototype.get=function(t){return this.request(i(i({},t),{method:"get"}),this.restrictedMethods.includes("get"))},e.prototype.post=function(t){return this.request(i(i({},t),{method:"post"}),this.restrictedMethods.includes("post"))},e.prototype.put=function(t){return this.request(i(i({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,n=t.file,r=t.name,o=t.method,a=t.headers,s=void 0===a?{}:a,c={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",u=new FormData;return"post"===c?(Object.keys(e).forEach(function(t){u.append(t,e[t])}),u.append("key",r),u.append("file",n),this.request(i(i({},t),{data:u,method:c}),this.restrictedMethods.includes("upload"))):this.request(i(i({},t),{method:"put",headers:s,body:n}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return a(this,void 0,Promise,function(){var e,n,r,o;return s(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,this.get(i(i({},t),{headers:{},responseType:"blob"}))];case 1:return e=a.sent().data,n=window.URL.createObjectURL(new Blob([e])),r=decodeURIComponent(new URL(t.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=n,o.setAttribute("download",r),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(n),document.body.removeChild(o),[3,3];case 2:return a.sent(),[3,3];case 3:return[2,new Promise(function(e){e({statusCode:200,tempFilePath:t.url})})]}})})},e.prototype.fetch=function(t){var e;return a(this,void 0,Promise,function(){var n,r,o,c,u,l,f,d,p,h,y,v,m,b=this;return s(this,function(g){switch(g.label){case 0:return n=new AbortController,r=t.url,o=t.enableAbort,c=void 0!==o&&o,u=t.stream,l=void 0!==u&&u,f=t.signal,d=t.timeout,p=t.shouldThrowOnError,h=void 0===p||p,y=null!=d?d:this.timeout,f&&(f.aborted&&n.abort(),f.addEventListener("abort",function(){return n.abort()})),v=null,c&&y&&(v=setTimeout(function(){console.warn(b.timeoutMsg),n.abort(new Error(b.timeoutMsg))},y)),[4,fetch(r,i(i({},t),{signal:n.signal})).then(function(t){return a(b,void 0,void 0,function(){var e,n,r;return s(this,function(o){switch(o.label){case 0:return clearTimeout(v),h?t.ok?(e=t,[3,3]):[3,1]:[3,4];case 1:return r=(n=Promise).reject,[4,t.json()];case 2:e=r.apply(n,[o.sent()]),o.label=3;case 3:return[2,e];case 4:return[2,t]}})})}).catch(function(t){return clearTimeout(v),Promise.reject(t)})];case 1:return m=g.sent(),[2,{data:l?m.body:(null===(e=m.headers.get("content-type"))||void 0===e?void 0:e.includes("application/json"))?m.json():m.text(),statusCode:m.status,header:m.headers,response:m}]}})})},e.prototype.request=function(t,e){var n=this;void 0===e&&(e=!1);var r=String(t.method).toLowerCase()||"get";return new Promise(function(o){var i=t.url,a=t.headers,s=void 0===a?{}:a,c=t.data,f=t.responseType,d=t.withCredentials,p=t.body,h=t.onUploadProgress,y=(0,u.formatUrl)((0,l.getProtocol)(),i,"get"===r?c:{}),v=new XMLHttpRequest;v.open(r,y),f&&(v.responseType=f);var m,b,g=t.signal;g&&(g.aborted?v.abort():g.addEventListener("abort",function(){return v.abort()},{once:!0})),Object.keys(s).forEach(function(t){v.setRequestHeader(t,s[t])}),h&&v.upload.addEventListener("progress",h),v.onreadystatechange=function(){var t={};if(4===v.readyState){var e=v.getAllResponseHeaders().trim().split(/[\r\n]+/),n={};e.forEach(function(t){var e=t.split(": "),r=e.shift().toLowerCase(),o=e.join(": ");n[r]=o}),t.header=n,t.statusCode=v.status;try{t.data="blob"===f?v.response:JSON.parse(v.responseText)}catch(e){t.data="blob"===f?v.response:v.responseText}clearTimeout(m),o(t)}},e&&n.timeout&&(m=setTimeout(function(){console.warn(n.timeoutMsg),v.abort()},n.timeout)),b=(0,u.isFormData)(c)?c:"application/x-www-form-urlencoded"===s["content-type"]?(0,u.toQueryString)(c):p||(c?JSON.stringify(c):void 0),d&&(v.withCredentials=!0),v.send(b)})},e}(c.AbstractSDKRequest);e.WebRequest=f,e.genAdapter=function(){return{type:"default",root:window,reqClass:f,wsClass:WebSocket,localStorage:localStorage}}},464:function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.COMMUNITY_SITE_URL=e.IS_DEBUG_MODE=e.getProtocol=e.setProtocol=e.getSdkName=e.setSdkName=void 0;var n="@cloudbase/js-sdk";e.setSdkName=function(t){n=t},e.getSdkName=function(){return n};var r="https:";e.setProtocol=function(t){r=t},e.getProtocol=function(){return r},e.IS_DEBUG_MODE=!1,e.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},519:function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.ERRORS=void 0,e.ERRORS={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"}},778:function(t,e,n){var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.OATUH_LOGINTYPE=void 0,o(n(464),e),o(n(519),e),e.OATUH_LOGINTYPE="constants"},517:function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function s(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}c((r=r.apply(t,e||[])).next())})},o=this&&this.__generator||function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.catchErrorsDecorator=void 0;var i=n(962),a=n(778),s=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(s=-1!==navigator.userAgent.indexOf("Firefox"));var c=s?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,u=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function l(t){var e=t.err,n=t.className,r=t.methodName,o=t.sourceLink;if(!o)return null;var i,a=e.stack.split("\n"),c=s?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(n,"\\.descriptor.value\\s*\\[as\\s").concat(r,"\\]\\s*\\(.*\\)$")),l=s?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(n,"\\.descriptor.value\\s*\\[as\\s").concat(r,"\\]")),f=a.findIndex(function(t){return c.test(t)});if(-1!==f){var d=a.filter(function(t,e){return e>f});d.unshift(a[f].replace(l,"".concat(n,".").concat(r)).replace(u,o)),(i=new Error).stack="".concat(s?"@debugger":"Error","\n").concat(d.join("\n"))}return i}e.catchErrorsDecorator=function(t){var e=t.mode,n=void 0===e?"async":e,s=t.customInfo,f=void 0===s?{}:s,d=t.title,p=t.messages,h=void 0===p?[]:p;return function(t,e,s){if(a.IS_DEBUG_MODE){var p=f.className||t.constructor.name,y=f.methodName||e,v=s.value,m=function(){var t="",e=(new Error).stack.split("\n"),n=e.findIndex(function(t){return c.test(t)});if(-1!==n){var r=u.exec(e[n+1]||"");t=r?r[0]:""}return t}();s.value="sync"===n?function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=l({err:new Error,className:p,methodName:y,sourceLink:m});try{return v.apply(this,t)}catch(t){var r=t,o=t.message,a=t.error,s=t.error_description,c={title:d||"".concat(p,".").concat(y," failed"),content:[{type:"error",body:t}]};if(o&&/^\{.*\}$/.test(o)){var u=JSON.parse(o);c.subtitle=o,u.code&&(n?(n.code=u.code,n.msg=u.msg):(t.code=u.code,t.message=u.msg),r=n||t,c.content=h.map(function(t){return{type:"info",body:t}}))}throw a&&s&&(c.subtitle=s,n?(n.code=a,n.msg=s):(t.code=a,t.message=s),r=n||t,c.content=h.map(function(t){return{type:"info",body:t}})),(0,i.printGroupLog)(c),r}}:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return r(this,void 0,void 0,function(){var e,n,r,a,s,c,u,f;return o(this,function(o){switch(o.label){case 0:e=l({err:new Error,className:p,methodName:y,sourceLink:m}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,v.apply(this,t)];case 2:return[2,o.sent()];case 3:throw n=o.sent(),r=n,a=n.message,s=n.error,c=n.error_description,u={title:d||"".concat(p,".").concat(y," failed"),content:[{type:"error",body:n}]},a&&/^\{.*\}$/.test(a)&&(f=JSON.parse(a),u.subtitle=f,f.code&&(e?(e.code=f.code,e.message=f.msg):(n.code=f.code,n.message=f.msg),r=e||n,u.content=h.map(function(t){return{type:"info",body:t}}))),s&&c&&(u.subtitle=c,e?(e.code=s,e.msg=c):(n.code=s,n.message=c),r=e||n,u.content=h.map(function(t){return{type:"info",body:t}})),(0,i.printGroupLog)(u),r;case 4:return[2]}})})}}}}},260:function(t,e,n){var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),o(n(517),e)},877:function(t,e,n){var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&r(e,t,n);return o(e,t),e},a=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.langEvent=e.AbortController=e.jwt=e.helpers=e.utils=e.events=e.cache=e.adapters=e.constants=void 0;var s=i(n(778));e.constants=s;var c=i(n(563));e.adapters=c;var u=i(n(865));e.cache=u;var l=i(n(940));e.events=l;var f=i(n(991));e.langEvent=f;var d=i(n(962));e.utils=d;var p=i(n(260));e.helpers=p;var h=a(n(829));e.AbortController=h.default;var y={decode:a(n(107)).default};e.jwt=y},829:function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(){var t=this;this.listeners=[],this.signal={aborted:!1,addEventListener:function(e,n){"abort"===e&&t.listeners.push(n)}}}return t.prototype.abort=function(){this.signal.aborted||(this.signal.aborted=!0,this.listeners.forEach(function(t){return t()}))},t}();e.default=n},865:function(t,e,n){var r,o=this&&this.__extends||(r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},r(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function s(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}c((r=r.apply(t,e||[])).next())})},a=this&&this.__generator||function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.CloudbaseCache=void 0;var s=n(764),c=n(962),u=n(778),l=function(t){function e(e){var n=t.call(this)||this;return n.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),n}return o(e,t),e.prototype.setItem=function(t,e){this.root.tcbCacheObject[t]=e},e.prototype.getItem=function(t){return this.root.tcbCacheObject[t]},e.prototype.removeItem=function(t){delete this.root.tcbCacheObject[t]},e.prototype.clear=function(){delete this.root.tcbCacheObject},e}(s.AbstractStorage),f=function(){function t(t){this.keys={};var e=t.persistence,n=t.platformInfo,r=void 0===n?{}:n,o=t.keys,i=void 0===o?{}:o;this.platformInfo=r,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||e,this.storage=function(t,e){switch(t){case"local":default:return e.localStorage?e.localStorage:((0,c.printWarn)(u.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new l(e.root));case"none":return new l(e.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(t.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),t.prototype.setStore=function(t,e,n){if("async"!==this.mode){if(this.storage)try{var r={version:n||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(r))}catch(t){throw new Error(JSON.stringify({code:u.ERRORS.OPERATION_FAIL,msg:"[".concat((0,u.getSdkName)(),"][").concat(u.ERRORS.OPERATION_FAIL,"]setStore failed"),info:t}))}}else(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,n){return i(this,void 0,void 0,function(){var r;return a(this,function(o){switch(o.label){case 0:if(!this.storage)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),r={version:n||"localCachev1",content:e},[4,this.storage.setItem(t,JSON.stringify(r))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}})})},t.prototype.getStore=function(t,e){var n;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(n={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===n?void 0:n.tcb_token))return{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(t){return""}e=e||"localCachev1";var r=this.storage.getItem(t);return r&&r.indexOf(e)>=0?JSON.parse(r).content:""}(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){var n;return i(this,void 0,void 0,function(){var r;return a(this,function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(n={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===n?void 0:n.tcb_token))return[2,{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(t){return[2,""]}return e=e||"localCachev1",[4,this.storage.getItem(t)];case 1:return(r=o.sent())&&r.indexOf(e)>=0?[2,JSON.parse(r).content]:[2,""]}})})},t.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},t.prototype.removeStoreAsync=function(t){return i(this,void 0,void 0,function(){return a(this,function(e){switch(e.label){case 0:return[4,this.storage.removeItem(t)];case 1:return e.sent(),[2]}})})},t}();e.CloudbaseCache=f},940:function(t,e,n){var r,o=this&&this.__extends||(r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},r(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__spreadArray||function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))};Object.defineProperty(e,"__esModule",{value:!0}),e.removeEventListener=e.activateEvent=e.addEventListener=e.CloudbaseEventEmitter=e.IErrorEvent=e.CloudbaseEvent=void 0;var a=n(962),s=function(t,e){this.data=e||null,this.name=t};e.CloudbaseEvent=s;var c=function(t){function e(e,n){var r=t.call(this,"error",{error:e,data:n})||this;return r.error=e,r}return o(e,t),e}(s);e.IErrorEvent=c;var u=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){return function(t,e,n){n[t]=n[t]||[],n[t].push(e)}(t,e,this.listeners),this},t.prototype.off=function(t,e){return function(t,e,n){if(null==n?void 0:n[t]){var r=n[t].indexOf(e);-1!==r&&n[t].splice(r,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if((0,a.isInstanceOf)(t,c))return console.error(t.error),this;var n=(0,a.isString)(t)?new s(t,e||{}):t,r=n.name;if(this.listens(r)){n.target=this;for(var o=0,u=this.listeners[r]?i([],this.listeners[r],!0):[];o<u.length;o++)u[o].call(this,n)}return this},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}();e.CloudbaseEventEmitter=u;var l=new u;e.addEventListener=function(t,e){l.on(t,e)},e.activateEvent=function(t,e){void 0===e&&(e={}),l.fire(t,e)},e.removeEventListener=function(t,e){l.off(t,e)}},991:function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),e.LANG_CHANGE_EVENT=e.bus=void 0;var r=n(940);e.bus=new r.CloudbaseEventEmitter,e.LANG_CHANGE_EVENT="lang_change"},962:function(t,e,n){var r,o=this&&this.__extends||(r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},r(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__assign||function(){return i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},i.apply(this,arguments)},a=this&&this.__rest||function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n};Object.defineProperty(e,"__esModule",{value:!0}),e.parseCaptcha=e.parseQueryString=e.transformPhone=e.sleep=e.printGroupLog=e.errorToResult=e.promoteGatewayError=e.maybeThrow=e.resolveThrow=e.createCloudbaseError=e.CloudbaseError=e.throwError=e.printInfo=e.printError=e.printWarn=e.execCallback=e.createPromiseCallback=e.removeParam=e.getHash=e.getQuery=e.toQueryString=e.formatUrl=e.generateRequestId=e.genSeqId=e.isFormData=e.isInstanceOf=e.isNull=e.isPalinObject=e.isUndefined=e.isString=e.isArray=void 0;var s=n(778);e.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},e.isString=function(t){return"string"==typeof t},e.isUndefined=function(t){return void 0===t},e.isPalinObject=function(t){return"[object Object]"===Object.prototype.toString.call(t)},e.isNull=function(t){return"[object Null]"===Object.prototype.toString.call(t)},e.isInstanceOf=function(t,e){return t instanceof e},e.isFormData=function(t){return"[object FormData]"===Object.prototype.toString.call(t)},e.genSeqId=function(){return Math.random().toString(16).slice(2)},e.generateRequestId=function(){var t=(new Date).getTime(),e=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){var r=16*Math.random();return t>0?(r=(t+r)%16|0,t=Math.floor(t/16)):(r=(e+r)%16|0,e=Math.floor(e/16)),("x"===n?r:7&r|8).toString(16)})},e.formatUrl=function(t,e,n){void 0===n&&(n={});var r=/\?/.test(e),o="";return Object.keys(n).forEach(function(t){""===o?!r&&(e+="?"):o+="&",o+="".concat(t,"=").concat(encodeURIComponent(n[t]))}),/^http(s)?:\/\//.test(e+=o)?e:"".concat(t).concat(e)},e.toQueryString=function(t){void 0===t&&(t={});var e=[];return Object.keys(t).forEach(function(n){e.push("".concat(n,"=").concat(encodeURIComponent(t[n])))}),e.join("&")},e.getQuery=function(t,e){if("undefined"==typeof window)return!1;var n=e||decodeURIComponent(window.location.search),r=new RegExp("(^|&)".concat(t,"=([^&]*)(&|$)")),o=n.substr(n.indexOf("?")+1).match(r);return null!=o?o[2]:""},e.getHash=function(t){if("undefined"==typeof window)return"";var e=window.location.hash.match(new RegExp("[#?&/]".concat(t,"=([^&#]*)")));return e?e[1]:""},e.removeParam=function(t,e){var n=e.split("?")[0],r=[],o=-1!==e.indexOf("?")?e.split("?")[1]:"";if(""!==o){for(var i=(r=o.split("&")).length-1;i>=0;i-=1)r[i].split("=")[0]===t&&r.splice(i,1);n="".concat(n,"?").concat(r.join("&"))}return n},e.createPromiseCallback=function(){var t={};if(!Promise){(t=function(){}).promise={};var e=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(t.promise,"then",{get:e}),Object.defineProperty(t.promise,"catch",{get:e}),t}var n=new Promise(function(e,n){t=function(t,r){return t?n(t):e(r)}});return t.promise=n,t},e.execCallback=function(t,e,n){if(void 0===n&&(n=null),t&&"function"==typeof t)return t(e,n);if(e)throw e;return n},e.printWarn=function(t,e){console.warn("[".concat((0,s.getSdkName)(),"][").concat(t,"]:").concat(e))},e.printError=function(t,e){console.error({code:t,msg:"[".concat((0,s.getSdkName)(),"][").concat(t,"]:").concat(e)})},e.printInfo=function(t,e){console.log("[".concat((0,s.getSdkName)(),"][").concat(t,"]:").concat(e))},e.throwError=function(t,e){var n=new Error(JSON.stringify({code:t,msg:"[".concat((0,s.getSdkName)(),"][").concat(t,"]:").concat(e)}));throw n.code=t,n};var c=function(t){function e(e){var n=t.call(this,e.msg||e.message||"")||this;return n.code=e.code||"",n.requestId=e.requestId||"",Object.defineProperty(n,"message",{value:e.msg||e.message||"",enumerable:!0,writable:!0,configurable:!0}),n}return o(e,t),e}(Error);e.CloudbaseError=c;var u=function(t){return new c(t)};function l(t,e){return(e||u)(t)}function f(t){return!t||"boolean"!=typeof t.throw||t.throw}e.createCloudbaseError=l,e.resolveThrow=f,e.maybeThrow=function(t,e){if(f(t))throw l(e,null==t?void 0:t.errorFactory);return i({code:e.code,message:e.msg},e.requestId?{requestId:e.requestId}:{})},e.promoteGatewayError=function(t){if(t&&"object"==typeof t&&t.data&&"object"==typeof t.data){var e=t.data,n=e.code,r=e.message;if(!t.code&&n||!t.message&&r)return i(i(i({},t),!t.code&&n?{code:n}:{}),!t.message&&r?{message:r}:{})}return t},e.errorToResult=function(t){if(t instanceof Error&&"string"==typeof t.message)try{var e=JSON.parse(t.message);if(e&&"string"==typeof e.code)return{code:e.code,message:e.msg||e.message||"",requestId:e.requestId}}catch(t){}return t&&"string"==typeof t.code?{code:t.code,message:t.message||"",requestId:t.requestId}:{code:"UNKNOWN_ERROR",message:String((null==t?void 0:t.message)||t||"")}},e.printGroupLog=function(t){var e,n=t.title,r=t.subtitle,o=void 0===r?"":r,i=t.content,a=void 0===i?[]:i,s=t.printTrace,c=void 0!==s&&s,u=t.collapsed;void 0!==u&&u?(console.groupCollapsed||console.error)(n,o):(console.group||console.error)(n,o);for(var l=0,f=a;l<f.length;l++){var d=f[l],p=d.type,h=d.body;switch(p){case"info":console.log(h);break;case"warn":console.warn(h);break;case"error":console.error(h)}}c&&(console.trace||console.log)("stack trace:"),null===(e=console.groupEnd)||void 0===e||e.call(console)},e.sleep=function(t){return void 0===t&&(t=0),new Promise(function(e){return setTimeout(e,t)})},e.transformPhone=function(t){return"+86".concat(t)},e.parseQueryString=function(t){t=t.replace(/^\?/,"");var e={};return t.split("&").forEach(function(t){var n=t.split("="),r=n[0],o=n[1];r=decodeURIComponent(r),o=decodeURIComponent(o),r&&(e[r]?Array.isArray(e[r])?e[r].push(o):e[r]=[e[r],o]:e[r]=o)}),e},e.parseCaptcha=function(t){var n={},r=t.match(/^(data:.*?)(\?[^#\s]*)?$/);if(r){t=r[1];var o=r[2];o&&(n=(0,e.parseQueryString)(o))}var i=n.token,s=a(n,["token"]);return/^data:/.test(t)&&!i?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(t)}:i?{state:s.state,token:i,captchaData:t}:{error:"unimplemented",error_description:"need to impl captcha data"}}},954:function(t,e,n){n.r(e),n.d(e,{CollectionReference:function(){return se},Db:function(){return Oe},DocumentReference:function(){return Kt},Query:function(){return re}});var r,o,i={};n.r(i),n.d(i,{LineString:function(){return B},MultiLineString:function(){return z},MultiPoint:function(){return V},MultiPolygon:function(){return X},Point:function(){return wt},Polygon:function(){return H}}),function(t){t.DocIDError="文档ID不合法",t.CollNameError="集合名称不合法",t.OpStrError="操作符不合法",t.DirectionError="排序字符不合法",t.IntergerError="must be integer",t.BooleanError="must be boolean",t.ArrayError="must be array",t.QueryParamTypeError="查询参数必须为对象",t.QueryParamValueError="查询参数对象值不能均为undefined",t.CentersPhereError="centersPhere结构不合法"}(o||(o={}));var a,s,c="Object",u="GeoPoint",l="GeoLineString",f="GeoPolygon",d="GeoMultiPoint",p="GeoMultiLineString",h="GeoMultiPolygon",y="Date",v="ServerDate",m=["desc","asc"],b=["<","<=","==",">=",">"];!function(t){t.lt="<",t.gt=">",t.lte="<=",t.gte=">=",t.eq="=="}(a||(a={})),(r={})[a.eq]="$eq",r[a.lt]="$lt",r[a.lte]="$lte",r[a.gt]="$gt",r[a.gte]="$gte",function(t){t.WHERE="WHERE",t.DOC="DOC"}(s||(s={}));var g,w=(g=function(t,e){return g=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},g(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}g(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),_=[],O={},E=function(t){function e(e,n){if(n!==O)throw new TypeError("InternalSymbol cannot be constructed with new operator");return t.call(this,e)||this}return w(e,t),e.for=function(t){for(var n=0,r=_.length;n<r;n++)if(_[n].target===t)return _[n].instance;var o=new e(t,O);return _.push({target:t,instance:o}),o},e}(function(t){Object.defineProperties(this,{target:{enumerable:!1,writable:!1,configurable:!1,value:t}})}),S=E,I=S.for("UNSET_FIELD_NAME"),N=S.for("UPDATE_COMMAND"),P=S.for("QUERY_COMMAND"),T=S.for("LOGIC_COMMAND"),j=S.for("GEO_POINT"),x=S.for("SYMBOL_GEO_LINE_STRING"),A=S.for("SYMBOL_GEO_POLYGON"),R=S.for("SYMBOL_GEO_MULTI_POINT"),C=S.for("SYMBOL_GEO_MULTI_LINE_STRING"),q=S.for("SYMBOL_GEO_MULTI_POLYGON"),D=S.for("SERVER_DATE"),L=S.for("REGEXP"),M=S.for("OBJECTID"),k=function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},U=function(t){return"object"===k(t)},J=function(t){return"number"===k(t)},$=function(t){return Array.isArray(t)},G=function(t){return"date"===k(t)},F=function(t){return"regexp"===k(t)},W=function(t){return t&&t._internalType instanceof E},B=function(){function t(t){if(!$(t))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof t));if(t.length<2)throw new Error('"points" must contain 2 points at least');t.forEach(function(t){if(!(t instanceof wt))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof t,"[]"))}),this.points=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"LineString",coordinates:this.points.map(function(t){return t.toJSON().coordinates})},e},t.prototype.toJSON=function(){return{type:"LineString",coordinates:this.points.map(function(t){return t.toJSON().coordinates})}},t.validate=function(t){var e,n;if("LineString"!==t.type||!$(t.coordinates))return!1;try{for(var r=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(t.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!J(i[0])||!J(i[1]))return!1}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return!0},t.isClosed=function(t){var e=t.points[0],n=t.points[t.points.length-1];if(e.latitude===n.latitude&&e.longitude===n.longitude)return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return x},enumerable:!1,configurable:!0}),t}(),Q=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},H=function(){function t(t){if(!$(t))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof t));if(0===t.length)throw new Error("Polygon must contain 1 linestring at least");t.forEach(function(t){if(!(t instanceof B))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof t,"[]"));if(!B.isClosed(t))throw new Error("LineString ".concat(t.points.map(function(t){return t.toReadableString()})," is not a closed cycle"))}),this.lines=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"Polygon",coordinates:this.lines.map(function(t){return t.points.map(function(t){return[t.longitude,t.latitude]})})},e},t.prototype.toJSON=function(){return{type:"Polygon",coordinates:this.lines.map(function(t){return t.points.map(function(t){return[t.longitude,t.latitude]})})}},t.validate=function(t){var e,n,r,o;if("Polygon"!==t.type||!$(t.coordinates))return!1;try{for(var i=Q(t.coordinates),a=i.next();!a.done;a=i.next()){var s=a.value;if(!this.isCloseLineString(s))return!1;try{for(var c=(r=void 0,Q(s)),u=c.next();!u.done;u=c.next()){var l=u.value;if(!J(l[0])||!J(l[1]))return!1}}catch(t){r={error:t}}finally{try{u&&!u.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return!0},t.isCloseLineString=function(t){var e=t[0],n=t[t.length-1];return e[0]===n[0]&&e[1]===n[1]},Object.defineProperty(t.prototype,"_internalType",{get:function(){return A},enumerable:!1,configurable:!0}),t}(),V=function(){function t(t){if(!$(t))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof t));if(0===t.length)throw new Error('"points" must contain 1 point at least');t.forEach(function(t){if(!(t instanceof wt))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof t,"[]"))}),this.points=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"MultiPoint",coordinates:this.points.map(function(t){return t.toJSON().coordinates})},e},t.prototype.toJSON=function(){return{type:"MultiPoint",coordinates:this.points.map(function(t){return t.toJSON().coordinates})}},t.validate=function(t){var e,n;if("MultiPoint"!==t.type||!$(t.coordinates))return!1;try{for(var r=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(t.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!J(i[0])||!J(i[1]))return!1}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return R},enumerable:!1,configurable:!0}),t}(),Y=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},z=function(){function t(t){if(!$(t))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof t));if(0===t.length)throw new Error("Polygon must contain 1 linestring at least");t.forEach(function(t){if(!(t instanceof B))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof t,"[]"))}),this.lines=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"MultiLineString",coordinates:this.lines.map(function(t){return t.points.map(function(t){return[t.longitude,t.latitude]})})},e},t.prototype.toJSON=function(){return{type:"MultiLineString",coordinates:this.lines.map(function(t){return t.points.map(function(t){return[t.longitude,t.latitude]})})}},t.validate=function(t){var e,n,r,o;if("MultiLineString"!==t.type||!$(t.coordinates))return!1;try{for(var i=Y(t.coordinates),a=i.next();!a.done;a=i.next()){var s=a.value;try{for(var c=(r=void 0,Y(s)),u=c.next();!u.done;u=c.next()){var l=u.value;if(!J(l[0])||!J(l[1]))return!1}}catch(t){r={error:t}}finally{try{u&&!u.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return C},enumerable:!1,configurable:!0}),t}(),K=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},X=function(){function t(t){var e,n;if(!$(t))throw new TypeError('"polygons" must be of type Polygon[]. Received type '.concat(typeof t));if(0===t.length)throw new Error("MultiPolygon must contain 1 polygon at least");try{for(var r=K(t),o=r.next();!o.done;o=r.next()){var i=o.value;if(!(i instanceof H))throw new TypeError('"polygon" must be of type Polygon[]. Received type '.concat(typeof i,"[]"))}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}this.polygons=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"MultiPolygon",coordinates:this.polygons.map(function(t){return t.lines.map(function(t){return t.points.map(function(t){return[t.longitude,t.latitude]})})})},e},t.prototype.toJSON=function(){return{type:"MultiPolygon",coordinates:this.polygons.map(function(t){return t.lines.map(function(t){return t.points.map(function(t){return[t.longitude,t.latitude]})})})}},t.validate=function(t){var e,n,r,o,i,a;if("MultiPolygon"!==t.type||!$(t.coordinates))return!1;try{for(var s=K(t.coordinates),c=s.next();!c.done;c=s.next()){var u=c.value;try{for(var l=(r=void 0,K(u)),f=l.next();!f.done;f=l.next()){var d=f.value;try{for(var p=(i=void 0,K(d)),h=p.next();!h.done;h=p.next()){var y=h.value;if(!J(y[0])||!J(y[1]))return!1}}catch(t){i={error:t}}finally{try{h&&!h.done&&(a=p.return)&&a.call(p)}finally{if(i)throw i.error}}}}catch(t){r={error:t}}finally{try{f&&!f.done&&(o=l.return)&&o.call(l)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{c&&!c.done&&(n=s.return)&&n.call(s)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return q},enumerable:!1,configurable:!0}),t}(),Z=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a},tt=function(){function t(){}return t.formatResDocumentData=function(e){return e.map(function(e){return t.formatField(e)})},t.formatField=function(e){var n=Object.keys(e),r={};return Array.isArray(e)&&(r=[]),n.forEach(function(n){var o,i=e[n];switch(t.whichType(i)){case u:o=new wt(i.coordinates[0],i.coordinates[1]);break;case l:o=new B(i.coordinates.map(function(t){return new wt(t[0],t[1])}));break;case f:o=new H(i.coordinates.map(function(t){return new B(t.map(function(t){var e=Z(t,2),n=e[0],r=e[1];return new wt(n,r)}))}));break;case d:o=new V(i.coordinates.map(function(t){return new wt(t[0],t[1])}));break;case p:o=new z(i.coordinates.map(function(t){return new B(t.map(function(t){var e=Z(t,2),n=e[0],r=e[1];return new wt(n,r)}))}));break;case h:o=new X(i.coordinates.map(function(t){return new H(t.map(function(t){return new B(t.map(function(t){var e=Z(t,2),n=e[0],r=e[1];return new wt(n,r)}))}))}));break;case y:o=i;break;case c:case"Array":o=t.formatField(i);break;case v:o=new Date(i.$date);break;default:o=i}Array.isArray(r)?r.push(o):r[n]=o}),r},t.whichType=function(t){var e=Object.prototype.toString.call(t).slice(8,-1);return e===y?y:(e===c&&(t.$date?e=v:wt.validate(t)?e=u:B.validate(t)?e=l:H.validate(t)?e=f:V.validate(t)?e=d:z.validate(t)?e=p:X.validate(t)&&(e=h)),e)},t.generateDocId=function(){for(var t="",e=0;e<24;e++)t+="ABCDEFabcdef0123456789".charAt(Math.floor(22*Math.random()));return t},t}(),et={code:"INVALID_PARAM",message:"Invalid request param"},nt="DATABASE_TRANSACTION_CONFLICT",rt={code:"DATABASE_REQUEST_FAILED",message:"database request failed"},ot=n(701),it=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),at=function(){return at=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},at.apply(this,arguments)};function st(t,e){if("function"!=typeof e)return t;t.then(function(t){return e(0,t)},function(t){return e(t)})}var ct={};function ut(t){if(!Oe.wsClientClass)throw new Error("to use realtime you must import realtime module first");var e=t.config.env;return ct[e]||(ct[e]=new Oe.wsClientClass({context:{appConfig:{docSizeLimit:1e3,realtimePingInterval:1e4,realtimePongWaitTimeout:5e3,request:Oe.createRequest(t.config)}}})),ct[e]}var lt=function(t){return void 0!==t.timeout?{timeout:t.timeout}:{}},ft=function(t){if(!U(t))return t;for(var e in t)void 0===t[e]?delete t[e]:U(t[e])&&(t[e]=ft(t[e]));return t},dt=function(t){return t=ft(t),ot.EJSON.stringify(t,{relaxed:!1})},pt=function(t){function e(e){var n=t.call(this,e.message)||this;return n.code=e.code,n.message=e.message,n}return it(e,t),e}(Error),ht=function(t){return new pt(t)};function yt(t,e){if(!1===t)return e;throw ht(at({},e))}var vt,mt=function(){return mt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},mt.apply(this,arguments)},bt=["limit","offset","projection","order","multiple","timeout","raw"],gt=function(){function t(){}return t.isGeopoint=function(t,e){if("Number"!==tt.whichType(e))throw new Error("Geo Point must be number type");var n=Math.abs(e);if("latitude"===t&&n>90)throw new Error("latitude should be a number ranges from -90 to 90");if("longitude"===t&&n>180)throw new Error("longitude should be a number ranges from -180 to 180");return!0},t.isInteger=function(t,e){if(!Number.isInteger(e))throw new Error(t+o.IntergerError);return!0},t.mustBeBoolean=function(t,e){if("boolean"!=typeof e)throw new Error(t+o.BooleanError);return!0},t.isProjection=function(t,e){if("object"!==k(e))throw ht(mt(mt({},et),{message:"".concat(t," projection must be an object")}));for(var n in e){var r=e[n];if("number"===k(r)){if(0!==r&&1!==r)throw ht(mt(mt({},et),{message:"if the value in projection is of number, it must be 0 or 1"}))}else if("object"!==k(r))throw ht(mt(mt({},et),{message:"invalid projection"}))}return!0},t.isOrder=function(t,e){if("object"!==k(e))throw ht(mt(mt({},et),{message:"".concat(t," order must be an object")}));for(var n in e){var r=e[n];if(1!==r&&-1!==r)throw ht(mt(mt({},et),{message:"order value must be 1 or -1"}))}return!0},t.isFieldOrder=function(t){if(-1===m.indexOf(t))throw new Error(o.DirectionError);return!0},t.isFieldPath=function(t){if(!/^[a-zA-Z0-9-_\.]/.test(t))throw new Error;return!0},t.isOperator=function(t){if(-1===b.indexOf(t))throw new Error(o.OpStrError);return!0},t.isCollName=function(t){if(!/^[a-zA-Z0-9]([a-zA-Z0-9-_]){1,32}$/.test(t))throw new Error(o.CollNameError);return!0},t.isDocID=function(t){if(!/^([a-fA-F0-9]){24}$/.test(t))throw new Error(o.DocIDError);return!0},t.isValidOptions=function(e){if(void 0===e&&(e={}),"object"!==k(e))throw ht(mt(mt({},et),{message:"options must be an object"}));var n=Object.keys(e);for(var r in n)if(bt.indexOf(n[r])<0)throw ht(mt(mt({},et),{message:"".concat(n[r]," is invalid options key")}));var o=e,i=o.limit,a=o.offset,s=o.projection,c=o.order,u=e.multiple;return void 0!==i&&t.isInteger("limit",i),void 0!==a&&t.isInteger("offset",a),void 0!==s&&t.isProjection("projection",s),void 0!==c&&t.isOrder("order",c),void 0!==u&&t.mustBeBoolean("multiple",u),void 0!==e.timeout&&t.isInteger("timeout",e.timeout),!0},t.isValidAggregation=function(t){if(1!==Object.keys(t).length)throw ht(mt(mt({},et),{message:"aggregation stage must have one key"}));return!0},t.isCentersPhere=function(e){if(Array.isArray(e)&&2===e.length){if("object"===k(e[0])&&e[0]._internalType===j&&"number"==typeof e[1])return!0;if(Array.isArray(e[0])&&2===e[0].length){var n=e[0][0],r=e[0][1];if(t.isGeopoint("longitude",n),t.isGeopoint("latitude",r),"number"==typeof e[1])return!0}}throw new Error("".concat(o.CentersPhereError))},t}(),wt=function(){function t(t,e){gt.isGeopoint("longitude",t),gt.isGeopoint("latitude",e),this.longitude=t,this.latitude=e}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"Point",coordinates:[this.longitude,this.latitude]},e},t.prototype.toJSON=function(){return{type:"Point",coordinates:[this.longitude,this.latitude]}},t.prototype.toReadableString=function(){return"[".concat(this.longitude,",").concat(this.latitude,"]")},t.validate=function(t){return"Point"===t.type&&$(t.coordinates)&&gt.isGeopoint("longitude",t.coordinates[0])&&gt.isGeopoint("latitude",t.coordinates[1])},Object.defineProperty(t.prototype,"_internalType",{get:function(){return j},enumerable:!1,configurable:!0}),t}();!function(t){t.SET="set",t.REMOVE="remove",t.INC="inc",t.MUL="mul",t.PUSH="push",t.PULL="pull",t.PULL_ALL="pullAll",t.POP="pop",t.SHIFT="shift",t.UNSHIFT="unshift",t.ADD_TO_SET="addToSet",t.BIT="bit",t.RENAME="rename",t.MAX="max",t.MIN="min"}(vt||(vt={}));var _t,Ot=function(){function t(t,e,n){this._internalType=N,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=t,this.operands=e,this.fieldName=n||I}return t.prototype._setFieldName=function(e){return new t(this.operator,this.operands,e)},t}();function Et(t){return t&&t instanceof Ot&&t._internalType===N}!function(t){t.AND="and",t.OR="or",t.NOT="not",t.NOR="nor"}(_t||(_t={}));var St=function(){function t(t,e,n){if(this._internalType=T,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=t,this.operands=e,this.fieldName=n||I,this.fieldName!==I)if(Array.isArray(e)){e=e.slice(),this.operands=e;for(var r=0,o=e.length;r<o;r++)(It(i=e[r])||jt(i))&&(e[r]=i._setFieldName(this.fieldName))}else{var i;(It(i=e)||jt(i))&&(e=i._setFieldName(this.fieldName))}}return t.prototype._setFieldName=function(e){var n=this.operands.map(function(n){return n instanceof t?n._setFieldName(e):n});return new t(this.operator,n,e)},t.prototype.and=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return r.unshift(this),new t(_t.AND,r,this.fieldName)},t.prototype.or=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return r.unshift(this),new t(_t.OR,r,this.fieldName)},t}();function It(t){return t&&t instanceof St&&t._internalType===T}var Nt,Pt=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();!function(t){t.EQ="eq",t.NEQ="neq",t.GT="gt",t.GTE="gte",t.LT="lt",t.LTE="lte",t.IN="in",t.NIN="nin",t.ALL="all",t.ELEM_MATCH="elemMatch",t.EXISTS="exists",t.SIZE="size",t.MOD="mod",t.GEO_NEAR="geoNear",t.GEO_WITHIN="geoWithin",t.GEO_INTERSECTS="geoIntersects"}(Nt||(Nt={}));var Tt=function(t){function e(e,n,r){var o=t.call(this,e,n,r)||this;return o.operator=e,o._internalType=P,o}return Pt(e,t),e.prototype.toJSON=function(){var t,e,n;switch(this.operator){case Nt.IN:case Nt.NIN:return(t={})["$"+this.operator]=this.operands,t;case Nt.NEQ:return(e={}).$ne=this.operands[0],e;default:return(n={})["$"+this.operator]=this.operands[0],n}},e.prototype._setFieldName=function(t){return new e(this.operator,this.operands,t)},e.prototype.eq=function(t){var n=new e(Nt.EQ,[t],this.fieldName);return this.and(n)},e.prototype.neq=function(t){var n=new e(Nt.NEQ,[t],this.fieldName);return this.and(n)},e.prototype.gt=function(t){var n=new e(Nt.GT,[t],this.fieldName);return this.and(n)},e.prototype.gte=function(t){var n=new e(Nt.GTE,[t],this.fieldName);return this.and(n)},e.prototype.lt=function(t){var n=new e(Nt.LT,[t],this.fieldName);return this.and(n)},e.prototype.lte=function(t){var n=new e(Nt.LTE,[t],this.fieldName);return this.and(n)},e.prototype.in=function(t){var n=new e(Nt.IN,t,this.fieldName);return this.and(n)},e.prototype.nin=function(t){var n=new e(Nt.NIN,t,this.fieldName);return this.and(n)},e.prototype.geoNear=function(t){if(!(t.geometry instanceof wt))throw new TypeError('"geometry" must be of type Point. Received type '.concat(typeof t.geometry));if(void 0!==t.maxDistance&&!J(t.maxDistance))throw new TypeError('"maxDistance" must be of type Number. Received type '.concat(typeof t.maxDistance));if(void 0!==t.minDistance&&!J(t.minDistance))throw new TypeError('"minDistance" must be of type Number. Received type '.concat(typeof t.minDistance));var n=new e(Nt.GEO_NEAR,[t],this.fieldName);return this.and(n)},e.prototype.geoWithin=function(t){if(!(t.geometry instanceof X||t.geometry instanceof H||gt.isCentersPhere(t.centerSphere)))throw new TypeError('"geometry" must be of type Polygon or MultiPolygon. Received type '.concat(typeof t.geometry));var n=new e(Nt.GEO_WITHIN,[t],this.fieldName);return this.and(n)},e.prototype.geoIntersects=function(t){if(!(t.geometry instanceof wt||t.geometry instanceof B||t.geometry instanceof H||t.geometry instanceof V||t.geometry instanceof z||t.geometry instanceof X))throw new TypeError('"geometry" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type '.concat(typeof t.geometry));var n=new e(Nt.GEO_INTERSECTS,[t],this.fieldName);return this.and(n)},e}(St);function jt(t){return t&&t instanceof Tt&&t._internalType===P}function xt(t){return jt(t)}var At={};for(var Rt in Nt)At[Rt]="$"+Rt;for(var Rt in _t)At[Rt]="$"+Rt;for(var Rt in vt)At[Rt]="$"+Rt;function Ct(t){return At[t]||"$"+t}At[Nt.NEQ]="$ne",At[vt.REMOVE]="$unset",At[vt.SHIFT]="$pop",At[vt.UNSHIFT]="$push";var qt=function(){return qt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},qt.apply(this,arguments)},Dt=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a},Lt=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))};function Mt(t){return kt(t,[t])}function kt(t,e){if(!W(t)){if(G(t))return t;if(F(t))return{$regularExpression:{pattern:t.source,options:t.flags}};if($(t))return t.map(function(t){if(e.indexOf(t)>-1)throw new Error("Cannot convert circular structure to JSON");return kt(t,Lt(Lt([],Dt(e),!1),[t],!1))});if(U(t)){var n=qt({},t),r={};for(var o in n){if(e.indexOf(n[o])>-1)throw new Error("Cannot convert circular structure to JSON");void 0!==n[o]&&(r[o]=kt(n[o],Lt(Lt([],Dt(e),!1),[n[o]],!1)))}return r}return t}switch(t._internalType){case j:return t.toJSON();case D:case L:case M:return t.parse();default:return t.toJSON?t.toJSON():t}}var Ut=function(){return Ut=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Ut.apply(this,arguments)},Jt=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a},$t=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))};function Gt(t,e,n,r){var o=Ut({},t);for(var i in t)if(!/^\$/.test(i)){var a=t[i];if(void 0!==a){if(a&&U(a)&&!e(a)){if(r.indexOf(a)>-1)throw new Error("Cannot convert circular structure to JSON");var s=Gt(a,e,$t($t([],Jt(n),!1),[i],!1),$t($t([],Jt(r),!1),[a],!1));o[i]=s;var c=!1;for(var u in s)/^\$/.test(u)?c=!0:(o["".concat(i,".").concat(u)]=s[u],delete o[i][u]);c||delete o[i]}}else delete o[i]}return o}function Ft(t){return Gt(t,Bt,[],[t])}function Wt(t,e,n){for(var r in e[n]||delete t[n],e)t[r]?$(t[r])?t[r].push(e[r]):U(t[r])?U(e[r])?Object.assign(t[r],e[r]):(console.warn("unmergable condition, query is object but condition is ".concat(k(e),", can only overwrite"),e,n),t[r]=e[r]):(console.warn("to-merge query is of type ".concat(k(t),", can only overwrite"),t,e,n),t[r]=e[r]):t[r]=e[r]}function Bt(t){return W(t)||G(t)||F(t)}function Qt(t){return Mt(t)}var Ht=function(){function t(){}return t.encode=function(e){return(new t).encodeUpdate(e)},t.encodeEJSON=function(e,n){var r=new t;return dt(n?e:r.encodeUpdate(e))},t.prototype.encodeUpdate=function(t){return Et(t)?this.encodeUpdateCommand(t):"object"===k(t)?this.encodeUpdateObject(t):t},t.prototype.encodeUpdateCommand=function(t){if(t.fieldName===I)throw new Error("Cannot encode a comparison command with unset field name");switch(t.operator){case vt.PUSH:case vt.PULL:case vt.PULL_ALL:case vt.POP:case vt.SHIFT:case vt.UNSHIFT:case vt.ADD_TO_SET:return this.encodeArrayUpdateCommand(t);default:return this.encodeFieldUpdateCommand(t)}},t.prototype.encodeFieldUpdateCommand=function(t){var e,n,r,o,i=Ct(t.operator);return t.operator===vt.REMOVE?((e={})[i]=((n={})[t.fieldName]="",n),e):((r={})[i]=((o={})[t.fieldName]=t.operands[0],o),r)},t.prototype.encodeArrayUpdateCommand=function(t){var e,n,r,o,i,a,s,c,u,l,f=Ct(t.operator);switch(t.operator){case vt.PUSH:var d=void 0;return d=$(t.operands)?{$each:t.operands.map(Qt)}:t.operands,(e={})[f]=((n={})[t.fieldName]=d,n),e;case vt.UNSHIFT:return d={$each:t.operands.map(Qt),$position:0},(r={})[f]=((o={})[t.fieldName]=d,o),r;case vt.POP:return(i={})[f]=((a={})[t.fieldName]=1,a),i;case vt.SHIFT:return(s={})[f]=((c={})[t.fieldName]=-1,c),s;default:return(u={})[f]=((l={})[t.fieldName]=Qt(t.operands),l),u}},t.prototype.encodeUpdateObject=function(t){var e=Ft(t);for(var n in e)if(!/^\$/.test(n)){var r=e[n];if(Et(r))e[n]=r._setFieldName(n),Wt(e,this.encodeUpdateCommand(e[n]),n);else{e[n]=r=Qt(r);var o=new Ot(vt.SET,[r],n);Wt(e,this.encodeUpdateCommand(o),n)}}return e},t}(),Vt=function(){return Vt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Vt.apply(this,arguments)},Yt=function(t,e,n,r){return new(n||(n=Promise))(function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function s(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}c((r=r.apply(t,e||[])).next())})},zt=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},Kt=function(){function t(t,e,n,r,o){var i=this;this.watch=function(t){return ut(i._db).watch(Vt(Vt({},t),{envId:i._db.config.env,collectionName:i._coll,query:JSON.stringify({_id:i.id})}))},this._db=t,this._coll=e,this.id=r,this._transactionId=o,this.request=Oe.createRequest(this._db.config),this._apiOptions=n}return t.prototype.create=function(t,e){return st(this._create(t),e)},t.prototype._create=function(t){return Yt(this,void 0,void 0,function(){var e,n,r;return zt(this,function(o){switch(o.label){case 0:return!(e=Array.isArray(t))&&this.id&&(t._id=this.id),n={collectionName:this._coll,data:e?t.map(function(t){return dt(Mt(t))}):[dt(Mt(t))],transactionId:this._transactionId},[4,this.request.send("database.insertDocument",n,lt(this._apiOptions))];case 1:return(r=o.sent()).code?[2,r]:this._transactionId?[2,{inserted:1,ok:1,id:r.data.insertedIds[0],requestId:r.requestId}]:e?[2,{ids:r.data&&r.data.insertedIds||[],requestId:r.requestId}]:[2,{id:r.data.insertedIds[0],requestId:r.requestId}]}})})},t.prototype.set=function(t,e){return st(this._set(t),e)},t.prototype._set=function(t){return Yt(this,void 0,void 0,function(){var e,n,r,o;return zt(this,function(i){switch(i.label){case 0:return this.id?t&&"object"==typeof t?t.hasOwnProperty("_id")?[2,yt(this._db.config.throwOnCode,Vt(Vt({},et),{message:"不能更新_id的值"}))]:(e=!1,n=function(t){if("object"==typeof t)for(var r in t)t[r]instanceof Ot?e=!0:"object"==typeof t[r]&&n(t[r])},n(t),e?[2,yt(this._db.config.throwOnCode,Vt(Vt({},rt),{message:"update operator complicit"}))]:(r={collectionName:this._coll,queryType:s.DOC,data:dt(Mt(t)),transactionId:this._transactionId,multi:!1,merge:!1,upsert:!0},this.id&&(r.query=dt({_id:this.id})),[4,this.request.send("database.modifyDocument",r,lt(this._apiOptions))])):[2,yt(this._db.config.throwOnCode,Vt(Vt({},et),{message:"参数必需是非空对象"}))]:[2,yt(this._db.config.throwOnCode,Vt(Vt({},et),{message:"docId不能为空"}))];case 1:return(o=i.sent()).code?[2,o]:this._transactionId?[2,{updated:o.data.updated,upserted:[{_id:o.data.upsert_id}],requestId:o.requestId}]:[2,{updated:o.data.updated,upsertedId:o.data.upsert_id,requestId:o.requestId}]}})})},t.prototype.update=function(t,e){return st(this._update(t),e)},t.prototype._update=function(t){return Yt(this,void 0,void 0,function(){var e,n,r;return zt(this,function(o){switch(o.label){case 0:return t&&"object"==typeof t?t.hasOwnProperty("_id")?[2,yt(this._db.config.throwOnCode,Vt(Vt({},et),{message:"不能更新_id的值"}))]:(e=dt({_id:this.id}),n={collectionName:this._coll,transactionId:this._transactionId,data:Ht.encodeEJSON(t,this._apiOptions.raw||!1),query:e,queryType:s.DOC,multi:!1,merge:!0,upsert:!1},[4,this.request.send("database.modifyDocument",n,lt(this._apiOptions))]):[2,yt(this._db.config.throwOnCode,Vt(Vt({},et),{message:"参数必需是非空对象"}))];case 1:return(r=o.sent()).code?[2,r]:[2,{updated:r.data.updated,requestId:r.requestId}]}})})},t.prototype.delete=function(t){return this.remove(t)},t.prototype.remove=function(t){return st(this._remove(),t)},t.prototype._remove=function(){return Yt(this,void 0,void 0,function(){var t,e,n;return zt(this,function(r){switch(r.label){case 0:return t=dt({_id:this.id}),e={collectionName:this._coll,transactionId:this._transactionId,query:t,queryType:s.DOC,multi:!1},[4,this.request.send("database.removeDocument",e,lt(this._apiOptions))];case 1:return(n=r.sent()).code?[2,n]:[2,{deleted:n.data.deleted,requestId:n.requestId}]}})})},t.prototype.get=function(t){return st(this._get(),t)},t.prototype._get=function(){return Yt(this,void 0,void 0,function(){var t,e,n,r,o,i;return zt(this,function(a){switch(a.label){case 0:return t=dt({_id:this.id}),e=this._apiOptions.projection,n={collectionName:this._coll,query:t,transactionId:this._transactionId,queryType:s.DOC,multi:!1},e&&(n.projection=dt(e)),[4,this.request.send("database.getDocument",n,lt(this._apiOptions))];case 1:return(r=a.sent()).code?[2,r]:(o=r.data.list.map(function(t){return ot.EJSON.parse(t)}),i=tt.formatResDocumentData(o),this._transactionId?[2,{data:i[0]||null,requestId:r.requestId}]:[2,{data:i,requestId:r.requestId}])}})})},t.prototype.field=function(e){var n={};for(var r in e)"boolean"==typeof e[r]&&(n[r]=!0===e[r]?1:0),"number"==typeof e[r]&&(n[r]=e[r]>0?1:0),"object"==typeof e[r]&&(n[r]=e[r]);var o=Vt({},this._apiOptions);return o.projection=n,new t(this._db,this._coll,o,this.id,this._transactionId)},t}(),Xt=function(){function t(){}return t.encode=function(t){return(new Zt).encodeQuery(t)},t.encodeEJSON=function(t,e){var n=new Zt;return dt(e?t:n.encodeQuery(t))},t}(),Zt=function(){function t(){}return t.prototype.encodeQuery=function(t,e){var n,r,o;return Bt(t)?It(t)?this.encodeLogicCommand(t):jt(t)?this.encodeQueryCommand(t):F(t)?((n={})[e]=this.encodeRegExp(t),n):G(t)?((r={})[e]=Qt(t),r):((o={})[e]=this.encodeQueryObject(t),o):U(t)?this.encodeQueryObject(t):t},t.prototype.encodeRegExp=function(t){return{$regularExpression:{pattern:t.source,options:t.flags}}},t.prototype.encodeLogicCommand=function(t){var e,n,r,o,i,a,s,c=this;switch(t.operator){case _t.NOR:case _t.AND:case _t.OR:var u=Ct(t.operator),l=t.operands.map(function(e){return c.encodeQuery(e,t.fieldName)});return(e={})[u]=l,e;case _t.NOT:u=Ct(t.operator);var f=t.operands[0];return F(f)?((n={})[t.fieldName]=((r={})[u]=this.encodeRegExp(f),r),n):(l=this.encodeQuery(f)[t.fieldName],(o={})[t.fieldName]=((i={})[u]=l,i),o);default:if(u=Ct(t.operator),1===t.operands.length){var d=this.encodeQuery(t.operands[0]);return(a={})[u]=d,a}return l=t.operands.map(this.encodeQuery.bind(this)),(s={})[u]=l,s}},t.prototype.encodeQueryCommand=function(t){return xt(t),this.encodeComparisonCommand(t)},t.prototype.encodeComparisonCommand=function(t){var e,n,r,o,i,a,s,c,u,l,f;if(t.fieldName===I)throw new Error("Cannot encode a comparison command with unset field name");var d=Ct(t.operator);switch(t.operator){case Nt.EQ:case Nt.NEQ:case Nt.LT:case Nt.LTE:case Nt.GT:case Nt.GTE:case Nt.ELEM_MATCH:case Nt.EXISTS:case Nt.SIZE:case Nt.MOD:return(e={})[t.fieldName]=((n={})[d]=Qt(t.operands[0]),n),e;case Nt.IN:case Nt.NIN:case Nt.ALL:return(r={})[t.fieldName]=((o={})[d]=Qt(t.operands),o),r;case Nt.GEO_NEAR:var p=t.operands[0];return(i={})[t.fieldName]={$nearSphere:{$geometry:p.geometry.toJSON(),$maxDistance:p.maxDistance,$minDistance:p.minDistance}},i;case Nt.GEO_WITHIN:if((p=t.operands[0]).centerSphere){gt.isCentersPhere(p.centerSphere);var h=p.centerSphere;return h[0]._internalType===j?((a={})[t.fieldName]={$geoWithin:{$centerSphere:[h[0].toJSON().coordinates,h[1]]}},a):((s={})[t.fieldName]={$geoWithin:{$centerSphere:p.centerSphere}},s)}return(c={})[t.fieldName]={$geoWithin:{$geometry:p.geometry.toJSON()}},c;case Nt.GEO_INTERSECTS:return p=t.operands[0],(u={})[t.fieldName]={$geoIntersects:{$geometry:p.geometry.toJSON()}},u;default:return(l={})[t.fieldName]=((f={})[d]=Qt(t.operands[0]),f),l}},t.prototype.encodeQueryObject=function(t){var e=Ft(t);for(var n in e){var r=e[n];if(It(r)){e[n]=r._setFieldName(n);var o=this.encodeLogicCommand(e[n]);this.mergeConditionAfterEncode(e,o,n)}else xt(r)?(e[n]=r._setFieldName(n),o=this.encodeComparisonCommand(e[n]),this.mergeConditionAfterEncode(e,o,n)):Bt(r)&&(e[n]=Qt(r))}return e},t.prototype.mergeConditionAfterEncode=function(t,e,n){for(var r in e[n]||delete t[n],e)t[r]?$(t[r])?t[r]=t[r].concat(e[r]):U(t[r])?U(e[r])?Object.assign(t,e):(console.warn("unmergable condition, query is object but condition is ".concat(k(e),", can only overwrite"),e,n),t[r]=e[r]):(console.warn("to-merge query is of type ".concat(k(t),", can only overwrite"),t,e,n),t[r]=e[r]):t[r]=e[r]},t}(),te=function(){return te=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},te.apply(this,arguments)},ee=function(t,e,n,r){return new(n||(n=Promise))(function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function s(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}c((r=r.apply(t,e||[])).next())})},ne=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},re=function(){function t(t,e,n,r,o){var i=this;this.watch=function(t){var e=ut(i._db),n=i._apiOptions,r=n.limit,o=n.order;return e.watch(te(te({},t),{envId:i._db.config.env,collectionName:i._coll,query:JSON.stringify(i._fieldFilters),limit:r,orderBy:o?o.reduce(function(t,e){return t[e.field]=e.direction,t},{}):void 0}))},this._db=t,this._coll=e,this._fieldFilters=n,this._apiOptions=r||{},this._request=Oe.createRequest(this._db.config),this._transactionId=o}return t.prototype.get=function(t){return st(this._get(),t)},t.prototype._get=function(){return ee(this,void 0,void 0,function(){var t,e,n,r,o,i,a,c,u;return ne(this,function(l){switch(l.label){case 0:return t=this._apiOptions.order,e={collectionName:this._coll,queryType:s.WHERE,transactionId:this._transactionId},this._fieldFilters&&(e.query=this._fieldFilters),t&&(e.order=dt(t)),(n=this._apiOptions.offset)&&(e.offset=n),r=this._apiOptions.limit,e.limit=r?r<1e3?r:1e3:100,(o=this._apiOptions.projection)&&(e.projection=dt(o)),[4,this._request.send("database.getDocument",e,lt(this._apiOptions))];case 1:return(i=l.sent()).code?[2,i]:(a=i.data.list.map(function(t){return ot.EJSON.parse(t)}),c=tt.formatResDocumentData(a),u={data:c,requestId:i.requestId},i.total&&(u.total=i.total),i.limit&&(u.limit=i.limit),i.offset&&(u.offset=i.offset),[2,u])}})})},t.prototype.count=function(t){return st(this._count(),t)},t.prototype._count=function(){return ee(this,void 0,void 0,function(){var t,e;return ne(this,function(n){switch(n.label){case 0:return t={collectionName:this._coll,queryType:s.WHERE},this._fieldFilters&&(t.query=this._fieldFilters),[4,this._request.send("database.calculateDocument",t,lt(this._apiOptions))];case 1:return(e=n.sent()).code?[2,e]:[2,{requestId:e.requestId,total:e.data.total}]}})})},t.prototype.where=function(e){if("Object"!==Object.prototype.toString.call(e).slice(8,-1))throw Error(o.QueryParamTypeError);var n=Object.keys(e),r=n.some(function(t){return void 0!==e[t]});if(n.length&&!r)throw Error(o.QueryParamValueError);return new t(this._db,this._coll,Xt.encodeEJSON(e,this._apiOptions.raw||!1),this._apiOptions,this._transactionId)},t.prototype.options=function(e){return gt.isValidOptions(e),new t(this._db,this._coll,this._fieldFilters,e,this._transactionId)},t.prototype.orderBy=function(e,n){var r;gt.isFieldPath(e),gt.isFieldOrder(n);var o=((r={})[e]="desc"===n?-1:1,r),i=this._apiOptions.order||{},a=Object.assign({},this._apiOptions,{order:Object.assign({},i,o)});return new t(this._db,this._coll,this._fieldFilters,a,this._transactionId)},t.prototype.limit=function(e){gt.isInteger("limit",e);var n=te({},this._apiOptions);return n.limit=e,new t(this._db,this._coll,this._fieldFilters,n,this._transactionId)},t.prototype.skip=function(e){gt.isInteger("offset",e);var n=te({},this._apiOptions);return n.offset=e,new t(this._db,this._coll,this._fieldFilters,n,this._transactionId)},t.prototype.update=function(t,e){return st(this._update(t),e)},t.prototype._update=function(t){return ee(this,void 0,void 0,function(){var e,n,r,o;return ne(this,function(i){switch(i.label){case 0:return t&&"object"==typeof t?t.hasOwnProperty("_id")?[2,yt(this._db.config.throwOnCode,te(te({},et),{message:"不能更新_id的值"}))]:(e=this._apiOptions.multiple,n=void 0===e||e,r={collectionName:this._coll,queryType:s.WHERE,multi:n,merge:!0,upsert:!1,data:Ht.encodeEJSON(t,this._apiOptions.raw||!1)},this._transactionId&&(r.transactionId=this._transactionId),this._fieldFilters&&(r.query=this._fieldFilters),[4,this._request.send("database.modifyDocument",r,lt(this._apiOptions))]):[2,yt(this._db.config.throwOnCode,te(te({},et),{message:"参数必需是非空对象"}))];case 1:return(o=i.sent()).code?[2,o]:[2,{requestId:o.requestId,updated:o.data.updated,upsertId:o.data.upsert_id}]}})})},t.prototype.field=function(e){var n={};for(var r in e)"boolean"==typeof e[r]&&(n[r]=!0===e[r]?1:0),"number"==typeof e[r]&&(n[r]=e[r]>0?1:0),"object"==typeof e[r]&&(n[r]=e[r]);var o=te({},this._apiOptions);return o.projection=n,new t(this._db,this._coll,this._fieldFilters,o,this._transactionId)},t.prototype.remove=function(t){return st(this._remove(),t)},t.prototype._remove=function(){return ee(this,void 0,void 0,function(){var t,e,n,r,o,i,a,c,u;return ne(this,function(l){switch(l.label){case 0:return t=this._apiOptions,e=t.offset,n=t.limit,r=t.projection,o=t.order,void 0===e&&void 0===n&&void 0===r&&void 0===o||console.warn("`offset`, `limit`, `projection`, `orderBy` are not supported in remove() operation"),i=this._apiOptions.multiple,a=void 0===i||i,c={collectionName:this._coll,query:this._fieldFilters,queryType:s.WHERE,multi:a},this._transactionId&&(c.transactionId=this._transactionId),[4,this._request.send("database.removeDocument",c,lt(this._apiOptions))];case 1:return(u=l.sent()).code?[2,u]:[2,{requestId:u.requestId,deleted:u.data.deleted}]}})})},t.prototype.updateAndReturn=function(t){return ee(this,void 0,void 0,function(){var e,n;return ne(this,function(r){switch(r.label){case 0:return t&&"object"==typeof t?t.hasOwnProperty("_id")?[2,yt(this._db.config.throwOnCode,te(te({},et),{message:"不能更新_id的值"}))]:(e={collectionName:this._coll,queryType:s.WHERE,data:Ht.encodeEJSON(t,!1)},this._transactionId&&(e.transactionId=this._transactionId),this._fieldFilters&&(e.query=this._fieldFilters),[4,this._request.send("database.modifyAndReturnDoc",e,lt(this._apiOptions))]):[2,yt(this._db.config.throwOnCode,te(te({},et),{message:"参数必需是非空对象"}))];case 1:return(n=r.sent()).code?[2,n]:[2,{requestId:n.requestId,updated:n.data.updated,doc:n.data.doc&&ot.EJSON.parse(n.data.doc)}]}})})},t}(),oe=function(){function t(t,e,n){var r=this;this._stages=[],t&&e&&(this._db=t,this._request=Oe.createRequest(this._db.config),this._collectionName=e,n&&n.length>0&&n.forEach(function(t){gt.isValidAggregation(t);var e=Object.keys(t)[0];r._pipe(e,t[e],!0)}))}return t.prototype.end=function(){return t=this,e=void 0,r=function(){var t;return function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}(this,function(e){switch(e.label){case 0:if(!this._collectionName||!this._db)throw new Error("Aggregation pipeline cannot send request");return[4,this._request.send("database.aggregateDocuments",{collectionName:this._collectionName,stages:this._stages})];case 1:return(t=e.sent())&&t.data&&t.data.list?[2,{requestId:t.requestId,data:t.data.list.map(ot.EJSON.parse)}]:[2,t]}})},new((n=void 0)||(n=Promise))(function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function s(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}c((r=r.apply(t,e||[])).next())});var t,e,n,r},t.prototype.unwrap=function(){return this._stages},t.prototype.done=function(){return this._stages.map(function(t){var e,n=t.stageKey,r=t.stageValue;return(e={})[n]=JSON.parse(r),e})},t.prototype._pipe=function(t,e,n){void 0===n&&(n=!1);var r;return r="object"===k(e)?dt(e):JSON.stringify(e),this._stages.push({stageKey:n?t:"$".concat(t),stageValue:r}),this},t.prototype.addFields=function(t){return this._pipe("addFields",t)},t.prototype.bucket=function(t){return this._pipe("bucket",t)},t.prototype.bucketAuto=function(t){return this._pipe("bucketAuto",t)},t.prototype.count=function(t){return this._pipe("count",t)},t.prototype.geoNear=function(t){return t.query&&(t.query=Xt.encode(t.query)),t.distanceMultiplier&&"number"==typeof t.distanceMultiplier&&(t.distanceMultiplier=t.distanceMultiplier),t.near&&(t.near=new wt(t.near.longitude,t.near.latitude).toJSON()),this._pipe("geoNear",t)},t.prototype.group=function(t){return this._pipe("group",t)},t.prototype.limit=function(t){return this._pipe("limit",t)},t.prototype.match=function(t){return this._pipe("match",Xt.encode(t))},t.prototype.project=function(t){return this._pipe("project",t)},t.prototype.lookup=function(t){return this._pipe("lookup",t)},t.prototype.replaceRoot=function(t){return this._pipe("replaceRoot",t)},t.prototype.sample=function(t){return this._pipe("sample",t)},t.prototype.skip=function(t){return this._pipe("skip",t)},t.prototype.sort=function(t){return this._pipe("sort",t)},t.prototype.sortByCount=function(t){return this._pipe("sortByCount",t)},t.prototype.unwind=function(t){return this._pipe("unwind",t)},t}(),ie=oe,ae=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),se=function(t){function e(e,n,r,o){var i=t.call(this,e,n,"",r,o)||this;return o&&(i._transactionId=o),i}return ae(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return this._coll},enumerable:!1,configurable:!0}),e.prototype.doc=function(t){if("string"!=typeof t&&"number"!=typeof t)throw new Error("docId必须为字符串或数字");return new Kt(this._db,this._coll,this._apiOptions,t,this._transactionId)},e.prototype.add=function(t,e){return st(this._add(t),e)},e.prototype._add=function(t){return e=this,n=void 0,o=function(){var e,n,r;return function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}(this,function(o){switch(o.label){case 0:return e=t,$(t)||(e=[t]),e=e.map(function(t){return dt(Mt(t))}),n={collectionName:this._coll,data:e},this._transactionId&&(n.transactionId=this._transactionId),[4,this._request.send("database.insertDocument",n,lt(this._apiOptions))];case 1:return(r=o.sent()).code?[2,r]:$(t)?[2,{ids:r.data.insertedIds,requestId:r.requestId}]:this._transactionId?[2,{inserted:1,ok:1,id:r.data.insertedIds[0],requestId:r.requestId}]:[2,{id:r.data.insertedIds[0],requestId:r.requestId}]}})},new((r=void 0)||(r=Promise))(function(t,i){function a(t){try{c(o.next(t))}catch(t){i(t)}}function s(t){try{c(o.throw(t))}catch(t){i(t)}}function c(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r(function(t){t(n)})).then(a,s)}c((o=o.apply(e,n||[])).next())});var e,n,r,o},e.prototype.aggregate=function(t){return void 0===t&&(t=[]),new ie(this._db,this._coll,this._apiOptions.raw?t:[])},e.prototype.options=function(t){return gt.isValidOptions(t),new e(this._db,this._coll,t,this._transactionId)},e}(re),ce={eq:function(t){return new Tt(Nt.EQ,[t])},neq:function(t){return new Tt(Nt.NEQ,[t])},lt:function(t){return new Tt(Nt.LT,[t])},lte:function(t){return new Tt(Nt.LTE,[t])},gt:function(t){return new Tt(Nt.GT,[t])},gte:function(t){return new Tt(Nt.GTE,[t])},in:function(t){return new Tt(Nt.IN,t)},nin:function(t){return new Tt(Nt.NIN,t)},all:function(t){return new Tt(Nt.ALL,t)},elemMatch:function(t){return new Tt(Nt.ELEM_MATCH,[t])},exists:function(t){return new Tt(Nt.EXISTS,[t])},size:function(t){return new Tt(Nt.SIZE,[t])},mod:function(){return new Tt(Nt.MOD,1==arguments.length?[arguments[0]]:2==arguments.length?[[arguments[0],arguments[1]]]:arguments)},geoNear:function(t){return new Tt(Nt.GEO_NEAR,[t])},geoWithin:function(t){return new Tt(Nt.GEO_WITHIN,[t])},geoIntersects:function(t){return new Tt(Nt.GEO_INTERSECTS,[t])},and:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=$(arguments[0])?arguments[0]:Array.from(arguments);return new St(_t.AND,n)},nor:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=$(arguments[0])?arguments[0]:Array.from(arguments);return new St(_t.NOR,n)},or:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=$(arguments[0])?arguments[0]:Array.from(arguments);return new St(_t.OR,n)},not:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=$(arguments[0])?arguments[0]:Array.from(arguments);return new St(_t.NOT,n)},set:function(t){return new Ot(vt.SET,[t])},remove:function(){return new Ot(vt.REMOVE,[])},inc:function(t){return new Ot(vt.INC,[t])},mul:function(t){return new Ot(vt.MUL,[t])},push:function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(U(e[0])&&e[0].hasOwnProperty("each")){t={};var r=e[0];void 0!==r.each&&(t.$each=r.each),void 0!==r.position&&(t.$position=r.position),void 0!==r.sort&&(t.$sort=r.sort),void 0!==r.slice&&(t.$slice=r.slice)}else t=$(e[0])?e[0]:Array.from(e);return new Ot(vt.PUSH,t)},pull:function(t){return new Ot(vt.PULL,t)},pullAll:function(t){return new Ot(vt.PULL_ALL,t)},pop:function(){return new Ot(vt.POP,[])},shift:function(){return new Ot(vt.SHIFT,[])},unshift:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=$(arguments[0])?arguments[0]:Array.from(arguments);return new Ot(vt.UNSHIFT,n)},addToSet:function(t){return new Ot(vt.ADD_TO_SET,t)},rename:function(t){return new Ot(vt.RENAME,[t])},bit:function(t){return new Ot(vt.BIT,[t])},max:function(t){return new Ot(vt.MAX,[t])},min:function(t){return new Ot(vt.MIN,[t])},expr:function(t){return{$expr:t}},jsonSchema:function(t){return{$jsonSchema:t}},text:function(t){return"string"===k(t)?{$search:t.search}:{$search:t.search,$language:t.language,$caseSensitive:t.caseSensitive,$diacriticSensitive:t.diacriticSensitive}},aggregate:{pipeline:function(){return new ie},abs:function(t){return new ue("abs",t)},add:function(t){return new ue("add",t)},ceil:function(t){return new ue("ceil",t)},divide:function(t){return new ue("divide",t)},exp:function(t){return new ue("exp",t)},floor:function(t){return new ue("floor",t)},ln:function(t){return new ue("ln",t)},log:function(t){return new ue("log",t)},log10:function(t){return new ue("log10",t)},mod:function(t){return new ue("mod",t)},multiply:function(t){return new ue("multiply",t)},pow:function(t){return new ue("pow",t)},sqrt:function(t){return new ue("sqrt",t)},subtract:function(t){return new ue("subtract",t)},trunc:function(t){return new ue("trunc",t)},arrayElemAt:function(t){return new ue("arrayElemAt",t)},arrayToObject:function(t){return new ue("arrayToObject",t)},concatArrays:function(t){return new ue("concatArrays",t)},filter:function(t){return new ue("filter",t)},in:function(t){return new ue("in",t)},indexOfArray:function(t){return new ue("indexOfArray",t)},isArray:function(t){return new ue("isArray",t)},map:function(t){return new ue("map",t)},range:function(t){return new ue("range",t)},reduce:function(t){return new ue("reduce",t)},reverseArray:function(t){return new ue("reverseArray",t)},size:function(t){return new ue("size",t)},slice:function(t){return new ue("slice",t)},zip:function(t){return new ue("zip",t)},and:function(t){return new ue("and",t)},not:function(t){return new ue("not",t)},or:function(t){return new ue("or",t)},cmp:function(t){return new ue("cmp",t)},eq:function(t){return new ue("eq",t)},gt:function(t){return new ue("gt",t)},gte:function(t){return new ue("gte",t)},lt:function(t){return new ue("lt",t)},lte:function(t){return new ue("lte",t)},neq:function(t){return new ue("ne",t)},cond:function(t){return new ue("cond",t)},ifNull:function(t){return new ue("ifNull",t)},switch:function(t){return new ue("switch",t)},dateFromParts:function(t){return new ue("dateFromParts",t)},dateFromString:function(t){return new ue("dateFromString",t)},dayOfMonth:function(t){return new ue("dayOfMonth",t)},dayOfWeek:function(t){return new ue("dayOfWeek",t)},dayOfYear:function(t){return new ue("dayOfYear",t)},isoDayOfWeek:function(t){return new ue("isoDayOfWeek",t)},isoWeek:function(t){return new ue("isoWeek",t)},isoWeekYear:function(t){return new ue("isoWeekYear",t)},millisecond:function(t){return new ue("millisecond",t)},minute:function(t){return new ue("minute",t)},month:function(t){return new ue("month",t)},second:function(t){return new ue("second",t)},hour:function(t){return new ue("hour",t)},week:function(t){return new ue("week",t)},year:function(t){return new ue("year",t)},literal:function(t){return new ue("literal",t)},mergeObjects:function(t){return new ue("mergeObjects",t)},objectToArray:function(t){return new ue("objectToArray",t)},allElementsTrue:function(t){return new ue("allElementsTrue",t)},anyElementTrue:function(t){return new ue("anyElementTrue",t)},setDifference:function(t){return new ue("setDifference",t)},setEquals:function(t){return new ue("setEquals",t)},setIntersection:function(t){return new ue("setIntersection",t)},setIsSubset:function(t){return new ue("setIsSubset",t)},setUnion:function(t){return new ue("setUnion",t)},concat:function(t){return new ue("concat",t)},dateToString:function(t){return new ue("dateToString",t)},indexOfBytes:function(t){return new ue("indexOfBytes",t)},indexOfCP:function(t){return new ue("indexOfCP",t)},split:function(t){return new ue("split",t)},strLenBytes:function(t){return new ue("strLenBytes",t)},strLenCP:function(t){return new ue("strLenCP",t)},strcasecmp:function(t){return new ue("strcasecmp",t)},substr:function(t){return new ue("substr",t)},substrBytes:function(t){return new ue("substrBytes",t)},substrCP:function(t){return new ue("substrCP",t)},toLower:function(t){return new ue("toLower",t)},toUpper:function(t){return new ue("toUpper",t)},meta:function(t){return new ue("meta",t)},addToSet:function(t){return new ue("addToSet",t)},avg:function(t){return new ue("avg",t)},first:function(t){return new ue("first",t)},last:function(t){return new ue("last",t)},max:function(t){return new ue("max",t)},min:function(t){return new ue("min",t)},push:function(t){return new ue("push",t)},stdDevPop:function(t){return new ue("stdDevPop",t)},stdDevSamp:function(t){return new ue("stdDevSamp",t)},sum:function(t){return new ue("sum",t)},let:function(t){return new ue("let",t)}},project:{slice:function(t){return new le("slice",t)},elemMatch:function(t){return new le("elemMatch",t)}}},ue=function(t,e){this["$"+t]=e},le=function(t,e){this["$"+t]=e},fe=function(){function t(t){var e=(void 0===t?{}:t).offset,n=void 0===e?0:e;this.offset=n}return Object.defineProperty(t.prototype,"_internalType",{get:function(){return D},enumerable:!1,configurable:!0}),t.prototype.parse=function(){return{$tcb_server_date:{offset:this.offset}}},t}();function de(t){return new fe(t)}var pe=function(){function t(t){var e=t.regexp,n=t.options;if(!e)throw new TypeError("regexp must be a string");this.$regularExpression={pattern:e||"",options:n||""}}return t.prototype.parse=function(){return{$regularExpression:{pattern:this.$regularExpression.pattern,options:this.$regularExpression.options}}},Object.defineProperty(t.prototype,"_internalType",{get:function(){return L},enumerable:!1,configurable:!0}),t}();function he(t){return new pe(t)}var ye=function(t,e,n,r){return new(n||(n=Promise))(function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function s(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}c((r=r.apply(t,e||[])).next())})},ve=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},me=function(){function t(t){this._db=t,this._request=Oe.createRequest(this._db.config),this.aborted=!1,this.commited=!1,this.inited=!1}return t.prototype.init=function(){return ye(this,void 0,void 0,function(){var t;return ve(this,function(e){switch(e.label){case 0:return[4,this._request.send("database.startTransaction")];case 1:if((t=e.sent()).code)throw t;return this.inited=!0,this._id=t.transactionId,[2]}})})},t.prototype.collection=function(t){if(!t)throw new Error("Collection name is required");return new se(this._db,t,{},this._id)},t.prototype.getTransactionId=function(){return this._id},t.prototype.getRequestMethod=function(){return this._request},t.prototype.commit=function(){return ye(this,void 0,void 0,function(){var t,e;return ve(this,function(n){switch(n.label){case 0:return t={transactionId:this._id},[4,this._request.send("database.commitTransaction",t)];case 1:if((e=n.sent()).code)throw e;return this.commited=!0,[2,e]}})})},t.prototype.rollback=function(t){return ye(this,void 0,void 0,function(){var e,n;return ve(this,function(r){switch(r.label){case 0:return e={transactionId:this._id},[4,this._request.send("database.abortTransaction",e)];case 1:if((n=r.sent()).code)throw n;return this.aborted=!0,this.abortReason=t,[2,n]}})})},t}();function be(){return ye(this,void 0,void 0,function(){var t;return ve(this,function(e){switch(e.label){case 0:return[4,(t=new me(this)).init()];case 1:return e.sent(),[2,t]}})})}function ge(t,e){return void 0===e&&(e=3),ye(this,void 0,void 0,function(){var n,r,o,i,a=this;return ve(this,function(s){switch(s.label){case 0:return s.trys.push([0,4,,10]),[4,(n=new me(this)).init()];case 1:return s.sent(),[4,t(n)];case 2:if(r=s.sent(),!0===n.aborted)throw n.abortReason;return[4,n.commit()];case 3:return s.sent(),[2,r];case 4:if(o=s.sent(),!1===n.inited)throw o;return i=function(t){return ye(a,void 0,void 0,function(){return ve(this,function(e){switch(e.label){case 0:if(n.aborted||n.commited)return[3,5];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,n.rollback()];case 2:case 3:return e.sent(),[3,4];case 4:throw t;case 5:if(!0===n.aborted)throw n.abortReason;throw t}})})},e<=0?[4,i(o)]:[3,6];case 5:s.sent(),s.label=6;case 6:return o&&o.code===nt?[4,ge.bind(this)(t,--e)]:[3,8];case 7:return[2,s.sent()];case 8:return[4,i(o)];case 9:return s.sent(),[3,10];case 10:return[2]}})})}var we=function(){function t(t){var e=(void 0===t?{}:t).id,n=void 0===e?"":e;this.id=n}return Object.defineProperty(t.prototype,"_internalType",{get:function(){return M},enumerable:!1,configurable:!0}),t.prototype.parse=function(){return{$oid:this.id}},t}();function _e(t){return new we(t)}var Oe=function(){function t(t){this.config=t,this.Geo=i,this.serverDate=de,this.command=ce,this.RegExp=he,this.ObjectId=_e,this.startTransaction=be,this.runTransaction=ge,this.logicCommand=St,this.updateCommand=Ot,this.queryCommand=Tt}return t.createRequest=function(e){var n=new t.reqClass(e),r=n.send;return n.send=function(t,n){for(var o=[],i=2;i<arguments.length;i++)o[i-2]=arguments[i];return n&&(e.instance&&(n.instance=e.instance),e.database&&(n.database=e.database)),r.call.apply(r,function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}([this,t,n],function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}(o),!1))},n},t.prototype.collection=function(t){if(!t)throw new Error("Collection name is required");return new se(this,t)},t.prototype.createCollection=function(e){var n={collectionName:e};return t.createRequest(this.config).send("database.addCollection",n)},t}()},764:function(t){t.exports=require("@cloudbase/adapter-interface")},701:function(t){t.exports=require("bson")},107:function(t){t.exports=require("jwt-decode")}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return t[r].call(i.exports,i,i.exports,n),i.exports}n.d=function(t,e){for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r=n(198);module.exports=r}();
1
+ !function(){"use strict";var t={198:function(t,e,n){var r,o=this&&this.__extends||(r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},r(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__assign||function(){return i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},i.apply(this,arguments)},a=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function c(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,c)}u((r=r.apply(t,e||[])).next())})},c=this&&this.__generator||function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=e.call(t,a)}catch(t){c=[6,t],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.registerDatabase=e.gateWayFunc=void 0;var u=n(954),s=n(701),l=n(877);e.gateWayFunc={filterRes:function(t){return delete(t=l.utils.promoteGatewayError(t)).header,delete t.statusCode,t},flattenResData:function(t){if("object"==typeof t.data&&null!==t.data){var e=i(i({},t),t.data);return delete e.data,e}return t},safeParseEJSON:function(t){if("string"!=typeof t)return t;try{return s.EJSON.parse(t)}catch(e){return t}},parseEJSONParam:function(t){if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(e){return t}},parseEJSONValue:function(t){if("string"!=typeof t)return t;try{return s.EJSON.parse(t)}catch(n){return e.gateWayFunc.parseEJSONParam(t)}},normalizeOrderParam:function(t){if(null!=t&&""!==t){for(var n=e.gateWayFunc.parseEJSONValue(t),r=function(t){var e=t&&"object"==typeof t?Number(t):t;if("number"==typeof e&&!isNaN(e))return e<0?"desc":"asc";if("string"==typeof e){var n=e.toLowerCase();if("desc"===n||"-1"===n)return"desc";if("asc"===n||"1"===n)return"asc"}},o=[],i=0,a=Array.isArray(n)?n:[n];i<a.length;i++){var c=a[i];if(c&&"object"==typeof c)if(void 0!==c.field)(l=r(c.direction))&&o.push({field:c.field,direction:l});else for(var u=0,s=Object.entries(c);u<s.length;u++){var l,f=s[u],d=f[0];(l=r(f[1]))&&o.push({field:d,direction:l})}}return o.length?o:void 0}},extractDocId:function(t){if(t&&"object"==typeof t&&!Array.isArray(t)&&1===Object.keys(t).length&&"_id"in t){var e=t._id;if("string"==typeof e||"number"==typeof e)return String(e);if(e&&"object"==typeof e){if("string"==typeof e.$oid)return e.$oid;var n=e.$eq;if("string"==typeof n||"number"==typeof n)return String(n);if(n&&"object"==typeof n&&"string"==typeof n.$oid)return n.$oid}}},toLegacyRegExp:function(t){if(!t||"object"!=typeof t)return t;if(t.$regularExpression&&"object"==typeof t.$regularExpression){var n=t.$regularExpression;return{$regex:n.pattern,$options:n.options}}if(Array.isArray(t))return t.map(function(t){return e.gateWayFunc.toLegacyRegExp(t)});var r={};for(var o in t)r[o]=e.gateWayFunc.toLegacyRegExp(t[o]);return r},parseWriteParam:function(t){return e.gateWayFunc.toLegacyRegExp(e.gateWayFunc.parseEJSONParam(t))},buildQueryParams:function(t){return Object.entries(t).filter(function(t){t[0];var e=t[1];return null!=e&&""!==e}).map(function(t){var e=t[0],n=t[1],r="object"==typeof n?JSON.stringify(n):String(n);return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(r))}).join("&")},getUrlPrefix:function(t){var e=(null==t?void 0:t.instance)||"(default)",n=(null==t?void 0:t.database)||"(default)";return"/database/instances/".concat(e,"/databases/").concat(n)},"database.queryDocument":function(t,n){var r,o,u,l;return a(this,void 0,Promise,function(){var a,f,d,p,h,y,m;return c(this,function(c){switch(c.label){case 0:return a=e.gateWayFunc.parseEJSONParam(t.query),f=e.gateWayFunc.parseEJSONValue(t.projection),d=e.gateWayFunc.extractDocId(a),p=void 0!==d,h=e.gateWayFunc.buildQueryParams(i({projection:f,transactionId:t.transactionId},p?{}:{offset:null!==(r=t.offset)&&void 0!==r?r:0,limit:null!==(o=t.limit)&&void 0!==o?o:100,order:e.gateWayFunc.normalizeOrderParam(t.order),query:a?s.EJSON.stringify(a,{relaxed:!1}):void 0})),y="".concat(e.gateWayFunc.getUrlPrefix(t),"/collections/").concat(t.collectionName,"/documents?").concat(h),p&&(y="".concat(e.gateWayFunc.getUrlPrefix(t),"/collections/").concat(t.collectionName,"/documents/").concat(d,"?").concat(h)),[4,this.gateWay({url:y,method:"GET"},n)];case 1:return(m=c.sent()).data=e.gateWayFunc.safeParseEJSON(JSON.stringify(m.data)),!p||m.code||(null===(u=m.data)||void 0===u?void 0:u.code)?(m.code||(null===(l=m.data)||void 0===l?void 0:l.code)?m=i(i({},m),{data:i(i({},m.data),{list:[]})}):Array.isArray(m.data)?m=i(i({},m),{data:{list:m.data}}):m.data&&!Array.isArray(m.data.list)&&(m=i(i({},m),{data:i(i({},m.data),{list:[]})})),[2,e.gateWayFunc.filterRes(m)]):[2,i(i({},m),{data:{list:[m.data]}})]}})})},"database.addDocument":function(t,n){var r,o,u;return a(this,void 0,Promise,function(){var a,s;return c(this,function(c){switch(c.label){case 0:return a=(Array.isArray(t.data)?t.data:[t.data]).map(function(t){return e.gateWayFunc.parseWriteParam(t)}),[4,this.gateWay({url:"".concat(e.gateWayFunc.getUrlPrefix(t),"/collections/").concat(t.collectionName,"/documents"),method:"POST",data:i({data:a},t.transactionId&&{transactionId:t.transactionId})},n)];case 1:return s=c.sent(),Array.isArray(t.data)?s=i(i({},s),{data:i({ids:(null===(r=s.data)||void 0===r?void 0:r.insertedIds)||[]},s.data)}):(null===(u=null===(o=s.data)||void 0===o?void 0:o.insertedIds)||void 0===u?void 0:u[0])&&(s=i(i({},s),{data:i({_id:s.data.insertedIds[0]},s.data)})),[2,e.gateWayFunc.filterRes(s)]}})})},"database.updateDocument":function(t,n){var r;return a(this,void 0,Promise,function(){var o;return c(this,function(a){switch(a.label){case 0:return[4,this.gateWay({url:"".concat(e.gateWayFunc.getUrlPrefix(t),"/collections/").concat(t.collectionName,"/documents"),method:"PATCH",data:i({query:e.gateWayFunc.parseEJSONParam(t.query),data:e.gateWayFunc.parseEJSONParam(t.data),multi:!!t.multi,upsert:!!t.upsert,replaceMode:null!==(r=t.replaceMode)&&void 0!==r?r:!1===t.merge},t.transactionId&&{transactionId:t.transactionId})},n)];case 1:return o=a.sent(),[2,e.gateWayFunc.filterRes(o)]}})})},"database.deleteDocument":function(t,n){return a(this,void 0,Promise,function(){var r;return c(this,function(o){switch(o.label){case 0:return[4,this.gateWay({url:"".concat(e.gateWayFunc.getUrlPrefix(t),"/collections/").concat(t.collectionName,"/documents/remove"),method:"POST",data:i({query:e.gateWayFunc.parseEJSONParam(t.query),multi:!!t.multi},t.transactionId&&{transactionId:t.transactionId})},n)];case 1:return r=o.sent(),[2,e.gateWayFunc.filterRes(r)]}})})},"database.countDocument":function(t,n){return a(this,void 0,Promise,function(){var r,o,i;return c(this,function(a){switch(a.label){case 0:return r=e.gateWayFunc.parseEJSONParam(t.query),o=e.gateWayFunc.buildQueryParams({count:!0,query:r?s.EJSON.stringify(r,{relaxed:!1}):void 0}),[4,this.gateWay({url:"".concat(e.gateWayFunc.getUrlPrefix(t),"/collections/").concat(t.collectionName,"/documents?").concat(o),method:"GET"},n)];case 1:return i=a.sent(),[2,e.gateWayFunc.filterRes(i)]}})})},"database.addCollection":function(t,n){return a(this,void 0,Promise,function(){var r;return c(this,function(o){switch(o.label){case 0:return[4,this.gateWay({url:"".concat(e.gateWayFunc.getUrlPrefix(t),"/collections"),method:"POST",data:{collectionName:t.collectionName}},n)];case 1:return r=o.sent(),[2,e.gateWayFunc.filterRes(r)]}})})},"database.aggregate":function(t,n){var r;return a(this,void 0,Promise,function(){var o,i;return c(this,function(a){switch(a.label){case 0:return o=t.stages.map(function(t){var e,n;try{var r="string"==typeof t.stageValue?JSON.parse(t.stageValue):t.stageValue;return(e={})[t.stageKey]=s.EJSON.serialize(r),e}catch(e){return(n={})[t.stageKey]=t.stageValue,n}}),[4,this.gateWay({url:"".concat(e.gateWayFunc.getUrlPrefix(t),"/collections/").concat(t.collectionName,"/documents/aggregations"),method:"POST",data:{pipeline:o}},n)];case 1:return i=a.sent(),Array.isArray(null===(r=i.data)||void 0===r?void 0:r.list)&&(i.data.list=JSON.stringify(i.data.list.map(function(t){return JSON.stringify(t)}))),[2,e.gateWayFunc.filterRes(i)]}})})},"database.startTransaction":function(t,n){return a(this,void 0,void 0,function(){var r;return c(this,function(o){switch(o.label){case 0:return[4,this.gateWay({url:"".concat(e.gateWayFunc.getUrlPrefix(t),"/transactions"),method:"POST"},n)];case 1:return r=o.sent(),[2,e.gateWayFunc.filterRes(e.gateWayFunc.flattenResData(r))]}})})},"database.commitTransaction":function(t,n){return a(this,void 0,void 0,function(){var r;return c(this,function(o){switch(o.label){case 0:return[4,this.gateWay({url:"".concat(e.gateWayFunc.getUrlPrefix(t),"/transactions/").concat(t.transactionId,"/commit"),method:"POST"},n)];case 1:return r=o.sent(),[2,e.gateWayFunc.filterRes(r)]}})})},"database.abortTransaction":function(t,n){return a(this,void 0,void 0,function(){var r;return c(this,function(o){switch(o.label){case 0:return[4,this.gateWay({url:"".concat(e.gateWayFunc.getUrlPrefix(t),"/transactions/").concat(t.transactionId,"/rollback"),method:"POST"},n)];case 1:return r=o.sent(),[2,e.gateWayFunc.filterRes(r)]}})})},"database.getInTransaction":function(t,n){var r;return a(this,void 0,void 0,function(){var o;return c(this,function(a){switch(a.label){case 0:return[4,e.gateWayFunc["database.queryDocument"].call(this,t,n)];case 1:return"object"==typeof(o=a.sent()).data&&null!==o.data?(null===(r=o.data)||void 0===r?void 0:r.code)?[2,e.gateWayFunc.flattenResData(o)]:[2,i(i({},o),{data:JSON.stringify(o.data)})]:[2,o]}})})},"database.updateDocInTransaction":function(t,n){return a(this,void 0,void 0,function(){var r;return c(this,function(o){switch(o.label){case 0:return[4,e.gateWayFunc["database.updateDocument"].call(this,t,n)];case 1:return r=o.sent(),[2,e.gateWayFunc.flattenResData(r)]}})})},"database.deleteDocInTransaction":function(t,n){return a(this,void 0,void 0,function(){var r;return c(this,function(o){switch(o.label){case 0:return[4,e.gateWayFunc["database.deleteDocument"].call(this,t,n)];case 1:return r=o.sent(),[2,e.gateWayFunc.flattenResData(r)]}})})},"database.insertDocInTransaction":function(t,n){var r;return a(this,void 0,Promise,function(){var o,a;return c(this,function(c){switch(c.label){case 0:return[4,e.gateWayFunc["database.addDocument"].call(this,t,n)];case 1:return"object"==typeof(o=c.sent()).data&&null!==o.data?(a=!!(null===(r=o.data)||void 0===r?void 0:r._id),o=i(i(i({},o),{inserted:a?1:0,ok:a?1:0}),o.data)):o=i({inserted:0,ok:0},o),delete o.data,[2,o]}})})},"database.runCommands":function(t,n){return a(this,void 0,Promise,function(){var r;return c(this,function(o){switch(o.label){case 0:return[4,this.gateWay({url:"".concat(e.gateWayFunc.getUrlPrefix(t),"/commands"),method:"POST",data:i({commands:s.EJSON.serialize(Array.isArray(t.commands)?t.commands.map(function(t){return e.gateWayFunc.parseEJSONParam(t)}):t.commands)},t.transactionId&&{transactionId:t.transactionId})},n)];case 1:"object"==typeof(r=o.sent()).data&&null!==r.data&&(delete(r=i(i({},r),r.data)).data,delete r.request_id);try{r=s.EJSON.deserialize(r)}catch(t){}return[2,e.gateWayFunc.filterRes(r)]}})})},"database.getDocument":function(t,n){var r;return a(this,void 0,Promise,function(){var o,a;return c(this,function(c){switch(c.label){case 0:return(o=i({},t)).query=e.gateWayFunc.parseEJSONParam(o.query),o.projection=e.gateWayFunc.parseEJSONValue(o.projection),[4,e.gateWayFunc["database.queryDocument"].call(this,o,n)];case 1:return a=c.sent(),Array.isArray(null===(r=a.data)||void 0===r?void 0:r.list)&&(a.data.list=a.data.list.map(function(t){return s.EJSON.stringify(t,{relaxed:!1})})),[2,a]}})})},"database.insertDocument":function(t,n){return a(this,void 0,Promise,function(){var r;return c(this,function(o){return(r=i({},t)).data=Array.isArray(r.data)?r.data.map(function(t){return e.gateWayFunc.parseWriteParam(t)}):e.gateWayFunc.parseWriteParam(r.data),[2,e.gateWayFunc["database.addDocument"].call(this,r,n)]})})},"database.modifyDocument":function(t,n){return a(this,void 0,Promise,function(){var r;return c(this,function(o){return(r=i({},t)).query=e.gateWayFunc.parseEJSONParam(r.query),r.data=e.gateWayFunc.parseEJSONParam(r.data),[2,e.gateWayFunc["database.updateDocument"].call(this,r,n)]})})},"database.modifyAndReturnDoc":function(t,n){var r,o;return a(this,void 0,Promise,function(){var a,u,l;return c(this,function(c){switch(c.label){case 0:return(a=i({},t)).query=e.gateWayFunc.parseEJSONParam(a.query),a.data=e.gateWayFunc.parseEJSONParam(a.data),(u=e.gateWayFunc.extractDocId(a.query))?[4,this.gateWay({url:"".concat(e.gateWayFunc.getUrlPrefix(a),"/collections/").concat(a.collectionName,"/documents/").concat(u),method:"PATCH",data:i({data:a.data,replaceMode:null!==(r=a.replaceMode)&&void 0!==r&&r,upsert:!!a.upsert,returnDoc:!0},a.transactionId&&{transactionId:a.transactionId})},n)]:[2,e.gateWayFunc["database.updateDocument"].call(this,a,n)];case 1:return l=c.sent(),void 0!==(null===(o=l.data)||void 0===o?void 0:o.doc)&&"string"!=typeof l.data.doc&&(l.data.doc=s.EJSON.stringify(l.data.doc,{relaxed:!1})),[2,e.gateWayFunc.filterRes(l)]}})})},"database.removeDocument":function(t,n){return a(this,void 0,Promise,function(){var r;return c(this,function(o){return(r=i({},t)).query=e.gateWayFunc.parseEJSONParam(r.query),[2,e.gateWayFunc["database.deleteDocument"].call(this,r,n)]})})},"database.calculateDocument":function(t,n){return a(this,void 0,Promise,function(){var r;return c(this,function(o){return(r=i({},t)).query=e.gateWayFunc.parseEJSONParam(r.query),[2,e.gateWayFunc["database.countDocument"].call(this,r,n)]})})},"database.aggregateDocuments":function(t,n){var r;return a(this,void 0,Promise,function(){var o,a;return c(this,function(c){switch(c.label){case 0:return o=i({},t),Array.isArray(o.stages)&&(o.stages=o.stages.map(function(t){return i(i({},t),{stageValue:e.gateWayFunc.parseEJSONParam(t.stageValue)})})),[4,e.gateWayFunc["database.aggregate"].call(this,o,n)];case 1:if(a=c.sent(),"string"==typeof(null===(r=a.data)||void 0===r?void 0:r.list))try{a.data.list=JSON.parse(a.data.list)}catch(t){}return[2,a]}})})}};var f={name:"database",entity:{database:function(t){var n;if(void 0!==t&&"Object"!==Object.prototype.toString.call(t).slice(8,-1))throw l.utils.createCloudbaseError({code:"INVALID_PARAM",msg:"dbConfig must be an object"},null===(n=this.config)||void 0===n?void 0:n.errorFactory);var r=this.platform,s=r.adapter,f=r.runtime,d=function(t){function n(e){return t.call(this,e)||this}return o(n,t),n.prototype.send=function(n,r,o){var i,u,s,f;return a(this,void 0,void 0,function(){var a,d,p;return c(this,function(c){switch(c.label){case 0:return a=null,d=o&&"number"==typeof o.timeout?{timeout:o.timeout}:void 0,"GATEWAY"===this.config.endPointMode&&e.gateWayFunc[n]?[4,e.gateWayFunc[n].call(this,r,d)]:[3,2];case 1:return a=c.sent(),[3,4];case 2:return[4,t.prototype.send.call(this,n,r,void 0,d)];case 3:a=c.sent(),c.label=4;case 4:if(p=l.utils.resolveThrow(null!==(s=null===(u=null===(i=this.config)||void 0===i?void 0:i._fromApp)||void 0===u?void 0:u.config)&&void 0!==s?s:this.config),a&&a.code&&p)throw l.utils.createCloudbaseError({code:a.code,msg:a.message||a.data&&a.data.message||"",requestId:a.requestId},null===(f=this.config)||void 0===f?void 0:f.errorFactory);return[2,a]}})})},n}(this.request.constructor);return u.Db.reqClass=d,u.Db.getAccessToken=this.authInstance?this.authInstance.getAccessToken.bind(this.authInstance):function(){return""},u.Db.runtime=f,this.wsClientClass&&(u.Db.wsClass=s.wsClass,u.Db.wsClientClass=this.wsClientClass),u.Db.ws||(u.Db.ws=null),new(function(t){function e(e){return t.call(this,e)||this}return o(e,t),e.prototype.runCommands=function(t){return a(this,void 0,Promise,function(){return c(this,function(e){return[2,u.Db.createRequest(this.config).send("database.runCommands",t)]})})},e}(u.Db))(i(i(i({},this.config),{_fromApp:this}),t))}}};try{cloudbase.registerComponent(f)}catch(t){}function d(t){try{t.registerComponent(f)}catch(t){console.warn(t)}}e.registerDatabase=d;try{window.registerDatabase=d}catch(t){}},563:function(t,e,n){var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),a=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&o(e,t,n);return i(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.useDefaultAdapter=e.useAdapters=e.RUNTIME=void 0;var c,u=a(n(92)),s=n(962);!function(t){t.WEB="web",t.WX_MP="wx_mp"}(c=e.RUNTIME||(e.RUNTIME={})),e.useAdapters=function(t,e){for(var n=0,o=(0,s.isArray)(t)?t:[t];n<o.length;n++){var i=o[n],a=i.isMatch,c=i.genAdapter,u=i.runtime;if(a())return{adapter:r({isMatch:a},c(e)),runtime:u}}},e.useDefaultAdapter=function(){return{adapter:r({},u.genAdapter()),runtime:c.WEB}}},92:function(t,e,n){var r,o=this&&this.__extends||(r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},r(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__assign||function(){return i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},i.apply(this,arguments)},a=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function c(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,c)}u((r=r.apply(t,e||[])).next())})},c=this&&this.__generator||function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=e.call(t,a)}catch(t){c=[6,t],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.WebRequest=e.genAdapter=void 0;var u=n(764),s=n(962),l=n(464),f=function(t){function e(e){var n=t.call(this)||this,r=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return n.timeout=r||0,n.timeoutMsg=o||"请求超时",n.restrictedMethods=i||["get","post","upload","download"],n}return o(e,t),e.prototype.get=function(t){return this.request(i(i({},t),{method:"get"}),this.restrictedMethods.includes("get"))},e.prototype.post=function(t){return this.request(i(i({},t),{method:"post"}),this.restrictedMethods.includes("post"))},e.prototype.put=function(t){return this.request(i(i({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,n=t.file,r=t.name,o=t.method,a=t.headers,c=void 0===a?{}:a,u={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",s=new FormData;return"post"===u?(Object.keys(e).forEach(function(t){s.append(t,e[t])}),s.append("key",r),s.append("file",n),this.request(i(i({},t),{data:s,method:u}),this.restrictedMethods.includes("upload"))):this.request(i(i({},t),{method:"put",headers:c,body:n}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return a(this,void 0,Promise,function(){var e,n,r,o;return c(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,this.get(i(i({},t),{headers:{},responseType:"blob"}))];case 1:return e=a.sent().data,n=window.URL.createObjectURL(new Blob([e])),r=decodeURIComponent(new URL(t.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=n,o.setAttribute("download",r),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(n),document.body.removeChild(o),[3,3];case 2:return a.sent(),[3,3];case 3:return[2,new Promise(function(e){e({statusCode:200,tempFilePath:t.url})})]}})})},e.prototype.fetch=function(t){var e;return a(this,void 0,Promise,function(){var n,r,o,u,s,l,f,d,p,h,y,m,v,g=this;return c(this,function(b){switch(b.label){case 0:return n=new AbortController,r=t.url,o=t.enableAbort,u=void 0!==o&&o,s=t.stream,l=void 0!==s&&s,f=t.signal,d=t.timeout,p=t.shouldThrowOnError,h=void 0===p||p,y=null!=d?d:this.timeout,f&&(f.aborted&&n.abort(),f.addEventListener("abort",function(){return n.abort()})),m=null,u&&y&&(m=setTimeout(function(){console.warn(g.timeoutMsg),n.abort(new Error(g.timeoutMsg))},y)),[4,fetch(r,i(i({},t),{signal:n.signal})).then(function(t){return a(g,void 0,void 0,function(){var e,n,r;return c(this,function(o){switch(o.label){case 0:return clearTimeout(m),h?t.ok?(e=t,[3,3]):[3,1]:[3,4];case 1:return r=(n=Promise).reject,[4,t.json()];case 2:e=r.apply(n,[o.sent()]),o.label=3;case 3:return[2,e];case 4:return[2,t]}})})}).catch(function(t){return clearTimeout(m),Promise.reject(t)})];case 1:return v=b.sent(),[2,{data:l?v.body:(null===(e=v.headers.get("content-type"))||void 0===e?void 0:e.includes("application/json"))?v.json():v.text(),statusCode:v.status,header:v.headers,response:v}]}})})},e.prototype.request=function(t,e){var n=this;void 0===e&&(e=!1);var r=String(t.method).toLowerCase()||"get";return new Promise(function(o){var i=t.url,a=t.headers,c=void 0===a?{}:a,u=t.data,f=t.responseType,d=t.withCredentials,p=t.body,h=t.onUploadProgress,y=(0,s.formatUrl)((0,l.getProtocol)(),i,"get"===r?u:{}),m=new XMLHttpRequest;m.open(r,y),f&&(m.responseType=f);var v,g,b=t.signal;b&&(b.aborted?m.abort():b.addEventListener("abort",function(){return m.abort()},{once:!0})),Object.keys(c).forEach(function(t){m.setRequestHeader(t,c[t])}),h&&m.upload.addEventListener("progress",h),m.onreadystatechange=function(){var t={};if(4===m.readyState){var e=m.getAllResponseHeaders().trim().split(/[\r\n]+/),n={};e.forEach(function(t){var e=t.split(": "),r=e.shift().toLowerCase(),o=e.join(": ");n[r]=o}),t.header=n,t.statusCode=m.status;try{t.data="blob"===f?m.response:JSON.parse(m.responseText)}catch(e){t.data="blob"===f?m.response:m.responseText}clearTimeout(v),o(t)}},e&&n.timeout&&(v=setTimeout(function(){console.warn(n.timeoutMsg),m.abort()},n.timeout)),g=(0,s.isFormData)(u)?u:"application/x-www-form-urlencoded"===c["content-type"]?(0,s.toQueryString)(u):p||(u?JSON.stringify(u):void 0),d&&(m.withCredentials=!0),m.send(g)})},e}(u.AbstractSDKRequest);e.WebRequest=f,e.genAdapter=function(){return{type:"default",root:window,reqClass:f,wsClass:WebSocket,localStorage:localStorage}}},464:function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.COMMUNITY_SITE_URL=e.IS_DEBUG_MODE=e.getProtocol=e.setProtocol=e.getSdkName=e.setSdkName=void 0;var n="@cloudbase/js-sdk";e.setSdkName=function(t){n=t},e.getSdkName=function(){return n};var r="https:";e.setProtocol=function(t){r=t},e.getProtocol=function(){return r},e.IS_DEBUG_MODE=!1,e.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},519:function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.ERRORS=void 0,e.ERRORS={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"}},778:function(t,e,n){var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.OATUH_LOGINTYPE=void 0,o(n(464),e),o(n(519),e),e.OATUH_LOGINTYPE="constants"},517:function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function c(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,c)}u((r=r.apply(t,e||[])).next())})},o=this&&this.__generator||function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=e.call(t,a)}catch(t){c=[6,t],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.catchErrorsDecorator=void 0;var i=n(962),a=n(778),c=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(c=-1!==navigator.userAgent.indexOf("Firefox"));var u=c?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,s=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function l(t){var e=t.err,n=t.className,r=t.methodName,o=t.sourceLink;if(!o)return null;var i,a=e.stack.split("\n"),u=c?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(n,"\\.descriptor.value\\s*\\[as\\s").concat(r,"\\]\\s*\\(.*\\)$")),l=c?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(n,"\\.descriptor.value\\s*\\[as\\s").concat(r,"\\]")),f=a.findIndex(function(t){return u.test(t)});if(-1!==f){var d=a.filter(function(t,e){return e>f});d.unshift(a[f].replace(l,"".concat(n,".").concat(r)).replace(s,o)),(i=new Error).stack="".concat(c?"@debugger":"Error","\n").concat(d.join("\n"))}return i}e.catchErrorsDecorator=function(t){var e=t.mode,n=void 0===e?"async":e,c=t.customInfo,f=void 0===c?{}:c,d=t.title,p=t.messages,h=void 0===p?[]:p;return function(t,e,c){if(a.IS_DEBUG_MODE){var p=f.className||t.constructor.name,y=f.methodName||e,m=c.value,v=function(){var t="",e=(new Error).stack.split("\n"),n=e.findIndex(function(t){return u.test(t)});if(-1!==n){var r=s.exec(e[n+1]||"");t=r?r[0]:""}return t}();c.value="sync"===n?function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=l({err:new Error,className:p,methodName:y,sourceLink:v});try{return m.apply(this,t)}catch(t){var r=t,o=t.message,a=t.error,c=t.error_description,u={title:d||"".concat(p,".").concat(y," failed"),content:[{type:"error",body:t}]};if(o&&/^\{.*\}$/.test(o)){var s=JSON.parse(o);u.subtitle=o,s.code&&(n?(n.code=s.code,n.msg=s.msg):(t.code=s.code,t.message=s.msg),r=n||t,u.content=h.map(function(t){return{type:"info",body:t}}))}throw a&&c&&(u.subtitle=c,n?(n.code=a,n.msg=c):(t.code=a,t.message=c),r=n||t,u.content=h.map(function(t){return{type:"info",body:t}})),(0,i.printGroupLog)(u),r}}:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return r(this,void 0,void 0,function(){var e,n,r,a,c,u,s,f;return o(this,function(o){switch(o.label){case 0:e=l({err:new Error,className:p,methodName:y,sourceLink:v}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,m.apply(this,t)];case 2:return[2,o.sent()];case 3:throw n=o.sent(),r=n,a=n.message,c=n.error,u=n.error_description,s={title:d||"".concat(p,".").concat(y," failed"),content:[{type:"error",body:n}]},a&&/^\{.*\}$/.test(a)&&(f=JSON.parse(a),s.subtitle=f,f.code&&(e?(e.code=f.code,e.message=f.msg):(n.code=f.code,n.message=f.msg),r=e||n,s.content=h.map(function(t){return{type:"info",body:t}}))),c&&u&&(s.subtitle=u,e?(e.code=c,e.msg=u):(n.code=c,n.message=u),r=e||n,s.content=h.map(function(t){return{type:"info",body:t}})),(0,i.printGroupLog)(s),r;case 4:return[2]}})})}}}}},260:function(t,e,n){var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),o(n(517),e)},877:function(t,e,n){var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&r(e,t,n);return o(e,t),e},a=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.langEvent=e.AbortController=e.jwt=e.helpers=e.utils=e.events=e.cache=e.adapters=e.constants=void 0;var c=i(n(778));e.constants=c;var u=i(n(563));e.adapters=u;var s=i(n(865));e.cache=s;var l=i(n(940));e.events=l;var f=i(n(991));e.langEvent=f;var d=i(n(962));e.utils=d;var p=i(n(260));e.helpers=p;var h=a(n(829));e.AbortController=h.default;var y={decode:a(n(107)).default};e.jwt=y},829:function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(){var t=this;this.listeners=[],this.signal={aborted:!1,addEventListener:function(e,n){"abort"===e&&t.listeners.push(n)}}}return t.prototype.abort=function(){this.signal.aborted||(this.signal.aborted=!0,this.listeners.forEach(function(t){return t()}))},t}();e.default=n},865:function(t,e,n){var r,o=this&&this.__extends||(r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},r(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function c(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,c)}u((r=r.apply(t,e||[])).next())})},a=this&&this.__generator||function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=e.call(t,a)}catch(t){c=[6,t],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.CloudbaseCache=void 0;var c=n(764),u=n(962),s=n(778),l=function(t){function e(e){var n=t.call(this)||this;return n.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),n}return o(e,t),e.prototype.setItem=function(t,e){this.root.tcbCacheObject[t]=e},e.prototype.getItem=function(t){return this.root.tcbCacheObject[t]},e.prototype.removeItem=function(t){delete this.root.tcbCacheObject[t]},e.prototype.clear=function(){delete this.root.tcbCacheObject},e}(c.AbstractStorage),f=function(){function t(t){this.keys={};var e=t.persistence,n=t.platformInfo,r=void 0===n?{}:n,o=t.keys,i=void 0===o?{}:o;this.platformInfo=r,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||e,this.storage=function(t,e){switch(t){case"local":default:return e.localStorage?e.localStorage:((0,u.printWarn)(s.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new l(e.root));case"none":return new l(e.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(t.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),t.prototype.setStore=function(t,e,n){if("async"!==this.mode){if(this.storage)try{var r={version:n||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(r))}catch(t){throw new Error(JSON.stringify({code:s.ERRORS.OPERATION_FAIL,msg:"[".concat((0,s.getSdkName)(),"][").concat(s.ERRORS.OPERATION_FAIL,"]setStore failed"),info:t}))}}else(0,u.printWarn)(s.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,n){return i(this,void 0,void 0,function(){var r;return a(this,function(o){switch(o.label){case 0:if(!this.storage)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),r={version:n||"localCachev1",content:e},[4,this.storage.setItem(t,JSON.stringify(r))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}})})},t.prototype.getStore=function(t,e){var n;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(n={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===n?void 0:n.tcb_token))return{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(t){return""}e=e||"localCachev1";var r=this.storage.getItem(t);return r&&r.indexOf(e)>=0?JSON.parse(r).content:""}(0,u.printWarn)(s.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){var n;return i(this,void 0,void 0,function(){var r;return a(this,function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(n={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===n?void 0:n.tcb_token))return[2,{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(t){return[2,""]}return e=e||"localCachev1",[4,this.storage.getItem(t)];case 1:return(r=o.sent())&&r.indexOf(e)>=0?[2,JSON.parse(r).content]:[2,""]}})})},t.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):(0,u.printWarn)(s.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},t.prototype.removeStoreAsync=function(t){return i(this,void 0,void 0,function(){return a(this,function(e){switch(e.label){case 0:return[4,this.storage.removeItem(t)];case 1:return e.sent(),[2]}})})},t}();e.CloudbaseCache=f},940:function(t,e,n){var r,o=this&&this.__extends||(r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},r(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__spreadArray||function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))};Object.defineProperty(e,"__esModule",{value:!0}),e.removeEventListener=e.activateEvent=e.addEventListener=e.CloudbaseEventEmitter=e.IErrorEvent=e.CloudbaseEvent=void 0;var a=n(962),c=function(t,e){this.data=e||null,this.name=t};e.CloudbaseEvent=c;var u=function(t){function e(e,n){var r=t.call(this,"error",{error:e,data:n})||this;return r.error=e,r}return o(e,t),e}(c);e.IErrorEvent=u;var s=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){return function(t,e,n){n[t]=n[t]||[],n[t].push(e)}(t,e,this.listeners),this},t.prototype.off=function(t,e){return function(t,e,n){if(null==n?void 0:n[t]){var r=n[t].indexOf(e);-1!==r&&n[t].splice(r,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if((0,a.isInstanceOf)(t,u))return console.error(t.error),this;var n=(0,a.isString)(t)?new c(t,e||{}):t,r=n.name;if(this.listens(r)){n.target=this;for(var o=0,s=this.listeners[r]?i([],this.listeners[r],!0):[];o<s.length;o++)s[o].call(this,n)}return this},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}();e.CloudbaseEventEmitter=s;var l=new s;e.addEventListener=function(t,e){l.on(t,e)},e.activateEvent=function(t,e){void 0===e&&(e={}),l.fire(t,e)},e.removeEventListener=function(t,e){l.off(t,e)}},991:function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),e.LANG_CHANGE_EVENT=e.bus=void 0;var r=n(940);e.bus=new r.CloudbaseEventEmitter,e.LANG_CHANGE_EVENT="lang_change"},962:function(t,e,n){var r,o=this&&this.__extends||(r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},r(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__assign||function(){return i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},i.apply(this,arguments)},a=this&&this.__rest||function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n};Object.defineProperty(e,"__esModule",{value:!0}),e.parseCaptcha=e.parseQueryString=e.transformPhone=e.sleep=e.printGroupLog=e.errorToResult=e.promoteGatewayError=e.maybeThrow=e.resolveThrow=e.createCloudbaseError=e.CloudbaseError=e.throwError=e.printInfo=e.printError=e.printWarn=e.execCallback=e.createPromiseCallback=e.removeParam=e.getHash=e.getQuery=e.toQueryString=e.formatUrl=e.generateRequestId=e.genSeqId=e.isFormData=e.isInstanceOf=e.isNull=e.isPalinObject=e.isUndefined=e.isString=e.isArray=void 0;var c=n(778);e.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},e.isString=function(t){return"string"==typeof t},e.isUndefined=function(t){return void 0===t},e.isPalinObject=function(t){return"[object Object]"===Object.prototype.toString.call(t)},e.isNull=function(t){return"[object Null]"===Object.prototype.toString.call(t)},e.isInstanceOf=function(t,e){return t instanceof e},e.isFormData=function(t){return"[object FormData]"===Object.prototype.toString.call(t)},e.genSeqId=function(){return Math.random().toString(16).slice(2)},e.generateRequestId=function(){var t=(new Date).getTime(),e=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){var r=16*Math.random();return t>0?(r=(t+r)%16|0,t=Math.floor(t/16)):(r=(e+r)%16|0,e=Math.floor(e/16)),("x"===n?r:7&r|8).toString(16)})},e.formatUrl=function(t,e,n){void 0===n&&(n={});var r=/\?/.test(e),o="";return Object.keys(n).forEach(function(t){""===o?!r&&(e+="?"):o+="&",o+="".concat(t,"=").concat(encodeURIComponent(n[t]))}),/^http(s)?:\/\//.test(e+=o)?e:"".concat(t).concat(e)},e.toQueryString=function(t){void 0===t&&(t={});var e=[];return Object.keys(t).forEach(function(n){e.push("".concat(n,"=").concat(encodeURIComponent(t[n])))}),e.join("&")},e.getQuery=function(t,e){if("undefined"==typeof window)return!1;var n=e||decodeURIComponent(window.location.search),r=new RegExp("(^|&)".concat(t,"=([^&]*)(&|$)")),o=n.substr(n.indexOf("?")+1).match(r);return null!=o?o[2]:""},e.getHash=function(t){if("undefined"==typeof window)return"";var e=window.location.hash.match(new RegExp("[#?&/]".concat(t,"=([^&#]*)")));return e?e[1]:""},e.removeParam=function(t,e){var n=e.split("?")[0],r=[],o=-1!==e.indexOf("?")?e.split("?")[1]:"";if(""!==o){for(var i=(r=o.split("&")).length-1;i>=0;i-=1)r[i].split("=")[0]===t&&r.splice(i,1);n="".concat(n,"?").concat(r.join("&"))}return n},e.createPromiseCallback=function(){var t={};if(!Promise){(t=function(){}).promise={};var e=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(t.promise,"then",{get:e}),Object.defineProperty(t.promise,"catch",{get:e}),t}var n=new Promise(function(e,n){t=function(t,r){return t?n(t):e(r)}});return t.promise=n,t},e.execCallback=function(t,e,n){if(void 0===n&&(n=null),t&&"function"==typeof t)return t(e,n);if(e)throw e;return n},e.printWarn=function(t,e){console.warn("[".concat((0,c.getSdkName)(),"][").concat(t,"]:").concat(e))},e.printError=function(t,e){console.error({code:t,msg:"[".concat((0,c.getSdkName)(),"][").concat(t,"]:").concat(e)})},e.printInfo=function(t,e){console.log("[".concat((0,c.getSdkName)(),"][").concat(t,"]:").concat(e))},e.throwError=function(t,e){var n=new Error(JSON.stringify({code:t,msg:"[".concat((0,c.getSdkName)(),"][").concat(t,"]:").concat(e)}));throw n.code=t,n};var u=function(t){function e(e){var n=t.call(this,e.msg||e.message||"")||this;return n.code=e.code||"",n.requestId=e.requestId||"",Object.defineProperty(n,"message",{value:e.msg||e.message||"",enumerable:!0,writable:!0,configurable:!0}),n}return o(e,t),e}(Error);e.CloudbaseError=u;var s=function(t){return new u(t)};function l(t,e){return(e||s)(t)}function f(t){return!t||"boolean"!=typeof t.throw||t.throw}e.createCloudbaseError=l,e.resolveThrow=f,e.maybeThrow=function(t,e){if(f(t))throw l(e,null==t?void 0:t.errorFactory);return i({code:e.code,message:e.msg},e.requestId?{requestId:e.requestId}:{})},e.promoteGatewayError=function(t){if(t&&"object"==typeof t&&t.data&&"object"==typeof t.data){var e=t.data,n=e.code,r=e.message;if(!t.code&&n||!t.message&&r)return i(i(i({},t),!t.code&&n?{code:n}:{}),!t.message&&r?{message:r}:{})}return t},e.errorToResult=function(t){if(t instanceof Error&&"string"==typeof t.message)try{var e=JSON.parse(t.message);if(e&&"string"==typeof e.code)return{code:e.code,message:e.msg||e.message||"",requestId:e.requestId}}catch(t){}return t&&"string"==typeof t.code?{code:t.code,message:t.message||"",requestId:t.requestId}:{code:"UNKNOWN_ERROR",message:String((null==t?void 0:t.message)||t||"")}},e.printGroupLog=function(t){var e,n=t.title,r=t.subtitle,o=void 0===r?"":r,i=t.content,a=void 0===i?[]:i,c=t.printTrace,u=void 0!==c&&c,s=t.collapsed;void 0!==s&&s?(console.groupCollapsed||console.error)(n,o):(console.group||console.error)(n,o);for(var l=0,f=a;l<f.length;l++){var d=f[l],p=d.type,h=d.body;switch(p){case"info":console.log(h);break;case"warn":console.warn(h);break;case"error":console.error(h)}}u&&(console.trace||console.log)("stack trace:"),null===(e=console.groupEnd)||void 0===e||e.call(console)},e.sleep=function(t){return void 0===t&&(t=0),new Promise(function(e){return setTimeout(e,t)})},e.transformPhone=function(t){return"+86".concat(t)},e.parseQueryString=function(t){t=t.replace(/^\?/,"");var e={};return t.split("&").forEach(function(t){var n=t.split("="),r=n[0],o=n[1];r=decodeURIComponent(r),o=decodeURIComponent(o),r&&(e[r]?Array.isArray(e[r])?e[r].push(o):e[r]=[e[r],o]:e[r]=o)}),e},e.parseCaptcha=function(t){var n={},r=t.match(/^(data:.*?)(\?[^#\s]*)?$/);if(r){t=r[1];var o=r[2];o&&(n=(0,e.parseQueryString)(o))}var i=n.token,c=a(n,["token"]);return/^data:/.test(t)&&!i?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(t)}:i?{state:c.state,token:i,captchaData:t}:{error:"unimplemented",error_description:"need to impl captcha data"}}},954:function(t,e,n){n.r(e),n.d(e,{CollectionReference:function(){return ce},Db:function(){return Oe},DocumentReference:function(){return Kt},Query:function(){return re}});var r,o,i={};n.r(i),n.d(i,{LineString:function(){return B},MultiLineString:function(){return z},MultiPoint:function(){return V},MultiPolygon:function(){return X},Point:function(){return wt},Polygon:function(){return H}}),function(t){t.DocIDError="文档ID不合法",t.CollNameError="集合名称不合法",t.OpStrError="操作符不合法",t.DirectionError="排序字符不合法",t.IntergerError="must be integer",t.BooleanError="must be boolean",t.ArrayError="must be array",t.QueryParamTypeError="查询参数必须为对象",t.QueryParamValueError="查询参数对象值不能均为undefined",t.CentersPhereError="centersPhere结构不合法"}(o||(o={}));var a,c,u="Object",s="GeoPoint",l="GeoLineString",f="GeoPolygon",d="GeoMultiPoint",p="GeoMultiLineString",h="GeoMultiPolygon",y="Date",m="ServerDate",v=["desc","asc"],g=["<","<=","==",">=",">"];!function(t){t.lt="<",t.gt=">",t.lte="<=",t.gte=">=",t.eq="=="}(a||(a={})),(r={})[a.eq]="$eq",r[a.lt]="$lt",r[a.lte]="$lte",r[a.gt]="$gt",r[a.gte]="$gte",function(t){t.WHERE="WHERE",t.DOC="DOC"}(c||(c={}));var b,w=(b=function(t,e){return b=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},b(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}b(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),_=[],O={},E=function(t){function e(e,n){if(n!==O)throw new TypeError("InternalSymbol cannot be constructed with new operator");return t.call(this,e)||this}return w(e,t),e.for=function(t){for(var n=0,r=_.length;n<r;n++)if(_[n].target===t)return _[n].instance;var o=new e(t,O);return _.push({target:t,instance:o}),o},e}(function(t){Object.defineProperties(this,{target:{enumerable:!1,writable:!1,configurable:!1,value:t}})}),S=E,I=S.for("UNSET_FIELD_NAME"),N=S.for("UPDATE_COMMAND"),P=S.for("QUERY_COMMAND"),T=S.for("LOGIC_COMMAND"),j=S.for("GEO_POINT"),x=S.for("SYMBOL_GEO_LINE_STRING"),A=S.for("SYMBOL_GEO_POLYGON"),R=S.for("SYMBOL_GEO_MULTI_POINT"),C=S.for("SYMBOL_GEO_MULTI_LINE_STRING"),D=S.for("SYMBOL_GEO_MULTI_POLYGON"),q=S.for("SERVER_DATE"),F=S.for("REGEXP"),L=S.for("OBJECTID"),W=function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},M=function(t){return"object"===W(t)},k=function(t){return"number"===W(t)},U=function(t){return Array.isArray(t)},J=function(t){return"date"===W(t)},$=function(t){return"regexp"===W(t)},G=function(t){return t&&t._internalType instanceof E},B=function(){function t(t){if(!U(t))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof t));if(t.length<2)throw new Error('"points" must contain 2 points at least');t.forEach(function(t){if(!(t instanceof wt))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof t,"[]"))}),this.points=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"LineString",coordinates:this.points.map(function(t){return t.toJSON().coordinates})},e},t.prototype.toJSON=function(){return{type:"LineString",coordinates:this.points.map(function(t){return t.toJSON().coordinates})}},t.validate=function(t){var e,n;if("LineString"!==t.type||!U(t.coordinates))return!1;try{for(var r=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(t.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!k(i[0])||!k(i[1]))return!1}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return!0},t.isClosed=function(t){var e=t.points[0],n=t.points[t.points.length-1];if(e.latitude===n.latitude&&e.longitude===n.longitude)return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return x},enumerable:!1,configurable:!0}),t}(),Q=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},H=function(){function t(t){if(!U(t))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof t));if(0===t.length)throw new Error("Polygon must contain 1 linestring at least");t.forEach(function(t){if(!(t instanceof B))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof t,"[]"));if(!B.isClosed(t))throw new Error("LineString ".concat(t.points.map(function(t){return t.toReadableString()})," is not a closed cycle"))}),this.lines=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"Polygon",coordinates:this.lines.map(function(t){return t.points.map(function(t){return[t.longitude,t.latitude]})})},e},t.prototype.toJSON=function(){return{type:"Polygon",coordinates:this.lines.map(function(t){return t.points.map(function(t){return[t.longitude,t.latitude]})})}},t.validate=function(t){var e,n,r,o;if("Polygon"!==t.type||!U(t.coordinates))return!1;try{for(var i=Q(t.coordinates),a=i.next();!a.done;a=i.next()){var c=a.value;if(!this.isCloseLineString(c))return!1;try{for(var u=(r=void 0,Q(c)),s=u.next();!s.done;s=u.next()){var l=s.value;if(!k(l[0])||!k(l[1]))return!1}}catch(t){r={error:t}}finally{try{s&&!s.done&&(o=u.return)&&o.call(u)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return!0},t.isCloseLineString=function(t){var e=t[0],n=t[t.length-1];return e[0]===n[0]&&e[1]===n[1]},Object.defineProperty(t.prototype,"_internalType",{get:function(){return A},enumerable:!1,configurable:!0}),t}(),V=function(){function t(t){if(!U(t))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof t));if(0===t.length)throw new Error('"points" must contain 1 point at least');t.forEach(function(t){if(!(t instanceof wt))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof t,"[]"))}),this.points=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"MultiPoint",coordinates:this.points.map(function(t){return t.toJSON().coordinates})},e},t.prototype.toJSON=function(){return{type:"MultiPoint",coordinates:this.points.map(function(t){return t.toJSON().coordinates})}},t.validate=function(t){var e,n;if("MultiPoint"!==t.type||!U(t.coordinates))return!1;try{for(var r=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(t.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!k(i[0])||!k(i[1]))return!1}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return R},enumerable:!1,configurable:!0}),t}(),Y=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},z=function(){function t(t){if(!U(t))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof t));if(0===t.length)throw new Error("Polygon must contain 1 linestring at least");t.forEach(function(t){if(!(t instanceof B))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof t,"[]"))}),this.lines=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"MultiLineString",coordinates:this.lines.map(function(t){return t.points.map(function(t){return[t.longitude,t.latitude]})})},e},t.prototype.toJSON=function(){return{type:"MultiLineString",coordinates:this.lines.map(function(t){return t.points.map(function(t){return[t.longitude,t.latitude]})})}},t.validate=function(t){var e,n,r,o;if("MultiLineString"!==t.type||!U(t.coordinates))return!1;try{for(var i=Y(t.coordinates),a=i.next();!a.done;a=i.next()){var c=a.value;try{for(var u=(r=void 0,Y(c)),s=u.next();!s.done;s=u.next()){var l=s.value;if(!k(l[0])||!k(l[1]))return!1}}catch(t){r={error:t}}finally{try{s&&!s.done&&(o=u.return)&&o.call(u)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return C},enumerable:!1,configurable:!0}),t}(),K=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},X=function(){function t(t){var e,n;if(!U(t))throw new TypeError('"polygons" must be of type Polygon[]. Received type '.concat(typeof t));if(0===t.length)throw new Error("MultiPolygon must contain 1 polygon at least");try{for(var r=K(t),o=r.next();!o.done;o=r.next()){var i=o.value;if(!(i instanceof H))throw new TypeError('"polygon" must be of type Polygon[]. Received type '.concat(typeof i,"[]"))}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}this.polygons=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"MultiPolygon",coordinates:this.polygons.map(function(t){return t.lines.map(function(t){return t.points.map(function(t){return[t.longitude,t.latitude]})})})},e},t.prototype.toJSON=function(){return{type:"MultiPolygon",coordinates:this.polygons.map(function(t){return t.lines.map(function(t){return t.points.map(function(t){return[t.longitude,t.latitude]})})})}},t.validate=function(t){var e,n,r,o,i,a;if("MultiPolygon"!==t.type||!U(t.coordinates))return!1;try{for(var c=K(t.coordinates),u=c.next();!u.done;u=c.next()){var s=u.value;try{for(var l=(r=void 0,K(s)),f=l.next();!f.done;f=l.next()){var d=f.value;try{for(var p=(i=void 0,K(d)),h=p.next();!h.done;h=p.next()){var y=h.value;if(!k(y[0])||!k(y[1]))return!1}}catch(t){i={error:t}}finally{try{h&&!h.done&&(a=p.return)&&a.call(p)}finally{if(i)throw i.error}}}}catch(t){r={error:t}}finally{try{f&&!f.done&&(o=l.return)&&o.call(l)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return D},enumerable:!1,configurable:!0}),t}(),Z=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a},tt=function(){function t(){}return t.formatResDocumentData=function(e){return e.map(function(e){return t.formatField(e)})},t.formatField=function(e){var n=Object.keys(e),r={};return Array.isArray(e)&&(r=[]),n.forEach(function(n){var o,i=e[n];switch(t.whichType(i)){case s:o=new wt(i.coordinates[0],i.coordinates[1]);break;case l:o=new B(i.coordinates.map(function(t){return new wt(t[0],t[1])}));break;case f:o=new H(i.coordinates.map(function(t){return new B(t.map(function(t){var e=Z(t,2),n=e[0],r=e[1];return new wt(n,r)}))}));break;case d:o=new V(i.coordinates.map(function(t){return new wt(t[0],t[1])}));break;case p:o=new z(i.coordinates.map(function(t){return new B(t.map(function(t){var e=Z(t,2),n=e[0],r=e[1];return new wt(n,r)}))}));break;case h:o=new X(i.coordinates.map(function(t){return new H(t.map(function(t){return new B(t.map(function(t){var e=Z(t,2),n=e[0],r=e[1];return new wt(n,r)}))}))}));break;case y:o=i;break;case u:case"Array":o=t.formatField(i);break;case m:o=new Date(i.$date);break;default:o=i}Array.isArray(r)?r.push(o):r[n]=o}),r},t.whichType=function(t){var e=Object.prototype.toString.call(t).slice(8,-1);return e===y?y:(e===u&&(t.$date?e=m:wt.validate(t)?e=s:B.validate(t)?e=l:H.validate(t)?e=f:V.validate(t)?e=d:z.validate(t)?e=p:X.validate(t)&&(e=h)),e)},t.generateDocId=function(){for(var t="",e=0;e<24;e++)t+="ABCDEFabcdef0123456789".charAt(Math.floor(22*Math.random()));return t},t}(),et={code:"INVALID_PARAM",message:"Invalid request param"},nt="DATABASE_TRANSACTION_CONFLICT",rt={code:"DATABASE_REQUEST_FAILED",message:"database request failed"},ot=n(701),it=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),at=function(){return at=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},at.apply(this,arguments)};function ct(t,e){if("function"!=typeof e)return t;t.then(function(t){return e(0,t)},function(t){return e(t)})}var ut={};function st(t){if(!Oe.wsClientClass)throw new Error("to use realtime you must import realtime module first");var e=t.config.env;return ut[e]||(ut[e]=new Oe.wsClientClass({context:{appConfig:{docSizeLimit:1e3,realtimePingInterval:1e4,realtimePongWaitTimeout:5e3,request:Oe.createRequest(t.config)}}})),ut[e]}var lt=function(t){return void 0!==t.timeout?{timeout:t.timeout}:{}},ft=function(t){if(!M(t))return t;for(var e in t)void 0===t[e]?delete t[e]:M(t[e])&&(t[e]=ft(t[e]));return t},dt=function(t){return t=ft(t),ot.EJSON.stringify(t,{relaxed:!1})},pt=function(t){function e(e){var n=t.call(this,e.message)||this;return n.code=e.code,n.message=e.message,n}return it(e,t),e}(Error),ht=function(t){return new pt(t)};function yt(t,e){if(!1===t)return e;throw ht(at({},e))}var mt,vt=function(){return vt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},vt.apply(this,arguments)},gt=["limit","offset","projection","order","multiple","timeout","raw"],bt=function(){function t(){}return t.isGeopoint=function(t,e){if("Number"!==tt.whichType(e))throw new Error("Geo Point must be number type");var n=Math.abs(e);if("latitude"===t&&n>90)throw new Error("latitude should be a number ranges from -90 to 90");if("longitude"===t&&n>180)throw new Error("longitude should be a number ranges from -180 to 180");return!0},t.isInteger=function(t,e){if(!Number.isInteger(e))throw new Error(t+o.IntergerError);return!0},t.mustBeBoolean=function(t,e){if("boolean"!=typeof e)throw new Error(t+o.BooleanError);return!0},t.isProjection=function(t,e){if("object"!==W(e))throw ht(vt(vt({},et),{message:"".concat(t," projection must be an object")}));for(var n in e){var r=e[n];if("number"===W(r)){if(0!==r&&1!==r)throw ht(vt(vt({},et),{message:"if the value in projection is of number, it must be 0 or 1"}))}else if("object"!==W(r))throw ht(vt(vt({},et),{message:"invalid projection"}))}return!0},t.isOrder=function(t,e){if("object"!==W(e))throw ht(vt(vt({},et),{message:"".concat(t," order must be an object")}));for(var n in e){var r=e[n];if(1!==r&&-1!==r)throw ht(vt(vt({},et),{message:"order value must be 1 or -1"}))}return!0},t.isFieldOrder=function(t){if(-1===v.indexOf(t))throw new Error(o.DirectionError);return!0},t.isFieldPath=function(t){if(!/^[a-zA-Z0-9-_\.]/.test(t))throw new Error;return!0},t.isOperator=function(t){if(-1===g.indexOf(t))throw new Error(o.OpStrError);return!0},t.isCollName=function(t){if(!/^[a-zA-Z0-9]([a-zA-Z0-9-_]){1,32}$/.test(t))throw new Error(o.CollNameError);return!0},t.isDocID=function(t){if(!/^([a-fA-F0-9]){24}$/.test(t))throw new Error(o.DocIDError);return!0},t.isValidOptions=function(e){if(void 0===e&&(e={}),"object"!==W(e))throw ht(vt(vt({},et),{message:"options must be an object"}));var n=Object.keys(e);for(var r in n)if(gt.indexOf(n[r])<0)throw ht(vt(vt({},et),{message:"".concat(n[r]," is invalid options key")}));var o=e,i=o.limit,a=o.offset,c=o.projection,u=o.order,s=e.multiple;return void 0!==i&&t.isInteger("limit",i),void 0!==a&&t.isInteger("offset",a),void 0!==c&&t.isProjection("projection",c),void 0!==u&&t.isOrder("order",u),void 0!==s&&t.mustBeBoolean("multiple",s),void 0!==e.timeout&&t.isInteger("timeout",e.timeout),!0},t.isValidAggregation=function(t){if(1!==Object.keys(t).length)throw ht(vt(vt({},et),{message:"aggregation stage must have one key"}));return!0},t.isCentersPhere=function(e){if(Array.isArray(e)&&2===e.length){if("object"===W(e[0])&&e[0]._internalType===j&&"number"==typeof e[1])return!0;if(Array.isArray(e[0])&&2===e[0].length){var n=e[0][0],r=e[0][1];if(t.isGeopoint("longitude",n),t.isGeopoint("latitude",r),"number"==typeof e[1])return!0}}throw new Error("".concat(o.CentersPhereError))},t}(),wt=function(){function t(t,e){bt.isGeopoint("longitude",t),bt.isGeopoint("latitude",e),this.longitude=t,this.latitude=e}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"Point",coordinates:[this.longitude,this.latitude]},e},t.prototype.toJSON=function(){return{type:"Point",coordinates:[this.longitude,this.latitude]}},t.prototype.toReadableString=function(){return"[".concat(this.longitude,",").concat(this.latitude,"]")},t.validate=function(t){return"Point"===t.type&&U(t.coordinates)&&bt.isGeopoint("longitude",t.coordinates[0])&&bt.isGeopoint("latitude",t.coordinates[1])},Object.defineProperty(t.prototype,"_internalType",{get:function(){return j},enumerable:!1,configurable:!0}),t}();!function(t){t.SET="set",t.REMOVE="remove",t.INC="inc",t.MUL="mul",t.PUSH="push",t.PULL="pull",t.PULL_ALL="pullAll",t.POP="pop",t.SHIFT="shift",t.UNSHIFT="unshift",t.ADD_TO_SET="addToSet",t.BIT="bit",t.RENAME="rename",t.MAX="max",t.MIN="min"}(mt||(mt={}));var _t,Ot=function(){function t(t,e,n){this._internalType=N,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=t,this.operands=e,this.fieldName=n||I}return t.prototype._setFieldName=function(e){return new t(this.operator,this.operands,e)},t}();function Et(t){return t&&t instanceof Ot&&t._internalType===N}!function(t){t.AND="and",t.OR="or",t.NOT="not",t.NOR="nor"}(_t||(_t={}));var St=function(){function t(t,e,n){if(this._internalType=T,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=t,this.operands=e,this.fieldName=n||I,this.fieldName!==I)if(Array.isArray(e)){e=e.slice(),this.operands=e;for(var r=0,o=e.length;r<o;r++)(It(i=e[r])||jt(i))&&(e[r]=i._setFieldName(this.fieldName))}else{var i;(It(i=e)||jt(i))&&(e=i._setFieldName(this.fieldName))}}return t.prototype._setFieldName=function(e){var n=this.operands.map(function(n){return n instanceof t?n._setFieldName(e):n});return new t(this.operator,n,e)},t.prototype.and=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return r.unshift(this),new t(_t.AND,r,this.fieldName)},t.prototype.or=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return r.unshift(this),new t(_t.OR,r,this.fieldName)},t}();function It(t){return t&&t instanceof St&&t._internalType===T}var Nt,Pt=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();!function(t){t.EQ="eq",t.NEQ="neq",t.GT="gt",t.GTE="gte",t.LT="lt",t.LTE="lte",t.IN="in",t.NIN="nin",t.ALL="all",t.ELEM_MATCH="elemMatch",t.EXISTS="exists",t.SIZE="size",t.MOD="mod",t.GEO_NEAR="geoNear",t.GEO_WITHIN="geoWithin",t.GEO_INTERSECTS="geoIntersects"}(Nt||(Nt={}));var Tt=function(t){function e(e,n,r){var o=t.call(this,e,n,r)||this;return o.operator=e,o._internalType=P,o}return Pt(e,t),e.prototype.toJSON=function(){var t,e,n;switch(this.operator){case Nt.IN:case Nt.NIN:return(t={})["$"+this.operator]=this.operands,t;case Nt.NEQ:return(e={}).$ne=this.operands[0],e;default:return(n={})["$"+this.operator]=this.operands[0],n}},e.prototype._setFieldName=function(t){return new e(this.operator,this.operands,t)},e.prototype.eq=function(t){var n=new e(Nt.EQ,[t],this.fieldName);return this.and(n)},e.prototype.neq=function(t){var n=new e(Nt.NEQ,[t],this.fieldName);return this.and(n)},e.prototype.gt=function(t){var n=new e(Nt.GT,[t],this.fieldName);return this.and(n)},e.prototype.gte=function(t){var n=new e(Nt.GTE,[t],this.fieldName);return this.and(n)},e.prototype.lt=function(t){var n=new e(Nt.LT,[t],this.fieldName);return this.and(n)},e.prototype.lte=function(t){var n=new e(Nt.LTE,[t],this.fieldName);return this.and(n)},e.prototype.in=function(t){var n=new e(Nt.IN,t,this.fieldName);return this.and(n)},e.prototype.nin=function(t){var n=new e(Nt.NIN,t,this.fieldName);return this.and(n)},e.prototype.geoNear=function(t){if(!(t.geometry instanceof wt))throw new TypeError('"geometry" must be of type Point. Received type '.concat(typeof t.geometry));if(void 0!==t.maxDistance&&!k(t.maxDistance))throw new TypeError('"maxDistance" must be of type Number. Received type '.concat(typeof t.maxDistance));if(void 0!==t.minDistance&&!k(t.minDistance))throw new TypeError('"minDistance" must be of type Number. Received type '.concat(typeof t.minDistance));var n=new e(Nt.GEO_NEAR,[t],this.fieldName);return this.and(n)},e.prototype.geoWithin=function(t){if(!(t.geometry instanceof X||t.geometry instanceof H||bt.isCentersPhere(t.centerSphere)))throw new TypeError('"geometry" must be of type Polygon or MultiPolygon. Received type '.concat(typeof t.geometry));var n=new e(Nt.GEO_WITHIN,[t],this.fieldName);return this.and(n)},e.prototype.geoIntersects=function(t){if(!(t.geometry instanceof wt||t.geometry instanceof B||t.geometry instanceof H||t.geometry instanceof V||t.geometry instanceof z||t.geometry instanceof X))throw new TypeError('"geometry" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type '.concat(typeof t.geometry));var n=new e(Nt.GEO_INTERSECTS,[t],this.fieldName);return this.and(n)},e}(St);function jt(t){return t&&t instanceof Tt&&t._internalType===P}function xt(t){return jt(t)}var At={};for(var Rt in Nt)At[Rt]="$"+Rt;for(var Rt in _t)At[Rt]="$"+Rt;for(var Rt in mt)At[Rt]="$"+Rt;function Ct(t){return At[t]||"$"+t}At[Nt.NEQ]="$ne",At[mt.REMOVE]="$unset",At[mt.SHIFT]="$pop",At[mt.UNSHIFT]="$push";var Dt=function(){return Dt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Dt.apply(this,arguments)},qt=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a},Ft=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))};function Lt(t){return Wt(t,[t])}function Wt(t,e){if(!G(t)){if(J(t))return t;if($(t))return{$regularExpression:{pattern:t.source,options:t.flags}};if(U(t))return t.map(function(t){if(e.indexOf(t)>-1)throw new Error("Cannot convert circular structure to JSON");return Wt(t,Ft(Ft([],qt(e),!1),[t],!1))});if(M(t)){var n=Dt({},t),r={};for(var o in n){if(e.indexOf(n[o])>-1)throw new Error("Cannot convert circular structure to JSON");void 0!==n[o]&&(r[o]=Wt(n[o],Ft(Ft([],qt(e),!1),[n[o]],!1)))}return r}return t}switch(t._internalType){case j:return t.toJSON();case q:case F:case L:return t.parse();default:return t.toJSON?t.toJSON():t}}var Mt=function(){return Mt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Mt.apply(this,arguments)},kt=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a},Ut=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))};function Jt(t,e,n,r){var o=Mt({},t);for(var i in t)if(!/^\$/.test(i)){var a=t[i];if(void 0!==a){if(a&&M(a)&&!e(a)){if(r.indexOf(a)>-1)throw new Error("Cannot convert circular structure to JSON");var c=Jt(a,e,Ut(Ut([],kt(n),!1),[i],!1),Ut(Ut([],kt(r),!1),[a],!1));o[i]=c;var u=!1;for(var s in c)/^\$/.test(s)?u=!0:(o["".concat(i,".").concat(s)]=c[s],delete o[i][s]);u||delete o[i]}}else delete o[i]}return o}function $t(t){return Jt(t,Bt,[],[t])}function Gt(t,e,n){for(var r in e[n]||delete t[n],e)t[r]?U(t[r])?t[r].push(e[r]):M(t[r])?M(e[r])?Object.assign(t[r],e[r]):(console.warn("unmergable condition, query is object but condition is ".concat(W(e),", can only overwrite"),e,n),t[r]=e[r]):(console.warn("to-merge query is of type ".concat(W(t),", can only overwrite"),t,e,n),t[r]=e[r]):t[r]=e[r]}function Bt(t){return G(t)||J(t)||$(t)}function Qt(t){return Lt(t)}var Ht=function(){function t(){}return t.encode=function(e){return(new t).encodeUpdate(e)},t.encodeEJSON=function(e,n){var r=new t;return dt(n?e:r.encodeUpdate(e))},t.prototype.encodeUpdate=function(t){return Et(t)?this.encodeUpdateCommand(t):"object"===W(t)?this.encodeUpdateObject(t):t},t.prototype.encodeUpdateCommand=function(t){if(t.fieldName===I)throw new Error("Cannot encode a comparison command with unset field name");switch(t.operator){case mt.PUSH:case mt.PULL:case mt.PULL_ALL:case mt.POP:case mt.SHIFT:case mt.UNSHIFT:case mt.ADD_TO_SET:return this.encodeArrayUpdateCommand(t);default:return this.encodeFieldUpdateCommand(t)}},t.prototype.encodeFieldUpdateCommand=function(t){var e,n,r,o,i=Ct(t.operator);return t.operator===mt.REMOVE?((e={})[i]=((n={})[t.fieldName]="",n),e):((r={})[i]=((o={})[t.fieldName]=t.operands[0],o),r)},t.prototype.encodeArrayUpdateCommand=function(t){var e,n,r,o,i,a,c,u,s,l,f=Ct(t.operator);switch(t.operator){case mt.PUSH:var d=void 0;return d=U(t.operands)?{$each:t.operands.map(Qt)}:t.operands,(e={})[f]=((n={})[t.fieldName]=d,n),e;case mt.UNSHIFT:return d={$each:t.operands.map(Qt),$position:0},(r={})[f]=((o={})[t.fieldName]=d,o),r;case mt.POP:return(i={})[f]=((a={})[t.fieldName]=1,a),i;case mt.SHIFT:return(c={})[f]=((u={})[t.fieldName]=-1,u),c;default:return(s={})[f]=((l={})[t.fieldName]=Qt(t.operands),l),s}},t.prototype.encodeUpdateObject=function(t){var e=$t(t);for(var n in e)if(!/^\$/.test(n)){var r=e[n];if(Et(r))e[n]=r._setFieldName(n),Gt(e,this.encodeUpdateCommand(e[n]),n);else{e[n]=r=Qt(r);var o=new Ot(mt.SET,[r],n);Gt(e,this.encodeUpdateCommand(o),n)}}return e},t}(),Vt=function(){return Vt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Vt.apply(this,arguments)},Yt=function(t,e,n,r){return new(n||(n=Promise))(function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function c(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,c)}u((r=r.apply(t,e||[])).next())})},zt=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=e.call(t,a)}catch(t){c=[6,t],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}},Kt=function(){function t(t,e,n,r,o){var i=this;this.watch=function(t){return st(i._db).watch(Vt(Vt({},t),{envId:i._db.config.env,collectionName:i._coll,query:JSON.stringify({_id:i.id})}))},this._db=t,this._coll=e,this.id=r,this._transactionId=o,this.request=Oe.createRequest(this._db.config),this._apiOptions=n}return t.prototype.create=function(t,e){return ct(this._create(t),e)},t.prototype._create=function(t){return Yt(this,void 0,void 0,function(){var e,n,r;return zt(this,function(o){switch(o.label){case 0:return!(e=Array.isArray(t))&&this.id&&(t._id=this.id),n={collectionName:this._coll,data:e?t.map(function(t){return dt(Lt(t))}):[dt(Lt(t))],transactionId:this._transactionId},[4,this.request.send("database.insertDocument",n,lt(this._apiOptions))];case 1:return(r=o.sent()).code?[2,r]:this._transactionId?[2,{inserted:1,ok:1,id:r.data.insertedIds[0],requestId:r.requestId}]:e?[2,{ids:r.data&&r.data.insertedIds||[],requestId:r.requestId}]:[2,{id:r.data.insertedIds[0],requestId:r.requestId}]}})})},t.prototype.set=function(t,e){return ct(this._set(t),e)},t.prototype._set=function(t){return Yt(this,void 0,void 0,function(){var e,n,r,o;return zt(this,function(i){switch(i.label){case 0:return this.id?t&&"object"==typeof t?t.hasOwnProperty("_id")?[2,yt(this._db.config.throwOnCode,Vt(Vt({},et),{message:"不能更新_id的值"}))]:(e=!1,n=function(t){if("object"==typeof t)for(var r in t)t[r]instanceof Ot?e=!0:"object"==typeof t[r]&&n(t[r])},n(t),e?[2,yt(this._db.config.throwOnCode,Vt(Vt({},rt),{message:"update operator complicit"}))]:(r={collectionName:this._coll,queryType:c.DOC,data:dt(Lt(t)),transactionId:this._transactionId,multi:!1,merge:!1,upsert:!0},this.id&&(r.query=dt({_id:this.id})),[4,this.request.send("database.modifyDocument",r,lt(this._apiOptions))])):[2,yt(this._db.config.throwOnCode,Vt(Vt({},et),{message:"参数必需是非空对象"}))]:[2,yt(this._db.config.throwOnCode,Vt(Vt({},et),{message:"docId不能为空"}))];case 1:return(o=i.sent()).code?[2,o]:this._transactionId?[2,{updated:o.data.updated,upserted:[{_id:o.data.upsert_id}],requestId:o.requestId}]:[2,{updated:o.data.updated,upsertedId:o.data.upsert_id,requestId:o.requestId}]}})})},t.prototype.update=function(t,e){return ct(this._update(t),e)},t.prototype._update=function(t){return Yt(this,void 0,void 0,function(){var e,n,r;return zt(this,function(o){switch(o.label){case 0:return t&&"object"==typeof t?t.hasOwnProperty("_id")?[2,yt(this._db.config.throwOnCode,Vt(Vt({},et),{message:"不能更新_id的值"}))]:(e=dt({_id:this.id}),n={collectionName:this._coll,transactionId:this._transactionId,data:Ht.encodeEJSON(t,this._apiOptions.raw||!1),query:e,queryType:c.DOC,multi:!1,merge:!0,upsert:!1},[4,this.request.send("database.modifyDocument",n,lt(this._apiOptions))]):[2,yt(this._db.config.throwOnCode,Vt(Vt({},et),{message:"参数必需是非空对象"}))];case 1:return(r=o.sent()).code?[2,r]:[2,{updated:r.data.updated,requestId:r.requestId}]}})})},t.prototype.delete=function(t){return this.remove(t)},t.prototype.remove=function(t){return ct(this._remove(),t)},t.prototype._remove=function(){return Yt(this,void 0,void 0,function(){var t,e,n;return zt(this,function(r){switch(r.label){case 0:return t=dt({_id:this.id}),e={collectionName:this._coll,transactionId:this._transactionId,query:t,queryType:c.DOC,multi:!1},[4,this.request.send("database.removeDocument",e,lt(this._apiOptions))];case 1:return(n=r.sent()).code?[2,n]:[2,{deleted:n.data.deleted,requestId:n.requestId}]}})})},t.prototype.get=function(t){return ct(this._get(),t)},t.prototype._get=function(){return Yt(this,void 0,void 0,function(){var t,e,n,r,o,i;return zt(this,function(a){switch(a.label){case 0:return t=dt({_id:this.id}),e=this._apiOptions.projection,n={collectionName:this._coll,query:t,transactionId:this._transactionId,queryType:c.DOC,multi:!1},e&&(n.projection=dt(e)),[4,this.request.send("database.getDocument",n,lt(this._apiOptions))];case 1:return(r=a.sent()).code?[2,r]:(o=r.data.list.map(function(t){return ot.EJSON.parse(t)}),i=tt.formatResDocumentData(o),this._transactionId?[2,{data:i[0]||null,requestId:r.requestId}]:[2,{data:i,requestId:r.requestId}])}})})},t.prototype.field=function(e){var n={};for(var r in e)"boolean"==typeof e[r]&&(n[r]=!0===e[r]?1:0),"number"==typeof e[r]&&(n[r]=e[r]>0?1:0),"object"==typeof e[r]&&(n[r]=e[r]);var o=Vt({},this._apiOptions);return o.projection=n,new t(this._db,this._coll,o,this.id,this._transactionId)},t}(),Xt=function(){function t(){}return t.encode=function(t){return(new Zt).encodeQuery(t)},t.encodeEJSON=function(t,e){var n=new Zt;return dt(e?t:n.encodeQuery(t))},t}(),Zt=function(){function t(){}return t.prototype.encodeQuery=function(t,e){var n,r,o;return Bt(t)?It(t)?this.encodeLogicCommand(t):jt(t)?this.encodeQueryCommand(t):$(t)?((n={})[e]=this.encodeRegExp(t),n):J(t)?((r={})[e]=Qt(t),r):((o={})[e]=this.encodeQueryObject(t),o):M(t)?this.encodeQueryObject(t):t},t.prototype.encodeRegExp=function(t){return{$regularExpression:{pattern:t.source,options:t.flags}}},t.prototype.encodeLogicCommand=function(t){var e,n,r,o,i,a,c,u=this;switch(t.operator){case _t.NOR:case _t.AND:case _t.OR:var s=Ct(t.operator),l=t.operands.map(function(e){return u.encodeQuery(e,t.fieldName)});return(e={})[s]=l,e;case _t.NOT:s=Ct(t.operator);var f=t.operands[0];return $(f)?((n={})[t.fieldName]=((r={})[s]=this.encodeRegExp(f),r),n):(l=this.encodeQuery(f)[t.fieldName],(o={})[t.fieldName]=((i={})[s]=l,i),o);default:if(s=Ct(t.operator),1===t.operands.length){var d=this.encodeQuery(t.operands[0]);return(a={})[s]=d,a}return l=t.operands.map(this.encodeQuery.bind(this)),(c={})[s]=l,c}},t.prototype.encodeQueryCommand=function(t){return xt(t),this.encodeComparisonCommand(t)},t.prototype.encodeComparisonCommand=function(t){var e,n,r,o,i,a,c,u,s,l,f;if(t.fieldName===I)throw new Error("Cannot encode a comparison command with unset field name");var d=Ct(t.operator);switch(t.operator){case Nt.EQ:case Nt.NEQ:case Nt.LT:case Nt.LTE:case Nt.GT:case Nt.GTE:case Nt.ELEM_MATCH:case Nt.EXISTS:case Nt.SIZE:case Nt.MOD:return(e={})[t.fieldName]=((n={})[d]=Qt(t.operands[0]),n),e;case Nt.IN:case Nt.NIN:case Nt.ALL:return(r={})[t.fieldName]=((o={})[d]=Qt(t.operands),o),r;case Nt.GEO_NEAR:var p=t.operands[0];return(i={})[t.fieldName]={$nearSphere:{$geometry:p.geometry.toJSON(),$maxDistance:p.maxDistance,$minDistance:p.minDistance}},i;case Nt.GEO_WITHIN:if((p=t.operands[0]).centerSphere){bt.isCentersPhere(p.centerSphere);var h=p.centerSphere;return h[0]._internalType===j?((a={})[t.fieldName]={$geoWithin:{$centerSphere:[h[0].toJSON().coordinates,h[1]]}},a):((c={})[t.fieldName]={$geoWithin:{$centerSphere:p.centerSphere}},c)}return(u={})[t.fieldName]={$geoWithin:{$geometry:p.geometry.toJSON()}},u;case Nt.GEO_INTERSECTS:return p=t.operands[0],(s={})[t.fieldName]={$geoIntersects:{$geometry:p.geometry.toJSON()}},s;default:return(l={})[t.fieldName]=((f={})[d]=Qt(t.operands[0]),f),l}},t.prototype.encodeQueryObject=function(t){var e=$t(t);for(var n in e){var r=e[n];if(It(r)){e[n]=r._setFieldName(n);var o=this.encodeLogicCommand(e[n]);this.mergeConditionAfterEncode(e,o,n)}else xt(r)?(e[n]=r._setFieldName(n),o=this.encodeComparisonCommand(e[n]),this.mergeConditionAfterEncode(e,o,n)):Bt(r)&&(e[n]=Qt(r))}return e},t.prototype.mergeConditionAfterEncode=function(t,e,n){for(var r in e[n]||delete t[n],e)t[r]?U(t[r])?t[r]=t[r].concat(e[r]):M(t[r])?M(e[r])?Object.assign(t,e):(console.warn("unmergable condition, query is object but condition is ".concat(W(e),", can only overwrite"),e,n),t[r]=e[r]):(console.warn("to-merge query is of type ".concat(W(t),", can only overwrite"),t,e,n),t[r]=e[r]):t[r]=e[r]},t}(),te=function(){return te=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},te.apply(this,arguments)},ee=function(t,e,n,r){return new(n||(n=Promise))(function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function c(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,c)}u((r=r.apply(t,e||[])).next())})},ne=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=e.call(t,a)}catch(t){c=[6,t],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}},re=function(){function t(t,e,n,r,o){var i=this;this.watch=function(t){var e=st(i._db),n=i._apiOptions,r=n.limit,o=n.order;return e.watch(te(te({},t),{envId:i._db.config.env,collectionName:i._coll,query:JSON.stringify(i._fieldFilters),limit:r,orderBy:o?o.reduce(function(t,e){return t[e.field]=e.direction,t},{}):void 0}))},this._db=t,this._coll=e,this._fieldFilters=n,this._apiOptions=r||{},this._request=Oe.createRequest(this._db.config),this._transactionId=o}return t.prototype.get=function(t){return ct(this._get(),t)},t.prototype._get=function(){return ee(this,void 0,void 0,function(){var t,e,n,r,o,i,a,u,s;return ne(this,function(l){switch(l.label){case 0:return t=this._apiOptions.order,e={collectionName:this._coll,queryType:c.WHERE,transactionId:this._transactionId},this._fieldFilters&&(e.query=this._fieldFilters),t&&(e.order=dt(t)),(n=this._apiOptions.offset)&&(e.offset=n),r=this._apiOptions.limit,e.limit=r?r<1e3?r:1e3:100,(o=this._apiOptions.projection)&&(e.projection=dt(o)),[4,this._request.send("database.getDocument",e,lt(this._apiOptions))];case 1:return(i=l.sent()).code?[2,i]:(a=i.data.list.map(function(t){return ot.EJSON.parse(t)}),u=tt.formatResDocumentData(a),s={data:u,requestId:i.requestId},i.total&&(s.total=i.total),i.limit&&(s.limit=i.limit),i.offset&&(s.offset=i.offset),[2,s])}})})},t.prototype.count=function(t){return ct(this._count(),t)},t.prototype._count=function(){return ee(this,void 0,void 0,function(){var t,e;return ne(this,function(n){switch(n.label){case 0:return t={collectionName:this._coll,queryType:c.WHERE},this._fieldFilters&&(t.query=this._fieldFilters),[4,this._request.send("database.calculateDocument",t,lt(this._apiOptions))];case 1:return(e=n.sent()).code?[2,e]:[2,{requestId:e.requestId,total:e.data.total}]}})})},t.prototype.where=function(e){if("Object"!==Object.prototype.toString.call(e).slice(8,-1))throw Error(o.QueryParamTypeError);var n=Object.keys(e),r=n.some(function(t){return void 0!==e[t]});if(n.length&&!r)throw Error(o.QueryParamValueError);return new t(this._db,this._coll,Xt.encodeEJSON(e,this._apiOptions.raw||!1),this._apiOptions,this._transactionId)},t.prototype.options=function(e){return bt.isValidOptions(e),new t(this._db,this._coll,this._fieldFilters,e,this._transactionId)},t.prototype.orderBy=function(e,n){var r;bt.isFieldPath(e),bt.isFieldOrder(n);var o=((r={})[e]="desc"===n?-1:1,r),i=this._apiOptions.order||{},a=Object.assign({},this._apiOptions,{order:Object.assign({},i,o)});return new t(this._db,this._coll,this._fieldFilters,a,this._transactionId)},t.prototype.limit=function(e){bt.isInteger("limit",e);var n=te({},this._apiOptions);return n.limit=e,new t(this._db,this._coll,this._fieldFilters,n,this._transactionId)},t.prototype.skip=function(e){bt.isInteger("offset",e);var n=te({},this._apiOptions);return n.offset=e,new t(this._db,this._coll,this._fieldFilters,n,this._transactionId)},t.prototype.update=function(t,e){return ct(this._update(t),e)},t.prototype._update=function(t){return ee(this,void 0,void 0,function(){var e,n,r,o;return ne(this,function(i){switch(i.label){case 0:return t&&"object"==typeof t?t.hasOwnProperty("_id")?[2,yt(this._db.config.throwOnCode,te(te({},et),{message:"不能更新_id的值"}))]:(e=this._apiOptions.multiple,n=void 0===e||e,r={collectionName:this._coll,queryType:c.WHERE,multi:n,merge:!0,upsert:!1,data:Ht.encodeEJSON(t,this._apiOptions.raw||!1)},this._transactionId&&(r.transactionId=this._transactionId),this._fieldFilters&&(r.query=this._fieldFilters),[4,this._request.send("database.modifyDocument",r,lt(this._apiOptions))]):[2,yt(this._db.config.throwOnCode,te(te({},et),{message:"参数必需是非空对象"}))];case 1:return(o=i.sent()).code?[2,o]:[2,{requestId:o.requestId,updated:o.data.updated,upsertId:o.data.upsert_id}]}})})},t.prototype.field=function(e){var n={};for(var r in e)"boolean"==typeof e[r]&&(n[r]=!0===e[r]?1:0),"number"==typeof e[r]&&(n[r]=e[r]>0?1:0),"object"==typeof e[r]&&(n[r]=e[r]);var o=te({},this._apiOptions);return o.projection=n,new t(this._db,this._coll,this._fieldFilters,o,this._transactionId)},t.prototype.remove=function(t){return ct(this._remove(),t)},t.prototype._remove=function(){return ee(this,void 0,void 0,function(){var t,e,n,r,o,i,a,u,s;return ne(this,function(l){switch(l.label){case 0:return t=this._apiOptions,e=t.offset,n=t.limit,r=t.projection,o=t.order,void 0===e&&void 0===n&&void 0===r&&void 0===o||console.warn("`offset`, `limit`, `projection`, `orderBy` are not supported in remove() operation"),i=this._apiOptions.multiple,a=void 0===i||i,u={collectionName:this._coll,query:this._fieldFilters,queryType:c.WHERE,multi:a},this._transactionId&&(u.transactionId=this._transactionId),[4,this._request.send("database.removeDocument",u,lt(this._apiOptions))];case 1:return(s=l.sent()).code?[2,s]:[2,{requestId:s.requestId,deleted:s.data.deleted}]}})})},t.prototype.updateAndReturn=function(t){return ee(this,void 0,void 0,function(){var e,n;return ne(this,function(r){switch(r.label){case 0:return t&&"object"==typeof t?t.hasOwnProperty("_id")?[2,yt(this._db.config.throwOnCode,te(te({},et),{message:"不能更新_id的值"}))]:(e={collectionName:this._coll,queryType:c.WHERE,data:Ht.encodeEJSON(t,!1)},this._transactionId&&(e.transactionId=this._transactionId),this._fieldFilters&&(e.query=this._fieldFilters),[4,this._request.send("database.modifyAndReturnDoc",e,lt(this._apiOptions))]):[2,yt(this._db.config.throwOnCode,te(te({},et),{message:"参数必需是非空对象"}))];case 1:return(n=r.sent()).code?[2,n]:[2,{requestId:n.requestId,updated:n.data.updated,doc:n.data.doc&&ot.EJSON.parse(n.data.doc)}]}})})},t}(),oe=function(){function t(t,e,n){var r=this;this._stages=[],t&&e&&(this._db=t,this._request=Oe.createRequest(this._db.config),this._collectionName=e,n&&n.length>0&&n.forEach(function(t){bt.isValidAggregation(t);var e=Object.keys(t)[0];r._pipe(e,t[e],!0)}))}return t.prototype.end=function(){return t=this,e=void 0,r=function(){var t;return function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=e.call(t,a)}catch(t){c=[6,t],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}}(this,function(e){switch(e.label){case 0:if(!this._collectionName||!this._db)throw new Error("Aggregation pipeline cannot send request");return[4,this._request.send("database.aggregateDocuments",{collectionName:this._collectionName,stages:this._stages})];case 1:return(t=e.sent())&&t.data&&t.data.list?[2,{requestId:t.requestId,data:t.data.list.map(ot.EJSON.parse)}]:[2,t]}})},new((n=void 0)||(n=Promise))(function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function c(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,c)}u((r=r.apply(t,e||[])).next())});var t,e,n,r},t.prototype.unwrap=function(){return this._stages},t.prototype.done=function(){return this._stages.map(function(t){var e,n=t.stageKey,r=t.stageValue;return(e={})[n]=JSON.parse(r),e})},t.prototype._pipe=function(t,e,n){void 0===n&&(n=!1);var r;return r="object"===W(e)?dt(e):JSON.stringify(e),this._stages.push({stageKey:n?t:"$".concat(t),stageValue:r}),this},t.prototype.addFields=function(t){return this._pipe("addFields",t)},t.prototype.bucket=function(t){return this._pipe("bucket",t)},t.prototype.bucketAuto=function(t){return this._pipe("bucketAuto",t)},t.prototype.count=function(t){return this._pipe("count",t)},t.prototype.geoNear=function(t){return t.query&&(t.query=Xt.encode(t.query)),t.distanceMultiplier&&"number"==typeof t.distanceMultiplier&&(t.distanceMultiplier=t.distanceMultiplier),t.near&&(t.near=new wt(t.near.longitude,t.near.latitude).toJSON()),this._pipe("geoNear",t)},t.prototype.group=function(t){return this._pipe("group",t)},t.prototype.limit=function(t){return this._pipe("limit",t)},t.prototype.match=function(t){return this._pipe("match",Xt.encode(t))},t.prototype.project=function(t){return this._pipe("project",t)},t.prototype.lookup=function(t){return this._pipe("lookup",t)},t.prototype.replaceRoot=function(t){return this._pipe("replaceRoot",t)},t.prototype.sample=function(t){return this._pipe("sample",t)},t.prototype.skip=function(t){return this._pipe("skip",t)},t.prototype.sort=function(t){return this._pipe("sort",t)},t.prototype.sortByCount=function(t){return this._pipe("sortByCount",t)},t.prototype.unwind=function(t){return this._pipe("unwind",t)},t}(),ie=oe,ae=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),ce=function(t){function e(e,n,r,o){var i=t.call(this,e,n,"",r,o)||this;return o&&(i._transactionId=o),i}return ae(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return this._coll},enumerable:!1,configurable:!0}),e.prototype.doc=function(t){if("string"!=typeof t&&"number"!=typeof t)throw new Error("docId必须为字符串或数字");return new Kt(this._db,this._coll,this._apiOptions,t,this._transactionId)},e.prototype.add=function(t,e){return ct(this._add(t),e)},e.prototype._add=function(t){return e=this,n=void 0,o=function(){var e,n,r;return function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=e.call(t,a)}catch(t){c=[6,t],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}}(this,function(o){switch(o.label){case 0:return e=t,U(t)||(e=[t]),e=e.map(function(t){return dt(Lt(t))}),n={collectionName:this._coll,data:e},this._transactionId&&(n.transactionId=this._transactionId),[4,this._request.send("database.insertDocument",n,lt(this._apiOptions))];case 1:return(r=o.sent()).code?[2,r]:U(t)?[2,{ids:r.data.insertedIds,requestId:r.requestId}]:this._transactionId?[2,{inserted:1,ok:1,id:r.data.insertedIds[0],requestId:r.requestId}]:[2,{id:r.data.insertedIds[0],requestId:r.requestId}]}})},new((r=void 0)||(r=Promise))(function(t,i){function a(t){try{u(o.next(t))}catch(t){i(t)}}function c(t){try{u(o.throw(t))}catch(t){i(t)}}function u(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r(function(t){t(n)})).then(a,c)}u((o=o.apply(e,n||[])).next())});var e,n,r,o},e.prototype.aggregate=function(t){return void 0===t&&(t=[]),new ie(this._db,this._coll,this._apiOptions.raw?t:[])},e.prototype.options=function(t){return bt.isValidOptions(t),new e(this._db,this._coll,t,this._transactionId)},e}(re),ue={eq:function(t){return new Tt(Nt.EQ,[t])},neq:function(t){return new Tt(Nt.NEQ,[t])},lt:function(t){return new Tt(Nt.LT,[t])},lte:function(t){return new Tt(Nt.LTE,[t])},gt:function(t){return new Tt(Nt.GT,[t])},gte:function(t){return new Tt(Nt.GTE,[t])},in:function(t){return new Tt(Nt.IN,t)},nin:function(t){return new Tt(Nt.NIN,t)},all:function(t){return new Tt(Nt.ALL,t)},elemMatch:function(t){return new Tt(Nt.ELEM_MATCH,[t])},exists:function(t){return new Tt(Nt.EXISTS,[t])},size:function(t){return new Tt(Nt.SIZE,[t])},mod:function(){return new Tt(Nt.MOD,1==arguments.length?[arguments[0]]:2==arguments.length?[[arguments[0],arguments[1]]]:arguments)},geoNear:function(t){return new Tt(Nt.GEO_NEAR,[t])},geoWithin:function(t){return new Tt(Nt.GEO_WITHIN,[t])},geoIntersects:function(t){return new Tt(Nt.GEO_INTERSECTS,[t])},and:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=U(arguments[0])?arguments[0]:Array.from(arguments);return new St(_t.AND,n)},nor:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=U(arguments[0])?arguments[0]:Array.from(arguments);return new St(_t.NOR,n)},or:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=U(arguments[0])?arguments[0]:Array.from(arguments);return new St(_t.OR,n)},not:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=U(arguments[0])?arguments[0]:Array.from(arguments);return new St(_t.NOT,n)},set:function(t){return new Ot(mt.SET,[t])},remove:function(){return new Ot(mt.REMOVE,[])},inc:function(t){return new Ot(mt.INC,[t])},mul:function(t){return new Ot(mt.MUL,[t])},push:function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(M(e[0])&&e[0].hasOwnProperty("each")){t={};var r=e[0];void 0!==r.each&&(t.$each=r.each),void 0!==r.position&&(t.$position=r.position),void 0!==r.sort&&(t.$sort=r.sort),void 0!==r.slice&&(t.$slice=r.slice)}else t=U(e[0])?e[0]:Array.from(e);return new Ot(mt.PUSH,t)},pull:function(t){return new Ot(mt.PULL,t)},pullAll:function(t){return new Ot(mt.PULL_ALL,t)},pop:function(){return new Ot(mt.POP,[])},shift:function(){return new Ot(mt.SHIFT,[])},unshift:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=U(arguments[0])?arguments[0]:Array.from(arguments);return new Ot(mt.UNSHIFT,n)},addToSet:function(t){return new Ot(mt.ADD_TO_SET,t)},rename:function(t){return new Ot(mt.RENAME,[t])},bit:function(t){return new Ot(mt.BIT,[t])},max:function(t){return new Ot(mt.MAX,[t])},min:function(t){return new Ot(mt.MIN,[t])},expr:function(t){return{$expr:t}},jsonSchema:function(t){return{$jsonSchema:t}},text:function(t){return"string"===W(t)?{$search:t.search}:{$search:t.search,$language:t.language,$caseSensitive:t.caseSensitive,$diacriticSensitive:t.diacriticSensitive}},aggregate:{pipeline:function(){return new ie},abs:function(t){return new se("abs",t)},add:function(t){return new se("add",t)},ceil:function(t){return new se("ceil",t)},divide:function(t){return new se("divide",t)},exp:function(t){return new se("exp",t)},floor:function(t){return new se("floor",t)},ln:function(t){return new se("ln",t)},log:function(t){return new se("log",t)},log10:function(t){return new se("log10",t)},mod:function(t){return new se("mod",t)},multiply:function(t){return new se("multiply",t)},pow:function(t){return new se("pow",t)},sqrt:function(t){return new se("sqrt",t)},subtract:function(t){return new se("subtract",t)},trunc:function(t){return new se("trunc",t)},arrayElemAt:function(t){return new se("arrayElemAt",t)},arrayToObject:function(t){return new se("arrayToObject",t)},concatArrays:function(t){return new se("concatArrays",t)},filter:function(t){return new se("filter",t)},in:function(t){return new se("in",t)},indexOfArray:function(t){return new se("indexOfArray",t)},isArray:function(t){return new se("isArray",t)},map:function(t){return new se("map",t)},range:function(t){return new se("range",t)},reduce:function(t){return new se("reduce",t)},reverseArray:function(t){return new se("reverseArray",t)},size:function(t){return new se("size",t)},slice:function(t){return new se("slice",t)},zip:function(t){return new se("zip",t)},and:function(t){return new se("and",t)},not:function(t){return new se("not",t)},or:function(t){return new se("or",t)},cmp:function(t){return new se("cmp",t)},eq:function(t){return new se("eq",t)},gt:function(t){return new se("gt",t)},gte:function(t){return new se("gte",t)},lt:function(t){return new se("lt",t)},lte:function(t){return new se("lte",t)},neq:function(t){return new se("ne",t)},cond:function(t){return new se("cond",t)},ifNull:function(t){return new se("ifNull",t)},switch:function(t){return new se("switch",t)},dateFromParts:function(t){return new se("dateFromParts",t)},dateFromString:function(t){return new se("dateFromString",t)},dayOfMonth:function(t){return new se("dayOfMonth",t)},dayOfWeek:function(t){return new se("dayOfWeek",t)},dayOfYear:function(t){return new se("dayOfYear",t)},isoDayOfWeek:function(t){return new se("isoDayOfWeek",t)},isoWeek:function(t){return new se("isoWeek",t)},isoWeekYear:function(t){return new se("isoWeekYear",t)},millisecond:function(t){return new se("millisecond",t)},minute:function(t){return new se("minute",t)},month:function(t){return new se("month",t)},second:function(t){return new se("second",t)},hour:function(t){return new se("hour",t)},week:function(t){return new se("week",t)},year:function(t){return new se("year",t)},literal:function(t){return new se("literal",t)},mergeObjects:function(t){return new se("mergeObjects",t)},objectToArray:function(t){return new se("objectToArray",t)},allElementsTrue:function(t){return new se("allElementsTrue",t)},anyElementTrue:function(t){return new se("anyElementTrue",t)},setDifference:function(t){return new se("setDifference",t)},setEquals:function(t){return new se("setEquals",t)},setIntersection:function(t){return new se("setIntersection",t)},setIsSubset:function(t){return new se("setIsSubset",t)},setUnion:function(t){return new se("setUnion",t)},concat:function(t){return new se("concat",t)},dateToString:function(t){return new se("dateToString",t)},indexOfBytes:function(t){return new se("indexOfBytes",t)},indexOfCP:function(t){return new se("indexOfCP",t)},split:function(t){return new se("split",t)},strLenBytes:function(t){return new se("strLenBytes",t)},strLenCP:function(t){return new se("strLenCP",t)},strcasecmp:function(t){return new se("strcasecmp",t)},substr:function(t){return new se("substr",t)},substrBytes:function(t){return new se("substrBytes",t)},substrCP:function(t){return new se("substrCP",t)},toLower:function(t){return new se("toLower",t)},toUpper:function(t){return new se("toUpper",t)},meta:function(t){return new se("meta",t)},addToSet:function(t){return new se("addToSet",t)},avg:function(t){return new se("avg",t)},first:function(t){return new se("first",t)},last:function(t){return new se("last",t)},max:function(t){return new se("max",t)},min:function(t){return new se("min",t)},push:function(t){return new se("push",t)},stdDevPop:function(t){return new se("stdDevPop",t)},stdDevSamp:function(t){return new se("stdDevSamp",t)},sum:function(t){return new se("sum",t)},let:function(t){return new se("let",t)}},project:{slice:function(t){return new le("slice",t)},elemMatch:function(t){return new le("elemMatch",t)}}},se=function(t,e){this["$"+t]=e},le=function(t,e){this["$"+t]=e},fe=function(){function t(t){var e=(void 0===t?{}:t).offset,n=void 0===e?0:e;this.offset=n}return Object.defineProperty(t.prototype,"_internalType",{get:function(){return q},enumerable:!1,configurable:!0}),t.prototype.parse=function(){return{$tcb_server_date:{offset:this.offset}}},t}();function de(t){return new fe(t)}var pe=function(){function t(t){var e=t.regexp,n=t.options;if(!e)throw new TypeError("regexp must be a string");this.$regularExpression={pattern:e||"",options:n||""}}return t.prototype.parse=function(){return{$regularExpression:{pattern:this.$regularExpression.pattern,options:this.$regularExpression.options}}},Object.defineProperty(t.prototype,"_internalType",{get:function(){return F},enumerable:!1,configurable:!0}),t}();function he(t){return new pe(t)}var ye=function(t,e,n,r){return new(n||(n=Promise))(function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function c(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,c)}u((r=r.apply(t,e||[])).next())})},me=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=e.call(t,a)}catch(t){c=[6,t],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}},ve=function(){function t(t){this._db=t,this._request=Oe.createRequest(this._db.config),this.aborted=!1,this.commited=!1,this.inited=!1}return t.prototype.init=function(){return ye(this,void 0,void 0,function(){var t;return me(this,function(e){switch(e.label){case 0:return[4,this._request.send("database.startTransaction")];case 1:if((t=e.sent()).code)throw t;return this.inited=!0,this._id=t.transactionId,[2]}})})},t.prototype.collection=function(t){if(!t)throw new Error("Collection name is required");return new ce(this._db,t,{},this._id)},t.prototype.getTransactionId=function(){return this._id},t.prototype.getRequestMethod=function(){return this._request},t.prototype.commit=function(){return ye(this,void 0,void 0,function(){var t,e;return me(this,function(n){switch(n.label){case 0:return t={transactionId:this._id},[4,this._request.send("database.commitTransaction",t)];case 1:if((e=n.sent()).code)throw e;return this.commited=!0,[2,e]}})})},t.prototype.rollback=function(t){return ye(this,void 0,void 0,function(){var e,n;return me(this,function(r){switch(r.label){case 0:return e={transactionId:this._id},[4,this._request.send("database.abortTransaction",e)];case 1:if((n=r.sent()).code)throw n;return this.aborted=!0,this.abortReason=t,[2,n]}})})},t}();function ge(){return ye(this,void 0,void 0,function(){var t;return me(this,function(e){switch(e.label){case 0:return[4,(t=new ve(this)).init()];case 1:return e.sent(),[2,t]}})})}function be(t,e){return void 0===e&&(e=3),ye(this,void 0,void 0,function(){var n,r,o,i,a=this;return me(this,function(c){switch(c.label){case 0:return c.trys.push([0,4,,10]),[4,(n=new ve(this)).init()];case 1:return c.sent(),[4,t(n)];case 2:if(r=c.sent(),!0===n.aborted)throw n.abortReason;return[4,n.commit()];case 3:return c.sent(),[2,r];case 4:if(o=c.sent(),!1===n.inited)throw o;return i=function(t){return ye(a,void 0,void 0,function(){return me(this,function(e){switch(e.label){case 0:if(n.aborted||n.commited)return[3,5];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,n.rollback()];case 2:case 3:return e.sent(),[3,4];case 4:throw t;case 5:if(!0===n.aborted)throw n.abortReason;throw t}})})},e<=0?[4,i(o)]:[3,6];case 5:c.sent(),c.label=6;case 6:return o&&o.code===nt?[4,be.bind(this)(t,--e)]:[3,8];case 7:return[2,c.sent()];case 8:return[4,i(o)];case 9:return c.sent(),[3,10];case 10:return[2]}})})}var we=function(){function t(t){var e=(void 0===t?{}:t).id,n=void 0===e?"":e;this.id=n}return Object.defineProperty(t.prototype,"_internalType",{get:function(){return L},enumerable:!1,configurable:!0}),t.prototype.parse=function(){return{$oid:this.id}},t}();function _e(t){return new we(t)}var Oe=function(){function t(t){this.config=t,this.Geo=i,this.serverDate=de,this.command=ue,this.RegExp=he,this.ObjectId=_e,this.startTransaction=ge,this.runTransaction=be,this.logicCommand=St,this.updateCommand=Ot,this.queryCommand=Tt}return t.createRequest=function(e){var n=new t.reqClass(e),r=n.send;return n.send=function(t,n){for(var o=[],i=2;i<arguments.length;i++)o[i-2]=arguments[i];return n&&(e.instance&&(n.instance=e.instance),e.database&&(n.database=e.database)),r.call.apply(r,function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}([this,t,n],function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}(o),!1))},n},t.prototype.collection=function(t){if(!t)throw new Error("Collection name is required");return new ce(this,t)},t.prototype.createCollection=function(e){var n={collectionName:e};return t.createRequest(this.config).send("database.addCollection",n)},t}()},764:function(t){t.exports=require("@cloudbase/adapter-interface")},701:function(t){t.exports=require("bson")},107:function(t){t.exports=require("jwt-decode")}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return t[r].call(i.exports,i,i.exports,n),i.exports}n.d=function(t,e){for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r=n(198);module.exports=r}();
2
2
  //# sourceMappingURL=index.js.map