@cloudbase/js-sdk 3.10.2 → 3.10.3
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.
- package/app/dist/index.js +1 -1
- package/app/dist/index.js.map +1 -1
- package/app/dist/index.node.js +1 -1
- package/app/dist/index.node.js.map +1 -1
- package/database/dist/index.esm.js +1 -1
- package/database/dist/index.esm.js.map +1 -1
- package/database/dist/index.js +1 -1
- package/database/dist/index.js.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.node.cjs.js +1 -1
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.esm.js +1 -1
- package/dist/index.node.esm.js.map +1 -1
- package/miniprogram_dist/database/index.js +1 -1
- package/miniprogram_dist/index.js +1 -1
- package/package.json +2 -2
package/database/dist/index.js
CHANGED
|
@@ -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{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),void 0!==r.query&&null!==r.query&&""!==r.query||(r.query={_id:{$exists:!0}}),[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,n=e.data,r=e.file,o=e.fileContent,a=e.name,c=e.method,u=e.headers,s=void 0===u?{}:u,l=null!=r?r:o,f={post:"post",put:"put"}[null==c?void 0:c.toLowerCase()]||"put",d=new FormData;return"post"===f?(Object.keys(n).forEach(function(t){d.append(t,n[t])}),d.append("key",a),d.append("file",l instanceof Blob?l:new Blob([l])),this.request(i(i({},t),{data:d,method:f}),this.restrictedMethods.includes("upload"))):this.request(i(i({},t),{method:"put",headers:s,body:l}),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(i(i({},e),{msg:e.message}),null==t?void 0:t.errorFactory);return i({code:e.code,message:e.message},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 se},Db:function(){return Se},DocumentReference:function(){return Zt},Query:function(){return ie}});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 Ot},Polygon:function(){return Q}}),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"),j=S.for("LOGIC_COMMAND"),T=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 Ot))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}(),H=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.")},Q=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=H(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,H(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 Ot))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 Q))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 Ot(i.coordinates[0],i.coordinates[1]);break;case l:o=new B(i.coordinates.map(function(t){return new Ot(t[0],t[1])}));break;case f:o=new Q(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 Ot(n,r)}))}));break;case d:o=new V(i.coordinates.map(function(t){return new Ot(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 Ot(n,r)}))}));break;case h:o=new X(i.coordinates.map(function(t){return new Q(t.map(function(t){return new B(t.map(function(t){var e=Z(t,2),n=e[0],r=e[1];return new Ot(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:Ot.validate(t)?e=s:B.validate(t)?e=l:Q.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(!Se.wsClientClass)throw new Error("to use realtime you must import realtime module first");var e=t.config.env;return ut[e]||(ut[e]=new Se.wsClientClass({context:{appConfig:{docSizeLimit:1e3,realtimePingInterval:1e4,realtimePongWaitTimeout:5e3,request:Se.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){var e,n;if(t instanceof Date)return{$date:+t};if(t instanceof RegExp)return{$regex:t.source,$options:t.flags};if(t&&"object"==typeof t){if("ObjectId"===t._bsontype)return{$oid:t.toHexString()};if("BSONRegExp"===t._bsontype)return{$regex:t.pattern,$options:t.options};if(Array.isArray(t))return t.map(pt);var r={};try{for(var o=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.")}(Object.keys(t)),i=o.next();!i.done;i=o.next()){var a=i.value;r[a]=pt(t[a])}}catch(t){e={error:t}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}return r}return t},ht=function(t){if(!t)return"{}";try{var e=ot.EJSON.parse(t);return JSON.stringify(pt(e))}catch(e){return t}},yt=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),mt=function(t){return new yt(t)};function vt(t,e){if(!1===t)return e;throw mt(at({},e))}var gt,bt=function(){return bt=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},bt.apply(this,arguments)},wt=["limit","offset","projection","order","multiple","timeout","raw"],_t=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 mt(bt(bt({},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 mt(bt(bt({},et),{message:"if the value in projection is of number, it must be 0 or 1"}))}else if("object"!==W(r))throw mt(bt(bt({},et),{message:"invalid projection"}))}return!0},t.isOrder=function(t,e){if("object"!==W(e))throw mt(bt(bt({},et),{message:"".concat(t," order must be an object")}));for(var n in e){var r=e[n];if(1!==r&&-1!==r)throw mt(bt(bt({},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 mt(bt(bt({},et),{message:"options must be an object"}));var n=Object.keys(e);for(var r in n)if(wt.indexOf(n[r])<0)throw mt(bt(bt({},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 mt(bt(bt({},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===T&&"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}(),Ot=function(){function t(t,e){_t.isGeopoint("longitude",t),_t.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)&&_t.isGeopoint("longitude",t.coordinates[0])&&_t.isGeopoint("latitude",t.coordinates[1])},Object.defineProperty(t.prototype,"_internalType",{get:function(){return T},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"}(gt||(gt={}));var Et,St=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 It(t){return t&&t instanceof St&&t._internalType===N}!function(t){t.AND="and",t.OR="or",t.NOT="not",t.NOR="nor"}(Et||(Et={}));var Nt=function(){function t(t,e,n){if(this._internalType=j,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++)(Pt(i=e[r])||At(i))&&(e[r]=i._setFieldName(this.fieldName))}else{var i;(Pt(i=e)||At(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(Et.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(Et.OR,r,this.fieldName)},t}();function Pt(t){return t&&t instanceof Nt&&t._internalType===j}var jt,Tt=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"}(jt||(jt={}));var xt=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 Tt(e,t),e.prototype.toJSON=function(){var t,e,n;switch(this.operator){case jt.IN:case jt.NIN:return(t={})["$"+this.operator]=this.operands,t;case jt.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(jt.EQ,[t],this.fieldName);return this.and(n)},e.prototype.neq=function(t){var n=new e(jt.NEQ,[t],this.fieldName);return this.and(n)},e.prototype.gt=function(t){var n=new e(jt.GT,[t],this.fieldName);return this.and(n)},e.prototype.gte=function(t){var n=new e(jt.GTE,[t],this.fieldName);return this.and(n)},e.prototype.lt=function(t){var n=new e(jt.LT,[t],this.fieldName);return this.and(n)},e.prototype.lte=function(t){var n=new e(jt.LTE,[t],this.fieldName);return this.and(n)},e.prototype.in=function(t){var n=new e(jt.IN,t,this.fieldName);return this.and(n)},e.prototype.nin=function(t){var n=new e(jt.NIN,t,this.fieldName);return this.and(n)},e.prototype.geoNear=function(t){if(!(t.geometry instanceof Ot))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(jt.GEO_NEAR,[t],this.fieldName);return this.and(n)},e.prototype.geoWithin=function(t){if(!(t.geometry instanceof X||t.geometry instanceof Q||_t.isCentersPhere(t.centerSphere)))throw new TypeError('"geometry" must be of type Polygon or MultiPolygon. Received type '.concat(typeof t.geometry));var n=new e(jt.GEO_WITHIN,[t],this.fieldName);return this.and(n)},e.prototype.geoIntersects=function(t){if(!(t.geometry instanceof Ot||t.geometry instanceof B||t.geometry instanceof Q||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(jt.GEO_INTERSECTS,[t],this.fieldName);return this.and(n)},e}(Nt);function At(t){return t&&t instanceof xt&&t._internalType===P}function Rt(t){return At(t)}var Ct={};for(var Dt in jt)Ct[Dt]="$"+Dt;for(var Dt in Et)Ct[Dt]="$"+Dt;for(var Dt in gt)Ct[Dt]="$"+Dt;function qt(t){return Ct[t]||"$"+t}Ct[jt.NEQ]="$ne",Ct[gt.REMOVE]="$unset",Ct[gt.SHIFT]="$pop",Ct[gt.UNSHIFT]="$push";var Ft=function(){return Ft=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},Ft.apply(this,arguments)},Lt=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},Wt=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(!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 kt(t,Wt(Wt([],Lt(e),!1),[t],!1))});if(M(t)){var n=Ft({},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],Wt(Wt([],Lt(e),!1),[n[o]],!1)))}return r}return t}switch(t._internalType){case T:return t.toJSON();case q:case F:case L: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&&M(a)&&!e(a)){if(r.indexOf(a)>-1)throw new Error("Cannot convert circular structure to JSON");var c=Gt(a,e,$t($t([],Jt(n),!1),[i],!1),$t($t([],Jt(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 Bt(t){return Gt(t,Qt,[],[t])}function Ht(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 Qt(t){return G(t)||J(t)||$(t)}function Vt(t){return Mt(t)}var Yt=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 It(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 gt.PUSH:case gt.PULL:case gt.PULL_ALL:case gt.POP:case gt.SHIFT:case gt.UNSHIFT:case gt.ADD_TO_SET:return this.encodeArrayUpdateCommand(t);default:return this.encodeFieldUpdateCommand(t)}},t.prototype.encodeFieldUpdateCommand=function(t){var e,n,r,o,i=qt(t.operator);return t.operator===gt.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=qt(t.operator);switch(t.operator){case gt.PUSH:var d=void 0;return d=U(t.operands)?{$each:t.operands.map(Vt)}:t.operands,(e={})[f]=((n={})[t.fieldName]=d,n),e;case gt.UNSHIFT:return d={$each:t.operands.map(Vt),$position:0},(r={})[f]=((o={})[t.fieldName]=d,o),r;case gt.POP:return(i={})[f]=((a={})[t.fieldName]=1,a),i;case gt.SHIFT:return(c={})[f]=((u={})[t.fieldName]=-1,u),c;default:return(s={})[f]=((l={})[t.fieldName]=Vt(t.operands),l),s}},t.prototype.encodeUpdateObject=function(t){var e=Bt(t);for(var n in e)if(!/^\$/.test(n)){var r=e[n];if(It(r))e[n]=r._setFieldName(n),Ht(e,this.encodeUpdateCommand(e[n]),n);else{e[n]=r=Vt(r);var o=new St(gt.SET,[r],n);Ht(e,this.encodeUpdateCommand(o),n)}}return e},t}(),zt=function(){return zt=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},zt.apply(this,arguments)},Kt=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())})},Xt=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])}}},Zt=function(){function t(t,e,n,r,o){var i=this;this.watch=function(t){return st(i._db).watch(zt(zt({},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=Se.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 Kt(this,void 0,void 0,function(){var e,n,r;return Xt(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 ct(this._set(t),e)},t.prototype._set=function(t){return Kt(this,void 0,void 0,function(){var e,n,r,o;return Xt(this,function(i){switch(i.label){case 0:return this.id?t&&"object"==typeof t?t.hasOwnProperty("_id")?[2,vt(this._db.config.throwOnCode,zt(zt({},et),{message:"不能更新_id的值"}))]:(e=!1,n=function(t){if("object"==typeof t)for(var r in t)t[r]instanceof St?e=!0:"object"==typeof t[r]&&n(t[r])},n(t),e?[2,vt(this._db.config.throwOnCode,zt(zt({},rt),{message:"update operator complicit"}))]:(r={collectionName:this._coll,queryType:c.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,vt(this._db.config.throwOnCode,zt(zt({},et),{message:"参数必需是非空对象"}))]:[2,vt(this._db.config.throwOnCode,zt(zt({},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 Kt(this,void 0,void 0,function(){var e,n,r;return Xt(this,function(o){switch(o.label){case 0:return t&&"object"==typeof t?t.hasOwnProperty("_id")?[2,vt(this._db.config.throwOnCode,zt(zt({},et),{message:"不能更新_id的值"}))]:(e=dt({_id:this.id}),n={collectionName:this._coll,transactionId:this._transactionId,data:Yt.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,vt(this._db.config.throwOnCode,zt(zt({},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 Kt(this,void 0,void 0,function(){var t,e,n;return Xt(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 Kt(this,void 0,void 0,function(){var t,e,n,r,o,i;return Xt(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=zt({},this._apiOptions);return o.projection=n,new t(this._db,this._coll,o,this.id,this._transactionId)},t}(),te=function(){function t(){}return t.encode=function(t){return(new ee).encodeQuery(t)},t.encodeEJSON=function(t,e){var n=new ee;return dt(e?t:n.encodeQuery(t))},t}(),ee=function(){function t(){}return t.prototype.encodeQuery=function(t,e){var n,r,o;return Qt(t)?Pt(t)?this.encodeLogicCommand(t):At(t)?this.encodeQueryCommand(t):$(t)?((n={})[e]=this.encodeRegExp(t),n):J(t)?((r={})[e]=Vt(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 Et.NOR:case Et.AND:case Et.OR:var s=qt(t.operator),l=t.operands.map(function(e){return u.encodeQuery(e,t.fieldName)});return(e={})[s]=l,e;case Et.NOT:s=qt(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=qt(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 Rt(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=qt(t.operator);switch(t.operator){case jt.EQ:case jt.NEQ:case jt.LT:case jt.LTE:case jt.GT:case jt.GTE:case jt.ELEM_MATCH:case jt.EXISTS:case jt.SIZE:case jt.MOD:return(e={})[t.fieldName]=((n={})[d]=Vt(t.operands[0]),n),e;case jt.IN:case jt.NIN:case jt.ALL:return(r={})[t.fieldName]=((o={})[d]=Vt(t.operands),o),r;case jt.GEO_NEAR:var p=t.operands[0];return(i={})[t.fieldName]={$nearSphere:{$geometry:p.geometry.toJSON(),$maxDistance:p.maxDistance,$minDistance:p.minDistance}},i;case jt.GEO_WITHIN:if((p=t.operands[0]).centerSphere){_t.isCentersPhere(p.centerSphere);var h=p.centerSphere;return h[0]._internalType===T?((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 jt.GEO_INTERSECTS:return p=t.operands[0],(s={})[t.fieldName]={$geoIntersects:{$geometry:p.geometry.toJSON()}},s;default:return(l={})[t.fieldName]=((f={})[d]=Vt(t.operands[0]),f),l}},t.prototype.encodeQueryObject=function(t){var e=Bt(t);for(var n in e){var r=e[n];if(Pt(r)){e[n]=r._setFieldName(n);var o=this.encodeLogicCommand(e[n]);this.mergeConditionAfterEncode(e,o,n)}else Rt(r)?(e[n]=r._setFieldName(n),o=this.encodeComparisonCommand(e[n]),this.mergeConditionAfterEncode(e,o,n)):Qt(r)&&(e[n]=Vt(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}(),ne=function(){return ne=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},ne.apply(this,arguments)},re=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())})},oe=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])}}},ie=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,a=o?Object.entries(o).reduce(function(t,e){var 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}(e,2),r=n[0],o=n[1];return t[r]=-1===o?"desc":"asc",t},{}):void 0;return e.watch(ne(ne({},t),{envId:i._db.config.env,collectionName:i._coll,query:ht(i._fieldFilters),limit:r,orderBy:a}))},this._db=t,this._coll=e,this._fieldFilters=n,this._apiOptions=r||{},this._request=Se.createRequest(this._db.config),this._transactionId=o}return t.prototype.get=function(t){return ct(this._get(),t)},t.prototype._get=function(){return re(this,void 0,void 0,function(){var t,e,n,r,o,i,a,u,s;return oe(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 re(this,void 0,void 0,function(){var t,e;return oe(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,te.encodeEJSON(e,this._apiOptions.raw||!1),this._apiOptions,this._transactionId)},t.prototype.options=function(e){return _t.isValidOptions(e),new t(this._db,this._coll,this._fieldFilters,e,this._transactionId)},t.prototype.orderBy=function(e,n){var r;_t.isFieldPath(e),_t.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){_t.isInteger("limit",e);var n=ne({},this._apiOptions);return n.limit=e,new t(this._db,this._coll,this._fieldFilters,n,this._transactionId)},t.prototype.skip=function(e){_t.isInteger("offset",e);var n=ne({},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 re(this,void 0,void 0,function(){var e,n,r,o;return oe(this,function(i){switch(i.label){case 0:return t&&"object"==typeof t?t.hasOwnProperty("_id")?[2,vt(this._db.config.throwOnCode,ne(ne({},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:Yt.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,vt(this._db.config.throwOnCode,ne(ne({},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=ne({},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 re(this,void 0,void 0,function(){var t,e,n,r,o,i,a,u,s;return oe(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 re(this,void 0,void 0,function(){var e,n;return oe(this,function(r){switch(r.label){case 0:return t&&"object"==typeof t?t.hasOwnProperty("_id")?[2,vt(this._db.config.throwOnCode,ne(ne({},et),{message:"不能更新_id的值"}))]:(e={collectionName:this._coll,queryType:c.WHERE,data:Yt.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,vt(this._db.config.throwOnCode,ne(ne({},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}(),ae=function(){function t(t,e,n){var r=this;this._stages=[],t&&e&&(this._db=t,this._request=Se.createRequest(this._db.config),this._collectionName=e,n&&n.length>0&&n.forEach(function(t){_t.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=te.encode(t.query)),t.distanceMultiplier&&"number"==typeof t.distanceMultiplier&&(t.distanceMultiplier=t.distanceMultiplier),t.near&&(t.near=new Ot(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",te.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}(),ce=ae,ue=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 ue(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 Zt(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(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]: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 ce(this._db,this._coll,this._apiOptions.raw?t:[])},e.prototype.options=function(t){return _t.isValidOptions(t),new e(this._db,this._coll,t,this._transactionId)},e}(ie),le={eq:function(t){return new xt(jt.EQ,[t])},neq:function(t){return new xt(jt.NEQ,[t])},lt:function(t){return new xt(jt.LT,[t])},lte:function(t){return new xt(jt.LTE,[t])},gt:function(t){return new xt(jt.GT,[t])},gte:function(t){return new xt(jt.GTE,[t])},in:function(t){return new xt(jt.IN,t)},nin:function(t){return new xt(jt.NIN,t)},all:function(t){return new xt(jt.ALL,t)},elemMatch:function(t){return new xt(jt.ELEM_MATCH,[t])},exists:function(t){return new xt(jt.EXISTS,[t])},size:function(t){return new xt(jt.SIZE,[t])},mod:function(){return new xt(jt.MOD,1==arguments.length?[arguments[0]]:2==arguments.length?[[arguments[0],arguments[1]]]:arguments)},geoNear:function(t){return new xt(jt.GEO_NEAR,[t])},geoWithin:function(t){return new xt(jt.GEO_WITHIN,[t])},geoIntersects:function(t){return new xt(jt.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 Nt(Et.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 Nt(Et.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 Nt(Et.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 Nt(Et.NOT,n)},set:function(t){return new St(gt.SET,[t])},remove:function(){return new St(gt.REMOVE,[])},inc:function(t){return new St(gt.INC,[t])},mul:function(t){return new St(gt.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 St(gt.PUSH,t)},pull:function(t){return new St(gt.PULL,t)},pullAll:function(t){return new St(gt.PULL_ALL,t)},pop:function(){return new St(gt.POP,[])},shift:function(){return new St(gt.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 St(gt.UNSHIFT,n)},addToSet:function(t){return new St(gt.ADD_TO_SET,t)},rename:function(t){return new St(gt.RENAME,[t])},bit:function(t){return new St(gt.BIT,[t])},max:function(t){return new St(gt.MAX,[t])},min:function(t){return new St(gt.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 ce},abs:function(t){return new fe("abs",t)},add:function(t){return new fe("add",t)},ceil:function(t){return new fe("ceil",t)},divide:function(t){return new fe("divide",t)},exp:function(t){return new fe("exp",t)},floor:function(t){return new fe("floor",t)},ln:function(t){return new fe("ln",t)},log:function(t){return new fe("log",t)},log10:function(t){return new fe("log10",t)},mod:function(t){return new fe("mod",t)},multiply:function(t){return new fe("multiply",t)},pow:function(t){return new fe("pow",t)},sqrt:function(t){return new fe("sqrt",t)},subtract:function(t){return new fe("subtract",t)},trunc:function(t){return new fe("trunc",t)},arrayElemAt:function(t){return new fe("arrayElemAt",t)},arrayToObject:function(t){return new fe("arrayToObject",t)},concatArrays:function(t){return new fe("concatArrays",t)},filter:function(t){return new fe("filter",t)},in:function(t){return new fe("in",t)},indexOfArray:function(t){return new fe("indexOfArray",t)},isArray:function(t){return new fe("isArray",t)},map:function(t){return new fe("map",t)},range:function(t){return new fe("range",t)},reduce:function(t){return new fe("reduce",t)},reverseArray:function(t){return new fe("reverseArray",t)},size:function(t){return new fe("size",t)},slice:function(t){return new fe("slice",t)},zip:function(t){return new fe("zip",t)},and:function(t){return new fe("and",t)},not:function(t){return new fe("not",t)},or:function(t){return new fe("or",t)},cmp:function(t){return new fe("cmp",t)},eq:function(t){return new fe("eq",t)},gt:function(t){return new fe("gt",t)},gte:function(t){return new fe("gte",t)},lt:function(t){return new fe("lt",t)},lte:function(t){return new fe("lte",t)},neq:function(t){return new fe("ne",t)},cond:function(t){return new fe("cond",t)},ifNull:function(t){return new fe("ifNull",t)},switch:function(t){return new fe("switch",t)},dateFromParts:function(t){return new fe("dateFromParts",t)},dateFromString:function(t){return new fe("dateFromString",t)},dayOfMonth:function(t){return new fe("dayOfMonth",t)},dayOfWeek:function(t){return new fe("dayOfWeek",t)},dayOfYear:function(t){return new fe("dayOfYear",t)},isoDayOfWeek:function(t){return new fe("isoDayOfWeek",t)},isoWeek:function(t){return new fe("isoWeek",t)},isoWeekYear:function(t){return new fe("isoWeekYear",t)},millisecond:function(t){return new fe("millisecond",t)},minute:function(t){return new fe("minute",t)},month:function(t){return new fe("month",t)},second:function(t){return new fe("second",t)},hour:function(t){return new fe("hour",t)},week:function(t){return new fe("week",t)},year:function(t){return new fe("year",t)},literal:function(t){return new fe("literal",t)},mergeObjects:function(t){return new fe("mergeObjects",t)},objectToArray:function(t){return new fe("objectToArray",t)},allElementsTrue:function(t){return new fe("allElementsTrue",t)},anyElementTrue:function(t){return new fe("anyElementTrue",t)},setDifference:function(t){return new fe("setDifference",t)},setEquals:function(t){return new fe("setEquals",t)},setIntersection:function(t){return new fe("setIntersection",t)},setIsSubset:function(t){return new fe("setIsSubset",t)},setUnion:function(t){return new fe("setUnion",t)},concat:function(t){return new fe("concat",t)},dateToString:function(t){return new fe("dateToString",t)},indexOfBytes:function(t){return new fe("indexOfBytes",t)},indexOfCP:function(t){return new fe("indexOfCP",t)},split:function(t){return new fe("split",t)},strLenBytes:function(t){return new fe("strLenBytes",t)},strLenCP:function(t){return new fe("strLenCP",t)},strcasecmp:function(t){return new fe("strcasecmp",t)},substr:function(t){return new fe("substr",t)},substrBytes:function(t){return new fe("substrBytes",t)},substrCP:function(t){return new fe("substrCP",t)},toLower:function(t){return new fe("toLower",t)},toUpper:function(t){return new fe("toUpper",t)},meta:function(t){return new fe("meta",t)},addToSet:function(t){return new fe("addToSet",t)},avg:function(t){return new fe("avg",t)},first:function(t){return new fe("first",t)},last:function(t){return new fe("last",t)},max:function(t){return new fe("max",t)},min:function(t){return new fe("min",t)},push:function(t){return new fe("push",t)},stdDevPop:function(t){return new fe("stdDevPop",t)},stdDevSamp:function(t){return new fe("stdDevSamp",t)},sum:function(t){return new fe("sum",t)},let:function(t){return new fe("let",t)}},project:{slice:function(t){return new de("slice",t)},elemMatch:function(t){return new de("elemMatch",t)}}},fe=function(t,e){this["$"+t]=e},de=function(t,e){this["$"+t]=e},pe=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 he(t){return new pe(t)}var ye=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 me(t){return new ye(t)}var ve=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())})},ge=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])}}},be=function(){function t(t){this._db=t,this._request=Se.createRequest(this._db.config),this.aborted=!1,this.commited=!1,this.inited=!1}return t.prototype.init=function(){return ve(this,void 0,void 0,function(){var t;return ge(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 ve(this,void 0,void 0,function(){var t,e;return ge(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 ve(this,void 0,void 0,function(){var e,n;return ge(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 we(){return ve(this,void 0,void 0,function(){var t;return ge(this,function(e){switch(e.label){case 0:return[4,(t=new be(this)).init()];case 1:return e.sent(),[2,t]}})})}function _e(t,e){return void 0===e&&(e=3),ve(this,void 0,void 0,function(){var n,r,o,i,a=this;return ge(this,function(c){switch(c.label){case 0:return c.trys.push([0,4,,10]),[4,(n=new be(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 ve(a,void 0,void 0,function(){return ge(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,_e.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 Oe=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 Ee(t){return new Oe(t)}var Se=function(){function t(t){this.config=t,this.Geo=i,this.serverDate=he,this.command=le,this.RegExp=me,this.ObjectId=Ee,this.startTransaction=we,this.runTransaction=_e,this.logicCommand=Nt,this.updateCommand=St,this.queryCommand=xt}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){t=l.utils.promoteGatewayError(t);var e=Number(t.statusCode);if(e>=400&&!t.code){var n=t.data,r="string"==typeof n&&n.trim()?n.slice(0,1024):"";t.code=l.constants.ERRORS.NETWORK_ERROR,t.message=r||t.message||"HTTP ".concat(e)}return delete 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),void 0!==r.query&&null!==r.query&&""!==r.query||(r.query={_id:{$exists:!0}}),[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,n=e.data,r=e.file,o=e.fileContent,a=e.name,c=e.method,u=e.headers,s=void 0===u?{}:u,l=null!=r?r:o,f={post:"post",put:"put"}[null==c?void 0:c.toLowerCase()]||"put",d=new FormData;return"post"===f?(Object.keys(n).forEach(function(t){d.append(t,n[t])}),d.append("key",a),d.append("file",l instanceof Blob?l:new Blob([l])),this.request(i(i({},t),{data:d,method:f}),this.restrictedMethods.includes("upload"))):this.request(i(i({},t),{method:"put",headers:s,body:l}),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(i(i({},e),{msg:e.message}),null==t?void 0:t.errorFactory);return i({code:e.code,message:e.message},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 se},Db:function(){return Se},DocumentReference:function(){return Zt},Query:function(){return ie}});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 Ot},Polygon:function(){return Q}}),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"),j=S.for("LOGIC_COMMAND"),T=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 Ot))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}(),H=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.")},Q=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=H(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,H(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 Ot))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 Q))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 Ot(i.coordinates[0],i.coordinates[1]);break;case l:o=new B(i.coordinates.map(function(t){return new Ot(t[0],t[1])}));break;case f:o=new Q(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 Ot(n,r)}))}));break;case d:o=new V(i.coordinates.map(function(t){return new Ot(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 Ot(n,r)}))}));break;case h:o=new X(i.coordinates.map(function(t){return new Q(t.map(function(t){return new B(t.map(function(t){var e=Z(t,2),n=e[0],r=e[1];return new Ot(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:Ot.validate(t)?e=s:B.validate(t)?e=l:Q.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(!Se.wsClientClass)throw new Error("to use realtime you must import realtime module first");var e=t.config.env;return ut[e]||(ut[e]=new Se.wsClientClass({context:{appConfig:{docSizeLimit:1e3,realtimePingInterval:1e4,realtimePongWaitTimeout:5e3,request:Se.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){var e,n;if(t instanceof Date)return{$date:+t};if(t instanceof RegExp)return{$regex:t.source,$options:t.flags};if(t&&"object"==typeof t){if("ObjectId"===t._bsontype)return{$oid:t.toHexString()};if("BSONRegExp"===t._bsontype)return{$regex:t.pattern,$options:t.options};if(Array.isArray(t))return t.map(pt);var r={};try{for(var o=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.")}(Object.keys(t)),i=o.next();!i.done;i=o.next()){var a=i.value;r[a]=pt(t[a])}}catch(t){e={error:t}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}return r}return t},ht=function(t){if(!t)return"{}";try{var e=ot.EJSON.parse(t);return JSON.stringify(pt(e))}catch(e){return t}},yt=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),mt=function(t){return new yt(t)};function vt(t,e){if(!1===t)return e;throw mt(at({},e))}var gt,bt=function(){return bt=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},bt.apply(this,arguments)},wt=["limit","offset","projection","order","multiple","timeout","raw"],_t=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 mt(bt(bt({},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 mt(bt(bt({},et),{message:"if the value in projection is of number, it must be 0 or 1"}))}else if("object"!==W(r))throw mt(bt(bt({},et),{message:"invalid projection"}))}return!0},t.isOrder=function(t,e){if("object"!==W(e))throw mt(bt(bt({},et),{message:"".concat(t," order must be an object")}));for(var n in e){var r=e[n];if(1!==r&&-1!==r)throw mt(bt(bt({},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 mt(bt(bt({},et),{message:"options must be an object"}));var n=Object.keys(e);for(var r in n)if(wt.indexOf(n[r])<0)throw mt(bt(bt({},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 mt(bt(bt({},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===T&&"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}(),Ot=function(){function t(t,e){_t.isGeopoint("longitude",t),_t.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)&&_t.isGeopoint("longitude",t.coordinates[0])&&_t.isGeopoint("latitude",t.coordinates[1])},Object.defineProperty(t.prototype,"_internalType",{get:function(){return T},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"}(gt||(gt={}));var Et,St=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 It(t){return t&&t instanceof St&&t._internalType===N}!function(t){t.AND="and",t.OR="or",t.NOT="not",t.NOR="nor"}(Et||(Et={}));var Nt=function(){function t(t,e,n){if(this._internalType=j,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++)(Pt(i=e[r])||At(i))&&(e[r]=i._setFieldName(this.fieldName))}else{var i;(Pt(i=e)||At(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(Et.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(Et.OR,r,this.fieldName)},t}();function Pt(t){return t&&t instanceof Nt&&t._internalType===j}var jt,Tt=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"}(jt||(jt={}));var xt=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 Tt(e,t),e.prototype.toJSON=function(){var t,e,n;switch(this.operator){case jt.IN:case jt.NIN:return(t={})["$"+this.operator]=this.operands,t;case jt.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(jt.EQ,[t],this.fieldName);return this.and(n)},e.prototype.neq=function(t){var n=new e(jt.NEQ,[t],this.fieldName);return this.and(n)},e.prototype.gt=function(t){var n=new e(jt.GT,[t],this.fieldName);return this.and(n)},e.prototype.gte=function(t){var n=new e(jt.GTE,[t],this.fieldName);return this.and(n)},e.prototype.lt=function(t){var n=new e(jt.LT,[t],this.fieldName);return this.and(n)},e.prototype.lte=function(t){var n=new e(jt.LTE,[t],this.fieldName);return this.and(n)},e.prototype.in=function(t){var n=new e(jt.IN,t,this.fieldName);return this.and(n)},e.prototype.nin=function(t){var n=new e(jt.NIN,t,this.fieldName);return this.and(n)},e.prototype.geoNear=function(t){if(!(t.geometry instanceof Ot))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(jt.GEO_NEAR,[t],this.fieldName);return this.and(n)},e.prototype.geoWithin=function(t){if(!(t.geometry instanceof X||t.geometry instanceof Q||_t.isCentersPhere(t.centerSphere)))throw new TypeError('"geometry" must be of type Polygon or MultiPolygon. Received type '.concat(typeof t.geometry));var n=new e(jt.GEO_WITHIN,[t],this.fieldName);return this.and(n)},e.prototype.geoIntersects=function(t){if(!(t.geometry instanceof Ot||t.geometry instanceof B||t.geometry instanceof Q||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(jt.GEO_INTERSECTS,[t],this.fieldName);return this.and(n)},e}(Nt);function At(t){return t&&t instanceof xt&&t._internalType===P}function Rt(t){return At(t)}var Ct={};for(var Dt in jt)Ct[Dt]="$"+Dt;for(var Dt in Et)Ct[Dt]="$"+Dt;for(var Dt in gt)Ct[Dt]="$"+Dt;function qt(t){return Ct[t]||"$"+t}Ct[jt.NEQ]="$ne",Ct[gt.REMOVE]="$unset",Ct[gt.SHIFT]="$pop",Ct[gt.UNSHIFT]="$push";var Ft=function(){return Ft=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},Ft.apply(this,arguments)},Lt=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},Wt=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(!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 kt(t,Wt(Wt([],Lt(e),!1),[t],!1))});if(M(t)){var n=Ft({},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],Wt(Wt([],Lt(e),!1),[n[o]],!1)))}return r}return t}switch(t._internalType){case T:return t.toJSON();case q:case F:case L: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&&M(a)&&!e(a)){if(r.indexOf(a)>-1)throw new Error("Cannot convert circular structure to JSON");var c=Gt(a,e,$t($t([],Jt(n),!1),[i],!1),$t($t([],Jt(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 Bt(t){return Gt(t,Qt,[],[t])}function Ht(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 Qt(t){return G(t)||J(t)||$(t)}function Vt(t){return Mt(t)}var Yt=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 It(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 gt.PUSH:case gt.PULL:case gt.PULL_ALL:case gt.POP:case gt.SHIFT:case gt.UNSHIFT:case gt.ADD_TO_SET:return this.encodeArrayUpdateCommand(t);default:return this.encodeFieldUpdateCommand(t)}},t.prototype.encodeFieldUpdateCommand=function(t){var e,n,r,o,i=qt(t.operator);return t.operator===gt.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=qt(t.operator);switch(t.operator){case gt.PUSH:var d=void 0;return d=U(t.operands)?{$each:t.operands.map(Vt)}:t.operands,(e={})[f]=((n={})[t.fieldName]=d,n),e;case gt.UNSHIFT:return d={$each:t.operands.map(Vt),$position:0},(r={})[f]=((o={})[t.fieldName]=d,o),r;case gt.POP:return(i={})[f]=((a={})[t.fieldName]=1,a),i;case gt.SHIFT:return(c={})[f]=((u={})[t.fieldName]=-1,u),c;default:return(s={})[f]=((l={})[t.fieldName]=Vt(t.operands),l),s}},t.prototype.encodeUpdateObject=function(t){var e=Bt(t);for(var n in e)if(!/^\$/.test(n)){var r=e[n];if(It(r))e[n]=r._setFieldName(n),Ht(e,this.encodeUpdateCommand(e[n]),n);else{e[n]=r=Vt(r);var o=new St(gt.SET,[r],n);Ht(e,this.encodeUpdateCommand(o),n)}}return e},t}(),zt=function(){return zt=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},zt.apply(this,arguments)},Kt=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())})},Xt=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])}}},Zt=function(){function t(t,e,n,r,o){var i=this;this.watch=function(t){return st(i._db).watch(zt(zt({},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=Se.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 Kt(this,void 0,void 0,function(){var e,n,r;return Xt(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 ct(this._set(t),e)},t.prototype._set=function(t){return Kt(this,void 0,void 0,function(){var e,n,r,o;return Xt(this,function(i){switch(i.label){case 0:return this.id?t&&"object"==typeof t?t.hasOwnProperty("_id")?[2,vt(this._db.config.throwOnCode,zt(zt({},et),{message:"不能更新_id的值"}))]:(e=!1,n=function(t){if("object"==typeof t)for(var r in t)t[r]instanceof St?e=!0:"object"==typeof t[r]&&n(t[r])},n(t),e?[2,vt(this._db.config.throwOnCode,zt(zt({},rt),{message:"update operator complicit"}))]:(r={collectionName:this._coll,queryType:c.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,vt(this._db.config.throwOnCode,zt(zt({},et),{message:"参数必需是非空对象"}))]:[2,vt(this._db.config.throwOnCode,zt(zt({},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 Kt(this,void 0,void 0,function(){var e,n,r;return Xt(this,function(o){switch(o.label){case 0:return t&&"object"==typeof t?t.hasOwnProperty("_id")?[2,vt(this._db.config.throwOnCode,zt(zt({},et),{message:"不能更新_id的值"}))]:(e=dt({_id:this.id}),n={collectionName:this._coll,transactionId:this._transactionId,data:Yt.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,vt(this._db.config.throwOnCode,zt(zt({},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 Kt(this,void 0,void 0,function(){var t,e,n;return Xt(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 Kt(this,void 0,void 0,function(){var t,e,n,r,o,i;return Xt(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=zt({},this._apiOptions);return o.projection=n,new t(this._db,this._coll,o,this.id,this._transactionId)},t}(),te=function(){function t(){}return t.encode=function(t){return(new ee).encodeQuery(t)},t.encodeEJSON=function(t,e){var n=new ee;return dt(e?t:n.encodeQuery(t))},t}(),ee=function(){function t(){}return t.prototype.encodeQuery=function(t,e){var n,r,o;return Qt(t)?Pt(t)?this.encodeLogicCommand(t):At(t)?this.encodeQueryCommand(t):$(t)?((n={})[e]=this.encodeRegExp(t),n):J(t)?((r={})[e]=Vt(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 Et.NOR:case Et.AND:case Et.OR:var s=qt(t.operator),l=t.operands.map(function(e){return u.encodeQuery(e,t.fieldName)});return(e={})[s]=l,e;case Et.NOT:s=qt(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=qt(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 Rt(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=qt(t.operator);switch(t.operator){case jt.EQ:case jt.NEQ:case jt.LT:case jt.LTE:case jt.GT:case jt.GTE:case jt.ELEM_MATCH:case jt.EXISTS:case jt.SIZE:case jt.MOD:return(e={})[t.fieldName]=((n={})[d]=Vt(t.operands[0]),n),e;case jt.IN:case jt.NIN:case jt.ALL:return(r={})[t.fieldName]=((o={})[d]=Vt(t.operands),o),r;case jt.GEO_NEAR:var p=t.operands[0];return(i={})[t.fieldName]={$nearSphere:{$geometry:p.geometry.toJSON(),$maxDistance:p.maxDistance,$minDistance:p.minDistance}},i;case jt.GEO_WITHIN:if((p=t.operands[0]).centerSphere){_t.isCentersPhere(p.centerSphere);var h=p.centerSphere;return h[0]._internalType===T?((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 jt.GEO_INTERSECTS:return p=t.operands[0],(s={})[t.fieldName]={$geoIntersects:{$geometry:p.geometry.toJSON()}},s;default:return(l={})[t.fieldName]=((f={})[d]=Vt(t.operands[0]),f),l}},t.prototype.encodeQueryObject=function(t){var e=Bt(t);for(var n in e){var r=e[n];if(Pt(r)){e[n]=r._setFieldName(n);var o=this.encodeLogicCommand(e[n]);this.mergeConditionAfterEncode(e,o,n)}else Rt(r)?(e[n]=r._setFieldName(n),o=this.encodeComparisonCommand(e[n]),this.mergeConditionAfterEncode(e,o,n)):Qt(r)&&(e[n]=Vt(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}(),ne=function(){return ne=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},ne.apply(this,arguments)},re=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())})},oe=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])}}},ie=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,a=o?Object.entries(o).reduce(function(t,e){var 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}(e,2),r=n[0],o=n[1];return t[r]=-1===o?"desc":"asc",t},{}):void 0;return e.watch(ne(ne({},t),{envId:i._db.config.env,collectionName:i._coll,query:ht(i._fieldFilters),limit:r,orderBy:a}))},this._db=t,this._coll=e,this._fieldFilters=n,this._apiOptions=r||{},this._request=Se.createRequest(this._db.config),this._transactionId=o}return t.prototype.get=function(t){return ct(this._get(),t)},t.prototype._get=function(){return re(this,void 0,void 0,function(){var t,e,n,r,o,i,a,u,s;return oe(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 re(this,void 0,void 0,function(){var t,e;return oe(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,te.encodeEJSON(e,this._apiOptions.raw||!1),this._apiOptions,this._transactionId)},t.prototype.options=function(e){return _t.isValidOptions(e),new t(this._db,this._coll,this._fieldFilters,e,this._transactionId)},t.prototype.orderBy=function(e,n){var r;_t.isFieldPath(e),_t.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){_t.isInteger("limit",e);var n=ne({},this._apiOptions);return n.limit=e,new t(this._db,this._coll,this._fieldFilters,n,this._transactionId)},t.prototype.skip=function(e){_t.isInteger("offset",e);var n=ne({},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 re(this,void 0,void 0,function(){var e,n,r,o;return oe(this,function(i){switch(i.label){case 0:return t&&"object"==typeof t?t.hasOwnProperty("_id")?[2,vt(this._db.config.throwOnCode,ne(ne({},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:Yt.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,vt(this._db.config.throwOnCode,ne(ne({},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=ne({},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 re(this,void 0,void 0,function(){var t,e,n,r,o,i,a,u,s;return oe(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 re(this,void 0,void 0,function(){var e,n;return oe(this,function(r){switch(r.label){case 0:return t&&"object"==typeof t?t.hasOwnProperty("_id")?[2,vt(this._db.config.throwOnCode,ne(ne({},et),{message:"不能更新_id的值"}))]:(e={collectionName:this._coll,queryType:c.WHERE,data:Yt.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,vt(this._db.config.throwOnCode,ne(ne({},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}(),ae=function(){function t(t,e,n){var r=this;this._stages=[],t&&e&&(this._db=t,this._request=Se.createRequest(this._db.config),this._collectionName=e,n&&n.length>0&&n.forEach(function(t){_t.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=te.encode(t.query)),t.distanceMultiplier&&"number"==typeof t.distanceMultiplier&&(t.distanceMultiplier=t.distanceMultiplier),t.near&&(t.near=new Ot(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",te.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}(),ce=ae,ue=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 ue(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 Zt(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(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]: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 ce(this._db,this._coll,this._apiOptions.raw?t:[])},e.prototype.options=function(t){return _t.isValidOptions(t),new e(this._db,this._coll,t,this._transactionId)},e}(ie),le={eq:function(t){return new xt(jt.EQ,[t])},neq:function(t){return new xt(jt.NEQ,[t])},lt:function(t){return new xt(jt.LT,[t])},lte:function(t){return new xt(jt.LTE,[t])},gt:function(t){return new xt(jt.GT,[t])},gte:function(t){return new xt(jt.GTE,[t])},in:function(t){return new xt(jt.IN,t)},nin:function(t){return new xt(jt.NIN,t)},all:function(t){return new xt(jt.ALL,t)},elemMatch:function(t){return new xt(jt.ELEM_MATCH,[t])},exists:function(t){return new xt(jt.EXISTS,[t])},size:function(t){return new xt(jt.SIZE,[t])},mod:function(){return new xt(jt.MOD,1==arguments.length?[arguments[0]]:2==arguments.length?[[arguments[0],arguments[1]]]:arguments)},geoNear:function(t){return new xt(jt.GEO_NEAR,[t])},geoWithin:function(t){return new xt(jt.GEO_WITHIN,[t])},geoIntersects:function(t){return new xt(jt.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 Nt(Et.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 Nt(Et.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 Nt(Et.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 Nt(Et.NOT,n)},set:function(t){return new St(gt.SET,[t])},remove:function(){return new St(gt.REMOVE,[])},inc:function(t){return new St(gt.INC,[t])},mul:function(t){return new St(gt.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 St(gt.PUSH,t)},pull:function(t){return new St(gt.PULL,t)},pullAll:function(t){return new St(gt.PULL_ALL,t)},pop:function(){return new St(gt.POP,[])},shift:function(){return new St(gt.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 St(gt.UNSHIFT,n)},addToSet:function(t){return new St(gt.ADD_TO_SET,t)},rename:function(t){return new St(gt.RENAME,[t])},bit:function(t){return new St(gt.BIT,[t])},max:function(t){return new St(gt.MAX,[t])},min:function(t){return new St(gt.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 ce},abs:function(t){return new fe("abs",t)},add:function(t){return new fe("add",t)},ceil:function(t){return new fe("ceil",t)},divide:function(t){return new fe("divide",t)},exp:function(t){return new fe("exp",t)},floor:function(t){return new fe("floor",t)},ln:function(t){return new fe("ln",t)},log:function(t){return new fe("log",t)},log10:function(t){return new fe("log10",t)},mod:function(t){return new fe("mod",t)},multiply:function(t){return new fe("multiply",t)},pow:function(t){return new fe("pow",t)},sqrt:function(t){return new fe("sqrt",t)},subtract:function(t){return new fe("subtract",t)},trunc:function(t){return new fe("trunc",t)},arrayElemAt:function(t){return new fe("arrayElemAt",t)},arrayToObject:function(t){return new fe("arrayToObject",t)},concatArrays:function(t){return new fe("concatArrays",t)},filter:function(t){return new fe("filter",t)},in:function(t){return new fe("in",t)},indexOfArray:function(t){return new fe("indexOfArray",t)},isArray:function(t){return new fe("isArray",t)},map:function(t){return new fe("map",t)},range:function(t){return new fe("range",t)},reduce:function(t){return new fe("reduce",t)},reverseArray:function(t){return new fe("reverseArray",t)},size:function(t){return new fe("size",t)},slice:function(t){return new fe("slice",t)},zip:function(t){return new fe("zip",t)},and:function(t){return new fe("and",t)},not:function(t){return new fe("not",t)},or:function(t){return new fe("or",t)},cmp:function(t){return new fe("cmp",t)},eq:function(t){return new fe("eq",t)},gt:function(t){return new fe("gt",t)},gte:function(t){return new fe("gte",t)},lt:function(t){return new fe("lt",t)},lte:function(t){return new fe("lte",t)},neq:function(t){return new fe("ne",t)},cond:function(t){return new fe("cond",t)},ifNull:function(t){return new fe("ifNull",t)},switch:function(t){return new fe("switch",t)},dateFromParts:function(t){return new fe("dateFromParts",t)},dateFromString:function(t){return new fe("dateFromString",t)},dayOfMonth:function(t){return new fe("dayOfMonth",t)},dayOfWeek:function(t){return new fe("dayOfWeek",t)},dayOfYear:function(t){return new fe("dayOfYear",t)},isoDayOfWeek:function(t){return new fe("isoDayOfWeek",t)},isoWeek:function(t){return new fe("isoWeek",t)},isoWeekYear:function(t){return new fe("isoWeekYear",t)},millisecond:function(t){return new fe("millisecond",t)},minute:function(t){return new fe("minute",t)},month:function(t){return new fe("month",t)},second:function(t){return new fe("second",t)},hour:function(t){return new fe("hour",t)},week:function(t){return new fe("week",t)},year:function(t){return new fe("year",t)},literal:function(t){return new fe("literal",t)},mergeObjects:function(t){return new fe("mergeObjects",t)},objectToArray:function(t){return new fe("objectToArray",t)},allElementsTrue:function(t){return new fe("allElementsTrue",t)},anyElementTrue:function(t){return new fe("anyElementTrue",t)},setDifference:function(t){return new fe("setDifference",t)},setEquals:function(t){return new fe("setEquals",t)},setIntersection:function(t){return new fe("setIntersection",t)},setIsSubset:function(t){return new fe("setIsSubset",t)},setUnion:function(t){return new fe("setUnion",t)},concat:function(t){return new fe("concat",t)},dateToString:function(t){return new fe("dateToString",t)},indexOfBytes:function(t){return new fe("indexOfBytes",t)},indexOfCP:function(t){return new fe("indexOfCP",t)},split:function(t){return new fe("split",t)},strLenBytes:function(t){return new fe("strLenBytes",t)},strLenCP:function(t){return new fe("strLenCP",t)},strcasecmp:function(t){return new fe("strcasecmp",t)},substr:function(t){return new fe("substr",t)},substrBytes:function(t){return new fe("substrBytes",t)},substrCP:function(t){return new fe("substrCP",t)},toLower:function(t){return new fe("toLower",t)},toUpper:function(t){return new fe("toUpper",t)},meta:function(t){return new fe("meta",t)},addToSet:function(t){return new fe("addToSet",t)},avg:function(t){return new fe("avg",t)},first:function(t){return new fe("first",t)},last:function(t){return new fe("last",t)},max:function(t){return new fe("max",t)},min:function(t){return new fe("min",t)},push:function(t){return new fe("push",t)},stdDevPop:function(t){return new fe("stdDevPop",t)},stdDevSamp:function(t){return new fe("stdDevSamp",t)},sum:function(t){return new fe("sum",t)},let:function(t){return new fe("let",t)}},project:{slice:function(t){return new de("slice",t)},elemMatch:function(t){return new de("elemMatch",t)}}},fe=function(t,e){this["$"+t]=e},de=function(t,e){this["$"+t]=e},pe=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 he(t){return new pe(t)}var ye=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 me(t){return new ye(t)}var ve=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())})},ge=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])}}},be=function(){function t(t){this._db=t,this._request=Se.createRequest(this._db.config),this.aborted=!1,this.commited=!1,this.inited=!1}return t.prototype.init=function(){return ve(this,void 0,void 0,function(){var t;return ge(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 ve(this,void 0,void 0,function(){var t,e;return ge(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 ve(this,void 0,void 0,function(){var e,n;return ge(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 we(){return ve(this,void 0,void 0,function(){var t;return ge(this,function(e){switch(e.label){case 0:return[4,(t=new be(this)).init()];case 1:return e.sent(),[2,t]}})})}function _e(t,e){return void 0===e&&(e=3),ve(this,void 0,void 0,function(){var n,r,o,i,a=this;return ge(this,function(c){switch(c.label){case 0:return c.trys.push([0,4,,10]),[4,(n=new be(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 ve(a,void 0,void 0,function(){return ge(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,_e.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 Oe=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 Ee(t){return new Oe(t)}var Se=function(){function t(t){this.config=t,this.Geo=i,this.serverDate=he,this.command=le,this.RegExp=me,this.ObjectId=Ee,this.startTransaction=we,this.runTransaction=_e,this.logicCommand=Nt,this.updateCommand=St,this.queryCommand=xt}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}();
|
|
2
2
|
//# sourceMappingURL=index.js.map
|