@cloudbase/js-sdk 1.8.2 → 1.8.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/analytics/dist/index.esm.js +1 -1
- package/analytics/dist/index.js +2 -2
- package/app/dist/index.esm.js +1 -1
- package/app/dist/index.js +2 -2
- package/database/dist/index.esm.js +4 -6
- package/database/dist/index.js +5 -7
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/functions/dist/index.esm.js +1 -1
- package/functions/dist/index.js +2 -2
- package/miniprogram_dist/app.js +1 -1
- package/miniprogram_dist/index.js +1 -1
- package/package.json +10 -10
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see index.js.LICENSE.txt */
|
|
2
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("cloudbase",[],e):"object"==typeof exports?exports.cloudbase=e():t.cloudbase=e()}("undefined"!=typeof window?window:this,(function(){return function(){var t={829:function(t,e,n){"use strict";var r;n.r(e),n.d(e,{AbstractSDKRequest:function(){return o},AbstractStorage:function(){return i},StorageType:function(){return r},formatUrl:function(){return s}}),function(t){t.local="local",t.none="none",t.session="session"}(r||(r={}));var o=function(){},i=function(){};function s(t,e,n){void 0===n&&(n={});var r=/\?/.test(e),o="";for(var i in n)""===o?!r&&(e+="?"):o+="&",o+=i+"="+encodeURIComponent(n[i]);return/^http(s)?\:\/\//.test(e+=o)?e:""+t+e}},972:function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}},o=r(n(793)),i=n(273),s=n(363),a=n(614),c=n(63),u=n(505),f=n(622),l=r(n(536)).default.version;o.default.registerVersion(l);try{(0,i.registerAuth)(o.default),(0,s.registerFunctions)(o.default),(0,a.registerStorage)(o.default),(0,f.registerDatabase)(o.default),(0,c.registerRealtime)(o.default),(0,u.registerAnalytics)(o.default)}catch(t){}try{window.cloudbase=o.default}catch(t){}e.default=o.default,t.exports=o.default},505:function(t,e,n){"use strict";n.r(e),n.d(e,{registerAnalytics:function(){return h}});var r=n(650),o=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},i=r.constants.ERRORS,s=r.constants.COMMUNITY_SITE_URL,a=r.helpers.catchErrorsDecorator,c="analytics",u=["mall"],f=new(function(){function t(){}return t.prototype.analytics=function(t){return e=this,n=void 0,o=function(){var e,n,r;return function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,(function(o){if(!function(t){if("Object"!==Object.prototype.toString.call(t).slice(8,-1))return!1;var e=t.report_data,n=t.report_type;return!1!==u.includes(n)&&"Object"===Object.prototype.toString.call(e).slice(8,-1)&&!(void 0!==e.action_time&&!Number.isInteger(e.action_time))&&"string"==typeof e.action_type}(t))throw new Error(JSON.stringify({code:i.INVALID_PARAMS,msg:"[".concat(c,".analytics] invalid report data")}));return e=void 0===t.report_data.action_time?Math.floor(Date.now()/1e3):t.report_data.action_time,n={analytics_scene:t.report_type,analytics_data:Object.assign({},t.report_data,{action_time:e})},r={requestData:n},this.request.send("analytics.report",r),[2]}))},new((r=void 0)||(r=Promise))((function(t,i){function s(t){try{c(o.next(t))}catch(t){i(t)}}function a(t){try{c(o.throw(t))}catch(t){i(t)}}function c(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r((function(t){t(n)}))).then(s,a)}c((o=o.apply(e,n||[])).next())}));var e,n,r,o},function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);i>3&&s&&Object.defineProperty(e,n,s)}([a({customInfo:{className:"Cloudbase",methodName:"analytics"},title:"上报调用失败",messages:["请确认以下各项:"," 1 - 调用 analytics() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(s)]}),o("design:type",Function),o("design:paramtypes",[Object]),o("design:returntype",Promise)],t.prototype,"analytics",null),t}()),l={name:c,entity:{analytics:f.analytics}};try{cloudbase.registerComponent(l)}catch(t){}function h(t){try{t.registerComponent(l)}catch(t){console.warn(t)}}},793:function(t,e,n){"use strict";n.r(e),n.d(e,{cloudbase:function(){return ct},default:function(){return ut}});var r,o=n(650),i=n(829),s=(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)e.hasOwnProperty(n)&&(t[n]=e[n])},r(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),a=function(){return a=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},a.apply(this,arguments)},c=function(t){function e(e){void 0===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 s(e,t),e.prototype.post=function(t){var e=this;return new Promise((function(n,r){var o=t.url,s=t.data,a=t.headers,c=wx.request({url:(0,i.formatUrl)("https:",o),data:s,timeout:e._timeout,method:"POST",header:a,success:function(t){n(t)},fail:function(t){r(t)},complete:function(t){if(t&&t.errMsg&&e._timeout&&-1!==e._restrictedMethods.indexOf("post")&&"request:fail timeout"===t.errMsg){console.warn(e._timeoutMsg);try{c.abort()}catch(t){}}}})}))},e.prototype.upload=function(t){var e=this,n=this;return new Promise((function(r){return o=e,i=void 0,c=function(){var e,o,i,s,c,u;return function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}(this,(function(f){return e=t.url,o=t.file,i=t.data,s=t.headers,c=t.onUploadProgress,u=wx.uploadFile({url:e,filePath:o,name:"file",formData:a({},i),header:s,timeout:this._timeout,success:function(t){var e={statusCode:t.statusCode,data:t.data||{}};200===t.statusCode&&i.success_action_status&&(e.statusCode=parseInt(i.success_action_status,10)),r(e)},fail:function(t){r(t)},complete:function(t){if(t&&t.errMsg&&n._timeout&&-1!==n._restrictedMethods.indexOf("upload")&&"request:fail timeout"===t.errMsg){console.warn(n._timeoutMsg);try{u.abort()}catch(t){}}}}),c&&u.onProgressUpdate((function(t){c(t)})),[2]}))},new((s=void 0)||(s=Promise))((function(t,e){function n(t){try{a(c.next(t))}catch(t){e(t)}}function r(t){try{a(c.throw(t))}catch(t){e(t)}}function a(e){var o;e.done?t(e.value):(o=e.value,o instanceof s?o:new s((function(t){t(o)}))).then(n,r)}a((c=c.apply(o,i||[])).next())}));var o,i,s,c}))},e.prototype.download=function(t){var e=this,n=this;return new Promise((function(r,o){var s=t.url,a=t.headers,c=wx.downloadFile({url:(0,i.formatUrl)("https:",s),header:a,timeout:e._timeout,success:function(t){200===t.statusCode&&t.tempFilePath?r({statusCode:200,tempFilePath:t.tempFilePath}):r(t)},fail:function(t){o(t)},complete:function(t){if(t&&t.errMsg&&n._timeout&&-1!==n._restrictedMethods.indexOf("download")&&"request:fail timeout"===t.errMsg){console.warn(n._timeoutMsg);try{c.abort()}catch(t){}}}})}))},e}(i.AbstractSDKRequest),u={setItem:function(t,e){wx.setStorageSync(t,e)},getItem:function(t){return wx.getStorageSync(t)},removeItem:function(t){wx.removeStorageSync(t)},clear:function(){wx.clearStorageSync()}},f=function(t,e){void 0===e&&(e={});var n=wx.connectSocket(a({url:t},e));return{set onopen(t){n.onOpen(t)},set onmessage(t){n.onMessage(t)},set onclose(t){n.onClose(t)},set onerror(t){n.onError(t)},send:function(t){return n.send({data:t})},close:function(t,e){return n.close({code:t,reason:e})},get readyState(){return n.readyState},CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3}},l={genAdapter:function(){return{root:{},reqClass:c,wsClass:f,localStorage:u,primaryStorage:i.StorageType.local,getAppSign:function(){var t=wx.getAccountInfoSync();return"undefined"!=typeof App||"undefined"!=typeof getApp||wx.onAppHide||wx.offAppHide||wx.onAppShow||wx.offAppShow?t&&t.miniProgram?t.miniProgram.appId:"":t&&t.plugin?t.plugin.appId:""}}},isMatch:function(){if("undefined"==typeof wx)return!1;if("undefined"==typeof Page)return!1;if(!wx.getSystemInfoSync)return!1;if(!wx.getStorageSync)return!1;if(!wx.setStorageSync)return!1;if(!wx.connectSocket)return!1;if(!wx.request)return!1;try{if(!wx.getSystemInfoSync())return!1;if("qq"===wx.getSystemInfoSync().AppPlatform)return!1}catch(t){return!1}return!0},runtime:"wx_mp"},h=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))},p=o.constants.ERRORS,d={};function y(t,e){var n=e.name,r=e.namespace,o=e.entity,i=e.injectEvents,s=e.IIFE,a=void 0!==s&&s;if(d[n]||r&&t[r])throw new Error(JSON.stringify({code:p.INVALID_OPERATION,msg:"Duplicate component ".concat(n)}));if(a){if(!o||"function"!=typeof o)throw new Error(JSON.stringify({code:p.INVALID_PARAMS,msg:"IIFE component's entity must be a function"}));o.call(t)}if(d[n]=e,r?t.prototype[r]=o:g(t.prototype,o),i){var c=i.bus,u=i.events;if(!c||!u||0===u.length)return;var f=t.prototype.fire||function(){};t.prototype.events||(t.prototype.events={}),(t.prototype.events||{})[n]?t.prototype.events[n].events=h(h([],t.prototype.events[n].events,!0),u,!0):t.prototype.events[n]={bus:c,events:u},t.prototype.fire=function(t,e){for(var n in f(t,e),this.events){var r=this.events[n],o=r.bus;if(r.events.includes(t)){o.fire(t,e);break}}}}}function g(t,e){if(!(e instanceof Object))return e;switch(e.constructor){case Date:return new Date(e.getTime());case Object:void 0===t&&(t={});break;case Array:t=[];break;default:return e}for(var n in e)e.hasOwnProperty(n)&&(t[n]=g(t[n],e[n]));return t}var v={},m=function(){return m=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},m.apply(this,arguments)},_=o.cache.CloudbaseCache,w={},b={};function E(t){var e=t.env,n=t.persistence,r=t.platformInfo,o={accessTokenKey:"".concat("access_token","_").concat(e),accessTokenExpireKey:"".concat("access_token_expire","_").concat(e),refreshTokenKey:"".concat("refresh_token","_").concat(e),anonymousUuidKey:"".concat("anonymous_uuid","_").concat(e),loginTypeKey:"".concat("login_type","_").concat(e),userInfoKey:"".concat("user_info","_").concat(e)};w[e]?w[e].updatePersistence(n):w[e]=new _(m(m({},t),{keys:o,platformInfo:r,alwaysLocalKeys:["anonymousUuidKey"]})),b[e]=b[e]||new _(m(m({},t),{keys:o,platformInfo:r,persistence:"local"}))}function S(t){return w[t]}function I(t){return b[t]}var O,A=o.constants.setSdkName,T=o.constants.setProtocol,N="",R="@cloudbase/js-sdk",P="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:",x="//tcb-api.tencentcloudapi.com/web";function L(t,e){x=t,e&&(P=e,T(e))}function C(){return{BASE_URL:x,PROTOCOL:P}}!function(t){t.ANONYMOUS="ANONYMOUS",t.WECHAT="WECHAT",t.CUSTOM="CUSTOM",t.NULL="NULL"}(O||(O={}));var k=function(){return k=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},k.apply(this,arguments)},U=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},j=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},D=o.constants.ERRORS,M=o.utils.genSeqId,q=o.utils.isFormData,B=o.utils.formatUrl,F=o.utils.createSign,W=o.adapters.RUNTIME,$=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"];function H(t,e,n){var r=t[e];t[e]=function(e){var o={},i={};n.forEach((function(n){var r=n.call(t,e),s=r.data,a=r.headers;Object.assign(o,s),Object.assign(i,a)}));var s=e.data;return s&&function(){if(q(s))for(var t in o)s.append(t,o[t]);else e.data=k(k({},s),o)}(),e.headers=k(k({},e.headers||{}),i),r.call(t,e)}}function G(){var t=M();return{data:{seqId:t},headers:{"X-SDK-Version":"@cloudbase/js-sdk/".concat(N),"x-seqid":t}}}var K=function(){function t(t){this._throwWhenRequestFail=!1,this.config=t,this._reqClass=new v.adapter.reqClass({timeout:this.config.timeout,timeoutMsg:"[@cloudbase/js-sdk] 请求在".concat(this.config.timeout/1e3,"s内未完成,已中断"),restrictedMethods:["post"]}),this._throwWhenRequestFail=t.throw||!1,this._cache=S(this.config.env),this._localCache=I(this.config.env),H(this._reqClass,"post",[G]),H(this._reqClass,"upload",[G]),H(this._reqClass,"download",[G])}return t.prototype.post=function(t){return U(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this._reqClass.post(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.upload=function(t){return U(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this._reqClass.upload(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.download=function(t){return U(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this._reqClass.download(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.refreshAccessToken=function(){return U(this,void 0,void 0,(function(){var t,e,n;return j(this,(function(r){switch(r.label){case 0:this._refreshAccessTokenPromise||(this._refreshAccessTokenPromise=this._refreshAccessToken()),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this._refreshAccessTokenPromise];case 2:return t=r.sent(),[3,4];case 3:return n=r.sent(),e=n,[3,4];case 4:if(this._refreshAccessTokenPromise=null,this._shouldRefreshAccessTokenHook=null,e)throw e;return[2,t]}}))}))},t.prototype.getAccessToken=function(){return U(this,void 0,void 0,(function(){var t,e,n,r,o,i,s,a,c;return j(this,(function(u){switch(u.label){case 0:return t=this._cache.keys,e=t.accessTokenKey,n=t.accessTokenExpireKey,r=t.refreshTokenKey,[4,this._cache.getStoreAsync(r)];case 1:if(!u.sent())throw new Error(JSON.stringify({code:D.OPERATION_FAIL,msg:"refresh token is not exist, your local data might be messed up, please retry after clear localStorage or sessionStorage"}));return[4,this._cache.getStoreAsync(e)];case 2:return o=u.sent(),s=Number,[4,this._cache.getStoreAsync(n)];case 3:return i=s.apply(void 0,[u.sent()]),a=!0,(c=this._shouldRefreshAccessTokenHook)?[4,this._shouldRefreshAccessTokenHook(o,i)]:[3,5];case 4:c=!u.sent(),u.label=5;case 5:return c&&(a=!1),o&&i&&!(i<Date.now())||!a?[3,7]:[4,this.refreshAccessToken()];case 6:return[2,u.sent()];case 7:return[2,{accessToken:o,accessTokenExpire:i}]}}))}))},t.prototype.request=function(t,e,n){return U(this,void 0,void 0,(function(){var r,o,i,s,a,c,u,f,l,h,p,d,y,g,m,_,w,b,E,S,I,O,A,T,N,R;return j(this,(function(P){switch(P.label){case 0:return r="x-tcb-trace_".concat(this.config.env),o="application/x-www-form-urlencoded",i=k({action:t,dataVersion:"2020-01-10",env:this.config.env},e),-1!==$.indexOf(t)?[3,3]:(s=this._cache.keys.refreshTokenKey,[4,this._cache.getStoreAsync(s)]);case 1:return P.sent()?(a=i,[4,this.getAccessToken()]):[3,3];case 2:a.access_token=P.sent().accessToken,P.label=3;case 3:if("storage.uploadFile"===t){for(u in c=new FormData)c.hasOwnProperty(u)&&void 0!==c[u]&&c.append(u,i[u]);o="multipart/form-data"}else for(u in o="application/json;charset=UTF-8",c={},i)void 0!==i[u]&&(c[u]=i[u]);return f={headers:{"content-type":o}},(null==n?void 0:n.onUploadProgress)&&(f.onUploadProgress=n.onUploadProgress),this.config.region&&(f.headers["X-TCB-Region"]=this.config.region),(l=this._localCache.getStore(r))&&(f.headers["X-TCB-Trace"]=l),v.runtime!==W.WEB&&(h=this.config,p=h.appSign,d=h.appSecret,y=Date.now(),g=d.appAccessKey,m=d.appAccessKeyId,_=F({data:{},timestamp:y,appAccessKeyId:m,appSign:p},g),f.headers["X-TCB-App-Source"]="timestamp=".concat(y,";appAccessKeyId=").concat(m,";appSign=").concat(p,";sign=").concat(_)),w=e.parse,b=e.inQuery,E=e.search,S={env:this.config.env},w&&(S.parse=!0),b&&(S=k(k({},b),S)),I=C(),O=I.BASE_URL,A=I.PROTOCOL,T=B(A,O,S),E&&(T+=E),[4,this.post(k({url:T,data:c},f))];case 4:if(N=P.sent(),(R=N.header&&N.header["x-tcb-trace"])&&this._localCache.setStore(r,R),200!==Number(N.status)&&200!==Number(N.statusCode)||!N.data)throw new Error("network request error");return[2,N]}}))}))},t.prototype.send=function(t,e){return void 0===e&&(e={}),U(this,void 0,void 0,(function(){var n;return j(this,(function(r){switch(r.label){case 0:return[4,this.request(t,e,{onUploadProgress:e.onUploadProgress})];case 1:return"ACCESS_TOKEN_EXPIRED"!==(n=r.sent()).data.code||-1!==$.indexOf(t)?[3,4]:[4,this.refreshAccessToken()];case 2:return r.sent(),[4,this.request(t,e,{onUploadProgress:e.onUploadProgress})];case 3:n=r.sent(),r.label=4;case 4:if(n.data.code&&this._throwWhenRequestFail)throw new Error(JSON.stringify({code:D.OPERATION_FAIL,msg:"[".concat(n.data.code,"] ").concat(n.data.message)}));return[2,n.data]}}))}))},t.prototype._refreshAccessToken=function(t){return void 0===t&&(t=1),U(this,void 0,void 0,(function(){var e,n,r,o,i,s,a,c,u,f,l,h,p;return j(this,(function(d){switch(d.label){case 0:return e=this._cache.keys,n=e.accessTokenKey,r=e.accessTokenExpireKey,o=e.refreshTokenKey,i=e.loginTypeKey,s=e.anonymousUuidKey,[4,this._cache.removeStoreAsync(n)];case 1:return d.sent(),[4,this._cache.removeStoreAsync(r)];case 2:return d.sent(),[4,this._cache.getStoreAsync(o)];case 3:if(!(a=d.sent()))throw new Error(JSON.stringify({code:D.INVALID_OPERATION,msg:"not login"}));return c={refresh_token:a},[4,this.request("auth.fetchAccessTokenWithRefreshToken",c)];case 4:return(u=d.sent()).data.code?"SIGN_PARAM_INVALID"!==(f=u.data.code)&&"REFRESH_TOKEN_EXPIRED"!==f&&"INVALID_REFRESH_TOKEN"!==f?[3,11]:[4,this._cache.getStoreAsync(i)]:[3,12];case 5:return d.sent()===O.ANONYMOUS&&"INVALID_REFRESH_TOKEN"===f?[4,this._cache.getStoreAsync(s)]:[3,9];case 6:return l=d.sent(),[4,this._cache.getStoreAsync(o)];case 7:return h=d.sent(),[4,this.send("auth.signInAnonymously",{anonymous_uuid:l,refresh_token:h})];case 8:if(p=d.sent(),this._setRefreshToken(p.refresh_token),t>=1)return[2,this._refreshAccessToken(--t)];throw new Error(JSON.stringify({code:D.OPERATION_FAIL,message:"重试获取 refresh token 失败"}));case 9:return ct.fire("loginStateExpire"),[4,this._cache.removeStoreAsync(o)];case 10:d.sent(),d.label=11;case 11:throw new Error(JSON.stringify({code:D.NETWORK_ERROR,msg:"refresh access_token failed:".concat(u.data.code)}));case 12:return u.data.access_token?(ct.fire("refreshAccessToken"),[4,this._cache.setStoreAsync(n,u.data.access_token)]):[3,15];case 13:return d.sent(),[4,this._cache.setStoreAsync(r,u.data.access_token_expire+Date.now())];case 14:return d.sent(),[2,{accessToken:u.data.access_token,accessTokenExpire:u.data.access_token_expire}];case 15:return u.data.refresh_token?[4,this._cache.removeStoreAsync(o)]:[3,19];case 16:return d.sent(),[4,this._cache.setStoreAsync(o,u.data.refresh_token)];case 17:return d.sent(),[4,this._refreshAccessToken()];case 18:d.sent(),d.label=19;case 19:return[2]}}))}))},t.prototype._setRefreshToken=function(t){return U(this,void 0,void 0,(function(){var e,n,r,o;return j(this,(function(i){switch(i.label){case 0:return e=this._cache.keys,n=e.accessTokenKey,r=e.accessTokenExpireKey,o=e.refreshTokenKey,[4,this._cache.removeStoreAsync(n)];case 1:return i.sent(),[4,this._cache.removeStoreAsync(r)];case 2:return i.sent(),[4,this._cache.setStoreAsync(o,t)];case 3:return i.sent(),[2]}}))}))},t}(),V={},J=function(){return J=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},J.apply(this,arguments)},Y=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},z=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},X=o.adapters.useAdapters,Z=o.adapters.useDefaultAdapter,Q=o.adapters.RUNTIME,tt=o.constants.ERRORS,et=o.constants.COMMUNITY_SITE_URL,nt=o.utils.printWarn,rt=o.helpers.catchErrorsDecorator,ot={timeout:15e3,persistence:"local"},it=6e5,st={},at=function(){function t(t){this._config=t||this._config,this.authInstance=null}return Object.defineProperty(t.prototype,"config",{get:function(){return this._config},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"platform",{get:function(){return v},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cache",{get:function(){return S(this._config.env)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCache",{get:function(){return I(this._config.env)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"request",{get:function(){return t=this._config.env,V[t];var t},enumerable:!1,configurable:!0}),t.prototype.init=function(e){if(!e.env)throw new Error(JSON.stringify({code:tt.INVALID_PARAMS,msg:"env must not be specified"}));if(v.adapter||this._useDefaultAdapter(),this.requestClient=new v.adapter.reqClass({timeout:e.timeout||5e3,timeoutMsg:"[".concat(R,"][REQUEST TIMEOUT] request had been abort since didn't finished within").concat(e.timeout/1e3,"s")}),v.runtime!==Q.WEB){if(!e.appSecret)throw new Error(JSON.stringify({code:tt.INVALID_PARAMS,msg:"invalid appSecret"}));var n=v.adapter.getAppSign?v.adapter.getAppSign():"";if(e.appSign&&n&&e.appSign!==n)throw new Error(JSON.stringify({code:tt.INVALID_PARAMS,msg:"invalid appSign"}));if(n&&(e.appSign=n),!e.appSign)throw new Error(JSON.stringify({code:tt.INVALID_PARAMS,msg:"invalid appSign"}))}this._config=J(J({},ot),e),this._config.timeout=this._formatTimeout(this._config.timeout);var r=this._config,o=r.env,i=r.persistence,s=r.debug,a=r.timeout,c=r.appSecret,u=r.appSign;E({env:o,persistence:i,debug:s,platformInfo:this.platform}),function(t){V[t.env]=new K(k(k({},t),{throw:!0}))}({env:o,region:e.region||"",timeout:a,appSecret:c,appSign:u}),e.region&&function(t,e){L(e?"//".concat(t,".").concat(e,".tcb-api.tencentcloudapi.com/web"):"//".concat(t,".ap-shanghai.tcb-api.tencentcloudapi.com/web"),void 0)}(o,e.region||"");var f=new t(this._config);return f.requestClient=this.requestClient,f},t.prototype.updateConfig=function(t){var e=t.persistence,n=t.debug;this._config.persistence=e,this._config.debug=n,E({env:this._config.env,persistence:e,debug:n,platformInfo:this.platform})},t.prototype.registerExtension=function(t){st[t.name]=t},t.prototype.invokeExtension=function(t,e){return n=this,r=void 0,i=function(){var n;return function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,(function(r){switch(r.label){case 0:if(!(n=st[t]))throw new Error(JSON.stringify({code:tt.INVALID_PARAMS,msg:"extension:".concat(t," must be registered before invoke")}));return[4,n.invoke(e,this)];case 1:return[2,r.sent()]}}))},new((o=void 0)||(o=Promise))((function(t,e){function s(t){try{c(i.next(t))}catch(t){e(t)}}function a(t){try{c(i.throw(t))}catch(t){e(t)}}function c(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(s,a)}c((i=i.apply(n,r||[])).next())}));var n,r,o,i},t.prototype.useAdapters=function(t){var e=X(t)||{},n=e.adapter,r=e.runtime;n&&(v.adapter=n),r&&(v.runtime=r)},t.prototype.registerHook=function(e){!function(t,e){var n=e.entity,r=e.target;if(!t.prototype.hasOwnProperty(r))throw new Error(JSON.stringify({code:p.INVALID_OPERATION,msg:"target:".concat(r," is not exist")}));var o=t.prototype[r];if("function"!=typeof o)throw new Error(JSON.stringify({code:p.INVALID_OPERATION,msg:"target:".concat(r," is not a function which is the only type supports hook")}));t.prototype[r]=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n.call.apply(n,h([this],t,!1)),o.call.apply(o,h([this],t,!1))}}(t,e)},t.prototype.registerComponent=function(e){y(t,e)},t.prototype.registerVersion=function(t){!function(t){N=t}(t)},t.prototype.registerSdkName=function(t){!function(t){R=t,A(t)}(t)},t.prototype.registerEndPoint=function(t,e){L(t,e)},t.prototype._useDefaultAdapter=function(){var t=Z(),e=t.adapter,n=t.runtime;v.adapter=e,v.runtime=n},t.prototype._formatTimeout=function(t){switch(!0){case t>it:return nt(tt.INVALID_PARAMS,"timeout is greater than maximum value[10min]"),it;case t<100:return nt(tt.INVALID_PARAMS,"timeout is less than maximum value[100ms]"),100;default:return t}},Y([rt({mode:"sync",title:"Cloudbase 初始化失败",messages:["请确认以下各项:"," 1 - 调用 cloudbase.init() 的语法或参数是否正确"," 2 - 如果是非浏览器环境,是否配置了安全应用来源(https://docs.cloudbase.net/api-reference/webv2/adapter.html#jie-ru-liu-cheng)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(et)]}),z("design:type",Function),z("design:paramtypes",[Object]),z("design:returntype",t)],t.prototype,"init",null),Y([rt({title:"调用扩展能力失败",messages:["请确认以下各项:"," 1 - 调用 invokeExtension() 的语法或参数是否正确"," 2 - 被调用的扩展能力是否已经安装并通过 registerExtension() 注册","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(et)]}),z("design:type",Function),z("design:paramtypes",[String,Object]),z("design:returntype",Promise)],t.prototype,"invokeExtension",null),t}(),ct=new at;ct.useAdapters(l);var ut=ct},273:function(t,e,n){"use strict";n.r(e),n.d(e,{Auth:function(){return jt},AuthProvider:function(){return a},EVENTS:function(){return Dt},LoginState:function(){return Ut},eventBus:function(){return Ct},registerAuth:function(){return qt},registerProvider:function(){return Bt}});var r,o=n(650),i=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},s=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},a=function(){function t(t){this._config=t,this._cache=t.cache,this._request=t.request}return t.prototype.checkLocalLoginState=function(){return i(this,void 0,void 0,(function(){var t,e,n,r,o,i;return s(this,(function(s){switch(s.label){case 0:return t=this._cache.keys,e=t.accessTokenKey,n=t.accessTokenExpireKey,[4,this._cache.getStoreAsync(e)];case 1:return r=s.sent(),[4,this._cache.getStoreAsync(n)];case 2:return o=s.sent(),r?o&&o>Date.now()?[4,(i=new Ut({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()]:[3,4]:[3,7];case 3:return s.sent(),[2,i];case 4:return[4,this._cache.removeStoreAsync(e)];case 5:return s.sent(),[4,this._cache.removeStoreAsync(n)];case 6:s.sent(),s.label=7;case 7:return[2]}}))}))},t.prototype.setRefreshToken=function(t){return i(this,void 0,void 0,(function(){var e,n,r,o;return s(this,(function(i){switch(i.label){case 0:return e=this._cache.keys,n=e.accessTokenKey,r=e.accessTokenExpireKey,o=e.refreshTokenKey,[4,this._cache.removeStoreAsync(n)];case 1:return i.sent(),[4,this._cache.removeStoreAsync(r)];case 2:return i.sent(),[4,this._cache.setStoreAsync(o,t)];case 3:return i.sent(),[2]}}))}))},t.prototype.setAccessToken=function(t,e){return i(this,void 0,void 0,(function(){var n,r,o;return s(this,(function(i){switch(i.label){case 0:return n=this._cache.keys,r=n.accessTokenKey,o=n.accessTokenExpireKey,[4,this._cache.setStoreAsync(r,t)];case 1:return i.sent(),[4,this._cache.setStoreAsync(o,e)];case 2:return i.sent(),[2]}}))}))},t.prototype.refreshUserInfo=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return[4,this._request.send("auth.getUserInfo",{})];case 1:return t=e.sent().data,[4,this.setLocalUserInfo(t)];case 2:return e.sent(),[2,t]}}))}))},t.prototype.setLocalUserInfo=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e=this._cache.keys.userInfoKey,[4,this._cache.setStoreAsync(e,t)];case 1:return n.sent(),[2]}}))}))},t}();!function(t){t.ANONYMOUS="ANONYMOUS",t.WECHAT="WECHAT",t.WECHAT_PUBLIC="WECHAT-PUBLIC",t.WECHAT_OPEN="WECHAT-OPEN",t.CUSTOM="CUSTOM",t.EMAIL="EMAIL",t.USERNAME="USERNAME",t.NULL="NULL",t.PHONE="PHONE"}(r||(r={}));var c,u=(c=function(t,e){return c=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])},c(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}c(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),f=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},l=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},h=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},p=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},d=o.constants.getSdkName,y=o.constants.ERRORS,g=o.constants.COMMUNITY_SITE_URL,v=o.adapters.RUNTIME,m=o.utils.getQuery,_=o.utils.getHash,w=o.utils.removeParam,b=o.utils.printWarn,E=o.helpers.catchErrorsDecorator,S=function(t){function e(e,n,r,o){var i=t.call(this,e)||this;return i._runtime=e.runtime,i._appid=n,i._scope=r,i._state=o||"weixin",i}return u(e,t),e.prototype.signIn=function(){return h(this,void 0,void 0,(function(){return p(this,(function(t){return[2,b(y.OPERATION_FAIL,"API signIn has been deprecated, please use signInWithRedirect insteed")]}))}))},e.prototype.signInWithRedirect=function(){return h(this,void 0,void 0,(function(){return p(this,(function(t){return[2,this._redirect()]}))}))},e.prototype.getRedirectResult=function(t){return h(this,void 0,void 0,(function(){var e;return p(this,(function(n){return(e=I())?[2,this._signInWithCode(e,t)]:[2,null]}))}))},e.prototype.getLinkRedirectResult=function(t){return void 0===t&&(t={}),h(this,void 0,void 0,(function(){var e,n,r,o,i,s;return p(this,(function(a){return s=t.withUnionId,e=void 0!==s&&s,(n=I())?(r=this._appid,c=this._scope,o="snsapi_login"===c?"WECHAT-OPEN":"WECHAT-PUBLIC",i=this._runtime===v.WX_MP?"1":"0",[2,this._request.send("auth.linkWithWeixinCode",{payload:{appid:r,loginType:o,code:n,hybridMiniapp:i,withUnionId:e}})]):[2,null];var c}))}))},e.prototype._redirect=function(){var t=w("code",location.href);t=w("state",t),t=encodeURIComponent(t);var e="//open.weixin.qq.com/connect/oauth2/authorize";"snsapi_login"===this._scope&&(e="//open.weixin.qq.com/connect/qrconnect");try{location.href="".concat(e,"?appid=").concat(this._appid,"&redirect_uri=").concat(t,"&response_type=code&scope=").concat(this._scope,"&state=").concat(this._state,"#wechat_redirect")}catch(t){throw new Error("[".concat(d(),"][").concat(y.UNKOWN_ERROR,"]").concat(t))}},e.prototype._signInWithCode=function(t,e){return h(this,void 0,void 0,(function(){var n,o,i,s,a,c,u,f;return p(this,(function(l){switch(l.label){case 0:return f=this._cache.keys,n=f.accessTokenKey,o=f.accessTokenExpireKey,i=f.refreshTokenKey,h=this._scope,s="snsapi_login"===h?"WECHAT-OPEN":"WECHAT-PUBLIC",[4,this._getRefreshTokenByWXCode(this._appid,s,t,e)];case 1:return a=l.sent(),c=a.refreshToken,[4,this._cache.setStoreAsync(i,c)];case 2:return l.sent(),a.accessToken?[4,this._cache.setStoreAsync(n,a.accessToken)]:[3,4];case 3:l.sent(),l.label=4;case 4:return a.accessTokenExpire?[4,this._cache.setStoreAsync(o,String(a.accessTokenExpire+Date.now()))]:[3,6];case 5:l.sent(),l.label=6;case 6:return Ct.fire(Dt.LOGIN_STATE_CHANGED),Ct.fire(Dt.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:r.WECHAT,persistence:this._config.persistence}),[4,this.refreshUserInfo()];case 7:return l.sent(),[4,(u=new Ut({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 8:return l.sent(),[2,u]}var h}))}))},e.prototype._getRefreshTokenByWXCode=function(t,e,n,r){return void 0===r&&(r={}),h(this,void 0,void 0,(function(){var o,i,s,a,c,u;return p(this,(function(f){return c=r.withUnionId,o=void 0!==c&&c,u=r.createUser,i=void 0===u||u,s="snsapi_base"!==this._scope&&(r.syncUserInfo||!1),a=this._runtime===v.WX_MP?"1":"0",[2,this._request.send("auth.signIn",{appid:t,loginType:e,hybridMiniapp:a,syncUserInfo:s,loginCredential:n,withUnionId:o,createUser:i}).then((function(t){if(t.code)throw new Error("[".concat(d(),"][").concat(y.OPERATION_FAIL,"] failed login via wechat: ").concat(t.code));if(t.refresh_token)return{refreshToken:t.refresh_token,accessToken:t.access_token,accessTokenExpire:t.access_token_expire};throw new Error("[".concat(d(),"][").concat(y.OPERATION_FAIL,"] action:getJwt not return refreshToken"))}))]}))}))},f([E({title:"跳转微信公众号授权失败",messages:["请确认以下各项:"," 1 - 调用 auth().weixinAuthProvider().signInWithRedirect() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(g)]}),l("design:type",Function),l("design:paramtypes",[]),l("design:returntype",Promise)],e.prototype,"signInWithRedirect",null),f([E({title:"微信公众号登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().weixinAuthProvider().getRedirectResult() 的语法或参数是否正确"," 2 - 当前环境是否开通了微信公众号登录授权"," 3 - 微信公众号的 AppId 与 AppSecret 配置是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(g)]}),l("design:type",Function),l("design:paramtypes",[Object]),l("design:returntype",Promise)],e.prototype,"getRedirectResult",null),f([E({title:"获取微信重定向绑定结果",messages:["请确认以下各项:"," 1 - 调用 auth().weixinAuthProvider().getLinkRedirectResult() 的语法或参数是否正确"," 2 - 当前环境是否开通了微信公众号登录授权"," 3 - 微信公众号的 AppId 与 AppSecret 配置是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(g)]}),l("design:type",Function),l("design:paramtypes",[Object]),l("design:returntype",Promise)],e.prototype,"getLinkRedirectResult",null),e}(a);function I(){return m("code")||_("code")}var O=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)}}(),A=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},T=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},N=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},R=o.constants.ERRORS,P=o.constants.COMMUNITY_SITE_URL,x=o.utils.throwError,L=o.utils.isString,C=o.events.addEventListener,k=o.helpers.catchErrorsDecorator,U=function(t){function e(e){var n=t.call(this,e)||this;return n._onConverted=n._onConverted.bind(n),C(Dt.ANONYMOUS_CONVERTED,n._onConverted),n}return O(e,t),e.prototype.signIn=function(){return T(this,void 0,void 0,(function(){var t,e,n,o,i,s,a;return N(this,(function(c){switch(c.label){case 0:return[4,this._cache.updatePersistenceAsync("local")];case 1:return c.sent(),a=this._cache.keys,t=a.anonymousUuidKey,e=a.refreshTokenKey,[4,this._cache.getStoreAsync(t)];case 2:return n=c.sent(),[4,this._cache.getStoreAsync(e)];case 3:return o=c.sent(),[4,this._request.send("auth.signInAnonymously",{anonymous_uuid:n,refresh_token:o})];case 4:return(i=c.sent()).uuid&&i.refresh_token?[4,this._setAnonymousUUID(i.uuid)]:[3,10];case 5:return c.sent(),[4,this.setRefreshToken(i.refresh_token)];case 6:return c.sent(),[4,this._request.refreshAccessToken()];case 7:return c.sent(),Ct.fire(Dt.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:r.ANONYMOUS,persistence:"local"}),Ct.fire(Dt.LOGIN_STATE_CHANGED),[4,(s=new Ut({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 8:return c.sent(),[4,s.user.refresh()];case 9:return c.sent(),[2,s];case 10:throw new Error(JSON.stringify({code:R.OPERATION_FAIL,msg:JSON.stringify(i)||"anonymous signIn failed"}))}}))}))},e.prototype.linkAndRetrieveDataWithTicket=function(t){return T(this,void 0,void 0,(function(){var e,n,o,i,s,a,c;return N(this,(function(u){switch(u.label){case 0:return L(t)||x(R.INVALID_PARAMS,"ticket must be a string"),c=this._cache.keys,e=c.anonymousUuidKey,n=c.refreshTokenKey,[4,this._cache.getStoreAsync(e)];case 1:return o=u.sent(),[4,this._cache.getStoreAsync(n)];case 2:return i=u.sent(),[4,this._request.send("auth.linkAndRetrieveDataWithTicket",{anonymous_uuid:o,refresh_token:i,ticket:t})];case 3:return(s=u.sent()).refresh_token?[4,this._clearAnonymousUUID()]:[3,8];case 4:return u.sent(),[4,this.setRefreshToken(s.refresh_token)];case 5:return u.sent(),[4,this._request.refreshAccessToken()];case 6:return u.sent(),Ct.fire(Dt.ANONYMOUS_CONVERTED,{env:this._config.env}),Ct.fire(Dt.LOGIN_TYPE_CHANGED,{loginType:r.CUSTOM,persistence:"local"}),[4,(a=new Ut({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 7:return u.sent(),[2,a];case 8:return x(R.OPERATION_FAIL,JSON.stringify(s)||"linkAndRetrieveDataWithTicket failed"),[2]}}))}))},e.prototype._setAnonymousUUID=function(t){return T(this,void 0,void 0,(function(){var e,n,o;return N(this,(function(i){switch(i.label){case 0:return o=this._cache.keys,e=o.anonymousUuidKey,n=o.loginTypeKey,[4,this._cache.removeStoreAsync(e)];case 1:return i.sent(),[4,this._cache.setStoreAsync(e,t)];case 2:return i.sent(),[4,this._cache.setStoreAsync(n,r.ANONYMOUS)];case 3:return i.sent(),[2]}}))}))},e.prototype._clearAnonymousUUID=function(){return T(this,void 0,void 0,(function(){return N(this,(function(t){switch(t.label){case 0:return[4,this._cache.removeStoreAsync(this._cache.keys.anonymousUuidKey)];case 1:return t.sent(),[2]}}))}))},e.prototype._onConverted=function(t){return T(this,void 0,void 0,(function(){return N(this,(function(e){switch(e.label){case 0:return t.data.env!==this._config.env?[2]:[4,this._cache.updatePersistenceAsync(this._config.persistence)];case 1:return e.sent(),[2]}}))}))},function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);i>3&&s&&Object.defineProperty(e,n,s)}([k({title:"匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().anonymouseProvider().signIn() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(P)]}),A("design:type",Function),A("design:paramtypes",[]),A("design:returntype",Promise)],e.prototype,"signIn",null),e}(a),j=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)}}(),D=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},M=o.constants.ERRORS,q=o.constants.COMMUNITY_SITE_URL,B=o.utils.isString,F=o.helpers.catchErrorsDecorator,W=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return j(e,t),e.prototype.signIn=function(t){return e=this,n=void 0,i=function(){var e,n,o,i,s,a,c;return function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,(function(u){switch(u.label){case 0:if(!B(t))throw new Error(JSON.stringify({code:M.INVALID_PARAMS,msg:"ticket must be a string"}));return e=this._cache.keys.refreshTokenKey,i=(o=this._request).send,s=["auth.signInWithTicket"],c={ticket:t},[4,this._cache.getStoreAsync(e)];case 1:return[4,i.apply(o,s.concat([(c.refresh_token=u.sent()||"",c)]))];case 2:return(n=u.sent()).refresh_token?[4,this.setRefreshToken(n.refresh_token)]:[3,7];case 3:return u.sent(),[4,this._request.refreshAccessToken()];case 4:return u.sent(),Ct.fire(Dt.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:r.CUSTOM,persistence:this._config.persistence}),Ct.fire(Dt.LOGIN_STATE_CHANGED),[4,this.refreshUserInfo()];case 5:return u.sent(),[4,(a=new Ut({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 6:return u.sent(),[2,a];case 7:throw new Error(JSON.stringify({code:M.OPERATION_FAIL,msg:"custom signIn failed"}))}}))},new((o=void 0)||(o=Promise))((function(t,r){function s(t){try{c(i.next(t))}catch(t){r(t)}}function a(t){try{c(i.throw(t))}catch(t){r(t)}}function c(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(s,a)}c((i=i.apply(e,n||[])).next())}));var e,n,o,i},function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);i>3&&s&&Object.defineProperty(e,n,s)}([F({title:"自定义登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了自定义登录"," 2 - 调用 auth().customAuthProvider().signIn() 的语法或参数是否正确"," 3 - ticket 是否归属于当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(q)]}),D("design:type",Function),D("design:paramtypes",[String]),D("design:returntype",Promise)],e.prototype,"signIn",null),e}(a),$=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)}}(),H=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},G=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},K=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},V=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},J=o.utils.throwError,Y=o.utils.isString,z=o.constants.ERRORS,X=o.constants.COMMUNITY_SITE_URL,Z=o.helpers.catchErrorsDecorator,Q=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return $(e,t),e.prototype.signIn=function(t,e){return K(this,void 0,void 0,(function(){var n,o,i,s,a;return V(this,(function(c){switch(c.label){case 0:return Y(t)||J(z.INVALID_PARAMS,"email must be a string"),n=this._cache.keys.refreshTokenKey,[4,this._request.send("auth.signIn",{loginType:"EMAIL",email:t,password:e,refresh_token:this._cache.getStore(n)||""})];case 1:return o=c.sent(),i=o.refresh_token,s=o.access_token,a=o.access_token_expire,i?[4,this.setRefreshToken(i)]:[3,8];case 2:return c.sent(),s&&a?[4,this.setAccessToken(s,a)]:[3,4];case 3:return c.sent(),[3,6];case 4:return[4,this._request.refreshAccessToken()];case 5:c.sent(),c.label=6;case 6:return[4,this.refreshUserInfo()];case 7:return c.sent(),Ct.fire(Dt.LOGIN_STATE_CHANGED),Ct.fire(Dt.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:r.EMAIL,persistence:this._config.persistence}),[2,new Ut({envId:this._config.env,cache:this._cache,request:this._request})];case 8:return o.code?J(z.OPERATION_FAIL,"Email login fail[".concat(o.code,"] ").concat(o.message)):J(z.OPERATION_FAIL,"Email login fail"),[2]}}))}))},e.prototype.signUp=function(t,e){return K(this,void 0,void 0,(function(){return V(this,(function(n){return[2,this._request.send("auth.signUpWithEmailAndPassword",{email:t,password:e})]}))}))},e.prototype.resetPassword=function(t){return K(this,void 0,void 0,(function(){return V(this,(function(e){return[2,this._request.send("auth.sendPasswordResetEmail",{email:t})]}))}))},e.prototype.resetPasswordWithToken=function(t,e){return K(this,void 0,void 0,(function(){return V(this,(function(n){return[2,this._request.send("auth.resetPasswordWithToken",{token:t,newPassword:e})]}))}))},e.prototype.activate=function(t){return K(this,void 0,void 0,(function(){return V(this,(function(e){return[2,this._request.send("auth.activateEndUserMail",{token:t})]}))}))},H([Z({title:"邮箱密码登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().emailAuthProvider() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录"," 3 - 邮箱地址与密码是否匹配","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(X)]}),G("design:type",Function),G("design:paramtypes",[String,String]),G("design:returntype",Promise)],e.prototype,"signIn",null),H([Z({title:"邮箱注册失败",messages:["请确认以下各项:"," 1 - 调用 auth().signUpWithEmailAndPassword() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录"," 3 - 此邮箱地址是否已经被其他用户占用","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(X)]}),G("design:type",Function),G("design:paramtypes",[String,String]),G("design:returntype",Promise)],e.prototype,"signUp",null),H([Z({title:"重置密码失败",messages:["请确认以下各项:"," 1 - 调用 auth().sendPasswordResetEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录"," 3 - 此邮箱地址是否已经与当前用户绑定"," 4 - 此邮箱地址是否已经被其他用户占用","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(X)]}),G("design:type",Function),G("design:paramtypes",[String]),G("design:returntype",Promise)],e.prototype,"resetPassword",null),H([Z({title:"重置密码失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(X)]}),G("design:type",Function),G("design:paramtypes",[String,String]),G("design:returntype",Promise)],e.prototype,"resetPasswordWithToken",null),H([Z({title:"邮箱激活失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(X)]}),G("design:type",Function),G("design:paramtypes",[String]),G("design:returntype",Promise)],e.prototype,"activate",null),e}(a),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)}}(),et=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},nt=o.utils.printWarn,rt=o.constants.ERRORS,ot=o.constants.COMMUNITY_SITE_URL,it=o.helpers.catchErrorsDecorator,st=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return tt(e,t),e.prototype.signIn=function(t,e){return n=this,o=void 0,s=function(){var n,o,i,s,a,c,u,f,l;return function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,(function(h){switch(h.label){case 0:if("string"!=typeof t)throw new Error(JSON.stringify({code:rt.INVALID_PARAMS,msg:"username must be a string"}));return"string"!=typeof e&&(e="",nt(rt.INVALID_PARAMS,"password is empty")),n=this._cache.keys.refreshTokenKey,s=(i=this._request).send,a=["auth.signIn"],l={loginType:r.USERNAME,username:t,password:e},[4,this._cache.getStoreAsync(n)];case 1:return[4,s.apply(i,a.concat([(l.refresh_token=h.sent()||"",l)]))];case 2:return o=h.sent(),c=o.refresh_token,u=o.access_token_expire,f=o.access_token,c?[4,this.setRefreshToken(c)]:[3,9];case 3:return h.sent(),f&&u?[4,this.setAccessToken(f,u)]:[3,5];case 4:return h.sent(),[3,7];case 5:return[4,this._request.refreshAccessToken()];case 6:h.sent(),h.label=7;case 7:return[4,this.refreshUserInfo()];case 8:return h.sent(),Ct.fire(Dt.LOGIN_STATE_CHANGED),Ct.fire(Dt.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:r.USERNAME,persistence:this._config.persistence}),[2,new Ut({envId:this._config.env,cache:this._cache,request:this._request})];case 9:throw o.code?new Error(JSON.stringify({code:rt.OPERATION_FAIL,msg:"login by username failed:[".concat(o.code,"] ").concat(o.message)})):new Error(JSON.stringify({code:rt.OPERATION_FAIL,msg:"login by username failed"}))}}))},new((i=void 0)||(i=Promise))((function(t,e){function r(t){try{c(s.next(t))}catch(t){e(t)}}function a(t){try{c(s.throw(t))}catch(t){e(t)}}function c(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i((function(t){t(n)}))).then(r,a)}c((s=s.apply(n,o||[])).next())}));var n,o,i,s},function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);i>3&&s&&Object.defineProperty(e,n,s)}([it({title:"用户名密码登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().signInWithUsernameAndPassword() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录"," 3 - 用户名密码是否匹配","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(ot)]}),et("design:type",Function),et("design:paramtypes",[String,String]),et("design:returntype",Promise)],e.prototype,"signIn",null),e}(a),at=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)}}(),ct=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},ut=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},ft=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},lt=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},ht=o.utils.throwError,pt=o.utils.isString,dt=o.utils.transformPhone,yt=o.constants.ERRORS,gt=o.constants.COMMUNITY_SITE_URL,vt=o.helpers.catchErrorsDecorator,mt="FORCERESETPWD",_t=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return at(e,t),e.prototype.signIn=function(t){return ft(this,void 0,void 0,(function(){var e,n,o,i,s,a,c,u,f;return lt(this,(function(l){switch(l.label){case 0:return e=t.phoneNumber,n=t.phoneCode,o=t.password,i=t.signMethod,pt(e)||ht(yt.INVALID_PARAMS,"phoneNumber must be a string"),pt(n)||pt(o)||ht(yt.INVALID_PARAMS,"phoneCode or password must be a string"),i||(i="SIGNIN"),s=this._cache.keys.refreshTokenKey,[4,this._request.send("auth.signIn",{loginType:r.PHONE,phoneNumber:dt(e),phoneCode:n,password:o,refresh_token:this._cache.getStore(s)||"",signMethod:i})];case 1:return a=l.sent(),c=a.refresh_token,u=a.access_token,f=a.access_token_expire,c?[4,this.setRefreshToken(c)]:[3,8];case 2:return l.sent(),u&&f?[4,this.setAccessToken(u,f)]:[3,4];case 3:return l.sent(),[3,6];case 4:return[4,this._request.refreshAccessToken()];case 5:l.sent(),l.label=6;case 6:return[4,this.refreshUserInfo()];case 7:return l.sent(),Ct.fire(Dt.LOGIN_STATE_CHANGED),Ct.fire(Dt.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:r.PHONE,persistence:this._config.persistence}),[2,new Ut({envId:this._config.env,cache:this._cache,request:this._request})];case 8:return a.code?ht(yt.OPERATION_FAIL,"Phone login fail[".concat(a.code,"] ").concat(a.message)):ht(yt.OPERATION_FAIL,"Phone login fail"),[2]}}))}))},e.prototype.signUp=function(t,e,n){return ft(this,void 0,void 0,(function(){return lt(this,(function(r){return[2,this.signIn({phoneNumber:t,phoneCode:e,password:n,signMethod:"SIGNUP"})]}))}))},e.prototype.forceResetPwd=function(t,e,n){return ft(this,void 0,void 0,(function(){return lt(this,(function(r){return[2,this.signIn({phoneNumber:t,phoneCode:e,password:n,signMethod:mt})]}))}))},ct([vt({title:"手机号登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().SmsAuthProvider() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录"," 3 - 短信验证码/密码是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(gt)]}),ut("design:type",Function),ut("design:paramtypes",[Object]),ut("design:returntype",Promise)],e.prototype,"signIn",null),ct([vt({title:"手机短信注册失败",messages:["请确认以下各项:"," 1 - 调用 auth().signUpWithPhoneCode() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(gt)]}),ut("design:type",Function),ut("design:paramtypes",[String,String,String]),ut("design:returntype",Promise)],e.prototype,"signUp",null),ct([vt({title:"手机密码重置失败",messages:["请确认以下各项:"," 1 - 调用 auth().forceResetPwd() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(gt)]}),ut("design:type",Function),ut("design:paramtypes",[String,String,String]),ut("design:returntype",Promise)],e.prototype,"forceResetPwd",null),e}(a),wt=function(){return wt=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},wt.apply(this,arguments)},bt=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},Et=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},St=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},It=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},Ot=o.events.CloudbaseEventEmitter,At=o.adapters.RUNTIME,Tt=o.utils.printWarn,Nt=o.utils.throwError,Rt=o.utils.transformPhone,Pt=o.constants.ERRORS,xt=o.constants.COMMUNITY_SITE_URL,Lt=o.helpers.catchErrorsDecorator,Ct=new Ot,kt=function(){function t(t){var e=t.cache,n=t.request;this._cache=e,this._request=n,this._setUserInfo()}return t.prototype.checkLocalInfo=function(){return St(this,void 0,void 0,(function(){return It(this,(function(t){return this.uid=this._getLocalUserInfo("uid"),this.loginType=this._getLocalUserInfo("loginType"),this.openid=this._getLocalUserInfo("wxOpenId"),this.wxOpenId=this._getLocalUserInfo("wxOpenId"),this.wxPublicId=this._getLocalUserInfo("wxPublicId"),this.unionId=this._getLocalUserInfo("wxUnionId"),this.qqMiniOpenId=this._getLocalUserInfo("qqMiniOpenId"),this.customUserId=this._getLocalUserInfo("customUserId"),this.nickName=this._getLocalUserInfo("nickName"),this.gender=this._getLocalUserInfo("gender"),this.avatarUrl=this._getLocalUserInfo("avatarUrl"),this.email=this._getLocalUserInfo("email"),this.hasPassword=Boolean(this._getLocalUserInfo("hasPassword")),this.phone=this._getLocalUserInfo("phone"),this.username=this._getLocalUserInfo("username"),this.location={country:this._getLocalUserInfo("country"),province:this._getLocalUserInfo("province"),city:this._getLocalUserInfo("city")},[2]}))}))},t.prototype.checkLocalInfoAsync=function(){return St(this,void 0,void 0,(function(){var t,e,n,r,o,i,s,a,c,u,f,l,h,p,d,y,g,v;return It(this,(function(m){switch(m.label){case 0:return t=this,[4,this._getLocalUserInfoAsync("uid")];case 1:return t.uid=m.sent(),e=this,[4,this._getLocalUserInfoAsync("loginType")];case 2:return e.loginType=m.sent(),n=this,[4,this._getLocalUserInfoAsync("wxOpenId")];case 3:return n.openid=m.sent(),r=this,[4,this._getLocalUserInfoAsync("wxOpenId")];case 4:return r.wxOpenId=m.sent(),o=this,[4,this._getLocalUserInfoAsync("wxPublicId")];case 5:return o.wxPublicId=m.sent(),i=this,[4,this._getLocalUserInfoAsync("wxUnionId")];case 6:return i.unionId=m.sent(),s=this,[4,this._getLocalUserInfoAsync("qqMiniOpenId")];case 7:return s.qqMiniOpenId=m.sent(),a=this,[4,this._getLocalUserInfoAsync("customUserId")];case 8:return a.customUserId=m.sent(),c=this,[4,this._getLocalUserInfoAsync("nickName")];case 9:return c.nickName=m.sent(),u=this,[4,this._getLocalUserInfoAsync("gender")];case 10:return u.gender=m.sent(),f=this,[4,this._getLocalUserInfoAsync("avatarUrl")];case 11:return f.avatarUrl=m.sent(),l=this,[4,this._getLocalUserInfoAsync("email")];case 12:return l.email=m.sent(),h=this,p=Boolean,[4,this._getLocalUserInfoAsync("hasPassword")];case 13:return h.hasPassword=p.apply(void 0,[m.sent()]),d=this,[4,this._getLocalUserInfoAsync("phone")];case 14:return d.phone=m.sent(),y=this,[4,this._getLocalUserInfoAsync("username")];case 15:return y.username=m.sent(),g=this,v={},[4,this._getLocalUserInfoAsync("country")];case 16:return v.country=m.sent(),[4,this._getLocalUserInfoAsync("province")];case 17:return v.province=m.sent(),[4,this._getLocalUserInfoAsync("city")];case 18:return g.location=(v.city=m.sent(),v),[2]}}))}))},t.prototype.linkWithTicket=function(t){if("string"!=typeof t)throw new Error("ticket must be string");return this._request.send("auth.linkWithTicket",{ticket:t})},t.prototype.linkWithRedirect=function(t){t.signInWithRedirect()},t.prototype.getLinkedUidList=function(){return St(this,void 0,void 0,(function(){var t,e,n,r,o,i;return It(this,(function(s){switch(s.label){case 0:return[4,this._request.send("auth.getLinkedUidList",{})];case 1:for(t=s.sent().data,e=!1,n=t.users,r=0,o=n;r<o.length;r++)if((i=o[r]).wxOpenId&&i.wxPublicId){e=!0;break}return[2,{users:n,hasPrimaryUid:e}]}}))}))},t.prototype.setPrimaryUid=function(t){return this._request.send("auth.setPrimaryUid",{uid:t})},t.prototype.unlink=function(t){return this._request.send("auth.unlink",{platform:t})},t.prototype.update=function(t){return St(this,void 0,void 0,(function(){var e,n,r,o,i,s,a;return It(this,(function(c){switch(c.label){case 0:return e=t.nickName,n=t.gender,r=t.avatarUrl,o=t.province,i=t.country,s=t.city,[4,this._request.send("auth.updateUserInfo",{nickName:e,gender:n,avatarUrl:r,province:o,country:i,city:s})];case 1:return a=c.sent().data,this._setLocalUserInfo(a),[2]}}))}))},t.prototype.updatePassword=function(t,e){return this._request.send("auth.updatePassword",{oldPassword:e,newPassword:t})},t.prototype.updateEmail=function(t,e){return this._request.send("auth.updateEmail",{newEmail:t,password:e})},t.prototype.updateUsername=function(t){return"string"!=typeof t&&Nt(Pt.INVALID_PARAMS,"username must be a string"),this._request.send("auth.updateUsername",{username:t})},t.prototype.refresh=function(){return St(this,void 0,void 0,(function(){var t;return It(this,(function(e){switch(e.label){case 0:return[4,this._request.send("auth.getUserInfo",{})];case 1:return t=e.sent().data,this._setLocalUserInfo(t),[2,t]}}))}))},t.prototype.linkWithPhoneNumber=function(t,e){return St(this,void 0,void 0,(function(){return It(this,(function(n){return[2,this._request.send("auth.linkOrUpdatePhoneNumber",{phoneNumber:Rt(t),phoneCode:e})]}))}))},t.prototype.updatePhoneNumber=function(t,e){return St(this,void 0,void 0,(function(){return It(this,(function(n){return[2,this._request.send("auth.linkOrUpdatePhoneNumber",{phoneNumber:Rt(t),phoneCode:e})]}))}))},t.prototype._getLocalUserInfo=function(t){var e=this._cache.keys.userInfoKey;return this._cache.getStore(e)[t]},t.prototype._getLocalUserInfoAsync=function(t){return St(this,void 0,void 0,(function(){var e;return It(this,(function(n){switch(n.label){case 0:return e=this._cache.keys.userInfoKey,[4,this._cache.getStoreAsync(e)];case 1:return[2,n.sent()[t]]}}))}))},t.prototype._setUserInfo=function(){var t=this,e=this._cache.keys.userInfoKey,n=this._cache.getStore(e);["uid","loginType","openid","wxOpenId","wxPublicId","unionId","qqMiniOpenId","email","hasPassword","customUserId","nickName","gender","avatarUrl","phone","username"].forEach((function(e){t[e]=n[e]})),this.location={country:n.country,province:n.province,city:n.city}},t.prototype._setLocalUserInfo=function(t){var e=this._cache.keys.userInfoKey;this._cache.setStore(e,t),this._setUserInfo()},bt([Lt({title:"绑定自定义登录失败",messages:["请确认以下各项:"," 1 - 调用 User.linkWithTicket() 的语法或参数是否正确"," 2 - 此账户是否已经绑定自定义登录"," 3 - ticket 参数是否归属当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[String]),Et("design:returntype",Promise)],t.prototype,"linkWithTicket",null),bt([Lt({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 User.linkWithRedirect() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方"," 3 - 此第三方是否已经授权","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[Object]),Et("design:returntype",void 0)],t.prototype,"linkWithRedirect",null),bt([Lt({title:"获取账户列表失败",messages:["请确认以下各项:"," 1 - 调用 User.getLinkedUidList() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[]),Et("design:returntype",Promise)],t.prototype,"getLinkedUidList",null),bt([Lt({title:"设置微信主账号失败",messages:["请确认以下各项:"," 1 - 调用 User.setPrimaryUid() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[String]),Et("design:returntype",void 0)],t.prototype,"setPrimaryUid",null),bt([Lt({title:"接触绑定失败",messages:["请确认以下各项:"," 1 - 调用 User.unlink() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[String]),Et("design:returntype",void 0)],t.prototype,"unlink",null),bt([Lt({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[Object]),Et("design:returntype",Promise)],t.prototype,"update",null),bt([Lt({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[String,String]),Et("design:returntype",void 0)],t.prototype,"updatePassword",null),bt([Lt({title:"更新邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 User.updateEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[String,String]),Et("design:returntype",void 0)],t.prototype,"updateEmail",null),bt([Lt({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[String]),Et("design:returntype",void 0)],t.prototype,"updateUsername",null),bt([Lt({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[]),Et("design:returntype",Promise)],t.prototype,"refresh",null),bt([Lt({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().linkWithPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[String,String]),Et("design:returntype",Promise)],t.prototype,"linkWithPhoneNumber",null),bt([Lt({title:"更新手机号失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[String,String]),Et("design:returntype",Promise)],t.prototype,"updatePhoneNumber",null),t}(),Ut=function(){function t(t){var e=t.envId,n=t.cache,r=t.request;e||Nt(Pt.INVALID_PARAMS,"envId is not defined"),this._cache=n,this.user=new kt({cache:n,request:r})}return t.prototype.checkLocalState=function(){return St(this,void 0,void 0,(function(){var t,e,n,r,o,i,s;return It(this,(function(a){return t=this._cache.keys,e=t.refreshTokenKey,n=t.accessTokenKey,r=t.accessTokenExpireKey,o=this._cache.getStore(e),i=this._cache.getStore(n),s=this._cache.getStore(r),this.credential={refreshToken:o,accessToken:i,accessTokenExpire:s},this._loginType=this._cache.getStore(this._cache.keys.loginTypeKey),this.user.checkLocalInfo(),[2]}))}))},t.prototype.checkLocalStateAsync=function(){return St(this,void 0,void 0,(function(){var t,e,n,r,o,i,s,a;return It(this,(function(c){switch(c.label){case 0:return t=this._cache.keys,e=t.refreshTokenKey,n=t.accessTokenKey,r=t.accessTokenExpireKey,[4,this._cache.getStoreAsync(e)];case 1:return o=c.sent(),[4,this._cache.getStoreAsync(n)];case 2:return i=c.sent(),[4,this._cache.getStoreAsync(r)];case 3:return s=c.sent(),this.credential={refreshToken:o,accessToken:i,accessTokenExpire:s},a=this,[4,this._cache.getStoreAsync(this._cache.keys.loginTypeKey)];case 4:return a._loginType=c.sent(),[4,this.user.checkLocalInfoAsync()];case 5:return c.sent(),[2]}}))}))},Object.defineProperty(t.prototype,"isAnonymousAuth",{get:function(){return this.loginType===r.ANONYMOUS},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isCustomAuth",{get:function(){return this.loginType===r.CUSTOM},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isWeixinAuth",{get:function(){return this.loginType===r.WECHAT||this.loginType===r.WECHAT_OPEN||this.loginType===r.WECHAT_PUBLIC},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isUsernameAuth",{get:function(){return this.loginType===r.USERNAME},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"loginType",{get:function(){return this._loginType},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isPhoneAuth",{get:function(){return this.loginType===r.PHONE},enumerable:!1,configurable:!0}),t}(),jt=function(){function t(t){this._config=t,this._cache=t.cache,this._request=t.request,this._runtime=t.runtime||At.WEB,Ct.on(Dt.LOGIN_TYPE_CHANGED,this._onLoginTypeChanged.bind(this))}return Object.defineProperty(t.prototype,"currentUser",{get:function(){if("async"!==this._cache.mode){var t=this.hasLoginState();return t&&t.user||null}Tt(Pt.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrentUser insteed")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"loginType",{get:function(){return this._cache.getStore(this._cache.keys.loginTypeKey)},enumerable:!1,configurable:!0}),t.prototype.getCurrenUser=function(){return St(this,void 0,void 0,(function(){return It(this,(function(t){switch(t.label){case 0:return[4,this.getCurrentUser()];case 1:return[2,t.sent()]}}))}))},t.prototype.getCurrentUser=function(){return St(this,void 0,void 0,(function(){var t;return It(this,(function(e){switch(e.label){case 0:return[4,this.getLoginState()];case 1:return(t=e.sent())?[4,t.user.checkLocalInfoAsync()]:[3,3];case 2:return e.sent(),[2,t.user||null];case 3:return[2,null]}}))}))},t.prototype.getLoginType=function(){return St(this,void 0,void 0,(function(){return It(this,(function(t){switch(t.label){case 0:return[4,this._cache.getStoreAsync(this._cache.keys.loginTypeKey)];case 1:return[2,t.sent()]}}))}))},t.prototype.getAccessToken=function(){return St(this,void 0,void 0,(function(){var t;return It(this,(function(e){switch(e.label){case 0:return t={},[4,this._request.getAccessToken()];case 1:return[2,(t.accessToken=e.sent().accessToken,t.env=this._config.env,t)]}}))}))},t.prototype.weixinAuthProvider=function(t){var e=t.appid,n=t.scope,r=t.state;return this._weixinAuthProvider||(this._weixinAuthProvider=new S(wt(wt({},this._config),{cache:this._cache,request:this._request,runtime:this._runtime}),e,n,r)),this._weixinAuthProvider},t.prototype.anonymousAuthProvider=function(){return this._anonymousAuthProvider||(this._anonymousAuthProvider=new U(wt(wt({},this._config),{cache:this._cache,request:this._request}))),this._anonymousAuthProvider},t.prototype.customAuthProvider=function(){return this._customAuthProvider||(this._customAuthProvider=new W(wt(wt({},this._config),{cache:this._cache,request:this._request}))),this._customAuthProvider},t.prototype.emailAuthProvider=function(){return this._emailAuthProvider||(this._emailAuthProvider=new Q(wt(wt({},this._config),{cache:this._cache,request:this._request}))),this._emailAuthProvider},t.prototype.usernameAuthProvider=function(){return this._usernameAuthProvider||(this._usernameAuthProvider=new st(wt(wt({},this._config),{cache:this._cache,request:this._request}))),this._usernameAuthProvider},t.prototype.phoneAuthProvider=function(){return this._phoneAuthProvider||(this._phoneAuthProvider=new _t(wt(wt({},this._config),{cache:this._cache,request:this._request}))),this._phoneAuthProvider},t.prototype.signInWithUsernameAndPassword=function(t,e){return St(this,void 0,void 0,(function(){return It(this,(function(n){return[2,this.usernameAuthProvider().signIn(t,e)]}))}))},t.prototype.isUsernameRegistered=function(t){return St(this,void 0,void 0,(function(){var e;return It(this,(function(n){switch(n.label){case 0:return"string"!=typeof t&&Nt(Pt.INVALID_PARAMS,"username must be a string"),[4,this._request.send("auth.isUsernameRegistered",{username:t})];case 1:return[2,null==(e=n.sent().data)?void 0:e.isRegistered]}}))}))},t.prototype.signInWithEmailAndPassword=function(t,e){return St(this,void 0,void 0,(function(){return It(this,(function(n){return[2,this.emailAuthProvider().signIn(t,e)]}))}))},t.prototype.signUpWithEmailAndPassword=function(t,e){return St(this,void 0,void 0,(function(){return It(this,(function(n){return[2,this.emailAuthProvider().signUp(t,e)]}))}))},t.prototype.sendPasswordResetEmail=function(t){return St(this,void 0,void 0,(function(){return It(this,(function(e){return[2,this.emailAuthProvider().resetPassword(t)]}))}))},t.prototype.signOut=function(){return St(this,void 0,void 0,(function(){var t,e,n,o,i,s,a;return It(this,(function(c){switch(c.label){case 0:return t=this._cache.keys,e=t.refreshTokenKey,n=t.accessTokenKey,o=t.accessTokenExpireKey,i="auth.logout",[4,this._cache.getStoreAsync(e)];case 1:return(s=c.sent())?[4,this._request.send(i,{refresh_token:s})]:[2];case 2:return a=c.sent(),this._cache.removeStoreAsync(e),this._cache.removeStoreAsync(n),this._cache.removeStoreAsync(o),Ct.fire(Dt.LOGIN_STATE_CHANGED),Ct.fire(Dt.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:r.NULL,persistence:this._config.persistence}),[2,a]}}))}))},t.prototype.onLoginStateChanged=function(t){return St(this,void 0,void 0,(function(){var e,n=this;return It(this,(function(r){switch(r.label){case 0:return Ct.on(Dt.LOGIN_STATE_CHANGED,(function(){return St(n,void 0,void 0,(function(){var e;return It(this,(function(n){switch(n.label){case 0:return[4,this.getLoginState()];case 1:return e=n.sent(),t.call(this,e),[2]}}))}))})),[4,this.getLoginState()];case 1:return e=r.sent(),t.call(this,e),[2]}}))}))},t.prototype.onLoginStateExpired=function(t){Ct.on(Dt.LOGIN_STATE_EXPIRED,t.bind(this))},t.prototype.onAccessTokenRefreshed=function(t){Ct.on(Dt.ACCESS_TOKEN_REFRESHD,t.bind(this))},t.prototype.onAnonymousConverted=function(t){Ct.on(Dt.ANONYMOUS_CONVERTED,t.bind(this))},t.prototype.onLoginTypeChanged=function(t){var e=this;Ct.on(Dt.LOGIN_TYPE_CHANGED,(function(){return St(e,void 0,void 0,(function(){var e;return It(this,(function(n){switch(n.label){case 0:return[4,this.getLoginState()];case 1:return e=n.sent(),t.call(this,e),[2]}}))}))}))},t.prototype.hasLoginState=function(){if("async"!==this._cache.mode){var t=this._cache.keys.refreshTokenKey;if(this._cache.getStore(t)){var e=new Ut({envId:this._config.env,cache:this._cache,request:this._request});return e.checkLocalState(),e}return null}Tt(Pt.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState insteed")},t.prototype.getLoginState=function(){return St(this,void 0,void 0,(function(){var t,e;return It(this,(function(n){switch(n.label){case 0:return t=this._cache.keys.refreshTokenKey,[4,this._cache.getStoreAsync(t)];case 1:return n.sent()?[4,(e=new Ut({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()]:[3,3];case 2:return n.sent(),[2,e];case 3:return[2,null]}}))}))},t.prototype.shouldRefreshAccessToken=function(t){this._request._shouldRefreshAccessTokenHook=t.bind(this)},t.prototype.getUserInfo=function(){return St(this,void 0,void 0,(function(){var t;return It(this,(function(e){switch(e.label){case 0:return[4,this._request.send("auth.getUserInfo",{})];case 1:return(t=e.sent()).code?[2,t]:[2,wt(wt({},t.data),{requestId:t.seqId})]}}))}))},t.prototype.getAuthHeader=function(){var t=this._cache.keys,e=t.refreshTokenKey,n=t.accessTokenKey,r=this._cache.getStore(e),o=this._cache.getStore(n);return{"x-cloudbase-credentials":"".concat(o,"/@@/").concat(r)}},t.prototype.getAuthHeaderAsync=function(){return St(this,void 0,void 0,(function(){var t,e,n,r,o;return It(this,(function(i){switch(i.label){case 0:return[4,this._request.refreshAccessToken()];case 1:return i.sent(),t=this._cache.keys,e=t.refreshTokenKey,n=t.accessTokenKey,[4,this._cache.getStoreAsync(e)];case 2:return r=i.sent(),[4,this._cache.getStoreAsync(n)];case 3:return o=i.sent(),[2,{"x-cloudbase-credentials":"".concat(o,"/@@/").concat(r)}]}}))}))},t.prototype.sendPhoneCode=function(t){return St(this,void 0,void 0,(function(){return It(this,(function(e){switch(e.label){case 0:return[4,this._request.send("auth.sendPhoneCode",{phoneNumber:Rt(t)})];case 1:return[2,"Ok"===e.sent().data.SendStatus]}}))}))},t.prototype.signUpWithPhoneCode=function(t,e,n){return St(this,void 0,void 0,(function(){return It(this,(function(r){return[2,this.phoneAuthProvider().signUp(t,e,n)]}))}))},t.prototype.signInWithPhoneCodeOrPassword=function(t){return St(this,void 0,void 0,(function(){return It(this,(function(e){return[2,this.phoneAuthProvider().signIn(t)]}))}))},t.prototype.forceResetPwdByPhoneCode=function(t){return St(this,void 0,void 0,(function(){return It(this,(function(e){return[2,this.phoneAuthProvider().signIn(wt(wt({},t),{signMethod:mt}))]}))}))},t.prototype._onLoginTypeChanged=function(t){return St(this,void 0,void 0,(function(){var e,n,r;return It(this,(function(o){switch(o.label){case 0:return e=t.data,n=e.loginType,r=e.persistence,e.env!==this._config.env?[2]:[4,this._cache.updatePersistenceAsync(r)];case 1:return o.sent(),[4,this._cache.setStoreAsync(this._cache.keys.loginTypeKey,n)];case 2:return o.sent(),[2]}}))}))},bt([Lt({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrenUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[]),Et("design:returntype",Promise)],t.prototype,"getCurrenUser",null),bt([Lt({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrentUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[]),Et("design:returntype",Promise)],t.prototype,"getCurrentUser",null),bt([Lt({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[String]),Et("design:returntype",Promise)],t.prototype,"isUsernameRegistered",null),bt([Lt({title:"用户登出失败",messages:["请确认以下各项:"," 1 - 调用 auth().signOut() 的语法或参数是否正确"," 2 - 当前用户是否为匿名登录(匿名登录不支持signOut)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[]),Et("design:returntype",Promise)],t.prototype,"signOut",null),bt([Lt({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[]),Et("design:returntype",Promise)],t.prototype,"getLoginState",null),bt([Lt({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[]),Et("design:returntype",Promise)],t.prototype,"getUserInfo",null),bt([Lt({title:"发送短信验证码失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[String]),Et("design:returntype",Promise)],t.prototype,"sendPhoneCode",null),t}(),Dt={LOGIN_STATE_CHANGED:"loginStateChanged",LOGIN_STATE_EXPIRED:"loginStateExpire",LOGIN_TYPE_CHANGED:"loginTypeChanged",ANONYMOUS_CONVERTED:"anonymousConverted",ACCESS_TOKEN_REFRESHD:"refreshAccessToken"},Mt={name:"auth",namespace:"auth",injectEvents:{bus:Ct,events:[Dt.LOGIN_TYPE_CHANGED,Dt.LOGIN_STATE_EXPIRED,Dt.LOGIN_STATE_CHANGED,Dt.ACCESS_TOKEN_REFRESHD,Dt.ANONYMOUS_CONVERTED]},entity:function(t){if(void 0===t&&(t={region:"",persistence:"local"}),this.authInstance)return Tt(Pt.INVALID_OPERATION,"every cloudbase instance should has only one auth object"),this.authInstance;var e=this.platform,n=e.adapter,r=e.runtime,o=t.persistence||n.primaryStorage;o&&o!==this.config.persistence&&this.updateConfig({persistence:o});var i=this.config,s=i.env,a=i.persistence,c=i.debug;return this.authInstance=new jt({env:s,region:t.region,persistence:a,debug:c,cache:this.cache,request:this.request,runtime:r}),this.authInstance}};try{cloudbase.registerComponent(Mt)}catch(t){}function qt(t){try{t.registerComponent(Mt)}catch(t){console.warn(t)}}function Bt(t,e){jt.prototype[t]=function(n){var r="_".concat(t);return this[r]||(this[r]=new e(wt(wt({},n),this._config))),this[r]}}},622:function(t,e,n){"use strict";n.r(e),n.d(e,{registerDatabase:function(){return Mn}});var r,o,i={};n.r(i),n.d(i,{LineString:function(){return H},MultiLineString:function(){return Y},MultiPoint:function(){return V},MultiPolygon:function(){return X},Point:function(){return ot},Polygon:function(){return K}}),function(t){t.DocIDError="文档ID不合法",t.CollNameError="集合名称不合法",t.OpStrError="操作符不合法",t.DirectionError="排序字符不合法",t.IntergerError="must be integer",t.QueryParamTypeError="查询参数必须为对象",t.QueryParamValueError="查询参数对象值不能均为undefined"}(o||(o={}));var s,a,c="Object",u="GeoPoint",f="GeoLineString",l="GeoPolygon",h="GeoMultiPoint",p="GeoMultiLineString",d="GeoMultiPolygon",y="Date",g="ServerDate",v=["desc","asc"],m=["<","<=","==",">=",">"];!function(t){t.lt="<",t.gt=">",t.lte="<=",t.gte=">=",t.eq="=="}(s||(s={})),(r={})[s.eq]="$eq",r[s.lt]="$lt",r[s.lte]="$lte",r[s.gt]="$gt",r[s.gte]="$gte",function(t){t.WHERE="WHERE",t.DOC="DOC"}(a||(a={}));var _,w=(_=function(t,e){return _=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},_(t,e)},function(t,e){function n(){this.constructor=t}_(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),b=[],E={},S=function(t){function e(e,n){if(n!==E)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=b.length;n<r;n++)if(b[n].target===t)return b[n].instance;var o=new e(t,E);return b.push({target:t,instance:o}),o},e}((function(t){Object.defineProperties(this,{target:{enumerable:!1,writable:!1,configurable:!1,value:t}})})),I=S,O=I.for("UNSET_FIELD_NAME"),A=I.for("UPDATE_COMMAND"),T=I.for("QUERY_COMMAND"),N=I.for("LOGIC_COMMAND"),R=I.for("GEO_POINT"),P=I.for("SYMBOL_GEO_LINE_STRING"),x=I.for("SYMBOL_GEO_POLYGON"),L=I.for("SYMBOL_GEO_MULTI_POINT"),C=I.for("SYMBOL_GEO_MULTI_LINE_STRING"),k=I.for("SYMBOL_GEO_MULTI_POLYGON"),U=I.for("SERVER_DATE"),j=I.for("REGEXP"),D=function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},M=function(t){return"object"===D(t)},q=function(t){return"number"===D(t)},B=function(t){return Array.isArray(t)},F=function(t){return"date"===D(t)},W=function(t){return"regexp"===D(t)},$=function(t){return t&&t._internalType instanceof S},H=function(){function t(t){if(!B(t))throw new TypeError('"points" must be of type Point[]. Received type '+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 '+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||!B(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(!q(i[0])||!q(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 P},enumerable:!0,configurable:!0}),t}(),G=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.")},K=function(){function t(t){if(!B(t))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof t);if(0===t.length)throw new Error("Polygon must contain 1 linestring at least");t.forEach((function(t){if(!(t instanceof H))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof t+"[]");if(!H.isClosed(t))throw new Error("LineString "+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||!B(t.coordinates))return!1;try{for(var i=G(t.coordinates),s=i.next();!s.done;s=i.next()){var a=s.value;if(!this.isCloseLineString(a))return!1;try{for(var c=(r=void 0,G(a)),u=c.next();!u.done;u=c.next()){var f=u.value;if(!q(f[0])||!q(f[1]))return!1}}catch(t){r={error:t}}finally{try{u&&!u.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{s&&!s.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 k},enumerable:!0,configurable:!0}),t}(),V=function(){function t(t){if(!B(t))throw new TypeError('"points" must be of type Point[]. Received type '+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 '+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||!B(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(!q(i[0])||!q(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 L},enumerable:!0,configurable:!0}),t}(),J=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.")},Y=function(){function t(t){if(!B(t))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof t);if(0===t.length)throw new Error("Polygon must contain 1 linestring at least");t.forEach((function(t){if(!(t instanceof H))throw new TypeError('"lines" must be of type LineString[]. Received type '+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||!B(t.coordinates))return!1;try{for(var i=J(t.coordinates),s=i.next();!s.done;s=i.next()){var a=s.value;try{for(var c=(r=void 0,J(a)),u=c.next();!u.done;u=c.next()){var f=u.value;if(!q(f[0])||!q(f[1]))return!1}}catch(t){r={error:t}}finally{try{u&&!u.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{s&&!s.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:!0,configurable:!0}),t}(),z=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(!B(t))throw new TypeError('"polygons" must be of type Polygon[]. Received type '+typeof t);if(0===t.length)throw new Error("MultiPolygon must contain 1 polygon at least");try{for(var r=z(t),o=r.next();!o.done;o=r.next()){var i=o.value;if(!(i instanceof K))throw new TypeError('"polygon" must be of type Polygon[]. Received type '+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,s;if("MultiPolygon"!==t.type||!B(t.coordinates))return!1;try{for(var a=z(t.coordinates),c=a.next();!c.done;c=a.next()){var u=c.value;try{for(var f=(r=void 0,z(u)),l=f.next();!l.done;l=f.next()){var h=l.value;try{for(var p=(i=void 0,z(h)),d=p.next();!d.done;d=p.next()){var y=d.value;if(!q(y[0])||!q(y[1]))return!1}}catch(t){i={error:t}}finally{try{d&&!d.done&&(s=p.return)&&s.call(p)}finally{if(i)throw i.error}}}}catch(t){r={error:t}}finally{try{l&&!l.done&&(o=f.return)&&o.call(f)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{c&&!c.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return x},enumerable:!0,configurable:!0}),t}(),Z=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 U},enumerable:!0,configurable:!0}),t.prototype.parse=function(){return{$date:{offset:this.offset}}},t}();function Q(t){return new Z(t)}var tt,et=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.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 s},nt=function(){function t(){}return t.formatResDocumentData=function(e){return e.map((function(e){return t.formatField(e)}))},t.formatField=function(e){var n=Object.keys(e),r={};return Array.isArray(e)&&(r=[]),n.forEach((function(n){var o,i=e[n];switch(t.whichType(i)){case u:o=new ot(i.coordinates[0],i.coordinates[1]);break;case f:o=new H(i.coordinates.map((function(t){return new ot(t[0],t[1])})));break;case l:o=new K(i.coordinates.map((function(t){return new H(t.map((function(t){var e=et(t,2),n=e[0],r=e[1];return new ot(n,r)})))})));break;case h:o=new V(i.coordinates.map((function(t){return new ot(t[0],t[1])})));break;case p:o=new Y(i.coordinates.map((function(t){return new H(t.map((function(t){var e=et(t,2),n=e[0],r=e[1];return new ot(n,r)})))})));break;case d:o=new X(i.coordinates.map((function(t){return new K(t.map((function(t){return new H(t.map((function(t){var e=et(t,2),n=e[0],r=e[1];return new ot(n,r)})))})))})));break;case y:o=new Date(1e3*i.$timestamp);break;case c:case"Array":o=t.formatField(i);break;case g: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);if(e===y)return"BsonDate";if(e===c){if(t instanceof ot)return u;if(t instanceof Date)return y;if(t instanceof Z)return g;t.$timestamp?e=y:t.$date?e=g:ot.validate(t)?e=u:H.validate(t)?e=f:K.validate(t)?e=l:V.validate(t)?e=h:Y.validate(t)?e=p:X.validate(t)&&(e=d)}return e},t.generateDocId=function(){for(var t="",e=0;e<24;e++)t+="ABCDEFabcdef0123456789".charAt(Math.floor(22*Math.random()));return t},t}(),rt=function(){function t(){}return t.isGeopoint=function(t,e){if("Number"!==nt.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.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===m.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}(),ot=function(){function t(t,e){rt.isGeopoint("longitude",t),rt.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"["+this.longitude+","+this.latitude+"]"},t.validate=function(t){return"Point"===t.type&&B(t.coordinates)&&rt.isGeopoint("longitude",t.coordinates[0])&&rt.isGeopoint("latitude",t.coordinates[1])},Object.defineProperty(t.prototype,"_internalType",{get:function(){return R},enumerable:!0,configurable:!0}),t}(),it=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};!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"}(tt||(tt={}));var st,at=function(){function t(t,e,n){this._internalType=A,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=t,this.operands=e,this.fieldName=n||O}return t.prototype._setFieldName=function(e){return new t(this.operator,this.operands,e)},t}();function ct(t){return t&&t instanceof at&&t._internalType===A}!function(t){t.AND="and",t.OR="or",t.NOT="not",t.NOR="nor"}(st||(st={}));var ut=function(){function t(t,e,n){if(this._internalType=N,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=t,this.operands=e,this.fieldName=n||O,this.fieldName!==O)if(Array.isArray(e)){e=e.slice(),this.operands=e;for(var r=0,o=e.length;r<o;r++)(ft(i=e[r])||dt(i))&&(e[r]=i._setFieldName(this.fieldName))}else{var i;(ft(i=e)||dt(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(st.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(st.OR,r,this.fieldName)},t}();function ft(t){return t&&t instanceof ut&&t._internalType===N}var lt,ht=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)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){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"}(lt||(lt={}));var pt=function(t){function e(e,n,r){var o=t.call(this,e,n,r)||this;return o.operator=e,o._internalType=T,o}return ht(e,t),e.prototype.toJSON=function(){var t,e;switch(this.operator){case lt.IN:case lt.NIN:return(t={})["$"+this.operator]=this.operands,t;default:return(e={})["$"+this.operator]=this.operands[0],e}},e.prototype._setFieldName=function(t){return new e(this.operator,this.operands,t)},e.prototype.eq=function(t){var n=new e(lt.EQ,[t],this.fieldName);return this.and(n)},e.prototype.neq=function(t){var n=new e(lt.NEQ,[t],this.fieldName);return this.and(n)},e.prototype.gt=function(t){var n=new e(lt.GT,[t],this.fieldName);return this.and(n)},e.prototype.gte=function(t){var n=new e(lt.GTE,[t],this.fieldName);return this.and(n)},e.prototype.lt=function(t){var n=new e(lt.LT,[t],this.fieldName);return this.and(n)},e.prototype.lte=function(t){var n=new e(lt.LTE,[t],this.fieldName);return this.and(n)},e.prototype.in=function(t){var n=new e(lt.IN,t,this.fieldName);return this.and(n)},e.prototype.nin=function(t){var n=new e(lt.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 '+typeof t.geometry);if(void 0!==t.maxDistance&&!q(t.maxDistance))throw new TypeError('"maxDistance" must be of type Number. Received type '+typeof t.maxDistance);if(void 0!==t.minDistance&&!q(t.minDistance))throw new TypeError('"minDistance" must be of type Number. Received type '+typeof t.minDistance);var n=new e(lt.GEO_NEAR,[t],this.fieldName);return this.and(n)},e.prototype.geoWithin=function(t){if(!(t.geometry instanceof X||t.geometry instanceof K))throw new TypeError('"geometry" must be of type Polygon or MultiPolygon. Received type '+typeof t.geometry);var n=new e(lt.GEO_WITHIN,[t],this.fieldName);return this.and(n)},e.prototype.geoIntersects=function(t){if(!(t.geometry instanceof ot||t.geometry instanceof H||t.geometry instanceof K||t.geometry instanceof V||t.geometry instanceof Y||t.geometry instanceof X))throw new TypeError('"geometry" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type '+typeof t.geometry);var n=new e(lt.GEO_INTERSECTS,[t],this.fieldName);return this.and(n)},e}(ut);function dt(t){return t&&t instanceof pt&&t._internalType===T}function yt(t){return dt(t)}var gt={};for(var vt in lt)gt[vt]="$"+vt;for(var vt in st)gt[vt]="$"+vt;for(var vt in tt)gt[vt]="$"+vt;function mt(t){return gt[t]||"$"+t}gt[lt.NEQ]="$ne",gt[tt.REMOVE]="$unset",gt[tt.SHIFT]="$pop",gt[tt.UNSHIFT]="$push";var _t=function(){return _t=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},_t.apply(this,arguments)},wt=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.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 s},bt=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(wt(arguments[e]));return t};function Et(t){return St(t,[t])}function St(t,e){if(!$(t)){if(F(t))return{$date:+t};if(W(t))return{$regex:t.source,$options:t.flags};if(B(t))return t.map((function(t){if(e.indexOf(t)>-1)throw new Error("Cannot convert circular structure to JSON");return St(t,bt(e,[t]))}));if(M(t)){var n=_t({},t);for(var r in n){if(e.indexOf(n[r])>-1)throw new Error("Cannot convert circular structure to JSON");n[r]=St(n[r],bt(e,[n[r]]))}return n}return t}switch(t._internalType){case R:return t.toJSON();case U:case j:return t.parse();default:return t.toJSON?t.toJSON():t}}var It=function(){return It=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},It.apply(this,arguments)},Ot=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.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 s},At=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Ot(arguments[e]));return t};function Tt(t,e,n,r){var o=It({},t);for(var i in t)if(!/^\$/.test(i)){var s=t[i];if(s&&M(s)&&!e(s)){if(r.indexOf(s)>-1)throw new Error("Cannot convert circular structure to JSON");var a=Tt(s,e,At(n,[i]),At(r,[s]));o[i]=a;var c=!1;for(var u in a)/^\$/.test(u)?c=!0:(o[i+"."+u]=a[u],delete o[i][u]);c||delete o[i]}}return o}function Nt(t){return Tt(t,Pt,[],[t])}function Rt(t,e,n){for(var r in e[n]||delete t[n],e)t[r]?B(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 "+D(e)+", can only overwrite",e,n),t[r]=e[r]):(console.warn("to-merge query is of type "+D(t)+", can only overwrite",t,e,n),t[r]=e[r]):t[r]=e[r]}function Pt(t){return $(t)||F(t)||W(t)}function xt(t){return Et(t)}var Lt=function(){function t(){}return t.encode=function(e){return(new t).encodeUpdate(e)},t.prototype.encodeUpdate=function(t){return ct(t)?this.encodeUpdateCommand(t):"object"===D(t)?this.encodeUpdateObject(t):t},t.prototype.encodeUpdateCommand=function(t){if(t.fieldName===O)throw new Error("Cannot encode a comparison command with unset field name");switch(t.operator){case tt.PUSH:case tt.PULL:case tt.PULL_ALL:case tt.POP:case tt.SHIFT:case tt.UNSHIFT:case tt.ADD_TO_SET:return this.encodeArrayUpdateCommand(t);default:return this.encodeFieldUpdateCommand(t)}},t.prototype.encodeFieldUpdateCommand=function(t){var e,n,r,o,i=mt(t.operator);return t.operator===tt.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,s,a,c,u,f,l=mt(t.operator);switch(t.operator){case tt.PUSH:var h=void 0;return h=B(t.operands)?{$each:t.operands.map(xt)}:t.operands,(e={})[l]=((n={})[t.fieldName]=h,n),e;case tt.UNSHIFT:return h={$each:t.operands.map(xt),$position:0},(r={})[l]=((o={})[t.fieldName]=h,o),r;case tt.POP:return(i={})[l]=((s={})[t.fieldName]=1,s),i;case tt.SHIFT:return(a={})[l]=((c={})[t.fieldName]=-1,c),a;default:return(u={})[l]=((f={})[t.fieldName]=xt(t.operands),f),u}},t.prototype.encodeUpdateObject=function(t){var e=Nt(t);for(var n in e)if(!/^\$/.test(n)){var r=e[n];if(ct(r))e[n]=r._setFieldName(n),Rt(e,this.encodeUpdateCommand(e[n]),n);else{e[n]=r=xt(r);var o=new at(tt.SET,[r],n);Rt(e,this.encodeUpdateCommand(o),n)}}return e},t}(),Ct={};function kt(t){if(!Un.wsClientClass)throw new Error("to use realtime you must import realtime module first");var e=t.config.env;return Ct[e]||(Ct[e]=new Un.wsClientClass({context:{appConfig:{docSizeLimit:1e3,realtimePingInterval:1e4,realtimePongWaitTimeout:5e3,request:new Un.reqClass(t.config)}}})),Ct[e]}for(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(){function t(t,e,n,r){var o=this;void 0===r&&(r={}),this.watch=function(t){return kt(o._db).watch(Ut(Ut({},t),{envId:o._db.config.env,collectionName:o._coll,query:JSON.stringify({_id:o.id})}))},this._db=t,this._coll=e,this.id=n,this.request=new Un.reqClass(this._db.config),this.projection=r}return t.prototype.create=function(t,e){e=e||it();var n={collectionName:this._coll,data:Et(t)};return this.id&&(n._id=this.id),this.request.send("database.addDocument",n).then((function(t){t.code?e(0,t):e(0,{id:t.data._id,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},t.prototype.set=function(t,e){if(e=e||it(),!this.id)return Promise.resolve({code:"INVALID_PARAM",message:"docId不能为空"});if(!t||"object"!=typeof t)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(t.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n=!1,r=function(t){if("object"==typeof t)for(var e in t)t[e]instanceof at?n=!0:"object"==typeof t[e]&&r(t[e])};if(r(t),n)return Promise.resolve({code:"DATABASE_REQUEST_FAILED",message:"update operator complicit"});var o={collectionName:this._coll,queryType:a.DOC,data:Et(t),multi:!1,merge:!1,upsert:!0};return this.id&&(o.query={_id:this.id}),this.request.send("database.updateDocument",o).then((function(t){t.code?e(0,t):e(0,{updated:t.data.updated,upsertedId:t.data.upserted_id,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},t.prototype.update=function(t,e){if(e=e||it(),!t||"object"!=typeof t)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(t.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n={_id:this.id},r={collectionName:this._coll,data:Lt.encode(t),query:n,queryType:a.DOC,multi:!1,merge:!0,upsert:!1};return this.request.send("database.updateDocument",r).then((function(t){t.code?e(0,t):e(0,{updated:t.data.updated,upsertedId:t.data.upserted_id,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},t.prototype.remove=function(t){t=t||it();var e={_id:this.id},n={collectionName:this._coll,query:e,queryType:a.DOC,multi:!1};return this.request.send("database.deleteDocument",n).then((function(e){e.code?t(0,e):t(0,{deleted:e.data.deleted,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},t.prototype.get=function(t){t=t||it();var e={_id:this.id},n={collectionName:this._coll,query:e,queryType:a.DOC,multi:!1,projection:this.projection};return this.request.send("database.queryDocument",n).then((function(e){if(e.code)t(0,e);else{var n=nt.formatResDocumentData(e.data.list);t(0,{data:n,requestId:e.requestId})}})).catch((function(e){t(e)})),t.promise},t.prototype.field=function(e){for(var n in e)e[n]?e[n]=1:e[n]=0;return new t(this._db,this._coll,this.id,e)},t}(),Dt=function(){function t(){}return t.encode=function(t){return(new Mt).encodeQuery(t)},t}(),Mt=function(){function t(){}return t.prototype.encodeQuery=function(t,e){var n;return Pt(t)?ft(t)?this.encodeLogicCommand(t):dt(t)?this.encodeQueryCommand(t):((n={})[e]=this.encodeQueryObject(t),n):M(t)?this.encodeQueryObject(t):t},t.prototype.encodeRegExp=function(t){return{$regex:t.source,$options:t.flags}},t.prototype.encodeLogicCommand=function(t){var e,n,r,o,i,s,a,c=this;switch(t.operator){case st.NOR:case st.AND:case st.OR:var u=mt(t.operator),f=t.operands.map((function(e){return c.encodeQuery(e,t.fieldName)}));return(e={})[u]=f,e;case st.NOT:u=mt(t.operator);var l=t.operands[0];return W(l)?((n={})[t.fieldName]=((r={})[u]=this.encodeRegExp(l),r),n):(f=this.encodeQuery(l)[t.fieldName],(o={})[t.fieldName]=((i={})[u]=f,i),o);default:if(u=mt(t.operator),1===t.operands.length){var h=this.encodeQuery(t.operands[0]);return(s={})[u]=h,s}return f=t.operands.map(this.encodeQuery.bind(this)),(a={})[u]=f,a}},t.prototype.encodeQueryCommand=function(t){return yt(t),this.encodeComparisonCommand(t)},t.prototype.encodeComparisonCommand=function(t){var e,n,r,o,i,s,a,c,u;if(t.fieldName===O)throw new Error("Cannot encode a comparison command with unset field name");var f=mt(t.operator);switch(t.operator){case lt.EQ:case lt.NEQ:case lt.LT:case lt.LTE:case lt.GT:case lt.GTE:case lt.ELEM_MATCH:case lt.EXISTS:case lt.SIZE:case lt.MOD:return(e={})[t.fieldName]=((n={})[f]=xt(t.operands[0]),n),e;case lt.IN:case lt.NIN:case lt.ALL:return(r={})[t.fieldName]=((o={})[f]=xt(t.operands),o),r;case lt.GEO_NEAR:var l=t.operands[0];return(i={})[t.fieldName]={$nearSphere:{$geometry:l.geometry.toJSON(),$maxDistance:l.maxDistance,$minDistance:l.minDistance}},i;case lt.GEO_WITHIN:return l=t.operands[0],(s={})[t.fieldName]={$geoWithin:{$geometry:l.geometry.toJSON()}},s;case lt.GEO_INTERSECTS:return l=t.operands[0],(a={})[t.fieldName]={$geoIntersects:{$geometry:l.geometry.toJSON()}},a;default:return(c={})[t.fieldName]=((u={})[f]=xt(t.operands[0]),u),c}},t.prototype.encodeQueryObject=function(t){var e=Nt(t);for(var n in e){var r=e[n];if(ft(r)){e[n]=r._setFieldName(n);var o=this.encodeLogicCommand(e[n]);this.mergeConditionAfterEncode(e,o,n)}else yt(r)?(e[n]=r._setFieldName(n),o=this.encodeComparisonCommand(e[n]),this.mergeConditionAfterEncode(e,o,n)):Pt(r)&&(e[n]=xt(r))}return e},t.prototype.mergeConditionAfterEncode=function(t,e,n){for(var r in e[n]||delete t[n],e)t[r]?B(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 "+D(e)+", can only overwrite",e,n),t[r]=e[r]):(console.warn("to-merge query is of type "+D(t)+", can only overwrite",t,e,n),t[r]=e[r]):t[r]=e[r]},t}(),qt=function(){return qt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},qt.apply(this,arguments)},Bt=function(){function t(t,e,n,r,o){var i=this;this.watch=function(t){return kt(i._db).watch(qt(qt({},t),{envId:i._db.config.env,collectionName:i._coll,query:JSON.stringify(i._fieldFilters||{}),limit:i._queryOptions.limit,orderBy:i._fieldOrders?i._fieldOrders.reduce((function(t,e){return t[e.field]=e.direction,t}),{}):void 0}))},this._db=t,this._coll=e,this._fieldFilters=n,this._fieldOrders=r||[],this._queryOptions=o||{},this._request=new Un.reqClass(this._db.config)}return t.prototype.get=function(t){t=t||it();var e=[];this._fieldOrders&&this._fieldOrders.forEach((function(t){e.push(t)}));var n={collectionName:this._coll,queryType:a.WHERE};return this._fieldFilters&&(n.query=this._fieldFilters),e.length>0&&(n.order=e),this._queryOptions.offset&&(n.offset=this._queryOptions.offset),this._queryOptions.limit?n.limit=this._queryOptions.limit<1e3?this._queryOptions.limit:1e3:n.limit=100,this._queryOptions.projection&&(n.projection=this._queryOptions.projection),this._request.send("database.queryDocument",n).then((function(e){if(e.code)t(0,e);else{var n={data:nt.formatResDocumentData(e.data.list),requestId:e.requestId};e.total&&(n.total=e.total),e.limit&&(n.limit=e.limit),e.offset&&(n.offset=e.offset),t(0,n)}})).catch((function(e){t(e)})),t.promise},t.prototype.count=function(t){t=t||it();var e={collectionName:this._coll,queryType:a.WHERE};return this._fieldFilters&&(e.query=this._fieldFilters),this._request.send("database.countDocument",e).then((function(e){e.code?t(0,e):t(0,{requestId:e.requestId,total:e.data.total})})).catch((function(e){t(e)})),t.promise},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,Dt.encode(e),this._fieldOrders,this._queryOptions)},t.prototype.orderBy=function(e,n){rt.isFieldPath(e),rt.isFieldOrder(n);var r={field:e,direction:n},o=this._fieldOrders.concat(r);return new t(this._db,this._coll,this._fieldFilters,o,this._queryOptions)},t.prototype.limit=function(e){rt.isInteger("limit",e);var n=qt({},this._queryOptions);return n.limit=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},t.prototype.skip=function(e){rt.isInteger("offset",e);var n=qt({},this._queryOptions);return n.offset=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},t.prototype.update=function(t,e){if(e=e||it(),!t||"object"!=typeof t)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(t.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n={collectionName:this._coll,query:this._fieldFilters,queryType:a.WHERE,multi:!0,merge:!0,upsert:!1,data:Lt.encode(t)};return this._request.send("database.updateDocument",n).then((function(t){t.code?e(0,t):e(0,{requestId:t.requestId,updated:t.data.updated,upsertId:t.data.upsert_id})})).catch((function(t){e(t)})),e.promise},t.prototype.field=function(e){for(var n in e)e[n]?"object"!=typeof e[n]&&(e[n]=1):e[n]=0;var r=qt({},this._queryOptions);return r.projection=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,r)},t.prototype.remove=function(t){t=t||it(),Object.keys(this._queryOptions).length>0&&console.warn("`offset`, `limit` and `projection` are not supported in remove() operation"),this._fieldOrders.length>0&&console.warn("`orderBy` is not supported in remove() operation");var e={collectionName:this._coll,query:Dt.encode(this._fieldFilters),queryType:a.WHERE,multi:!0};return this._request.send("database.deleteDocument",e).then((function(e){e.code?t(0,e):t(0,{requestId:e.requestId,deleted:e.data.deleted})})).catch((function(e){t(e)})),t.promise},t}(),Ft=[],Wt=[],$t="undefined"!=typeof Uint8Array?Uint8Array:Array,Ht="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Gt=0;Gt<64;++Gt)Ft[Gt]=Ht[Gt],Wt[Ht.charCodeAt(Gt)]=Gt;function Kt(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function Vt(t,e,n){for(var r,o,i=[],s=e;s<n;s+=3)r=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]),i.push(Ft[(o=r)>>18&63]+Ft[o>>12&63]+Ft[o>>6&63]+Ft[63&o]);return i.join("")}Wt["-".charCodeAt(0)]=62,Wt["_".charCodeAt(0)]=63;var Jt=function(t){var e,n,r=Kt(t),o=r[0],i=r[1],s=new $t(function(t,e,n){return 3*(e+n)/4-n}(0,o,i)),a=0,c=i>0?o-4:o;for(n=0;n<c;n+=4)e=Wt[t.charCodeAt(n)]<<18|Wt[t.charCodeAt(n+1)]<<12|Wt[t.charCodeAt(n+2)]<<6|Wt[t.charCodeAt(n+3)],s[a++]=e>>16&255,s[a++]=e>>8&255,s[a++]=255&e;return 2===i&&(e=Wt[t.charCodeAt(n)]<<2|Wt[t.charCodeAt(n+1)]>>4,s[a++]=255&e),1===i&&(e=Wt[t.charCodeAt(n)]<<10|Wt[t.charCodeAt(n+1)]<<4|Wt[t.charCodeAt(n+2)]>>2,s[a++]=e>>8&255,s[a++]=255&e),s},Yt=function(t){for(var e,n=t.length,r=n%3,o=[],i=16383,s=0,a=n-r;s<a;s+=i)o.push(Vt(t,s,s+i>a?a:s+i));return 1===r?(e=t[n-1],o.push(Ft[e>>2]+Ft[e<<4&63]+"==")):2===r&&(e=(t[n-2]<<8)+t[n-1],o.push(Ft[e>>10]+Ft[e>>4&63]+Ft[e<<2&63]+"=")),o.join("")},zt=function(t,e,n,r,o){var i,s,a=8*o-r-1,c=(1<<a)-1,u=c>>1,f=-7,l=n?o-1:0,h=n?-1:1,p=t[e+l];for(l+=h,i=p&(1<<-f)-1,p>>=-f,f+=a;f>0;i=256*i+t[e+l],l+=h,f-=8);for(s=i&(1<<-f)-1,i>>=-f,f+=r;f>0;s=256*s+t[e+l],l+=h,f-=8);if(0===i)i=1-u;else{if(i===c)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),i-=u}return(p?-1:1)*s*Math.pow(2,i-r)},Xt=function(t,e,n,r,o,i){var s,a,c,u=8*i-o-1,f=(1<<u)-1,l=f>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:i-1,d=r?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),(e+=s+l>=1?h/c:h*Math.pow(2,1-l))*c>=2&&(s++,c/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(e*c-1)*Math.pow(2,o),s+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,o),s=0));o>=8;t[n+p]=255&a,p+=d,a/=256,o-=8);for(s=s<<o|a,u+=o;u>0;t[n+p]=255&s,p+=d,s/=256,u-=8);t[n+p-d]|=128*y},Zt=function(t,e){return function(t,e){var n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=i,e.SlowBuffer=function(t){return+t!=t&&(t=0),i.alloc(+t)},e.INSPECT_MAX_BYTES=50;var r=2147483647;function o(t){if(t>r)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return Object.setPrototypeOf(e,i.prototype),e}function i(t,e,n){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return s(t,e,n)}function s(t,e,n){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!i.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var n=0|h(t,e),r=o(n),s=r.write(t,e);return s!==n&&(r=r.slice(0,s)),r}(t,e);if(ArrayBuffer.isView(t))return function(t){if(M(t,Uint8Array)){var e=new Uint8Array(t);return f(e.buffer,e.byteOffset,e.byteLength)}return u(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+babelHelpers.typeof(t));if(M(t,ArrayBuffer)||t&&M(t.buffer,ArrayBuffer))return f(t,e,n);if("undefined"!=typeof SharedArrayBuffer&&(M(t,SharedArrayBuffer)||t&&M(t.buffer,SharedArrayBuffer)))return f(t,e,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');var r=t.valueOf&&t.valueOf();if(null!=r&&r!==t)return i.from(r,e,n);var s=function(t){if(i.isBuffer(t)){var e=0|l(t.length),n=o(e);return 0===n.length||t.copy(n,0,0,e),n}return void 0!==t.length?"number"!=typeof t.length||q(t.length)?o(0):u(t):"Buffer"===t.type&&Array.isArray(t.data)?u(t.data):void 0}(t);if(s)return s;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return i.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+babelHelpers.typeof(t))}function a(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function c(t){return a(t),o(t<0?0:0|l(t))}function u(t){for(var e=t.length<0?0:0|l(t.length),n=o(e),r=0;r<e;r+=1)n[r]=255&t[r];return n}function f(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');var r;return r=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n),Object.setPrototypeOf(r,i.prototype),r}function l(t){if(t>=r)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r.toString(16)+" bytes");return 0|t}function h(t,e){if(i.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||M(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+babelHelpers.typeof(t));var n=t.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return U(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return j(t).length;default:if(o)return r?-1:U(t).length;e=(""+e).toLowerCase(),o=!0}}function p(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return T(this,e,n);case"utf8":case"utf-8":return S(this,e,n);case"ascii":return O(this,e,n);case"latin1":case"binary":return A(this,e,n);case"base64":return E(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function d(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function y(t,e,n,r,o){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),q(n=+n)&&(n=o?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(o)return-1;n=t.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof e&&(e=i.from(e,r)),i.isBuffer(e))return 0===e.length?-1:g(t,e,n,r,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):g(t,[e],n,r,o);throw new TypeError("val must be string, number or Buffer")}function g(t,e,n,r,o){var i,s=1,a=t.length,c=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;s=2,a/=2,c/=2,n/=2}function u(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){var f=-1;for(i=n;i<a;i++)if(u(t,i)===u(e,-1===f?0:i-f)){if(-1===f&&(f=i),i-f+1===c)return f*s}else-1!==f&&(i-=i-f),f=-1}else for(n+c>a&&(n=a-c),i=n;i>=0;i--){for(var l=!0,h=0;h<c;h++)if(u(t,i+h)!==u(e,h)){l=!1;break}if(l)return i}return-1}function v(t,e,n,r){n=Number(n)||0;var o=t.length-n;r?(r=Number(r))>o&&(r=o):r=o;var i=e.length;r>i/2&&(r=i/2);for(var s=0;s<r;++s){var a=parseInt(e.substr(2*s,2),16);if(q(a))return s;t[n+s]=a}return s}function m(t,e,n,r){return D(U(e,t.length-n),t,n,r)}function _(t,e,n,r){return D(function(t){for(var e=[],n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}function w(t,e,n,r){return D(j(e),t,n,r)}function b(t,e,n,r){return D(function(t,e){for(var n,r,o,i=[],s=0;s<t.length&&!((e-=2)<0);++s)r=(n=t.charCodeAt(s))>>8,o=n%256,i.push(o),i.push(r);return i}(e,t.length-n),t,n,r)}function E(t,e,n){return 0===e&&n===t.length?Yt(t):Yt(t.slice(e,n))}function S(t,e,n){n=Math.min(t.length,n);for(var r=[],o=e;o<n;){var i,s,a,c,u=t[o],f=null,l=u>239?4:u>223?3:u>191?2:1;if(o+l<=n)switch(l){case 1:u<128&&(f=u);break;case 2:128==(192&(i=t[o+1]))&&(c=(31&u)<<6|63&i)>127&&(f=c);break;case 3:i=t[o+1],s=t[o+2],128==(192&i)&&128==(192&s)&&(c=(15&u)<<12|(63&i)<<6|63&s)>2047&&(c<55296||c>57343)&&(f=c);break;case 4:i=t[o+1],s=t[o+2],a=t[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(c=(15&u)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(f=c)}null===f?(f=65533,l=1):f>65535&&(f-=65536,r.push(f>>>10&1023|55296),f=56320|1023&f),r.push(f),o+=l}return function(t){var e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);for(var n="",r=0;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=I));return n}(r)}e.kMaxLength=r,i.TYPED_ARRAY_SUPPORT=function(){try{var t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),i.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(i.prototype,"parent",{enumerable:!0,get:function(){if(i.isBuffer(this))return this.buffer}}),Object.defineProperty(i.prototype,"offset",{enumerable:!0,get:function(){if(i.isBuffer(this))return this.byteOffset}}),i.poolSize=8192,i.from=function(t,e,n){return s(t,e,n)},Object.setPrototypeOf(i.prototype,Uint8Array.prototype),Object.setPrototypeOf(i,Uint8Array),i.alloc=function(t,e,n){return function(t,e,n){return a(t),t<=0?o(t):void 0!==e?"string"==typeof n?o(t).fill(e,n):o(t).fill(e):o(t)}(t,e,n)},i.allocUnsafe=function(t){return c(t)},i.allocUnsafeSlow=function(t){return c(t)},i.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==i.prototype},i.compare=function(t,e){if(M(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),M(e,Uint8Array)&&(e=i.from(e,e.offset,e.byteLength)),!i.isBuffer(t)||!i.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var n=t.length,r=e.length,o=0,s=Math.min(n,r);o<s;++o)if(t[o]!==e[o]){n=t[o],r=e[o];break}return n<r?-1:r<n?1:0},i.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},i.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return i.alloc(0);var n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var r=i.allocUnsafe(e),o=0;for(n=0;n<t.length;++n){var s=t[n];if(M(s,Uint8Array))o+s.length>r.length?i.from(s).copy(r,o):Uint8Array.prototype.set.call(r,s,o);else{if(!i.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,o)}o+=s.length}return r},i.byteLength=h,i.prototype._isBuffer=!0,i.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)d(this,e,e+1);return this},i.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)d(this,e,e+3),d(this,e+1,e+2);return this},i.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)d(this,e,e+7),d(this,e+1,e+6),d(this,e+2,e+5),d(this,e+3,e+4);return this},i.prototype.toString=function(){var t=this.length;return 0===t?"":0===arguments.length?S(this,0,t):p.apply(this,arguments)},i.prototype.toLocaleString=i.prototype.toString,i.prototype.equals=function(t){if(!i.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===i.compare(this,t)},i.prototype.inspect=function(){var t="",n=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(t+=" ... "),"<Buffer "+t+">"},n&&(i.prototype[n]=i.prototype.inspect),i.prototype.compare=function(t,e,n,r,o){if(M(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),!i.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+babelHelpers.typeof(t));if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),e<0||n>t.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&e>=n)return 0;if(r>=o)return-1;if(e>=n)return 1;if(this===t)return 0;for(var s=(o>>>=0)-(r>>>=0),a=(n>>>=0)-(e>>>=0),c=Math.min(s,a),u=this.slice(r,o),f=t.slice(e,n),l=0;l<c;++l)if(u[l]!==f[l]){s=u[l],a=f[l];break}return s<a?-1:a<s?1:0},i.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},i.prototype.indexOf=function(t,e,n){return y(this,t,e,n,!0)},i.prototype.lastIndexOf=function(t,e,n){return y(this,t,e,n,!1)},i.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-e;if((void 0===n||n>o)&&(n=o),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return v(this,t,e,n);case"utf8":case"utf-8":return m(this,t,e,n);case"ascii":case"latin1":case"binary":return _(this,t,e,n);case"base64":return w(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return b(this,t,e,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var I=4096;function O(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;o<n;++o)r+=String.fromCharCode(127&t[o]);return r}function A(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;o<n;++o)r+=String.fromCharCode(t[o]);return r}function T(t,e,n){var r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);for(var o="",i=e;i<n;++i)o+=B[t[i]];return o}function N(t,e,n){for(var r=t.slice(e,n),o="",i=0;i<r.length-1;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}function R(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function P(t,e,n,r,o,s){if(!i.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<s)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function x(t,e,n,r,o,i){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function L(t,e,n,r,o){return e=+e,n>>>=0,o||x(t,0,n,4),Xt(t,e,n,r,23,4),n+4}function C(t,e,n,r,o){return e=+e,n>>>=0,o||x(t,0,n,8),Xt(t,e,n,r,52,8),n+8}i.prototype.slice=function(t,e){var n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t);var r=this.subarray(t,e);return Object.setPrototypeOf(r,i.prototype),r},i.prototype.readUintLE=i.prototype.readUIntLE=function(t,e,n){t>>>=0,e>>>=0,n||R(t,e,this.length);for(var r=this[t],o=1,i=0;++i<e&&(o*=256);)r+=this[t+i]*o;return r},i.prototype.readUintBE=i.prototype.readUIntBE=function(t,e,n){t>>>=0,e>>>=0,n||R(t,e,this.length);for(var r=this[t+--e],o=1;e>0&&(o*=256);)r+=this[t+--e]*o;return r},i.prototype.readUint8=i.prototype.readUInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),this[t]},i.prototype.readUint16LE=i.prototype.readUInt16LE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]|this[t+1]<<8},i.prototype.readUint16BE=i.prototype.readUInt16BE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]<<8|this[t+1]},i.prototype.readUint32LE=i.prototype.readUInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},i.prototype.readUint32BE=i.prototype.readUInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},i.prototype.readIntLE=function(t,e,n){t>>>=0,e>>>=0,n||R(t,e,this.length);for(var r=this[t],o=1,i=0;++i<e&&(o*=256);)r+=this[t+i]*o;return r>=(o*=128)&&(r-=Math.pow(2,8*e)),r},i.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||R(t,e,this.length);for(var r=e,o=1,i=this[t+--r];r>0&&(o*=256);)i+=this[t+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},i.prototype.readInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},i.prototype.readInt16LE=function(t,e){t>>>=0,e||R(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},i.prototype.readInt16BE=function(t,e){t>>>=0,e||R(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},i.prototype.readInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},i.prototype.readInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},i.prototype.readFloatLE=function(t,e){return t>>>=0,e||R(t,4,this.length),zt(this,t,!0,23,4)},i.prototype.readFloatBE=function(t,e){return t>>>=0,e||R(t,4,this.length),zt(this,t,!1,23,4)},i.prototype.readDoubleLE=function(t,e){return t>>>=0,e||R(t,8,this.length),zt(this,t,!0,52,8)},i.prototype.readDoubleBE=function(t,e){return t>>>=0,e||R(t,8,this.length),zt(this,t,!1,52,8)},i.prototype.writeUintLE=i.prototype.writeUIntLE=function(t,e,n,r){t=+t,e>>>=0,n>>>=0,r||P(this,t,e,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[e]=255&t;++i<n&&(o*=256);)this[e+i]=t/o&255;return e+n},i.prototype.writeUintBE=i.prototype.writeUIntBE=function(t,e,n,r){t=+t,e>>>=0,n>>>=0,r||P(this,t,e,n,Math.pow(2,8*n)-1,0);var o=n-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+n},i.prototype.writeUint8=i.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||P(this,t,e,1,255,0),this[e]=255&t,e+1},i.prototype.writeUint16LE=i.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||P(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeUint16BE=i.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||P(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeUint32LE=i.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||P(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},i.prototype.writeUint32BE=i.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||P(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},i.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e>>>=0,!r){var o=Math.pow(2,8*n-1);P(this,t,e,n,o-1,-o)}var i=0,s=1,a=0;for(this[e]=255&t;++i<n&&(s*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/s|0)-a&255;return e+n},i.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e>>>=0,!r){var o=Math.pow(2,8*n-1);P(this,t,e,n,o-1,-o)}var i=n-1,s=1,a=0;for(this[e+i]=255&t;--i>=0&&(s*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/s|0)-a&255;return e+n},i.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||P(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},i.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||P(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||P(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||P(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},i.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||P(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},i.prototype.writeFloatLE=function(t,e,n){return L(this,t,e,!0,n)},i.prototype.writeFloatBE=function(t,e,n){return L(this,t,e,!1,n)},i.prototype.writeDoubleLE=function(t,e,n){return C(this,t,e,!0,n)},i.prototype.writeDoubleBE=function(t,e,n){return C(this,t,e,!1,n)},i.prototype.copy=function(t,e,n,r){if(!i.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);var o=r-n;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,n,r):Uint8Array.prototype.set.call(t,this.subarray(n,r),e),o},i.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!i.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===t.length){var o=t.charCodeAt(0);("utf8"===r&&o<128||"latin1"===r)&&(t=o)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;var s;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(s=e;s<n;++s)this[s]=t;else{var a=i.isBuffer(t)?t:i.from(t,r),c=a.length;if(0===c)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(s=0;s<n-e;++s)this[s+e]=a[s%c]}return this};var k=/[^+/0-9A-Za-z-_]/g;function U(t,e){var n;e=e||1/0;for(var r=t.length,o=null,i=[],s=0;s<r;++s){if((n=t.charCodeAt(s))>55295&&n<57344){if(!o){if(n>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(e-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(e-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((e-=1)<0)break;i.push(n)}else if(n<2048){if((e-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function j(t){return Jt(function(t){if((t=(t=t.split("=")[0]).trim().replace(k,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function D(t,e,n,r){for(var o=0;o<r&&!(o+n>=e.length||o>=t.length);++o)e[o+n]=t[o];return o}function M(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function q(t){return t!=t}var B=function(){for(var t="0123456789abcdef",e=new Array(256),n=0;n<16;++n)for(var r=16*n,o=0;o<16;++o)e[r+o]=t[n]+t[o];return e}()}(e={exports:{}},e.exports),e.exports}(),Qt=Zt.Buffer;Zt.SlowBuffer,Zt.INSPECT_MAX_BYTES,Zt.kMaxLength;var te=function(t,e){return te=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},te(t,e)};function ee(t,e){function n(){this.constructor=t}te(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var ne=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r}return ee(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return"BSONError"},enumerable:!1,configurable:!0}),e}(Error),re=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r}return ee(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return"BSONTypeError"},enumerable:!1,configurable:!0}),e}(TypeError);function oe(t){return t&&t.Math==Math&&t}function ie(){return oe("object"==typeof globalThis&&globalThis)||oe("object"==typeof window&&window)||oe("object"==typeof self&&self)||oe("object"==typeof n.g&&n.g)||Function("return this")()}var se=function(t){var e,n="object"==typeof(e=ie()).navigator&&"ReactNative"===e.navigator.product?"BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.":"BSON: No cryptographic implementation for random bytes present, falling back to a less secure implementation.";console.warn(n);for(var r=Qt.alloc(t),o=0;o<t;++o)r[o]=Math.floor(256*Math.random());return r},ae=function(){if("undefined"!=typeof window){var t=window.crypto||window.msCrypto;if(t&&t.getRandomValues)return function(e){return t.getRandomValues(Qt.alloc(e))}}return void 0!==n.g&&n.g.crypto&&n.g.crypto.getRandomValues?function(t){return n.g.crypto.getRandomValues(Qt.alloc(t))}:se}();function ce(t){return"[object Uint8Array]"===Object.prototype.toString.call(t)}function ue(t){return"object"==typeof t&&null!==t}function fe(t,e){var n=!1;return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];return n||(console.warn(e),n=!0),t.apply(this,r)}}function le(t){if(ArrayBuffer.isView(t))return Qt.from(t.buffer,t.byteOffset,t.byteLength);if(e=t,["[object ArrayBuffer]","[object SharedArrayBuffer]"].includes(Object.prototype.toString.call(e)))return Qt.from(t);var e;throw new re("Must use either Buffer or TypedArray")}var he=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|[0-9a-f]{12}4[0-9a-f]{3}[89ab][0-9a-f]{15})$/i,pe=function(t){return"string"==typeof t&&he.test(t)},de=function(t){if(!pe(t))throw new re('UUID string representations must be a 32 or 36 character hex string (dashes excluded/included). Format: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" or "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".');var e=t.replace(/-/g,"");return Qt.from(e,"hex")},ye=function(t,e){return void 0===e&&(e=!0),e?t.toString("hex",0,4)+"-"+t.toString("hex",4,6)+"-"+t.toString("hex",6,8)+"-"+t.toString("hex",8,10)+"-"+t.toString("hex",10,16):t.toString("hex")},ge=(Math.pow(2,63),Math.pow(2,63),Math.pow(2,53)),ve=-Math.pow(2,53),me=function(){function t(e,n){if(!(this instanceof t))return new t(e,n);if(!(null==e||"string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||Array.isArray(e)))throw new re("Binary can only be constructed from string, Buffer, TypedArray, or Array<number>");this.sub_type=null!=n?n:t.BSON_BINARY_SUBTYPE_DEFAULT,null==e?(this.buffer=Qt.alloc(t.BUFFER_SIZE),this.position=0):("string"==typeof e?this.buffer=Qt.from(e,"binary"):Array.isArray(e)?this.buffer=Qt.from(e):this.buffer=le(e),this.position=this.buffer.byteLength)}return t.prototype.put=function(e){if("string"==typeof e&&1!==e.length)throw new re("only accepts single character String");if("number"!=typeof e&&1!==e.length)throw new re("only accepts single character Uint8Array or Array");var n;if((n="string"==typeof e?e.charCodeAt(0):"number"==typeof e?e:e[0])<0||n>255)throw new re("only accepts number in a valid unsigned byte range 0-255");if(this.buffer.length>this.position)this.buffer[this.position++]=n;else{var r=Qt.alloc(t.BUFFER_SIZE+this.buffer.length);this.buffer.copy(r,0,0,this.buffer.length),this.buffer=r,this.buffer[this.position++]=n}},t.prototype.write=function(t,e){if(e="number"==typeof e?e:this.position,this.buffer.length<e+t.length){var n=Qt.alloc(this.buffer.length+t.length);this.buffer.copy(n,0,0,this.buffer.length),this.buffer=n}ArrayBuffer.isView(t)?(this.buffer.set(le(t),e),this.position=e+t.byteLength>this.position?e+t.length:this.position):"string"==typeof t&&(this.buffer.write(t,e,t.length,"binary"),this.position=e+t.length>this.position?e+t.length:this.position)},t.prototype.read=function(t,e){return e=e&&e>0?e:this.position,this.buffer.slice(t,t+e)},t.prototype.value=function(t){return(t=!!t)&&this.buffer.length===this.position?this.buffer:t?this.buffer.slice(0,this.position):this.buffer.toString("binary",0,this.position)},t.prototype.length=function(){return this.position},t.prototype.toJSON=function(){return this.buffer.toString("base64")},t.prototype.toString=function(t){return this.buffer.toString(t)},t.prototype.toExtendedJSON=function(t){t=t||{};var e=this.buffer.toString("base64"),n=Number(this.sub_type).toString(16);return t.legacy?{$binary:e,$type:1===n.length?"0"+n:n}:{$binary:{base64:e,subType:1===n.length?"0"+n:n}}},t.prototype.toUUID=function(){if(this.sub_type===t.SUBTYPE_UUID)return new _e(this.buffer.slice(0,this.position));throw new ne('Binary sub_type "'.concat(this.sub_type,'" is not supported for converting to UUID. Only "').concat(t.SUBTYPE_UUID,'" is currently supported.'))},t.fromExtendedJSON=function(e,n){var r,o;if(n=n||{},"$binary"in e?n.legacy&&"string"==typeof e.$binary&&"$type"in e?(o=e.$type?parseInt(e.$type,16):0,r=Qt.from(e.$binary,"base64")):"string"!=typeof e.$binary&&(o=e.$binary.subType?parseInt(e.$binary.subType,16):0,r=Qt.from(e.$binary.base64,"base64")):"$uuid"in e&&(o=4,r=de(e.$uuid)),!r)throw new re("Unexpected Binary Extended JSON format ".concat(JSON.stringify(e)));return 4===o?new _e(r):new t(r,o)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){var t=this.value(!0);return'new Binary(Buffer.from("'.concat(t.toString("hex"),'", "hex"), ').concat(this.sub_type,")")},t.BSON_BINARY_SUBTYPE_DEFAULT=0,t.BUFFER_SIZE=256,t.SUBTYPE_DEFAULT=0,t.SUBTYPE_FUNCTION=1,t.SUBTYPE_BYTE_ARRAY=2,t.SUBTYPE_UUID_OLD=3,t.SUBTYPE_UUID=4,t.SUBTYPE_MD5=5,t.SUBTYPE_ENCRYPTED=6,t.SUBTYPE_COLUMN=7,t.SUBTYPE_USER_DEFINED=128,t}();Object.defineProperty(me.prototype,"_bsontype",{value:"Binary"});var _e=function(t){function e(n){var r,o,i=this;if(null==n)r=e.generate();else if(n instanceof e)r=Qt.from(n.buffer),o=n.__id;else if(ArrayBuffer.isView(n)&&16===n.byteLength)r=le(n);else{if("string"!=typeof n)throw new re("Argument passed in UUID constructor must be a UUID, a 16 byte Buffer or a 32/36 character hex string (dashes excluded/included, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).");r=de(n)}return(i=t.call(this,r,4)||this).__id=o,i}return ee(e,t),Object.defineProperty(e.prototype,"id",{get:function(){return this.buffer},set:function(t){this.buffer=t,e.cacheHexString&&(this.__id=ye(t))},enumerable:!1,configurable:!0}),e.prototype.toHexString=function(t){if(void 0===t&&(t=!0),e.cacheHexString&&this.__id)return this.__id;var n=ye(this.id,t);return e.cacheHexString&&(this.__id=n),n},e.prototype.toString=function(t){return t?this.id.toString(t):this.toHexString()},e.prototype.toJSON=function(){return this.toHexString()},e.prototype.equals=function(t){if(!t)return!1;if(t instanceof e)return t.id.equals(this.id);try{return new e(t).id.equals(this.id)}catch(t){return!1}},e.prototype.toBinary=function(){return new me(this.id,me.SUBTYPE_UUID)},e.generate=function(){var t=ae(16);return t[6]=15&t[6]|64,t[8]=63&t[8]|128,Qt.from(t)},e.isValid=function(t){return!!t&&(t instanceof e||("string"==typeof t?pe(t):!(!ce(t)||16!==t.length||64!=(240&t[6])||128&~t[8])))},e.createFromHexString=function(t){return new e(de(t))},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return'new UUID("'.concat(this.toHexString(),'")')},e}(me),we=function(){function t(e,n){if(!(this instanceof t))return new t(e,n);this.code=e,this.scope=n}return t.prototype.toJSON=function(){return{code:this.code,scope:this.scope}},t.prototype.toExtendedJSON=function(){return this.scope?{$code:this.code,$scope:this.scope}:{$code:this.code}},t.fromExtendedJSON=function(e){return new t(e.$code,e.$scope)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){var t=this.toJSON();return'new Code("'.concat(String(t.code),'"').concat(t.scope?", ".concat(JSON.stringify(t.scope)):"",")")},t}();Object.defineProperty(we.prototype,"_bsontype",{value:"Code"});var be=function(){function t(e,n,r,o){if(!(this instanceof t))return new t(e,n,r,o);var i=e.split(".");2===i.length&&(r=i.shift(),e=i.shift()),this.collection=e,this.oid=n,this.db=r,this.fields=o||{}}return Object.defineProperty(t.prototype,"namespace",{get:function(){return this.collection},set:function(t){this.collection=t},enumerable:!1,configurable:!0}),t.prototype.toJSON=function(){var t=Object.assign({$ref:this.collection,$id:this.oid},this.fields);return null!=this.db&&(t.$db=this.db),t},t.prototype.toExtendedJSON=function(t){t=t||{};var e={$ref:this.collection,$id:this.oid};return t.legacy?e:(this.db&&(e.$db=this.db),e=Object.assign(e,this.fields))},t.fromExtendedJSON=function(e){var n=Object.assign({},e);return delete n.$ref,delete n.$id,delete n.$db,new t(e.$ref,e.$id,e.$db,n)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){var t=void 0===this.oid||void 0===this.oid.toString?this.oid:this.oid.toString();return'new DBRef("'.concat(this.namespace,'", new ObjectId("').concat(String(t),'")').concat(this.db?', "'.concat(this.db,'"'):"",")")},t}();Object.defineProperty(be.prototype,"_bsontype",{value:"DBRef"});var Ee=void 0;try{Ee=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(r){}var Se=4294967296,Ie=0x10000000000000000,Oe=Ie/2,Ae={},Te={},Ne=function(){function t(e,n,r){if(void 0===e&&(e=0),!(this instanceof t))return new t(e,n,r);"bigint"==typeof e?Object.assign(this,t.fromBigInt(e,!!n)):"string"==typeof e?Object.assign(this,t.fromString(e,!!n)):(this.low=0|e,this.high=0|n,this.unsigned=!!r),Object.defineProperty(this,"__isLong__",{value:!0,configurable:!1,writable:!1,enumerable:!1})}return t.fromBits=function(e,n,r){return new t(e,n,r)},t.fromInt=function(e,n){var r,o,i;return n?(i=0<=(e>>>=0)&&e<256)&&(o=Te[e])?o:(r=t.fromBits(e,(0|e)<0?-1:0,!0),i&&(Te[e]=r),r):(i=-128<=(e|=0)&&e<128)&&(o=Ae[e])?o:(r=t.fromBits(e,e<0?-1:0,!1),i&&(Ae[e]=r),r)},t.fromNumber=function(e,n){if(isNaN(e))return n?t.UZERO:t.ZERO;if(n){if(e<0)return t.UZERO;if(e>=Ie)return t.MAX_UNSIGNED_VALUE}else{if(e<=-Oe)return t.MIN_VALUE;if(e+1>=Oe)return t.MAX_VALUE}return e<0?t.fromNumber(-e,n).neg():t.fromBits(e%Se|0,e/Se|0,n)},t.fromBigInt=function(e,n){return t.fromString(e.toString(),n)},t.fromString=function(e,n,r){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t.ZERO;if("number"==typeof n?(r=n,n=!1):n=!!n,(r=r||10)<2||36<r)throw RangeError("radix");var o;if((o=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===o)return t.fromString(e.substring(1),n,r).neg();for(var i=t.fromNumber(Math.pow(r,8)),s=t.ZERO,a=0;a<e.length;a+=8){var c=Math.min(8,e.length-a),u=parseInt(e.substring(a,a+c),r);if(c<8){var f=t.fromNumber(Math.pow(r,c));s=s.mul(f).add(t.fromNumber(u))}else s=(s=s.mul(i)).add(t.fromNumber(u))}return s.unsigned=n,s},t.fromBytes=function(e,n,r){return r?t.fromBytesLE(e,n):t.fromBytesBE(e,n)},t.fromBytesLE=function(e,n){return new t(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,n)},t.fromBytesBE=function(e,n){return new t(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],n)},t.isLong=function(t){return ue(t)&&!0===t.__isLong__},t.fromValue=function(e,n){return"number"==typeof e?t.fromNumber(e,n):"string"==typeof e?t.fromString(e,n):t.fromBits(e.low,e.high,"boolean"==typeof n?n:e.unsigned)},t.prototype.add=function(e){t.isLong(e)||(e=t.fromValue(e));var n=this.high>>>16,r=65535&this.high,o=this.low>>>16,i=65535&this.low,s=e.high>>>16,a=65535&e.high,c=e.low>>>16,u=0,f=0,l=0,h=0;return l+=(h+=i+(65535&e.low))>>>16,h&=65535,f+=(l+=o+c)>>>16,l&=65535,u+=(f+=r+a)>>>16,f&=65535,u+=n+s,u&=65535,t.fromBits(l<<16|h,u<<16|f,this.unsigned)},t.prototype.and=function(e){return t.isLong(e)||(e=t.fromValue(e)),t.fromBits(this.low&e.low,this.high&e.high,this.unsigned)},t.prototype.compare=function(e){if(t.isLong(e)||(e=t.fromValue(e)),this.eq(e))return 0;var n=this.isNegative(),r=e.isNegative();return n&&!r?-1:!n&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},t.prototype.comp=function(t){return this.compare(t)},t.prototype.divide=function(e){if(t.isLong(e)||(e=t.fromValue(e)),e.isZero())throw Error("division by zero");if(Ee){if(!this.unsigned&&-2147483648===this.high&&-1===e.low&&-1===e.high)return this;var n=(this.unsigned?Ee.div_u:Ee.div_s)(this.low,this.high,e.low,e.high);return t.fromBits(n,Ee.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?t.UZERO:t.ZERO;var r,o,i;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return t.UZERO;if(e.gt(this.shru(1)))return t.UONE;i=t.UZERO}else{if(this.eq(t.MIN_VALUE))return e.eq(t.ONE)||e.eq(t.NEG_ONE)?t.MIN_VALUE:e.eq(t.MIN_VALUE)?t.ONE:(r=this.shr(1).div(e).shl(1)).eq(t.ZERO)?e.isNegative()?t.ONE:t.NEG_ONE:(o=this.sub(e.mul(r)),i=r.add(o.div(e)));if(e.eq(t.MIN_VALUE))return this.unsigned?t.UZERO:t.ZERO;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();i=t.ZERO}for(o=this;o.gte(e);){r=Math.max(1,Math.floor(o.toNumber()/e.toNumber()));for(var s=Math.ceil(Math.log(r)/Math.LN2),a=s<=48?1:Math.pow(2,s-48),c=t.fromNumber(r),u=c.mul(e);u.isNegative()||u.gt(o);)r-=a,u=(c=t.fromNumber(r,this.unsigned)).mul(e);c.isZero()&&(c=t.ONE),i=i.add(c),o=o.sub(u)}return i},t.prototype.div=function(t){return this.divide(t)},t.prototype.equals=function(e){return t.isLong(e)||(e=t.fromValue(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&this.high===e.high&&this.low===e.low},t.prototype.eq=function(t){return this.equals(t)},t.prototype.getHighBits=function(){return this.high},t.prototype.getHighBitsUnsigned=function(){return this.high>>>0},t.prototype.getLowBits=function(){return this.low},t.prototype.getLowBitsUnsigned=function(){return this.low>>>0},t.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.eq(t.MIN_VALUE)?64:this.neg().getNumBitsAbs();var e,n=0!==this.high?this.high:this.low;for(e=31;e>0&&!(n&1<<e);e--);return 0!==this.high?e+33:e+1},t.prototype.greaterThan=function(t){return this.comp(t)>0},t.prototype.gt=function(t){return this.greaterThan(t)},t.prototype.greaterThanOrEqual=function(t){return this.comp(t)>=0},t.prototype.gte=function(t){return this.greaterThanOrEqual(t)},t.prototype.ge=function(t){return this.greaterThanOrEqual(t)},t.prototype.isEven=function(){return!(1&this.low)},t.prototype.isNegative=function(){return!this.unsigned&&this.high<0},t.prototype.isOdd=function(){return!(1&~this.low)},t.prototype.isPositive=function(){return this.unsigned||this.high>=0},t.prototype.isZero=function(){return 0===this.high&&0===this.low},t.prototype.lessThan=function(t){return this.comp(t)<0},t.prototype.lt=function(t){return this.lessThan(t)},t.prototype.lessThanOrEqual=function(t){return this.comp(t)<=0},t.prototype.lte=function(t){return this.lessThanOrEqual(t)},t.prototype.modulo=function(e){if(t.isLong(e)||(e=t.fromValue(e)),Ee){var n=(this.unsigned?Ee.rem_u:Ee.rem_s)(this.low,this.high,e.low,e.high);return t.fromBits(n,Ee.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))},t.prototype.mod=function(t){return this.modulo(t)},t.prototype.rem=function(t){return this.modulo(t)},t.prototype.multiply=function(e){if(this.isZero())return t.ZERO;if(t.isLong(e)||(e=t.fromValue(e)),Ee){var n=Ee.mul(this.low,this.high,e.low,e.high);return t.fromBits(n,Ee.get_high(),this.unsigned)}if(e.isZero())return t.ZERO;if(this.eq(t.MIN_VALUE))return e.isOdd()?t.MIN_VALUE:t.ZERO;if(e.eq(t.MIN_VALUE))return this.isOdd()?t.MIN_VALUE:t.ZERO;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(t.TWO_PWR_24)&&e.lt(t.TWO_PWR_24))return t.fromNumber(this.toNumber()*e.toNumber(),this.unsigned);var r=this.high>>>16,o=65535&this.high,i=this.low>>>16,s=65535&this.low,a=e.high>>>16,c=65535&e.high,u=e.low>>>16,f=65535&e.low,l=0,h=0,p=0,d=0;return p+=(d+=s*f)>>>16,d&=65535,h+=(p+=i*f)>>>16,p&=65535,h+=(p+=s*u)>>>16,p&=65535,l+=(h+=o*f)>>>16,h&=65535,l+=(h+=i*u)>>>16,h&=65535,l+=(h+=s*c)>>>16,h&=65535,l+=r*f+o*u+i*c+s*a,l&=65535,t.fromBits(p<<16|d,l<<16|h,this.unsigned)},t.prototype.mul=function(t){return this.multiply(t)},t.prototype.negate=function(){return!this.unsigned&&this.eq(t.MIN_VALUE)?t.MIN_VALUE:this.not().add(t.ONE)},t.prototype.neg=function(){return this.negate()},t.prototype.not=function(){return t.fromBits(~this.low,~this.high,this.unsigned)},t.prototype.notEquals=function(t){return!this.equals(t)},t.prototype.neq=function(t){return this.notEquals(t)},t.prototype.ne=function(t){return this.notEquals(t)},t.prototype.or=function(e){return t.isLong(e)||(e=t.fromValue(e)),t.fromBits(this.low|e.low,this.high|e.high,this.unsigned)},t.prototype.shiftLeft=function(e){return t.isLong(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?t.fromBits(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):t.fromBits(0,this.low<<e-32,this.unsigned)},t.prototype.shl=function(t){return this.shiftLeft(t)},t.prototype.shiftRight=function(e){return t.isLong(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?t.fromBits(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):t.fromBits(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},t.prototype.shr=function(t){return this.shiftRight(t)},t.prototype.shiftRightUnsigned=function(e){if(t.isLong(e)&&(e=e.toInt()),0==(e&=63))return this;var n=this.high;if(e<32){var r=this.low;return t.fromBits(r>>>e|n<<32-e,n>>>e,this.unsigned)}return 32===e?t.fromBits(n,0,this.unsigned):t.fromBits(n>>>e-32,0,this.unsigned)},t.prototype.shr_u=function(t){return this.shiftRightUnsigned(t)},t.prototype.shru=function(t){return this.shiftRightUnsigned(t)},t.prototype.subtract=function(e){return t.isLong(e)||(e=t.fromValue(e)),this.add(e.neg())},t.prototype.sub=function(t){return this.subtract(t)},t.prototype.toInt=function(){return this.unsigned?this.low>>>0:this.low},t.prototype.toNumber=function(){return this.unsigned?(this.high>>>0)*Se+(this.low>>>0):this.high*Se+(this.low>>>0)},t.prototype.toBigInt=function(){return BigInt(this.toString())},t.prototype.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()},t.prototype.toBytesLE=function(){var t=this.high,e=this.low;return[255&e,e>>>8&255,e>>>16&255,e>>>24,255&t,t>>>8&255,t>>>16&255,t>>>24]},t.prototype.toBytesBE=function(){var t=this.high,e=this.low;return[t>>>24,t>>>16&255,t>>>8&255,255&t,e>>>24,e>>>16&255,e>>>8&255,255&e]},t.prototype.toSigned=function(){return this.unsigned?t.fromBits(this.low,this.high,!1):this},t.prototype.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(t.MIN_VALUE)){var n=t.fromNumber(e),r=this.div(n),o=r.mul(n).sub(this);return r.toString(e)+o.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var i=t.fromNumber(Math.pow(e,6),this.unsigned),s=this,a="";;){var c=s.div(i),u=(s.sub(c.mul(i)).toInt()>>>0).toString(e);if((s=c).isZero())return u+a;for(;u.length<6;)u="0"+u;a=""+u+a}},t.prototype.toUnsigned=function(){return this.unsigned?this:t.fromBits(this.low,this.high,!0)},t.prototype.xor=function(e){return t.isLong(e)||(e=t.fromValue(e)),t.fromBits(this.low^e.low,this.high^e.high,this.unsigned)},t.prototype.eqz=function(){return this.isZero()},t.prototype.le=function(t){return this.lessThanOrEqual(t)},t.prototype.toExtendedJSON=function(t){return t&&t.relaxed?this.toNumber():{$numberLong:this.toString()}},t.fromExtendedJSON=function(e,n){var r=t.fromString(e.$numberLong);return n&&n.relaxed?r.toNumber():r},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return'new Long("'.concat(this.toString(),'"').concat(this.unsigned?", true":"",")")},t.TWO_PWR_24=t.fromInt(16777216),t.MAX_UNSIGNED_VALUE=t.fromBits(-1,-1,!0),t.ZERO=t.fromInt(0),t.UZERO=t.fromInt(0,!0),t.ONE=t.fromInt(1),t.UONE=t.fromInt(1,!0),t.NEG_ONE=t.fromInt(-1),t.MAX_VALUE=t.fromBits(-1,2147483647,!1),t.MIN_VALUE=t.fromBits(0,-2147483648,!1),t}();Object.defineProperty(Ne.prototype,"__isLong__",{value:!0}),Object.defineProperty(Ne.prototype,"_bsontype",{value:"Long"});var Re=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,Pe=/^(\+|-)?(Infinity|inf)$/i,xe=/^(\+|-)?NaN$/i,Le=6111,Ce=-6176,ke=[124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),Ue=[248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),je=[120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),De=/^([-+])?(\d+)?$/;function Me(t){return!isNaN(parseInt(t,10))}function qe(t){var e=Ne.fromNumber(1e9),n=Ne.fromNumber(0);if(!(t.parts[0]||t.parts[1]||t.parts[2]||t.parts[3]))return{quotient:t,rem:n};for(var r=0;r<=3;r++)n=(n=n.shiftLeft(32)).add(new Ne(t.parts[r],0)),t.parts[r]=n.div(e).low,n=n.modulo(e);return{quotient:t,rem:n}}function Be(t,e){throw new re('"'.concat(t,'" is not a valid Decimal128 string - ').concat(e))}var Fe=function(){function t(e){if(!(this instanceof t))return new t(e);if("string"==typeof e)this.bytes=t.fromString(e).bytes;else{if(!ce(e))throw new re("Decimal128 must take a Buffer or string");if(16!==e.byteLength)throw new re("Decimal128 must take a Buffer of 16 bytes");this.bytes=e}}return t.fromString=function(e){var n,r=!1,o=!1,i=!1,s=0,a=0,c=0,u=0,f=0,l=[0],h=0,p=0,d=0,y=0,g=0,v=0,m=new Ne(0,0),_=new Ne(0,0),w=0;if(e.length>=7e3)throw new re(e+" not a valid Decimal128 string");var b=e.match(Re),E=e.match(Pe),S=e.match(xe);if(!b&&!E&&!S||0===e.length)throw new re(e+" not a valid Decimal128 string");if(b){var I=b[2],O=b[4],A=b[5],T=b[6];O&&void 0===T&&Be(e,"missing exponent power"),O&&void 0===I&&Be(e,"missing exponent base"),void 0===O&&(A||T)&&Be(e,"missing e before exponent")}if("+"!==e[w]&&"-"!==e[w]||(r="-"===e[w++]),!Me(e[w])&&"."!==e[w]){if("i"===e[w]||"I"===e[w])return new t(Qt.from(r?Ue:je));if("N"===e[w])return new t(Qt.from(ke))}for(;Me(e[w])||"."===e[w];)"."!==e[w]?(h<34&&("0"!==e[w]||i)&&(i||(f=a),i=!0,l[p++]=parseInt(e[w],10),h+=1),i&&(c+=1),o&&(u+=1),a+=1,w+=1):(o&&Be(e,"contains multiple periods"),o=!0,w+=1);if(o&&!a)throw new re(e+" not a valid Decimal128 string");if("e"===e[w]||"E"===e[w]){var N=e.substr(++w).match(De);if(!N||!N[2])return new t(Qt.from(ke));g=parseInt(N[0],10),w+=N[0].length}if(e[w])return new t(Qt.from(ke));if(d=0,h){if(y=h-1,1!==(s=c))for(;0===l[f+s-1];)s-=1}else d=0,y=0,l[0]=0,c=1,h=1,s=0;for(g<=u&&u-g>16384?g=Ce:g-=u;g>Le;){if((y+=1)-d>34){if(l.join("").match(/^0+$/)){g=Le;break}Be(e,"overflow")}g-=1}for(;g<Ce||h<c;){if(0===y&&s<h){g=Ce,s=0;break}if(h<c?c-=1:y-=1,g<Le)g+=1;else{if(l.join("").match(/^0+$/)){g=Le;break}Be(e,"overflow")}}if(y-d+1<s){var R=a;o&&(f+=1,R+=1),r&&(f+=1,R+=1);var P=parseInt(e[f+y+1],10),x=0;if(P>=5&&(x=1,5===P))for(x=l[y]%2==1?1:0,v=f+y+2;v<R;v++)if(parseInt(e[v],10)){x=1;break}if(x)for(var L=y;L>=0;L--)if(++l[L]>9&&(l[L]=0,0===L)){if(!(g<Le))return new t(Qt.from(r?Ue:je));g+=1,l[L]=1}}if(m=Ne.fromNumber(0),_=Ne.fromNumber(0),0===s)m=Ne.fromNumber(0),_=Ne.fromNumber(0);else if(y-d<17)for(L=d,_=Ne.fromNumber(l[L++]),m=new Ne(0,0);L<=y;L++)_=(_=_.multiply(Ne.fromNumber(10))).add(Ne.fromNumber(l[L]));else{for(L=d,m=Ne.fromNumber(l[L++]);L<=y-17;L++)m=(m=m.multiply(Ne.fromNumber(10))).add(Ne.fromNumber(l[L]));for(_=Ne.fromNumber(l[L++]);L<=y;L++)_=(_=_.multiply(Ne.fromNumber(10))).add(Ne.fromNumber(l[L]))}var C,k,U,j,D=function(t,e){if(!t&&!e)return{high:Ne.fromNumber(0),low:Ne.fromNumber(0)};var n=t.shiftRightUnsigned(32),r=new Ne(t.getLowBits(),0),o=e.shiftRightUnsigned(32),i=new Ne(e.getLowBits(),0),s=n.multiply(o),a=n.multiply(i),c=r.multiply(o),u=r.multiply(i);return s=s.add(a.shiftRightUnsigned(32)),a=new Ne(a.getLowBits(),0).add(c).add(u.shiftRightUnsigned(32)),{high:s=s.add(a.shiftRightUnsigned(32)),low:u=a.shiftLeft(32).add(new Ne(u.getLowBits(),0))}}(m,Ne.fromString("100000000000000000"));D.low=D.low.add(_),k=_,((U=(C=D.low).high>>>0)<(j=k.high>>>0)||U===j&&C.low>>>0<k.low>>>0)&&(D.high=D.high.add(Ne.fromNumber(1))),n=g+6176;var M={low:Ne.fromNumber(0),high:Ne.fromNumber(0)};D.high.shiftRightUnsigned(49).and(Ne.fromNumber(1)).equals(Ne.fromNumber(1))?(M.high=M.high.or(Ne.fromNumber(3).shiftLeft(61)),M.high=M.high.or(Ne.fromNumber(n).and(Ne.fromNumber(16383).shiftLeft(47))),M.high=M.high.or(D.high.and(Ne.fromNumber(0x7fffffffffff)))):(M.high=M.high.or(Ne.fromNumber(16383&n).shiftLeft(49)),M.high=M.high.or(D.high.and(Ne.fromNumber(562949953421311)))),M.low=D.low,r&&(M.high=M.high.or(Ne.fromString("9223372036854775808")));var q=Qt.alloc(16);return w=0,q[w++]=255&M.low.low,q[w++]=M.low.low>>8&255,q[w++]=M.low.low>>16&255,q[w++]=M.low.low>>24&255,q[w++]=255&M.low.high,q[w++]=M.low.high>>8&255,q[w++]=M.low.high>>16&255,q[w++]=M.low.high>>24&255,q[w++]=255&M.high.low,q[w++]=M.high.low>>8&255,q[w++]=M.high.low>>16&255,q[w++]=M.high.low>>24&255,q[w++]=255&M.high.high,q[w++]=M.high.high>>8&255,q[w++]=M.high.high>>16&255,q[w++]=M.high.high>>24&255,new t(q)},t.prototype.toString=function(){for(var t,e=0,n=new Array(36),r=0;r<n.length;r++)n[r]=0;var o,i,s,a=0,c=!1,u={parts:[0,0,0,0]},f=[];a=0;var l=this.bytes,h=l[a++]|l[a++]<<8|l[a++]<<16|l[a++]<<24,p=l[a++]|l[a++]<<8|l[a++]<<16|l[a++]<<24,d=l[a++]|l[a++]<<8|l[a++]<<16|l[a++]<<24,y=l[a++]|l[a++]<<8|l[a++]<<16|l[a++]<<24;a=0,(new Ne(h,p),new Ne(d,y)).lessThan(Ne.ZERO)&&f.push("-");var g=y>>26&31;if(g>>3==3){if(30===g)return f.join("")+"Infinity";if(31===g)return"NaN";t=y>>15&16383,o=8+(y>>14&1)}else o=y>>14&7,t=y>>17&16383;var v=t-6176;if(u.parts[0]=(16383&y)+((15&o)<<14),u.parts[1]=d,u.parts[2]=p,u.parts[3]=h,0===u.parts[0]&&0===u.parts[1]&&0===u.parts[2]&&0===u.parts[3])c=!0;else for(s=3;s>=0;s--){var m=0,_=qe(u);if(u=_.quotient,m=_.rem.low)for(i=8;i>=0;i--)n[9*s+i]=m%10,m=Math.floor(m/10)}if(c)e=1,n[a]=0;else for(e=36;!n[a];)e-=1,a+=1;var w=e-1+v;if(w>=34||w<=-7||v>0){if(e>34)return f.push("".concat(0)),v>0?f.push("E+".concat(v)):v<0&&f.push("E".concat(v)),f.join("");for(f.push("".concat(n[a++])),(e-=1)&&f.push("."),r=0;r<e;r++)f.push("".concat(n[a++]));f.push("E"),w>0?f.push("+".concat(w)):f.push("".concat(w))}else if(v>=0)for(r=0;r<e;r++)f.push("".concat(n[a++]));else{var b=e+v;if(b>0)for(r=0;r<b;r++)f.push("".concat(n[a++]));else f.push("0");for(f.push(".");b++<0;)f.push("0");for(r=0;r<e-Math.max(b-1,0);r++)f.push("".concat(n[a++]))}return f.join("")},t.prototype.toJSON=function(){return{$numberDecimal:this.toString()}},t.prototype.toExtendedJSON=function(){return{$numberDecimal:this.toString()}},t.fromExtendedJSON=function(e){return t.fromString(e.$numberDecimal)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return'new Decimal128("'.concat(this.toString(),'")')},t}();Object.defineProperty(Fe.prototype,"_bsontype",{value:"Decimal128"});var We=function(){function t(e){if(!(this instanceof t))return new t(e);e instanceof Number&&(e=e.valueOf()),this.value=+e}return t.prototype.valueOf=function(){return this.value},t.prototype.toJSON=function(){return this.value},t.prototype.toString=function(t){return this.value.toString(t)},t.prototype.toExtendedJSON=function(t){return t&&(t.legacy||t.relaxed&&isFinite(this.value))?this.value:Object.is(Math.sign(this.value),-0)?{$numberDouble:"-".concat(this.value.toFixed(1))}:{$numberDouble:Number.isInteger(this.value)?this.value.toFixed(1):this.value.toString()}},t.fromExtendedJSON=function(e,n){var r=parseFloat(e.$numberDouble);return n&&n.relaxed?r:new t(r)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){var t=this.toExtendedJSON();return"new Double(".concat(t.$numberDouble,")")},t}();Object.defineProperty(We.prototype,"_bsontype",{value:"Double"});var $e=function(){function t(e){if(!(this instanceof t))return new t(e);e instanceof Number&&(e=e.valueOf()),this.value=0|+e}return t.prototype.valueOf=function(){return this.value},t.prototype.toString=function(t){return this.value.toString(t)},t.prototype.toJSON=function(){return this.value},t.prototype.toExtendedJSON=function(t){return t&&(t.relaxed||t.legacy)?this.value:{$numberInt:this.value.toString()}},t.fromExtendedJSON=function(e,n){return n&&n.relaxed?parseInt(e.$numberInt,10):new t(e.$numberInt)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return"new Int32(".concat(this.valueOf(),")")},t}();Object.defineProperty($e.prototype,"_bsontype",{value:"Int32"});var He=function(){function t(){if(!(this instanceof t))return new t}return t.prototype.toExtendedJSON=function(){return{$maxKey:1}},t.fromExtendedJSON=function(){return new t},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return"new MaxKey()"},t}();Object.defineProperty(He.prototype,"_bsontype",{value:"MaxKey"});var Ge=function(){function t(){if(!(this instanceof t))return new t}return t.prototype.toExtendedJSON=function(){return{$minKey:1}},t.fromExtendedJSON=function(){return new t},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return"new MinKey()"},t}();Object.defineProperty(Ge.prototype,"_bsontype",{value:"MinKey"});var Ke=new RegExp("^[0-9a-fA-F]{24}$"),Ve=null,Je=Symbol("id"),Ye=function(){function t(e){if(!(this instanceof t))return new t(e);var n;if("object"==typeof e&&e&&"id"in e){if("string"!=typeof e.id&&!ArrayBuffer.isView(e.id))throw new re("Argument passed in must have an id that is of type string or Buffer");n="toHexString"in e&&"function"==typeof e.toHexString?Qt.from(e.toHexString(),"hex"):e.id}else n=e;if(null==n||"number"==typeof n)this[Je]=t.generate("number"==typeof n?n:void 0);else if(ArrayBuffer.isView(n)&&12===n.byteLength)this[Je]=n instanceof Qt?n:le(n);else{if("string"!=typeof n)throw new re("Argument passed in does not match the accepted types");if(12===n.length){var r=Qt.from(n);if(12!==r.byteLength)throw new re("Argument passed in must be a string of 12 bytes");this[Je]=r}else{if(24!==n.length||!Ke.test(n))throw new re("Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer");this[Je]=Qt.from(n,"hex")}}t.cacheHexString&&(this.__id=this.id.toString("hex"))}return Object.defineProperty(t.prototype,"id",{get:function(){return this[Je]},set:function(e){this[Je]=e,t.cacheHexString&&(this.__id=e.toString("hex"))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"generationTime",{get:function(){return this.id.readInt32BE(0)},set:function(t){this.id.writeUInt32BE(t,0)},enumerable:!1,configurable:!0}),t.prototype.toHexString=function(){if(t.cacheHexString&&this.__id)return this.__id;var e=this.id.toString("hex");return t.cacheHexString&&!this.__id&&(this.__id=e),e},t.getInc=function(){return t.index=(t.index+1)%16777215},t.generate=function(e){"number"!=typeof e&&(e=Math.floor(Date.now()/1e3));var n=t.getInc(),r=Qt.alloc(12);return r.writeUInt32BE(e,0),null===Ve&&(Ve=ae(5)),r[4]=Ve[0],r[5]=Ve[1],r[6]=Ve[2],r[7]=Ve[3],r[8]=Ve[4],r[11]=255&n,r[10]=n>>8&255,r[9]=n>>16&255,r},t.prototype.toString=function(t){return t?this.id.toString(t):this.toHexString()},t.prototype.toJSON=function(){return this.toHexString()},t.prototype.equals=function(e){if(null==e)return!1;if(e instanceof t)return this[Je][11]===e[Je][11]&&this[Je].equals(e[Je]);if("string"==typeof e&&t.isValid(e)&&12===e.length&&ce(this.id))return e===Qt.prototype.toString.call(this.id,"latin1");if("string"==typeof e&&t.isValid(e)&&24===e.length)return e.toLowerCase()===this.toHexString();if("string"==typeof e&&t.isValid(e)&&12===e.length)return Qt.from(e).equals(this.id);if("object"==typeof e&&"toHexString"in e&&"function"==typeof e.toHexString){var n=e.toHexString(),r=this.toHexString().toLowerCase();return"string"==typeof n&&n.toLowerCase()===r}return!1},t.prototype.getTimestamp=function(){var t=new Date,e=this.id.readUInt32BE(0);return t.setTime(1e3*Math.floor(e)),t},t.createPk=function(){return new t},t.createFromTime=function(e){var n=Qt.from([0,0,0,0,0,0,0,0,0,0,0,0]);return n.writeUInt32BE(e,0),new t(n)},t.createFromHexString=function(e){if(void 0===e||null!=e&&24!==e.length)throw new re("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");return new t(Qt.from(e,"hex"))},t.isValid=function(e){if(null==e)return!1;try{return new t(e),!0}catch(t){return!1}},t.prototype.toExtendedJSON=function(){return this.toHexString?{$oid:this.toHexString()}:{$oid:this.toString("hex")}},t.fromExtendedJSON=function(e){return new t(e.$oid)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return'new ObjectId("'.concat(this.toHexString(),'")')},t.index=Math.floor(16777215*Math.random()),t}();Object.defineProperty(Ye.prototype,"generate",{value:fe((function(t){return Ye.generate(t)}),"Please use the static `ObjectId.generate(time)` instead")}),Object.defineProperty(Ye.prototype,"getInc",{value:fe((function(){return Ye.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(Ye.prototype,"get_inc",{value:fe((function(){return Ye.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(Ye,"get_inc",{value:fe((function(){return Ye.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(Ye.prototype,"_bsontype",{value:"ObjectID"});var ze=function(){function t(e,n){if(!(this instanceof t))return new t(e,n);if(this.pattern=e,this.options=(null!=n?n:"").split("").sort().join(""),-1!==this.pattern.indexOf("\0"))throw new ne("BSON Regex patterns cannot contain null bytes, found: ".concat(JSON.stringify(this.pattern)));if(-1!==this.options.indexOf("\0"))throw new ne("BSON Regex options cannot contain null bytes, found: ".concat(JSON.stringify(this.options)));for(var r=0;r<this.options.length;r++)if("i"!==this.options[r]&&"m"!==this.options[r]&&"x"!==this.options[r]&&"l"!==this.options[r]&&"s"!==this.options[r]&&"u"!==this.options[r])throw new ne("The regular expression option [".concat(this.options[r],"] is not supported"))}return t.parseOptions=function(t){return t?t.split("").sort().join(""):""},t.prototype.toExtendedJSON=function(t){return(t=t||{}).legacy?{$regex:this.pattern,$options:this.options}:{$regularExpression:{pattern:this.pattern,options:this.options}}},t.fromExtendedJSON=function(e){if("$regex"in e){if("string"==typeof e.$regex)return new t(e.$regex,t.parseOptions(e.$options));if("BSONRegExp"===e.$regex._bsontype)return e}if("$regularExpression"in e)return new t(e.$regularExpression.pattern,t.parseOptions(e.$regularExpression.options));throw new re("Unexpected BSONRegExp EJSON object form: ".concat(JSON.stringify(e)))},t}();Object.defineProperty(ze.prototype,"_bsontype",{value:"BSONRegExp"});var Xe=function(){function t(e){if(!(this instanceof t))return new t(e);this.value=e}return t.prototype.valueOf=function(){return this.value},t.prototype.toString=function(){return this.value},t.prototype.inspect=function(){return'new BSONSymbol("'.concat(this.value,'")')},t.prototype.toJSON=function(){return this.value},t.prototype.toExtendedJSON=function(){return{$symbol:this.value}},t.fromExtendedJSON=function(e){return new t(e.$symbol)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t}();Object.defineProperty(Xe.prototype,"_bsontype",{value:"Symbol"});var Ze=function(t){function e(n,r){var o=this;return o instanceof e?(o=Ne.isLong(n)?t.call(this,n.low,n.high,!0)||this:ue(n)&&void 0!==n.t&&void 0!==n.i?t.call(this,n.i,n.t,!0)||this:t.call(this,n,r,!0)||this,Object.defineProperty(o,"_bsontype",{value:"Timestamp",writable:!1,configurable:!1,enumerable:!1}),o):new e(n,r)}return ee(e,t),e.prototype.toJSON=function(){return{$timestamp:this.toString()}},e.fromInt=function(t){return new e(Ne.fromInt(t,!0))},e.fromNumber=function(t){return new e(Ne.fromNumber(t,!0))},e.fromBits=function(t,n){return new e(t,n)},e.fromString=function(t,n){return new e(Ne.fromString(t,!0,n))},e.prototype.toExtendedJSON=function(){return{$timestamp:{t:this.high>>>0,i:this.low>>>0}}},e.fromExtendedJSON=function(t){return new e(t.$timestamp)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return"new Timestamp({ t: ".concat(this.getHighBits(),", i: ").concat(this.getLowBits()," })")},e.MAX_VALUE=Ne.MAX_UNSIGNED_VALUE,e}(Ne);var Qe=2147483647,tn=-2147483648,en=0x8000000000000000,nn=-0x8000000000000000,rn={$oid:Ye,$binary:me,$uuid:me,$symbol:Xe,$numberInt:$e,$numberDecimal:Fe,$numberDouble:We,$numberLong:Ne,$minKey:Ge,$maxKey:He,$regex:ze,$regularExpression:ze,$timestamp:Ze};function on(t,e){if(void 0===e&&(e={}),"number"==typeof t){if(e.relaxed||e.legacy)return t;if(Math.floor(t)===t){if(t>=tn&&t<=Qe)return new $e(t);if(t>=nn&&t<=en)return Ne.fromNumber(t)}return new We(t)}if(null==t||"object"!=typeof t)return t;if(t.$undefined)return null;for(var n=Object.keys(t).filter((function(e){return e.startsWith("$")&&null!=t[e]})),r=0;r<n.length;r++){var o=rn[n[r]];if(o)return o.fromExtendedJSON(t,e)}if(null!=t.$date){var i=t.$date,s=new Date;return e.legacy?"number"==typeof i?s.setTime(i):"string"==typeof i&&s.setTime(Date.parse(i)):"string"==typeof i?s.setTime(Date.parse(i)):Ne.isLong(i)?s.setTime(i.toNumber()):"number"==typeof i&&e.relaxed&&s.setTime(i),s}if(null!=t.$code){var a=Object.assign({},t);return t.$scope&&(a.$scope=on(t.$scope)),we.fromExtendedJSON(t)}if(function(t){return ue(t)&&null!=t.$id&&"string"==typeof t.$ref&&(null==t.$db||"string"==typeof t.$db)}(t)||t.$dbPointer){var c=t.$ref?t:t.$dbPointer;if(c instanceof be)return c;var u=Object.keys(c).filter((function(t){return t.startsWith("$")})),f=!0;if(u.forEach((function(t){-1===["$ref","$id","$db"].indexOf(t)&&(f=!1)})),f)return be.fromExtendedJSON(c)}return t}function sn(t){var e=t.toISOString();return 0!==t.getUTCMilliseconds()?e:e.slice(0,-5)+"Z"}function an(t,e){if(("object"==typeof t||"function"==typeof t)&&null!==t){var n=e.seenObjects.findIndex((function(e){return e.obj===t}));if(-1!==n){var r=e.seenObjects.map((function(t){return t.propertyName})),o=r.slice(0,n).map((function(t){return"".concat(t," -> ")})).join(""),i=r[n],s=" -> "+r.slice(n+1,r.length-1).map((function(t){return"".concat(t," -> ")})).join(""),a=r[r.length-1],c=" ".repeat(o.length+i.length/2),u="-".repeat(s.length+(i.length+a.length)/2-1);throw new re("Converting circular structure to EJSON:\n"+" ".concat(o).concat(i).concat(s).concat(a,"\n")+" ".concat(c,"\\").concat(u,"/"))}e.seenObjects[e.seenObjects.length-1].obj=t}if(Array.isArray(t))return function(t,e){return t.map((function(t,n){e.seenObjects.push({propertyName:"index ".concat(n),obj:null});try{return an(t,e)}finally{e.seenObjects.pop()}}))}(t,e);if(void 0===t)return null;if(t instanceof Date||ue(h=t)&&"[object Date]"===Object.prototype.toString.call(h)){var f=t.getTime(),l=f>-1&&f<2534023188e5;return e.legacy?e.relaxed&&l?{$date:t.getTime()}:{$date:sn(t)}:e.relaxed&&l?{$date:sn(t)}:{$date:{$numberLong:t.getTime().toString()}}}var h;if(!("number"!=typeof t||e.relaxed&&isFinite(t))){if(Math.floor(t)===t){var p=t>=nn&&t<=en;if(t>=tn&&t<=Qe)return{$numberInt:t.toString()};if(p)return{$numberLong:t.toString()}}return{$numberDouble:t.toString()}}if(t instanceof RegExp||function(t){return"[object RegExp]"===Object.prototype.toString.call(t)}(t)){var d=t.flags;if(void 0===d){var y=t.toString().match(/[gimuy]*$/);y&&(d=y[0])}return new ze(t.source,d).toExtendedJSON(e)}return null!=t&&"object"==typeof t?function(t,e){if(null==t||"object"!=typeof t)throw new ne("not an object instance");var n=t._bsontype;if(void 0===n){var r={};for(var o in t){e.seenObjects.push({propertyName:o,obj:null});try{var i=an(t[o],e);"__proto__"===o?Object.defineProperty(r,o,{value:i,writable:!0,enumerable:!0,configurable:!0}):r[o]=i}finally{e.seenObjects.pop()}}return r}if(function(t){return ue(t)&&Reflect.has(t,"_bsontype")&&"string"==typeof t._bsontype}(t)){var s=t;if("function"!=typeof s.toExtendedJSON){var a=un[t._bsontype];if(!a)throw new re("Unrecognized or invalid _bsontype: "+t._bsontype);s=a(s)}return"Code"===n&&s.scope?s=new we(s.code,an(s.scope,e)):"DBRef"===n&&s.oid&&(s=new be(an(s.collection,e),an(s.oid,e),an(s.db,e),an(s.fields,e))),s.toExtendedJSON(e)}throw new ne("_bsontype must be a string, but was: "+typeof n)}(t,e):t}var cn,un={Binary:function(t){return new me(t.value(),t.sub_type)},Code:function(t){return new we(t.code,t.scope)},DBRef:function(t){return new be(t.collection||t.namespace,t.oid,t.db,t.fields)},Decimal128:function(t){return new Fe(t.bytes)},Double:function(t){return new We(t.value)},Int32:function(t){return new $e(t.value)},Long:function(t){return Ne.fromBits(null!=t.low?t.low:t.low_,null!=t.low?t.high:t.high_,null!=t.low?t.unsigned:t.unsigned_)},MaxKey:function(){return new He},MinKey:function(){return new Ge},ObjectID:function(t){return new Ye(t)},ObjectId:function(t){return new Ye(t)},BSONRegExp:function(t){return new ze(t.pattern,t.options)},Symbol:function(t){return new Xe(t.value)},Timestamp:function(t){return Ze.fromBits(t.low,t.high)}};!function(t){function e(t,e){var n=Object.assign({},{relaxed:!0,legacy:!1},e);return"boolean"==typeof n.relaxed&&(n.strict=!n.relaxed),"boolean"==typeof n.strict&&(n.relaxed=!n.strict),JSON.parse(t,(function(t,e){if(-1!==t.indexOf("\0"))throw new ne("BSON Document field names cannot contain null bytes, found: ".concat(JSON.stringify(t)));return on(e,n)}))}function n(t,e,n,r){null!=n&&"object"==typeof n&&(r=n,n=0),null==e||"object"!=typeof e||Array.isArray(e)||(r=e,e=void 0,n=0);var o=an(t,Object.assign({relaxed:!0,legacy:!1},r,{seenObjects:[{propertyName:"(root)",obj:null}]}));return JSON.stringify(o,e,n)}t.parse=e,t.stringify=n,t.serialize=function(t,e){return e=e||{},JSON.parse(n(t,e))},t.deserialize=function(t,n){return n=n||{},e(JSON.stringify(t),n)}}(cn||(cn={}));var fn=ie();fn.Map?fn.Map:function(){function t(t){void 0===t&&(t=[]),this._keys=[],this._values={};for(var e=0;e<t.length;e++)if(null!=t[e]){var n=t[e],r=n[0],o=n[1];this._keys.push(r),this._values[r]={v:o,i:this._keys.length-1}}}t.prototype.clear=function(){this._keys=[],this._values={}},t.prototype.delete=function(t){var e=this._values[t];return null!=e&&(delete this._values[t],this._keys.splice(e.i,1),!0)},t.prototype.entries=function(){var t=this,e=0;return{next:function(){var n=t._keys[e++];return{value:void 0!==n?[n,t._values[n].v]:void 0,done:void 0===n}}}},t.prototype.forEach=function(t,e){e=e||this;for(var n=0;n<this._keys.length;n++){var r=this._keys[n];t.call(e,this._values[r].v,r,e)}},t.prototype.get=function(t){return this._values[t]?this._values[t].v:void 0},t.prototype.has=function(t){return null!=this._values[t]},t.prototype.keys=function(){var t=this,e=0;return{next:function(){var n=t._keys[e++];return{value:void 0!==n?n:void 0,done:void 0===n}}}},t.prototype.set=function(t,e){return this._values[t]?(this._values[t].v=e,this):(this._keys.push(t),this._values[t]={v:e,i:this._keys.length-1},this)},t.prototype.values=function(){var t=this,e=0;return{next:function(){var n=t._keys[e++];return{value:void 0!==n?t._values[n].v:void 0,done:void 0===n}}}},Object.defineProperty(t.prototype,"size",{get:function(){return this._keys.length},enumerable:!1,configurable:!0})}(),Ne.fromNumber(ge),Ne.fromNumber(ve),new Set(["$db","$ref","$id","$clusterTime"]);var ln=new Uint8Array(8);new DataView(ln.buffer,ln.byteOffset,ln.byteLength);Qt.alloc(17825792);var hn=function(){function t(t,e){this._stages=[],t&&e&&(this._db=t,this._request=new Un.reqClass(this._db.config),this._collectionName=e)}return t.prototype.end=function(){return t=this,e=void 0,r=function(){var t;return function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}(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.aggregate",{collectionName:this._collectionName,stages:this._stages})];case 1:return(t=e.sent())&&t.data&&t.data.list?[2,{requestId:t.requestId,data:JSON.parse(t.data.list).map(cn.parse)}]:[2,t]}}))},new((n=void 0)||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}));var t,e,n,r},t.prototype.unwrap=function(){return this._stages},t.prototype.done=function(){return this._stages.map((function(t){var e,n=t.stageKey,r=t.stageValue;return(e={})[n]=JSON.parse(r),e}))},t.prototype._pipe=function(t,e){return this._stages.push({stageKey:"$"+t,stageValue:JSON.stringify(e)}),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=Dt.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",Dt.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}(),pn=hn,dn=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)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),yn=function(t){function e(e,n){return t.call(this,e,n)||this}return dn(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return this._coll},enumerable:!0,configurable:!0}),e.prototype.doc=function(t){if("string"!=typeof t&&"number"!=typeof t)throw new Error("docId必须为字符串或数字");return new jt(this._db,this._coll,t)},e.prototype.add=function(t,e){return new jt(this._db,this._coll,void 0).create(t,e)},e.prototype.aggregate=function(){return new pn(this._db,this._coll)},e}(Bt),gn={eq:function(t){return new pt(lt.EQ,[t])},neq:function(t){return new pt(lt.NEQ,[t])},lt:function(t){return new pt(lt.LT,[t])},lte:function(t){return new pt(lt.LTE,[t])},gt:function(t){return new pt(lt.GT,[t])},gte:function(t){return new pt(lt.GTE,[t])},in:function(t){return new pt(lt.IN,t)},nin:function(t){return new pt(lt.NIN,t)},all:function(t){return new pt(lt.ALL,t)},elemMatch:function(t){return new pt(lt.ELEM_MATCH,[t])},exists:function(t){return new pt(lt.EXISTS,[t])},size:function(t){return new pt(lt.SIZE,[t])},mod:function(t){return new pt(lt.MOD,[t])},geoNear:function(t){return new pt(lt.GEO_NEAR,[t])},geoWithin:function(t){return new pt(lt.GEO_WITHIN,[t])},geoIntersects:function(t){return new pt(lt.GEO_INTERSECTS,[t])},and:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=B(arguments[0])?arguments[0]:Array.from(arguments);return new ut(st.AND,n)},nor:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=B(arguments[0])?arguments[0]:Array.from(arguments);return new ut(st.NOR,n)},or:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=B(arguments[0])?arguments[0]:Array.from(arguments);return new ut(st.OR,n)},not:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=B(arguments[0])?arguments[0]:Array.from(arguments);return new ut(st.NOT,n)},set:function(t){return new at(tt.SET,[t])},remove:function(){return new at(tt.REMOVE,[])},inc:function(t){return new at(tt.INC,[t])},mul:function(t){return new at(tt.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")){var r=e[0];t={$each:r.each,$position:r.position,$sort:r.sort,$slice:r.slice}}else t=B(e[0])?e[0]:Array.from(e);return new at(tt.PUSH,t)},pull:function(t){return new at(tt.PULL,t)},pullAll:function(t){return new at(tt.PULL_ALL,t)},pop:function(){return new at(tt.POP,[])},shift:function(){return new at(tt.SHIFT,[])},unshift:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=B(arguments[0])?arguments[0]:Array.from(arguments);return new at(tt.UNSHIFT,n)},addToSet:function(t){return new at(tt.ADD_TO_SET,t)},rename:function(t){return new at(tt.RENAME,[t])},bit:function(t){return new at(tt.BIT,[t])},max:function(t){return new at(tt.MAX,[t])},min:function(t){return new at(tt.MIN,[t])},expr:function(t){return{$expr:t}},jsonSchema:function(t){return{$jsonSchema:t}},text:function(t){return"string"===D(t)?{$search:t.search}:{$search:t.search,$language:t.language,$caseSensitive:t.caseSensitive,$diacriticSensitive:t.diacriticSensitive}},aggregate:{pipeline:function(){return new pn},abs:function(t){return new vn("abs",t)},add:function(t){return new vn("add",t)},ceil:function(t){return new vn("ceil",t)},divide:function(t){return new vn("divide",t)},exp:function(t){return new vn("exp",t)},floor:function(t){return new vn("floor",t)},ln:function(t){return new vn("ln",t)},log:function(t){return new vn("log",t)},log10:function(t){return new vn("log10",t)},mod:function(t){return new vn("mod",t)},multiply:function(t){return new vn("multiply",t)},pow:function(t){return new vn("pow",t)},sqrt:function(t){return new vn("sqrt",t)},subtract:function(t){return new vn("subtract",t)},trunc:function(t){return new vn("trunc",t)},arrayElemAt:function(t){return new vn("arrayElemAt",t)},arrayToObject:function(t){return new vn("arrayToObject",t)},concatArrays:function(t){return new vn("concatArrays",t)},filter:function(t){return new vn("filter",t)},in:function(t){return new vn("in",t)},indexOfArray:function(t){return new vn("indexOfArray",t)},isArray:function(t){return new vn("isArray",t)},map:function(t){return new vn("map",t)},range:function(t){return new vn("range",t)},reduce:function(t){return new vn("reduce",t)},reverseArray:function(t){return new vn("reverseArray",t)},size:function(t){return new vn("size",t)},slice:function(t){return new vn("slice",t)},zip:function(t){return new vn("zip",t)},and:function(t){return new vn("and",t)},not:function(t){return new vn("not",t)},or:function(t){return new vn("or",t)},cmp:function(t){return new vn("cmp",t)},eq:function(t){return new vn("eq",t)},gt:function(t){return new vn("gt",t)},gte:function(t){return new vn("gte",t)},lt:function(t){return new vn("lt",t)},lte:function(t){return new vn("lte",t)},neq:function(t){return new vn("ne",t)},cond:function(t){return new vn("cond",t)},ifNull:function(t){return new vn("ifNull",t)},switch:function(t){return new vn("switch",t)},dateFromParts:function(t){return new vn("dateFromParts",t)},dateFromString:function(t){return new vn("dateFromString",t)},dayOfMonth:function(t){return new vn("dayOfMonth",t)},dayOfWeek:function(t){return new vn("dayOfWeek",t)},dayOfYear:function(t){return new vn("dayOfYear",t)},isoDayOfWeek:function(t){return new vn("isoDayOfWeek",t)},isoWeek:function(t){return new vn("isoWeek",t)},isoWeekYear:function(t){return new vn("isoWeekYear",t)},millisecond:function(t){return new vn("millisecond",t)},minute:function(t){return new vn("minute",t)},month:function(t){return new vn("month",t)},second:function(t){return new vn("second",t)},hour:function(t){return new vn("hour",t)},week:function(t){return new vn("week",t)},year:function(t){return new vn("year",t)},literal:function(t){return new vn("literal",t)},mergeObjects:function(t){return new vn("mergeObjects",t)},objectToArray:function(t){return new vn("objectToArray",t)},allElementsTrue:function(t){return new vn("allElementsTrue",t)},anyElementTrue:function(t){return new vn("anyElementTrue",t)},setDifference:function(t){return new vn("setDifference",t)},setEquals:function(t){return new vn("setEquals",t)},setIntersection:function(t){return new vn("setIntersection",t)},setIsSubset:function(t){return new vn("setIsSubset",t)},setUnion:function(t){return new vn("setUnion",t)},concat:function(t){return new vn("concat",t)},dateToString:function(t){return new vn("dateToString",t)},indexOfBytes:function(t){return new vn("indexOfBytes",t)},indexOfCP:function(t){return new vn("indexOfCP",t)},split:function(t){return new vn("split",t)},strLenBytes:function(t){return new vn("strLenBytes",t)},strLenCP:function(t){return new vn("strLenCP",t)},strcasecmp:function(t){return new vn("strcasecmp",t)},substr:function(t){return new vn("substr",t)},substrBytes:function(t){return new vn("substrBytes",t)},substrCP:function(t){return new vn("substrCP",t)},toLower:function(t){return new vn("toLower",t)},toUpper:function(t){return new vn("toUpper",t)},meta:function(t){return new vn("meta",t)},addToSet:function(t){return new vn("addToSet",t)},avg:function(t){return new vn("avg",t)},first:function(t){return new vn("first",t)},last:function(t){return new vn("last",t)},max:function(t){return new vn("max",t)},min:function(t){return new vn("min",t)},push:function(t){return new vn("push",t)},stdDevPop:function(t){return new vn("stdDevPop",t)},stdDevSamp:function(t){return new vn("stdDevSamp",t)},sum:function(t){return new vn("sum",t)},let:function(t){return new vn("let",t)}},project:{slice:function(t){return new mn("slice",t)},elemMatch:function(t){return new mn("elemMatch",t)}}},vn=function(t,e){this["$"+t]=e},mn=function(t,e){this["$"+t]=e},_n=function(){function t(t){var e=t.regexp,n=t.options;if(!e)throw new TypeError("regexp must be a string");this.$regex=e,this.$options=n}return t.prototype.parse=function(){return{$regex:this.$regex,$options:this.$options}},Object.defineProperty(t.prototype,"_internalType",{get:function(){return j},enumerable:!0,configurable:!0}),t}();function wn(t){return new _n(t)}var bn="insert document failed",En="DATABASE_TRANSACTION_CONFLICT",Sn=function(){return Sn=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},Sn.apply(this,arguments)},In=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},On=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},An="database.updateDocInTransaction",Tn=function(){function t(t,e,n){this._coll=e,this.id=n,this._transaction=t,this._request=this._transaction.getRequestMethod(),this._transactionId=this._transaction.getTransactionId()}return t.prototype.create=function(t){return In(this,void 0,void 0,(function(){var e,n,r,o;return On(this,(function(i){switch(i.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,data:cn.stringify(Et(t),{relaxed:!1})},this.id&&(e._id=this.id),[4,this._request.send("database.insertDocInTransaction",e)];case 1:if((n=i.sent()).code)throw n;if(r=cn.parse(n.inserted),1==(o=cn.parse(n.ok))&&1==r)return[2,Sn(Sn({},n),{ok:o,inserted:r})];throw new Error(bn)}}))}))},t.prototype.get=function(){return In(this,void 0,void 0,(function(){var t,e;return On(this,(function(n){switch(n.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.getInTransaction",t)];case 1:if((e=n.sent()).code)throw e;return[2,{data:"null"!==e.data?nt.formatField(cn.parse(e.data)):cn.parse(e.data),requestId:e.requestId}]}}))}))},t.prototype.set=function(t){return In(this,void 0,void 0,(function(){var e,n;return On(this,(function(r){switch(r.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:cn.stringify(Et(t),{relaxed:!1}),upsert:!0},[4,this._request.send(An,e)];case 1:if((n=r.sent()).code)throw n;return[2,Sn(Sn({},n),{updated:cn.parse(n.updated),upserted:n.upserted?JSON.parse(n.upserted):null})]}}))}))},t.prototype.update=function(t){return In(this,void 0,void 0,(function(){var e,n;return On(this,(function(r){switch(r.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:cn.stringify(Lt.encode(t),{relaxed:!1})},[4,this._request.send(An,e)];case 1:if((n=r.sent()).code)throw n;return[2,Sn(Sn({},n),{updated:cn.parse(n.updated)})]}}))}))},t.prototype.delete=function(){return In(this,void 0,void 0,(function(){var t,e;return On(this,(function(n){switch(n.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.deleteDocInTransaction",t)];case 1:if((e=n.sent()).code)throw e;return[2,Sn(Sn({},e),{deleted:cn.parse(e.deleted)})]}}))}))},t}(),Nn=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)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Rn=function(t){function e(e,n){return t.call(this,e,n)||this}return Nn(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return this._coll},enumerable:!0,configurable:!0}),e.prototype.doc=function(t){if("string"!=typeof t&&"number"!=typeof t)throw new Error("docId必须为字符串或数字");return new Tn(this._transaction,this._coll,t)},e.prototype.add=function(t){var e;return void 0!==t._id&&(e=t._id),new Tn(this._transaction,this._coll,e).create(t)},e}((function(t,e){this._coll=e,this._transaction=t})),Pn=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},xn=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},Ln=function(){function t(t){this._db=t,this._request=new Un.reqClass(this._db.config),this.aborted=!1,this.commited=!1,this.inited=!1}return t.prototype.init=function(){return Pn(this,void 0,void 0,(function(){var t;return xn(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 Rn(this,t)},t.prototype.getTransactionId=function(){return this._id},t.prototype.getRequestMethod=function(){return this._request},t.prototype.commit=function(){return Pn(this,void 0,void 0,(function(){var t,e;return xn(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 Pn(this,void 0,void 0,(function(){var e,n;return xn(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 Cn(){return Pn(this,void 0,void 0,(function(){var t;return xn(this,(function(e){switch(e.label){case 0:return[4,(t=new Ln(this)).init()];case 1:return e.sent(),[2,t]}}))}))}function kn(t,e){return void 0===e&&(e=3),Pn(this,void 0,void 0,(function(){var n,r,o,i,s=this;return xn(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,10]),[4,(n=new Ln(this)).init()];case 1:return a.sent(),[4,t(n)];case 2:if(r=a.sent(),!0===n.aborted)throw n.abortReason;return[4,n.commit()];case 3:return a.sent(),[2,r];case 4:if(o=a.sent(),!1===n.inited)throw o;return i=function(t){return Pn(s,void 0,void 0,(function(){return xn(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:a.sent(),a.label=6;case 6:return o&&o.code===En?[4,kn.bind(this)(t,--e)]:[3,8];case 7:return[2,a.sent()];case 8:return[4,i(o)];case 9:return a.sent(),[3,10];case 10:return[2]}}))}))}var Un=function(){function t(t){this.config=t,this.Geo=i,this.serverDate=Q,this.command=gn,this.RegExp=wn,this.startTransaction=Cn,this.runTransaction=kn,this.logicCommand=ut,this.updateCommand=at,this.queryCommand=pt}return t.prototype.collection=function(t){if(!t)throw new Error("Collection name is required");return new yn(this,t)},t.prototype.createCollection=function(e){var n={collectionName:e};return new t.reqClass(this.config).send("database.addCollection",n)},t}(),jn=function(){return jn=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},jn.apply(this,arguments)},Dn={name:"database",entity:{database:function(t){var e=this.platform,n=e.adapter,r=e.runtime;return Un.reqClass=this.request.constructor,Un.getAccessToken=this.authInstance?this.authInstance.getAccessToken.bind(this.authInstance):function(){return""},Un.runtime=r,this.wsClientClass&&(Un.wsClass=n.wsClass,Un.wsClientClass=this.wsClientClass),Un.ws||(Un.ws=null),new Un(jn(jn({},this.config),t))}}};try{cloudbase.registerComponent(Dn)}catch(t){}function Mn(t){try{t.registerComponent(Dn)}catch(t){console.warn(t)}}},363:function(t,e,n){"use strict";n.r(e),n.d(e,{registerFunctions:function(){return p}});var r=n(650),o=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},i=r.constants.getSdkName,s=r.constants.ERRORS,a=r.constants.COMMUNITY_SITE_URL,c=r.utils.execCallback,u=r.helpers.catchErrorsDecorator,f="functions",l=new(function(){function t(){}return t.prototype.callFunction=function(t,e){return n=this,r=void 0,a=function(){var n,r,o,a,u,l,h,p,d,y,g,v;return function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,(function(m){switch(m.label){case 0:if(n=t.name,r=t.data,o=t.query,a=t.parse,u=t.search,!n)throw new Error(JSON.stringify({code:s.INVALID_PARAMS,msg:"[".concat(f,".callFunction] invalid function name")}));try{l=r?JSON.stringify(r):""}catch(t){throw new Error(JSON.stringify({code:s.INVALID_PARAMS,msg:"[".concat(f,".callFunction] invalid data")}))}h="functions.invokeFunction",p={inQuery:o,parse:a,search:u,function_name:n,request_data:l},d=this.request,m.label=1;case 1:return m.trys.push([1,3,,4]),[4,d.send(h,p)];case 2:if((y=m.sent()).code)return[2,c(e,null,y)];if(g=y.data.response_data,a)return[2,c(e,null,{result:g,requestId:y.requestId})];try{return g=JSON.parse(y.data.response_data),[2,c(e,null,{result:g,requestId:y.requestId})]}catch(t){c(e,new Error("[".concat(i(),"][").concat(s.INVALID_PARAMS,"][").concat(f,".callFunction] response data must be json")))}return[3,4];case 3:return v=m.sent(),c(e,v),[3,4];case 4:return[2]}}))},new((o=void 0)||(o=Promise))((function(t,e){function i(t){try{c(a.next(t))}catch(t){e(t)}}function s(t){try{c(a.throw(t))}catch(t){e(t)}}function c(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(i,s)}c((a=a.apply(n,r||[])).next())}));var n,r,o,a},function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);i>3&&s&&Object.defineProperty(e,n,s)}([u({customInfo:{className:"Cloudbase",methodName:"callFunction"},title:"函数调用失败",messages:["请确认以下各项:"," 1 - 调用 callFunction() 的语法或参数是否正确"," 2 - 当前环境下是否存在此函数"," 3 - 函数安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(a)]}),o("design:type",Function),o("design:paramtypes",[Object,Function]),o("design:returntype",Promise)],t.prototype,"callFunction",null),t}()),h={name:f,entity:{callFunction:l.callFunction}};try{cloudbase.registerComponent(h)}catch(t){}function p(t){try{t.registerComponent(h)}catch(t){console.warn(t)}}},63:function(t,e,n){"use strict";n.r(e),n.d(e,{registerRealtime:function(){return F}});var r=n(880),o=n.n(r),i=n(373),s=n.n(i),a=n(907),c=n.n(a);function u(t){return void 0===t&&(t=""),"".concat(t?"".concat(t,"_"):"").concat(+new Date,"_").concat(Math.random())}var f,l,h=function(t){this.close=t.close,this.onChange=t.onChange,this.onError=t.onError,t.debug&&Object.defineProperty(this,"virtualClient",{get:function(){return t.virtualClient}})},p=function(t){var e,n,r=t.id,o=t.docChanges,i=t.docs,s=t.msgType,a=t.type;Object.defineProperties(this,{id:{get:function(){return r},enumerable:!0},docChanges:{get:function(){return e||(e=JSON.parse(JSON.stringify(o))),e},enumerable:!0},docs:{get:function(){return n||(n=JSON.parse(JSON.stringify(i))),n},enumerable:!0},msgType:{get:function(){return s},enumerable:!0},type:{get:function(){return a},enumerable:!0}})},d=(f=function(t,e){return f=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])},f(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}f(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),y=function(t){function e(e){var n=t.call(this,"Watch Error ".concat(JSON.stringify(e.msgData)," (requestid: ").concat(e.requestId,")"))||this;return n.isRealtimeErrorMessageError=!0,n.payload=e,n}return d(e,t),e}(Error),g=function(t){return null==t?void 0:t.isRealtimeErrorMessageError},v=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="timeout",e.payload=null,e.generic=!0,e}return d(e,t),e}(Error),m=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="cancelled",e.payload=null,e.generic=!0,e}return d(e,t),e}(Error),_=function(t){function e(e){var n=t.call(this,e.errMsg)||this;return n.errCode="UNKNOWN_ERROR",Object.defineProperties(n,{message:{get:function(){return"errCode: ".concat(this.errCode," ").concat(w[this.errCode]||""," | errMsg: ").concat(this.errMsg)},set:function(t){this.errMsg=t}}}),n.errCode=e.errCode||"UNKNOWN_ERROR",n.errMsg=e.errMsg,n}return d(e,t),Object.defineProperty(e.prototype,"message",{get:function(){return"errCode: ".concat(this.errCode," | errMsg: ").concat(this.errMsg)},set:function(t){this.errMsg=t},enumerable:!1,configurable:!0}),e}(Error),w={UNKNOWN_ERROR:"UNKNOWN_ERROR",SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG:"SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG",SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA:"SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA",SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR:"SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR",SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED:"SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED",SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL:"SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL",SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR:"SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR"},b=function(t){return void 0===t&&(t=0),new Promise((function(e){return setTimeout(e,t)}))},E=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},S=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},I=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(t){t.LOGGINGIN="LOGGINGIN",t.INITING="INITING",t.REBUILDING="REBUILDING",t.ACTIVE="ACTIVE",t.ERRORED="ERRORED",t.CLOSING="CLOSING",t.CLOSED="CLOSED",t.PAUSED="PAUSED",t.RESUMING="RESUMING"}(l||(l={}));var O=function(){function t(t){var e=this;this.watchStatus=l.INITING,this._login=function(t,n){return E(e,void 0,void 0,(function(){var e;return S(this,(function(r){switch(r.label){case 0:return this.watchStatus=l.LOGGINGIN,[4,this.login(t,n)];case 1:return e=r.sent(),this.envId||(this.envId=e.envId),[2,e]}}))}))},this.initWatch=function(t){return E(e,void 0,void 0,(function(){var e,n=this;return S(this,(function(r){switch(r.label){case 0:if(this._initWatchPromise)return[2,this._initWatchPromise];this._initWatchPromise=new Promise((function(e,r){return E(n,void 0,void 0,(function(){var n,o,i,s,a,c,f,h,d,y;return S(this,(function(g){switch(g.label){case 0:return g.trys.push([0,3,,4]),this.watchStatus===l.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,e()]):[4,this._login(this.envId,t)];case 1:return n=g.sent().envId,this.watchStatus===l.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,e()]):(this.watchStatus=l.INITING,o={watchId:this.watchId,requestId:u(),msgType:"INIT_WATCH",msgData:{envId:n,collName:this.collectionName,query:this.query,limit:this.limit,orderBy:this.orderBy}},[4,this.send({msg:o,waitResponse:!0,skipOnMessage:!0,timeout:1e4})]);case 2:if(i=g.sent(),s=i.msgData,a=s.events,c=s.currEvent,this.sessionInfo={queryID:i.msgData.queryID,currentEventId:c-1,currentDocs:[]},a.length>0){for(f=0,h=a;f<h.length;f++)h[f].ID=c;this.handleServerEvents(i)}else this.sessionInfo.currentEventId=c,d=new p({id:c,docChanges:[],docs:[],type:"init"}),this.listener.onChange(d),this.scheduleSendACK();return this.onWatchStart(this,this.sessionInfo.queryID),this.watchStatus=l.ACTIVE,this._availableRetries.INIT_WATCH=2,e(),[3,4];case 3:return y=g.sent(),this.handleWatchEstablishmentError(y,{operationName:"INIT_WATCH",resolve:e,reject:r}),[3,4];case 4:return[2]}}))}))})),e=!1,r.label=1;case 1:return r.trys.push([1,,3,4]),[4,this._initWatchPromise];case 2:return r.sent(),e=!0,[3,4];case 3:return this._initWatchPromise=void 0,[7];case 4:return console.log("[realtime] initWatch ".concat(e?"success":"fail")),[2]}}))}))},this.rebuildWatch=function(t){return E(e,void 0,void 0,(function(){var e,n=this;return S(this,(function(r){switch(r.label){case 0:if(this._rebuildWatchPromise)return[2,this._rebuildWatchPromise];this._rebuildWatchPromise=new Promise((function(e,r){return E(n,void 0,void 0,(function(){var n,o,i,s;return S(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),this.watchStatus===l.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,e()]):[4,this._login(this.envId,t)];case 1:if(n=a.sent().envId,!this.sessionInfo)throw new Error("can not rebuildWatch without a successful initWatch (lack of sessionInfo)");return this.watchStatus===l.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,e()]):(this.watchStatus=l.REBUILDING,o={watchId:this.watchId,requestId:u(),msgType:"REBUILD_WATCH",msgData:{envId:n,collName:this.collectionName,queryID:this.sessionInfo.queryID,eventID:this.sessionInfo.currentEventId}},[4,this.send({msg:o,waitResponse:!0,skipOnMessage:!1,timeout:1e4})]);case 2:return i=a.sent(),this.handleServerEvents(i),this.watchStatus=l.ACTIVE,this._availableRetries.REBUILD_WATCH=2,e(),[3,4];case 3:return s=a.sent(),this.handleWatchEstablishmentError(s,{operationName:"REBUILD_WATCH",resolve:e,reject:r}),[3,4];case 4:return[2]}}))}))})),e=!1,r.label=1;case 1:return r.trys.push([1,,3,4]),[4,this._rebuildWatchPromise];case 2:return r.sent(),e=!0,[3,4];case 3:return this._rebuildWatchPromise=void 0,[7];case 4:return console.log("[realtime] rebuildWatch ".concat(e?"success":"fail")),[2]}}))}))},this.handleWatchEstablishmentError=function(t,n){return E(e,void 0,void 0,(function(){var e,r,o,i=this;return S(this,(function(s){return e="INIT_WATCH"===n.operationName,r=function(){i.closeWithError(new _({errCode:e?w.SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:w.SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL,errMsg:t})),n.reject(t)},o=function(t){i.useRetryTicket(n.operationName)?e?(i._initWatchPromise=void 0,n.resolve(i.initWatch(t))):(i._rebuildWatchPromise=void 0,n.resolve(i.rebuildWatch(t))):r()},this.handleCommonError(t,{onSignError:function(){return o(!0)},onTimeoutError:function(){return o(!1)},onNotRetryableError:r,onCancelledError:n.reject,onUnknownError:function(){return E(i,void 0,void 0,(function(){var t,e=this;return S(this,(function(r){switch(r.label){case 0:return r.trys.push([0,8,,9]),t=function(){return E(e,void 0,void 0,(function(){return S(this,(function(t){switch(t.label){case 0:return this.pause(),[4,this.onceWSConnected()];case 1:return t.sent(),o(!0),[2]}}))}))},this.isWSConnected()?[3,2]:[4,t()];case 1:return r.sent(),[3,7];case 2:return[4,b(100)];case 3:return r.sent(),this.watchStatus!==l.PAUSED?[3,4]:(n.reject(new m("".concat(n.operationName," cancelled due to pause after unknownError"))),[3,7]);case 4:return this.isWSConnected()?[3,6]:[4,t()];case 5:return r.sent(),[3,7];case 6:o(!1),r.label=7;case 7:return[3,9];case 8:return r.sent(),o(!0),[3,9];case 9:return[2]}}))}))}}),[2]}))}))},this.closeWatch=function(){return E(e,void 0,void 0,(function(){var t,e,n;return S(this,(function(r){switch(r.label){case 0:if(t=this.sessionInfo?this.sessionInfo.queryID:"",this.watchStatus!==l.ACTIVE)return this.watchStatus=l.CLOSED,this.onWatchClose(this,t),[2];r.label=1;case 1:return r.trys.push([1,3,4,5]),this.watchStatus=l.CLOSING,e={watchId:this.watchId,requestId:u(),msgType:"CLOSE_WATCH",msgData:null},[4,this.send({msg:e})];case 2:return r.sent(),this.sessionInfo=void 0,this.watchStatus=l.CLOSED,[3,5];case 3:return n=r.sent(),this.closeWithError(new _({errCode:w.SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL,errMsg:n})),[3,5];case 4:return this.onWatchClose(this,t),[7];case 5:return[2]}}))}))},this.scheduleSendACK=function(){e.clearACKSchedule(),e._ackTimeoutId=setTimeout((function(){e._waitExpectedTimeoutId?e.scheduleSendACK():e.sendACK()}),1e4)},this.clearACKSchedule=function(){e._ackTimeoutId&&clearTimeout(e._ackTimeoutId)},this.sendACK=function(){return E(e,void 0,void 0,(function(){var t,e,n;return S(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.watchStatus!==l.ACTIVE?(this.scheduleSendACK(),[2]):this.sessionInfo?(t={watchId:this.watchId,requestId:u(),msgType:"CHECK_LAST",msgData:{queryID:this.sessionInfo.queryID,eventID:this.sessionInfo.currentEventId}},[4,this.send({msg:t})]):(console.warn("[realtime listener] can not send ack without a successful initWatch (lack of sessionInfo)"),[2]);case 1:return r.sent(),this.scheduleSendACK(),[3,3];case 2:if(e=r.sent(),g(e))switch((n=e.payload).msgData.code){case"CHECK_LOGIN_FAILED":case"SIGN_EXPIRED_ERROR":case"SIGN_INVALID_ERROR":case"SIGN_PARAM_INVALID":return this.rebuildWatch(),[2];case"QUERYID_INVALID_ERROR":case"SYS_ERR":case"INVALIID_ENV":case"COLLECTION_PERMISSION_DENIED":return this.closeWithError(new _({errCode:w.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:n.msgData.code})),[2]}return this._availableRetries.CHECK_LAST&&this._availableRetries.CHECK_LAST>0?(this._availableRetries.CHECK_LAST--,this.scheduleSendACK()):this.closeWithError(new _({errCode:w.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:e})),[3,3];case 3:return[2]}}))}))},this.handleCommonError=function(t,e){if(g(t))switch(t.payload.msgData.code){case"CHECK_LOGIN_FAILED":case"SIGN_EXPIRED_ERROR":case"SIGN_INVALID_ERROR":case"SIGN_PARAM_INVALID":return void e.onSignError(t);default:return void e.onNotRetryableError(t)}else{if(function(t){return"timeout"===t.type}(t))return void e.onTimeoutError(t);if(function(t){return"cancelled"===t.type}(t))return void e.onCancelledError(t)}e.onUnknownError(t)},this.watchId="watchid_".concat(+new Date,"_").concat(Math.random()),this.envId=t.envId,this.collectionName=t.collectionName,this.query=t.query,this.limit=t.limit,this.orderBy=t.orderBy,this.send=t.send,this.login=t.login,this.isWSConnected=t.isWSConnected,this.onceWSConnected=t.onceWSConnected,this.getWaitExpectedTimeoutLength=t.getWaitExpectedTimeoutLength,this.onWatchStart=t.onWatchStart,this.onWatchClose=t.onWatchClose,this.debug=t.debug,this._availableRetries={INIT_WATCH:2,REBUILD_WATCH:2,CHECK_LAST:2},this.listener=new h({close:this.closeWatch,onChange:t.onChange,onError:t.onError,debug:this.debug,virtualClient:this}),this.initWatch()}return t.prototype.onMessage=function(t){var e=this;switch(this.watchStatus){case l.PAUSED:if("ERROR"!==t.msgType)return;break;case l.LOGGINGIN:case l.INITING:case l.REBUILDING:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received while ".concat(this.watchStatus));case l.CLOSED:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received when the watch has closed");case l.ERRORED:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received when the watch has ended with error")}if(this.sessionInfo)switch(this.scheduleSendACK(),t.msgType){case"NEXT_EVENT":console.warn("nextevent ".concat(t.msgData.currEvent," ignored"),t),this.handleServerEvents(t);break;case"CHECK_EVENT":this.sessionInfo.currentEventId<t.msgData.currEvent&&(this.sessionInfo.expectEventId=t.msgData.currEvent,this.clearWaitExpectedEvent(),this._waitExpectedTimeoutId=setTimeout((function(){e.rebuildWatch()}),this.getWaitExpectedTimeoutLength()),console.log("[realtime] waitExpectedTimeoutLength ".concat(this.getWaitExpectedTimeoutLength())));break;case"ERROR":this.closeWithError(new _({errCode:w.SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG,errMsg:"".concat(t.msgData.code," - ").concat(t.msgData.message)}));break;default:console.warn("[realtime listener] virtual client receive unexpected msg ".concat(t.msgType,": "),t)}else console.warn("[realtime listener] internal non-fatal error: sessionInfo not found while message is received.")},t.prototype.closeWithError=function(t){var e;this.watchStatus=l.ERRORED,this.clearACKSchedule(),this.listener.onError(t),this.onWatchClose(this,(null===(e=this.sessionInfo)||void 0===e?void 0:e.queryID)||""),console.log("[realtime] client closed (".concat(this.collectionName," ").concat(this.query,") (watchId ").concat(this.watchId,")"))},t.prototype.pause=function(){this.watchStatus=l.PAUSED,console.log("[realtime] client paused (".concat(this.collectionName," ").concat(this.query,") (watchId ").concat(this.watchId,")"))},t.prototype.resume=function(){return E(this,void 0,void 0,(function(){var t;return S(this,(function(e){switch(e.label){case 0:this.watchStatus=l.RESUMING,console.log("[realtime] client resuming with ".concat(this.sessionInfo?"REBUILD_WATCH":"INIT_WATCH"," (").concat(this.collectionName," ").concat(this.query,") (").concat(this.watchId,")")),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.sessionInfo?this.rebuildWatch():this.initWatch()];case 2:return e.sent(),console.log("[realtime] client successfully resumed (".concat(this.collectionName," ").concat(this.query,") (").concat(this.watchId,")")),[3,4];case 3:return t=e.sent(),console.error("[realtime] client resume failed (".concat(this.collectionName," ").concat(this.query,") (").concat(this.watchId,")"),t),[3,4];case 4:return[2]}}))}))},t.prototype.useRetryTicket=function(t){return!!(this._availableRetries[t]&&this._availableRetries[t]>0)&&(this._availableRetries[t]--,console.log("[realtime] ".concat(t," use a retry ticket, now only ").concat(this._availableRetries[t]," retry left")),!0)},t.prototype.handleServerEvents=function(t){return E(this,void 0,void 0,(function(){var e;return S(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this.scheduleSendACK(),[4,this._handleServerEvents(t)];case 1:return n.sent(),this._postHandleServerEventsValidityCheck(t),[3,3];case 2:throw e=n.sent(),console.error("[realtime listener] internal non-fatal error: handle server events failed with error: ",e),e;case 3:return[2]}}))}))},t.prototype._handleServerEvents=function(t){return E(this,void 0,void 0,(function(){var e,n,r,i,a,u,f,l,h,d,y,g;return S(this,(function(v){switch(v.label){case 0:if(e=t.requestId,n=t.msgData.events,r=t.msgType,!n.length||!this.sessionInfo)return[2];i=this.sessionInfo;try{a=n.map(A)}catch(t){return this.closeWithError(new _({errCode:w.SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA,errMsg:t})),[2]}u=I([],i.currentDocs,!0),f=!1,l=function(n,l){var d,y,g,v,m,b,E,O,A,T,N;return S(this,(function(S){switch(S.label){case 0:return d=a[n],i.currentEventId>=d.id?(!a[n-1]||d.id>a[n-1].id?console.warn("[realtime] duplicate event received, cur ".concat(i.currentEventId," but got ").concat(d.id)):console.error("[realtime listener] server non-fatal error: events out of order (the latter event's id is smaller than that of the former) (requestId ".concat(e,")")),[2,"continue"]):[3,1];case 1:if(i.currentEventId!==d.id-1)return[3,2];switch(d.dataType){case"update":if(!d.doc)switch(d.queueType){case"update":case"dequeue":if(y=u.find((function(t){return t._id===d.docId})),y){if(b=c()(y),d.updatedFields)for(m in d.updatedFields)o()(b,m,d.updatedFields[m]);if(d.removedFields)for(g=0,v=d.removedFields;g<v.length;g++)m=v[g],s()(b,m);d.doc=b}else console.error("[realtime listener] internal non-fatal server error: unexpected update dataType event where no doc is associated.");break;case"enqueue":throw E=new _({errCode:w.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="update" and queueType="enqueue" (requestId '.concat(t.requestId,")")}),h.closeWithError(E),E}break;case"replace":if(!d.doc)throw E=new _({errCode:w.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="replace" (requestId '.concat(t.requestId,")")}),h.closeWithError(E),E;break;case"remove":(b=u.find((function(t){return t._id===d.docId})))?d.doc=b:console.error("[realtime listener] internal non-fatal server error: unexpected remove event where no doc is associated.");break;case"limit":if(!d.doc)switch(d.queueType){case"dequeue":(b=u.find((function(t){return t._id===d.docId})))?d.doc=b:console.error("[realtime listener] internal non-fatal server error: unexpected limit dataType event where no doc is associated.");break;case"enqueue":throw E=new _({errCode:w.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="limit" and queueType="enqueue" (requestId '.concat(t.requestId,")")}),h.closeWithError(E),E}}switch(d.queueType){case"init":f?u.push(d.doc):(f=!0,u=[d.doc]);break;case"enqueue":u.push(d.doc);break;case"dequeue":O=u.findIndex((function(t){return t._id===d.docId})),O>-1?u.splice(O,1):console.error("[realtime listener] internal non-fatal server error: unexpected dequeue event where no doc is associated.");break;case"update":O=u.findIndex((function(t){return t._id===d.docId})),O>-1?u[O]=d.doc:console.error("[realtime listener] internal non-fatal server error: unexpected queueType update event where no doc is associated.")}return(n===l-1||a[n+1]&&a[n+1].id!==d.id)&&(A=I([],u,!0),T=a.slice(0,n+1).filter((function(t){return t.id===d.id})),h.sessionInfo.currentEventId=d.id,h.sessionInfo.currentDocs=u,N=new p({id:d.id,docChanges:T,docs:A,msgType:r}),h.listener.onChange(N)),[3,4];case 2:return console.warn("[realtime listener] event received is out of order, cur ".concat(h.sessionInfo.currentEventId," but got ").concat(d.id)),[4,h.rebuildWatch()];case 3:return S.sent(),[2,{value:void 0}];case 4:return[2]}}))},h=this,d=0,y=a.length,v.label=1;case 1:return d<y?[5,l(d,y)]:[3,4];case 2:if("object"==typeof(g=v.sent()))return[2,g.value];v.label=3;case 3:return d++,[3,1];case 4:return[2]}}))}))},t.prototype._postHandleServerEventsValidityCheck=function(t){this.sessionInfo?(this.sessionInfo.expectEventId&&this.sessionInfo.currentEventId>=this.sessionInfo.expectEventId&&this.clearWaitExpectedEvent(),this.sessionInfo.currentEventId<t.msgData.currEvent&&console.warn("[realtime listener] internal non-fatal error: client eventId does not match with server event id after server event handling")):console.error("[realtime listener] internal non-fatal error: sessionInfo lost after server event handling, this should never occur")},t.prototype.clearWaitExpectedEvent=function(){this._waitExpectedTimeoutId&&(clearTimeout(this._waitExpectedTimeoutId),this._waitExpectedTimeoutId=void 0)},t}();function A(t){var e={id:t.ID,dataType:t.DataType,queueType:t.QueueType,docId:t.DocID,doc:t.Doc&&"{}"!==t.Doc?JSON.parse(t.Doc):void 0};return"update"===t.DataType&&(t.UpdatedFields&&(e.updatedFields=JSON.parse(t.UpdatedFields)),(t.removedFields||t.RemovedFields)&&(e.removedFields=JSON.parse(t.removedFields))),e}var T,N={1e3:{code:1e3,name:"Normal Closure",description:"Normal closure; the connection successfully completed whatever purpose for which it was created."},1001:{code:1001,name:"Going Away",description:"The endpoint is going away, either because of a server failure or because the browser is navigating away from the page that opened the connection."},1002:{code:1002,name:"Protocol Error",description:"The endpoint is terminating the connection due to a protocol error."},1003:{code:1003,name:"Unsupported Data",description:"The connection is being terminated because the endpoint received data of a type it cannot accept (for example, a text-only endpoint received binary data)."},1005:{code:1005,name:"No Status Received",description:"Indicates that no status code was provided even though one was expected."},1006:{code:1006,name:"Abnormal Closure",description:"Used to indicate that a connection was closed abnormally (that is, with no close frame being sent) when a status code is expected."},1007:{code:1007,name:"Invalid frame payload data",description:"The endpoint is terminating the connection because a message was received that contained inconsistent data (e.g., non-UTF-8 data within a text message)."},1008:{code:1008,name:"Policy Violation",description:"The endpoint is terminating the connection because it received a message that violates its policy. This is a generic status code, used when codes 1003 and 1009 are not suitable."},1009:{code:1009,name:"Message too big",description:"The endpoint is terminating the connection because a data frame was received that is too large."},1010:{code:1010,name:"Missing Extension",description:"The client is terminating the connection because it expected the server to negotiate one or more extension, but the server didn't."},1011:{code:1011,name:"Internal Error",description:"The server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request."},1012:{code:1012,name:"Service Restart",description:"The server is terminating the connection because it is restarting."},1013:{code:1013,name:"Try Again Later",description:"The server is terminating the connection due to a temporary condition, e.g. it is overloaded and is casting off some of its clients."},1014:{code:1014,name:"Bad Gateway",description:"The server was acting as a gateway or proxy and received an invalid response from the upstream server. This is similar to 502 HTTP Status Code."},1015:{code:1015,name:"TLS Handshake",description:"Indicates that the connection was closed due to a failure to perform a TLS handshake (e.g., the server certificate can't be verified)."},3e3:{code:3e3,name:"Reconnect WebSocket",description:"The client is terminating the connection because it wants to reconnect"},3001:{code:3001,name:"No Realtime Listeners",description:"The client is terminating the connection because no more realtime listeners exist"},3002:{code:3002,name:"Heartbeat Ping Error",description:"The client is terminating the connection due to its failure in sending heartbeat messages"},3003:{code:3003,name:"Heartbeat Pong Timeout Error",description:"The client is terminating the connection because no heartbeat response is received from the server"},3050:{code:3050,name:"Server Close",description:"The client is terminating the connection because no heartbeat response is received from the server"}};!function(t){t[t.NormalClosure=1e3]="NormalClosure",t[t.GoingAway=1001]="GoingAway",t[t.ProtocolError=1002]="ProtocolError",t[t.UnsupportedData=1003]="UnsupportedData",t[t.NoStatusReceived=1005]="NoStatusReceived",t[t.AbnormalClosure=1006]="AbnormalClosure",t[t.InvalidFramePayloadData=1007]="InvalidFramePayloadData",t[t.PolicyViolation=1008]="PolicyViolation",t[t.MessageTooBig=1009]="MessageTooBig",t[t.MissingExtension=1010]="MissingExtension",t[t.InternalError=1011]="InternalError",t[t.ServiceRestart=1012]="ServiceRestart",t[t.TryAgainLater=1013]="TryAgainLater",t[t.BadGateway=1014]="BadGateway",t[t.TLSHandshake=1015]="TLSHandshake",t[t.ReconnectWebSocket=3e3]="ReconnectWebSocket",t[t.NoRealtimeListeners=3001]="NoRealtimeListeners",t[t.HeartbeatPingError=3002]="HeartbeatPingError",t[t.HeartbeatPongTimeoutError=3003]="HeartbeatPongTimeoutError",t[t.NoAuthentication=3050]="NoAuthentication"}(T||(T={}));var R=function(t,e){var n=N[t],r=n?"".concat(n.name,", code ").concat(t,", reason ").concat(e||n.description):"code ".concat(t);return new _({errCode:w.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED,errMsg:r})},P=null,x="web";function L(){return P}function C(){return x}function k(t){x=t}var U=function(){return U=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},U.apply(this,arguments)},j=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},D=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},M=function(){function t(t){var e=this;this._virtualWSClient=new Set,this._queryIdClientMap=new Map,this._watchIdClientMap=new Map,this._pingFailed=0,this._pongMissed=0,this._logins=new Map,this._wsReadySubsribers=[],this._wsResponseWait=new Map,this._rttObserved=[],this.send=function(t){return j(e,void 0,void 0,(function(){var e=this;return D(this,(function(n){return[2,new Promise((function(n,r){return j(e,void 0,void 0,(function(){var e,o,i,s,a,c,u,f=this;return D(this,(function(l){switch(l.label){case 0:o=!1,i=!1,s=function(t){o=!0,e&&clearTimeout(e),n(t)},a=function(t){i=!0,e&&clearTimeout(e),r(t)},t.timeout&&(e=setTimeout((function(){return j(f,void 0,void 0,(function(){return D(this,(function(t){switch(t.label){case 0:return o&&i?[3,2]:[4,b(0)];case 1:t.sent(),o&&i||a(new v("wsclient.send timedout")),t.label=2;case 2:return[2]}}))}))}),t.timeout)),l.label=1;case 1:return l.trys.push([1,8,,9]),this._wsInitPromise?[4,this._wsInitPromise]:[3,3];case 2:l.sent(),l.label=3;case 3:if(!this._ws)return a(new Error("invalid state: ws connection not exists, can not send message")),[2];if(1!==this._ws.readyState)return a(new Error("ws readyState invalid: ".concat(this._ws.readyState,", can not send message"))),[2];t.waitResponse&&this._wsResponseWait.set(t.msg.requestId,{resolve:s,reject:a,skipOnMessage:t.skipOnMessage}),l.label=4;case 4:return l.trys.push([4,6,,7]),[4,this._ws.send(JSON.stringify(t.msg))];case 5:return l.sent(),t.waitResponse||s(void 0),[3,7];case 6:return(c=l.sent())&&(a(c),t.waitResponse&&this._wsResponseWait.delete(t.msg.requestId)),[3,7];case 7:return[3,9];case 8:return u=l.sent(),a(u),[3,9];case 9:return[2]}}))}))}))]}))}))},this.closeAllClients=function(t){e._virtualWSClient.forEach((function(e){e.closeWithError(t)}))},this.pauseClients=function(t){(t||e._virtualWSClient).forEach((function(t){t.pause()}))},this.resumeClients=function(t){(t||e._virtualWSClient).forEach((function(t){t.resume()}))},this.initWebSocketConnection=function(t,n){return void 0===n&&(n=e._maxReconnect),j(e,void 0,void 0,(function(){var e=this;return D(this,(function(r){switch(r.label){case 0:if(t&&this._reconnectState)return[2];if(t&&(this._reconnectState=!0),this._wsInitPromise)return[2,this._wsInitPromise];t&&this.pauseClients(),this.close(T.ReconnectWebSocket),this._wsInitPromise=new Promise((function(r,o){return j(e,void 0,void 0,(function(){var e,i,s=this;return D(this,(function(a){switch(a.label){case 0:return a.trys.push([0,6,,11]),[4,this.getWsSign()];case 1:return e=a.sent(),[4,new Promise((function(t){var n=e.wsUrl||"wss://tcb-ws.tencentcloudapi.com",r=L();s._ws=r?new r(n):new WebSocket(n),t(void 0)}))];case 2:return a.sent(),this._ws.connect?[4,this._ws.connect()]:[3,4];case 3:a.sent(),a.label=4;case 4:return[4,this.initWebSocketEvent()];case 5:return a.sent(),r(),t&&(this.resumeClients(),this._reconnectState=!1),[3,11];case 6:return i=a.sent(),console.error("[realtime] initWebSocketConnection connect fail",i),n>0?(this._wsInitPromise=void 0,[4,b(this._reconnectInterval)]):[3,9];case 7:a.sent(),t&&(this._reconnectState=!1),a.label=8;case 8:return r(this.initWebSocketConnection(t,n-1)),[3,10];case 9:o(i),t&&this.closeAllClients(new _({errCode:w.SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL,errMsg:i})),a.label=10;case 10:return[3,11];case 11:return[2]}}))}))})),r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,this._wsInitPromise];case 2:return r.sent(),this._wsReadySubsribers.forEach((function(t){return(0,t.resolve)()})),[3,5];case 3:return r.sent(),this._wsReadySubsribers.forEach((function(t){return(0,t.reject)()})),[3,5];case 4:return this._wsInitPromise=void 0,this._wsReadySubsribers=[],[7];case 5:return[2]}}))}))},this.initWebSocketEvent=function(){return new Promise((function(t,n){if(!e._ws)throw new Error("can not initWebSocketEvent, ws not exists");var r=!1;e._ws.onopen=function(e){console.warn("[realtime] ws event: open",e),r=!0,t()},e._ws.onerror=function(t){e._logins=new Map,r?(console.error("[realtime] ws event: error",t),e.clearHeartbeat(),e._virtualWSClient.forEach((function(e){return e.closeWithError(new _({errCode:w.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR,errMsg:t}))}))):(console.error("[realtime] ws open failed with ws event: error",t),n(t))},e._ws.onclose=function(t){switch(console.warn("[realtime] ws event: close",t),e._logins=new Map,e.clearHeartbeat(),t.code){case T.ReconnectWebSocket:case T.NoRealtimeListeners:break;case T.HeartbeatPingError:case T.HeartbeatPongTimeoutError:case T.NormalClosure:case T.AbnormalClosure:e._maxReconnect>0?e.initWebSocketConnection(!0,e._maxReconnect):e.closeAllClients(R(t.code));break;case T.NoAuthentication:e.closeAllClients(R(t.code,t.reason));break;default:e._maxReconnect>0?e.initWebSocketConnection(!0,e._maxReconnect):e.closeAllClients(R(t.code))}},e._ws.onmessage=function(t){var n,r=t.data;e.heartbeat();try{n=JSON.parse(r)}catch(t){throw new Error("[realtime] onMessage parse res.data error: ".concat(t))}if("ERROR"===n.msgType){var o=null;e._virtualWSClient.forEach((function(t){t.watchId===n.watchId&&(o=t)})),o&&o.listener.onError(n)}var i=e._wsResponseWait.get(n.requestId);if(i){try{"ERROR"===n.msgType?i.reject(new y(n)):i.resolve(n)}catch(t){console.error("ws onMessage responseWaitSpec.resolve(msg) errored:",t)}finally{e._wsResponseWait.delete(n.requestId)}if(i.skipOnMessage)return}if("PONG"!==n.msgType){var s=n.watchId&&e._watchIdClientMap.get(n.watchId);if(s)s.onMessage(n);else switch(console.error("[realtime] no realtime listener found responsible for watchId ".concat(n.watchId,": "),n),n.msgType){case"INIT_EVENT":case"NEXT_EVENT":case"CHECK_EVENT":(s=e._queryIdClientMap.get(n.msgData.queryID))&&s.onMessage(n);break;default:for(var a=0,c=Array.from(e._watchIdClientMap.entries());a<c.length;a++){c[a][1].onMessage(n);break}}}else if(e._lastPingSendTS){var u=Date.now()-e._lastPingSendTS;if(u>1e4)return void console.warn("[realtime] untrusted rtt observed: ".concat(u));e._rttObserved.length>=3&&e._rttObserved.splice(0,e._rttObserved.length-3+1),e._rttObserved.push(u)}},e.heartbeat()}))},this.isWSConnected=function(){return Boolean(e._ws&&1===e._ws.readyState)},this.onceWSConnected=function(){return j(e,void 0,void 0,(function(){var t=this;return D(this,(function(e){return this.isWSConnected()?[2]:this._wsInitPromise?[2,this._wsInitPromise]:[2,new Promise((function(e,n){t._wsReadySubsribers.push({resolve:e,reject:n})}))]}))}))},this.webLogin=function(t,n){return j(e,void 0,void 0,(function(){var e,r,o,i,s,a,c,f,l=this;return D(this,(function(h){switch(h.label){case 0:if(!n)if(t){if(e=this._logins.get(t)){if(e.loggedIn&&e.loginResult)return[2,e.loginResult];if(e.loggingInPromise)return[2,e.loggingInPromise]}}else if(null==(r=this._logins.get(""))?void 0:r.loggingInPromise)return[2,r.loggingInPromise];o=new Promise((function(t,e){return j(l,void 0,void 0,(function(){var n,r,o,i,s;return D(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),[4,this.getWsSign()];case 1:return n=a.sent(),r={envId:n.envId||"",accessToken:"",referrer:"web",sdkVersion:"",dataVersion:""},o={watchId:void 0,requestId:u(),msgType:"LOGIN",msgData:r,exMsgData:{runtime:C(),signStr:n.signStr,secretVersion:n.secretVersion}},[4,this.send({msg:o,waitResponse:!0,skipOnMessage:!0,timeout:5e3})];case 2:return(i=a.sent()).msgData.code?e(new Error("".concat(i.msgData.code," ").concat(i.msgData.message))):t({envId:n.envId}),[3,4];case 3:return s=a.sent(),e(s),[3,4];case 4:return[2]}}))}))})),i=t&&this._logins.get(t),s=Date.now(),i?(i.loggedIn=!1,i.loggingInPromise=o,i.loginStartTS=s):(i={loggedIn:!1,loggingInPromise:o,loginStartTS:s},this._logins.set(t||"",i)),h.label=1;case 1:return h.trys.push([1,3,,4]),[4,o];case 2:if(a=h.sent(),(c=t&&this._logins.get(t))&&c===i&&c.loginStartTS===s)return i.loggedIn=!0,i.loggingInPromise=void 0,i.loginStartTS=void 0,i.loginResult=a,[2,a];if(c){if(c.loggedIn&&c.loginResult)return[2,c.loginResult];if(c.loggingInPromise)return[2,c.loggingInPromise];throw new Error("ws unexpected login info")}throw new Error("ws login info reset");case 3:throw f=h.sent(),i.loggedIn=!1,i.loggingInPromise=void 0,i.loginStartTS=void 0,i.loginResult=void 0,f;case 4:return[2]}}))}))},this.getWsSign=function(){return j(e,void 0,void 0,(function(){var t,e,n,r,o,i,s;return D(this,(function(a){switch(a.label){case 0:return this._wsSign&&this._wsSign.expiredTs>Date.now()?[2,this._wsSign]:(t=Date.now()+6e4,[4,this._context.appConfig.request.send("auth.wsWebSign",{runtime:C()})]);case 1:if((e=a.sent()).code)throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败: ".concat(e.code));if(e.data)return n=e.data,r=n.signStr,o=n.wsUrl,i=n.secretVersion,s=n.envId,[2,{signStr:r,wsUrl:o,secretVersion:i,envId:s,expiredTs:t}];throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败")}}))}))},this.getWaitExpectedTimeoutLength=function(){return e._rttObserved.length?e._rttObserved.reduce((function(t,e){return t+e}))/e._rttObserved.length*1.5:5e3},this.ping=function(){return j(e,void 0,void 0,(function(){var t;return D(this,(function(e){switch(e.label){case 0:return t={watchId:void 0,requestId:u(),msgType:"PING",msgData:null},[4,this.send({msg:t})];case 1:return e.sent(),[2]}}))}))},this.onWatchStart=function(t,n){e._queryIdClientMap.set(n,t)},this.onWatchClose=function(t,n){n&&e._queryIdClientMap.delete(n),e._watchIdClientMap.delete(t.watchId),e._virtualWSClient.delete(t),e._virtualWSClient.size||e.close(T.NoRealtimeListeners)},this._maxReconnect=t.maxReconnect||5,this._reconnectInterval=t.reconnectInterval||1e4,this._context=t.context}return t.prototype.clearHeartbeat=function(){this._pingTimeoutId&&clearTimeout(this._pingTimeoutId),this._pongTimeoutId&&clearTimeout(this._pongTimeoutId)},t.prototype.close=function(t){this.clearHeartbeat(),this._ws&&(this._ws.close(t,N[t].name),this._ws=void 0)},t.prototype.watch=function(t){this._ws||this._wsInitPromise||this.initWebSocketConnection(!1);var e=new O(U(U({},t),{send:this.send,login:this.webLogin,isWSConnected:this.isWSConnected,onceWSConnected:this.onceWSConnected,getWaitExpectedTimeoutLength:this.getWaitExpectedTimeoutLength,onWatchStart:this.onWatchStart,onWatchClose:this.onWatchClose,debug:!0}));return this._virtualWSClient.add(e),this._watchIdClientMap.set(e.watchId,e),e.listener},t.prototype.heartbeat=function(t){var e=this;this.clearHeartbeat(),this._pingTimeoutId=setTimeout((function(){return j(e,void 0,void 0,(function(){var t=this;return D(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),this._ws&&1===this._ws.readyState?(this._lastPingSendTS=Date.now(),[4,this.ping()]):[2];case 1:return e.sent(),this._pingFailed=0,this._pongTimeoutId=setTimeout((function(){console.error("pong timed out"),t._pongMissed<2?(t._pongMissed++,t.heartbeat(!0)):t.initWebSocketConnection(!0)}),this._context.appConfig.realtimePongWaitTimeout),[3,3];case 2:return e.sent(),this._pingFailed<2?(this._pingFailed++,this.heartbeat()):this.close(T.HeartbeatPingError),[3,3];case 3:return[2]}}))}))}),t?0:this._context.appConfig.realtimePingInterval)},t}(),q={target:"database",entity:function(){var t,e=this.platform,n=e.adapter,r=e.runtime;t=n.wsClass,P=t,k(r)}},B={name:"realtime",IIFE:!0,entity:function(){this.prototype.wsClientClass=M}};try{cloudbase.registerComponent(B),cloudbase.registerHook(q)}catch(t){}function F(t){try{t.registerComponent(B),t.registerHook(q)}catch(t){console.warn(t)}}},614:function(t,e,n){"use strict";n.r(e),n.d(e,{registerStorage:function(){return _}});var r=n(650),o=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},i=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},s=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},a=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},c=r.constants.getSdkName,u=r.constants.ERRORS,f=r.constants.COMMUNITY_SITE_URL,l=r.utils.isArray,h=r.utils.isString,p=r.utils.isPalinObject,d=r.utils.execCallback,y=r.helpers.catchErrorsDecorator,g="storage",v=new(function(){function t(){}return t.prototype.uploadFile=function(t,e){return s(this,void 0,void 0,(function(){var n,r,o,i,s,f,l,p,y,v,m,_,w,b,E;return a(this,(function(a){switch(a.label){case 0:if(n=t.cloudPath,r=t.filePath,o=t.onUploadProgress,!h(n)||!r)throw new Error(JSON.stringify({code:u.INVALID_PARAMS,msg:"[".concat(g,".uploadFile] invalid params")}));return[4,(i=this.request).send("storage.getUploadMetadata",{path:n})];case 1:return s=a.sent(),f=s.data,l=f.url,p=f.authorization,y=f.token,v=f.fileId,m=f.cosFileId,_=f.download_url,w=s.requestId,b={key:n,signature:p,"x-cos-meta-fileid":m,success_action_status:"201","x-cos-security-token":y},[4,i.upload({url:l,data:b,file:r,name:n,onUploadProgress:o})];case 2:return 201===(E=a.sent()).statusCode?[2,d(e,null,{fileID:v,download_url:_,requestId:w})]:[2,d(e,new Error("[".concat(c(),"][").concat(u.OPERATION_FAIL,"][").concat(g,"]:").concat(E.data)))]}}))}))},t.prototype.getUploadMetadata=function(t,e){return s(this,void 0,void 0,(function(){var n,r,o,i,s;return a(this,(function(a){switch(a.label){case 0:if(n=t.cloudPath,!h(n))throw new Error(JSON.stringify({code:u.INVALID_PARAMS,msg:"[".concat(g,".getUploadMetadata] invalid cloudPath")}));r=this.request,o="storage.getUploadMetadata",a.label=1;case 1:return a.trys.push([1,3,,4]),[4,r.send(o,{path:n})];case 2:return i=a.sent(),[2,d(e,null,i)];case 3:return s=a.sent(),[2,d(e,s)];case 4:return[2]}}))}))},t.prototype.deleteFile=function(t,e){return s(this,void 0,void 0,(function(){var n,r,o,i,s,c;return a(this,(function(a){switch(a.label){case 0:if(!(n=t.fileList)||!l(n)||0===n.length)throw new Error(JSON.stringify({code:u.INVALID_PARAMS,msg:"[".concat(g,".deleteFile] fileList must not be empty")}));for(r=0,o=n;r<o.length;r++)if(!(i=o[r])||!h(i))throw new Error(JSON.stringify({code:u.INVALID_PARAMS,msg:"[".concat(g,".deleteFile] fileID must be string")}));return[4,this.request.send("storage.batchDeleteFile",{fileid_list:n})];case 1:return(s=a.sent()).code?[2,d(e,null,s)]:(c={fileList:s.data.delete_list,requestId:s.requestId},[2,d(e,null,c)])}}))}))},t.prototype.getTempFileURL=function(t,e){return s(this,void 0,void 0,(function(){var n,r,o,i,s,c;return a(this,(function(a){switch(a.label){case 0:if(!(n=t.fileList)||!l(n)||0===n.length)throw new Error(JSON.stringify({code:u.INVALID_PARAMS,msg:"[".concat(g,".getTempFileURL] fileList must not be empty")}));for(r=[],o=0,i=n;o<i.length;o++)if(s=i[o],p(s)){if(!s.hasOwnProperty("fileID")||!s.hasOwnProperty("maxAge"))throw new Error(JSON.stringify({code:u.INVALID_PARAMS,msg:"[".concat(g,".getTempFileURL] file info must include fileID and maxAge")}));r.push({fileid:s.fileID,max_age:s.maxAge})}else{if(!h(s))throw new Error(JSON.stringify({code:u.INVALID_PARAMS,msg:"[".concat(g,".getTempFileURL] invalid fileList")}));r.push({fileid:s})}return[4,this.request.send("storage.batchGetDownloadUrl",{file_list:r})];case 1:return(c=a.sent()).code?[2,d(e,null,c)]:[2,d(e,null,{fileList:c.data.download_list,requestId:c.requestId})]}}))}))},t.prototype.downloadFile=function(t,e){return s(this,void 0,void 0,(function(){var n,r,o,i,s,c;return a(this,(function(a){switch(a.label){case 0:if(n=t.fileID,!h(n))throw new Error(JSON.stringify({code:u.INVALID_PARAMS,msg:"[".concat(g,".getTempFileURL] fileID must be string")}));return[4,this.getTempFileURL.call(this,{fileList:[{fileID:n,maxAge:600}]})];case 1:return r=a.sent(),"SUCCESS"!==(o=r.fileList[0]).code?[2,d(e,o)]:(i=this.request,s=encodeURI(o.download_url),[4,i.download({url:s})]);case 2:return c=a.sent(),[2,d(e,null,c)]}}))}))},o([y({customInfo:{className:"Cloudbase",methodName:"uploadFile"},title:"上传文件失败",messages:["请确认以下各项:"," 1 - 调用 uploadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f)]}),i("design:type",Function),i("design:paramtypes",[Object,Function]),i("design:returntype",Promise)],t.prototype,"uploadFile",null),o([y({customInfo:{className:"Cloudbase",methodName:"getUploadMetadata"},title:"获取上传元信息失败",messages:["请确认以下各项:"," 1 - 调用 getUploadMetadata() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f)]}),i("design:type",Function),i("design:paramtypes",[Object,Function]),i("design:returntype",Promise)],t.prototype,"getUploadMetadata",null),o([y({customInfo:{className:"Cloudbase",methodName:"deleteFile"},title:"删除文件失败",messages:["请确认以下各项:"," 1 - 调用 deleteFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f)]}),i("design:type",Function),i("design:paramtypes",[Object,Function]),i("design:returntype",Promise)],t.prototype,"deleteFile",null),o([y({customInfo:{className:"Cloudbase",methodName:"getTempFileURL"},title:"获取文件下载链接",messages:["请确认以下各项:"," 1 - 调用 getTempFileURL() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f)]}),i("design:type",Function),i("design:paramtypes",[Object,Function]),i("design:returntype",Promise)],t.prototype,"getTempFileURL",null),o([y({customInfo:{className:"Cloudbase",methodName:"downloadFile"},title:"下载文件失败",messages:["请确认以下各项:"," 1 - 调用 downloadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f)]}),i("design:type",Function),i("design:paramtypes",[Object,Function]),i("design:returntype",Promise)],t.prototype,"downloadFile",null),t}()),m={name:g,entity:{uploadFile:v.uploadFile,deleteFile:v.deleteFile,getTempFileURL:v.getTempFileURL,downloadFile:v.downloadFile,getUploadMetadata:v.getUploadMetadata}};try{cloudbase.registerComponent(m)}catch(t){}function _(t){try{t.registerComponent(m)}catch(t){console.warn(t)}}},182:function(t,e,n){"use strict";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};Object.defineProperty(e,"__esModule",{value:!0}),e.useDefaultAdapter=e.useAdapters=e.RUNTIME=void 0;var s,a=i(n(274)),c=n(616);!function(t){t.WEB="web",t.WX_MP="wx_mp"}(s=e.RUNTIME||(e.RUNTIME={})),e.useAdapters=function(t){for(var e=0,n=(0,c.isArray)(t)?t:[t];e<n.length;e++){var r=n[e],o=r.isMatch,i=r.genAdapter,s=r.runtime;if(o())return{adapter:i(),runtime:s}}},e.useDefaultAdapter=function(){return{adapter:a.genAdapter(),runtime:s.WEB}}},274:function(t,e,n){"use strict";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)},s=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.WebRequest=e.genAdapter=void 0;var c=n(829),u=n(616),f=n(946),l=function(t){function e(e){var n=t.call(this)||this,r=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return n._timeout=r||0,n._timeoutMsg=o||"请求超时",n._restrictedMethods=i||["get","post","upload","download"],n}return o(e,t),e.prototype.get=function(t){return this._request(i(i({},t),{method:"get"}),this._restrictedMethods.includes("get"))},e.prototype.post=function(t){return this._request(i(i({},t),{method:"post"}),this._restrictedMethods.includes("post"))},e.prototype.put=function(t){return this._request(i(i({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,n=t.file,r=t.name,o=new FormData;for(var s in e)o.append(s,e[s]);return o.append("key",r),o.append("file",n),this._request(i(i({},t),{data:o,method:"post"}),this._restrictedMethods.includes("upload"))},e.prototype.download=function(t){return s(this,void 0,void 0,(function(){var e,n,r,o;return a(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.get(i(i({},t),{headers:{},responseType:"blob"}))];case 1:return e=s.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 s.sent(),[3,3];case 3:return[2,new Promise((function(e){e({statusCode:200,tempFilePath:t.url})}))]}}))}))},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,s,a=t.url,c=t.headers,l=void 0===c?{}:c,h=t.data,p=t.responseType,d=t.withCredentials,y=t.body,g=t.onUploadProgress,v=(0,u.formatUrl)((0,f.getProtocol)(),a,"get"===r?h:{}),m=new XMLHttpRequest;for(var _ in m.open(r,v),p&&(m.responseType=p),l)m.setRequestHeader(_,l[_]);g&&m.upload.addEventListener("progress",g),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"===p?m.response:JSON.parse(m.responseText)}catch(e){t.data="blob"===p?m.response:m.responseText}clearTimeout(i),o(t)}},e&&n._timeout&&(i=setTimeout((function(){console.warn(n._timeoutMsg),m.abort()}),n._timeout)),s=(0,u.isFormData)(h)?h:"application/x-www-form-urlencoded"===l["content-type"]?(0,u.toQueryString)(h):y||(h?JSON.stringify(h):void 0),d&&(m.withCredentials=!0),m.send(s)}))},e}(c.AbstractSDKRequest);e.WebRequest=l,e.genAdapter=function(){return{root:window,reqClass:l,wsClass:WebSocket,localStorage:localStorage,sessionStorage:sessionStorage}}},946:function(t,e){"use strict";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="undefined"!=typeof location&&"http:"===location.protocol?"http:":"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"},205:function(t,e){"use strict";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"}},794:function(t,e,n){"use strict";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(946),e),o(n(205),e)},718:function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.catchErrorsDecorator=void 0;var i=n(616),s=n(794),a=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(a=-1!==navigator.userAgent.indexOf("Firefox"));var c=a?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,u=/https?\:\/\/.+\:\d*\/.*\.js\:\d+\:\d+/;function f(t){var e=t.err,n=t.className,r=t.methodName,o=t.sourceLink;if(!o)return null;var i,s=e.stack.split("\n"),c=a?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(n,"\\.descriptor.value\\s*\\[as\\s").concat(r,"\\]\\s*\\(.*\\)$")),f=a?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(n,"\\.descriptor.value\\s*\\[as\\s").concat(r,"\\]")),l=s.findIndex((function(t){return c.test(t)}));if(-1!==l){var h=s.filter((function(t,e){return e>l}));h.unshift(s[l].replace(f,"".concat(n,".").concat(r)).replace(u,o)),(i=new Error).stack="".concat(a?"@debugger":"Error","\n").concat(h.join("\n"))}return i}e.catchErrorsDecorator=function(t){var e=t.mode,n=void 0===e?"async":e,a=t.customInfo,l=void 0===a?{}:a,h=t.title,p=t.messages,d=void 0===p?[]:p;return function(t,e,a){if(s.IS_DEBUG_MODE){var p=l.className||t.constructor.name,y=l.methodName||e,g=a.value,v=function(){var t="",e=(new Error).stack.split("\n"),n=e.findIndex((function(t){return c.test(t)}));if(-1!==n){var r=u.exec(e[n+1]||"");t=r?r[0]:""}return t}();a.value="sync"===n?function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=f({err:new Error,className:p,methodName:y,sourceLink:v});try{return g.apply(this,t)}catch(t){var r=t,o=t.message,s={title:h||"".concat(p,".").concat(y," failed"),content:[{type:"error",body:t}]};if(o&&/^\{.*\}$/.test(o)){var a=JSON.parse(o);s.subtitle=o,a.code&&(n?(n.code=a.code,n.msg=a.msg):(t.code=a.code,t.message=a.msg),r=n||t,s.content=d.map((function(t){return{type:"info",body:t}})))}throw(0,i.printGroupLog)(s),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,s,a,c;return o(this,(function(o){switch(o.label){case 0:e=f({err:new Error,className:p,methodName:y,sourceLink:v}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,g.apply(this,t)];case 2:return[2,o.sent()];case 3:throw n=o.sent(),r=n,s=n.message,a={title:h||"".concat(p,".").concat(y," failed"),content:[{type:"error",body:n}]},s&&/^\{.*\}$/.test(s)&&(c=JSON.parse(s),a.subtitle=c,c.code&&(e?(e.code=c.code,e.message=c.msg):(n.code=c.code,n.message=c.msg),r=e||n,a.content=d.map((function(t){return{type:"info",body:t}})))),(0,i.printGroupLog)(a),r;case 4:return[2]}}))}))}}}}},141:function(t,e,n){"use strict";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(718),e)},650:function(t,e,n){"use strict";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};Object.defineProperty(e,"__esModule",{value:!0}),e.helpers=e.utils=e.events=e.cache=e.adapters=e.constants=void 0;var s=i(n(794));e.constants=s;var a=i(n(182));e.adapters=a;var c=i(n(197));e.cache=c;var u=i(n(689));e.events=u;var f=i(n(616));e.utils=f;var l=i(n(141));e.helpers=l},197:function(t,e,n){"use strict";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 s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},s=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.CloudbaseCache=void 0;var a=n(829),c=n(616),u=n(794),f=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}(a.AbstractStorage);function l(t,e){switch(t){case"local":default:return e.localStorage?e.localStorage:((0,c.printWarn)(u.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new f(e.root));case"none":return new f(e.root);case"session":return e.sessionStorage?e.sessionStorage:((0,c.printWarn)(u.ERRORS.INVALID_PARAMS,"sessionStorage is not supported on current platform"),new f(e.root))}}var h=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,s=t.alwaysLocalKeys,a=void 0===s?[]:s;this._platformInfo=r,this._alwaysLocalKeys=a,this._storage||(this._persistence=r.adapter.primaryStorage||e,this._storage=l(this._persistence,r.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._persistence},enumerable:!1,configurable:!0}),t.prototype.updatePersistence=function(t){if("async"!==this.mode){if(t!==this._persistence){var e="local"===this._persistence;this._persistence=t;var n=l(t,this._platformInfo.adapter);for(var r in this.keys){var o=this.keys[r];if(!e||!this._alwaysLocalKeys.includes(r)){var i=this._storage.getItem(o);(0,c.isUndefined)(i)||(0,c.isNull)(i)||(n.setItem(o,i),this._storage.removeItem(o))}}this._storage=n}}else(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use updatePersistenceAsync insteed")},t.prototype.updatePersistenceAsync=function(t){return i(this,void 0,void 0,(function(){var e,n,r,o,i,a,u,f,h;return s(this,(function(s){switch(s.label){case 0:if(t===this._persistence)return[2];for(i in e="local"===this._persistence,this._persistence=t,n=l(t,this._platformInfo.adapter),r=this.keys,o=[],r)o.push(i);a=0,s.label=1;case 1:return a<o.length?(i=o[a])in r?(u=i,f=this.keys[u],e&&this._alwaysLocalKeys.includes(u)?[3,4]:[4,this._storage.getItem(f)]):[3,4]:[3,5];case 2:return h=s.sent(),(0,c.isUndefined)(h)||(0,c.isNull)(h)?[3,4]:(n.setItem(f,h),[4,this._storage.removeItem(f)]);case 3:s.sent(),s.label=4;case 4:return a++,[3,1];case 5:return this._storage=n,[2]}}))}))},t.prototype.setStore=function(t,e,n){if("async"!==this.mode){if(this._storage)try{var r={version:n||"localCachev1",content:e};this._storage.setItem(t,JSON.stringify(r))}catch(t){throw new Error(JSON.stringify({code:u.ERRORS.OPERATION_FAIL,msg:"[".concat((0,u.getSdkName)(),"][").concat(u.ERRORS.OPERATION_FAIL,"]setStore failed"),info:t}))}}else(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,n){return i(this,void 0,void 0,(function(){var r;return s(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=process.env)||void 0===n?void 0:n.tcb_token))return process.env.tcb_token;if(!this._storage)return""}catch(t){return""}e=e||"localCachev1";var r=this._storage.getItem(t);return r&&r.indexOf(e)>=0?JSON.parse(r).content:""}(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){var n;return i(this,void 0,void 0,(function(){var r;return s(this,(function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(n=process.env)||void 0===n?void 0:n.tcb_token))return[2,process.env.tcb_token];if(!this._storage)return[2,""]}catch(t){return[2,""]}return e=e||"localCachev1",[4,this._storage.getItem(t)];case 1:return(r=o.sent())&&r.indexOf(e)>=0?[2,JSON.parse(r).content]:[2,""]}}))}))},t.prototype.removeStore=function(t){"async"!==this.mode?this._storage.removeItem(t):(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},t.prototype.removeStoreAsync=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._storage.removeItem(t)];case 1:return e.sent(),[2]}}))}))},t}();e.CloudbaseCache=h},689:function(t,e,n){"use strict";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 s=n(616),a=function(t,e){this.data=e||null,this.name=t};e.CloudbaseEvent=a;var c=function(t){function e(e,n){var r=t.call(this,"error",{error:e,data:n})||this;return r.error=e,r}return o(e,t),e}(a);e.IErrorEvent=c;var u=function(){function t(){this._listeners={}}return t.prototype.on=function(t,e){return function(t,e,n){n[t]=n[t]||[],n[t].push(e)}(t,e,this._listeners),this},t.prototype.off=function(t,e){return function(t,e,n){if(null==n?void 0:n[t]){var r=n[t].indexOf(e);-1!==r&&n[t].splice(r,1)}}(t,e,this._listeners),this},t.prototype.fire=function(t,e){if((0,s.isInstanceOf)(t,c))return console.error(t.error),this;var n=(0,s.isString)(t)?new a(t,e||{}):t,r=n.name;if(this._listens(r)){n.target=this;for(var o=0,u=this._listeners[r]?i([],this._listeners[r],!0):[];o<u.length;o++)u[o].call(this,n)}return this},t.prototype._listens=function(t){return this._listeners[t]&&this._listeners[t].length>0},t}();e.CloudbaseEventEmitter=u;var f=new u;e.addEventListener=function(t,e){f.on(t,e)},e.activateEvent=function(t,e){void 0===e&&(e={}),f.fire(t,e)},e.removeEventListener=function(t,e){f.off(t,e)}},616:function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.transformPhone=e.sleep=e.printGroupLog=e.throwError=e.printInfo=e.printError=e.printWarn=e.execCallback=e.createPromiseCallback=e.removeParam=e.getHash=e.getQuery=e.toQueryString=e.createSign=e.formatUrl=e.genSeqId=e.isFormData=e.isInstanceOf=e.isNull=e.isPalinObject=e.isUndefined=e.isString=e.isArray=void 0;var o=r(n(61)),i=r(n(139)),s=r(n(307)),a=n(794);function c(t){var e=i.default.stringify(t);return(e=(e=e.replace(/=+$/,"")).replace(/\+/g,"-")).replace(/\//g,"_")}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.formatUrl=function(t,e,n){void 0===n&&(n={});var r=/\?/.test(e),o="";for(var i in n)""===o?!r&&(e+="?"):o+="&",o+="".concat(i,"=").concat(encodeURIComponent(n[i]));return/^http(s)?\:\/\//.test(e+=o)?e:"".concat(t).concat(e)},e.createSign=function(t,e){var n=c(s.default.parse(JSON.stringify({alg:"HS256",typ:"JWT"}))),r=c(s.default.parse(JSON.stringify(t))),i="".concat(n,".").concat(r),a=c((0,o.default)(i,e));return"".concat(i,".").concat(a)},e.toQueryString=function(t){void 0===t&&(t={});var e=[];for(var n in t)e.push("".concat(n,"=").concat(encodeURIComponent(t[n])));return e.join("&")},e.getQuery=function(t,e){if("undefined"==typeof window)return!1;var n=e||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,a.getSdkName)(),"][").concat(t,"]:").concat(e))},e.printError=function(t,e){console.error({code:t,msg:"[".concat((0,a.getSdkName)(),"][").concat(t,"]:").concat(e)})},e.printInfo=function(t,e){console.log("[".concat((0,a.getSdkName)(),"][").concat(t,"]:").concat(e))},e.throwError=function(t,e){throw new Error(JSON.stringify({code:t,msg:"[".concat((0,a.getSdkName)(),"][").concat(t,"]:").concat(e)}))},e.printGroupLog=function(t){var e=t.title,n=t.subtitle,r=void 0===n?"":n,o=t.content,i=void 0===o?[]:o,s=t.printTrace,a=void 0!==s&&s,c=t.collapsed;void 0!==c&&c?console.groupCollapsed(e,r):console.group(e,r);for(var u=0,f=i;u<f.length;u++){var l=f[u],h=l.type,p=l.body;switch(h){case"info":console.log(p);break;case"warn":console.warn(p);break;case"error":console.error(p)}}a&&console.trace("stack trace:"),console.groupEnd()},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)}},359:function(t,e,n){var r;t.exports=(r=r||function(t){var e;if("undefined"!=typeof window&&window.crypto&&(e=window.crypto),"undefined"!=typeof self&&self.crypto&&(e=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(e=globalThis.crypto),!e&&"undefined"!=typeof window&&window.msCrypto&&(e=window.msCrypto),!e&&void 0!==n.g&&n.g.crypto&&(e=n.g.crypto),!e)try{e=n(633)}catch(t){}var r=function(){if(e){if("function"==typeof e.getRandomValues)try{return e.getRandomValues(new Uint32Array(1))[0]}catch(t){}if("function"==typeof e.randomBytes)try{return e.randomBytes(4).readInt32LE()}catch(t){}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||function(){function t(){}return function(e){var n;return t.prototype=e,n=new t,t.prototype=null,n}}(),i={},s=i.lib={},a=s.Base={extend:function(t){var e=o(this);return t&&e.mixIn(t),e.hasOwnProperty("init")&&this.init!==e.init||(e.init=function(){e.$super.init.apply(this,arguments)}),e.init.prototype=e,e.$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},c=s.WordArray=a.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:4*t.length},toString:function(t){return(t||f).stringify(this)},concat:function(t){var e=this.words,n=t.words,r=this.sigBytes,o=t.sigBytes;if(this.clamp(),r%4)for(var i=0;i<o;i++){var s=n[i>>>2]>>>24-i%4*8&255;e[r+i>>>2]|=s<<24-(r+i)%4*8}else for(var a=0;a<o;a+=4)e[r+a>>>2]=n[a>>>2];return this.sigBytes+=o,this},clamp:function(){var e=this.words,n=this.sigBytes;e[n>>>2]&=4294967295<<32-n%4*8,e.length=t.ceil(n/4)},clone:function(){var t=a.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],n=0;n<t;n+=4)e.push(r());return new c.init(e,t)}}),u=i.enc={},f=u.Hex={stringify:function(t){for(var e=t.words,n=t.sigBytes,r=[],o=0;o<n;o++){var i=e[o>>>2]>>>24-o%4*8&255;r.push((i>>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r<e;r+=2)n[r>>>3]|=parseInt(t.substr(r,2),16)<<24-r%8*4;return new c.init(n,e/2)}},l=u.Latin1={stringify:function(t){for(var e=t.words,n=t.sigBytes,r=[],o=0;o<n;o++){var i=e[o>>>2]>>>24-o%4*8&255;r.push(String.fromCharCode(i))}return r.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r<e;r++)n[r>>>2]|=(255&t.charCodeAt(r))<<24-r%4*8;return new c.init(n,e)}},h=u.Utf8={stringify:function(t){try{return decodeURIComponent(escape(l.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return l.parse(unescape(encodeURIComponent(t)))}},p=s.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=h.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var n,r=this._data,o=r.words,i=r.sigBytes,s=this.blockSize,a=i/(4*s),u=(a=e?t.ceil(a):t.max((0|a)-this._minBufferSize,0))*s,f=t.min(4*u,i);if(u){for(var l=0;l<u;l+=s)this._doProcessBlock(o,l);n=o.splice(0,u),r.sigBytes-=f}return new c.init(n,f)},clone:function(){var t=a.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0}),d=(s.Hasher=p.extend({cfg:a.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){p.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){return t&&this._append(t),this._doFinalize()},blockSize:16,_createHelper:function(t){return function(e,n){return new t.init(n).finalize(e)}},_createHmacHelper:function(t){return function(e,n){return new d.HMAC.init(t,n).finalize(e)}}}),i.algo={});return i}(Math),r)},139:function(t,e,n){var r,o,i;t.exports=(r=n(359),i=(o=r).lib.WordArray,o.enc.Base64={stringify:function(t){var e=t.words,n=t.sigBytes,r=this._map;t.clamp();for(var o=[],i=0;i<n;i+=3)for(var s=(e[i>>>2]>>>24-i%4*8&255)<<16|(e[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|e[i+2>>>2]>>>24-(i+2)%4*8&255,a=0;a<4&&i+.75*a<n;a++)o.push(r.charAt(s>>>6*(3-a)&63));var c=r.charAt(64);if(c)for(;o.length%4;)o.push(c);return o.join("")},parse:function(t){var e=t.length,n=this._map,r=this._reverseMap;if(!r){r=this._reverseMap=[];for(var o=0;o<n.length;o++)r[n.charCodeAt(o)]=o}var s=n.charAt(64);if(s){var a=t.indexOf(s);-1!==a&&(e=a)}return function(t,e,n){for(var r=[],o=0,s=0;s<e;s++)if(s%4){var a=n[t.charCodeAt(s-1)]<<s%4*2|n[t.charCodeAt(s)]>>>6-s%4*2;r[o>>>2]|=a<<24-o%4*8,o++}return i.create(r,o)}(t,e,r)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},r.enc.Base64)},307:function(t,e,n){t.exports=n(359).enc.Utf8},61:function(t,e,n){var r;t.exports=(r=n(359),n(93),n(423),r.HmacSHA256)},423:function(t,e,n){var r,o,i;t.exports=(o=(r=n(359)).lib.Base,i=r.enc.Utf8,void(r.algo.HMAC=o.extend({init:function(t,e){t=this._hasher=new t.init,"string"==typeof e&&(e=i.parse(e));var n=t.blockSize,r=4*n;e.sigBytes>r&&(e=t.finalize(e)),e.clamp();for(var o=this._oKey=e.clone(),s=this._iKey=e.clone(),a=o.words,c=s.words,u=0;u<n;u++)a[u]^=1549556828,c[u]^=909522486;o.sigBytes=s.sigBytes=r,this.reset()},reset:function(){var t=this._hasher;t.reset(),t.update(this._iKey)},update:function(t){return this._hasher.update(t),this},finalize:function(t){var e=this._hasher,n=e.finalize(t);return e.reset(),e.finalize(this._oKey.clone().concat(n))}})))},93:function(t,e,n){var r;t.exports=(r=n(359),function(t){var e=r,n=e.lib,o=n.WordArray,i=n.Hasher,s=e.algo,a=[],c=[];!function(){function e(e){for(var n=t.sqrt(e),r=2;r<=n;r++)if(!(e%r))return!1;return!0}function n(t){return 4294967296*(t-(0|t))|0}for(var r=2,o=0;o<64;)e(r)&&(o<8&&(a[o]=n(t.pow(r,.5))),c[o]=n(t.pow(r,1/3)),o++),r++}();var u=[],f=s.SHA256=i.extend({_doReset:function(){this._hash=new o.init(a.slice(0))},_doProcessBlock:function(t,e){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],s=n[3],a=n[4],f=n[5],l=n[6],h=n[7],p=0;p<64;p++){if(p<16)u[p]=0|t[e+p];else{var d=u[p-15],y=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,g=u[p-2],v=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;u[p]=y+u[p-7]+v+u[p-16]}var m=r&o^r&i^o&i,_=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),w=h+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&f^~a&l)+c[p]+u[p];h=l,l=f,f=a,a=s+w|0,s=i,i=o,o=r,r=w+(_+m)|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+a|0,n[5]=n[5]+f|0,n[6]=n[6]+l|0,n[7]=n[7]+h|0},_doFinalize:function(){var e=this._data,n=e.words,r=8*this._nDataBytes,o=8*e.sigBytes;return n[o>>>5]|=128<<24-o%32,n[14+(o+64>>>9<<4)]=t.floor(r/4294967296),n[15+(o+64>>>9<<4)]=r,e.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=i._createHelper(f),e.HmacSHA256=i._createHmacHelper(f)}(Math),r.SHA256)},907:function(t,e,n){t=n.nmd(t);var r="__lodash_hash_undefined__",o=9007199254740991,i="[object Arguments]",s="[object Boolean]",a="[object Date]",c="[object Function]",u="[object GeneratorFunction]",f="[object Map]",l="[object Number]",h="[object Object]",p="[object Promise]",d="[object RegExp]",y="[object Set]",g="[object String]",v="[object Symbol]",m="[object WeakMap]",_="[object ArrayBuffer]",w="[object DataView]",b="[object Float32Array]",E="[object Float64Array]",S="[object Int8Array]",I="[object Int16Array]",O="[object Int32Array]",A="[object Uint8Array]",T="[object Uint8ClampedArray]",N="[object Uint16Array]",R="[object Uint32Array]",P=/\w*$/,x=/^\[object .+?Constructor\]$/,L=/^(?:0|[1-9]\d*)$/,C={};C[i]=C["[object Array]"]=C[_]=C[w]=C[s]=C[a]=C[b]=C[E]=C[S]=C[I]=C[O]=C[f]=C[l]=C[h]=C[d]=C[y]=C[g]=C[v]=C[A]=C[T]=C[N]=C[R]=!0,C["[object Error]"]=C[c]=C[m]=!1;var k="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,U="object"==typeof self&&self&&self.Object===Object&&self,j=k||U||Function("return this")(),D=e&&!e.nodeType&&e,M=D&&t&&!t.nodeType&&t,q=M&&M.exports===D;function B(t,e){return t.set(e[0],e[1]),t}function F(t,e){return t.add(e),t}function W(t,e,n,r){var o=-1,i=t?t.length:0;for(r&&i&&(n=t[++o]);++o<i;)n=e(n,t[o],o,t);return n}function $(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}function H(t){var e=-1,n=Array(t.size);return t.forEach((function(t,r){n[++e]=[r,t]})),n}function G(t,e){return function(n){return t(e(n))}}function K(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=t})),n}var V,J=Array.prototype,Y=Function.prototype,z=Object.prototype,X=j["__core-js_shared__"],Z=(V=/[^.]+$/.exec(X&&X.keys&&X.keys.IE_PROTO||""))?"Symbol(src)_1."+V:"",Q=Y.toString,tt=z.hasOwnProperty,et=z.toString,nt=RegExp("^"+Q.call(tt).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),rt=q?j.Buffer:void 0,ot=j.Symbol,it=j.Uint8Array,st=G(Object.getPrototypeOf,Object),at=Object.create,ct=z.propertyIsEnumerable,ut=J.splice,ft=Object.getOwnPropertySymbols,lt=rt?rt.isBuffer:void 0,ht=G(Object.keys,Object),pt=jt(j,"DataView"),dt=jt(j,"Map"),yt=jt(j,"Promise"),gt=jt(j,"Set"),vt=jt(j,"WeakMap"),mt=jt(Object,"create"),_t=Ft(pt),wt=Ft(dt),bt=Ft(yt),Et=Ft(gt),St=Ft(vt),It=ot?ot.prototype:void 0,Ot=It?It.valueOf:void 0;function At(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function Tt(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function Nt(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function Rt(t){this.__data__=new Tt(t)}function Pt(t,e,n){var r=t[e];tt.call(t,e)&&Wt(r,n)&&(void 0!==n||e in t)||(t[e]=n)}function xt(t,e){for(var n=t.length;n--;)if(Wt(t[n][0],e))return n;return-1}function Lt(t,e,n,r,o,p,m){var x;if(r&&(x=p?r(t,o,p,m):r(t)),void 0!==x)return x;if(!Vt(t))return t;var L=$t(t);if(L){if(x=function(t){var e=t.length,n=t.constructor(e);return e&&"string"==typeof t[0]&&tt.call(t,"index")&&(n.index=t.index,n.input=t.input),n}(t),!e)return function(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e}(t,x)}else{var k=Mt(t),U=k==c||k==u;if(Gt(t))return function(t,e){if(e)return t.slice();var n=new t.constructor(t.length);return t.copy(n),n}(t,e);if(k==h||k==i||U&&!p){if($(t))return p?t:{};if(x=function(t){return"function"!=typeof t.constructor||Bt(t)?{}:Vt(e=st(t))?at(e):{};var e}(U?{}:t),!e)return function(t,e){return kt(t,Dt(t),e)}(t,function(t,e){return t&&kt(e,Jt(e),t)}(x,t))}else{if(!C[k])return p?t:{};x=function(t,e,n,r){var o,i=t.constructor;switch(e){case _:return Ct(t);case s:case a:return new i(+t);case w:return function(t,e){var n=e?Ct(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}(t,r);case b:case E:case S:case I:case O:case A:case T:case N:case R:return function(t,e){var n=e?Ct(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}(t,r);case f:return function(t,e,n){return W(e?n(H(t),!0):H(t),B,new t.constructor)}(t,r,n);case l:case g:return new i(t);case d:return function(t){var e=new t.constructor(t.source,P.exec(t));return e.lastIndex=t.lastIndex,e}(t);case y:return function(t,e,n){return W(e?n(K(t),!0):K(t),F,new t.constructor)}(t,r,n);case v:return o=t,Ot?Object(Ot.call(o)):{}}}(t,k,Lt,e)}}m||(m=new Rt);var j=m.get(t);if(j)return j;if(m.set(t,x),!L)var D=n?function(t){return function(t,e,n){var r=e(t);return $t(t)?r:function(t,e){for(var n=-1,r=e.length,o=t.length;++n<r;)t[o+n]=e[n];return t}(r,n(t))}(t,Jt,Dt)}(t):Jt(t);return function(t,e){for(var n=-1,r=t?t.length:0;++n<r&&!1!==e(t[n],n););}(D||t,(function(o,i){D&&(o=t[i=o]),Pt(x,i,Lt(o,e,n,r,i,t,m))})),x}function Ct(t){var e=new t.constructor(t.byteLength);return new it(e).set(new it(t)),e}function kt(t,e,n,r){n||(n={});for(var o=-1,i=e.length;++o<i;){var s=e[o],a=r?r(n[s],t[s],s,n,t):void 0;Pt(n,s,void 0===a?t[s]:a)}return n}function Ut(t,e){var n,r,o=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof e?"string":"hash"]:o.map}function jt(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return function(t){return!(!Vt(t)||(e=t,Z&&Z in e))&&(Kt(t)||$(t)?nt:x).test(Ft(t));var e}(n)?n:void 0}At.prototype.clear=function(){this.__data__=mt?mt(null):{}},At.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},At.prototype.get=function(t){var e=this.__data__;if(mt){var n=e[t];return n===r?void 0:n}return tt.call(e,t)?e[t]:void 0},At.prototype.has=function(t){var e=this.__data__;return mt?void 0!==e[t]:tt.call(e,t)},At.prototype.set=function(t,e){return this.__data__[t]=mt&&void 0===e?r:e,this},Tt.prototype.clear=function(){this.__data__=[]},Tt.prototype.delete=function(t){var e=this.__data__,n=xt(e,t);return!(n<0||(n==e.length-1?e.pop():ut.call(e,n,1),0))},Tt.prototype.get=function(t){var e=this.__data__,n=xt(e,t);return n<0?void 0:e[n][1]},Tt.prototype.has=function(t){return xt(this.__data__,t)>-1},Tt.prototype.set=function(t,e){var n=this.__data__,r=xt(n,t);return r<0?n.push([t,e]):n[r][1]=e,this},Nt.prototype.clear=function(){this.__data__={hash:new At,map:new(dt||Tt),string:new At}},Nt.prototype.delete=function(t){return Ut(this,t).delete(t)},Nt.prototype.get=function(t){return Ut(this,t).get(t)},Nt.prototype.has=function(t){return Ut(this,t).has(t)},Nt.prototype.set=function(t,e){return Ut(this,t).set(t,e),this},Rt.prototype.clear=function(){this.__data__=new Tt},Rt.prototype.delete=function(t){return this.__data__.delete(t)},Rt.prototype.get=function(t){return this.__data__.get(t)},Rt.prototype.has=function(t){return this.__data__.has(t)},Rt.prototype.set=function(t,e){var n=this.__data__;if(n instanceof Tt){var r=n.__data__;if(!dt||r.length<199)return r.push([t,e]),this;n=this.__data__=new Nt(r)}return n.set(t,e),this};var Dt=ft?G(ft,Object):function(){return[]},Mt=function(t){return et.call(t)};function qt(t,e){return!!(e=null==e?o:e)&&("number"==typeof t||L.test(t))&&t>-1&&t%1==0&&t<e}function Bt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||z)}function Ft(t){if(null!=t){try{return Q.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function Wt(t,e){return t===e||t!=t&&e!=e}(pt&&Mt(new pt(new ArrayBuffer(1)))!=w||dt&&Mt(new dt)!=f||yt&&Mt(yt.resolve())!=p||gt&&Mt(new gt)!=y||vt&&Mt(new vt)!=m)&&(Mt=function(t){var e=et.call(t),n=e==h?t.constructor:void 0,r=n?Ft(n):void 0;if(r)switch(r){case _t:return w;case wt:return f;case bt:return p;case Et:return y;case St:return m}return e});var $t=Array.isArray;function Ht(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=o}(t.length)&&!Kt(t)}var Gt=lt||function(){return!1};function Kt(t){var e=Vt(t)?et.call(t):"";return e==c||e==u}function Vt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Jt(t){return Ht(t)?function(t,e){var n=$t(t)||function(t){return function(t){return function(t){return!!t&&"object"==typeof t}(t)&&Ht(t)}(t)&&tt.call(t,"callee")&&(!ct.call(t,"callee")||et.call(t)==i)}(t)?function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}(t.length,String):[],r=n.length,o=!!r;for(var s in t)!e&&!tt.call(t,s)||o&&("length"==s||qt(s,r))||n.push(s);return n}(t):function(t){if(!Bt(t))return ht(t);var e=[];for(var n in Object(t))tt.call(t,n)&&"constructor"!=n&&e.push(n);return e}(t)}t.exports=function(t){return Lt(t,!0,!0)}},880:function(t,e,n){var r,o="__lodash_hash_undefined__",i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/,a=/^\./,c=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,u=/\\(\\)?/g,f=/^\[object .+?Constructor\]$/,l=/^(?:0|[1-9]\d*)$/,h="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,p="object"==typeof self&&self&&self.Object===Object&&self,d=h||p||Function("return this")(),y=Array.prototype,g=Function.prototype,v=Object.prototype,m=d["__core-js_shared__"],_=(r=/[^.]+$/.exec(m&&m.keys&&m.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",w=g.toString,b=v.hasOwnProperty,E=v.toString,S=RegExp("^"+w.call(b).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),I=d.Symbol,O=y.splice,A=j(d,"Map"),T=j(Object,"create"),N=I?I.prototype:void 0,R=N?N.toString:void 0;function P(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function x(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function L(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function C(t,e,n){var r=t[e];b.call(t,e)&&F(r,n)&&(void 0!==n||e in t)||(t[e]=n)}function k(t,e){for(var n=t.length;n--;)if(F(t[n][0],e))return n;return-1}function U(t,e){var n,r,o=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof e?"string":"hash"]:o.map}function j(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return function(t){if(!$(t)||_&&_ in t)return!1;var e=function(t){var e=$(t)?E.call(t):"";return"[object Function]"==e||"[object GeneratorFunction]"==e}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?S:f;return e.test(function(t){if(null!=t){try{return w.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}(n)?n:void 0}function D(t,e){return!!(e=null==e?9007199254740991:e)&&("number"==typeof t||l.test(t))&&t>-1&&t%1==0&&t<e}P.prototype.clear=function(){this.__data__=T?T(null):{}},P.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},P.prototype.get=function(t){var e=this.__data__;if(T){var n=e[t];return n===o?void 0:n}return b.call(e,t)?e[t]:void 0},P.prototype.has=function(t){var e=this.__data__;return T?void 0!==e[t]:b.call(e,t)},P.prototype.set=function(t,e){return this.__data__[t]=T&&void 0===e?o:e,this},x.prototype.clear=function(){this.__data__=[]},x.prototype.delete=function(t){var e=this.__data__,n=k(e,t);return!(n<0||(n==e.length-1?e.pop():O.call(e,n,1),0))},x.prototype.get=function(t){var e=this.__data__,n=k(e,t);return n<0?void 0:e[n][1]},x.prototype.has=function(t){return k(this.__data__,t)>-1},x.prototype.set=function(t,e){var n=this.__data__,r=k(n,t);return r<0?n.push([t,e]):n[r][1]=e,this},L.prototype.clear=function(){this.__data__={hash:new P,map:new(A||x),string:new P}},L.prototype.delete=function(t){return U(this,t).delete(t)},L.prototype.get=function(t){return U(this,t).get(t)},L.prototype.has=function(t){return U(this,t).has(t)},L.prototype.set=function(t,e){return U(this,t).set(t,e),this};var M=B((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(H(t))return R?R.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}(e);var n=[];return a.test(t)&&n.push(""),t.replace(c,(function(t,e,r,o){n.push(r?o.replace(u,"$1"):e||t)})),n}));function q(t){if("string"==typeof t||H(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function B(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError("Expected a function");var n=function(){var r=arguments,o=e?e.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=t.apply(this,r);return n.cache=i.set(o,s),s};return n.cache=new(B.Cache||L),n}function F(t,e){return t===e||t!=t&&e!=e}B.Cache=L;var W=Array.isArray;function $(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function H(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==E.call(t)}t.exports=function(t,e,n){return null==t?t:function(t,e,n,r){if(!$(t))return t;e=function(t,e){if(W(t))return!1;var n=typeof t;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=t&&!H(t))||s.test(t)||!i.test(t)||null!=e&&t in Object(e)}(e,t)?[e]:function(t){return W(t)?t:M(t)}(e);for(var o=-1,a=e.length,c=a-1,u=t;null!=u&&++o<a;){var f=q(e[o]),l=n;if(o!=c){var h=u[f];void 0===(l=r?r(h,f,u):void 0)&&(l=$(h)?h:D(e[o+1])?[]:{})}C(u,f,l),u=u[f]}return t}(t,e,n)}},373:function(t,e,n){var r,o="__lodash_hash_undefined__",i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/,a=/^\./,c=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,u=/\\(\\)?/g,f=/^\[object .+?Constructor\]$/,l="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,h="object"==typeof self&&self&&self.Object===Object&&self,p=l||h||Function("return this")(),d=Array.prototype,y=Function.prototype,g=Object.prototype,v=p["__core-js_shared__"],m=(r=/[^.]+$/.exec(v&&v.keys&&v.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",_=y.toString,w=g.hasOwnProperty,b=g.toString,E=RegExp("^"+_.call(w).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),S=p.Symbol,I=d.splice,O=U(p,"Map"),A=U(Object,"create"),T=S?S.prototype:void 0,N=T?T.toString:void 0;function R(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function P(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function x(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function L(t,e){for(var n,r,o=t.length;o--;)if((n=t[o][0])===(r=e)||n!=n&&r!=r)return o;return-1}function C(t){return B(t)?t:D(t)}function k(t,e){var n,r,o=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof e?"string":"hash"]:o.map}function U(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return function(t){if(!F(t)||m&&m in t)return!1;var e=function(t){var e=F(t)?b.call(t):"";return"[object Function]"==e||"[object GeneratorFunction]"==e}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?E:f;return e.test(function(t){if(null!=t){try{return _.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}(n)?n:void 0}function j(t,e){if(B(t))return!1;var n=typeof t;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=t&&!W(t))||s.test(t)||!i.test(t)||null!=e&&t in Object(e)}R.prototype.clear=function(){this.__data__=A?A(null):{}},R.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},R.prototype.get=function(t){var e=this.__data__;if(A){var n=e[t];return n===o?void 0:n}return w.call(e,t)?e[t]:void 0},R.prototype.has=function(t){var e=this.__data__;return A?void 0!==e[t]:w.call(e,t)},R.prototype.set=function(t,e){return this.__data__[t]=A&&void 0===e?o:e,this},P.prototype.clear=function(){this.__data__=[]},P.prototype.delete=function(t){var e=this.__data__,n=L(e,t);return!(n<0||(n==e.length-1?e.pop():I.call(e,n,1),0))},P.prototype.get=function(t){var e=this.__data__,n=L(e,t);return n<0?void 0:e[n][1]},P.prototype.has=function(t){return L(this.__data__,t)>-1},P.prototype.set=function(t,e){var n=this.__data__,r=L(n,t);return r<0?n.push([t,e]):n[r][1]=e,this},x.prototype.clear=function(){this.__data__={hash:new R,map:new(O||P),string:new R}},x.prototype.delete=function(t){return k(this,t).delete(t)},x.prototype.get=function(t){return k(this,t).get(t)},x.prototype.has=function(t){return k(this,t).has(t)},x.prototype.set=function(t,e){return k(this,t).set(t,e),this};var D=q((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(W(t))return N?N.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}(e);var n=[];return a.test(t)&&n.push(""),t.replace(c,(function(t,e,r,o){n.push(r?o.replace(u,"$1"):e||t)})),n}));function M(t){if("string"==typeof t||W(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function q(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError("Expected a function");var n=function(){var r=arguments,o=e?e.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=t.apply(this,r);return n.cache=i.set(o,s),s};return n.cache=new(q.Cache||x),n}q.Cache=x;var B=Array.isArray;function F(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function W(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==b.call(t)}t.exports=function(t,e){return null==t||function(t,e){t=function(t,e){return 1==e.length?t:function(t,e){for(var n=0,r=(e=j(e,t)?[e]:C(e)).length;null!=t&&n<r;)t=t[M(e[n++])];return n&&n==r?t:void 0}(t,function(t,e,n){var r=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(n=n>o?o:n)<0&&(n+=o),o=e>n?0:n-e>>>0,e>>>=0;for(var i=Array(o);++r<o;)i[r]=t[r+e];return i}(e,0,-1))}(t,e=j(e,t)?[e]:C(e));var n,r,o=M((r=(n=e)?n.length:0)?n[r-1]:void 0);return!(null!=t&&w.call(t,o))||delete t[o]}(t,e)}},47:function(t){var e=function(t){"use strict";var e,n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function u(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,n){return t[e]=n}}function f(t,e,n,r){var i=e&&e.prototype instanceof v?e:v,s=Object.create(i.prototype),a=new P(r||[]);return o(s,"_invoke",{value:A(t,n,a)}),s}function l(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function v(){}function m(){}function _(){}var w={};u(w,s,(function(){return this}));var b=Object.getPrototypeOf,E=b&&b(b(x([])));E&&E!==n&&r.call(E,s)&&(w=E);var S=_.prototype=v.prototype=Object.create(w);function I(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function n(o,i,s,a){var c=l(t[o],t,i);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"==typeof f&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,s,a)}),(function(t){n("throw",t,s,a)})):e.resolve(f).then((function(t){u.value=t,s(u)}),(function(t){return n("throw",t,s,a)}))}a(c.arg)}var i;o(this,"_invoke",{value:function(t,r){function o(){return new e((function(e,o){n(t,r,e,o)}))}return i=i?i.then(o,o):o()}})}function A(t,n,r){var o=h;return function(i,s){if(o===d)throw new Error("Generator is already running");if(o===y){if("throw"===i)throw s;return{value:e,done:!0}}for(r.method=i,r.arg=s;;){var a=r.delegate;if(a){var c=T(a,r);if(c){if(c===g)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===h)throw o=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=d;var u=l(t,n,r);if("normal"===u.type){if(o=r.done?y:p,u.arg===g)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(o=y,r.method="throw",r.arg=u.arg)}}}function T(t,n){var r=n.method,o=t.iterator[r];if(o===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,T(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var i=l(o,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,g;var s=i.arg;return s?s.done?(n[t.resultName]=s.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,g):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function N(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function R(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(N,this),this.reset(!0)}function x(t){if(null!=t){var n=t[s];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function n(){for(;++o<t.length;)if(r.call(t,o))return n.value=t[o],n.done=!1,n;return n.value=e,n.done=!0,n};return i.next=i}}throw new TypeError(typeof t+" is not iterable")}return m.prototype=_,o(S,"constructor",{value:_,configurable:!0}),o(_,"constructor",{value:m,configurable:!0}),m.displayName=u(_,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===m||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,_):(t.__proto__=_,u(t,c,"GeneratorFunction")),t.prototype=Object.create(S),t},t.awrap=function(t){return{__await:t}},I(O.prototype),u(O.prototype,a,(function(){return this})),t.AsyncIterator=O,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var s=new O(f(e,n,r,o),i);return t.isGeneratorFunction(n)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},I(S),u(S,c,"Generator"),u(S,s,(function(){return this})),u(S,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},t.values=x,P.prototype={constructor:P,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(R),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function o(r,o){return a.type="throw",a.arg=t,n.next=r,o&&(n.method="next",n.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var s=this.tryEntries[i],a=s.completion;if("root"===s.tryLoc)return o("end");if(s.tryLoc<=this.prev){var c=r.call(s,"catchLoc"),u=r.call(s,"finallyLoc");if(c&&u){if(this.prev<s.catchLoc)return o(s.catchLoc,!0);if(this.prev<s.finallyLoc)return o(s.finallyLoc)}else if(c){if(this.prev<s.catchLoc)return o(s.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return o(s.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=t,s.arg=e,i?(this.method="next",this.next=i.finallyLoc,g):this.complete(s)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),g},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),R(n),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;R(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:x(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),g}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}},633:function(){},536:function(t){"use strict";t.exports={version:"1.8.1"}}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={id:r,loaded:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}return n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,{a:e}),e},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.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),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})},n.nmd=function(t){return t.paths=[],t.children||(t.children=[]),t},n(47),n(972)}()}));
|
|
2
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("cloudbase",[],e):"object"==typeof exports?exports.cloudbase=e():t.cloudbase=e()}("undefined"!=typeof window?window:this,(function(){return function(){var t={829:function(t,e,n){"use strict";var r;n.r(e),n.d(e,{AbstractSDKRequest:function(){return o},AbstractStorage:function(){return i},StorageType:function(){return r},formatUrl:function(){return s}}),function(t){t.local="local",t.none="none",t.session="session"}(r||(r={}));var o=function(){},i=function(){};function s(t,e,n){void 0===n&&(n={});var r=/\?/.test(e),o="";for(var i in n)""===o?!r&&(e+="?"):o+="&",o+=i+"="+encodeURIComponent(n[i]);return/^http(s)?\:\/\//.test(e+=o)?e:""+t+e}},972:function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}},o=r(n(793)),i=n(273),s=n(363),a=n(614),c=n(63),u=n(505),f=n(622),l=r(n(536)).default.version;o.default.registerVersion(l);try{(0,i.registerAuth)(o.default),(0,s.registerFunctions)(o.default),(0,a.registerStorage)(o.default),(0,f.registerDatabase)(o.default),(0,c.registerRealtime)(o.default),(0,u.registerAnalytics)(o.default)}catch(t){}try{window.cloudbase=o.default}catch(t){}e.default=o.default,t.exports=o.default},505:function(t,e,n){"use strict";n.r(e),n.d(e,{registerAnalytics:function(){return h}});var r=n(650),o=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},i=r.constants.ERRORS,s=r.constants.COMMUNITY_SITE_URL,a=r.helpers.catchErrorsDecorator,c="analytics",u=["mall"],f=new(function(){function t(){}return t.prototype.analytics=function(t){return e=this,n=void 0,o=function(){var e,n,r;return function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,(function(o){if(!function(t){if("Object"!==Object.prototype.toString.call(t).slice(8,-1))return!1;var e=t.report_data,n=t.report_type;return!1!==u.includes(n)&&"Object"===Object.prototype.toString.call(e).slice(8,-1)&&!(void 0!==e.action_time&&!Number.isInteger(e.action_time))&&"string"==typeof e.action_type}(t))throw new Error(JSON.stringify({code:i.INVALID_PARAMS,msg:"[".concat(c,".analytics] invalid report data")}));return e=void 0===t.report_data.action_time?Math.floor(Date.now()/1e3):t.report_data.action_time,n={analytics_scene:t.report_type,analytics_data:Object.assign({},t.report_data,{action_time:e})},r={requestData:n},this.request.send("analytics.report",r),[2]}))},new((r=void 0)||(r=Promise))((function(t,i){function s(t){try{c(o.next(t))}catch(t){i(t)}}function a(t){try{c(o.throw(t))}catch(t){i(t)}}function c(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r((function(t){t(n)}))).then(s,a)}c((o=o.apply(e,n||[])).next())}));var e,n,r,o},function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);i>3&&s&&Object.defineProperty(e,n,s)}([a({customInfo:{className:"Cloudbase",methodName:"analytics"},title:"上报调用失败",messages:["请确认以下各项:"," 1 - 调用 analytics() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(s)]}),o("design:type",Function),o("design:paramtypes",[Object]),o("design:returntype",Promise)],t.prototype,"analytics",null),t}()),l={name:c,entity:{analytics:f.analytics}};try{cloudbase.registerComponent(l)}catch(t){}function h(t){try{t.registerComponent(l)}catch(t){console.warn(t)}}},793:function(t,e,n){"use strict";n.r(e),n.d(e,{cloudbase:function(){return ct},default:function(){return ut}});var r,o=n(650),i=n(829),s=(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)e.hasOwnProperty(n)&&(t[n]=e[n])},r(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),a=function(){return a=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},a.apply(this,arguments)},c=function(t){function e(e){void 0===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 s(e,t),e.prototype.post=function(t){var e=this;return new Promise((function(n,r){var o=t.url,s=t.data,a=t.headers,c=wx.request({url:(0,i.formatUrl)("https:",o),data:s,timeout:e._timeout,method:"POST",header:a,success:function(t){n(t)},fail:function(t){r(t)},complete:function(t){if(t&&t.errMsg&&e._timeout&&-1!==e._restrictedMethods.indexOf("post")&&"request:fail timeout"===t.errMsg){console.warn(e._timeoutMsg);try{c.abort()}catch(t){}}}})}))},e.prototype.upload=function(t){var e=this,n=this;return new Promise((function(r){return o=e,i=void 0,c=function(){var e,o,i,s,c,u;return function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}(this,(function(f){return e=t.url,o=t.file,i=t.data,s=t.headers,c=t.onUploadProgress,u=wx.uploadFile({url:e,filePath:o,name:"file",formData:a({},i),header:s,timeout:this._timeout,success:function(t){var e={statusCode:t.statusCode,data:t.data||{}};200===t.statusCode&&i.success_action_status&&(e.statusCode=parseInt(i.success_action_status,10)),r(e)},fail:function(t){r(t)},complete:function(t){if(t&&t.errMsg&&n._timeout&&-1!==n._restrictedMethods.indexOf("upload")&&"request:fail timeout"===t.errMsg){console.warn(n._timeoutMsg);try{u.abort()}catch(t){}}}}),c&&u.onProgressUpdate((function(t){c(t)})),[2]}))},new((s=void 0)||(s=Promise))((function(t,e){function n(t){try{a(c.next(t))}catch(t){e(t)}}function r(t){try{a(c.throw(t))}catch(t){e(t)}}function a(e){var o;e.done?t(e.value):(o=e.value,o instanceof s?o:new s((function(t){t(o)}))).then(n,r)}a((c=c.apply(o,i||[])).next())}));var o,i,s,c}))},e.prototype.download=function(t){var e=this,n=this;return new Promise((function(r,o){var s=t.url,a=t.headers,c=wx.downloadFile({url:(0,i.formatUrl)("https:",s),header:a,timeout:e._timeout,success:function(t){200===t.statusCode&&t.tempFilePath?r({statusCode:200,tempFilePath:t.tempFilePath}):r(t)},fail:function(t){o(t)},complete:function(t){if(t&&t.errMsg&&n._timeout&&-1!==n._restrictedMethods.indexOf("download")&&"request:fail timeout"===t.errMsg){console.warn(n._timeoutMsg);try{c.abort()}catch(t){}}}})}))},e}(i.AbstractSDKRequest),u={setItem:function(t,e){wx.setStorageSync(t,e)},getItem:function(t){return wx.getStorageSync(t)},removeItem:function(t){wx.removeStorageSync(t)},clear:function(){wx.clearStorageSync()}},f=function(t,e){void 0===e&&(e={});var n=wx.connectSocket(a({url:t},e));return{set onopen(t){n.onOpen(t)},set onmessage(t){n.onMessage(t)},set onclose(t){n.onClose(t)},set onerror(t){n.onError(t)},send:function(t){return n.send({data:t})},close:function(t,e){return n.close({code:t,reason:e})},get readyState(){return n.readyState},CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3}},l={genAdapter:function(){return{root:{},reqClass:c,wsClass:f,localStorage:u,primaryStorage:i.StorageType.local,getAppSign:function(){var t=wx.getAccountInfoSync();return"undefined"!=typeof App||"undefined"!=typeof getApp||wx.onAppHide||wx.offAppHide||wx.onAppShow||wx.offAppShow?t&&t.miniProgram?t.miniProgram.appId:"":t&&t.plugin?t.plugin.appId:""}}},isMatch:function(){if("undefined"==typeof wx)return!1;if("undefined"==typeof Page)return!1;if(!wx.getSystemInfoSync)return!1;if(!wx.getStorageSync)return!1;if(!wx.setStorageSync)return!1;if(!wx.connectSocket)return!1;if(!wx.request)return!1;try{if(!wx.getSystemInfoSync())return!1;if("qq"===wx.getSystemInfoSync().AppPlatform)return!1}catch(t){return!1}return!0},runtime:"wx_mp"},h=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))},p=o.constants.ERRORS,d={};function y(t,e){var n=e.name,r=e.namespace,o=e.entity,i=e.injectEvents,s=e.IIFE,a=void 0!==s&&s;if(d[n]||r&&t[r])throw new Error(JSON.stringify({code:p.INVALID_OPERATION,msg:"Duplicate component ".concat(n)}));if(a){if(!o||"function"!=typeof o)throw new Error(JSON.stringify({code:p.INVALID_PARAMS,msg:"IIFE component's entity must be a function"}));o.call(t)}if(d[n]=e,r?t.prototype[r]=o:g(t.prototype,o),i){var c=i.bus,u=i.events;if(!c||!u||0===u.length)return;var f=t.prototype.fire||function(){};t.prototype.events||(t.prototype.events={}),(t.prototype.events||{})[n]?t.prototype.events[n].events=h(h([],t.prototype.events[n].events,!0),u,!0):t.prototype.events[n]={bus:c,events:u},t.prototype.fire=function(t,e){for(var n in f(t,e),this.events){var r=this.events[n],o=r.bus;if(r.events.includes(t)){o.fire(t,e);break}}}}}function g(t,e){if(!(e instanceof Object))return e;switch(e.constructor){case Date:return new Date(e.getTime());case Object:void 0===t&&(t={});break;case Array:t=[];break;default:return e}for(var n in e)e.hasOwnProperty(n)&&(t[n]=g(t[n],e[n]));return t}var v={},m=function(){return m=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},m.apply(this,arguments)},_=o.cache.CloudbaseCache,w={},b={};function E(t){var e=t.env,n=t.persistence,r=t.platformInfo,o={accessTokenKey:"".concat("access_token","_").concat(e),accessTokenExpireKey:"".concat("access_token_expire","_").concat(e),refreshTokenKey:"".concat("refresh_token","_").concat(e),anonymousUuidKey:"".concat("anonymous_uuid","_").concat(e),loginTypeKey:"".concat("login_type","_").concat(e),userInfoKey:"".concat("user_info","_").concat(e)};w[e]?w[e].updatePersistence(n):w[e]=new _(m(m({},t),{keys:o,platformInfo:r,alwaysLocalKeys:["anonymousUuidKey"]})),b[e]=b[e]||new _(m(m({},t),{keys:o,platformInfo:r,persistence:"local"}))}function S(t){return w[t]}function I(t){return b[t]}var O,A=o.constants.setSdkName,T=o.constants.setProtocol,N="",R="@cloudbase/js-sdk",P="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:",x="//tcb-api.tencentcloudapi.com/web";function L(t,e){x=t,e&&(P=e,T(e))}function C(){return{BASE_URL:x,PROTOCOL:P}}!function(t){t.ANONYMOUS="ANONYMOUS",t.WECHAT="WECHAT",t.CUSTOM="CUSTOM",t.NULL="NULL"}(O||(O={}));var k=function(){return k=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},k.apply(this,arguments)},U=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},j=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},D=o.constants.ERRORS,M=o.utils.genSeqId,q=o.utils.isFormData,B=o.utils.formatUrl,F=o.utils.createSign,W=o.adapters.RUNTIME,$=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"];function H(t,e,n){var r=t[e];t[e]=function(e){var o={},i={};n.forEach((function(n){var r=n.call(t,e),s=r.data,a=r.headers;Object.assign(o,s),Object.assign(i,a)}));var s=e.data;return s&&function(){if(q(s))for(var t in o)s.append(t,o[t]);else e.data=k(k({},s),o)}(),e.headers=k(k({},e.headers||{}),i),r.call(t,e)}}function G(){var t=M();return{data:{seqId:t},headers:{"X-SDK-Version":"@cloudbase/js-sdk/".concat(N),"x-seqid":t}}}var K=function(){function t(t){this._throwWhenRequestFail=!1,this.config=t,this._reqClass=new v.adapter.reqClass({timeout:this.config.timeout,timeoutMsg:"[@cloudbase/js-sdk] 请求在".concat(this.config.timeout/1e3,"s内未完成,已中断"),restrictedMethods:["post"]}),this._throwWhenRequestFail=t.throw||!1,this._cache=S(this.config.env),this._localCache=I(this.config.env),H(this._reqClass,"post",[G]),H(this._reqClass,"upload",[G]),H(this._reqClass,"download",[G])}return t.prototype.post=function(t){return U(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this._reqClass.post(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.upload=function(t){return U(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this._reqClass.upload(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.download=function(t){return U(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this._reqClass.download(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.refreshAccessToken=function(){return U(this,void 0,void 0,(function(){var t,e,n;return j(this,(function(r){switch(r.label){case 0:this._refreshAccessTokenPromise||(this._refreshAccessTokenPromise=this._refreshAccessToken()),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this._refreshAccessTokenPromise];case 2:return t=r.sent(),[3,4];case 3:return n=r.sent(),e=n,[3,4];case 4:if(this._refreshAccessTokenPromise=null,this._shouldRefreshAccessTokenHook=null,e)throw e;return[2,t]}}))}))},t.prototype.getAccessToken=function(){return U(this,void 0,void 0,(function(){var t,e,n,r,o,i,s,a,c;return j(this,(function(u){switch(u.label){case 0:return t=this._cache.keys,e=t.accessTokenKey,n=t.accessTokenExpireKey,r=t.refreshTokenKey,[4,this._cache.getStoreAsync(r)];case 1:if(!u.sent())throw new Error(JSON.stringify({code:D.OPERATION_FAIL,msg:"refresh token is not exist, your local data might be messed up, please retry after clear localStorage or sessionStorage"}));return[4,this._cache.getStoreAsync(e)];case 2:return o=u.sent(),s=Number,[4,this._cache.getStoreAsync(n)];case 3:return i=s.apply(void 0,[u.sent()]),a=!0,(c=this._shouldRefreshAccessTokenHook)?[4,this._shouldRefreshAccessTokenHook(o,i)]:[3,5];case 4:c=!u.sent(),u.label=5;case 5:return c&&(a=!1),o&&i&&!(i<Date.now())||!a?[3,7]:[4,this.refreshAccessToken()];case 6:return[2,u.sent()];case 7:return[2,{accessToken:o,accessTokenExpire:i}]}}))}))},t.prototype.request=function(t,e,n){return U(this,void 0,void 0,(function(){var r,o,i,s,a,c,u,f,l,h,p,d,y,g,m,_,w,b,E,S,I,O,A,T,N,R;return j(this,(function(P){switch(P.label){case 0:return r="x-tcb-trace_".concat(this.config.env),o="application/x-www-form-urlencoded",i=k({action:t,dataVersion:"2020-01-10",env:this.config.env},e),-1!==$.indexOf(t)?[3,3]:(s=this._cache.keys.refreshTokenKey,[4,this._cache.getStoreAsync(s)]);case 1:return P.sent()?(a=i,[4,this.getAccessToken()]):[3,3];case 2:a.access_token=P.sent().accessToken,P.label=3;case 3:if("storage.uploadFile"===t){for(u in c=new FormData)c.hasOwnProperty(u)&&void 0!==c[u]&&c.append(u,i[u]);o="multipart/form-data"}else for(u in o="application/json;charset=UTF-8",c={},i)void 0!==i[u]&&(c[u]=i[u]);return f={headers:{"content-type":o}},(null==n?void 0:n.onUploadProgress)&&(f.onUploadProgress=n.onUploadProgress),this.config.region&&(f.headers["X-TCB-Region"]=this.config.region),(l=this._localCache.getStore(r))&&(f.headers["X-TCB-Trace"]=l),v.runtime!==W.WEB&&(h=this.config,p=h.appSign,d=h.appSecret,y=Date.now(),g=d.appAccessKey,m=d.appAccessKeyId,_=F({data:{},timestamp:y,appAccessKeyId:m,appSign:p},g),f.headers["X-TCB-App-Source"]="timestamp=".concat(y,";appAccessKeyId=").concat(m,";appSign=").concat(p,";sign=").concat(_)),w=e.parse,b=e.inQuery,E=e.search,S={env:this.config.env},w&&(S.parse=!0),b&&(S=k(k({},b),S)),I=C(),O=I.BASE_URL,A=I.PROTOCOL,T=B(A,O,S),E&&(T+=E),[4,this.post(k({url:T,data:c},f))];case 4:if(N=P.sent(),(R=N.header&&N.header["x-tcb-trace"])&&this._localCache.setStore(r,R),200!==Number(N.status)&&200!==Number(N.statusCode)||!N.data)throw new Error("network request error");return[2,N]}}))}))},t.prototype.send=function(t,e){return void 0===e&&(e={}),U(this,void 0,void 0,(function(){var n;return j(this,(function(r){switch(r.label){case 0:return[4,this.request(t,e,{onUploadProgress:e.onUploadProgress})];case 1:return"ACCESS_TOKEN_EXPIRED"!==(n=r.sent()).data.code||-1!==$.indexOf(t)?[3,4]:[4,this.refreshAccessToken()];case 2:return r.sent(),[4,this.request(t,e,{onUploadProgress:e.onUploadProgress})];case 3:n=r.sent(),r.label=4;case 4:if(n.data.code&&this._throwWhenRequestFail)throw new Error(JSON.stringify({code:D.OPERATION_FAIL,msg:"[".concat(n.data.code,"] ").concat(n.data.message)}));return[2,n.data]}}))}))},t.prototype._refreshAccessToken=function(t){return void 0===t&&(t=1),U(this,void 0,void 0,(function(){var e,n,r,o,i,s,a,c,u,f,l,h,p;return j(this,(function(d){switch(d.label){case 0:return e=this._cache.keys,n=e.accessTokenKey,r=e.accessTokenExpireKey,o=e.refreshTokenKey,i=e.loginTypeKey,s=e.anonymousUuidKey,[4,this._cache.removeStoreAsync(n)];case 1:return d.sent(),[4,this._cache.removeStoreAsync(r)];case 2:return d.sent(),[4,this._cache.getStoreAsync(o)];case 3:if(!(a=d.sent()))throw new Error(JSON.stringify({code:D.INVALID_OPERATION,msg:"not login"}));return c={refresh_token:a},[4,this.request("auth.fetchAccessTokenWithRefreshToken",c)];case 4:return(u=d.sent()).data.code?"SIGN_PARAM_INVALID"!==(f=u.data.code)&&"REFRESH_TOKEN_EXPIRED"!==f&&"INVALID_REFRESH_TOKEN"!==f?[3,11]:[4,this._cache.getStoreAsync(i)]:[3,12];case 5:return d.sent()===O.ANONYMOUS&&"INVALID_REFRESH_TOKEN"===f?[4,this._cache.getStoreAsync(s)]:[3,9];case 6:return l=d.sent(),[4,this._cache.getStoreAsync(o)];case 7:return h=d.sent(),[4,this.send("auth.signInAnonymously",{anonymous_uuid:l,refresh_token:h})];case 8:if(p=d.sent(),this._setRefreshToken(p.refresh_token),t>=1)return[2,this._refreshAccessToken(--t)];throw new Error(JSON.stringify({code:D.OPERATION_FAIL,message:"重试获取 refresh token 失败"}));case 9:return ct.fire("loginStateExpire"),[4,this._cache.removeStoreAsync(o)];case 10:d.sent(),d.label=11;case 11:throw new Error(JSON.stringify({code:D.NETWORK_ERROR,msg:"refresh access_token failed:".concat(u.data.code)}));case 12:return u.data.access_token?(ct.fire("refreshAccessToken"),[4,this._cache.setStoreAsync(n,u.data.access_token)]):[3,15];case 13:return d.sent(),[4,this._cache.setStoreAsync(r,u.data.access_token_expire+Date.now())];case 14:return d.sent(),[2,{accessToken:u.data.access_token,accessTokenExpire:u.data.access_token_expire}];case 15:return u.data.refresh_token?[4,this._cache.removeStoreAsync(o)]:[3,19];case 16:return d.sent(),[4,this._cache.setStoreAsync(o,u.data.refresh_token)];case 17:return d.sent(),[4,this._refreshAccessToken()];case 18:d.sent(),d.label=19;case 19:return[2]}}))}))},t.prototype._setRefreshToken=function(t){return U(this,void 0,void 0,(function(){var e,n,r,o;return j(this,(function(i){switch(i.label){case 0:return e=this._cache.keys,n=e.accessTokenKey,r=e.accessTokenExpireKey,o=e.refreshTokenKey,[4,this._cache.removeStoreAsync(n)];case 1:return i.sent(),[4,this._cache.removeStoreAsync(r)];case 2:return i.sent(),[4,this._cache.setStoreAsync(o,t)];case 3:return i.sent(),[2]}}))}))},t}(),V={},J=function(){return J=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},J.apply(this,arguments)},Y=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},z=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},X=o.adapters.useAdapters,Z=o.adapters.useDefaultAdapter,Q=o.adapters.RUNTIME,tt=o.constants.ERRORS,et=o.constants.COMMUNITY_SITE_URL,nt=o.utils.printWarn,rt=o.helpers.catchErrorsDecorator,ot={timeout:15e3,persistence:"local"},it=6e5,st={},at=function(){function t(t){this._config=t||this._config,this.authInstance=null}return Object.defineProperty(t.prototype,"config",{get:function(){return this._config},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"platform",{get:function(){return v},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cache",{get:function(){return S(this._config.env)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCache",{get:function(){return I(this._config.env)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"request",{get:function(){return t=this._config.env,V[t];var t},enumerable:!1,configurable:!0}),t.prototype.init=function(e){if(!e.env)throw new Error(JSON.stringify({code:tt.INVALID_PARAMS,msg:"env must not be specified"}));if(v.adapter||this._useDefaultAdapter(),this.requestClient=new v.adapter.reqClass({timeout:e.timeout||5e3,timeoutMsg:"[".concat(R,"][REQUEST TIMEOUT] request had been abort since didn't finished within").concat(e.timeout/1e3,"s")}),v.runtime!==Q.WEB){if(!e.appSecret)throw new Error(JSON.stringify({code:tt.INVALID_PARAMS,msg:"invalid appSecret"}));var n=v.adapter.getAppSign?v.adapter.getAppSign():"";if(e.appSign&&n&&e.appSign!==n)throw new Error(JSON.stringify({code:tt.INVALID_PARAMS,msg:"invalid appSign"}));if(n&&(e.appSign=n),!e.appSign)throw new Error(JSON.stringify({code:tt.INVALID_PARAMS,msg:"invalid appSign"}))}this._config=J(J({},ot),e),this._config.timeout=this._formatTimeout(this._config.timeout);var r=this._config,o=r.env,i=r.persistence,s=r.debug,a=r.timeout,c=r.appSecret,u=r.appSign;E({env:o,persistence:i,debug:s,platformInfo:this.platform}),function(t){V[t.env]=new K(k(k({},t),{throw:!0}))}({env:o,region:e.region||"",timeout:a,appSecret:c,appSign:u}),e.region&&function(t,e){L(e?"//".concat(t,".").concat(e,".tcb-api.tencentcloudapi.com/web"):"//".concat(t,".ap-shanghai.tcb-api.tencentcloudapi.com/web"),void 0)}(o,e.region||"");var f=new t(this._config);return f.requestClient=this.requestClient,f},t.prototype.updateConfig=function(t){var e=t.persistence,n=t.debug;this._config.persistence=e,this._config.debug=n,E({env:this._config.env,persistence:e,debug:n,platformInfo:this.platform})},t.prototype.registerExtension=function(t){st[t.name]=t},t.prototype.invokeExtension=function(t,e){return n=this,r=void 0,i=function(){var n;return function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,(function(r){switch(r.label){case 0:if(!(n=st[t]))throw new Error(JSON.stringify({code:tt.INVALID_PARAMS,msg:"extension:".concat(t," must be registered before invoke")}));return[4,n.invoke(e,this)];case 1:return[2,r.sent()]}}))},new((o=void 0)||(o=Promise))((function(t,e){function s(t){try{c(i.next(t))}catch(t){e(t)}}function a(t){try{c(i.throw(t))}catch(t){e(t)}}function c(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(s,a)}c((i=i.apply(n,r||[])).next())}));var n,r,o,i},t.prototype.useAdapters=function(t){var e=X(t)||{},n=e.adapter,r=e.runtime;n&&(v.adapter=n),r&&(v.runtime=r)},t.prototype.registerHook=function(e){!function(t,e){var n=e.entity,r=e.target;if(!t.prototype.hasOwnProperty(r))throw new Error(JSON.stringify({code:p.INVALID_OPERATION,msg:"target:".concat(r," is not exist")}));var o=t.prototype[r];if("function"!=typeof o)throw new Error(JSON.stringify({code:p.INVALID_OPERATION,msg:"target:".concat(r," is not a function which is the only type supports hook")}));t.prototype[r]=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n.call.apply(n,h([this],t,!1)),o.call.apply(o,h([this],t,!1))}}(t,e)},t.prototype.registerComponent=function(e){y(t,e)},t.prototype.registerVersion=function(t){!function(t){N=t}(t)},t.prototype.registerSdkName=function(t){!function(t){R=t,A(t)}(t)},t.prototype.registerEndPoint=function(t,e){L(t,e)},t.prototype._useDefaultAdapter=function(){var t=Z(),e=t.adapter,n=t.runtime;v.adapter=e,v.runtime=n},t.prototype._formatTimeout=function(t){switch(!0){case t>it:return nt(tt.INVALID_PARAMS,"timeout is greater than maximum value[10min]"),it;case t<100:return nt(tt.INVALID_PARAMS,"timeout is less than maximum value[100ms]"),100;default:return t}},Y([rt({mode:"sync",title:"Cloudbase 初始化失败",messages:["请确认以下各项:"," 1 - 调用 cloudbase.init() 的语法或参数是否正确"," 2 - 如果是非浏览器环境,是否配置了安全应用来源(https://docs.cloudbase.net/api-reference/webv2/adapter.html#jie-ru-liu-cheng)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(et)]}),z("design:type",Function),z("design:paramtypes",[Object]),z("design:returntype",t)],t.prototype,"init",null),Y([rt({title:"调用扩展能力失败",messages:["请确认以下各项:"," 1 - 调用 invokeExtension() 的语法或参数是否正确"," 2 - 被调用的扩展能力是否已经安装并通过 registerExtension() 注册","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(et)]}),z("design:type",Function),z("design:paramtypes",[String,Object]),z("design:returntype",Promise)],t.prototype,"invokeExtension",null),t}(),ct=new at;ct.useAdapters(l);var ut=ct},273:function(t,e,n){"use strict";n.r(e),n.d(e,{Auth:function(){return jt},AuthProvider:function(){return a},EVENTS:function(){return Dt},LoginState:function(){return Ut},eventBus:function(){return Ct},registerAuth:function(){return qt},registerProvider:function(){return Bt}});var r,o=n(650),i=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},s=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},a=function(){function t(t){this._config=t,this._cache=t.cache,this._request=t.request}return t.prototype.checkLocalLoginState=function(){return i(this,void 0,void 0,(function(){var t,e,n,r,o,i;return s(this,(function(s){switch(s.label){case 0:return t=this._cache.keys,e=t.accessTokenKey,n=t.accessTokenExpireKey,[4,this._cache.getStoreAsync(e)];case 1:return r=s.sent(),[4,this._cache.getStoreAsync(n)];case 2:return o=s.sent(),r?o&&o>Date.now()?[4,(i=new Ut({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()]:[3,4]:[3,7];case 3:return s.sent(),[2,i];case 4:return[4,this._cache.removeStoreAsync(e)];case 5:return s.sent(),[4,this._cache.removeStoreAsync(n)];case 6:s.sent(),s.label=7;case 7:return[2]}}))}))},t.prototype.setRefreshToken=function(t){return i(this,void 0,void 0,(function(){var e,n,r,o;return s(this,(function(i){switch(i.label){case 0:return e=this._cache.keys,n=e.accessTokenKey,r=e.accessTokenExpireKey,o=e.refreshTokenKey,[4,this._cache.removeStoreAsync(n)];case 1:return i.sent(),[4,this._cache.removeStoreAsync(r)];case 2:return i.sent(),[4,this._cache.setStoreAsync(o,t)];case 3:return i.sent(),[2]}}))}))},t.prototype.setAccessToken=function(t,e){return i(this,void 0,void 0,(function(){var n,r,o;return s(this,(function(i){switch(i.label){case 0:return n=this._cache.keys,r=n.accessTokenKey,o=n.accessTokenExpireKey,[4,this._cache.setStoreAsync(r,t)];case 1:return i.sent(),[4,this._cache.setStoreAsync(o,e)];case 2:return i.sent(),[2]}}))}))},t.prototype.refreshUserInfo=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return[4,this._request.send("auth.getUserInfo",{})];case 1:return t=e.sent().data,[4,this.setLocalUserInfo(t)];case 2:return e.sent(),[2,t]}}))}))},t.prototype.setLocalUserInfo=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e=this._cache.keys.userInfoKey,[4,this._cache.setStoreAsync(e,t)];case 1:return n.sent(),[2]}}))}))},t}();!function(t){t.ANONYMOUS="ANONYMOUS",t.WECHAT="WECHAT",t.WECHAT_PUBLIC="WECHAT-PUBLIC",t.WECHAT_OPEN="WECHAT-OPEN",t.CUSTOM="CUSTOM",t.EMAIL="EMAIL",t.USERNAME="USERNAME",t.NULL="NULL",t.PHONE="PHONE"}(r||(r={}));var c,u=(c=function(t,e){return c=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])},c(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}c(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),f=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},l=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},h=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},p=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},d=o.constants.getSdkName,y=o.constants.ERRORS,g=o.constants.COMMUNITY_SITE_URL,v=o.adapters.RUNTIME,m=o.utils.getQuery,_=o.utils.getHash,w=o.utils.removeParam,b=o.utils.printWarn,E=o.helpers.catchErrorsDecorator,S=function(t){function e(e,n,r,o){var i=t.call(this,e)||this;return i._runtime=e.runtime,i._appid=n,i._scope=r,i._state=o||"weixin",i}return u(e,t),e.prototype.signIn=function(){return h(this,void 0,void 0,(function(){return p(this,(function(t){return[2,b(y.OPERATION_FAIL,"API signIn has been deprecated, please use signInWithRedirect insteed")]}))}))},e.prototype.signInWithRedirect=function(){return h(this,void 0,void 0,(function(){return p(this,(function(t){return[2,this._redirect()]}))}))},e.prototype.getRedirectResult=function(t){return h(this,void 0,void 0,(function(){var e;return p(this,(function(n){return(e=I())?[2,this._signInWithCode(e,t)]:[2,null]}))}))},e.prototype.getLinkRedirectResult=function(t){return void 0===t&&(t={}),h(this,void 0,void 0,(function(){var e,n,r,o,i,s;return p(this,(function(a){return s=t.withUnionId,e=void 0!==s&&s,(n=I())?(r=this._appid,c=this._scope,o="snsapi_login"===c?"WECHAT-OPEN":"WECHAT-PUBLIC",i=this._runtime===v.WX_MP?"1":"0",[2,this._request.send("auth.linkWithWeixinCode",{payload:{appid:r,loginType:o,code:n,hybridMiniapp:i,withUnionId:e}})]):[2,null];var c}))}))},e.prototype._redirect=function(){var t=w("code",location.href);t=w("state",t),t=encodeURIComponent(t);var e="//open.weixin.qq.com/connect/oauth2/authorize";"snsapi_login"===this._scope&&(e="//open.weixin.qq.com/connect/qrconnect");try{location.href="".concat(e,"?appid=").concat(this._appid,"&redirect_uri=").concat(t,"&response_type=code&scope=").concat(this._scope,"&state=").concat(this._state,"#wechat_redirect")}catch(t){throw new Error("[".concat(d(),"][").concat(y.UNKOWN_ERROR,"]").concat(t))}},e.prototype._signInWithCode=function(t,e){return h(this,void 0,void 0,(function(){var n,o,i,s,a,c,u,f;return p(this,(function(l){switch(l.label){case 0:return f=this._cache.keys,n=f.accessTokenKey,o=f.accessTokenExpireKey,i=f.refreshTokenKey,h=this._scope,s="snsapi_login"===h?"WECHAT-OPEN":"WECHAT-PUBLIC",[4,this._getRefreshTokenByWXCode(this._appid,s,t,e)];case 1:return a=l.sent(),c=a.refreshToken,[4,this._cache.setStoreAsync(i,c)];case 2:return l.sent(),a.accessToken?[4,this._cache.setStoreAsync(n,a.accessToken)]:[3,4];case 3:l.sent(),l.label=4;case 4:return a.accessTokenExpire?[4,this._cache.setStoreAsync(o,String(a.accessTokenExpire+Date.now()))]:[3,6];case 5:l.sent(),l.label=6;case 6:return Ct.fire(Dt.LOGIN_STATE_CHANGED),Ct.fire(Dt.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:r.WECHAT,persistence:this._config.persistence}),[4,this.refreshUserInfo()];case 7:return l.sent(),[4,(u=new Ut({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 8:return l.sent(),[2,u]}var h}))}))},e.prototype._getRefreshTokenByWXCode=function(t,e,n,r){return void 0===r&&(r={}),h(this,void 0,void 0,(function(){var o,i,s,a,c,u;return p(this,(function(f){return c=r.withUnionId,o=void 0!==c&&c,u=r.createUser,i=void 0===u||u,s="snsapi_base"!==this._scope&&(r.syncUserInfo||!1),a=this._runtime===v.WX_MP?"1":"0",[2,this._request.send("auth.signIn",{appid:t,loginType:e,hybridMiniapp:a,syncUserInfo:s,loginCredential:n,withUnionId:o,createUser:i}).then((function(t){if(t.code)throw new Error("[".concat(d(),"][").concat(y.OPERATION_FAIL,"] failed login via wechat: ").concat(t.code));if(t.refresh_token)return{refreshToken:t.refresh_token,accessToken:t.access_token,accessTokenExpire:t.access_token_expire};throw new Error("[".concat(d(),"][").concat(y.OPERATION_FAIL,"] action:getJwt not return refreshToken"))}))]}))}))},f([E({title:"跳转微信公众号授权失败",messages:["请确认以下各项:"," 1 - 调用 auth().weixinAuthProvider().signInWithRedirect() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(g)]}),l("design:type",Function),l("design:paramtypes",[]),l("design:returntype",Promise)],e.prototype,"signInWithRedirect",null),f([E({title:"微信公众号登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().weixinAuthProvider().getRedirectResult() 的语法或参数是否正确"," 2 - 当前环境是否开通了微信公众号登录授权"," 3 - 微信公众号的 AppId 与 AppSecret 配置是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(g)]}),l("design:type",Function),l("design:paramtypes",[Object]),l("design:returntype",Promise)],e.prototype,"getRedirectResult",null),f([E({title:"获取微信重定向绑定结果",messages:["请确认以下各项:"," 1 - 调用 auth().weixinAuthProvider().getLinkRedirectResult() 的语法或参数是否正确"," 2 - 当前环境是否开通了微信公众号登录授权"," 3 - 微信公众号的 AppId 与 AppSecret 配置是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(g)]}),l("design:type",Function),l("design:paramtypes",[Object]),l("design:returntype",Promise)],e.prototype,"getLinkRedirectResult",null),e}(a);function I(){return m("code")||_("code")}var O=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)}}(),A=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},T=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},N=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},R=o.constants.ERRORS,P=o.constants.COMMUNITY_SITE_URL,x=o.utils.throwError,L=o.utils.isString,C=o.events.addEventListener,k=o.helpers.catchErrorsDecorator,U=function(t){function e(e){var n=t.call(this,e)||this;return n._onConverted=n._onConverted.bind(n),C(Dt.ANONYMOUS_CONVERTED,n._onConverted),n}return O(e,t),e.prototype.signIn=function(){return T(this,void 0,void 0,(function(){var t,e,n,o,i,s,a;return N(this,(function(c){switch(c.label){case 0:return[4,this._cache.updatePersistenceAsync("local")];case 1:return c.sent(),a=this._cache.keys,t=a.anonymousUuidKey,e=a.refreshTokenKey,[4,this._cache.getStoreAsync(t)];case 2:return n=c.sent(),[4,this._cache.getStoreAsync(e)];case 3:return o=c.sent(),[4,this._request.send("auth.signInAnonymously",{anonymous_uuid:n,refresh_token:o})];case 4:return(i=c.sent()).uuid&&i.refresh_token?[4,this._setAnonymousUUID(i.uuid)]:[3,10];case 5:return c.sent(),[4,this.setRefreshToken(i.refresh_token)];case 6:return c.sent(),[4,this._request.refreshAccessToken()];case 7:return c.sent(),Ct.fire(Dt.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:r.ANONYMOUS,persistence:"local"}),Ct.fire(Dt.LOGIN_STATE_CHANGED),[4,(s=new Ut({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 8:return c.sent(),[4,s.user.refresh()];case 9:return c.sent(),[2,s];case 10:throw new Error(JSON.stringify({code:R.OPERATION_FAIL,msg:JSON.stringify(i)||"anonymous signIn failed"}))}}))}))},e.prototype.linkAndRetrieveDataWithTicket=function(t){return T(this,void 0,void 0,(function(){var e,n,o,i,s,a,c;return N(this,(function(u){switch(u.label){case 0:return L(t)||x(R.INVALID_PARAMS,"ticket must be a string"),c=this._cache.keys,e=c.anonymousUuidKey,n=c.refreshTokenKey,[4,this._cache.getStoreAsync(e)];case 1:return o=u.sent(),[4,this._cache.getStoreAsync(n)];case 2:return i=u.sent(),[4,this._request.send("auth.linkAndRetrieveDataWithTicket",{anonymous_uuid:o,refresh_token:i,ticket:t})];case 3:return(s=u.sent()).refresh_token?[4,this._clearAnonymousUUID()]:[3,8];case 4:return u.sent(),[4,this.setRefreshToken(s.refresh_token)];case 5:return u.sent(),[4,this._request.refreshAccessToken()];case 6:return u.sent(),Ct.fire(Dt.ANONYMOUS_CONVERTED,{env:this._config.env}),Ct.fire(Dt.LOGIN_TYPE_CHANGED,{loginType:r.CUSTOM,persistence:"local"}),[4,(a=new Ut({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 7:return u.sent(),[2,a];case 8:return x(R.OPERATION_FAIL,JSON.stringify(s)||"linkAndRetrieveDataWithTicket failed"),[2]}}))}))},e.prototype._setAnonymousUUID=function(t){return T(this,void 0,void 0,(function(){var e,n,o;return N(this,(function(i){switch(i.label){case 0:return o=this._cache.keys,e=o.anonymousUuidKey,n=o.loginTypeKey,[4,this._cache.removeStoreAsync(e)];case 1:return i.sent(),[4,this._cache.setStoreAsync(e,t)];case 2:return i.sent(),[4,this._cache.setStoreAsync(n,r.ANONYMOUS)];case 3:return i.sent(),[2]}}))}))},e.prototype._clearAnonymousUUID=function(){return T(this,void 0,void 0,(function(){return N(this,(function(t){switch(t.label){case 0:return[4,this._cache.removeStoreAsync(this._cache.keys.anonymousUuidKey)];case 1:return t.sent(),[2]}}))}))},e.prototype._onConverted=function(t){return T(this,void 0,void 0,(function(){return N(this,(function(e){switch(e.label){case 0:return t.data.env!==this._config.env?[2]:[4,this._cache.updatePersistenceAsync(this._config.persistence)];case 1:return e.sent(),[2]}}))}))},function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);i>3&&s&&Object.defineProperty(e,n,s)}([k({title:"匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().anonymouseProvider().signIn() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(P)]}),A("design:type",Function),A("design:paramtypes",[]),A("design:returntype",Promise)],e.prototype,"signIn",null),e}(a),j=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)}}(),D=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},M=o.constants.ERRORS,q=o.constants.COMMUNITY_SITE_URL,B=o.utils.isString,F=o.helpers.catchErrorsDecorator,W=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return j(e,t),e.prototype.signIn=function(t){return e=this,n=void 0,i=function(){var e,n,o,i,s,a,c;return function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,(function(u){switch(u.label){case 0:if(!B(t))throw new Error(JSON.stringify({code:M.INVALID_PARAMS,msg:"ticket must be a string"}));return e=this._cache.keys.refreshTokenKey,i=(o=this._request).send,s=["auth.signInWithTicket"],c={ticket:t},[4,this._cache.getStoreAsync(e)];case 1:return[4,i.apply(o,s.concat([(c.refresh_token=u.sent()||"",c)]))];case 2:return(n=u.sent()).refresh_token?[4,this.setRefreshToken(n.refresh_token)]:[3,7];case 3:return u.sent(),[4,this._request.refreshAccessToken()];case 4:return u.sent(),Ct.fire(Dt.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:r.CUSTOM,persistence:this._config.persistence}),Ct.fire(Dt.LOGIN_STATE_CHANGED),[4,this.refreshUserInfo()];case 5:return u.sent(),[4,(a=new Ut({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()];case 6:return u.sent(),[2,a];case 7:throw new Error(JSON.stringify({code:M.OPERATION_FAIL,msg:"custom signIn failed"}))}}))},new((o=void 0)||(o=Promise))((function(t,r){function s(t){try{c(i.next(t))}catch(t){r(t)}}function a(t){try{c(i.throw(t))}catch(t){r(t)}}function c(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(s,a)}c((i=i.apply(e,n||[])).next())}));var e,n,o,i},function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);i>3&&s&&Object.defineProperty(e,n,s)}([F({title:"自定义登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了自定义登录"," 2 - 调用 auth().customAuthProvider().signIn() 的语法或参数是否正确"," 3 - ticket 是否归属于当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(q)]}),D("design:type",Function),D("design:paramtypes",[String]),D("design:returntype",Promise)],e.prototype,"signIn",null),e}(a),$=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)}}(),H=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},G=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},K=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},V=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},J=o.utils.throwError,Y=o.utils.isString,z=o.constants.ERRORS,X=o.constants.COMMUNITY_SITE_URL,Z=o.helpers.catchErrorsDecorator,Q=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return $(e,t),e.prototype.signIn=function(t,e){return K(this,void 0,void 0,(function(){var n,o,i,s,a;return V(this,(function(c){switch(c.label){case 0:return Y(t)||J(z.INVALID_PARAMS,"email must be a string"),n=this._cache.keys.refreshTokenKey,[4,this._request.send("auth.signIn",{loginType:"EMAIL",email:t,password:e,refresh_token:this._cache.getStore(n)||""})];case 1:return o=c.sent(),i=o.refresh_token,s=o.access_token,a=o.access_token_expire,i?[4,this.setRefreshToken(i)]:[3,8];case 2:return c.sent(),s&&a?[4,this.setAccessToken(s,a)]:[3,4];case 3:return c.sent(),[3,6];case 4:return[4,this._request.refreshAccessToken()];case 5:c.sent(),c.label=6;case 6:return[4,this.refreshUserInfo()];case 7:return c.sent(),Ct.fire(Dt.LOGIN_STATE_CHANGED),Ct.fire(Dt.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:r.EMAIL,persistence:this._config.persistence}),[2,new Ut({envId:this._config.env,cache:this._cache,request:this._request})];case 8:return o.code?J(z.OPERATION_FAIL,"Email login fail[".concat(o.code,"] ").concat(o.message)):J(z.OPERATION_FAIL,"Email login fail"),[2]}}))}))},e.prototype.signUp=function(t,e){return K(this,void 0,void 0,(function(){return V(this,(function(n){return[2,this._request.send("auth.signUpWithEmailAndPassword",{email:t,password:e})]}))}))},e.prototype.resetPassword=function(t){return K(this,void 0,void 0,(function(){return V(this,(function(e){return[2,this._request.send("auth.sendPasswordResetEmail",{email:t})]}))}))},e.prototype.resetPasswordWithToken=function(t,e){return K(this,void 0,void 0,(function(){return V(this,(function(n){return[2,this._request.send("auth.resetPasswordWithToken",{token:t,newPassword:e})]}))}))},e.prototype.activate=function(t){return K(this,void 0,void 0,(function(){return V(this,(function(e){return[2,this._request.send("auth.activateEndUserMail",{token:t})]}))}))},H([Z({title:"邮箱密码登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().emailAuthProvider() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录"," 3 - 邮箱地址与密码是否匹配","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(X)]}),G("design:type",Function),G("design:paramtypes",[String,String]),G("design:returntype",Promise)],e.prototype,"signIn",null),H([Z({title:"邮箱注册失败",messages:["请确认以下各项:"," 1 - 调用 auth().signUpWithEmailAndPassword() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录"," 3 - 此邮箱地址是否已经被其他用户占用","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(X)]}),G("design:type",Function),G("design:paramtypes",[String,String]),G("design:returntype",Promise)],e.prototype,"signUp",null),H([Z({title:"重置密码失败",messages:["请确认以下各项:"," 1 - 调用 auth().sendPasswordResetEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录"," 3 - 此邮箱地址是否已经与当前用户绑定"," 4 - 此邮箱地址是否已经被其他用户占用","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(X)]}),G("design:type",Function),G("design:paramtypes",[String]),G("design:returntype",Promise)],e.prototype,"resetPassword",null),H([Z({title:"重置密码失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(X)]}),G("design:type",Function),G("design:paramtypes",[String,String]),G("design:returntype",Promise)],e.prototype,"resetPasswordWithToken",null),H([Z({title:"邮箱激活失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(X)]}),G("design:type",Function),G("design:paramtypes",[String]),G("design:returntype",Promise)],e.prototype,"activate",null),e}(a),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)}}(),et=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},nt=o.utils.printWarn,rt=o.constants.ERRORS,ot=o.constants.COMMUNITY_SITE_URL,it=o.helpers.catchErrorsDecorator,st=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return tt(e,t),e.prototype.signIn=function(t,e){return n=this,o=void 0,s=function(){var n,o,i,s,a,c,u,f,l;return function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,(function(h){switch(h.label){case 0:if("string"!=typeof t)throw new Error(JSON.stringify({code:rt.INVALID_PARAMS,msg:"username must be a string"}));return"string"!=typeof e&&(e="",nt(rt.INVALID_PARAMS,"password is empty")),n=this._cache.keys.refreshTokenKey,s=(i=this._request).send,a=["auth.signIn"],l={loginType:r.USERNAME,username:t,password:e},[4,this._cache.getStoreAsync(n)];case 1:return[4,s.apply(i,a.concat([(l.refresh_token=h.sent()||"",l)]))];case 2:return o=h.sent(),c=o.refresh_token,u=o.access_token_expire,f=o.access_token,c?[4,this.setRefreshToken(c)]:[3,9];case 3:return h.sent(),f&&u?[4,this.setAccessToken(f,u)]:[3,5];case 4:return h.sent(),[3,7];case 5:return[4,this._request.refreshAccessToken()];case 6:h.sent(),h.label=7;case 7:return[4,this.refreshUserInfo()];case 8:return h.sent(),Ct.fire(Dt.LOGIN_STATE_CHANGED),Ct.fire(Dt.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:r.USERNAME,persistence:this._config.persistence}),[2,new Ut({envId:this._config.env,cache:this._cache,request:this._request})];case 9:throw o.code?new Error(JSON.stringify({code:rt.OPERATION_FAIL,msg:"login by username failed:[".concat(o.code,"] ").concat(o.message)})):new Error(JSON.stringify({code:rt.OPERATION_FAIL,msg:"login by username failed"}))}}))},new((i=void 0)||(i=Promise))((function(t,e){function r(t){try{c(s.next(t))}catch(t){e(t)}}function a(t){try{c(s.throw(t))}catch(t){e(t)}}function c(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i((function(t){t(n)}))).then(r,a)}c((s=s.apply(n,o||[])).next())}));var n,o,i,s},function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);i>3&&s&&Object.defineProperty(e,n,s)}([it({title:"用户名密码登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().signInWithUsernameAndPassword() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录"," 3 - 用户名密码是否匹配","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(ot)]}),et("design:type",Function),et("design:paramtypes",[String,String]),et("design:returntype",Promise)],e.prototype,"signIn",null),e}(a),at=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)}}(),ct=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},ut=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},ft=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},lt=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},ht=o.utils.throwError,pt=o.utils.isString,dt=o.utils.transformPhone,yt=o.constants.ERRORS,gt=o.constants.COMMUNITY_SITE_URL,vt=o.helpers.catchErrorsDecorator,mt="FORCERESETPWD",_t=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return at(e,t),e.prototype.signIn=function(t){return ft(this,void 0,void 0,(function(){var e,n,o,i,s,a,c,u,f;return lt(this,(function(l){switch(l.label){case 0:return e=t.phoneNumber,n=t.phoneCode,o=t.password,i=t.signMethod,pt(e)||ht(yt.INVALID_PARAMS,"phoneNumber must be a string"),pt(n)||pt(o)||ht(yt.INVALID_PARAMS,"phoneCode or password must be a string"),i||(i="SIGNIN"),s=this._cache.keys.refreshTokenKey,[4,this._request.send("auth.signIn",{loginType:r.PHONE,phoneNumber:dt(e),phoneCode:n,password:o,refresh_token:this._cache.getStore(s)||"",signMethod:i})];case 1:return a=l.sent(),c=a.refresh_token,u=a.access_token,f=a.access_token_expire,c?[4,this.setRefreshToken(c)]:[3,8];case 2:return l.sent(),u&&f?[4,this.setAccessToken(u,f)]:[3,4];case 3:return l.sent(),[3,6];case 4:return[4,this._request.refreshAccessToken()];case 5:l.sent(),l.label=6;case 6:return[4,this.refreshUserInfo()];case 7:return l.sent(),Ct.fire(Dt.LOGIN_STATE_CHANGED),Ct.fire(Dt.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:r.PHONE,persistence:this._config.persistence}),[2,new Ut({envId:this._config.env,cache:this._cache,request:this._request})];case 8:return a.code?ht(yt.OPERATION_FAIL,"Phone login fail[".concat(a.code,"] ").concat(a.message)):ht(yt.OPERATION_FAIL,"Phone login fail"),[2]}}))}))},e.prototype.signUp=function(t,e,n){return ft(this,void 0,void 0,(function(){return lt(this,(function(r){return[2,this.signIn({phoneNumber:t,phoneCode:e,password:n,signMethod:"SIGNUP"})]}))}))},e.prototype.forceResetPwd=function(t,e,n){return ft(this,void 0,void 0,(function(){return lt(this,(function(r){return[2,this.signIn({phoneNumber:t,phoneCode:e,password:n,signMethod:mt})]}))}))},ct([vt({title:"手机号登录失败",messages:["请确认以下各项:"," 1 - 调用 auth().SmsAuthProvider() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录"," 3 - 短信验证码/密码是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(gt)]}),ut("design:type",Function),ut("design:paramtypes",[Object]),ut("design:returntype",Promise)],e.prototype,"signIn",null),ct([vt({title:"手机短信注册失败",messages:["请确认以下各项:"," 1 - 调用 auth().signUpWithPhoneCode() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(gt)]}),ut("design:type",Function),ut("design:paramtypes",[String,String,String]),ut("design:returntype",Promise)],e.prototype,"signUp",null),ct([vt({title:"手机密码重置失败",messages:["请确认以下各项:"," 1 - 调用 auth().forceResetPwd() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(gt)]}),ut("design:type",Function),ut("design:paramtypes",[String,String,String]),ut("design:returntype",Promise)],e.prototype,"forceResetPwd",null),e}(a),wt=function(){return wt=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},wt.apply(this,arguments)},bt=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},Et=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},St=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},It=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},Ot=o.events.CloudbaseEventEmitter,At=o.adapters.RUNTIME,Tt=o.utils.printWarn,Nt=o.utils.throwError,Rt=o.utils.transformPhone,Pt=o.constants.ERRORS,xt=o.constants.COMMUNITY_SITE_URL,Lt=o.helpers.catchErrorsDecorator,Ct=new Ot,kt=function(){function t(t){var e=t.cache,n=t.request;this._cache=e,this._request=n,this._setUserInfo()}return t.prototype.checkLocalInfo=function(){return St(this,void 0,void 0,(function(){return It(this,(function(t){return this.uid=this._getLocalUserInfo("uid"),this.loginType=this._getLocalUserInfo("loginType"),this.openid=this._getLocalUserInfo("wxOpenId"),this.wxOpenId=this._getLocalUserInfo("wxOpenId"),this.wxPublicId=this._getLocalUserInfo("wxPublicId"),this.unionId=this._getLocalUserInfo("wxUnionId"),this.qqMiniOpenId=this._getLocalUserInfo("qqMiniOpenId"),this.customUserId=this._getLocalUserInfo("customUserId"),this.nickName=this._getLocalUserInfo("nickName"),this.gender=this._getLocalUserInfo("gender"),this.avatarUrl=this._getLocalUserInfo("avatarUrl"),this.email=this._getLocalUserInfo("email"),this.hasPassword=Boolean(this._getLocalUserInfo("hasPassword")),this.phone=this._getLocalUserInfo("phone"),this.username=this._getLocalUserInfo("username"),this.location={country:this._getLocalUserInfo("country"),province:this._getLocalUserInfo("province"),city:this._getLocalUserInfo("city")},[2]}))}))},t.prototype.checkLocalInfoAsync=function(){return St(this,void 0,void 0,(function(){var t,e,n,r,o,i,s,a,c,u,f,l,h,p,d,y,g,v;return It(this,(function(m){switch(m.label){case 0:return t=this,[4,this._getLocalUserInfoAsync("uid")];case 1:return t.uid=m.sent(),e=this,[4,this._getLocalUserInfoAsync("loginType")];case 2:return e.loginType=m.sent(),n=this,[4,this._getLocalUserInfoAsync("wxOpenId")];case 3:return n.openid=m.sent(),r=this,[4,this._getLocalUserInfoAsync("wxOpenId")];case 4:return r.wxOpenId=m.sent(),o=this,[4,this._getLocalUserInfoAsync("wxPublicId")];case 5:return o.wxPublicId=m.sent(),i=this,[4,this._getLocalUserInfoAsync("wxUnionId")];case 6:return i.unionId=m.sent(),s=this,[4,this._getLocalUserInfoAsync("qqMiniOpenId")];case 7:return s.qqMiniOpenId=m.sent(),a=this,[4,this._getLocalUserInfoAsync("customUserId")];case 8:return a.customUserId=m.sent(),c=this,[4,this._getLocalUserInfoAsync("nickName")];case 9:return c.nickName=m.sent(),u=this,[4,this._getLocalUserInfoAsync("gender")];case 10:return u.gender=m.sent(),f=this,[4,this._getLocalUserInfoAsync("avatarUrl")];case 11:return f.avatarUrl=m.sent(),l=this,[4,this._getLocalUserInfoAsync("email")];case 12:return l.email=m.sent(),h=this,p=Boolean,[4,this._getLocalUserInfoAsync("hasPassword")];case 13:return h.hasPassword=p.apply(void 0,[m.sent()]),d=this,[4,this._getLocalUserInfoAsync("phone")];case 14:return d.phone=m.sent(),y=this,[4,this._getLocalUserInfoAsync("username")];case 15:return y.username=m.sent(),g=this,v={},[4,this._getLocalUserInfoAsync("country")];case 16:return v.country=m.sent(),[4,this._getLocalUserInfoAsync("province")];case 17:return v.province=m.sent(),[4,this._getLocalUserInfoAsync("city")];case 18:return g.location=(v.city=m.sent(),v),[2]}}))}))},t.prototype.linkWithTicket=function(t){if("string"!=typeof t)throw new Error("ticket must be string");return this._request.send("auth.linkWithTicket",{ticket:t})},t.prototype.linkWithRedirect=function(t){t.signInWithRedirect()},t.prototype.getLinkedUidList=function(){return St(this,void 0,void 0,(function(){var t,e,n,r,o,i;return It(this,(function(s){switch(s.label){case 0:return[4,this._request.send("auth.getLinkedUidList",{})];case 1:for(t=s.sent().data,e=!1,n=t.users,r=0,o=n;r<o.length;r++)if((i=o[r]).wxOpenId&&i.wxPublicId){e=!0;break}return[2,{users:n,hasPrimaryUid:e}]}}))}))},t.prototype.setPrimaryUid=function(t){return this._request.send("auth.setPrimaryUid",{uid:t})},t.prototype.unlink=function(t){return this._request.send("auth.unlink",{platform:t})},t.prototype.update=function(t){return St(this,void 0,void 0,(function(){var e,n,r,o,i,s,a;return It(this,(function(c){switch(c.label){case 0:return e=t.nickName,n=t.gender,r=t.avatarUrl,o=t.province,i=t.country,s=t.city,[4,this._request.send("auth.updateUserInfo",{nickName:e,gender:n,avatarUrl:r,province:o,country:i,city:s})];case 1:return a=c.sent().data,this._setLocalUserInfo(a),[2]}}))}))},t.prototype.updatePassword=function(t,e){return this._request.send("auth.updatePassword",{oldPassword:e,newPassword:t})},t.prototype.updateEmail=function(t,e){return this._request.send("auth.updateEmail",{newEmail:t,password:e})},t.prototype.updateUsername=function(t){return"string"!=typeof t&&Nt(Pt.INVALID_PARAMS,"username must be a string"),this._request.send("auth.updateUsername",{username:t})},t.prototype.refresh=function(){return St(this,void 0,void 0,(function(){var t;return It(this,(function(e){switch(e.label){case 0:return[4,this._request.send("auth.getUserInfo",{})];case 1:return t=e.sent().data,this._setLocalUserInfo(t),[2,t]}}))}))},t.prototype.linkWithPhoneNumber=function(t,e){return St(this,void 0,void 0,(function(){return It(this,(function(n){return[2,this._request.send("auth.linkOrUpdatePhoneNumber",{phoneNumber:Rt(t),phoneCode:e})]}))}))},t.prototype.updatePhoneNumber=function(t,e){return St(this,void 0,void 0,(function(){return It(this,(function(n){return[2,this._request.send("auth.linkOrUpdatePhoneNumber",{phoneNumber:Rt(t),phoneCode:e})]}))}))},t.prototype._getLocalUserInfo=function(t){var e=this._cache.keys.userInfoKey;return this._cache.getStore(e)[t]},t.prototype._getLocalUserInfoAsync=function(t){return St(this,void 0,void 0,(function(){var e;return It(this,(function(n){switch(n.label){case 0:return e=this._cache.keys.userInfoKey,[4,this._cache.getStoreAsync(e)];case 1:return[2,n.sent()[t]]}}))}))},t.prototype._setUserInfo=function(){var t=this,e=this._cache.keys.userInfoKey,n=this._cache.getStore(e);["uid","loginType","openid","wxOpenId","wxPublicId","unionId","qqMiniOpenId","email","hasPassword","customUserId","nickName","gender","avatarUrl","phone","username"].forEach((function(e){t[e]=n[e]})),this.location={country:n.country,province:n.province,city:n.city}},t.prototype._setLocalUserInfo=function(t){var e=this._cache.keys.userInfoKey;this._cache.setStore(e,t),this._setUserInfo()},bt([Lt({title:"绑定自定义登录失败",messages:["请确认以下各项:"," 1 - 调用 User.linkWithTicket() 的语法或参数是否正确"," 2 - 此账户是否已经绑定自定义登录"," 3 - ticket 参数是否归属当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[String]),Et("design:returntype",Promise)],t.prototype,"linkWithTicket",null),bt([Lt({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 User.linkWithRedirect() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方"," 3 - 此第三方是否已经授权","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[Object]),Et("design:returntype",void 0)],t.prototype,"linkWithRedirect",null),bt([Lt({title:"获取账户列表失败",messages:["请确认以下各项:"," 1 - 调用 User.getLinkedUidList() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[]),Et("design:returntype",Promise)],t.prototype,"getLinkedUidList",null),bt([Lt({title:"设置微信主账号失败",messages:["请确认以下各项:"," 1 - 调用 User.setPrimaryUid() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[String]),Et("design:returntype",void 0)],t.prototype,"setPrimaryUid",null),bt([Lt({title:"接触绑定失败",messages:["请确认以下各项:"," 1 - 调用 User.unlink() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[String]),Et("design:returntype",void 0)],t.prototype,"unlink",null),bt([Lt({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[Object]),Et("design:returntype",Promise)],t.prototype,"update",null),bt([Lt({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[String,String]),Et("design:returntype",void 0)],t.prototype,"updatePassword",null),bt([Lt({title:"更新邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 User.updateEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[String,String]),Et("design:returntype",void 0)],t.prototype,"updateEmail",null),bt([Lt({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[String]),Et("design:returntype",void 0)],t.prototype,"updateUsername",null),bt([Lt({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[]),Et("design:returntype",Promise)],t.prototype,"refresh",null),bt([Lt({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().linkWithPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[String,String]),Et("design:returntype",Promise)],t.prototype,"linkWithPhoneNumber",null),bt([Lt({title:"更新手机号失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[String,String]),Et("design:returntype",Promise)],t.prototype,"updatePhoneNumber",null),t}(),Ut=function(){function t(t){var e=t.envId,n=t.cache,r=t.request;e||Nt(Pt.INVALID_PARAMS,"envId is not defined"),this._cache=n,this.user=new kt({cache:n,request:r})}return t.prototype.checkLocalState=function(){return St(this,void 0,void 0,(function(){var t,e,n,r,o,i,s;return It(this,(function(a){return t=this._cache.keys,e=t.refreshTokenKey,n=t.accessTokenKey,r=t.accessTokenExpireKey,o=this._cache.getStore(e),i=this._cache.getStore(n),s=this._cache.getStore(r),this.credential={refreshToken:o,accessToken:i,accessTokenExpire:s},this._loginType=this._cache.getStore(this._cache.keys.loginTypeKey),this.user.checkLocalInfo(),[2]}))}))},t.prototype.checkLocalStateAsync=function(){return St(this,void 0,void 0,(function(){var t,e,n,r,o,i,s,a;return It(this,(function(c){switch(c.label){case 0:return t=this._cache.keys,e=t.refreshTokenKey,n=t.accessTokenKey,r=t.accessTokenExpireKey,[4,this._cache.getStoreAsync(e)];case 1:return o=c.sent(),[4,this._cache.getStoreAsync(n)];case 2:return i=c.sent(),[4,this._cache.getStoreAsync(r)];case 3:return s=c.sent(),this.credential={refreshToken:o,accessToken:i,accessTokenExpire:s},a=this,[4,this._cache.getStoreAsync(this._cache.keys.loginTypeKey)];case 4:return a._loginType=c.sent(),[4,this.user.checkLocalInfoAsync()];case 5:return c.sent(),[2]}}))}))},Object.defineProperty(t.prototype,"isAnonymousAuth",{get:function(){return this.loginType===r.ANONYMOUS},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isCustomAuth",{get:function(){return this.loginType===r.CUSTOM},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isWeixinAuth",{get:function(){return this.loginType===r.WECHAT||this.loginType===r.WECHAT_OPEN||this.loginType===r.WECHAT_PUBLIC},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isUsernameAuth",{get:function(){return this.loginType===r.USERNAME},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"loginType",{get:function(){return this._loginType},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isPhoneAuth",{get:function(){return this.loginType===r.PHONE},enumerable:!1,configurable:!0}),t}(),jt=function(){function t(t){this._config=t,this._cache=t.cache,this._request=t.request,this._runtime=t.runtime||At.WEB,Ct.on(Dt.LOGIN_TYPE_CHANGED,this._onLoginTypeChanged.bind(this))}return Object.defineProperty(t.prototype,"currentUser",{get:function(){if("async"!==this._cache.mode){var t=this.hasLoginState();return t&&t.user||null}Tt(Pt.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrentUser insteed")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"loginType",{get:function(){return this._cache.getStore(this._cache.keys.loginTypeKey)},enumerable:!1,configurable:!0}),t.prototype.getCurrenUser=function(){return St(this,void 0,void 0,(function(){return It(this,(function(t){switch(t.label){case 0:return[4,this.getCurrentUser()];case 1:return[2,t.sent()]}}))}))},t.prototype.getCurrentUser=function(){return St(this,void 0,void 0,(function(){var t;return It(this,(function(e){switch(e.label){case 0:return[4,this.getLoginState()];case 1:return(t=e.sent())?[4,t.user.checkLocalInfoAsync()]:[3,3];case 2:return e.sent(),[2,t.user||null];case 3:return[2,null]}}))}))},t.prototype.getLoginType=function(){return St(this,void 0,void 0,(function(){return It(this,(function(t){switch(t.label){case 0:return[4,this._cache.getStoreAsync(this._cache.keys.loginTypeKey)];case 1:return[2,t.sent()]}}))}))},t.prototype.getAccessToken=function(){return St(this,void 0,void 0,(function(){var t;return It(this,(function(e){switch(e.label){case 0:return t={},[4,this._request.getAccessToken()];case 1:return[2,(t.accessToken=e.sent().accessToken,t.env=this._config.env,t)]}}))}))},t.prototype.weixinAuthProvider=function(t){var e=t.appid,n=t.scope,r=t.state;return this._weixinAuthProvider||(this._weixinAuthProvider=new S(wt(wt({},this._config),{cache:this._cache,request:this._request,runtime:this._runtime}),e,n,r)),this._weixinAuthProvider},t.prototype.anonymousAuthProvider=function(){return this._anonymousAuthProvider||(this._anonymousAuthProvider=new U(wt(wt({},this._config),{cache:this._cache,request:this._request}))),this._anonymousAuthProvider},t.prototype.customAuthProvider=function(){return this._customAuthProvider||(this._customAuthProvider=new W(wt(wt({},this._config),{cache:this._cache,request:this._request}))),this._customAuthProvider},t.prototype.emailAuthProvider=function(){return this._emailAuthProvider||(this._emailAuthProvider=new Q(wt(wt({},this._config),{cache:this._cache,request:this._request}))),this._emailAuthProvider},t.prototype.usernameAuthProvider=function(){return this._usernameAuthProvider||(this._usernameAuthProvider=new st(wt(wt({},this._config),{cache:this._cache,request:this._request}))),this._usernameAuthProvider},t.prototype.phoneAuthProvider=function(){return this._phoneAuthProvider||(this._phoneAuthProvider=new _t(wt(wt({},this._config),{cache:this._cache,request:this._request}))),this._phoneAuthProvider},t.prototype.signInWithUsernameAndPassword=function(t,e){return St(this,void 0,void 0,(function(){return It(this,(function(n){return[2,this.usernameAuthProvider().signIn(t,e)]}))}))},t.prototype.isUsernameRegistered=function(t){return St(this,void 0,void 0,(function(){var e;return It(this,(function(n){switch(n.label){case 0:return"string"!=typeof t&&Nt(Pt.INVALID_PARAMS,"username must be a string"),[4,this._request.send("auth.isUsernameRegistered",{username:t})];case 1:return[2,null==(e=n.sent().data)?void 0:e.isRegistered]}}))}))},t.prototype.signInWithEmailAndPassword=function(t,e){return St(this,void 0,void 0,(function(){return It(this,(function(n){return[2,this.emailAuthProvider().signIn(t,e)]}))}))},t.prototype.signUpWithEmailAndPassword=function(t,e){return St(this,void 0,void 0,(function(){return It(this,(function(n){return[2,this.emailAuthProvider().signUp(t,e)]}))}))},t.prototype.sendPasswordResetEmail=function(t){return St(this,void 0,void 0,(function(){return It(this,(function(e){return[2,this.emailAuthProvider().resetPassword(t)]}))}))},t.prototype.signOut=function(){return St(this,void 0,void 0,(function(){var t,e,n,o,i,s,a;return It(this,(function(c){switch(c.label){case 0:return t=this._cache.keys,e=t.refreshTokenKey,n=t.accessTokenKey,o=t.accessTokenExpireKey,i="auth.logout",[4,this._cache.getStoreAsync(e)];case 1:return(s=c.sent())?[4,this._request.send(i,{refresh_token:s})]:[2];case 2:return a=c.sent(),this._cache.removeStoreAsync(e),this._cache.removeStoreAsync(n),this._cache.removeStoreAsync(o),Ct.fire(Dt.LOGIN_STATE_CHANGED),Ct.fire(Dt.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:r.NULL,persistence:this._config.persistence}),[2,a]}}))}))},t.prototype.onLoginStateChanged=function(t){return St(this,void 0,void 0,(function(){var e,n=this;return It(this,(function(r){switch(r.label){case 0:return Ct.on(Dt.LOGIN_STATE_CHANGED,(function(){return St(n,void 0,void 0,(function(){var e;return It(this,(function(n){switch(n.label){case 0:return[4,this.getLoginState()];case 1:return e=n.sent(),t.call(this,e),[2]}}))}))})),[4,this.getLoginState()];case 1:return e=r.sent(),t.call(this,e),[2]}}))}))},t.prototype.onLoginStateExpired=function(t){Ct.on(Dt.LOGIN_STATE_EXPIRED,t.bind(this))},t.prototype.onAccessTokenRefreshed=function(t){Ct.on(Dt.ACCESS_TOKEN_REFRESHD,t.bind(this))},t.prototype.onAnonymousConverted=function(t){Ct.on(Dt.ANONYMOUS_CONVERTED,t.bind(this))},t.prototype.onLoginTypeChanged=function(t){var e=this;Ct.on(Dt.LOGIN_TYPE_CHANGED,(function(){return St(e,void 0,void 0,(function(){var e;return It(this,(function(n){switch(n.label){case 0:return[4,this.getLoginState()];case 1:return e=n.sent(),t.call(this,e),[2]}}))}))}))},t.prototype.hasLoginState=function(){if("async"!==this._cache.mode){var t=this._cache.keys.refreshTokenKey;if(this._cache.getStore(t)){var e=new Ut({envId:this._config.env,cache:this._cache,request:this._request});return e.checkLocalState(),e}return null}Tt(Pt.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState insteed")},t.prototype.getLoginState=function(){return St(this,void 0,void 0,(function(){var t,e;return It(this,(function(n){switch(n.label){case 0:return t=this._cache.keys.refreshTokenKey,[4,this._cache.getStoreAsync(t)];case 1:return n.sent()?[4,(e=new Ut({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()]:[3,3];case 2:return n.sent(),[2,e];case 3:return[2,null]}}))}))},t.prototype.shouldRefreshAccessToken=function(t){this._request._shouldRefreshAccessTokenHook=t.bind(this)},t.prototype.getUserInfo=function(){return St(this,void 0,void 0,(function(){var t;return It(this,(function(e){switch(e.label){case 0:return[4,this._request.send("auth.getUserInfo",{})];case 1:return(t=e.sent()).code?[2,t]:[2,wt(wt({},t.data),{requestId:t.seqId})]}}))}))},t.prototype.getAuthHeader=function(){var t=this._cache.keys,e=t.refreshTokenKey,n=t.accessTokenKey,r=this._cache.getStore(e),o=this._cache.getStore(n);return{"x-cloudbase-credentials":"".concat(o,"/@@/").concat(r)}},t.prototype.getAuthHeaderAsync=function(){return St(this,void 0,void 0,(function(){var t,e,n,r,o;return It(this,(function(i){switch(i.label){case 0:return[4,this._request.refreshAccessToken()];case 1:return i.sent(),t=this._cache.keys,e=t.refreshTokenKey,n=t.accessTokenKey,[4,this._cache.getStoreAsync(e)];case 2:return r=i.sent(),[4,this._cache.getStoreAsync(n)];case 3:return o=i.sent(),[2,{"x-cloudbase-credentials":"".concat(o,"/@@/").concat(r)}]}}))}))},t.prototype.sendPhoneCode=function(t){return St(this,void 0,void 0,(function(){return It(this,(function(e){switch(e.label){case 0:return[4,this._request.send("auth.sendPhoneCode",{phoneNumber:Rt(t)})];case 1:return[2,"Ok"===e.sent().data.SendStatus]}}))}))},t.prototype.signUpWithPhoneCode=function(t,e,n){return St(this,void 0,void 0,(function(){return It(this,(function(r){return[2,this.phoneAuthProvider().signUp(t,e,n)]}))}))},t.prototype.signInWithPhoneCodeOrPassword=function(t){return St(this,void 0,void 0,(function(){return It(this,(function(e){return[2,this.phoneAuthProvider().signIn(t)]}))}))},t.prototype.forceResetPwdByPhoneCode=function(t){return St(this,void 0,void 0,(function(){return It(this,(function(e){return[2,this.phoneAuthProvider().signIn(wt(wt({},t),{signMethod:mt}))]}))}))},t.prototype._onLoginTypeChanged=function(t){return St(this,void 0,void 0,(function(){var e,n,r;return It(this,(function(o){switch(o.label){case 0:return e=t.data,n=e.loginType,r=e.persistence,e.env!==this._config.env?[2]:[4,this._cache.updatePersistenceAsync(r)];case 1:return o.sent(),[4,this._cache.setStoreAsync(this._cache.keys.loginTypeKey,n)];case 2:return o.sent(),[2]}}))}))},bt([Lt({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrenUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[]),Et("design:returntype",Promise)],t.prototype,"getCurrenUser",null),bt([Lt({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrentUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[]),Et("design:returntype",Promise)],t.prototype,"getCurrentUser",null),bt([Lt({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[String]),Et("design:returntype",Promise)],t.prototype,"isUsernameRegistered",null),bt([Lt({title:"用户登出失败",messages:["请确认以下各项:"," 1 - 调用 auth().signOut() 的语法或参数是否正确"," 2 - 当前用户是否为匿名登录(匿名登录不支持signOut)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[]),Et("design:returntype",Promise)],t.prototype,"signOut",null),bt([Lt({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[]),Et("design:returntype",Promise)],t.prototype,"getLoginState",null),bt([Lt({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[]),Et("design:returntype",Promise)],t.prototype,"getUserInfo",null),bt([Lt({title:"发送短信验证码失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),Et("design:type",Function),Et("design:paramtypes",[String]),Et("design:returntype",Promise)],t.prototype,"sendPhoneCode",null),t}(),Dt={LOGIN_STATE_CHANGED:"loginStateChanged",LOGIN_STATE_EXPIRED:"loginStateExpire",LOGIN_TYPE_CHANGED:"loginTypeChanged",ANONYMOUS_CONVERTED:"anonymousConverted",ACCESS_TOKEN_REFRESHD:"refreshAccessToken"},Mt={name:"auth",namespace:"auth",injectEvents:{bus:Ct,events:[Dt.LOGIN_TYPE_CHANGED,Dt.LOGIN_STATE_EXPIRED,Dt.LOGIN_STATE_CHANGED,Dt.ACCESS_TOKEN_REFRESHD,Dt.ANONYMOUS_CONVERTED]},entity:function(t){if(void 0===t&&(t={region:"",persistence:"local"}),this.authInstance)return Tt(Pt.INVALID_OPERATION,"every cloudbase instance should has only one auth object"),this.authInstance;var e=this.platform,n=e.adapter,r=e.runtime,o=t.persistence||n.primaryStorage;o&&o!==this.config.persistence&&this.updateConfig({persistence:o});var i=this.config,s=i.env,a=i.persistence,c=i.debug;return this.authInstance=new jt({env:s,region:t.region,persistence:a,debug:c,cache:this.cache,request:this.request,runtime:r}),this.authInstance}};try{cloudbase.registerComponent(Mt)}catch(t){}function qt(t){try{t.registerComponent(Mt)}catch(t){console.warn(t)}}function Bt(t,e){jt.prototype[t]=function(n){var r="_".concat(t);return this[r]||(this[r]=new e(wt(wt({},n),this._config))),this[r]}}},622:function(t,e,n){"use strict";n.r(e),n.d(e,{registerDatabase:function(){return Mn}});var r,o,i={};n.r(i),n.d(i,{LineString:function(){return H},MultiLineString:function(){return Y},MultiPoint:function(){return V},MultiPolygon:function(){return X},Point:function(){return ot},Polygon:function(){return K}}),function(t){t.DocIDError="文档ID不合法",t.CollNameError="集合名称不合法",t.OpStrError="操作符不合法",t.DirectionError="排序字符不合法",t.IntergerError="must be integer",t.QueryParamTypeError="查询参数必须为对象",t.QueryParamValueError="查询参数对象值不能均为undefined"}(o||(o={}));var s,a,c="Object",u="GeoPoint",f="GeoLineString",l="GeoPolygon",h="GeoMultiPoint",p="GeoMultiLineString",d="GeoMultiPolygon",y="Date",g="ServerDate",v=["desc","asc"],m=["<","<=","==",">=",">"];!function(t){t.lt="<",t.gt=">",t.lte="<=",t.gte=">=",t.eq="=="}(s||(s={})),(r={})[s.eq]="$eq",r[s.lt]="$lt",r[s.lte]="$lte",r[s.gt]="$gt",r[s.gte]="$gte",function(t){t.WHERE="WHERE",t.DOC="DOC"}(a||(a={}));var _,w=(_=function(t,e){return _=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},_(t,e)},function(t,e){function n(){this.constructor=t}_(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),b=[],E={},S=function(t){function e(e,n){if(n!==E)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=b.length;n<r;n++)if(b[n].target===t)return b[n].instance;var o=new e(t,E);return b.push({target:t,instance:o}),o},e}((function(t){Object.defineProperties(this,{target:{enumerable:!1,writable:!1,configurable:!1,value:t}})})),I=S,O=I.for("UNSET_FIELD_NAME"),A=I.for("UPDATE_COMMAND"),T=I.for("QUERY_COMMAND"),N=I.for("LOGIC_COMMAND"),R=I.for("GEO_POINT"),P=I.for("SYMBOL_GEO_LINE_STRING"),x=I.for("SYMBOL_GEO_POLYGON"),L=I.for("SYMBOL_GEO_MULTI_POINT"),C=I.for("SYMBOL_GEO_MULTI_LINE_STRING"),k=I.for("SYMBOL_GEO_MULTI_POLYGON"),U=I.for("SERVER_DATE"),j=I.for("REGEXP"),D=function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},M=function(t){return"object"===D(t)},q=function(t){return"number"===D(t)},B=function(t){return Array.isArray(t)},F=function(t){return"date"===D(t)},W=function(t){return"regexp"===D(t)},$=function(t){return t&&t._internalType instanceof S},H=function(){function t(t){if(!B(t))throw new TypeError('"points" must be of type Point[]. Received type '+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 '+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||!B(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(!q(i[0])||!q(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 P},enumerable:!0,configurable:!0}),t}(),G=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.")},K=function(){function t(t){if(!B(t))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof t);if(0===t.length)throw new Error("Polygon must contain 1 linestring at least");t.forEach((function(t){if(!(t instanceof H))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof t+"[]");if(!H.isClosed(t))throw new Error("LineString "+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||!B(t.coordinates))return!1;try{for(var i=G(t.coordinates),s=i.next();!s.done;s=i.next()){var a=s.value;if(!this.isCloseLineString(a))return!1;try{for(var c=(r=void 0,G(a)),u=c.next();!u.done;u=c.next()){var f=u.value;if(!q(f[0])||!q(f[1]))return!1}}catch(t){r={error:t}}finally{try{u&&!u.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{s&&!s.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 k},enumerable:!0,configurable:!0}),t}(),V=function(){function t(t){if(!B(t))throw new TypeError('"points" must be of type Point[]. Received type '+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 '+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||!B(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(!q(i[0])||!q(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 L},enumerable:!0,configurable:!0}),t}(),J=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.")},Y=function(){function t(t){if(!B(t))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof t);if(0===t.length)throw new Error("Polygon must contain 1 linestring at least");t.forEach((function(t){if(!(t instanceof H))throw new TypeError('"lines" must be of type LineString[]. Received type '+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||!B(t.coordinates))return!1;try{for(var i=J(t.coordinates),s=i.next();!s.done;s=i.next()){var a=s.value;try{for(var c=(r=void 0,J(a)),u=c.next();!u.done;u=c.next()){var f=u.value;if(!q(f[0])||!q(f[1]))return!1}}catch(t){r={error:t}}finally{try{u&&!u.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{s&&!s.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:!0,configurable:!0}),t}(),z=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(!B(t))throw new TypeError('"polygons" must be of type Polygon[]. Received type '+typeof t);if(0===t.length)throw new Error("MultiPolygon must contain 1 polygon at least");try{for(var r=z(t),o=r.next();!o.done;o=r.next()){var i=o.value;if(!(i instanceof K))throw new TypeError('"polygon" must be of type Polygon[]. Received type '+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,s;if("MultiPolygon"!==t.type||!B(t.coordinates))return!1;try{for(var a=z(t.coordinates),c=a.next();!c.done;c=a.next()){var u=c.value;try{for(var f=(r=void 0,z(u)),l=f.next();!l.done;l=f.next()){var h=l.value;try{for(var p=(i=void 0,z(h)),d=p.next();!d.done;d=p.next()){var y=d.value;if(!q(y[0])||!q(y[1]))return!1}}catch(t){i={error:t}}finally{try{d&&!d.done&&(s=p.return)&&s.call(p)}finally{if(i)throw i.error}}}}catch(t){r={error:t}}finally{try{l&&!l.done&&(o=f.return)&&o.call(f)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{c&&!c.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return x},enumerable:!0,configurable:!0}),t}(),Z=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 U},enumerable:!0,configurable:!0}),t.prototype.parse=function(){return{$date:{offset:this.offset}}},t}();function Q(t){return new Z(t)}var tt,et=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.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 s},nt=function(){function t(){}return t.formatResDocumentData=function(e){return e.map((function(e){return t.formatField(e)}))},t.formatField=function(e){var n=Object.keys(e),r={};return Array.isArray(e)&&(r=[]),n.forEach((function(n){var o,i=e[n];switch(t.whichType(i)){case u:o=new ot(i.coordinates[0],i.coordinates[1]);break;case f:o=new H(i.coordinates.map((function(t){return new ot(t[0],t[1])})));break;case l:o=new K(i.coordinates.map((function(t){return new H(t.map((function(t){var e=et(t,2),n=e[0],r=e[1];return new ot(n,r)})))})));break;case h:o=new V(i.coordinates.map((function(t){return new ot(t[0],t[1])})));break;case p:o=new Y(i.coordinates.map((function(t){return new H(t.map((function(t){var e=et(t,2),n=e[0],r=e[1];return new ot(n,r)})))})));break;case d:o=new X(i.coordinates.map((function(t){return new K(t.map((function(t){return new H(t.map((function(t){var e=et(t,2),n=e[0],r=e[1];return new ot(n,r)})))})))})));break;case y:o=new Date(1e3*i.$timestamp);break;case c:case"Array":o=t.formatField(i);break;case g: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);if(e===y)return"BsonDate";if(e===c){if(t instanceof ot)return u;if(t instanceof Date)return y;if(t instanceof Z)return g;t.$timestamp?e=y:t.$date?e=g:ot.validate(t)?e=u:H.validate(t)?e=f:K.validate(t)?e=l:V.validate(t)?e=h:Y.validate(t)?e=p:X.validate(t)&&(e=d)}return e},t.generateDocId=function(){for(var t="",e=0;e<24;e++)t+="ABCDEFabcdef0123456789".charAt(Math.floor(22*Math.random()));return t},t}(),rt=function(){function t(){}return t.isGeopoint=function(t,e){if("Number"!==nt.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.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===m.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}(),ot=function(){function t(t,e){rt.isGeopoint("longitude",t),rt.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"["+this.longitude+","+this.latitude+"]"},t.validate=function(t){return"Point"===t.type&&B(t.coordinates)&&rt.isGeopoint("longitude",t.coordinates[0])&&rt.isGeopoint("latitude",t.coordinates[1])},Object.defineProperty(t.prototype,"_internalType",{get:function(){return R},enumerable:!0,configurable:!0}),t}(),it=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};!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"}(tt||(tt={}));var st,at=function(){function t(t,e,n){this._internalType=A,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=t,this.operands=e,this.fieldName=n||O}return t.prototype._setFieldName=function(e){return new t(this.operator,this.operands,e)},t}();function ct(t){return t&&t instanceof at&&t._internalType===A}!function(t){t.AND="and",t.OR="or",t.NOT="not",t.NOR="nor"}(st||(st={}));var ut=function(){function t(t,e,n){if(this._internalType=N,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=t,this.operands=e,this.fieldName=n||O,this.fieldName!==O)if(Array.isArray(e)){e=e.slice(),this.operands=e;for(var r=0,o=e.length;r<o;r++)(ft(i=e[r])||dt(i))&&(e[r]=i._setFieldName(this.fieldName))}else{var i;(ft(i=e)||dt(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(st.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(st.OR,r,this.fieldName)},t}();function ft(t){return t&&t instanceof ut&&t._internalType===N}var lt,ht=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)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){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"}(lt||(lt={}));var pt=function(t){function e(e,n,r){var o=t.call(this,e,n,r)||this;return o.operator=e,o._internalType=T,o}return ht(e,t),e.prototype.toJSON=function(){var t,e;switch(this.operator){case lt.IN:case lt.NIN:return(t={})["$"+this.operator]=this.operands,t;default:return(e={})["$"+this.operator]=this.operands[0],e}},e.prototype._setFieldName=function(t){return new e(this.operator,this.operands,t)},e.prototype.eq=function(t){var n=new e(lt.EQ,[t],this.fieldName);return this.and(n)},e.prototype.neq=function(t){var n=new e(lt.NEQ,[t],this.fieldName);return this.and(n)},e.prototype.gt=function(t){var n=new e(lt.GT,[t],this.fieldName);return this.and(n)},e.prototype.gte=function(t){var n=new e(lt.GTE,[t],this.fieldName);return this.and(n)},e.prototype.lt=function(t){var n=new e(lt.LT,[t],this.fieldName);return this.and(n)},e.prototype.lte=function(t){var n=new e(lt.LTE,[t],this.fieldName);return this.and(n)},e.prototype.in=function(t){var n=new e(lt.IN,t,this.fieldName);return this.and(n)},e.prototype.nin=function(t){var n=new e(lt.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 '+typeof t.geometry);if(void 0!==t.maxDistance&&!q(t.maxDistance))throw new TypeError('"maxDistance" must be of type Number. Received type '+typeof t.maxDistance);if(void 0!==t.minDistance&&!q(t.minDistance))throw new TypeError('"minDistance" must be of type Number. Received type '+typeof t.minDistance);var n=new e(lt.GEO_NEAR,[t],this.fieldName);return this.and(n)},e.prototype.geoWithin=function(t){if(!(t.geometry instanceof X||t.geometry instanceof K))throw new TypeError('"geometry" must be of type Polygon or MultiPolygon. Received type '+typeof t.geometry);var n=new e(lt.GEO_WITHIN,[t],this.fieldName);return this.and(n)},e.prototype.geoIntersects=function(t){if(!(t.geometry instanceof ot||t.geometry instanceof H||t.geometry instanceof K||t.geometry instanceof V||t.geometry instanceof Y||t.geometry instanceof X))throw new TypeError('"geometry" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type '+typeof t.geometry);var n=new e(lt.GEO_INTERSECTS,[t],this.fieldName);return this.and(n)},e}(ut);function dt(t){return t&&t instanceof pt&&t._internalType===T}function yt(t){return dt(t)}var gt={};for(var vt in lt)gt[vt]="$"+vt;for(var vt in st)gt[vt]="$"+vt;for(var vt in tt)gt[vt]="$"+vt;function mt(t){return gt[t]||"$"+t}gt[lt.NEQ]="$ne",gt[tt.REMOVE]="$unset",gt[tt.SHIFT]="$pop",gt[tt.UNSHIFT]="$push";var _t=function(){return _t=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},_t.apply(this,arguments)},wt=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.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 s},bt=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(wt(arguments[e]));return t};function Et(t){return St(t,[t])}function St(t,e){if(!$(t)){if(F(t))return{$date:+t};if(W(t))return{$regex:t.source,$options:t.flags};if(B(t))return t.map((function(t){if(e.indexOf(t)>-1)throw new Error("Cannot convert circular structure to JSON");return St(t,bt(e,[t]))}));if(M(t)){var n=_t({},t);for(var r in n){if(e.indexOf(n[r])>-1)throw new Error("Cannot convert circular structure to JSON");n[r]=St(n[r],bt(e,[n[r]]))}return n}return t}switch(t._internalType){case R:return t.toJSON();case U:case j:return t.parse();default:return t.toJSON?t.toJSON():t}}var It=function(){return It=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},It.apply(this,arguments)},Ot=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.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 s},At=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Ot(arguments[e]));return t};function Tt(t,e,n,r){var o=It({},t);for(var i in t)if(!/^\$/.test(i)){var s=t[i];if(s&&M(s)&&!e(s)){if(r.indexOf(s)>-1)throw new Error("Cannot convert circular structure to JSON");var a=Tt(s,e,At(n,[i]),At(r,[s]));o[i]=a;var c=!1;for(var u in a)/^\$/.test(u)?c=!0:(o[i+"."+u]=a[u],delete o[i][u]);c||delete o[i]}}return o}function Nt(t){return Tt(t,Pt,[],[t])}function Rt(t,e,n){for(var r in e[n]||delete t[n],e)t[r]?B(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 "+D(e)+", can only overwrite",e,n),t[r]=e[r]):(console.warn("to-merge query is of type "+D(t)+", can only overwrite",t,e,n),t[r]=e[r]):t[r]=e[r]}function Pt(t){return $(t)||F(t)||W(t)}function xt(t){return Et(t)}var Lt=function(){function t(){}return t.encode=function(e){return(new t).encodeUpdate(e)},t.prototype.encodeUpdate=function(t){return ct(t)?this.encodeUpdateCommand(t):"object"===D(t)?this.encodeUpdateObject(t):t},t.prototype.encodeUpdateCommand=function(t){if(t.fieldName===O)throw new Error("Cannot encode a comparison command with unset field name");switch(t.operator){case tt.PUSH:case tt.PULL:case tt.PULL_ALL:case tt.POP:case tt.SHIFT:case tt.UNSHIFT:case tt.ADD_TO_SET:return this.encodeArrayUpdateCommand(t);default:return this.encodeFieldUpdateCommand(t)}},t.prototype.encodeFieldUpdateCommand=function(t){var e,n,r,o,i=mt(t.operator);return t.operator===tt.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,s,a,c,u,f,l=mt(t.operator);switch(t.operator){case tt.PUSH:var h=void 0;return h=B(t.operands)?{$each:t.operands.map(xt)}:t.operands,(e={})[l]=((n={})[t.fieldName]=h,n),e;case tt.UNSHIFT:return h={$each:t.operands.map(xt),$position:0},(r={})[l]=((o={})[t.fieldName]=h,o),r;case tt.POP:return(i={})[l]=((s={})[t.fieldName]=1,s),i;case tt.SHIFT:return(a={})[l]=((c={})[t.fieldName]=-1,c),a;default:return(u={})[l]=((f={})[t.fieldName]=xt(t.operands),f),u}},t.prototype.encodeUpdateObject=function(t){var e=Nt(t);for(var n in e)if(!/^\$/.test(n)){var r=e[n];if(ct(r))e[n]=r._setFieldName(n),Rt(e,this.encodeUpdateCommand(e[n]),n);else{e[n]=r=xt(r);var o=new at(tt.SET,[r],n);Rt(e,this.encodeUpdateCommand(o),n)}}return e},t}(),Ct={};function kt(t){if(!Un.wsClientClass)throw new Error("to use realtime you must import realtime module first");var e=t.config.env;return Ct[e]||(Ct[e]=new Un.wsClientClass({context:{appConfig:{docSizeLimit:1e3,realtimePingInterval:1e4,realtimePongWaitTimeout:5e3,request:new Un.reqClass(t.config)}}})),Ct[e]}for(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(){function t(t,e,n,r){var o=this;void 0===r&&(r={}),this.watch=function(t){return kt(o._db).watch(Ut(Ut({},t),{envId:o._db.config.env,collectionName:o._coll,query:JSON.stringify({_id:o.id})}))},this._db=t,this._coll=e,this.id=n,this.request=new Un.reqClass(this._db.config),this.projection=r}return t.prototype.create=function(t,e){e=e||it();var n={collectionName:this._coll,data:Et(t)};return this.id&&(n._id=this.id),this.request.send("database.addDocument",n).then((function(t){t.code?e(0,t):e(0,{id:t.data._id,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},t.prototype.set=function(t,e){if(e=e||it(),!this.id)return Promise.resolve({code:"INVALID_PARAM",message:"docId不能为空"});if(!t||"object"!=typeof t)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(t.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n=!1,r=function(t){if("object"==typeof t)for(var e in t)t[e]instanceof at?n=!0:"object"==typeof t[e]&&r(t[e])};if(r(t),n)return Promise.resolve({code:"DATABASE_REQUEST_FAILED",message:"update operator complicit"});var o={collectionName:this._coll,queryType:a.DOC,data:Et(t),multi:!1,merge:!1,upsert:!0};return this.id&&(o.query={_id:this.id}),this.request.send("database.updateDocument",o).then((function(t){t.code?e(0,t):e(0,{updated:t.data.updated,upsertedId:t.data.upserted_id,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},t.prototype.update=function(t,e){if(e=e||it(),!t||"object"!=typeof t)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(t.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n={_id:this.id},r={collectionName:this._coll,data:Lt.encode(t),query:n,queryType:a.DOC,multi:!1,merge:!0,upsert:!1};return this.request.send("database.updateDocument",r).then((function(t){t.code?e(0,t):e(0,{updated:t.data.updated,upsertedId:t.data.upserted_id,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},t.prototype.remove=function(t){t=t||it();var e={_id:this.id},n={collectionName:this._coll,query:e,queryType:a.DOC,multi:!1};return this.request.send("database.deleteDocument",n).then((function(e){e.code?t(0,e):t(0,{deleted:e.data.deleted,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},t.prototype.get=function(t){t=t||it();var e={_id:this.id},n={collectionName:this._coll,query:e,queryType:a.DOC,multi:!1,projection:this.projection};return this.request.send("database.queryDocument",n).then((function(e){if(e.code)t(0,e);else{var n=nt.formatResDocumentData(e.data.list);t(0,{data:n,requestId:e.requestId})}})).catch((function(e){t(e)})),t.promise},t.prototype.field=function(e){for(var n in e)e[n]?e[n]=1:e[n]=0;return new t(this._db,this._coll,this.id,e)},t}(),Dt=function(){function t(){}return t.encode=function(t){return(new Mt).encodeQuery(t)},t}(),Mt=function(){function t(){}return t.prototype.encodeQuery=function(t,e){var n;return Pt(t)?ft(t)?this.encodeLogicCommand(t):dt(t)?this.encodeQueryCommand(t):((n={})[e]=this.encodeQueryObject(t),n):M(t)?this.encodeQueryObject(t):t},t.prototype.encodeRegExp=function(t){return{$regex:t.source,$options:t.flags}},t.prototype.encodeLogicCommand=function(t){var e,n,r,o,i,s,a,c=this;switch(t.operator){case st.NOR:case st.AND:case st.OR:var u=mt(t.operator),f=t.operands.map((function(e){return c.encodeQuery(e,t.fieldName)}));return(e={})[u]=f,e;case st.NOT:u=mt(t.operator);var l=t.operands[0];return W(l)?((n={})[t.fieldName]=((r={})[u]=this.encodeRegExp(l),r),n):(f=this.encodeQuery(l)[t.fieldName],(o={})[t.fieldName]=((i={})[u]=f,i),o);default:if(u=mt(t.operator),1===t.operands.length){var h=this.encodeQuery(t.operands[0]);return(s={})[u]=h,s}return f=t.operands.map(this.encodeQuery.bind(this)),(a={})[u]=f,a}},t.prototype.encodeQueryCommand=function(t){return yt(t),this.encodeComparisonCommand(t)},t.prototype.encodeComparisonCommand=function(t){var e,n,r,o,i,s,a,c,u;if(t.fieldName===O)throw new Error("Cannot encode a comparison command with unset field name");var f=mt(t.operator);switch(t.operator){case lt.EQ:case lt.NEQ:case lt.LT:case lt.LTE:case lt.GT:case lt.GTE:case lt.ELEM_MATCH:case lt.EXISTS:case lt.SIZE:case lt.MOD:return(e={})[t.fieldName]=((n={})[f]=xt(t.operands[0]),n),e;case lt.IN:case lt.NIN:case lt.ALL:return(r={})[t.fieldName]=((o={})[f]=xt(t.operands),o),r;case lt.GEO_NEAR:var l=t.operands[0];return(i={})[t.fieldName]={$nearSphere:{$geometry:l.geometry.toJSON(),$maxDistance:l.maxDistance,$minDistance:l.minDistance}},i;case lt.GEO_WITHIN:return l=t.operands[0],(s={})[t.fieldName]={$geoWithin:{$geometry:l.geometry.toJSON()}},s;case lt.GEO_INTERSECTS:return l=t.operands[0],(a={})[t.fieldName]={$geoIntersects:{$geometry:l.geometry.toJSON()}},a;default:return(c={})[t.fieldName]=((u={})[f]=xt(t.operands[0]),u),c}},t.prototype.encodeQueryObject=function(t){var e=Nt(t);for(var n in e){var r=e[n];if(ft(r)){e[n]=r._setFieldName(n);var o=this.encodeLogicCommand(e[n]);this.mergeConditionAfterEncode(e,o,n)}else yt(r)?(e[n]=r._setFieldName(n),o=this.encodeComparisonCommand(e[n]),this.mergeConditionAfterEncode(e,o,n)):Pt(r)&&(e[n]=xt(r))}return e},t.prototype.mergeConditionAfterEncode=function(t,e,n){for(var r in e[n]||delete t[n],e)t[r]?B(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 "+D(e)+", can only overwrite",e,n),t[r]=e[r]):(console.warn("to-merge query is of type "+D(t)+", can only overwrite",t,e,n),t[r]=e[r]):t[r]=e[r]},t}(),qt=function(){return qt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},qt.apply(this,arguments)},Bt=function(){function t(t,e,n,r,o){var i=this;this.watch=function(t){return kt(i._db).watch(qt(qt({},t),{envId:i._db.config.env,collectionName:i._coll,query:JSON.stringify(i._fieldFilters||{}),limit:i._queryOptions.limit,orderBy:i._fieldOrders?i._fieldOrders.reduce((function(t,e){return t[e.field]=e.direction,t}),{}):void 0}))},this._db=t,this._coll=e,this._fieldFilters=n,this._fieldOrders=r||[],this._queryOptions=o||{},this._request=new Un.reqClass(this._db.config)}return t.prototype.get=function(t){t=t||it();var e=[];this._fieldOrders&&this._fieldOrders.forEach((function(t){e.push(t)}));var n={collectionName:this._coll,queryType:a.WHERE};return this._fieldFilters&&(n.query=this._fieldFilters),e.length>0&&(n.order=e),this._queryOptions.offset&&(n.offset=this._queryOptions.offset),this._queryOptions.limit?n.limit=this._queryOptions.limit<1e3?this._queryOptions.limit:1e3:n.limit=100,this._queryOptions.projection&&(n.projection=this._queryOptions.projection),this._request.send("database.queryDocument",n).then((function(e){if(e.code)t(0,e);else{var n={data:nt.formatResDocumentData(e.data.list),requestId:e.requestId};e.total&&(n.total=e.total),e.limit&&(n.limit=e.limit),e.offset&&(n.offset=e.offset),t(0,n)}})).catch((function(e){t(e)})),t.promise},t.prototype.count=function(t){t=t||it();var e={collectionName:this._coll,queryType:a.WHERE};return this._fieldFilters&&(e.query=this._fieldFilters),this._request.send("database.countDocument",e).then((function(e){e.code?t(0,e):t(0,{requestId:e.requestId,total:e.data.total})})).catch((function(e){t(e)})),t.promise},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,Dt.encode(e),this._fieldOrders,this._queryOptions)},t.prototype.orderBy=function(e,n){rt.isFieldPath(e),rt.isFieldOrder(n);var r={field:e,direction:n},o=this._fieldOrders.concat(r);return new t(this._db,this._coll,this._fieldFilters,o,this._queryOptions)},t.prototype.limit=function(e){rt.isInteger("limit",e);var n=qt({},this._queryOptions);return n.limit=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},t.prototype.skip=function(e){rt.isInteger("offset",e);var n=qt({},this._queryOptions);return n.offset=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},t.prototype.update=function(t,e){if(e=e||it(),!t||"object"!=typeof t)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(t.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n={collectionName:this._coll,query:this._fieldFilters,queryType:a.WHERE,multi:!0,merge:!0,upsert:!1,data:Lt.encode(t)};return this._request.send("database.updateDocument",n).then((function(t){t.code?e(0,t):e(0,{requestId:t.requestId,updated:t.data.updated,upsertId:t.data.upsert_id})})).catch((function(t){e(t)})),e.promise},t.prototype.field=function(e){for(var n in e)e[n]?"object"!=typeof e[n]&&(e[n]=1):e[n]=0;var r=qt({},this._queryOptions);return r.projection=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,r)},t.prototype.remove=function(t){t=t||it(),Object.keys(this._queryOptions).length>0&&console.warn("`offset`, `limit` and `projection` are not supported in remove() operation"),this._fieldOrders.length>0&&console.warn("`orderBy` is not supported in remove() operation");var e={collectionName:this._coll,query:Dt.encode(this._fieldFilters),queryType:a.WHERE,multi:!0};return this._request.send("database.deleteDocument",e).then((function(e){e.code?t(0,e):t(0,{requestId:e.requestId,deleted:e.data.deleted})})).catch((function(e){t(e)})),t.promise},t}(),Ft=[],Wt=[],$t="undefined"!=typeof Uint8Array?Uint8Array:Array,Ht="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Gt=0;Gt<64;++Gt)Ft[Gt]=Ht[Gt],Wt[Ht.charCodeAt(Gt)]=Gt;function Kt(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function Vt(t,e,n){for(var r,o,i=[],s=e;s<n;s+=3)r=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]),i.push(Ft[(o=r)>>18&63]+Ft[o>>12&63]+Ft[o>>6&63]+Ft[63&o]);return i.join("")}Wt["-".charCodeAt(0)]=62,Wt["_".charCodeAt(0)]=63;var Jt=function(t){var e,n,r=Kt(t),o=r[0],i=r[1],s=new $t(function(t,e,n){return 3*(e+n)/4-n}(0,o,i)),a=0,c=i>0?o-4:o;for(n=0;n<c;n+=4)e=Wt[t.charCodeAt(n)]<<18|Wt[t.charCodeAt(n+1)]<<12|Wt[t.charCodeAt(n+2)]<<6|Wt[t.charCodeAt(n+3)],s[a++]=e>>16&255,s[a++]=e>>8&255,s[a++]=255&e;return 2===i&&(e=Wt[t.charCodeAt(n)]<<2|Wt[t.charCodeAt(n+1)]>>4,s[a++]=255&e),1===i&&(e=Wt[t.charCodeAt(n)]<<10|Wt[t.charCodeAt(n+1)]<<4|Wt[t.charCodeAt(n+2)]>>2,s[a++]=e>>8&255,s[a++]=255&e),s},Yt=function(t){for(var e,n=t.length,r=n%3,o=[],i=16383,s=0,a=n-r;s<a;s+=i)o.push(Vt(t,s,s+i>a?a:s+i));return 1===r?(e=t[n-1],o.push(Ft[e>>2]+Ft[e<<4&63]+"==")):2===r&&(e=(t[n-2]<<8)+t[n-1],o.push(Ft[e>>10]+Ft[e>>4&63]+Ft[e<<2&63]+"=")),o.join("")},zt=function(t,e,n,r,o){var i,s,a=8*o-r-1,c=(1<<a)-1,u=c>>1,f=-7,l=n?o-1:0,h=n?-1:1,p=t[e+l];for(l+=h,i=p&(1<<-f)-1,p>>=-f,f+=a;f>0;i=256*i+t[e+l],l+=h,f-=8);for(s=i&(1<<-f)-1,i>>=-f,f+=r;f>0;s=256*s+t[e+l],l+=h,f-=8);if(0===i)i=1-u;else{if(i===c)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),i-=u}return(p?-1:1)*s*Math.pow(2,i-r)},Xt=function(t,e,n,r,o,i){var s,a,c,u=8*i-o-1,f=(1<<u)-1,l=f>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:i-1,d=r?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),(e+=s+l>=1?h/c:h*Math.pow(2,1-l))*c>=2&&(s++,c/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(e*c-1)*Math.pow(2,o),s+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,o),s=0));o>=8;t[n+p]=255&a,p+=d,a/=256,o-=8);for(s=s<<o|a,u+=o;u>0;t[n+p]=255&s,p+=d,s/=256,u-=8);t[n+p-d]|=128*y},Zt=function(t,e){return function(t,e){var n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=i,e.SlowBuffer=function(t){return+t!=t&&(t=0),i.alloc(+t)},e.INSPECT_MAX_BYTES=50;var r=2147483647;function o(t){if(t>r)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return Object.setPrototypeOf(e,i.prototype),e}function i(t,e,n){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return s(t,e,n)}function s(t,e,n){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!i.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var n=0|h(t,e),r=o(n),s=r.write(t,e);return s!==n&&(r=r.slice(0,s)),r}(t,e);if(ArrayBuffer.isView(t))return function(t){if(M(t,Uint8Array)){var e=new Uint8Array(t);return f(e.buffer,e.byteOffset,e.byteLength)}return u(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+babelHelpers.typeof(t));if(M(t,ArrayBuffer)||t&&M(t.buffer,ArrayBuffer))return f(t,e,n);if("undefined"!=typeof SharedArrayBuffer&&(M(t,SharedArrayBuffer)||t&&M(t.buffer,SharedArrayBuffer)))return f(t,e,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');var r=t.valueOf&&t.valueOf();if(null!=r&&r!==t)return i.from(r,e,n);var s=function(t){if(i.isBuffer(t)){var e=0|l(t.length),n=o(e);return 0===n.length||t.copy(n,0,0,e),n}return void 0!==t.length?"number"!=typeof t.length||q(t.length)?o(0):u(t):"Buffer"===t.type&&Array.isArray(t.data)?u(t.data):void 0}(t);if(s)return s;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return i.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+babelHelpers.typeof(t))}function a(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function c(t){return a(t),o(t<0?0:0|l(t))}function u(t){for(var e=t.length<0?0:0|l(t.length),n=o(e),r=0;r<e;r+=1)n[r]=255&t[r];return n}function f(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');var r;return r=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n),Object.setPrototypeOf(r,i.prototype),r}function l(t){if(t>=r)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r.toString(16)+" bytes");return 0|t}function h(t,e){if(i.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||M(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+babelHelpers.typeof(t));var n=t.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return U(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return j(t).length;default:if(o)return r?-1:U(t).length;e=(""+e).toLowerCase(),o=!0}}function p(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return T(this,e,n);case"utf8":case"utf-8":return S(this,e,n);case"ascii":return O(this,e,n);case"latin1":case"binary":return A(this,e,n);case"base64":return E(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function d(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function y(t,e,n,r,o){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),q(n=+n)&&(n=o?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(o)return-1;n=t.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof e&&(e=i.from(e,r)),i.isBuffer(e))return 0===e.length?-1:g(t,e,n,r,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):g(t,[e],n,r,o);throw new TypeError("val must be string, number or Buffer")}function g(t,e,n,r,o){var i,s=1,a=t.length,c=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;s=2,a/=2,c/=2,n/=2}function u(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){var f=-1;for(i=n;i<a;i++)if(u(t,i)===u(e,-1===f?0:i-f)){if(-1===f&&(f=i),i-f+1===c)return f*s}else-1!==f&&(i-=i-f),f=-1}else for(n+c>a&&(n=a-c),i=n;i>=0;i--){for(var l=!0,h=0;h<c;h++)if(u(t,i+h)!==u(e,h)){l=!1;break}if(l)return i}return-1}function v(t,e,n,r){n=Number(n)||0;var o=t.length-n;r?(r=Number(r))>o&&(r=o):r=o;var i=e.length;r>i/2&&(r=i/2);for(var s=0;s<r;++s){var a=parseInt(e.substr(2*s,2),16);if(q(a))return s;t[n+s]=a}return s}function m(t,e,n,r){return D(U(e,t.length-n),t,n,r)}function _(t,e,n,r){return D(function(t){for(var e=[],n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}function w(t,e,n,r){return D(j(e),t,n,r)}function b(t,e,n,r){return D(function(t,e){for(var n,r,o,i=[],s=0;s<t.length&&!((e-=2)<0);++s)r=(n=t.charCodeAt(s))>>8,o=n%256,i.push(o),i.push(r);return i}(e,t.length-n),t,n,r)}function E(t,e,n){return 0===e&&n===t.length?Yt(t):Yt(t.slice(e,n))}function S(t,e,n){n=Math.min(t.length,n);for(var r=[],o=e;o<n;){var i,s,a,c,u=t[o],f=null,l=u>239?4:u>223?3:u>191?2:1;if(o+l<=n)switch(l){case 1:u<128&&(f=u);break;case 2:128==(192&(i=t[o+1]))&&(c=(31&u)<<6|63&i)>127&&(f=c);break;case 3:i=t[o+1],s=t[o+2],128==(192&i)&&128==(192&s)&&(c=(15&u)<<12|(63&i)<<6|63&s)>2047&&(c<55296||c>57343)&&(f=c);break;case 4:i=t[o+1],s=t[o+2],a=t[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(c=(15&u)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(f=c)}null===f?(f=65533,l=1):f>65535&&(f-=65536,r.push(f>>>10&1023|55296),f=56320|1023&f),r.push(f),o+=l}return function(t){var e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);for(var n="",r=0;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=I));return n}(r)}e.kMaxLength=r,i.TYPED_ARRAY_SUPPORT=function(){try{var t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),i.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(i.prototype,"parent",{enumerable:!0,get:function(){if(i.isBuffer(this))return this.buffer}}),Object.defineProperty(i.prototype,"offset",{enumerable:!0,get:function(){if(i.isBuffer(this))return this.byteOffset}}),i.poolSize=8192,i.from=function(t,e,n){return s(t,e,n)},Object.setPrototypeOf(i.prototype,Uint8Array.prototype),Object.setPrototypeOf(i,Uint8Array),i.alloc=function(t,e,n){return function(t,e,n){return a(t),t<=0?o(t):void 0!==e?"string"==typeof n?o(t).fill(e,n):o(t).fill(e):o(t)}(t,e,n)},i.allocUnsafe=function(t){return c(t)},i.allocUnsafeSlow=function(t){return c(t)},i.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==i.prototype},i.compare=function(t,e){if(M(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),M(e,Uint8Array)&&(e=i.from(e,e.offset,e.byteLength)),!i.isBuffer(t)||!i.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var n=t.length,r=e.length,o=0,s=Math.min(n,r);o<s;++o)if(t[o]!==e[o]){n=t[o],r=e[o];break}return n<r?-1:r<n?1:0},i.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},i.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return i.alloc(0);var n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var r=i.allocUnsafe(e),o=0;for(n=0;n<t.length;++n){var s=t[n];if(M(s,Uint8Array))o+s.length>r.length?i.from(s).copy(r,o):Uint8Array.prototype.set.call(r,s,o);else{if(!i.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,o)}o+=s.length}return r},i.byteLength=h,i.prototype._isBuffer=!0,i.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)d(this,e,e+1);return this},i.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)d(this,e,e+3),d(this,e+1,e+2);return this},i.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)d(this,e,e+7),d(this,e+1,e+6),d(this,e+2,e+5),d(this,e+3,e+4);return this},i.prototype.toString=function(){var t=this.length;return 0===t?"":0===arguments.length?S(this,0,t):p.apply(this,arguments)},i.prototype.toLocaleString=i.prototype.toString,i.prototype.equals=function(t){if(!i.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===i.compare(this,t)},i.prototype.inspect=function(){var t="",n=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(t+=" ... "),"<Buffer "+t+">"},n&&(i.prototype[n]=i.prototype.inspect),i.prototype.compare=function(t,e,n,r,o){if(M(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),!i.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+babelHelpers.typeof(t));if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),e<0||n>t.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&e>=n)return 0;if(r>=o)return-1;if(e>=n)return 1;if(this===t)return 0;for(var s=(o>>>=0)-(r>>>=0),a=(n>>>=0)-(e>>>=0),c=Math.min(s,a),u=this.slice(r,o),f=t.slice(e,n),l=0;l<c;++l)if(u[l]!==f[l]){s=u[l],a=f[l];break}return s<a?-1:a<s?1:0},i.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},i.prototype.indexOf=function(t,e,n){return y(this,t,e,n,!0)},i.prototype.lastIndexOf=function(t,e,n){return y(this,t,e,n,!1)},i.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-e;if((void 0===n||n>o)&&(n=o),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return v(this,t,e,n);case"utf8":case"utf-8":return m(this,t,e,n);case"ascii":case"latin1":case"binary":return _(this,t,e,n);case"base64":return w(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return b(this,t,e,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var I=4096;function O(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;o<n;++o)r+=String.fromCharCode(127&t[o]);return r}function A(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;o<n;++o)r+=String.fromCharCode(t[o]);return r}function T(t,e,n){var r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);for(var o="",i=e;i<n;++i)o+=B[t[i]];return o}function N(t,e,n){for(var r=t.slice(e,n),o="",i=0;i<r.length-1;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}function R(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function P(t,e,n,r,o,s){if(!i.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<s)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function x(t,e,n,r,o,i){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function L(t,e,n,r,o){return e=+e,n>>>=0,o||x(t,0,n,4),Xt(t,e,n,r,23,4),n+4}function C(t,e,n,r,o){return e=+e,n>>>=0,o||x(t,0,n,8),Xt(t,e,n,r,52,8),n+8}i.prototype.slice=function(t,e){var n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t);var r=this.subarray(t,e);return Object.setPrototypeOf(r,i.prototype),r},i.prototype.readUintLE=i.prototype.readUIntLE=function(t,e,n){t>>>=0,e>>>=0,n||R(t,e,this.length);for(var r=this[t],o=1,i=0;++i<e&&(o*=256);)r+=this[t+i]*o;return r},i.prototype.readUintBE=i.prototype.readUIntBE=function(t,e,n){t>>>=0,e>>>=0,n||R(t,e,this.length);for(var r=this[t+--e],o=1;e>0&&(o*=256);)r+=this[t+--e]*o;return r},i.prototype.readUint8=i.prototype.readUInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),this[t]},i.prototype.readUint16LE=i.prototype.readUInt16LE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]|this[t+1]<<8},i.prototype.readUint16BE=i.prototype.readUInt16BE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]<<8|this[t+1]},i.prototype.readUint32LE=i.prototype.readUInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},i.prototype.readUint32BE=i.prototype.readUInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},i.prototype.readIntLE=function(t,e,n){t>>>=0,e>>>=0,n||R(t,e,this.length);for(var r=this[t],o=1,i=0;++i<e&&(o*=256);)r+=this[t+i]*o;return r>=(o*=128)&&(r-=Math.pow(2,8*e)),r},i.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||R(t,e,this.length);for(var r=e,o=1,i=this[t+--r];r>0&&(o*=256);)i+=this[t+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},i.prototype.readInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},i.prototype.readInt16LE=function(t,e){t>>>=0,e||R(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},i.prototype.readInt16BE=function(t,e){t>>>=0,e||R(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},i.prototype.readInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},i.prototype.readInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},i.prototype.readFloatLE=function(t,e){return t>>>=0,e||R(t,4,this.length),zt(this,t,!0,23,4)},i.prototype.readFloatBE=function(t,e){return t>>>=0,e||R(t,4,this.length),zt(this,t,!1,23,4)},i.prototype.readDoubleLE=function(t,e){return t>>>=0,e||R(t,8,this.length),zt(this,t,!0,52,8)},i.prototype.readDoubleBE=function(t,e){return t>>>=0,e||R(t,8,this.length),zt(this,t,!1,52,8)},i.prototype.writeUintLE=i.prototype.writeUIntLE=function(t,e,n,r){t=+t,e>>>=0,n>>>=0,r||P(this,t,e,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[e]=255&t;++i<n&&(o*=256);)this[e+i]=t/o&255;return e+n},i.prototype.writeUintBE=i.prototype.writeUIntBE=function(t,e,n,r){t=+t,e>>>=0,n>>>=0,r||P(this,t,e,n,Math.pow(2,8*n)-1,0);var o=n-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+n},i.prototype.writeUint8=i.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||P(this,t,e,1,255,0),this[e]=255&t,e+1},i.prototype.writeUint16LE=i.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||P(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeUint16BE=i.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||P(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeUint32LE=i.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||P(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},i.prototype.writeUint32BE=i.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||P(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},i.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e>>>=0,!r){var o=Math.pow(2,8*n-1);P(this,t,e,n,o-1,-o)}var i=0,s=1,a=0;for(this[e]=255&t;++i<n&&(s*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/s|0)-a&255;return e+n},i.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e>>>=0,!r){var o=Math.pow(2,8*n-1);P(this,t,e,n,o-1,-o)}var i=n-1,s=1,a=0;for(this[e+i]=255&t;--i>=0&&(s*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/s|0)-a&255;return e+n},i.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||P(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},i.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||P(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||P(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||P(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},i.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||P(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},i.prototype.writeFloatLE=function(t,e,n){return L(this,t,e,!0,n)},i.prototype.writeFloatBE=function(t,e,n){return L(this,t,e,!1,n)},i.prototype.writeDoubleLE=function(t,e,n){return C(this,t,e,!0,n)},i.prototype.writeDoubleBE=function(t,e,n){return C(this,t,e,!1,n)},i.prototype.copy=function(t,e,n,r){if(!i.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);var o=r-n;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,n,r):Uint8Array.prototype.set.call(t,this.subarray(n,r),e),o},i.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!i.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===t.length){var o=t.charCodeAt(0);("utf8"===r&&o<128||"latin1"===r)&&(t=o)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;var s;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(s=e;s<n;++s)this[s]=t;else{var a=i.isBuffer(t)?t:i.from(t,r),c=a.length;if(0===c)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(s=0;s<n-e;++s)this[s+e]=a[s%c]}return this};var k=/[^+/0-9A-Za-z-_]/g;function U(t,e){var n;e=e||1/0;for(var r=t.length,o=null,i=[],s=0;s<r;++s){if((n=t.charCodeAt(s))>55295&&n<57344){if(!o){if(n>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(e-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(e-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((e-=1)<0)break;i.push(n)}else if(n<2048){if((e-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function j(t){return Jt(function(t){if((t=(t=t.split("=")[0]).trim().replace(k,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function D(t,e,n,r){for(var o=0;o<r&&!(o+n>=e.length||o>=t.length);++o)e[o+n]=t[o];return o}function M(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function q(t){return t!=t}var B=function(){for(var t="0123456789abcdef",e=new Array(256),n=0;n<16;++n)for(var r=16*n,o=0;o<16;++o)e[r+o]=t[n]+t[o];return e}()}(e={exports:{}},e.exports),e.exports}(),Qt=Zt.Buffer;Zt.SlowBuffer,Zt.INSPECT_MAX_BYTES,Zt.kMaxLength;var te=function(t,e){return te=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},te(t,e)};function ee(t,e){function n(){this.constructor=t}te(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var ne=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r}return ee(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return"BSONError"},enumerable:!1,configurable:!0}),e}(Error),re=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r}return ee(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return"BSONTypeError"},enumerable:!1,configurable:!0}),e}(TypeError);function oe(t){return t&&t.Math==Math&&t}function ie(){return oe("object"==typeof globalThis&&globalThis)||oe("object"==typeof window&&window)||oe("object"==typeof self&&self)||oe("object"==typeof n.g&&n.g)||Function("return this")()}var se=function(t){var e,n="object"==typeof(e=ie()).navigator&&"ReactNative"===e.navigator.product?"BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.":"BSON: No cryptographic implementation for random bytes present, falling back to a less secure implementation.";console.warn(n);for(var r=Qt.alloc(t),o=0;o<t;++o)r[o]=Math.floor(256*Math.random());return r},ae=function(){if("undefined"!=typeof window){var t=window.crypto||window.msCrypto;if(t&&t.getRandomValues)return function(e){return t.getRandomValues(Qt.alloc(e))}}return void 0!==n.g&&n.g.crypto&&n.g.crypto.getRandomValues?function(t){return n.g.crypto.getRandomValues(Qt.alloc(t))}:se}();function ce(t){return"[object Uint8Array]"===Object.prototype.toString.call(t)}function ue(t){return"object"==typeof t&&null!==t}function fe(t,e){var n=!1;return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];return n||(console.warn(e),n=!0),t.apply(this,r)}}function le(t){if(ArrayBuffer.isView(t))return Qt.from(t.buffer,t.byteOffset,t.byteLength);if(e=t,["[object ArrayBuffer]","[object SharedArrayBuffer]"].includes(Object.prototype.toString.call(e)))return Qt.from(t);var e;throw new re("Must use either Buffer or TypedArray")}var he=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|[0-9a-f]{12}4[0-9a-f]{3}[89ab][0-9a-f]{15})$/i,pe=function(t){return"string"==typeof t&&he.test(t)},de=function(t){if(!pe(t))throw new re('UUID string representations must be a 32 or 36 character hex string (dashes excluded/included). Format: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" or "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".');var e=t.replace(/-/g,"");return Qt.from(e,"hex")},ye=function(t,e){return void 0===e&&(e=!0),e?t.toString("hex",0,4)+"-"+t.toString("hex",4,6)+"-"+t.toString("hex",6,8)+"-"+t.toString("hex",8,10)+"-"+t.toString("hex",10,16):t.toString("hex")},ge=(Math.pow(2,63),Math.pow(2,63),Math.pow(2,53)),ve=-Math.pow(2,53),me=function(){function t(e,n){if(!(this instanceof t))return new t(e,n);if(!(null==e||"string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||Array.isArray(e)))throw new re("Binary can only be constructed from string, Buffer, TypedArray, or Array<number>");this.sub_type=null!=n?n:t.BSON_BINARY_SUBTYPE_DEFAULT,null==e?(this.buffer=Qt.alloc(t.BUFFER_SIZE),this.position=0):("string"==typeof e?this.buffer=Qt.from(e,"binary"):Array.isArray(e)?this.buffer=Qt.from(e):this.buffer=le(e),this.position=this.buffer.byteLength)}return t.prototype.put=function(e){if("string"==typeof e&&1!==e.length)throw new re("only accepts single character String");if("number"!=typeof e&&1!==e.length)throw new re("only accepts single character Uint8Array or Array");var n;if((n="string"==typeof e?e.charCodeAt(0):"number"==typeof e?e:e[0])<0||n>255)throw new re("only accepts number in a valid unsigned byte range 0-255");if(this.buffer.length>this.position)this.buffer[this.position++]=n;else{var r=Qt.alloc(t.BUFFER_SIZE+this.buffer.length);this.buffer.copy(r,0,0,this.buffer.length),this.buffer=r,this.buffer[this.position++]=n}},t.prototype.write=function(t,e){if(e="number"==typeof e?e:this.position,this.buffer.length<e+t.length){var n=Qt.alloc(this.buffer.length+t.length);this.buffer.copy(n,0,0,this.buffer.length),this.buffer=n}ArrayBuffer.isView(t)?(this.buffer.set(le(t),e),this.position=e+t.byteLength>this.position?e+t.length:this.position):"string"==typeof t&&(this.buffer.write(t,e,t.length,"binary"),this.position=e+t.length>this.position?e+t.length:this.position)},t.prototype.read=function(t,e){return e=e&&e>0?e:this.position,this.buffer.slice(t,t+e)},t.prototype.value=function(t){return(t=!!t)&&this.buffer.length===this.position?this.buffer:t?this.buffer.slice(0,this.position):this.buffer.toString("binary",0,this.position)},t.prototype.length=function(){return this.position},t.prototype.toJSON=function(){return this.buffer.toString("base64")},t.prototype.toString=function(t){return this.buffer.toString(t)},t.prototype.toExtendedJSON=function(t){t=t||{};var e=this.buffer.toString("base64"),n=Number(this.sub_type).toString(16);return t.legacy?{$binary:e,$type:1===n.length?"0"+n:n}:{$binary:{base64:e,subType:1===n.length?"0"+n:n}}},t.prototype.toUUID=function(){if(this.sub_type===t.SUBTYPE_UUID)return new _e(this.buffer.slice(0,this.position));throw new ne('Binary sub_type "'.concat(this.sub_type,'" is not supported for converting to UUID. Only "').concat(t.SUBTYPE_UUID,'" is currently supported.'))},t.fromExtendedJSON=function(e,n){var r,o;if(n=n||{},"$binary"in e?n.legacy&&"string"==typeof e.$binary&&"$type"in e?(o=e.$type?parseInt(e.$type,16):0,r=Qt.from(e.$binary,"base64")):"string"!=typeof e.$binary&&(o=e.$binary.subType?parseInt(e.$binary.subType,16):0,r=Qt.from(e.$binary.base64,"base64")):"$uuid"in e&&(o=4,r=de(e.$uuid)),!r)throw new re("Unexpected Binary Extended JSON format ".concat(JSON.stringify(e)));return 4===o?new _e(r):new t(r,o)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){var t=this.value(!0);return'new Binary(Buffer.from("'.concat(t.toString("hex"),'", "hex"), ').concat(this.sub_type,")")},t.BSON_BINARY_SUBTYPE_DEFAULT=0,t.BUFFER_SIZE=256,t.SUBTYPE_DEFAULT=0,t.SUBTYPE_FUNCTION=1,t.SUBTYPE_BYTE_ARRAY=2,t.SUBTYPE_UUID_OLD=3,t.SUBTYPE_UUID=4,t.SUBTYPE_MD5=5,t.SUBTYPE_ENCRYPTED=6,t.SUBTYPE_COLUMN=7,t.SUBTYPE_USER_DEFINED=128,t}();Object.defineProperty(me.prototype,"_bsontype",{value:"Binary"});var _e=function(t){function e(n){var r,o,i=this;if(null==n)r=e.generate();else if(n instanceof e)r=Qt.from(n.buffer),o=n.__id;else if(ArrayBuffer.isView(n)&&16===n.byteLength)r=le(n);else{if("string"!=typeof n)throw new re("Argument passed in UUID constructor must be a UUID, a 16 byte Buffer or a 32/36 character hex string (dashes excluded/included, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).");r=de(n)}return(i=t.call(this,r,4)||this).__id=o,i}return ee(e,t),Object.defineProperty(e.prototype,"id",{get:function(){return this.buffer},set:function(t){this.buffer=t,e.cacheHexString&&(this.__id=ye(t))},enumerable:!1,configurable:!0}),e.prototype.toHexString=function(t){if(void 0===t&&(t=!0),e.cacheHexString&&this.__id)return this.__id;var n=ye(this.id,t);return e.cacheHexString&&(this.__id=n),n},e.prototype.toString=function(t){return t?this.id.toString(t):this.toHexString()},e.prototype.toJSON=function(){return this.toHexString()},e.prototype.equals=function(t){if(!t)return!1;if(t instanceof e)return t.id.equals(this.id);try{return new e(t).id.equals(this.id)}catch(t){return!1}},e.prototype.toBinary=function(){return new me(this.id,me.SUBTYPE_UUID)},e.generate=function(){var t=ae(16);return t[6]=15&t[6]|64,t[8]=63&t[8]|128,Qt.from(t)},e.isValid=function(t){return!!t&&(t instanceof e||("string"==typeof t?pe(t):!(!ce(t)||16!==t.length||64!=(240&t[6])||128&~t[8])))},e.createFromHexString=function(t){return new e(de(t))},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return'new UUID("'.concat(this.toHexString(),'")')},e}(me),we=function(){function t(e,n){if(!(this instanceof t))return new t(e,n);this.code=e,this.scope=n}return t.prototype.toJSON=function(){return{code:this.code,scope:this.scope}},t.prototype.toExtendedJSON=function(){return this.scope?{$code:this.code,$scope:this.scope}:{$code:this.code}},t.fromExtendedJSON=function(e){return new t(e.$code,e.$scope)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){var t=this.toJSON();return'new Code("'.concat(String(t.code),'"').concat(t.scope?", ".concat(JSON.stringify(t.scope)):"",")")},t}();Object.defineProperty(we.prototype,"_bsontype",{value:"Code"});var be=function(){function t(e,n,r,o){if(!(this instanceof t))return new t(e,n,r,o);var i=e.split(".");2===i.length&&(r=i.shift(),e=i.shift()),this.collection=e,this.oid=n,this.db=r,this.fields=o||{}}return Object.defineProperty(t.prototype,"namespace",{get:function(){return this.collection},set:function(t){this.collection=t},enumerable:!1,configurable:!0}),t.prototype.toJSON=function(){var t=Object.assign({$ref:this.collection,$id:this.oid},this.fields);return null!=this.db&&(t.$db=this.db),t},t.prototype.toExtendedJSON=function(t){t=t||{};var e={$ref:this.collection,$id:this.oid};return t.legacy?e:(this.db&&(e.$db=this.db),e=Object.assign(e,this.fields))},t.fromExtendedJSON=function(e){var n=Object.assign({},e);return delete n.$ref,delete n.$id,delete n.$db,new t(e.$ref,e.$id,e.$db,n)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){var t=void 0===this.oid||void 0===this.oid.toString?this.oid:this.oid.toString();return'new DBRef("'.concat(this.namespace,'", new ObjectId("').concat(String(t),'")').concat(this.db?', "'.concat(this.db,'"'):"",")")},t}();Object.defineProperty(be.prototype,"_bsontype",{value:"DBRef"});var Ee=void 0;try{Ee=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(r){}var Se=4294967296,Ie=0x10000000000000000,Oe=Ie/2,Ae={},Te={},Ne=function(){function t(e,n,r){if(void 0===e&&(e=0),!(this instanceof t))return new t(e,n,r);"bigint"==typeof e?Object.assign(this,t.fromBigInt(e,!!n)):"string"==typeof e?Object.assign(this,t.fromString(e,!!n)):(this.low=0|e,this.high=0|n,this.unsigned=!!r),Object.defineProperty(this,"__isLong__",{value:!0,configurable:!1,writable:!1,enumerable:!1})}return t.fromBits=function(e,n,r){return new t(e,n,r)},t.fromInt=function(e,n){var r,o,i;return n?(i=0<=(e>>>=0)&&e<256)&&(o=Te[e])?o:(r=t.fromBits(e,(0|e)<0?-1:0,!0),i&&(Te[e]=r),r):(i=-128<=(e|=0)&&e<128)&&(o=Ae[e])?o:(r=t.fromBits(e,e<0?-1:0,!1),i&&(Ae[e]=r),r)},t.fromNumber=function(e,n){if(isNaN(e))return n?t.UZERO:t.ZERO;if(n){if(e<0)return t.UZERO;if(e>=Ie)return t.MAX_UNSIGNED_VALUE}else{if(e<=-Oe)return t.MIN_VALUE;if(e+1>=Oe)return t.MAX_VALUE}return e<0?t.fromNumber(-e,n).neg():t.fromBits(e%Se|0,e/Se|0,n)},t.fromBigInt=function(e,n){return t.fromString(e.toString(),n)},t.fromString=function(e,n,r){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t.ZERO;if("number"==typeof n?(r=n,n=!1):n=!!n,(r=r||10)<2||36<r)throw RangeError("radix");var o;if((o=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===o)return t.fromString(e.substring(1),n,r).neg();for(var i=t.fromNumber(Math.pow(r,8)),s=t.ZERO,a=0;a<e.length;a+=8){var c=Math.min(8,e.length-a),u=parseInt(e.substring(a,a+c),r);if(c<8){var f=t.fromNumber(Math.pow(r,c));s=s.mul(f).add(t.fromNumber(u))}else s=(s=s.mul(i)).add(t.fromNumber(u))}return s.unsigned=n,s},t.fromBytes=function(e,n,r){return r?t.fromBytesLE(e,n):t.fromBytesBE(e,n)},t.fromBytesLE=function(e,n){return new t(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,n)},t.fromBytesBE=function(e,n){return new t(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],n)},t.isLong=function(t){return ue(t)&&!0===t.__isLong__},t.fromValue=function(e,n){return"number"==typeof e?t.fromNumber(e,n):"string"==typeof e?t.fromString(e,n):t.fromBits(e.low,e.high,"boolean"==typeof n?n:e.unsigned)},t.prototype.add=function(e){t.isLong(e)||(e=t.fromValue(e));var n=this.high>>>16,r=65535&this.high,o=this.low>>>16,i=65535&this.low,s=e.high>>>16,a=65535&e.high,c=e.low>>>16,u=0,f=0,l=0,h=0;return l+=(h+=i+(65535&e.low))>>>16,h&=65535,f+=(l+=o+c)>>>16,l&=65535,u+=(f+=r+a)>>>16,f&=65535,u+=n+s,u&=65535,t.fromBits(l<<16|h,u<<16|f,this.unsigned)},t.prototype.and=function(e){return t.isLong(e)||(e=t.fromValue(e)),t.fromBits(this.low&e.low,this.high&e.high,this.unsigned)},t.prototype.compare=function(e){if(t.isLong(e)||(e=t.fromValue(e)),this.eq(e))return 0;var n=this.isNegative(),r=e.isNegative();return n&&!r?-1:!n&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},t.prototype.comp=function(t){return this.compare(t)},t.prototype.divide=function(e){if(t.isLong(e)||(e=t.fromValue(e)),e.isZero())throw Error("division by zero");if(Ee){if(!this.unsigned&&-2147483648===this.high&&-1===e.low&&-1===e.high)return this;var n=(this.unsigned?Ee.div_u:Ee.div_s)(this.low,this.high,e.low,e.high);return t.fromBits(n,Ee.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?t.UZERO:t.ZERO;var r,o,i;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return t.UZERO;if(e.gt(this.shru(1)))return t.UONE;i=t.UZERO}else{if(this.eq(t.MIN_VALUE))return e.eq(t.ONE)||e.eq(t.NEG_ONE)?t.MIN_VALUE:e.eq(t.MIN_VALUE)?t.ONE:(r=this.shr(1).div(e).shl(1)).eq(t.ZERO)?e.isNegative()?t.ONE:t.NEG_ONE:(o=this.sub(e.mul(r)),i=r.add(o.div(e)));if(e.eq(t.MIN_VALUE))return this.unsigned?t.UZERO:t.ZERO;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();i=t.ZERO}for(o=this;o.gte(e);){r=Math.max(1,Math.floor(o.toNumber()/e.toNumber()));for(var s=Math.ceil(Math.log(r)/Math.LN2),a=s<=48?1:Math.pow(2,s-48),c=t.fromNumber(r),u=c.mul(e);u.isNegative()||u.gt(o);)r-=a,u=(c=t.fromNumber(r,this.unsigned)).mul(e);c.isZero()&&(c=t.ONE),i=i.add(c),o=o.sub(u)}return i},t.prototype.div=function(t){return this.divide(t)},t.prototype.equals=function(e){return t.isLong(e)||(e=t.fromValue(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&this.high===e.high&&this.low===e.low},t.prototype.eq=function(t){return this.equals(t)},t.prototype.getHighBits=function(){return this.high},t.prototype.getHighBitsUnsigned=function(){return this.high>>>0},t.prototype.getLowBits=function(){return this.low},t.prototype.getLowBitsUnsigned=function(){return this.low>>>0},t.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.eq(t.MIN_VALUE)?64:this.neg().getNumBitsAbs();var e,n=0!==this.high?this.high:this.low;for(e=31;e>0&&!(n&1<<e);e--);return 0!==this.high?e+33:e+1},t.prototype.greaterThan=function(t){return this.comp(t)>0},t.prototype.gt=function(t){return this.greaterThan(t)},t.prototype.greaterThanOrEqual=function(t){return this.comp(t)>=0},t.prototype.gte=function(t){return this.greaterThanOrEqual(t)},t.prototype.ge=function(t){return this.greaterThanOrEqual(t)},t.prototype.isEven=function(){return!(1&this.low)},t.prototype.isNegative=function(){return!this.unsigned&&this.high<0},t.prototype.isOdd=function(){return!(1&~this.low)},t.prototype.isPositive=function(){return this.unsigned||this.high>=0},t.prototype.isZero=function(){return 0===this.high&&0===this.low},t.prototype.lessThan=function(t){return this.comp(t)<0},t.prototype.lt=function(t){return this.lessThan(t)},t.prototype.lessThanOrEqual=function(t){return this.comp(t)<=0},t.prototype.lte=function(t){return this.lessThanOrEqual(t)},t.prototype.modulo=function(e){if(t.isLong(e)||(e=t.fromValue(e)),Ee){var n=(this.unsigned?Ee.rem_u:Ee.rem_s)(this.low,this.high,e.low,e.high);return t.fromBits(n,Ee.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))},t.prototype.mod=function(t){return this.modulo(t)},t.prototype.rem=function(t){return this.modulo(t)},t.prototype.multiply=function(e){if(this.isZero())return t.ZERO;if(t.isLong(e)||(e=t.fromValue(e)),Ee){var n=Ee.mul(this.low,this.high,e.low,e.high);return t.fromBits(n,Ee.get_high(),this.unsigned)}if(e.isZero())return t.ZERO;if(this.eq(t.MIN_VALUE))return e.isOdd()?t.MIN_VALUE:t.ZERO;if(e.eq(t.MIN_VALUE))return this.isOdd()?t.MIN_VALUE:t.ZERO;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(t.TWO_PWR_24)&&e.lt(t.TWO_PWR_24))return t.fromNumber(this.toNumber()*e.toNumber(),this.unsigned);var r=this.high>>>16,o=65535&this.high,i=this.low>>>16,s=65535&this.low,a=e.high>>>16,c=65535&e.high,u=e.low>>>16,f=65535&e.low,l=0,h=0,p=0,d=0;return p+=(d+=s*f)>>>16,d&=65535,h+=(p+=i*f)>>>16,p&=65535,h+=(p+=s*u)>>>16,p&=65535,l+=(h+=o*f)>>>16,h&=65535,l+=(h+=i*u)>>>16,h&=65535,l+=(h+=s*c)>>>16,h&=65535,l+=r*f+o*u+i*c+s*a,l&=65535,t.fromBits(p<<16|d,l<<16|h,this.unsigned)},t.prototype.mul=function(t){return this.multiply(t)},t.prototype.negate=function(){return!this.unsigned&&this.eq(t.MIN_VALUE)?t.MIN_VALUE:this.not().add(t.ONE)},t.prototype.neg=function(){return this.negate()},t.prototype.not=function(){return t.fromBits(~this.low,~this.high,this.unsigned)},t.prototype.notEquals=function(t){return!this.equals(t)},t.prototype.neq=function(t){return this.notEquals(t)},t.prototype.ne=function(t){return this.notEquals(t)},t.prototype.or=function(e){return t.isLong(e)||(e=t.fromValue(e)),t.fromBits(this.low|e.low,this.high|e.high,this.unsigned)},t.prototype.shiftLeft=function(e){return t.isLong(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?t.fromBits(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):t.fromBits(0,this.low<<e-32,this.unsigned)},t.prototype.shl=function(t){return this.shiftLeft(t)},t.prototype.shiftRight=function(e){return t.isLong(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?t.fromBits(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):t.fromBits(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},t.prototype.shr=function(t){return this.shiftRight(t)},t.prototype.shiftRightUnsigned=function(e){if(t.isLong(e)&&(e=e.toInt()),0==(e&=63))return this;var n=this.high;if(e<32){var r=this.low;return t.fromBits(r>>>e|n<<32-e,n>>>e,this.unsigned)}return 32===e?t.fromBits(n,0,this.unsigned):t.fromBits(n>>>e-32,0,this.unsigned)},t.prototype.shr_u=function(t){return this.shiftRightUnsigned(t)},t.prototype.shru=function(t){return this.shiftRightUnsigned(t)},t.prototype.subtract=function(e){return t.isLong(e)||(e=t.fromValue(e)),this.add(e.neg())},t.prototype.sub=function(t){return this.subtract(t)},t.prototype.toInt=function(){return this.unsigned?this.low>>>0:this.low},t.prototype.toNumber=function(){return this.unsigned?(this.high>>>0)*Se+(this.low>>>0):this.high*Se+(this.low>>>0)},t.prototype.toBigInt=function(){return BigInt(this.toString())},t.prototype.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()},t.prototype.toBytesLE=function(){var t=this.high,e=this.low;return[255&e,e>>>8&255,e>>>16&255,e>>>24,255&t,t>>>8&255,t>>>16&255,t>>>24]},t.prototype.toBytesBE=function(){var t=this.high,e=this.low;return[t>>>24,t>>>16&255,t>>>8&255,255&t,e>>>24,e>>>16&255,e>>>8&255,255&e]},t.prototype.toSigned=function(){return this.unsigned?t.fromBits(this.low,this.high,!1):this},t.prototype.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(t.MIN_VALUE)){var n=t.fromNumber(e),r=this.div(n),o=r.mul(n).sub(this);return r.toString(e)+o.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var i=t.fromNumber(Math.pow(e,6),this.unsigned),s=this,a="";;){var c=s.div(i),u=(s.sub(c.mul(i)).toInt()>>>0).toString(e);if((s=c).isZero())return u+a;for(;u.length<6;)u="0"+u;a=""+u+a}},t.prototype.toUnsigned=function(){return this.unsigned?this:t.fromBits(this.low,this.high,!0)},t.prototype.xor=function(e){return t.isLong(e)||(e=t.fromValue(e)),t.fromBits(this.low^e.low,this.high^e.high,this.unsigned)},t.prototype.eqz=function(){return this.isZero()},t.prototype.le=function(t){return this.lessThanOrEqual(t)},t.prototype.toExtendedJSON=function(t){return t&&t.relaxed?this.toNumber():{$numberLong:this.toString()}},t.fromExtendedJSON=function(e,n){var r=t.fromString(e.$numberLong);return n&&n.relaxed?r.toNumber():r},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return'new Long("'.concat(this.toString(),'"').concat(this.unsigned?", true":"",")")},t.TWO_PWR_24=t.fromInt(16777216),t.MAX_UNSIGNED_VALUE=t.fromBits(-1,-1,!0),t.ZERO=t.fromInt(0),t.UZERO=t.fromInt(0,!0),t.ONE=t.fromInt(1),t.UONE=t.fromInt(1,!0),t.NEG_ONE=t.fromInt(-1),t.MAX_VALUE=t.fromBits(-1,2147483647,!1),t.MIN_VALUE=t.fromBits(0,-2147483648,!1),t}();Object.defineProperty(Ne.prototype,"__isLong__",{value:!0}),Object.defineProperty(Ne.prototype,"_bsontype",{value:"Long"});var Re=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,Pe=/^(\+|-)?(Infinity|inf)$/i,xe=/^(\+|-)?NaN$/i,Le=6111,Ce=-6176,ke=[124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),Ue=[248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),je=[120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),De=/^([-+])?(\d+)?$/;function Me(t){return!isNaN(parseInt(t,10))}function qe(t){var e=Ne.fromNumber(1e9),n=Ne.fromNumber(0);if(!(t.parts[0]||t.parts[1]||t.parts[2]||t.parts[3]))return{quotient:t,rem:n};for(var r=0;r<=3;r++)n=(n=n.shiftLeft(32)).add(new Ne(t.parts[r],0)),t.parts[r]=n.div(e).low,n=n.modulo(e);return{quotient:t,rem:n}}function Be(t,e){throw new re('"'.concat(t,'" is not a valid Decimal128 string - ').concat(e))}var Fe=function(){function t(e){if(!(this instanceof t))return new t(e);if("string"==typeof e)this.bytes=t.fromString(e).bytes;else{if(!ce(e))throw new re("Decimal128 must take a Buffer or string");if(16!==e.byteLength)throw new re("Decimal128 must take a Buffer of 16 bytes");this.bytes=e}}return t.fromString=function(e){var n,r=!1,o=!1,i=!1,s=0,a=0,c=0,u=0,f=0,l=[0],h=0,p=0,d=0,y=0,g=0,v=0,m=new Ne(0,0),_=new Ne(0,0),w=0;if(e.length>=7e3)throw new re(e+" not a valid Decimal128 string");var b=e.match(Re),E=e.match(Pe),S=e.match(xe);if(!b&&!E&&!S||0===e.length)throw new re(e+" not a valid Decimal128 string");if(b){var I=b[2],O=b[4],A=b[5],T=b[6];O&&void 0===T&&Be(e,"missing exponent power"),O&&void 0===I&&Be(e,"missing exponent base"),void 0===O&&(A||T)&&Be(e,"missing e before exponent")}if("+"!==e[w]&&"-"!==e[w]||(r="-"===e[w++]),!Me(e[w])&&"."!==e[w]){if("i"===e[w]||"I"===e[w])return new t(Qt.from(r?Ue:je));if("N"===e[w])return new t(Qt.from(ke))}for(;Me(e[w])||"."===e[w];)"."!==e[w]?(h<34&&("0"!==e[w]||i)&&(i||(f=a),i=!0,l[p++]=parseInt(e[w],10),h+=1),i&&(c+=1),o&&(u+=1),a+=1,w+=1):(o&&Be(e,"contains multiple periods"),o=!0,w+=1);if(o&&!a)throw new re(e+" not a valid Decimal128 string");if("e"===e[w]||"E"===e[w]){var N=e.substr(++w).match(De);if(!N||!N[2])return new t(Qt.from(ke));g=parseInt(N[0],10),w+=N[0].length}if(e[w])return new t(Qt.from(ke));if(d=0,h){if(y=h-1,1!==(s=c))for(;0===l[f+s-1];)s-=1}else d=0,y=0,l[0]=0,c=1,h=1,s=0;for(g<=u&&u-g>16384?g=Ce:g-=u;g>Le;){if((y+=1)-d>34){if(l.join("").match(/^0+$/)){g=Le;break}Be(e,"overflow")}g-=1}for(;g<Ce||h<c;){if(0===y&&s<h){g=Ce,s=0;break}if(h<c?c-=1:y-=1,g<Le)g+=1;else{if(l.join("").match(/^0+$/)){g=Le;break}Be(e,"overflow")}}if(y-d+1<s){var R=a;o&&(f+=1,R+=1),r&&(f+=1,R+=1);var P=parseInt(e[f+y+1],10),x=0;if(P>=5&&(x=1,5===P))for(x=l[y]%2==1?1:0,v=f+y+2;v<R;v++)if(parseInt(e[v],10)){x=1;break}if(x)for(var L=y;L>=0;L--)if(++l[L]>9&&(l[L]=0,0===L)){if(!(g<Le))return new t(Qt.from(r?Ue:je));g+=1,l[L]=1}}if(m=Ne.fromNumber(0),_=Ne.fromNumber(0),0===s)m=Ne.fromNumber(0),_=Ne.fromNumber(0);else if(y-d<17)for(L=d,_=Ne.fromNumber(l[L++]),m=new Ne(0,0);L<=y;L++)_=(_=_.multiply(Ne.fromNumber(10))).add(Ne.fromNumber(l[L]));else{for(L=d,m=Ne.fromNumber(l[L++]);L<=y-17;L++)m=(m=m.multiply(Ne.fromNumber(10))).add(Ne.fromNumber(l[L]));for(_=Ne.fromNumber(l[L++]);L<=y;L++)_=(_=_.multiply(Ne.fromNumber(10))).add(Ne.fromNumber(l[L]))}var C,k,U,j,D=function(t,e){if(!t&&!e)return{high:Ne.fromNumber(0),low:Ne.fromNumber(0)};var n=t.shiftRightUnsigned(32),r=new Ne(t.getLowBits(),0),o=e.shiftRightUnsigned(32),i=new Ne(e.getLowBits(),0),s=n.multiply(o),a=n.multiply(i),c=r.multiply(o),u=r.multiply(i);return s=s.add(a.shiftRightUnsigned(32)),a=new Ne(a.getLowBits(),0).add(c).add(u.shiftRightUnsigned(32)),{high:s=s.add(a.shiftRightUnsigned(32)),low:u=a.shiftLeft(32).add(new Ne(u.getLowBits(),0))}}(m,Ne.fromString("100000000000000000"));D.low=D.low.add(_),k=_,((U=(C=D.low).high>>>0)<(j=k.high>>>0)||U===j&&C.low>>>0<k.low>>>0)&&(D.high=D.high.add(Ne.fromNumber(1))),n=g+6176;var M={low:Ne.fromNumber(0),high:Ne.fromNumber(0)};D.high.shiftRightUnsigned(49).and(Ne.fromNumber(1)).equals(Ne.fromNumber(1))?(M.high=M.high.or(Ne.fromNumber(3).shiftLeft(61)),M.high=M.high.or(Ne.fromNumber(n).and(Ne.fromNumber(16383).shiftLeft(47))),M.high=M.high.or(D.high.and(Ne.fromNumber(0x7fffffffffff)))):(M.high=M.high.or(Ne.fromNumber(16383&n).shiftLeft(49)),M.high=M.high.or(D.high.and(Ne.fromNumber(562949953421311)))),M.low=D.low,r&&(M.high=M.high.or(Ne.fromString("9223372036854775808")));var q=Qt.alloc(16);return w=0,q[w++]=255&M.low.low,q[w++]=M.low.low>>8&255,q[w++]=M.low.low>>16&255,q[w++]=M.low.low>>24&255,q[w++]=255&M.low.high,q[w++]=M.low.high>>8&255,q[w++]=M.low.high>>16&255,q[w++]=M.low.high>>24&255,q[w++]=255&M.high.low,q[w++]=M.high.low>>8&255,q[w++]=M.high.low>>16&255,q[w++]=M.high.low>>24&255,q[w++]=255&M.high.high,q[w++]=M.high.high>>8&255,q[w++]=M.high.high>>16&255,q[w++]=M.high.high>>24&255,new t(q)},t.prototype.toString=function(){for(var t,e=0,n=new Array(36),r=0;r<n.length;r++)n[r]=0;var o,i,s,a=0,c=!1,u={parts:[0,0,0,0]},f=[];a=0;var l=this.bytes,h=l[a++]|l[a++]<<8|l[a++]<<16|l[a++]<<24,p=l[a++]|l[a++]<<8|l[a++]<<16|l[a++]<<24,d=l[a++]|l[a++]<<8|l[a++]<<16|l[a++]<<24,y=l[a++]|l[a++]<<8|l[a++]<<16|l[a++]<<24;a=0,(new Ne(h,p),new Ne(d,y)).lessThan(Ne.ZERO)&&f.push("-");var g=y>>26&31;if(g>>3==3){if(30===g)return f.join("")+"Infinity";if(31===g)return"NaN";t=y>>15&16383,o=8+(y>>14&1)}else o=y>>14&7,t=y>>17&16383;var v=t-6176;if(u.parts[0]=(16383&y)+((15&o)<<14),u.parts[1]=d,u.parts[2]=p,u.parts[3]=h,0===u.parts[0]&&0===u.parts[1]&&0===u.parts[2]&&0===u.parts[3])c=!0;else for(s=3;s>=0;s--){var m=0,_=qe(u);if(u=_.quotient,m=_.rem.low)for(i=8;i>=0;i--)n[9*s+i]=m%10,m=Math.floor(m/10)}if(c)e=1,n[a]=0;else for(e=36;!n[a];)e-=1,a+=1;var w=e-1+v;if(w>=34||w<=-7||v>0){if(e>34)return f.push("".concat(0)),v>0?f.push("E+".concat(v)):v<0&&f.push("E".concat(v)),f.join("");for(f.push("".concat(n[a++])),(e-=1)&&f.push("."),r=0;r<e;r++)f.push("".concat(n[a++]));f.push("E"),w>0?f.push("+".concat(w)):f.push("".concat(w))}else if(v>=0)for(r=0;r<e;r++)f.push("".concat(n[a++]));else{var b=e+v;if(b>0)for(r=0;r<b;r++)f.push("".concat(n[a++]));else f.push("0");for(f.push(".");b++<0;)f.push("0");for(r=0;r<e-Math.max(b-1,0);r++)f.push("".concat(n[a++]))}return f.join("")},t.prototype.toJSON=function(){return{$numberDecimal:this.toString()}},t.prototype.toExtendedJSON=function(){return{$numberDecimal:this.toString()}},t.fromExtendedJSON=function(e){return t.fromString(e.$numberDecimal)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return'new Decimal128("'.concat(this.toString(),'")')},t}();Object.defineProperty(Fe.prototype,"_bsontype",{value:"Decimal128"});var We=function(){function t(e){if(!(this instanceof t))return new t(e);e instanceof Number&&(e=e.valueOf()),this.value=+e}return t.prototype.valueOf=function(){return this.value},t.prototype.toJSON=function(){return this.value},t.prototype.toString=function(t){return this.value.toString(t)},t.prototype.toExtendedJSON=function(t){return t&&(t.legacy||t.relaxed&&isFinite(this.value))?this.value:Object.is(Math.sign(this.value),-0)?{$numberDouble:"-".concat(this.value.toFixed(1))}:{$numberDouble:Number.isInteger(this.value)?this.value.toFixed(1):this.value.toString()}},t.fromExtendedJSON=function(e,n){var r=parseFloat(e.$numberDouble);return n&&n.relaxed?r:new t(r)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){var t=this.toExtendedJSON();return"new Double(".concat(t.$numberDouble,")")},t}();Object.defineProperty(We.prototype,"_bsontype",{value:"Double"});var $e=function(){function t(e){if(!(this instanceof t))return new t(e);e instanceof Number&&(e=e.valueOf()),this.value=0|+e}return t.prototype.valueOf=function(){return this.value},t.prototype.toString=function(t){return this.value.toString(t)},t.prototype.toJSON=function(){return this.value},t.prototype.toExtendedJSON=function(t){return t&&(t.relaxed||t.legacy)?this.value:{$numberInt:this.value.toString()}},t.fromExtendedJSON=function(e,n){return n&&n.relaxed?parseInt(e.$numberInt,10):new t(e.$numberInt)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return"new Int32(".concat(this.valueOf(),")")},t}();Object.defineProperty($e.prototype,"_bsontype",{value:"Int32"});var He=function(){function t(){if(!(this instanceof t))return new t}return t.prototype.toExtendedJSON=function(){return{$maxKey:1}},t.fromExtendedJSON=function(){return new t},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return"new MaxKey()"},t}();Object.defineProperty(He.prototype,"_bsontype",{value:"MaxKey"});var Ge=function(){function t(){if(!(this instanceof t))return new t}return t.prototype.toExtendedJSON=function(){return{$minKey:1}},t.fromExtendedJSON=function(){return new t},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return"new MinKey()"},t}();Object.defineProperty(Ge.prototype,"_bsontype",{value:"MinKey"});var Ke=new RegExp("^[0-9a-fA-F]{24}$"),Ve=null,Je=Symbol("id"),Ye=function(){function t(e){if(!(this instanceof t))return new t(e);var n;if("object"==typeof e&&e&&"id"in e){if("string"!=typeof e.id&&!ArrayBuffer.isView(e.id))throw new re("Argument passed in must have an id that is of type string or Buffer");n="toHexString"in e&&"function"==typeof e.toHexString?Qt.from(e.toHexString(),"hex"):e.id}else n=e;if(null==n||"number"==typeof n)this[Je]=t.generate("number"==typeof n?n:void 0);else if(ArrayBuffer.isView(n)&&12===n.byteLength)this[Je]=n instanceof Qt?n:le(n);else{if("string"!=typeof n)throw new re("Argument passed in does not match the accepted types");if(12===n.length){var r=Qt.from(n);if(12!==r.byteLength)throw new re("Argument passed in must be a string of 12 bytes");this[Je]=r}else{if(24!==n.length||!Ke.test(n))throw new re("Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer");this[Je]=Qt.from(n,"hex")}}t.cacheHexString&&(this.__id=this.id.toString("hex"))}return Object.defineProperty(t.prototype,"id",{get:function(){return this[Je]},set:function(e){this[Je]=e,t.cacheHexString&&(this.__id=e.toString("hex"))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"generationTime",{get:function(){return this.id.readInt32BE(0)},set:function(t){this.id.writeUInt32BE(t,0)},enumerable:!1,configurable:!0}),t.prototype.toHexString=function(){if(t.cacheHexString&&this.__id)return this.__id;var e=this.id.toString("hex");return t.cacheHexString&&!this.__id&&(this.__id=e),e},t.getInc=function(){return t.index=(t.index+1)%16777215},t.generate=function(e){"number"!=typeof e&&(e=Math.floor(Date.now()/1e3));var n=t.getInc(),r=Qt.alloc(12);return r.writeUInt32BE(e,0),null===Ve&&(Ve=ae(5)),r[4]=Ve[0],r[5]=Ve[1],r[6]=Ve[2],r[7]=Ve[3],r[8]=Ve[4],r[11]=255&n,r[10]=n>>8&255,r[9]=n>>16&255,r},t.prototype.toString=function(t){return t?this.id.toString(t):this.toHexString()},t.prototype.toJSON=function(){return this.toHexString()},t.prototype.equals=function(e){if(null==e)return!1;if(e instanceof t)return this[Je][11]===e[Je][11]&&this[Je].equals(e[Je]);if("string"==typeof e&&t.isValid(e)&&12===e.length&&ce(this.id))return e===Qt.prototype.toString.call(this.id,"latin1");if("string"==typeof e&&t.isValid(e)&&24===e.length)return e.toLowerCase()===this.toHexString();if("string"==typeof e&&t.isValid(e)&&12===e.length)return Qt.from(e).equals(this.id);if("object"==typeof e&&"toHexString"in e&&"function"==typeof e.toHexString){var n=e.toHexString(),r=this.toHexString().toLowerCase();return"string"==typeof n&&n.toLowerCase()===r}return!1},t.prototype.getTimestamp=function(){var t=new Date,e=this.id.readUInt32BE(0);return t.setTime(1e3*Math.floor(e)),t},t.createPk=function(){return new t},t.createFromTime=function(e){var n=Qt.from([0,0,0,0,0,0,0,0,0,0,0,0]);return n.writeUInt32BE(e,0),new t(n)},t.createFromHexString=function(e){if(void 0===e||null!=e&&24!==e.length)throw new re("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");return new t(Qt.from(e,"hex"))},t.isValid=function(e){if(null==e)return!1;try{return new t(e),!0}catch(t){return!1}},t.prototype.toExtendedJSON=function(){return this.toHexString?{$oid:this.toHexString()}:{$oid:this.toString("hex")}},t.fromExtendedJSON=function(e){return new t(e.$oid)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return'new ObjectId("'.concat(this.toHexString(),'")')},t.index=Math.floor(16777215*Math.random()),t}();Object.defineProperty(Ye.prototype,"generate",{value:fe((function(t){return Ye.generate(t)}),"Please use the static `ObjectId.generate(time)` instead")}),Object.defineProperty(Ye.prototype,"getInc",{value:fe((function(){return Ye.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(Ye.prototype,"get_inc",{value:fe((function(){return Ye.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(Ye,"get_inc",{value:fe((function(){return Ye.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(Ye.prototype,"_bsontype",{value:"ObjectID"});var ze=function(){function t(e,n){if(!(this instanceof t))return new t(e,n);if(this.pattern=e,this.options=(null!=n?n:"").split("").sort().join(""),-1!==this.pattern.indexOf("\0"))throw new ne("BSON Regex patterns cannot contain null bytes, found: ".concat(JSON.stringify(this.pattern)));if(-1!==this.options.indexOf("\0"))throw new ne("BSON Regex options cannot contain null bytes, found: ".concat(JSON.stringify(this.options)));for(var r=0;r<this.options.length;r++)if("i"!==this.options[r]&&"m"!==this.options[r]&&"x"!==this.options[r]&&"l"!==this.options[r]&&"s"!==this.options[r]&&"u"!==this.options[r])throw new ne("The regular expression option [".concat(this.options[r],"] is not supported"))}return t.parseOptions=function(t){return t?t.split("").sort().join(""):""},t.prototype.toExtendedJSON=function(t){return(t=t||{}).legacy?{$regex:this.pattern,$options:this.options}:{$regularExpression:{pattern:this.pattern,options:this.options}}},t.fromExtendedJSON=function(e){if("$regex"in e){if("string"==typeof e.$regex)return new t(e.$regex,t.parseOptions(e.$options));if("BSONRegExp"===e.$regex._bsontype)return e}if("$regularExpression"in e)return new t(e.$regularExpression.pattern,t.parseOptions(e.$regularExpression.options));throw new re("Unexpected BSONRegExp EJSON object form: ".concat(JSON.stringify(e)))},t}();Object.defineProperty(ze.prototype,"_bsontype",{value:"BSONRegExp"});var Xe=function(){function t(e){if(!(this instanceof t))return new t(e);this.value=e}return t.prototype.valueOf=function(){return this.value},t.prototype.toString=function(){return this.value},t.prototype.inspect=function(){return'new BSONSymbol("'.concat(this.value,'")')},t.prototype.toJSON=function(){return this.value},t.prototype.toExtendedJSON=function(){return{$symbol:this.value}},t.fromExtendedJSON=function(e){return new t(e.$symbol)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t}();Object.defineProperty(Xe.prototype,"_bsontype",{value:"Symbol"});var Ze=function(t){function e(n,r){var o=this;return o instanceof e?(o=Ne.isLong(n)?t.call(this,n.low,n.high,!0)||this:ue(n)&&void 0!==n.t&&void 0!==n.i?t.call(this,n.i,n.t,!0)||this:t.call(this,n,r,!0)||this,Object.defineProperty(o,"_bsontype",{value:"Timestamp",writable:!1,configurable:!1,enumerable:!1}),o):new e(n,r)}return ee(e,t),e.prototype.toJSON=function(){return{$timestamp:this.toString()}},e.fromInt=function(t){return new e(Ne.fromInt(t,!0))},e.fromNumber=function(t){return new e(Ne.fromNumber(t,!0))},e.fromBits=function(t,n){return new e(t,n)},e.fromString=function(t,n){return new e(Ne.fromString(t,!0,n))},e.prototype.toExtendedJSON=function(){return{$timestamp:{t:this.high>>>0,i:this.low>>>0}}},e.fromExtendedJSON=function(t){return new e(t.$timestamp)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return"new Timestamp({ t: ".concat(this.getHighBits(),", i: ").concat(this.getLowBits()," })")},e.MAX_VALUE=Ne.MAX_UNSIGNED_VALUE,e}(Ne);var Qe=2147483647,tn=-2147483648,en=0x8000000000000000,nn=-0x8000000000000000,rn={$oid:Ye,$binary:me,$uuid:me,$symbol:Xe,$numberInt:$e,$numberDecimal:Fe,$numberDouble:We,$numberLong:Ne,$minKey:Ge,$maxKey:He,$regex:ze,$regularExpression:ze,$timestamp:Ze};function on(t,e){if(void 0===e&&(e={}),"number"==typeof t){if(e.relaxed||e.legacy)return t;if(Math.floor(t)===t){if(t>=tn&&t<=Qe)return new $e(t);if(t>=nn&&t<=en)return Ne.fromNumber(t)}return new We(t)}if(null==t||"object"!=typeof t)return t;if(t.$undefined)return null;for(var n=Object.keys(t).filter((function(e){return e.startsWith("$")&&null!=t[e]})),r=0;r<n.length;r++){var o=rn[n[r]];if(o)return o.fromExtendedJSON(t,e)}if(null!=t.$date){var i=t.$date,s=new Date;return e.legacy?"number"==typeof i?s.setTime(i):"string"==typeof i&&s.setTime(Date.parse(i)):"string"==typeof i?s.setTime(Date.parse(i)):Ne.isLong(i)?s.setTime(i.toNumber()):"number"==typeof i&&e.relaxed&&s.setTime(i),s}if(null!=t.$code){var a=Object.assign({},t);return t.$scope&&(a.$scope=on(t.$scope)),we.fromExtendedJSON(t)}if(function(t){return ue(t)&&null!=t.$id&&"string"==typeof t.$ref&&(null==t.$db||"string"==typeof t.$db)}(t)||t.$dbPointer){var c=t.$ref?t:t.$dbPointer;if(c instanceof be)return c;var u=Object.keys(c).filter((function(t){return t.startsWith("$")})),f=!0;if(u.forEach((function(t){-1===["$ref","$id","$db"].indexOf(t)&&(f=!1)})),f)return be.fromExtendedJSON(c)}return t}function sn(t){var e=t.toISOString();return 0!==t.getUTCMilliseconds()?e:e.slice(0,-5)+"Z"}function an(t,e){if(("object"==typeof t||"function"==typeof t)&&null!==t){var n=e.seenObjects.findIndex((function(e){return e.obj===t}));if(-1!==n){var r=e.seenObjects.map((function(t){return t.propertyName})),o=r.slice(0,n).map((function(t){return"".concat(t," -> ")})).join(""),i=r[n],s=" -> "+r.slice(n+1,r.length-1).map((function(t){return"".concat(t," -> ")})).join(""),a=r[r.length-1],c=" ".repeat(o.length+i.length/2),u="-".repeat(s.length+(i.length+a.length)/2-1);throw new re("Converting circular structure to EJSON:\n"+" ".concat(o).concat(i).concat(s).concat(a,"\n")+" ".concat(c,"\\").concat(u,"/"))}e.seenObjects[e.seenObjects.length-1].obj=t}if(Array.isArray(t))return function(t,e){return t.map((function(t,n){e.seenObjects.push({propertyName:"index ".concat(n),obj:null});try{return an(t,e)}finally{e.seenObjects.pop()}}))}(t,e);if(void 0===t)return null;if(t instanceof Date||ue(h=t)&&"[object Date]"===Object.prototype.toString.call(h)){var f=t.getTime(),l=f>-1&&f<2534023188e5;return e.legacy?e.relaxed&&l?{$date:t.getTime()}:{$date:sn(t)}:e.relaxed&&l?{$date:sn(t)}:{$date:{$numberLong:t.getTime().toString()}}}var h;if(!("number"!=typeof t||e.relaxed&&isFinite(t))){if(Math.floor(t)===t){var p=t>=nn&&t<=en;if(t>=tn&&t<=Qe)return{$numberInt:t.toString()};if(p)return{$numberLong:t.toString()}}return{$numberDouble:t.toString()}}if(t instanceof RegExp||function(t){return"[object RegExp]"===Object.prototype.toString.call(t)}(t)){var d=t.flags;if(void 0===d){var y=t.toString().match(/[gimuy]*$/);y&&(d=y[0])}return new ze(t.source,d).toExtendedJSON(e)}return null!=t&&"object"==typeof t?function(t,e){if(null==t||"object"!=typeof t)throw new ne("not an object instance");var n=t._bsontype;if(void 0===n){var r={};for(var o in t){e.seenObjects.push({propertyName:o,obj:null});try{var i=an(t[o],e);"__proto__"===o?Object.defineProperty(r,o,{value:i,writable:!0,enumerable:!0,configurable:!0}):r[o]=i}finally{e.seenObjects.pop()}}return r}if(function(t){return ue(t)&&Reflect.has(t,"_bsontype")&&"string"==typeof t._bsontype}(t)){var s=t;if("function"!=typeof s.toExtendedJSON){var a=un[t._bsontype];if(!a)throw new re("Unrecognized or invalid _bsontype: "+t._bsontype);s=a(s)}return"Code"===n&&s.scope?s=new we(s.code,an(s.scope,e)):"DBRef"===n&&s.oid&&(s=new be(an(s.collection,e),an(s.oid,e),an(s.db,e),an(s.fields,e))),s.toExtendedJSON(e)}throw new ne("_bsontype must be a string, but was: "+typeof n)}(t,e):t}var cn,un={Binary:function(t){return new me(t.value(),t.sub_type)},Code:function(t){return new we(t.code,t.scope)},DBRef:function(t){return new be(t.collection||t.namespace,t.oid,t.db,t.fields)},Decimal128:function(t){return new Fe(t.bytes)},Double:function(t){return new We(t.value)},Int32:function(t){return new $e(t.value)},Long:function(t){return Ne.fromBits(null!=t.low?t.low:t.low_,null!=t.low?t.high:t.high_,null!=t.low?t.unsigned:t.unsigned_)},MaxKey:function(){return new He},MinKey:function(){return new Ge},ObjectID:function(t){return new Ye(t)},ObjectId:function(t){return new Ye(t)},BSONRegExp:function(t){return new ze(t.pattern,t.options)},Symbol:function(t){return new Xe(t.value)},Timestamp:function(t){return Ze.fromBits(t.low,t.high)}};!function(t){function e(t,e){var n=Object.assign({},{relaxed:!0,legacy:!1},e);return"boolean"==typeof n.relaxed&&(n.strict=!n.relaxed),"boolean"==typeof n.strict&&(n.relaxed=!n.strict),JSON.parse(t,(function(t,e){if(-1!==t.indexOf("\0"))throw new ne("BSON Document field names cannot contain null bytes, found: ".concat(JSON.stringify(t)));return on(e,n)}))}function n(t,e,n,r){null!=n&&"object"==typeof n&&(r=n,n=0),null==e||"object"!=typeof e||Array.isArray(e)||(r=e,e=void 0,n=0);var o=an(t,Object.assign({relaxed:!0,legacy:!1},r,{seenObjects:[{propertyName:"(root)",obj:null}]}));return JSON.stringify(o,e,n)}t.parse=e,t.stringify=n,t.serialize=function(t,e){return e=e||{},JSON.parse(n(t,e))},t.deserialize=function(t,n){return n=n||{},e(JSON.stringify(t),n)}}(cn||(cn={}));var fn=ie();fn.Map?fn.Map:function(){function t(t){void 0===t&&(t=[]),this._keys=[],this._values={};for(var e=0;e<t.length;e++)if(null!=t[e]){var n=t[e],r=n[0],o=n[1];this._keys.push(r),this._values[r]={v:o,i:this._keys.length-1}}}t.prototype.clear=function(){this._keys=[],this._values={}},t.prototype.delete=function(t){var e=this._values[t];return null!=e&&(delete this._values[t],this._keys.splice(e.i,1),!0)},t.prototype.entries=function(){var t=this,e=0;return{next:function(){var n=t._keys[e++];return{value:void 0!==n?[n,t._values[n].v]:void 0,done:void 0===n}}}},t.prototype.forEach=function(t,e){e=e||this;for(var n=0;n<this._keys.length;n++){var r=this._keys[n];t.call(e,this._values[r].v,r,e)}},t.prototype.get=function(t){return this._values[t]?this._values[t].v:void 0},t.prototype.has=function(t){return null!=this._values[t]},t.prototype.keys=function(){var t=this,e=0;return{next:function(){var n=t._keys[e++];return{value:void 0!==n?n:void 0,done:void 0===n}}}},t.prototype.set=function(t,e){return this._values[t]?(this._values[t].v=e,this):(this._keys.push(t),this._values[t]={v:e,i:this._keys.length-1},this)},t.prototype.values=function(){var t=this,e=0;return{next:function(){var n=t._keys[e++];return{value:void 0!==n?t._values[n].v:void 0,done:void 0===n}}}},Object.defineProperty(t.prototype,"size",{get:function(){return this._keys.length},enumerable:!1,configurable:!0})}(),Ne.fromNumber(ge),Ne.fromNumber(ve),new Set(["$db","$ref","$id","$clusterTime"]);var ln=new Uint8Array(8);new DataView(ln.buffer,ln.byteOffset,ln.byteLength);Qt.alloc(17825792);var hn=function(){function t(t,e){this._stages=[],t&&e&&(this._db=t,this._request=new Un.reqClass(this._db.config),this._collectionName=e)}return t.prototype.end=function(){return t=this,e=void 0,r=function(){var t;return function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}(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.aggregate",{collectionName:this._collectionName,stages:this._stages})];case 1:return(t=e.sent())&&t.data&&t.data.list?[2,{requestId:t.requestId,data:JSON.parse(t.data.list).map(cn.parse)}]:[2,t]}}))},new((n=void 0)||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}));var t,e,n,r},t.prototype.unwrap=function(){return this._stages},t.prototype.done=function(){return this._stages.map((function(t){var e,n=t.stageKey,r=t.stageValue;return(e={})[n]=JSON.parse(r),e}))},t.prototype._pipe=function(t,e){return this._stages.push({stageKey:"$"+t,stageValue:JSON.stringify(e)}),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=Dt.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",Dt.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}(),pn=hn,dn=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)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),yn=function(t){function e(e,n){return t.call(this,e,n)||this}return dn(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return this._coll},enumerable:!0,configurable:!0}),e.prototype.doc=function(t){if("string"!=typeof t&&"number"!=typeof t)throw new Error("docId必须为字符串或数字");return new jt(this._db,this._coll,t)},e.prototype.add=function(t,e){return new jt(this._db,this._coll,void 0).create(t,e)},e.prototype.aggregate=function(){return new pn(this._db,this._coll)},e}(Bt),gn={eq:function(t){return new pt(lt.EQ,[t])},neq:function(t){return new pt(lt.NEQ,[t])},lt:function(t){return new pt(lt.LT,[t])},lte:function(t){return new pt(lt.LTE,[t])},gt:function(t){return new pt(lt.GT,[t])},gte:function(t){return new pt(lt.GTE,[t])},in:function(t){return new pt(lt.IN,t)},nin:function(t){return new pt(lt.NIN,t)},all:function(t){return new pt(lt.ALL,t)},elemMatch:function(t){return new pt(lt.ELEM_MATCH,[t])},exists:function(t){return new pt(lt.EXISTS,[t])},size:function(t){return new pt(lt.SIZE,[t])},mod:function(t){return new pt(lt.MOD,[t])},geoNear:function(t){return new pt(lt.GEO_NEAR,[t])},geoWithin:function(t){return new pt(lt.GEO_WITHIN,[t])},geoIntersects:function(t){return new pt(lt.GEO_INTERSECTS,[t])},and:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=B(arguments[0])?arguments[0]:Array.from(arguments);return new ut(st.AND,n)},nor:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=B(arguments[0])?arguments[0]:Array.from(arguments);return new ut(st.NOR,n)},or:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=B(arguments[0])?arguments[0]:Array.from(arguments);return new ut(st.OR,n)},not:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=B(arguments[0])?arguments[0]:Array.from(arguments);return new ut(st.NOT,n)},set:function(t){return new at(tt.SET,[t])},remove:function(){return new at(tt.REMOVE,[])},inc:function(t){return new at(tt.INC,[t])},mul:function(t){return new at(tt.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")){var r=e[0];t={$each:r.each,$position:r.position,$sort:r.sort,$slice:r.slice}}else t=B(e[0])?e[0]:Array.from(e);return new at(tt.PUSH,t)},pull:function(t){return new at(tt.PULL,t)},pullAll:function(t){return new at(tt.PULL_ALL,t)},pop:function(){return new at(tt.POP,[])},shift:function(){return new at(tt.SHIFT,[])},unshift:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=B(arguments[0])?arguments[0]:Array.from(arguments);return new at(tt.UNSHIFT,n)},addToSet:function(t){return new at(tt.ADD_TO_SET,t)},rename:function(t){return new at(tt.RENAME,[t])},bit:function(t){return new at(tt.BIT,[t])},max:function(t){return new at(tt.MAX,[t])},min:function(t){return new at(tt.MIN,[t])},expr:function(t){return{$expr:t}},jsonSchema:function(t){return{$jsonSchema:t}},text:function(t){return"string"===D(t)?{$search:t.search}:{$search:t.search,$language:t.language,$caseSensitive:t.caseSensitive,$diacriticSensitive:t.diacriticSensitive}},aggregate:{pipeline:function(){return new pn},abs:function(t){return new vn("abs",t)},add:function(t){return new vn("add",t)},ceil:function(t){return new vn("ceil",t)},divide:function(t){return new vn("divide",t)},exp:function(t){return new vn("exp",t)},floor:function(t){return new vn("floor",t)},ln:function(t){return new vn("ln",t)},log:function(t){return new vn("log",t)},log10:function(t){return new vn("log10",t)},mod:function(t){return new vn("mod",t)},multiply:function(t){return new vn("multiply",t)},pow:function(t){return new vn("pow",t)},sqrt:function(t){return new vn("sqrt",t)},subtract:function(t){return new vn("subtract",t)},trunc:function(t){return new vn("trunc",t)},arrayElemAt:function(t){return new vn("arrayElemAt",t)},arrayToObject:function(t){return new vn("arrayToObject",t)},concatArrays:function(t){return new vn("concatArrays",t)},filter:function(t){return new vn("filter",t)},in:function(t){return new vn("in",t)},indexOfArray:function(t){return new vn("indexOfArray",t)},isArray:function(t){return new vn("isArray",t)},map:function(t){return new vn("map",t)},range:function(t){return new vn("range",t)},reduce:function(t){return new vn("reduce",t)},reverseArray:function(t){return new vn("reverseArray",t)},size:function(t){return new vn("size",t)},slice:function(t){return new vn("slice",t)},zip:function(t){return new vn("zip",t)},and:function(t){return new vn("and",t)},not:function(t){return new vn("not",t)},or:function(t){return new vn("or",t)},cmp:function(t){return new vn("cmp",t)},eq:function(t){return new vn("eq",t)},gt:function(t){return new vn("gt",t)},gte:function(t){return new vn("gte",t)},lt:function(t){return new vn("lt",t)},lte:function(t){return new vn("lte",t)},neq:function(t){return new vn("ne",t)},cond:function(t){return new vn("cond",t)},ifNull:function(t){return new vn("ifNull",t)},switch:function(t){return new vn("switch",t)},dateFromParts:function(t){return new vn("dateFromParts",t)},dateFromString:function(t){return new vn("dateFromString",t)},dayOfMonth:function(t){return new vn("dayOfMonth",t)},dayOfWeek:function(t){return new vn("dayOfWeek",t)},dayOfYear:function(t){return new vn("dayOfYear",t)},isoDayOfWeek:function(t){return new vn("isoDayOfWeek",t)},isoWeek:function(t){return new vn("isoWeek",t)},isoWeekYear:function(t){return new vn("isoWeekYear",t)},millisecond:function(t){return new vn("millisecond",t)},minute:function(t){return new vn("minute",t)},month:function(t){return new vn("month",t)},second:function(t){return new vn("second",t)},hour:function(t){return new vn("hour",t)},week:function(t){return new vn("week",t)},year:function(t){return new vn("year",t)},literal:function(t){return new vn("literal",t)},mergeObjects:function(t){return new vn("mergeObjects",t)},objectToArray:function(t){return new vn("objectToArray",t)},allElementsTrue:function(t){return new vn("allElementsTrue",t)},anyElementTrue:function(t){return new vn("anyElementTrue",t)},setDifference:function(t){return new vn("setDifference",t)},setEquals:function(t){return new vn("setEquals",t)},setIntersection:function(t){return new vn("setIntersection",t)},setIsSubset:function(t){return new vn("setIsSubset",t)},setUnion:function(t){return new vn("setUnion",t)},concat:function(t){return new vn("concat",t)},dateToString:function(t){return new vn("dateToString",t)},indexOfBytes:function(t){return new vn("indexOfBytes",t)},indexOfCP:function(t){return new vn("indexOfCP",t)},split:function(t){return new vn("split",t)},strLenBytes:function(t){return new vn("strLenBytes",t)},strLenCP:function(t){return new vn("strLenCP",t)},strcasecmp:function(t){return new vn("strcasecmp",t)},substr:function(t){return new vn("substr",t)},substrBytes:function(t){return new vn("substrBytes",t)},substrCP:function(t){return new vn("substrCP",t)},toLower:function(t){return new vn("toLower",t)},toUpper:function(t){return new vn("toUpper",t)},meta:function(t){return new vn("meta",t)},addToSet:function(t){return new vn("addToSet",t)},avg:function(t){return new vn("avg",t)},first:function(t){return new vn("first",t)},last:function(t){return new vn("last",t)},max:function(t){return new vn("max",t)},min:function(t){return new vn("min",t)},push:function(t){return new vn("push",t)},stdDevPop:function(t){return new vn("stdDevPop",t)},stdDevSamp:function(t){return new vn("stdDevSamp",t)},sum:function(t){return new vn("sum",t)},let:function(t){return new vn("let",t)}},project:{slice:function(t){return new mn("slice",t)},elemMatch:function(t){return new mn("elemMatch",t)}}},vn=function(t,e){this["$"+t]=e},mn=function(t,e){this["$"+t]=e},_n=function(){function t(t){var e=t.regexp,n=t.options;if(!e)throw new TypeError("regexp must be a string");this.$regex=e,this.$options=n}return t.prototype.parse=function(){return{$regex:this.$regex,$options:this.$options}},Object.defineProperty(t.prototype,"_internalType",{get:function(){return j},enumerable:!0,configurable:!0}),t}();function wn(t){return new _n(t)}var bn="insert document failed",En="DATABASE_TRANSACTION_CONFLICT",Sn=function(){return Sn=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},Sn.apply(this,arguments)},In=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},On=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},An="database.updateDocInTransaction",Tn=function(){function t(t,e,n){this._coll=e,this.id=n,this._transaction=t,this._request=this._transaction.getRequestMethod(),this._transactionId=this._transaction.getTransactionId()}return t.prototype.create=function(t){return In(this,void 0,void 0,(function(){var e,n,r,o;return On(this,(function(i){switch(i.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,data:cn.stringify(Et(t),{relaxed:!1})},this.id&&(e._id=this.id),[4,this._request.send("database.insertDocInTransaction",e)];case 1:if((n=i.sent()).code)throw n;if(r=cn.parse(n.inserted),1==(o=cn.parse(n.ok))&&1==r)return[2,Sn(Sn({},n),{ok:o,inserted:r})];throw new Error(bn)}}))}))},t.prototype.get=function(){return In(this,void 0,void 0,(function(){var t,e;return On(this,(function(n){switch(n.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.getInTransaction",t)];case 1:if((e=n.sent()).code)throw e;return[2,{data:"null"!==e.data?nt.formatField(cn.parse(e.data)):cn.parse(e.data),requestId:e.requestId}]}}))}))},t.prototype.set=function(t){return In(this,void 0,void 0,(function(){var e,n;return On(this,(function(r){switch(r.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:cn.stringify(Et(t),{relaxed:!1}),upsert:!0},[4,this._request.send(An,e)];case 1:if((n=r.sent()).code)throw n;return[2,Sn(Sn({},n),{updated:cn.parse(n.updated),upserted:n.upserted?JSON.parse(n.upserted):null})]}}))}))},t.prototype.update=function(t){return In(this,void 0,void 0,(function(){var e,n;return On(this,(function(r){switch(r.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:cn.stringify(Lt.encode(t),{relaxed:!1})},[4,this._request.send(An,e)];case 1:if((n=r.sent()).code)throw n;return[2,Sn(Sn({},n),{updated:cn.parse(n.updated)})]}}))}))},t.prototype.delete=function(){return In(this,void 0,void 0,(function(){var t,e;return On(this,(function(n){switch(n.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.deleteDocInTransaction",t)];case 1:if((e=n.sent()).code)throw e;return[2,Sn(Sn({},e),{deleted:cn.parse(e.deleted)})]}}))}))},t}(),Nn=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)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Rn=function(t){function e(e,n){return t.call(this,e,n)||this}return Nn(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return this._coll},enumerable:!0,configurable:!0}),e.prototype.doc=function(t){if("string"!=typeof t&&"number"!=typeof t)throw new Error("docId必须为字符串或数字");return new Tn(this._transaction,this._coll,t)},e.prototype.add=function(t){var e;return void 0!==t._id&&(e=t._id),new Tn(this._transaction,this._coll,e).create(t)},e}((function(t,e){this._coll=e,this._transaction=t})),Pn=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},xn=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},Ln=function(){function t(t){this._db=t,this._request=new Un.reqClass(this._db.config),this.aborted=!1,this.commited=!1,this.inited=!1}return t.prototype.init=function(){return Pn(this,void 0,void 0,(function(){var t;return xn(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 Rn(this,t)},t.prototype.getTransactionId=function(){return this._id},t.prototype.getRequestMethod=function(){return this._request},t.prototype.commit=function(){return Pn(this,void 0,void 0,(function(){var t,e;return xn(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 Pn(this,void 0,void 0,(function(){var e,n;return xn(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 Cn(){return Pn(this,void 0,void 0,(function(){var t;return xn(this,(function(e){switch(e.label){case 0:return[4,(t=new Ln(this)).init()];case 1:return e.sent(),[2,t]}}))}))}function kn(t,e){return void 0===e&&(e=3),Pn(this,void 0,void 0,(function(){var n,r,o,i,s=this;return xn(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,10]),[4,(n=new Ln(this)).init()];case 1:return a.sent(),[4,t(n)];case 2:if(r=a.sent(),!0===n.aborted)throw n.abortReason;return[4,n.commit()];case 3:return a.sent(),[2,r];case 4:if(o=a.sent(),!1===n.inited)throw o;return i=function(t){return Pn(s,void 0,void 0,(function(){return xn(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:a.sent(),a.label=6;case 6:return o&&o.code===En?[4,kn.bind(this)(t,--e)]:[3,8];case 7:return[2,a.sent()];case 8:return[4,i(o)];case 9:return a.sent(),[3,10];case 10:return[2]}}))}))}var Un=function(){function t(t){this.config=t,this.Geo=i,this.serverDate=Q,this.command=gn,this.RegExp=wn,this.startTransaction=Cn,this.runTransaction=kn,this.logicCommand=ut,this.updateCommand=at,this.queryCommand=pt}return t.prototype.collection=function(t){if(!t)throw new Error("Collection name is required");return new yn(this,t)},t.prototype.createCollection=function(e){var n={collectionName:e};return new t.reqClass(this.config).send("database.addCollection",n)},t}(),jn=function(){return jn=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},jn.apply(this,arguments)},Dn={name:"database",entity:{database:function(t){var e=this.platform,n=e.adapter,r=e.runtime;return Un.reqClass=this.request.constructor,Un.getAccessToken=this.authInstance?this.authInstance.getAccessToken.bind(this.authInstance):function(){return""},Un.runtime=r,this.wsClientClass&&(Un.wsClass=n.wsClass,Un.wsClientClass=this.wsClientClass),Un.ws||(Un.ws=null),new Un(jn(jn({},this.config),t))}}};try{cloudbase.registerComponent(Dn)}catch(t){}function Mn(t){try{t.registerComponent(Dn)}catch(t){console.warn(t)}}},363:function(t,e,n){"use strict";n.r(e),n.d(e,{registerFunctions:function(){return p}});var r=n(650),o=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},i=r.constants.getSdkName,s=r.constants.ERRORS,a=r.constants.COMMUNITY_SITE_URL,c=r.utils.execCallback,u=r.helpers.catchErrorsDecorator,f="functions",l=new(function(){function t(){}return t.prototype.callFunction=function(t,e){return n=this,r=void 0,a=function(){var n,r,o,a,u,l,h,p,d,y,g,v;return function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,(function(m){switch(m.label){case 0:if(n=t.name,r=t.data,o=t.query,a=t.parse,u=t.search,!n)throw new Error(JSON.stringify({code:s.INVALID_PARAMS,msg:"[".concat(f,".callFunction] invalid function name")}));try{l=r?JSON.stringify(r):""}catch(t){throw new Error(JSON.stringify({code:s.INVALID_PARAMS,msg:"[".concat(f,".callFunction] invalid data")}))}h="functions.invokeFunction",p={inQuery:o,parse:a,search:u,function_name:n,request_data:l},d=this.request,m.label=1;case 1:return m.trys.push([1,3,,4]),[4,d.send(h,p)];case 2:if((y=m.sent()).code)return[2,c(e,null,y)];if(g=y.data.response_data,a)return[2,c(e,null,{result:g,requestId:y.requestId})];try{return g=JSON.parse(y.data.response_data),[2,c(e,null,{result:g,requestId:y.requestId})]}catch(t){c(e,new Error("[".concat(i(),"][").concat(s.INVALID_PARAMS,"][").concat(f,".callFunction] response data must be json")))}return[3,4];case 3:return v=m.sent(),c(e,v),[3,4];case 4:return[2]}}))},new((o=void 0)||(o=Promise))((function(t,e){function i(t){try{c(a.next(t))}catch(t){e(t)}}function s(t){try{c(a.throw(t))}catch(t){e(t)}}function c(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(i,s)}c((a=a.apply(n,r||[])).next())}));var n,r,o,a},function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);i>3&&s&&Object.defineProperty(e,n,s)}([u({customInfo:{className:"Cloudbase",methodName:"callFunction"},title:"函数调用失败",messages:["请确认以下各项:"," 1 - 调用 callFunction() 的语法或参数是否正确"," 2 - 当前环境下是否存在此函数"," 3 - 函数安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(a)]}),o("design:type",Function),o("design:paramtypes",[Object,Function]),o("design:returntype",Promise)],t.prototype,"callFunction",null),t}()),h={name:f,entity:{callFunction:l.callFunction}};try{cloudbase.registerComponent(h)}catch(t){}function p(t){try{t.registerComponent(h)}catch(t){console.warn(t)}}},63:function(t,e,n){"use strict";n.r(e),n.d(e,{registerRealtime:function(){return F}});var r=n(880),o=n.n(r),i=n(373),s=n.n(i),a=n(907),c=n.n(a);function u(t){return void 0===t&&(t=""),"".concat(t?"".concat(t,"_"):"").concat(+new Date,"_").concat(Math.random())}var f,l,h=function(t){this.close=t.close,this.onChange=t.onChange,this.onError=t.onError,t.debug&&Object.defineProperty(this,"virtualClient",{get:function(){return t.virtualClient}})},p=function(t){var e,n,r=t.id,o=t.docChanges,i=t.docs,s=t.msgType,a=t.type;Object.defineProperties(this,{id:{get:function(){return r},enumerable:!0},docChanges:{get:function(){return e||(e=JSON.parse(JSON.stringify(o))),e},enumerable:!0},docs:{get:function(){return n||(n=JSON.parse(JSON.stringify(i))),n},enumerable:!0},msgType:{get:function(){return s},enumerable:!0},type:{get:function(){return a},enumerable:!0}})},d=(f=function(t,e){return f=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])},f(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}f(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),y=function(t){function e(e){var n=t.call(this,"Watch Error ".concat(JSON.stringify(e.msgData)," (requestid: ").concat(e.requestId,")"))||this;return n.isRealtimeErrorMessageError=!0,n.payload=e,n}return d(e,t),e}(Error),g=function(t){return null==t?void 0:t.isRealtimeErrorMessageError},v=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="timeout",e.payload=null,e.generic=!0,e}return d(e,t),e}(Error),m=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="cancelled",e.payload=null,e.generic=!0,e}return d(e,t),e}(Error),_=function(t){function e(e){var n=t.call(this,e.errMsg)||this;return n.errCode="UNKNOWN_ERROR",Object.defineProperties(n,{message:{get:function(){return"errCode: ".concat(this.errCode," ").concat(w[this.errCode]||""," | errMsg: ").concat(this.errMsg)},set:function(t){this.errMsg=t}}}),n.errCode=e.errCode||"UNKNOWN_ERROR",n.errMsg=e.errMsg,n}return d(e,t),Object.defineProperty(e.prototype,"message",{get:function(){return"errCode: ".concat(this.errCode," | errMsg: ").concat(this.errMsg)},set:function(t){this.errMsg=t},enumerable:!1,configurable:!0}),e}(Error),w={UNKNOWN_ERROR:"UNKNOWN_ERROR",SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG:"SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG",SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA:"SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA",SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR:"SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR",SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED:"SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED",SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL:"SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL",SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR:"SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR"},b=function(t){return void 0===t&&(t=0),new Promise((function(e){return setTimeout(e,t)}))},E=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},S=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},I=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(t){t.LOGGINGIN="LOGGINGIN",t.INITING="INITING",t.REBUILDING="REBUILDING",t.ACTIVE="ACTIVE",t.ERRORED="ERRORED",t.CLOSING="CLOSING",t.CLOSED="CLOSED",t.PAUSED="PAUSED",t.RESUMING="RESUMING"}(l||(l={}));var O=function(){function t(t){var e=this;this.watchStatus=l.INITING,this._login=function(t,n){return E(e,void 0,void 0,(function(){var e;return S(this,(function(r){switch(r.label){case 0:return this.watchStatus=l.LOGGINGIN,[4,this.login(t,n)];case 1:return e=r.sent(),this.envId||(this.envId=e.envId),[2,e]}}))}))},this.initWatch=function(t){return E(e,void 0,void 0,(function(){var e,n=this;return S(this,(function(r){switch(r.label){case 0:if(this._initWatchPromise)return[2,this._initWatchPromise];this._initWatchPromise=new Promise((function(e,r){return E(n,void 0,void 0,(function(){var n,o,i,s,a,c,f,h,d,y;return S(this,(function(g){switch(g.label){case 0:return g.trys.push([0,3,,4]),this.watchStatus===l.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,e()]):[4,this._login(this.envId,t)];case 1:return n=g.sent().envId,this.watchStatus===l.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,e()]):(this.watchStatus=l.INITING,o={watchId:this.watchId,requestId:u(),msgType:"INIT_WATCH",msgData:{envId:n,collName:this.collectionName,query:this.query,limit:this.limit,orderBy:this.orderBy}},[4,this.send({msg:o,waitResponse:!0,skipOnMessage:!0,timeout:1e4})]);case 2:if(i=g.sent(),s=i.msgData,a=s.events,c=s.currEvent,this.sessionInfo={queryID:i.msgData.queryID,currentEventId:c-1,currentDocs:[]},a.length>0){for(f=0,h=a;f<h.length;f++)h[f].ID=c;this.handleServerEvents(i)}else this.sessionInfo.currentEventId=c,d=new p({id:c,docChanges:[],docs:[],type:"init"}),this.listener.onChange(d),this.scheduleSendACK();return this.onWatchStart(this,this.sessionInfo.queryID),this.watchStatus=l.ACTIVE,this._availableRetries.INIT_WATCH=2,e(),[3,4];case 3:return y=g.sent(),this.handleWatchEstablishmentError(y,{operationName:"INIT_WATCH",resolve:e,reject:r}),[3,4];case 4:return[2]}}))}))})),e=!1,r.label=1;case 1:return r.trys.push([1,,3,4]),[4,this._initWatchPromise];case 2:return r.sent(),e=!0,[3,4];case 3:return this._initWatchPromise=void 0,[7];case 4:return console.log("[realtime] initWatch ".concat(e?"success":"fail")),[2]}}))}))},this.rebuildWatch=function(t){return E(e,void 0,void 0,(function(){var e,n=this;return S(this,(function(r){switch(r.label){case 0:if(this._rebuildWatchPromise)return[2,this._rebuildWatchPromise];this._rebuildWatchPromise=new Promise((function(e,r){return E(n,void 0,void 0,(function(){var n,o,i,s;return S(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),this.watchStatus===l.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,e()]):[4,this._login(this.envId,t)];case 1:if(n=a.sent().envId,!this.sessionInfo)throw new Error("can not rebuildWatch without a successful initWatch (lack of sessionInfo)");return this.watchStatus===l.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,e()]):(this.watchStatus=l.REBUILDING,o={watchId:this.watchId,requestId:u(),msgType:"REBUILD_WATCH",msgData:{envId:n,collName:this.collectionName,queryID:this.sessionInfo.queryID,eventID:this.sessionInfo.currentEventId}},[4,this.send({msg:o,waitResponse:!0,skipOnMessage:!1,timeout:1e4})]);case 2:return i=a.sent(),this.handleServerEvents(i),this.watchStatus=l.ACTIVE,this._availableRetries.REBUILD_WATCH=2,e(),[3,4];case 3:return s=a.sent(),this.handleWatchEstablishmentError(s,{operationName:"REBUILD_WATCH",resolve:e,reject:r}),[3,4];case 4:return[2]}}))}))})),e=!1,r.label=1;case 1:return r.trys.push([1,,3,4]),[4,this._rebuildWatchPromise];case 2:return r.sent(),e=!0,[3,4];case 3:return this._rebuildWatchPromise=void 0,[7];case 4:return console.log("[realtime] rebuildWatch ".concat(e?"success":"fail")),[2]}}))}))},this.handleWatchEstablishmentError=function(t,n){return E(e,void 0,void 0,(function(){var e,r,o,i=this;return S(this,(function(s){return e="INIT_WATCH"===n.operationName,r=function(){i.closeWithError(new _({errCode:e?w.SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:w.SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL,errMsg:t})),n.reject(t)},o=function(t){i.useRetryTicket(n.operationName)?e?(i._initWatchPromise=void 0,n.resolve(i.initWatch(t))):(i._rebuildWatchPromise=void 0,n.resolve(i.rebuildWatch(t))):r()},this.handleCommonError(t,{onSignError:function(){return o(!0)},onTimeoutError:function(){return o(!1)},onNotRetryableError:r,onCancelledError:n.reject,onUnknownError:function(){return E(i,void 0,void 0,(function(){var t,e=this;return S(this,(function(r){switch(r.label){case 0:return r.trys.push([0,8,,9]),t=function(){return E(e,void 0,void 0,(function(){return S(this,(function(t){switch(t.label){case 0:return this.pause(),[4,this.onceWSConnected()];case 1:return t.sent(),o(!0),[2]}}))}))},this.isWSConnected()?[3,2]:[4,t()];case 1:return r.sent(),[3,7];case 2:return[4,b(100)];case 3:return r.sent(),this.watchStatus!==l.PAUSED?[3,4]:(n.reject(new m("".concat(n.operationName," cancelled due to pause after unknownError"))),[3,7]);case 4:return this.isWSConnected()?[3,6]:[4,t()];case 5:return r.sent(),[3,7];case 6:o(!1),r.label=7;case 7:return[3,9];case 8:return r.sent(),o(!0),[3,9];case 9:return[2]}}))}))}}),[2]}))}))},this.closeWatch=function(){return E(e,void 0,void 0,(function(){var t,e,n;return S(this,(function(r){switch(r.label){case 0:if(t=this.sessionInfo?this.sessionInfo.queryID:"",this.watchStatus!==l.ACTIVE)return this.watchStatus=l.CLOSED,this.onWatchClose(this,t),[2];r.label=1;case 1:return r.trys.push([1,3,4,5]),this.watchStatus=l.CLOSING,e={watchId:this.watchId,requestId:u(),msgType:"CLOSE_WATCH",msgData:null},[4,this.send({msg:e})];case 2:return r.sent(),this.sessionInfo=void 0,this.watchStatus=l.CLOSED,[3,5];case 3:return n=r.sent(),this.closeWithError(new _({errCode:w.SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL,errMsg:n})),[3,5];case 4:return this.onWatchClose(this,t),[7];case 5:return[2]}}))}))},this.scheduleSendACK=function(){e.clearACKSchedule(),e._ackTimeoutId=setTimeout((function(){e._waitExpectedTimeoutId?e.scheduleSendACK():e.sendACK()}),1e4)},this.clearACKSchedule=function(){e._ackTimeoutId&&clearTimeout(e._ackTimeoutId)},this.sendACK=function(){return E(e,void 0,void 0,(function(){var t,e,n;return S(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.watchStatus!==l.ACTIVE?(this.scheduleSendACK(),[2]):this.sessionInfo?(t={watchId:this.watchId,requestId:u(),msgType:"CHECK_LAST",msgData:{queryID:this.sessionInfo.queryID,eventID:this.sessionInfo.currentEventId}},[4,this.send({msg:t})]):(console.warn("[realtime listener] can not send ack without a successful initWatch (lack of sessionInfo)"),[2]);case 1:return r.sent(),this.scheduleSendACK(),[3,3];case 2:if(e=r.sent(),g(e))switch((n=e.payload).msgData.code){case"CHECK_LOGIN_FAILED":case"SIGN_EXPIRED_ERROR":case"SIGN_INVALID_ERROR":case"SIGN_PARAM_INVALID":return this.rebuildWatch(),[2];case"QUERYID_INVALID_ERROR":case"SYS_ERR":case"INVALIID_ENV":case"COLLECTION_PERMISSION_DENIED":return this.closeWithError(new _({errCode:w.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:n.msgData.code})),[2]}return this._availableRetries.CHECK_LAST&&this._availableRetries.CHECK_LAST>0?(this._availableRetries.CHECK_LAST--,this.scheduleSendACK()):this.closeWithError(new _({errCode:w.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:e})),[3,3];case 3:return[2]}}))}))},this.handleCommonError=function(t,e){if(g(t))switch(t.payload.msgData.code){case"CHECK_LOGIN_FAILED":case"SIGN_EXPIRED_ERROR":case"SIGN_INVALID_ERROR":case"SIGN_PARAM_INVALID":return void e.onSignError(t);default:return void e.onNotRetryableError(t)}else{if(function(t){return"timeout"===t.type}(t))return void e.onTimeoutError(t);if(function(t){return"cancelled"===t.type}(t))return void e.onCancelledError(t)}e.onUnknownError(t)},this.watchId="watchid_".concat(+new Date,"_").concat(Math.random()),this.envId=t.envId,this.collectionName=t.collectionName,this.query=t.query,this.limit=t.limit,this.orderBy=t.orderBy,this.send=t.send,this.login=t.login,this.isWSConnected=t.isWSConnected,this.onceWSConnected=t.onceWSConnected,this.getWaitExpectedTimeoutLength=t.getWaitExpectedTimeoutLength,this.onWatchStart=t.onWatchStart,this.onWatchClose=t.onWatchClose,this.debug=t.debug,this._availableRetries={INIT_WATCH:2,REBUILD_WATCH:2,CHECK_LAST:2},this.listener=new h({close:this.closeWatch,onChange:t.onChange,onError:t.onError,debug:this.debug,virtualClient:this}),this.initWatch()}return t.prototype.onMessage=function(t){var e=this;switch(this.watchStatus){case l.PAUSED:if("ERROR"!==t.msgType)return;break;case l.LOGGINGIN:case l.INITING:case l.REBUILDING:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received while ".concat(this.watchStatus));case l.CLOSED:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received when the watch has closed");case l.ERRORED:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received when the watch has ended with error")}if(this.sessionInfo)switch(this.scheduleSendACK(),t.msgType){case"NEXT_EVENT":console.warn("nextevent ".concat(t.msgData.currEvent," ignored"),t),this.handleServerEvents(t);break;case"CHECK_EVENT":this.sessionInfo.currentEventId<t.msgData.currEvent&&(this.sessionInfo.expectEventId=t.msgData.currEvent,this.clearWaitExpectedEvent(),this._waitExpectedTimeoutId=setTimeout((function(){e.rebuildWatch()}),this.getWaitExpectedTimeoutLength()),console.log("[realtime] waitExpectedTimeoutLength ".concat(this.getWaitExpectedTimeoutLength())));break;case"ERROR":this.closeWithError(new _({errCode:w.SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG,errMsg:"".concat(t.msgData.code," - ").concat(t.msgData.message)}));break;default:console.warn("[realtime listener] virtual client receive unexpected msg ".concat(t.msgType,": "),t)}else console.warn("[realtime listener] internal non-fatal error: sessionInfo not found while message is received.")},t.prototype.closeWithError=function(t){var e;this.watchStatus=l.ERRORED,this.clearACKSchedule(),this.listener.onError(t),this.onWatchClose(this,(null===(e=this.sessionInfo)||void 0===e?void 0:e.queryID)||""),console.log("[realtime] client closed (".concat(this.collectionName," ").concat(this.query,") (watchId ").concat(this.watchId,")"))},t.prototype.pause=function(){this.watchStatus=l.PAUSED,console.log("[realtime] client paused (".concat(this.collectionName," ").concat(this.query,") (watchId ").concat(this.watchId,")"))},t.prototype.resume=function(){return E(this,void 0,void 0,(function(){var t;return S(this,(function(e){switch(e.label){case 0:this.watchStatus=l.RESUMING,console.log("[realtime] client resuming with ".concat(this.sessionInfo?"REBUILD_WATCH":"INIT_WATCH"," (").concat(this.collectionName," ").concat(this.query,") (").concat(this.watchId,")")),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.sessionInfo?this.rebuildWatch():this.initWatch()];case 2:return e.sent(),console.log("[realtime] client successfully resumed (".concat(this.collectionName," ").concat(this.query,") (").concat(this.watchId,")")),[3,4];case 3:return t=e.sent(),console.error("[realtime] client resume failed (".concat(this.collectionName," ").concat(this.query,") (").concat(this.watchId,")"),t),[3,4];case 4:return[2]}}))}))},t.prototype.useRetryTicket=function(t){return!!(this._availableRetries[t]&&this._availableRetries[t]>0)&&(this._availableRetries[t]--,console.log("[realtime] ".concat(t," use a retry ticket, now only ").concat(this._availableRetries[t]," retry left")),!0)},t.prototype.handleServerEvents=function(t){return E(this,void 0,void 0,(function(){var e;return S(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this.scheduleSendACK(),[4,this._handleServerEvents(t)];case 1:return n.sent(),this._postHandleServerEventsValidityCheck(t),[3,3];case 2:throw e=n.sent(),console.error("[realtime listener] internal non-fatal error: handle server events failed with error: ",e),e;case 3:return[2]}}))}))},t.prototype._handleServerEvents=function(t){return E(this,void 0,void 0,(function(){var e,n,r,i,a,u,f,l,h,d,y,g;return S(this,(function(v){switch(v.label){case 0:if(e=t.requestId,n=t.msgData.events,r=t.msgType,!n.length||!this.sessionInfo)return[2];i=this.sessionInfo;try{a=n.map(A)}catch(t){return this.closeWithError(new _({errCode:w.SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA,errMsg:t})),[2]}u=I([],i.currentDocs,!0),f=!1,l=function(n,l){var d,y,g,v,m,b,E,O,A,T,N;return S(this,(function(S){switch(S.label){case 0:return d=a[n],i.currentEventId>=d.id?(!a[n-1]||d.id>a[n-1].id?console.warn("[realtime] duplicate event received, cur ".concat(i.currentEventId," but got ").concat(d.id)):console.error("[realtime listener] server non-fatal error: events out of order (the latter event's id is smaller than that of the former) (requestId ".concat(e,")")),[2,"continue"]):[3,1];case 1:if(i.currentEventId!==d.id-1)return[3,2];switch(d.dataType){case"update":if(!d.doc)switch(d.queueType){case"update":case"dequeue":if(y=u.find((function(t){return t._id===d.docId})),y){if(b=c()(y),d.updatedFields)for(m in d.updatedFields)o()(b,m,d.updatedFields[m]);if(d.removedFields)for(g=0,v=d.removedFields;g<v.length;g++)m=v[g],s()(b,m);d.doc=b}else console.error("[realtime listener] internal non-fatal server error: unexpected update dataType event where no doc is associated.");break;case"enqueue":throw E=new _({errCode:w.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="update" and queueType="enqueue" (requestId '.concat(t.requestId,")")}),h.closeWithError(E),E}break;case"replace":if(!d.doc)throw E=new _({errCode:w.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="replace" (requestId '.concat(t.requestId,")")}),h.closeWithError(E),E;break;case"remove":(b=u.find((function(t){return t._id===d.docId})))?d.doc=b:console.error("[realtime listener] internal non-fatal server error: unexpected remove event where no doc is associated.");break;case"limit":if(!d.doc)switch(d.queueType){case"dequeue":(b=u.find((function(t){return t._id===d.docId})))?d.doc=b:console.error("[realtime listener] internal non-fatal server error: unexpected limit dataType event where no doc is associated.");break;case"enqueue":throw E=new _({errCode:w.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="limit" and queueType="enqueue" (requestId '.concat(t.requestId,")")}),h.closeWithError(E),E}}switch(d.queueType){case"init":f?u.push(d.doc):(f=!0,u=[d.doc]);break;case"enqueue":u.push(d.doc);break;case"dequeue":O=u.findIndex((function(t){return t._id===d.docId})),O>-1?u.splice(O,1):console.error("[realtime listener] internal non-fatal server error: unexpected dequeue event where no doc is associated.");break;case"update":O=u.findIndex((function(t){return t._id===d.docId})),O>-1?u[O]=d.doc:console.error("[realtime listener] internal non-fatal server error: unexpected queueType update event where no doc is associated.")}return(n===l-1||a[n+1]&&a[n+1].id!==d.id)&&(A=I([],u,!0),T=a.slice(0,n+1).filter((function(t){return t.id===d.id})),h.sessionInfo.currentEventId=d.id,h.sessionInfo.currentDocs=u,N=new p({id:d.id,docChanges:T,docs:A,msgType:r}),h.listener.onChange(N)),[3,4];case 2:return console.warn("[realtime listener] event received is out of order, cur ".concat(h.sessionInfo.currentEventId," but got ").concat(d.id)),[4,h.rebuildWatch()];case 3:return S.sent(),[2,{value:void 0}];case 4:return[2]}}))},h=this,d=0,y=a.length,v.label=1;case 1:return d<y?[5,l(d,y)]:[3,4];case 2:if("object"==typeof(g=v.sent()))return[2,g.value];v.label=3;case 3:return d++,[3,1];case 4:return[2]}}))}))},t.prototype._postHandleServerEventsValidityCheck=function(t){this.sessionInfo?(this.sessionInfo.expectEventId&&this.sessionInfo.currentEventId>=this.sessionInfo.expectEventId&&this.clearWaitExpectedEvent(),this.sessionInfo.currentEventId<t.msgData.currEvent&&console.warn("[realtime listener] internal non-fatal error: client eventId does not match with server event id after server event handling")):console.error("[realtime listener] internal non-fatal error: sessionInfo lost after server event handling, this should never occur")},t.prototype.clearWaitExpectedEvent=function(){this._waitExpectedTimeoutId&&(clearTimeout(this._waitExpectedTimeoutId),this._waitExpectedTimeoutId=void 0)},t}();function A(t){var e={id:t.ID,dataType:t.DataType,queueType:t.QueueType,docId:t.DocID,doc:t.Doc&&"{}"!==t.Doc?JSON.parse(t.Doc):void 0};return"update"===t.DataType&&(t.UpdatedFields&&(e.updatedFields=JSON.parse(t.UpdatedFields)),(t.removedFields||t.RemovedFields)&&(e.removedFields=JSON.parse(t.removedFields))),e}var T,N={1e3:{code:1e3,name:"Normal Closure",description:"Normal closure; the connection successfully completed whatever purpose for which it was created."},1001:{code:1001,name:"Going Away",description:"The endpoint is going away, either because of a server failure or because the browser is navigating away from the page that opened the connection."},1002:{code:1002,name:"Protocol Error",description:"The endpoint is terminating the connection due to a protocol error."},1003:{code:1003,name:"Unsupported Data",description:"The connection is being terminated because the endpoint received data of a type it cannot accept (for example, a text-only endpoint received binary data)."},1005:{code:1005,name:"No Status Received",description:"Indicates that no status code was provided even though one was expected."},1006:{code:1006,name:"Abnormal Closure",description:"Used to indicate that a connection was closed abnormally (that is, with no close frame being sent) when a status code is expected."},1007:{code:1007,name:"Invalid frame payload data",description:"The endpoint is terminating the connection because a message was received that contained inconsistent data (e.g., non-UTF-8 data within a text message)."},1008:{code:1008,name:"Policy Violation",description:"The endpoint is terminating the connection because it received a message that violates its policy. This is a generic status code, used when codes 1003 and 1009 are not suitable."},1009:{code:1009,name:"Message too big",description:"The endpoint is terminating the connection because a data frame was received that is too large."},1010:{code:1010,name:"Missing Extension",description:"The client is terminating the connection because it expected the server to negotiate one or more extension, but the server didn't."},1011:{code:1011,name:"Internal Error",description:"The server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request."},1012:{code:1012,name:"Service Restart",description:"The server is terminating the connection because it is restarting."},1013:{code:1013,name:"Try Again Later",description:"The server is terminating the connection due to a temporary condition, e.g. it is overloaded and is casting off some of its clients."},1014:{code:1014,name:"Bad Gateway",description:"The server was acting as a gateway or proxy and received an invalid response from the upstream server. This is similar to 502 HTTP Status Code."},1015:{code:1015,name:"TLS Handshake",description:"Indicates that the connection was closed due to a failure to perform a TLS handshake (e.g., the server certificate can't be verified)."},3e3:{code:3e3,name:"Reconnect WebSocket",description:"The client is terminating the connection because it wants to reconnect"},3001:{code:3001,name:"No Realtime Listeners",description:"The client is terminating the connection because no more realtime listeners exist"},3002:{code:3002,name:"Heartbeat Ping Error",description:"The client is terminating the connection due to its failure in sending heartbeat messages"},3003:{code:3003,name:"Heartbeat Pong Timeout Error",description:"The client is terminating the connection because no heartbeat response is received from the server"},3050:{code:3050,name:"Server Close",description:"The client is terminating the connection because no heartbeat response is received from the server"}};!function(t){t[t.NormalClosure=1e3]="NormalClosure",t[t.GoingAway=1001]="GoingAway",t[t.ProtocolError=1002]="ProtocolError",t[t.UnsupportedData=1003]="UnsupportedData",t[t.NoStatusReceived=1005]="NoStatusReceived",t[t.AbnormalClosure=1006]="AbnormalClosure",t[t.InvalidFramePayloadData=1007]="InvalidFramePayloadData",t[t.PolicyViolation=1008]="PolicyViolation",t[t.MessageTooBig=1009]="MessageTooBig",t[t.MissingExtension=1010]="MissingExtension",t[t.InternalError=1011]="InternalError",t[t.ServiceRestart=1012]="ServiceRestart",t[t.TryAgainLater=1013]="TryAgainLater",t[t.BadGateway=1014]="BadGateway",t[t.TLSHandshake=1015]="TLSHandshake",t[t.ReconnectWebSocket=3e3]="ReconnectWebSocket",t[t.NoRealtimeListeners=3001]="NoRealtimeListeners",t[t.HeartbeatPingError=3002]="HeartbeatPingError",t[t.HeartbeatPongTimeoutError=3003]="HeartbeatPongTimeoutError",t[t.NoAuthentication=3050]="NoAuthentication"}(T||(T={}));var R=function(t,e){var n=N[t],r=n?"".concat(n.name,", code ").concat(t,", reason ").concat(e||n.description):"code ".concat(t);return new _({errCode:w.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED,errMsg:r})},P=null,x="web";function L(){return P}function C(){return x}function k(t){x=t}var U=function(){return U=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},U.apply(this,arguments)},j=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},D=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},M=function(){function t(t){var e=this;this._virtualWSClient=new Set,this._queryIdClientMap=new Map,this._watchIdClientMap=new Map,this._pingFailed=0,this._pongMissed=0,this._logins=new Map,this._wsReadySubsribers=[],this._wsResponseWait=new Map,this._rttObserved=[],this.send=function(t){return j(e,void 0,void 0,(function(){var e=this;return D(this,(function(n){return[2,new Promise((function(n,r){return j(e,void 0,void 0,(function(){var e,o,i,s,a,c,u,f=this;return D(this,(function(l){switch(l.label){case 0:o=!1,i=!1,s=function(t){o=!0,e&&clearTimeout(e),n(t)},a=function(t){i=!0,e&&clearTimeout(e),r(t)},t.timeout&&(e=setTimeout((function(){return j(f,void 0,void 0,(function(){return D(this,(function(t){switch(t.label){case 0:return o&&i?[3,2]:[4,b(0)];case 1:t.sent(),o&&i||a(new v("wsclient.send timedout")),t.label=2;case 2:return[2]}}))}))}),t.timeout)),l.label=1;case 1:return l.trys.push([1,8,,9]),this._wsInitPromise?[4,this._wsInitPromise]:[3,3];case 2:l.sent(),l.label=3;case 3:if(!this._ws)return a(new Error("invalid state: ws connection not exists, can not send message")),[2];if(1!==this._ws.readyState)return a(new Error("ws readyState invalid: ".concat(this._ws.readyState,", can not send message"))),[2];t.waitResponse&&this._wsResponseWait.set(t.msg.requestId,{resolve:s,reject:a,skipOnMessage:t.skipOnMessage}),l.label=4;case 4:return l.trys.push([4,6,,7]),[4,this._ws.send(JSON.stringify(t.msg))];case 5:return l.sent(),t.waitResponse||s(void 0),[3,7];case 6:return(c=l.sent())&&(a(c),t.waitResponse&&this._wsResponseWait.delete(t.msg.requestId)),[3,7];case 7:return[3,9];case 8:return u=l.sent(),a(u),[3,9];case 9:return[2]}}))}))}))]}))}))},this.closeAllClients=function(t){e._virtualWSClient.forEach((function(e){e.closeWithError(t)}))},this.pauseClients=function(t){(t||e._virtualWSClient).forEach((function(t){t.pause()}))},this.resumeClients=function(t){(t||e._virtualWSClient).forEach((function(t){t.resume()}))},this.initWebSocketConnection=function(t,n){return void 0===n&&(n=e._maxReconnect),j(e,void 0,void 0,(function(){var e=this;return D(this,(function(r){switch(r.label){case 0:if(t&&this._reconnectState)return[2];if(t&&(this._reconnectState=!0),this._wsInitPromise)return[2,this._wsInitPromise];t&&this.pauseClients(),this.close(T.ReconnectWebSocket),this._wsInitPromise=new Promise((function(r,o){return j(e,void 0,void 0,(function(){var e,i,s=this;return D(this,(function(a){switch(a.label){case 0:return a.trys.push([0,6,,11]),[4,this.getWsSign()];case 1:return e=a.sent(),[4,new Promise((function(t){var n=e.wsUrl||"wss://tcb-ws.tencentcloudapi.com",r=L();s._ws=r?new r(n):new WebSocket(n),t(void 0)}))];case 2:return a.sent(),this._ws.connect?[4,this._ws.connect()]:[3,4];case 3:a.sent(),a.label=4;case 4:return[4,this.initWebSocketEvent()];case 5:return a.sent(),r(),t&&(this.resumeClients(),this._reconnectState=!1),[3,11];case 6:return i=a.sent(),console.error("[realtime] initWebSocketConnection connect fail",i),n>0?(this._wsInitPromise=void 0,[4,b(this._reconnectInterval)]):[3,9];case 7:a.sent(),t&&(this._reconnectState=!1),a.label=8;case 8:return r(this.initWebSocketConnection(t,n-1)),[3,10];case 9:o(i),t&&this.closeAllClients(new _({errCode:w.SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL,errMsg:i})),a.label=10;case 10:return[3,11];case 11:return[2]}}))}))})),r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,this._wsInitPromise];case 2:return r.sent(),this._wsReadySubsribers.forEach((function(t){return(0,t.resolve)()})),[3,5];case 3:return r.sent(),this._wsReadySubsribers.forEach((function(t){return(0,t.reject)()})),[3,5];case 4:return this._wsInitPromise=void 0,this._wsReadySubsribers=[],[7];case 5:return[2]}}))}))},this.initWebSocketEvent=function(){return new Promise((function(t,n){if(!e._ws)throw new Error("can not initWebSocketEvent, ws not exists");var r=!1;e._ws.onopen=function(e){console.warn("[realtime] ws event: open",e),r=!0,t()},e._ws.onerror=function(t){e._logins=new Map,r?(console.error("[realtime] ws event: error",t),e.clearHeartbeat(),e._virtualWSClient.forEach((function(e){return e.closeWithError(new _({errCode:w.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR,errMsg:t}))}))):(console.error("[realtime] ws open failed with ws event: error",t),n(t))},e._ws.onclose=function(t){switch(console.warn("[realtime] ws event: close",t),e._logins=new Map,e.clearHeartbeat(),t.code){case T.ReconnectWebSocket:case T.NoRealtimeListeners:break;case T.HeartbeatPingError:case T.HeartbeatPongTimeoutError:case T.NormalClosure:case T.AbnormalClosure:e._maxReconnect>0?e.initWebSocketConnection(!0,e._maxReconnect):e.closeAllClients(R(t.code));break;case T.NoAuthentication:e.closeAllClients(R(t.code,t.reason));break;default:e._maxReconnect>0?e.initWebSocketConnection(!0,e._maxReconnect):e.closeAllClients(R(t.code))}},e._ws.onmessage=function(t){var n,r=t.data;e.heartbeat();try{n=JSON.parse(r)}catch(t){throw new Error("[realtime] onMessage parse res.data error: ".concat(t))}if("ERROR"===n.msgType){var o=null;e._virtualWSClient.forEach((function(t){t.watchId===n.watchId&&(o=t)})),o&&o.listener.onError(n)}var i=e._wsResponseWait.get(n.requestId);if(i){try{"ERROR"===n.msgType?i.reject(new y(n)):i.resolve(n)}catch(t){console.error("ws onMessage responseWaitSpec.resolve(msg) errored:",t)}finally{e._wsResponseWait.delete(n.requestId)}if(i.skipOnMessage)return}if("PONG"!==n.msgType){var s=n.watchId&&e._watchIdClientMap.get(n.watchId);if(s)s.onMessage(n);else switch(console.error("[realtime] no realtime listener found responsible for watchId ".concat(n.watchId,": "),n),n.msgType){case"INIT_EVENT":case"NEXT_EVENT":case"CHECK_EVENT":(s=e._queryIdClientMap.get(n.msgData.queryID))&&s.onMessage(n);break;default:for(var a=0,c=Array.from(e._watchIdClientMap.entries());a<c.length;a++){c[a][1].onMessage(n);break}}}else if(e._lastPingSendTS){var u=Date.now()-e._lastPingSendTS;if(u>1e4)return void console.warn("[realtime] untrusted rtt observed: ".concat(u));e._rttObserved.length>=3&&e._rttObserved.splice(0,e._rttObserved.length-3+1),e._rttObserved.push(u)}},e.heartbeat()}))},this.isWSConnected=function(){return Boolean(e._ws&&1===e._ws.readyState)},this.onceWSConnected=function(){return j(e,void 0,void 0,(function(){var t=this;return D(this,(function(e){return this.isWSConnected()?[2]:this._wsInitPromise?[2,this._wsInitPromise]:[2,new Promise((function(e,n){t._wsReadySubsribers.push({resolve:e,reject:n})}))]}))}))},this.webLogin=function(t,n){return j(e,void 0,void 0,(function(){var e,r,o,i,s,a,c,f,l=this;return D(this,(function(h){switch(h.label){case 0:if(!n)if(t){if(e=this._logins.get(t)){if(e.loggedIn&&e.loginResult)return[2,e.loginResult];if(e.loggingInPromise)return[2,e.loggingInPromise]}}else if(null==(r=this._logins.get(""))?void 0:r.loggingInPromise)return[2,r.loggingInPromise];o=new Promise((function(t,e){return j(l,void 0,void 0,(function(){var n,r,o,i,s;return D(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),[4,this.getWsSign()];case 1:return n=a.sent(),r={envId:n.envId||"",accessToken:"",referrer:"web",sdkVersion:"",dataVersion:""},o={watchId:void 0,requestId:u(),msgType:"LOGIN",msgData:r,exMsgData:{runtime:C(),signStr:n.signStr,secretVersion:n.secretVersion}},[4,this.send({msg:o,waitResponse:!0,skipOnMessage:!0,timeout:5e3})];case 2:return(i=a.sent()).msgData.code?e(new Error("".concat(i.msgData.code," ").concat(i.msgData.message))):t({envId:n.envId}),[3,4];case 3:return s=a.sent(),e(s),[3,4];case 4:return[2]}}))}))})),i=t&&this._logins.get(t),s=Date.now(),i?(i.loggedIn=!1,i.loggingInPromise=o,i.loginStartTS=s):(i={loggedIn:!1,loggingInPromise:o,loginStartTS:s},this._logins.set(t||"",i)),h.label=1;case 1:return h.trys.push([1,3,,4]),[4,o];case 2:if(a=h.sent(),(c=t&&this._logins.get(t))&&c===i&&c.loginStartTS===s)return i.loggedIn=!0,i.loggingInPromise=void 0,i.loginStartTS=void 0,i.loginResult=a,[2,a];if(c){if(c.loggedIn&&c.loginResult)return[2,c.loginResult];if(c.loggingInPromise)return[2,c.loggingInPromise];throw new Error("ws unexpected login info")}throw new Error("ws login info reset");case 3:throw f=h.sent(),i.loggedIn=!1,i.loggingInPromise=void 0,i.loginStartTS=void 0,i.loginResult=void 0,f;case 4:return[2]}}))}))},this.getWsSign=function(){return j(e,void 0,void 0,(function(){var t,e,n,r,o,i,s;return D(this,(function(a){switch(a.label){case 0:return this._wsSign&&this._wsSign.expiredTs>Date.now()?[2,this._wsSign]:(t=Date.now()+6e4,[4,this._context.appConfig.request.send("auth.wsWebSign",{runtime:C()})]);case 1:if((e=a.sent()).code)throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败: ".concat(e.code));if(e.data)return n=e.data,r=n.signStr,o=n.wsUrl,i=n.secretVersion,s=n.envId,[2,{signStr:r,wsUrl:o,secretVersion:i,envId:s,expiredTs:t}];throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败")}}))}))},this.getWaitExpectedTimeoutLength=function(){return e._rttObserved.length?e._rttObserved.reduce((function(t,e){return t+e}))/e._rttObserved.length*1.5:5e3},this.ping=function(){return j(e,void 0,void 0,(function(){var t;return D(this,(function(e){switch(e.label){case 0:return t={watchId:void 0,requestId:u(),msgType:"PING",msgData:null},[4,this.send({msg:t})];case 1:return e.sent(),[2]}}))}))},this.onWatchStart=function(t,n){e._queryIdClientMap.set(n,t)},this.onWatchClose=function(t,n){n&&e._queryIdClientMap.delete(n),e._watchIdClientMap.delete(t.watchId),e._virtualWSClient.delete(t),e._virtualWSClient.size||e.close(T.NoRealtimeListeners)},this._maxReconnect=t.maxReconnect||5,this._reconnectInterval=t.reconnectInterval||1e4,this._context=t.context}return t.prototype.clearHeartbeat=function(){this._pingTimeoutId&&clearTimeout(this._pingTimeoutId),this._pongTimeoutId&&clearTimeout(this._pongTimeoutId)},t.prototype.close=function(t){this.clearHeartbeat(),this._ws&&(this._ws.close(t,N[t].name),this._ws=void 0)},t.prototype.watch=function(t){this._ws||this._wsInitPromise||this.initWebSocketConnection(!1);var e=new O(U(U({},t),{send:this.send,login:this.webLogin,isWSConnected:this.isWSConnected,onceWSConnected:this.onceWSConnected,getWaitExpectedTimeoutLength:this.getWaitExpectedTimeoutLength,onWatchStart:this.onWatchStart,onWatchClose:this.onWatchClose,debug:!0}));return this._virtualWSClient.add(e),this._watchIdClientMap.set(e.watchId,e),e.listener},t.prototype.heartbeat=function(t){var e=this;this.clearHeartbeat(),this._pingTimeoutId=setTimeout((function(){return j(e,void 0,void 0,(function(){var t=this;return D(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),this._ws&&1===this._ws.readyState?(this._lastPingSendTS=Date.now(),[4,this.ping()]):[2];case 1:return e.sent(),this._pingFailed=0,this._pongTimeoutId=setTimeout((function(){console.error("pong timed out"),t._pongMissed<2?(t._pongMissed++,t.heartbeat(!0)):t.initWebSocketConnection(!0)}),this._context.appConfig.realtimePongWaitTimeout),[3,3];case 2:return e.sent(),this._pingFailed<2?(this._pingFailed++,this.heartbeat()):this.close(T.HeartbeatPingError),[3,3];case 3:return[2]}}))}))}),t?0:this._context.appConfig.realtimePingInterval)},t}(),q={target:"database",entity:function(){var t,e=this.platform,n=e.adapter,r=e.runtime;t=n.wsClass,P=t,k(r)}},B={name:"realtime",IIFE:!0,entity:function(){this.prototype.wsClientClass=M}};try{cloudbase.registerComponent(B),cloudbase.registerHook(q)}catch(t){}function F(t){try{t.registerComponent(B),t.registerHook(q)}catch(t){console.warn(t)}}},614:function(t,e,n){"use strict";n.r(e),n.d(e,{registerStorage:function(){return _}});var r=n(650),o=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},i=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},s=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},a=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},c=r.constants.getSdkName,u=r.constants.ERRORS,f=r.constants.COMMUNITY_SITE_URL,l=r.utils.isArray,h=r.utils.isString,p=r.utils.isPalinObject,d=r.utils.execCallback,y=r.helpers.catchErrorsDecorator,g="storage",v=new(function(){function t(){}return t.prototype.uploadFile=function(t,e){return s(this,void 0,void 0,(function(){var n,r,o,i,s,f,l,p,y,v,m,_,w,b,E;return a(this,(function(a){switch(a.label){case 0:if(n=t.cloudPath,r=t.filePath,o=t.onUploadProgress,!h(n)||!r)throw new Error(JSON.stringify({code:u.INVALID_PARAMS,msg:"[".concat(g,".uploadFile] invalid params")}));return[4,(i=this.request).send("storage.getUploadMetadata",{path:n})];case 1:return s=a.sent(),f=s.data,l=f.url,p=f.authorization,y=f.token,v=f.fileId,m=f.cosFileId,_=f.download_url,w=s.requestId,b={key:n,signature:p,"x-cos-meta-fileid":m,success_action_status:"201","x-cos-security-token":y},[4,i.upload({url:l,data:b,file:r,name:n,onUploadProgress:o})];case 2:return 201===(E=a.sent()).statusCode?[2,d(e,null,{fileID:v,download_url:_,requestId:w})]:[2,d(e,new Error("[".concat(c(),"][").concat(u.OPERATION_FAIL,"][").concat(g,"]:").concat(E.data)))]}}))}))},t.prototype.getUploadMetadata=function(t,e){return s(this,void 0,void 0,(function(){var n,r,o,i,s;return a(this,(function(a){switch(a.label){case 0:if(n=t.cloudPath,!h(n))throw new Error(JSON.stringify({code:u.INVALID_PARAMS,msg:"[".concat(g,".getUploadMetadata] invalid cloudPath")}));r=this.request,o="storage.getUploadMetadata",a.label=1;case 1:return a.trys.push([1,3,,4]),[4,r.send(o,{path:n})];case 2:return i=a.sent(),[2,d(e,null,i)];case 3:return s=a.sent(),[2,d(e,s)];case 4:return[2]}}))}))},t.prototype.deleteFile=function(t,e){return s(this,void 0,void 0,(function(){var n,r,o,i,s,c;return a(this,(function(a){switch(a.label){case 0:if(!(n=t.fileList)||!l(n)||0===n.length)throw new Error(JSON.stringify({code:u.INVALID_PARAMS,msg:"[".concat(g,".deleteFile] fileList must not be empty")}));for(r=0,o=n;r<o.length;r++)if(!(i=o[r])||!h(i))throw new Error(JSON.stringify({code:u.INVALID_PARAMS,msg:"[".concat(g,".deleteFile] fileID must be string")}));return[4,this.request.send("storage.batchDeleteFile",{fileid_list:n})];case 1:return(s=a.sent()).code?[2,d(e,null,s)]:(c={fileList:s.data.delete_list,requestId:s.requestId},[2,d(e,null,c)])}}))}))},t.prototype.getTempFileURL=function(t,e){return s(this,void 0,void 0,(function(){var n,r,o,i,s,c;return a(this,(function(a){switch(a.label){case 0:if(!(n=t.fileList)||!l(n)||0===n.length)throw new Error(JSON.stringify({code:u.INVALID_PARAMS,msg:"[".concat(g,".getTempFileURL] fileList must not be empty")}));for(r=[],o=0,i=n;o<i.length;o++)if(s=i[o],p(s)){if(!s.hasOwnProperty("fileID")||!s.hasOwnProperty("maxAge"))throw new Error(JSON.stringify({code:u.INVALID_PARAMS,msg:"[".concat(g,".getTempFileURL] file info must include fileID and maxAge")}));r.push({fileid:s.fileID,max_age:s.maxAge})}else{if(!h(s))throw new Error(JSON.stringify({code:u.INVALID_PARAMS,msg:"[".concat(g,".getTempFileURL] invalid fileList")}));r.push({fileid:s})}return[4,this.request.send("storage.batchGetDownloadUrl",{file_list:r})];case 1:return(c=a.sent()).code?[2,d(e,null,c)]:[2,d(e,null,{fileList:c.data.download_list,requestId:c.requestId})]}}))}))},t.prototype.downloadFile=function(t,e){return s(this,void 0,void 0,(function(){var n,r,o,i,s,c;return a(this,(function(a){switch(a.label){case 0:if(n=t.fileID,!h(n))throw new Error(JSON.stringify({code:u.INVALID_PARAMS,msg:"[".concat(g,".getTempFileURL] fileID must be string")}));return[4,this.getTempFileURL.call(this,{fileList:[{fileID:n,maxAge:600}]})];case 1:return r=a.sent(),"SUCCESS"!==(o=r.fileList[0]).code?[2,d(e,o)]:(i=this.request,s=encodeURI(o.download_url),[4,i.download({url:s})]);case 2:return c=a.sent(),[2,d(e,null,c)]}}))}))},o([y({customInfo:{className:"Cloudbase",methodName:"uploadFile"},title:"上传文件失败",messages:["请确认以下各项:"," 1 - 调用 uploadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f)]}),i("design:type",Function),i("design:paramtypes",[Object,Function]),i("design:returntype",Promise)],t.prototype,"uploadFile",null),o([y({customInfo:{className:"Cloudbase",methodName:"getUploadMetadata"},title:"获取上传元信息失败",messages:["请确认以下各项:"," 1 - 调用 getUploadMetadata() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f)]}),i("design:type",Function),i("design:paramtypes",[Object,Function]),i("design:returntype",Promise)],t.prototype,"getUploadMetadata",null),o([y({customInfo:{className:"Cloudbase",methodName:"deleteFile"},title:"删除文件失败",messages:["请确认以下各项:"," 1 - 调用 deleteFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f)]}),i("design:type",Function),i("design:paramtypes",[Object,Function]),i("design:returntype",Promise)],t.prototype,"deleteFile",null),o([y({customInfo:{className:"Cloudbase",methodName:"getTempFileURL"},title:"获取文件下载链接",messages:["请确认以下各项:"," 1 - 调用 getTempFileURL() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f)]}),i("design:type",Function),i("design:paramtypes",[Object,Function]),i("design:returntype",Promise)],t.prototype,"getTempFileURL",null),o([y({customInfo:{className:"Cloudbase",methodName:"downloadFile"},title:"下载文件失败",messages:["请确认以下各项:"," 1 - 调用 downloadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f)]}),i("design:type",Function),i("design:paramtypes",[Object,Function]),i("design:returntype",Promise)],t.prototype,"downloadFile",null),t}()),m={name:g,entity:{uploadFile:v.uploadFile,deleteFile:v.deleteFile,getTempFileURL:v.getTempFileURL,downloadFile:v.downloadFile,getUploadMetadata:v.getUploadMetadata}};try{cloudbase.registerComponent(m)}catch(t){}function _(t){try{t.registerComponent(m)}catch(t){console.warn(t)}}},182:function(t,e,n){"use strict";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};Object.defineProperty(e,"__esModule",{value:!0}),e.useDefaultAdapter=e.useAdapters=e.RUNTIME=void 0;var s,a=i(n(274)),c=n(616);!function(t){t.WEB="web",t.WX_MP="wx_mp"}(s=e.RUNTIME||(e.RUNTIME={})),e.useAdapters=function(t){for(var e=0,n=(0,c.isArray)(t)?t:[t];e<n.length;e++){var r=n[e],o=r.isMatch,i=r.genAdapter,s=r.runtime;if(o())return{adapter:i(),runtime:s}}},e.useDefaultAdapter=function(){return{adapter:a.genAdapter(),runtime:s.WEB}}},274:function(t,e,n){"use strict";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)},s=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.WebRequest=e.genAdapter=void 0;var c=n(829),u=n(616),f=n(946),l=function(t){function e(e){var n=t.call(this)||this,r=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return n._timeout=r||0,n._timeoutMsg=o||"请求超时",n._restrictedMethods=i||["get","post","upload","download"],n}return o(e,t),e.prototype.get=function(t){return this._request(i(i({},t),{method:"get"}),this._restrictedMethods.includes("get"))},e.prototype.post=function(t){return this._request(i(i({},t),{method:"post"}),this._restrictedMethods.includes("post"))},e.prototype.put=function(t){return this._request(i(i({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,n=t.file,r=t.name,o=new FormData;for(var s in e)o.append(s,e[s]);return o.append("key",r),o.append("file",n),this._request(i(i({},t),{data:o,method:"post"}),this._restrictedMethods.includes("upload"))},e.prototype.download=function(t){return s(this,void 0,void 0,(function(){var e,n,r,o;return a(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.get(i(i({},t),{headers:{},responseType:"blob"}))];case 1:return e=s.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 s.sent(),[3,3];case 3:return[2,new Promise((function(e){e({statusCode:200,tempFilePath:t.url})}))]}}))}))},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,s,a=t.url,c=t.headers,l=void 0===c?{}:c,h=t.data,p=t.responseType,d=t.withCredentials,y=t.body,g=t.onUploadProgress,v=(0,u.formatUrl)((0,f.getProtocol)(),a,"get"===r?h:{}),m=new XMLHttpRequest;for(var _ in m.open(r,v),p&&(m.responseType=p),l)m.setRequestHeader(_,l[_]);g&&m.upload.addEventListener("progress",g),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"===p?m.response:JSON.parse(m.responseText)}catch(e){t.data="blob"===p?m.response:m.responseText}clearTimeout(i),o(t)}},e&&n._timeout&&(i=setTimeout((function(){console.warn(n._timeoutMsg),m.abort()}),n._timeout)),s=(0,u.isFormData)(h)?h:"application/x-www-form-urlencoded"===l["content-type"]?(0,u.toQueryString)(h):y||(h?JSON.stringify(h):void 0),d&&(m.withCredentials=!0),m.send(s)}))},e}(c.AbstractSDKRequest);e.WebRequest=l,e.genAdapter=function(){return{root:window,reqClass:l,wsClass:WebSocket,localStorage:localStorage,sessionStorage:sessionStorage}}},946:function(t,e){"use strict";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="undefined"!=typeof location&&"http:"===location.protocol?"http:":"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"},205:function(t,e){"use strict";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"}},794:function(t,e,n){"use strict";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(946),e),o(n(205),e)},718:function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.catchErrorsDecorator=void 0;var i=n(616),s=n(794),a=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(a=-1!==navigator.userAgent.indexOf("Firefox"));var c=a?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,u=/https?\:\/\/.+\:\d*\/.*\.js\:\d+\:\d+/;function f(t){var e=t.err,n=t.className,r=t.methodName,o=t.sourceLink;if(!o)return null;var i,s=e.stack.split("\n"),c=a?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(n,"\\.descriptor.value\\s*\\[as\\s").concat(r,"\\]\\s*\\(.*\\)$")),f=a?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(n,"\\.descriptor.value\\s*\\[as\\s").concat(r,"\\]")),l=s.findIndex((function(t){return c.test(t)}));if(-1!==l){var h=s.filter((function(t,e){return e>l}));h.unshift(s[l].replace(f,"".concat(n,".").concat(r)).replace(u,o)),(i=new Error).stack="".concat(a?"@debugger":"Error","\n").concat(h.join("\n"))}return i}e.catchErrorsDecorator=function(t){var e=t.mode,n=void 0===e?"async":e,a=t.customInfo,l=void 0===a?{}:a,h=t.title,p=t.messages,d=void 0===p?[]:p;return function(t,e,a){if(s.IS_DEBUG_MODE){var p=l.className||t.constructor.name,y=l.methodName||e,g=a.value,v=function(){var t="",e=(new Error).stack.split("\n"),n=e.findIndex((function(t){return c.test(t)}));if(-1!==n){var r=u.exec(e[n+1]||"");t=r?r[0]:""}return t}();a.value="sync"===n?function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=f({err:new Error,className:p,methodName:y,sourceLink:v});try{return g.apply(this,t)}catch(t){var r=t,o=t.message,s={title:h||"".concat(p,".").concat(y," failed"),content:[{type:"error",body:t}]};if(o&&/^\{.*\}$/.test(o)){var a=JSON.parse(o);s.subtitle=o,a.code&&(n?(n.code=a.code,n.msg=a.msg):(t.code=a.code,t.message=a.msg),r=n||t,s.content=d.map((function(t){return{type:"info",body:t}})))}throw(0,i.printGroupLog)(s),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,s,a,c;return o(this,(function(o){switch(o.label){case 0:e=f({err:new Error,className:p,methodName:y,sourceLink:v}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,g.apply(this,t)];case 2:return[2,o.sent()];case 3:throw n=o.sent(),r=n,s=n.message,a={title:h||"".concat(p,".").concat(y," failed"),content:[{type:"error",body:n}]},s&&/^\{.*\}$/.test(s)&&(c=JSON.parse(s),a.subtitle=c,c.code&&(e?(e.code=c.code,e.message=c.msg):(n.code=c.code,n.message=c.msg),r=e||n,a.content=d.map((function(t){return{type:"info",body:t}})))),(0,i.printGroupLog)(a),r;case 4:return[2]}}))}))}}}}},141:function(t,e,n){"use strict";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(718),e)},650:function(t,e,n){"use strict";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};Object.defineProperty(e,"__esModule",{value:!0}),e.helpers=e.utils=e.events=e.cache=e.adapters=e.constants=void 0;var s=i(n(794));e.constants=s;var a=i(n(182));e.adapters=a;var c=i(n(197));e.cache=c;var u=i(n(689));e.events=u;var f=i(n(616));e.utils=f;var l=i(n(141));e.helpers=l},197:function(t,e,n){"use strict";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 s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},s=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.CloudbaseCache=void 0;var a=n(829),c=n(616),u=n(794),f=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}(a.AbstractStorage);function l(t,e){switch(t){case"local":default:return e.localStorage?e.localStorage:((0,c.printWarn)(u.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new f(e.root));case"none":return new f(e.root);case"session":return e.sessionStorage?e.sessionStorage:((0,c.printWarn)(u.ERRORS.INVALID_PARAMS,"sessionStorage is not supported on current platform"),new f(e.root))}}var h=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,s=t.alwaysLocalKeys,a=void 0===s?[]:s;this._platformInfo=r,this._alwaysLocalKeys=a,this._storage||(this._persistence=r.adapter.primaryStorage||e,this._storage=l(this._persistence,r.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._persistence},enumerable:!1,configurable:!0}),t.prototype.updatePersistence=function(t){if("async"!==this.mode){if(t!==this._persistence){var e="local"===this._persistence;this._persistence=t;var n=l(t,this._platformInfo.adapter);for(var r in this.keys){var o=this.keys[r];if(!e||!this._alwaysLocalKeys.includes(r)){var i=this._storage.getItem(o);(0,c.isUndefined)(i)||(0,c.isNull)(i)||(n.setItem(o,i),this._storage.removeItem(o))}}this._storage=n}}else(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use updatePersistenceAsync insteed")},t.prototype.updatePersistenceAsync=function(t){return i(this,void 0,void 0,(function(){var e,n,r,o,i,a,u,f,h;return s(this,(function(s){switch(s.label){case 0:if(t===this._persistence)return[2];for(i in e="local"===this._persistence,this._persistence=t,n=l(t,this._platformInfo.adapter),r=this.keys,o=[],r)o.push(i);a=0,s.label=1;case 1:return a<o.length?(i=o[a])in r?(u=i,f=this.keys[u],e&&this._alwaysLocalKeys.includes(u)?[3,4]:[4,this._storage.getItem(f)]):[3,4]:[3,5];case 2:return h=s.sent(),(0,c.isUndefined)(h)||(0,c.isNull)(h)?[3,4]:(n.setItem(f,h),[4,this._storage.removeItem(f)]);case 3:s.sent(),s.label=4;case 4:return a++,[3,1];case 5:return this._storage=n,[2]}}))}))},t.prototype.setStore=function(t,e,n){if("async"!==this.mode){if(this._storage)try{var r={version:n||"localCachev1",content:e};this._storage.setItem(t,JSON.stringify(r))}catch(t){throw new Error(JSON.stringify({code:u.ERRORS.OPERATION_FAIL,msg:"[".concat((0,u.getSdkName)(),"][").concat(u.ERRORS.OPERATION_FAIL,"]setStore failed"),info:t}))}}else(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,n){return i(this,void 0,void 0,(function(){var r;return s(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=process.env)||void 0===n?void 0:n.tcb_token))return process.env.tcb_token;if(!this._storage)return""}catch(t){return""}e=e||"localCachev1";var r=this._storage.getItem(t);return r&&r.indexOf(e)>=0?JSON.parse(r).content:""}(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){var n;return i(this,void 0,void 0,(function(){var r;return s(this,(function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(n=process.env)||void 0===n?void 0:n.tcb_token))return[2,process.env.tcb_token];if(!this._storage)return[2,""]}catch(t){return[2,""]}return e=e||"localCachev1",[4,this._storage.getItem(t)];case 1:return(r=o.sent())&&r.indexOf(e)>=0?[2,JSON.parse(r).content]:[2,""]}}))}))},t.prototype.removeStore=function(t){"async"!==this.mode?this._storage.removeItem(t):(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},t.prototype.removeStoreAsync=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this._storage.removeItem(t)];case 1:return e.sent(),[2]}}))}))},t}();e.CloudbaseCache=h},689:function(t,e,n){"use strict";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 s=n(616),a=function(t,e){this.data=e||null,this.name=t};e.CloudbaseEvent=a;var c=function(t){function e(e,n){var r=t.call(this,"error",{error:e,data:n})||this;return r.error=e,r}return o(e,t),e}(a);e.IErrorEvent=c;var u=function(){function t(){this._listeners={}}return t.prototype.on=function(t,e){return function(t,e,n){n[t]=n[t]||[],n[t].push(e)}(t,e,this._listeners),this},t.prototype.off=function(t,e){return function(t,e,n){if(null==n?void 0:n[t]){var r=n[t].indexOf(e);-1!==r&&n[t].splice(r,1)}}(t,e,this._listeners),this},t.prototype.fire=function(t,e){if((0,s.isInstanceOf)(t,c))return console.error(t.error),this;var n=(0,s.isString)(t)?new a(t,e||{}):t,r=n.name;if(this._listens(r)){n.target=this;for(var o=0,u=this._listeners[r]?i([],this._listeners[r],!0):[];o<u.length;o++)u[o].call(this,n)}return this},t.prototype._listens=function(t){return this._listeners[t]&&this._listeners[t].length>0},t}();e.CloudbaseEventEmitter=u;var f=new u;e.addEventListener=function(t,e){f.on(t,e)},e.activateEvent=function(t,e){void 0===e&&(e={}),f.fire(t,e)},e.removeEventListener=function(t,e){f.off(t,e)}},616:function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.transformPhone=e.sleep=e.printGroupLog=e.throwError=e.printInfo=e.printError=e.printWarn=e.execCallback=e.createPromiseCallback=e.removeParam=e.getHash=e.getQuery=e.toQueryString=e.createSign=e.formatUrl=e.genSeqId=e.isFormData=e.isInstanceOf=e.isNull=e.isPalinObject=e.isUndefined=e.isString=e.isArray=void 0;var o=r(n(61)),i=r(n(139)),s=r(n(307)),a=n(794);function c(t){var e=i.default.stringify(t);return(e=(e=e.replace(/=+$/,"")).replace(/\+/g,"-")).replace(/\//g,"_")}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.formatUrl=function(t,e,n){void 0===n&&(n={});var r=/\?/.test(e),o="";for(var i in n)""===o?!r&&(e+="?"):o+="&",o+="".concat(i,"=").concat(encodeURIComponent(n[i]));return/^http(s)?\:\/\//.test(e+=o)?e:"".concat(t).concat(e)},e.createSign=function(t,e){var n=c(s.default.parse(JSON.stringify({alg:"HS256",typ:"JWT"}))),r=c(s.default.parse(JSON.stringify(t))),i="".concat(n,".").concat(r),a=c((0,o.default)(i,e));return"".concat(i,".").concat(a)},e.toQueryString=function(t){void 0===t&&(t={});var e=[];for(var n in t)e.push("".concat(n,"=").concat(encodeURIComponent(t[n])));return e.join("&")},e.getQuery=function(t,e){if("undefined"==typeof window)return!1;var n=e||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,a.getSdkName)(),"][").concat(t,"]:").concat(e))},e.printError=function(t,e){console.error({code:t,msg:"[".concat((0,a.getSdkName)(),"][").concat(t,"]:").concat(e)})},e.printInfo=function(t,e){console.log("[".concat((0,a.getSdkName)(),"][").concat(t,"]:").concat(e))},e.throwError=function(t,e){throw new Error(JSON.stringify({code:t,msg:"[".concat((0,a.getSdkName)(),"][").concat(t,"]:").concat(e)}))},e.printGroupLog=function(t){var e=t.title,n=t.subtitle,r=void 0===n?"":n,o=t.content,i=void 0===o?[]:o,s=t.printTrace,a=void 0!==s&&s,c=t.collapsed;void 0!==c&&c?console.groupCollapsed(e,r):console.group(e,r);for(var u=0,f=i;u<f.length;u++){var l=f[u],h=l.type,p=l.body;switch(h){case"info":console.log(p);break;case"warn":console.warn(p);break;case"error":console.error(p)}}a&&console.trace("stack trace:"),console.groupEnd()},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)}},359:function(t,e,n){var r;t.exports=(r=r||function(t){var e;if("undefined"!=typeof window&&window.crypto&&(e=window.crypto),"undefined"!=typeof self&&self.crypto&&(e=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(e=globalThis.crypto),!e&&"undefined"!=typeof window&&window.msCrypto&&(e=window.msCrypto),!e&&void 0!==n.g&&n.g.crypto&&(e=n.g.crypto),!e)try{e=n(633)}catch(t){}var r=function(){if(e){if("function"==typeof e.getRandomValues)try{return e.getRandomValues(new Uint32Array(1))[0]}catch(t){}if("function"==typeof e.randomBytes)try{return e.randomBytes(4).readInt32LE()}catch(t){}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||function(){function t(){}return function(e){var n;return t.prototype=e,n=new t,t.prototype=null,n}}(),i={},s=i.lib={},a=s.Base={extend:function(t){var e=o(this);return t&&e.mixIn(t),e.hasOwnProperty("init")&&this.init!==e.init||(e.init=function(){e.$super.init.apply(this,arguments)}),e.init.prototype=e,e.$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},c=s.WordArray=a.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:4*t.length},toString:function(t){return(t||f).stringify(this)},concat:function(t){var e=this.words,n=t.words,r=this.sigBytes,o=t.sigBytes;if(this.clamp(),r%4)for(var i=0;i<o;i++){var s=n[i>>>2]>>>24-i%4*8&255;e[r+i>>>2]|=s<<24-(r+i)%4*8}else for(var a=0;a<o;a+=4)e[r+a>>>2]=n[a>>>2];return this.sigBytes+=o,this},clamp:function(){var e=this.words,n=this.sigBytes;e[n>>>2]&=4294967295<<32-n%4*8,e.length=t.ceil(n/4)},clone:function(){var t=a.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],n=0;n<t;n+=4)e.push(r());return new c.init(e,t)}}),u=i.enc={},f=u.Hex={stringify:function(t){for(var e=t.words,n=t.sigBytes,r=[],o=0;o<n;o++){var i=e[o>>>2]>>>24-o%4*8&255;r.push((i>>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r<e;r+=2)n[r>>>3]|=parseInt(t.substr(r,2),16)<<24-r%8*4;return new c.init(n,e/2)}},l=u.Latin1={stringify:function(t){for(var e=t.words,n=t.sigBytes,r=[],o=0;o<n;o++){var i=e[o>>>2]>>>24-o%4*8&255;r.push(String.fromCharCode(i))}return r.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r<e;r++)n[r>>>2]|=(255&t.charCodeAt(r))<<24-r%4*8;return new c.init(n,e)}},h=u.Utf8={stringify:function(t){try{return decodeURIComponent(escape(l.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return l.parse(unescape(encodeURIComponent(t)))}},p=s.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=h.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var n,r=this._data,o=r.words,i=r.sigBytes,s=this.blockSize,a=i/(4*s),u=(a=e?t.ceil(a):t.max((0|a)-this._minBufferSize,0))*s,f=t.min(4*u,i);if(u){for(var l=0;l<u;l+=s)this._doProcessBlock(o,l);n=o.splice(0,u),r.sigBytes-=f}return new c.init(n,f)},clone:function(){var t=a.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0}),d=(s.Hasher=p.extend({cfg:a.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){p.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){return t&&this._append(t),this._doFinalize()},blockSize:16,_createHelper:function(t){return function(e,n){return new t.init(n).finalize(e)}},_createHmacHelper:function(t){return function(e,n){return new d.HMAC.init(t,n).finalize(e)}}}),i.algo={});return i}(Math),r)},139:function(t,e,n){var r,o,i;t.exports=(r=n(359),i=(o=r).lib.WordArray,o.enc.Base64={stringify:function(t){var e=t.words,n=t.sigBytes,r=this._map;t.clamp();for(var o=[],i=0;i<n;i+=3)for(var s=(e[i>>>2]>>>24-i%4*8&255)<<16|(e[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|e[i+2>>>2]>>>24-(i+2)%4*8&255,a=0;a<4&&i+.75*a<n;a++)o.push(r.charAt(s>>>6*(3-a)&63));var c=r.charAt(64);if(c)for(;o.length%4;)o.push(c);return o.join("")},parse:function(t){var e=t.length,n=this._map,r=this._reverseMap;if(!r){r=this._reverseMap=[];for(var o=0;o<n.length;o++)r[n.charCodeAt(o)]=o}var s=n.charAt(64);if(s){var a=t.indexOf(s);-1!==a&&(e=a)}return function(t,e,n){for(var r=[],o=0,s=0;s<e;s++)if(s%4){var a=n[t.charCodeAt(s-1)]<<s%4*2|n[t.charCodeAt(s)]>>>6-s%4*2;r[o>>>2]|=a<<24-o%4*8,o++}return i.create(r,o)}(t,e,r)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},r.enc.Base64)},307:function(t,e,n){t.exports=n(359).enc.Utf8},61:function(t,e,n){var r;t.exports=(r=n(359),n(93),n(423),r.HmacSHA256)},423:function(t,e,n){var r,o,i;t.exports=(o=(r=n(359)).lib.Base,i=r.enc.Utf8,void(r.algo.HMAC=o.extend({init:function(t,e){t=this._hasher=new t.init,"string"==typeof e&&(e=i.parse(e));var n=t.blockSize,r=4*n;e.sigBytes>r&&(e=t.finalize(e)),e.clamp();for(var o=this._oKey=e.clone(),s=this._iKey=e.clone(),a=o.words,c=s.words,u=0;u<n;u++)a[u]^=1549556828,c[u]^=909522486;o.sigBytes=s.sigBytes=r,this.reset()},reset:function(){var t=this._hasher;t.reset(),t.update(this._iKey)},update:function(t){return this._hasher.update(t),this},finalize:function(t){var e=this._hasher,n=e.finalize(t);return e.reset(),e.finalize(this._oKey.clone().concat(n))}})))},93:function(t,e,n){var r;t.exports=(r=n(359),function(t){var e=r,n=e.lib,o=n.WordArray,i=n.Hasher,s=e.algo,a=[],c=[];!function(){function e(e){for(var n=t.sqrt(e),r=2;r<=n;r++)if(!(e%r))return!1;return!0}function n(t){return 4294967296*(t-(0|t))|0}for(var r=2,o=0;o<64;)e(r)&&(o<8&&(a[o]=n(t.pow(r,.5))),c[o]=n(t.pow(r,1/3)),o++),r++}();var u=[],f=s.SHA256=i.extend({_doReset:function(){this._hash=new o.init(a.slice(0))},_doProcessBlock:function(t,e){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],s=n[3],a=n[4],f=n[5],l=n[6],h=n[7],p=0;p<64;p++){if(p<16)u[p]=0|t[e+p];else{var d=u[p-15],y=(d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3,g=u[p-2],v=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;u[p]=y+u[p-7]+v+u[p-16]}var m=r&o^r&i^o&i,_=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),w=h+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&f^~a&l)+c[p]+u[p];h=l,l=f,f=a,a=s+w|0,s=i,i=o,o=r,r=w+(_+m)|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+a|0,n[5]=n[5]+f|0,n[6]=n[6]+l|0,n[7]=n[7]+h|0},_doFinalize:function(){var e=this._data,n=e.words,r=8*this._nDataBytes,o=8*e.sigBytes;return n[o>>>5]|=128<<24-o%32,n[14+(o+64>>>9<<4)]=t.floor(r/4294967296),n[15+(o+64>>>9<<4)]=r,e.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=i._createHelper(f),e.HmacSHA256=i._createHmacHelper(f)}(Math),r.SHA256)},907:function(t,e,n){t=n.nmd(t);var r="__lodash_hash_undefined__",o=9007199254740991,i="[object Arguments]",s="[object Boolean]",a="[object Date]",c="[object Function]",u="[object GeneratorFunction]",f="[object Map]",l="[object Number]",h="[object Object]",p="[object Promise]",d="[object RegExp]",y="[object Set]",g="[object String]",v="[object Symbol]",m="[object WeakMap]",_="[object ArrayBuffer]",w="[object DataView]",b="[object Float32Array]",E="[object Float64Array]",S="[object Int8Array]",I="[object Int16Array]",O="[object Int32Array]",A="[object Uint8Array]",T="[object Uint8ClampedArray]",N="[object Uint16Array]",R="[object Uint32Array]",P=/\w*$/,x=/^\[object .+?Constructor\]$/,L=/^(?:0|[1-9]\d*)$/,C={};C[i]=C["[object Array]"]=C[_]=C[w]=C[s]=C[a]=C[b]=C[E]=C[S]=C[I]=C[O]=C[f]=C[l]=C[h]=C[d]=C[y]=C[g]=C[v]=C[A]=C[T]=C[N]=C[R]=!0,C["[object Error]"]=C[c]=C[m]=!1;var k="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,U="object"==typeof self&&self&&self.Object===Object&&self,j=k||U||Function("return this")(),D=e&&!e.nodeType&&e,M=D&&t&&!t.nodeType&&t,q=M&&M.exports===D;function B(t,e){return t.set(e[0],e[1]),t}function F(t,e){return t.add(e),t}function W(t,e,n,r){var o=-1,i=t?t.length:0;for(r&&i&&(n=t[++o]);++o<i;)n=e(n,t[o],o,t);return n}function $(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}function H(t){var e=-1,n=Array(t.size);return t.forEach((function(t,r){n[++e]=[r,t]})),n}function G(t,e){return function(n){return t(e(n))}}function K(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=t})),n}var V,J=Array.prototype,Y=Function.prototype,z=Object.prototype,X=j["__core-js_shared__"],Z=(V=/[^.]+$/.exec(X&&X.keys&&X.keys.IE_PROTO||""))?"Symbol(src)_1."+V:"",Q=Y.toString,tt=z.hasOwnProperty,et=z.toString,nt=RegExp("^"+Q.call(tt).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),rt=q?j.Buffer:void 0,ot=j.Symbol,it=j.Uint8Array,st=G(Object.getPrototypeOf,Object),at=Object.create,ct=z.propertyIsEnumerable,ut=J.splice,ft=Object.getOwnPropertySymbols,lt=rt?rt.isBuffer:void 0,ht=G(Object.keys,Object),pt=jt(j,"DataView"),dt=jt(j,"Map"),yt=jt(j,"Promise"),gt=jt(j,"Set"),vt=jt(j,"WeakMap"),mt=jt(Object,"create"),_t=Ft(pt),wt=Ft(dt),bt=Ft(yt),Et=Ft(gt),St=Ft(vt),It=ot?ot.prototype:void 0,Ot=It?It.valueOf:void 0;function At(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function Tt(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function Nt(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function Rt(t){this.__data__=new Tt(t)}function Pt(t,e,n){var r=t[e];tt.call(t,e)&&Wt(r,n)&&(void 0!==n||e in t)||(t[e]=n)}function xt(t,e){for(var n=t.length;n--;)if(Wt(t[n][0],e))return n;return-1}function Lt(t,e,n,r,o,p,m){var x;if(r&&(x=p?r(t,o,p,m):r(t)),void 0!==x)return x;if(!Vt(t))return t;var L=$t(t);if(L){if(x=function(t){var e=t.length,n=t.constructor(e);return e&&"string"==typeof t[0]&&tt.call(t,"index")&&(n.index=t.index,n.input=t.input),n}(t),!e)return function(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e}(t,x)}else{var k=Mt(t),U=k==c||k==u;if(Gt(t))return function(t,e){if(e)return t.slice();var n=new t.constructor(t.length);return t.copy(n),n}(t,e);if(k==h||k==i||U&&!p){if($(t))return p?t:{};if(x=function(t){return"function"!=typeof t.constructor||Bt(t)?{}:Vt(e=st(t))?at(e):{};var e}(U?{}:t),!e)return function(t,e){return kt(t,Dt(t),e)}(t,function(t,e){return t&&kt(e,Jt(e),t)}(x,t))}else{if(!C[k])return p?t:{};x=function(t,e,n,r){var o,i=t.constructor;switch(e){case _:return Ct(t);case s:case a:return new i(+t);case w:return function(t,e){var n=e?Ct(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}(t,r);case b:case E:case S:case I:case O:case A:case T:case N:case R:return function(t,e){var n=e?Ct(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}(t,r);case f:return function(t,e,n){return W(e?n(H(t),!0):H(t),B,new t.constructor)}(t,r,n);case l:case g:return new i(t);case d:return function(t){var e=new t.constructor(t.source,P.exec(t));return e.lastIndex=t.lastIndex,e}(t);case y:return function(t,e,n){return W(e?n(K(t),!0):K(t),F,new t.constructor)}(t,r,n);case v:return o=t,Ot?Object(Ot.call(o)):{}}}(t,k,Lt,e)}}m||(m=new Rt);var j=m.get(t);if(j)return j;if(m.set(t,x),!L)var D=n?function(t){return function(t,e,n){var r=e(t);return $t(t)?r:function(t,e){for(var n=-1,r=e.length,o=t.length;++n<r;)t[o+n]=e[n];return t}(r,n(t))}(t,Jt,Dt)}(t):Jt(t);return function(t,e){for(var n=-1,r=t?t.length:0;++n<r&&!1!==e(t[n],n););}(D||t,(function(o,i){D&&(o=t[i=o]),Pt(x,i,Lt(o,e,n,r,i,t,m))})),x}function Ct(t){var e=new t.constructor(t.byteLength);return new it(e).set(new it(t)),e}function kt(t,e,n,r){n||(n={});for(var o=-1,i=e.length;++o<i;){var s=e[o],a=r?r(n[s],t[s],s,n,t):void 0;Pt(n,s,void 0===a?t[s]:a)}return n}function Ut(t,e){var n,r,o=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof e?"string":"hash"]:o.map}function jt(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return function(t){return!(!Vt(t)||(e=t,Z&&Z in e))&&(Kt(t)||$(t)?nt:x).test(Ft(t));var e}(n)?n:void 0}At.prototype.clear=function(){this.__data__=mt?mt(null):{}},At.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},At.prototype.get=function(t){var e=this.__data__;if(mt){var n=e[t];return n===r?void 0:n}return tt.call(e,t)?e[t]:void 0},At.prototype.has=function(t){var e=this.__data__;return mt?void 0!==e[t]:tt.call(e,t)},At.prototype.set=function(t,e){return this.__data__[t]=mt&&void 0===e?r:e,this},Tt.prototype.clear=function(){this.__data__=[]},Tt.prototype.delete=function(t){var e=this.__data__,n=xt(e,t);return!(n<0||(n==e.length-1?e.pop():ut.call(e,n,1),0))},Tt.prototype.get=function(t){var e=this.__data__,n=xt(e,t);return n<0?void 0:e[n][1]},Tt.prototype.has=function(t){return xt(this.__data__,t)>-1},Tt.prototype.set=function(t,e){var n=this.__data__,r=xt(n,t);return r<0?n.push([t,e]):n[r][1]=e,this},Nt.prototype.clear=function(){this.__data__={hash:new At,map:new(dt||Tt),string:new At}},Nt.prototype.delete=function(t){return Ut(this,t).delete(t)},Nt.prototype.get=function(t){return Ut(this,t).get(t)},Nt.prototype.has=function(t){return Ut(this,t).has(t)},Nt.prototype.set=function(t,e){return Ut(this,t).set(t,e),this},Rt.prototype.clear=function(){this.__data__=new Tt},Rt.prototype.delete=function(t){return this.__data__.delete(t)},Rt.prototype.get=function(t){return this.__data__.get(t)},Rt.prototype.has=function(t){return this.__data__.has(t)},Rt.prototype.set=function(t,e){var n=this.__data__;if(n instanceof Tt){var r=n.__data__;if(!dt||r.length<199)return r.push([t,e]),this;n=this.__data__=new Nt(r)}return n.set(t,e),this};var Dt=ft?G(ft,Object):function(){return[]},Mt=function(t){return et.call(t)};function qt(t,e){return!!(e=null==e?o:e)&&("number"==typeof t||L.test(t))&&t>-1&&t%1==0&&t<e}function Bt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||z)}function Ft(t){if(null!=t){try{return Q.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function Wt(t,e){return t===e||t!=t&&e!=e}(pt&&Mt(new pt(new ArrayBuffer(1)))!=w||dt&&Mt(new dt)!=f||yt&&Mt(yt.resolve())!=p||gt&&Mt(new gt)!=y||vt&&Mt(new vt)!=m)&&(Mt=function(t){var e=et.call(t),n=e==h?t.constructor:void 0,r=n?Ft(n):void 0;if(r)switch(r){case _t:return w;case wt:return f;case bt:return p;case Et:return y;case St:return m}return e});var $t=Array.isArray;function Ht(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=o}(t.length)&&!Kt(t)}var Gt=lt||function(){return!1};function Kt(t){var e=Vt(t)?et.call(t):"";return e==c||e==u}function Vt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Jt(t){return Ht(t)?function(t,e){var n=$t(t)||function(t){return function(t){return function(t){return!!t&&"object"==typeof t}(t)&&Ht(t)}(t)&&tt.call(t,"callee")&&(!ct.call(t,"callee")||et.call(t)==i)}(t)?function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}(t.length,String):[],r=n.length,o=!!r;for(var s in t)!e&&!tt.call(t,s)||o&&("length"==s||qt(s,r))||n.push(s);return n}(t):function(t){if(!Bt(t))return ht(t);var e=[];for(var n in Object(t))tt.call(t,n)&&"constructor"!=n&&e.push(n);return e}(t)}t.exports=function(t){return Lt(t,!0,!0)}},880:function(t,e,n){var r,o="__lodash_hash_undefined__",i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/,a=/^\./,c=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,u=/\\(\\)?/g,f=/^\[object .+?Constructor\]$/,l=/^(?:0|[1-9]\d*)$/,h="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,p="object"==typeof self&&self&&self.Object===Object&&self,d=h||p||Function("return this")(),y=Array.prototype,g=Function.prototype,v=Object.prototype,m=d["__core-js_shared__"],_=(r=/[^.]+$/.exec(m&&m.keys&&m.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",w=g.toString,b=v.hasOwnProperty,E=v.toString,S=RegExp("^"+w.call(b).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),I=d.Symbol,O=y.splice,A=j(d,"Map"),T=j(Object,"create"),N=I?I.prototype:void 0,R=N?N.toString:void 0;function P(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function x(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function L(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function C(t,e,n){var r=t[e];b.call(t,e)&&F(r,n)&&(void 0!==n||e in t)||(t[e]=n)}function k(t,e){for(var n=t.length;n--;)if(F(t[n][0],e))return n;return-1}function U(t,e){var n,r,o=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof e?"string":"hash"]:o.map}function j(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return function(t){if(!$(t)||_&&_ in t)return!1;var e=function(t){var e=$(t)?E.call(t):"";return"[object Function]"==e||"[object GeneratorFunction]"==e}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?S:f;return e.test(function(t){if(null!=t){try{return w.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}(n)?n:void 0}function D(t,e){return!!(e=null==e?9007199254740991:e)&&("number"==typeof t||l.test(t))&&t>-1&&t%1==0&&t<e}P.prototype.clear=function(){this.__data__=T?T(null):{}},P.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},P.prototype.get=function(t){var e=this.__data__;if(T){var n=e[t];return n===o?void 0:n}return b.call(e,t)?e[t]:void 0},P.prototype.has=function(t){var e=this.__data__;return T?void 0!==e[t]:b.call(e,t)},P.prototype.set=function(t,e){return this.__data__[t]=T&&void 0===e?o:e,this},x.prototype.clear=function(){this.__data__=[]},x.prototype.delete=function(t){var e=this.__data__,n=k(e,t);return!(n<0||(n==e.length-1?e.pop():O.call(e,n,1),0))},x.prototype.get=function(t){var e=this.__data__,n=k(e,t);return n<0?void 0:e[n][1]},x.prototype.has=function(t){return k(this.__data__,t)>-1},x.prototype.set=function(t,e){var n=this.__data__,r=k(n,t);return r<0?n.push([t,e]):n[r][1]=e,this},L.prototype.clear=function(){this.__data__={hash:new P,map:new(A||x),string:new P}},L.prototype.delete=function(t){return U(this,t).delete(t)},L.prototype.get=function(t){return U(this,t).get(t)},L.prototype.has=function(t){return U(this,t).has(t)},L.prototype.set=function(t,e){return U(this,t).set(t,e),this};var M=B((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(H(t))return R?R.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}(e);var n=[];return a.test(t)&&n.push(""),t.replace(c,(function(t,e,r,o){n.push(r?o.replace(u,"$1"):e||t)})),n}));function q(t){if("string"==typeof t||H(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function B(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError("Expected a function");var n=function(){var r=arguments,o=e?e.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=t.apply(this,r);return n.cache=i.set(o,s),s};return n.cache=new(B.Cache||L),n}function F(t,e){return t===e||t!=t&&e!=e}B.Cache=L;var W=Array.isArray;function $(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function H(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==E.call(t)}t.exports=function(t,e,n){return null==t?t:function(t,e,n,r){if(!$(t))return t;e=function(t,e){if(W(t))return!1;var n=typeof t;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=t&&!H(t))||s.test(t)||!i.test(t)||null!=e&&t in Object(e)}(e,t)?[e]:function(t){return W(t)?t:M(t)}(e);for(var o=-1,a=e.length,c=a-1,u=t;null!=u&&++o<a;){var f=q(e[o]),l=n;if(o!=c){var h=u[f];void 0===(l=r?r(h,f,u):void 0)&&(l=$(h)?h:D(e[o+1])?[]:{})}C(u,f,l),u=u[f]}return t}(t,e,n)}},373:function(t,e,n){var r,o="__lodash_hash_undefined__",i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/,a=/^\./,c=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,u=/\\(\\)?/g,f=/^\[object .+?Constructor\]$/,l="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,h="object"==typeof self&&self&&self.Object===Object&&self,p=l||h||Function("return this")(),d=Array.prototype,y=Function.prototype,g=Object.prototype,v=p["__core-js_shared__"],m=(r=/[^.]+$/.exec(v&&v.keys&&v.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",_=y.toString,w=g.hasOwnProperty,b=g.toString,E=RegExp("^"+_.call(w).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),S=p.Symbol,I=d.splice,O=U(p,"Map"),A=U(Object,"create"),T=S?S.prototype:void 0,N=T?T.toString:void 0;function R(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function P(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function x(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function L(t,e){for(var n,r,o=t.length;o--;)if((n=t[o][0])===(r=e)||n!=n&&r!=r)return o;return-1}function C(t){return B(t)?t:D(t)}function k(t,e){var n,r,o=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof e?"string":"hash"]:o.map}function U(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return function(t){if(!F(t)||m&&m in t)return!1;var e=function(t){var e=F(t)?b.call(t):"";return"[object Function]"==e||"[object GeneratorFunction]"==e}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?E:f;return e.test(function(t){if(null!=t){try{return _.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}(n)?n:void 0}function j(t,e){if(B(t))return!1;var n=typeof t;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=t&&!W(t))||s.test(t)||!i.test(t)||null!=e&&t in Object(e)}R.prototype.clear=function(){this.__data__=A?A(null):{}},R.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},R.prototype.get=function(t){var e=this.__data__;if(A){var n=e[t];return n===o?void 0:n}return w.call(e,t)?e[t]:void 0},R.prototype.has=function(t){var e=this.__data__;return A?void 0!==e[t]:w.call(e,t)},R.prototype.set=function(t,e){return this.__data__[t]=A&&void 0===e?o:e,this},P.prototype.clear=function(){this.__data__=[]},P.prototype.delete=function(t){var e=this.__data__,n=L(e,t);return!(n<0||(n==e.length-1?e.pop():I.call(e,n,1),0))},P.prototype.get=function(t){var e=this.__data__,n=L(e,t);return n<0?void 0:e[n][1]},P.prototype.has=function(t){return L(this.__data__,t)>-1},P.prototype.set=function(t,e){var n=this.__data__,r=L(n,t);return r<0?n.push([t,e]):n[r][1]=e,this},x.prototype.clear=function(){this.__data__={hash:new R,map:new(O||P),string:new R}},x.prototype.delete=function(t){return k(this,t).delete(t)},x.prototype.get=function(t){return k(this,t).get(t)},x.prototype.has=function(t){return k(this,t).has(t)},x.prototype.set=function(t,e){return k(this,t).set(t,e),this};var D=q((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(W(t))return N?N.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}(e);var n=[];return a.test(t)&&n.push(""),t.replace(c,(function(t,e,r,o){n.push(r?o.replace(u,"$1"):e||t)})),n}));function M(t){if("string"==typeof t||W(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function q(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError("Expected a function");var n=function(){var r=arguments,o=e?e.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=t.apply(this,r);return n.cache=i.set(o,s),s};return n.cache=new(q.Cache||x),n}q.Cache=x;var B=Array.isArray;function F(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function W(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==b.call(t)}t.exports=function(t,e){return null==t||function(t,e){t=function(t,e){return 1==e.length?t:function(t,e){for(var n=0,r=(e=j(e,t)?[e]:C(e)).length;null!=t&&n<r;)t=t[M(e[n++])];return n&&n==r?t:void 0}(t,function(t,e,n){var r=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(n=n>o?o:n)<0&&(n+=o),o=e>n?0:n-e>>>0,e>>>=0;for(var i=Array(o);++r<o;)i[r]=t[r+e];return i}(e,0,-1))}(t,e=j(e,t)?[e]:C(e));var n,r,o=M((r=(n=e)?n.length:0)?n[r-1]:void 0);return!(null!=t&&w.call(t,o))||delete t[o]}(t,e)}},47:function(t){var e=function(t){"use strict";var e,n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function u(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,n){return t[e]=n}}function f(t,e,n,r){var i=e&&e.prototype instanceof v?e:v,s=Object.create(i.prototype),a=new P(r||[]);return o(s,"_invoke",{value:A(t,n,a)}),s}function l(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function v(){}function m(){}function _(){}var w={};u(w,s,(function(){return this}));var b=Object.getPrototypeOf,E=b&&b(b(x([])));E&&E!==n&&r.call(E,s)&&(w=E);var S=_.prototype=v.prototype=Object.create(w);function I(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function n(o,i,s,a){var c=l(t[o],t,i);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"==typeof f&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,s,a)}),(function(t){n("throw",t,s,a)})):e.resolve(f).then((function(t){u.value=t,s(u)}),(function(t){return n("throw",t,s,a)}))}a(c.arg)}var i;o(this,"_invoke",{value:function(t,r){function o(){return new e((function(e,o){n(t,r,e,o)}))}return i=i?i.then(o,o):o()}})}function A(t,n,r){var o=h;return function(i,s){if(o===d)throw new Error("Generator is already running");if(o===y){if("throw"===i)throw s;return{value:e,done:!0}}for(r.method=i,r.arg=s;;){var a=r.delegate;if(a){var c=T(a,r);if(c){if(c===g)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===h)throw o=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=d;var u=l(t,n,r);if("normal"===u.type){if(o=r.done?y:p,u.arg===g)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(o=y,r.method="throw",r.arg=u.arg)}}}function T(t,n){var r=n.method,o=t.iterator[r];if(o===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,T(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var i=l(o,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,g;var s=i.arg;return s?s.done?(n[t.resultName]=s.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,g):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function N(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function R(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(N,this),this.reset(!0)}function x(t){if(null!=t){var n=t[s];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function n(){for(;++o<t.length;)if(r.call(t,o))return n.value=t[o],n.done=!1,n;return n.value=e,n.done=!0,n};return i.next=i}}throw new TypeError(typeof t+" is not iterable")}return m.prototype=_,o(S,"constructor",{value:_,configurable:!0}),o(_,"constructor",{value:m,configurable:!0}),m.displayName=u(_,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===m||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,_):(t.__proto__=_,u(t,c,"GeneratorFunction")),t.prototype=Object.create(S),t},t.awrap=function(t){return{__await:t}},I(O.prototype),u(O.prototype,a,(function(){return this})),t.AsyncIterator=O,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var s=new O(f(e,n,r,o),i);return t.isGeneratorFunction(n)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},I(S),u(S,c,"Generator"),u(S,s,(function(){return this})),u(S,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},t.values=x,P.prototype={constructor:P,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(R),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function o(r,o){return a.type="throw",a.arg=t,n.next=r,o&&(n.method="next",n.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var s=this.tryEntries[i],a=s.completion;if("root"===s.tryLoc)return o("end");if(s.tryLoc<=this.prev){var c=r.call(s,"catchLoc"),u=r.call(s,"finallyLoc");if(c&&u){if(this.prev<s.catchLoc)return o(s.catchLoc,!0);if(this.prev<s.finallyLoc)return o(s.finallyLoc)}else if(c){if(this.prev<s.catchLoc)return o(s.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return o(s.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=t,s.arg=e,i?(this.method="next",this.next=i.finallyLoc,g):this.complete(s)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),g},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),R(n),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;R(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:x(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),g}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}},633:function(){},536:function(t){"use strict";t.exports={version:"1.8.2"}}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={id:r,loaded:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}return n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,{a:e}),e},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.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),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})},n.nmd=function(t){return t.paths=[],t.children||(t.children=[]),t},n(47),n(972)}()}));
|