@cloudbase/js-sdk 2.19.7 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,2 +1,2 @@
|
|
|
1
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={2829:function(t,e,r){"use strict";var n;r.r(e),r.d(e,{AbstractSDKRequest:function(){return o},AbstractStorage:function(){return i},StorageType:function(){return n},formatUrl:function(){return s}}),function(t){t.local="local",t.none="none",t.session="session"}(n||(n={}));var o=function(){},i=function(){};function s(t,e,r){void 0===r&&(r={});var n=/\?/.test(e),o="";for(var i in r)""===o?!n&&(e+="?"):o+="&",o+=i+"="+encodeURIComponent(r[i]);return/^http(s)?\:\/\//.test(e+=o)?e:""+t+e}},190:function(t,e,r){"use strict";var n,o=r(2829),i=r(5993),s=(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},n(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),a=function(){return a=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},a.apply(this,arguments)},u="Error when aborting requestTask",c=function(t){function e(e){void 0===e&&(e={});var r=t.call(this)||this,n=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return r._timeout=n||0,r._timeoutMsg=o||"请求超时",r._restrictedMethods=i||["get","post","upload","download"],r}return s(e,t),e.prototype.post=function(t){var e=this;return new Promise((function(r,n){var i=t.url,s=t.data,a=t.headers,u=wx.request({url:(0,o.formatUrl)("https:",i),data:s,timeout:e._timeout,method:"POST",header:a,success:function(t){r(t)},fail:function(t){n(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{u.abort()}catch(t){}}}})}))},e.prototype.upload=function(t){var e=this,r=this;return new Promise((function(n){return o=e,i=void 0,u=function(){var e,o,i,s,u,c;return function(t,e){var r,n,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(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}(this,(function(l){return e=t.url,o=t.file,i=t.data,s=t.headers,u=t.onUploadProgress,c=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)),n(e)},fail:function(t){n(t)},complete:function(t){if(t&&t.errMsg&&r._timeout&&-1!==r._restrictedMethods.indexOf("upload")&&"request:fail timeout"===t.errMsg){console.warn(r._timeoutMsg);try{c.abort()}catch(t){}}}}),u&&c.onProgressUpdate((function(t){u(t)})),[2]}))},new((s=void 0)||(s=Promise))((function(t,e){function r(t){try{a(u.next(t))}catch(t){e(t)}}function n(t){try{a(u.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(r,n)}a((u=u.apply(o,i||[])).next())}));var o,i,s,u}))},e.prototype.download=function(t){var e=this,r=this;return new Promise((function(n,i){var s=t.url,a=t.headers,u=wx.downloadFile({url:(0,o.formatUrl)("https:",s),header:a,timeout:e._timeout,success:function(t){200===t.statusCode&&t.tempFilePath?n({statusCode:200,tempFilePath:t.tempFilePath}):n(t)},fail:function(t){i(t)},complete:function(t){if(t&&t.errMsg&&r._timeout&&-1!==r._restrictedMethods.indexOf("download")&&"request:fail timeout"===t.errMsg){console.warn(r._timeoutMsg);try{u.abort()}catch(t){}}}})}))},e.prototype.fetch=function(t){var e=t.url,r=t.body,n=t.enableAbort,s=t.headers,a=t.method,c=t.stream,l=void 0!==c&&c,f=t.signal,h=t.timeout,d=this,p=null!=h?h:this._timeout,y=null,v=new i.Pz({start:function(t){y=t},cancel:function(){y=null}});return new Promise((function(t,i){l&&t({data:v});var c=wx.request({url:(0,o.formatUrl)("https:",e),data:r,timeout:p,method:a.toUpperCase(),header:s,success:function(e){var r;null===(r=y)||void 0===r||r.close(),!l&&t(e)},fail:function(t){var e;if(null===(e=y)||void 0===e||e.close(),i(t),l)throw t},complete:function(t){if(t&&t.errMsg&&p&&-1!==d._restrictedMethods.indexOf("post")&&n&&"request:fail timeout"===t.errMsg){console.warn(d._timeoutMsg);try{c.abort()}catch(t){console.warn(u,t)}}},enableChunked:l});if(c.onChunkReceived((function(t){var e;null===(e=y)||void 0===e||e.enqueue(new Uint8Array(t.data))})),f){var h=function(){try{c.abort()}catch(t){console.warn(u,t)}};f.aborted?h():f.addEventListener("abort",(function(){return h()}))}}))},e}(o.AbstractSDKRequest),l={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 r=wx.connectSocket(a({url:t},e));return{set onopen(t){r.onOpen(t)},set onmessage(t){r.onMessage(t)},set onclose(t){r.onClose(t)},set onerror(t){r.onError(t)},send:function(t){return r.send({data:t})},close:function(t,e){return r.close({code:t,reason:e})},get readyState(){return r.readyState},CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3}},h={genAdapter:function(){return{root:{},reqClass:c,wsClass:f,localStorage:l,primaryStorage:o.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"};e.ZP=h},5304:function(t,e){!function(t){"use strict";var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},e(t,r)};var r=function(){return r=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)};function n(t,e,r,n){return new(r||(r=Promise))((function(e,o){function i(t){try{a(n.next(t))}catch(t){o(t)}}function s(t){try{a(n.throw(t))}catch(t){o(t)}}function a(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r((function(t){t(n)}))).then(i,s)}a((n=n.apply(t,[])).next())}))}function o(t,e){var r,n,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(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}var i=function(t){function r(e,r){var n=t.call(this,e)||this;return n.name="WxCloudSDKError",n.code=null==r?void 0:r.code,n.requestId=null==r?void 0:r.requestId,n.originError=null==r?void 0:r.originError,n}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}(r,t),r}(Error);function s(){return"undefined"!=typeof window&&window||"undefined"!=typeof globalThis&&globalThis}function a(){try{var t=s();if(!t)return;return"undefined"==typeof wx?s().location.href:t.__wxRoute}catch(t){}}var u=function(t){var e=t.dataSourceName,r=t.methodName,u=t.params,c=t.realMethodName,l=t.callFunction,f=t.envType,h=void 0===f?"prod":f,d=t.mode;return n(void 0,0,void 0,(function(){var t,n,f,p,y,v;return o(this,(function(o){switch(o.label){case 0:t={data:{},requestId:""},o.label=1;case 1:return o.trys.push([1,3,,4]),[4,l({name:"lowcode-datasource",data:{dataSourceName:e,methodName:r,params:u,userAgent:(m=s(),(null==m?void 0:m.navigator)?m.navigator.userAgent:"undefined"!=typeof wx&&wx.getSystemInfo?(wx.getSystemInfo({success:function(t){t&&(g=["brand","model","version","system","platform","SDKVersion","language"].map((function(e){return"".concat(e,": ").concat(t[e])})).join(", "))}}),g):void 0),referrer:a(),"x-sdk-version":"1.5.0",envType:h,mode:d}})];case 2:if(n=o.sent(),f=(null===(y=null==n?void 0:n.result)||void 0===y?void 0:y.requestId)||(null==n?void 0:n.requestId)||(null==n?void 0:n.requestID),null==n?void 0:n.result.code)throw new i("【错误】".concat(null==n?void 0:n.result.message,"\n【操作】调用 models.").concat(e?"".concat(e,"."):"").concat(c,"\n【错误码】").concat(null==n?void 0:n.result.code,"\n【请求ID】").concat(f||"N/A"),{code:null==n?void 0:n.result.code,requestId:f});return t.data=(null===(v=null==n?void 0:n.result)||void 0===v?void 0:v.data)||{},t.requestId=f,[3,4];case 3:throw"WxCloudSDKError"===(p=o.sent()).name?p:(console.log(p),new i("【错误】".concat(p.message,"\n 【操作】调用 models.").concat(e?"".concat(e,"."):"").concat(c,"\n 【请求ID】N/A"),{code:"UnknownError",originError:p}));case 4:return[2,t]}var g,m}))}))},c=function(t){var e=t.sql,r=t.params,i=t.config,s=t.callFunction,a=t.unsafe,c=void 0!==a&&a;return n(void 0,0,void 0,(function(){return o(this,(function(t){return[2,u({realMethodName:"$runSQL",methodName:"callWedaApi",params:{action:"RunMysqlCommand",data:{sqlTemplate:e,config:i,parameter:c?"":Object.entries(r||{}).reduce((function(t,e){var r=e[0],n=e[1];if(void 0!==n){var o="OBJECT";switch(typeof n){case"boolean":o="BOOLEAN";break;case"number":o="NUMBER";break;case"string":o="STRING";break;default:o=Array.isArray(n)?"ARRAY":"OBJECT"}t.push({key:r,type:o,value:"STRING"===o?n:JSON.stringify(n)})}return t}),[])||[]}},callFunction:s,mode:"sdk"})]}))}))},l=function(t){return{$runSQL:function(e,i,s){return n(this,0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return[4,c({sql:e,params:i,config:r(r({},s),{preparedStatements:!0}),callFunction:t})];case 1:return[2,n.sent()]}}))}))},$runSQLRaw:function(e,i){return n(this,0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return[4,c({sql:e,params:[],config:r(r({},i),{preparedStatements:!1}),callFunction:t})];case 1:return[2,n.sent()]}}))}))}}},f={create:{methodName:"wedaCreateV2"},createMany:{methodName:"wedaBatchCreateV2"},update:{methodName:"wedaUpdateV2"},upsert:{methodName:"wedaUpsertV2"},updateMany:{methodName:"wedaBatchUpdateV2"},delete:{methodName:"wedaDeleteV2"},deleteMany:{methodName:"wedaBatchDeleteV2"},get:{methodName:"wedaGetItemV2",defaultParams:{filter:{where:{}},select:{$master:!0}}},list:{methodName:"wedaGetRecordsV2",defaultParams:{filter:{where:{}},select:{$master:!0}}}},h=function(t){var e=l(t);return new Proxy({},{get:function(s,a){if("string"==typeof a)return Object.prototype.hasOwnProperty.call(e,a)?e[a]:function(t,e){return new Proxy({},{get:function(s,a){var c=f[a];if(!c){var l=new Error("不支持的操作: ".concat(a));throw new i(l.message||"Unknown error occurred",{originError:l,code:"NotSupported",requestId:"N/A"})}return function(i){return n(void 0,0,void 0,(function(){var n,s,l,f,h;return o(this,(function(o){switch(o.label){case 0:return n=r(r({},c.defaultParams||{}),i||{}),[4,u({callFunction:e,dataSourceName:t,methodName:c.methodName,realMethodName:a,params:n,envType:null==i?void 0:i.envType})];case 1:return s=o.sent(),l={data:{}},f=c.responseKey,l.data=f?null===(h=null==s?void 0:s.data)||void 0===h?void 0:h[f]:null==s?void 0:s.data,[2,l]}}))}))}}})}(a,t)}})},d={filter:{where:{}},select:{$master:!0}};function p(t){return{getUrl:function(e){return"".concat(e,"/").concat(t)},method:"post"}}var y={get:r(r({},p("get")),{defaultParams:r({},d)}),list:r(r({},p("list")),{defaultParams:r({},d)}),create:p("create"),createMany:p("createMany"),update:r(r({},p("update")),{method:"put"}),updateMany:r(r({},p("updateMany")),{method:"put"}),upsert:p("upsert"),delete:p("delete"),deleteMany:p("deleteMany")},v="Unknown error occurred",g="NotSupported",m=function(t,e,r,n){var o=l(t);return new Proxy({},{get:function(t,i){if("string"==typeof i)return Object.prototype.hasOwnProperty.call(o,i)?o[i]:w(r,i,e,n)}})},b=function(t,e,r,n,o){return new i("【错误】".concat(t,"\n【操作】调用 models.").concat(e,".").concat(r,"\n【错误码】").concat(n,"\n【请求ID】").concat(o),{code:n,requestId:o})},w=function(t,e,s,a){return new Proxy({},{get:function(u,c){if("runSQLTemplate"!==c){var l=y[c];if(!l){var f=new Error("不支持的操作: ".concat(c));throw new i(f.message||v,{originError:f,code:g,requestId:"N/A"})}return function(r){return void 0===r&&(r={}),n(void 0,0,void 0,(function(){var n,a,u,f,h,d,p,y,g,m;return o(this,(function(o){switch(o.label){case 0:n=l.getUrl,a=l.method,u=l.defaultParams,f=void 0===u?{}:u,h=Object.assign({},f,r),d="pre"===h.envType?"pre":"prod",p=[t,d,n(e)].join("/"),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,s({url:p,body:JSON.stringify(h),method:a})];case 2:if((y=o.sent()).code)throw b(null==y?void 0:y.message,e,c,null==y?void 0:y.code,null==y?void 0:y.requestId);return"get"===c&&Object.assign(y,{data:null!==(m=y.data.record)&&void 0!==m?m:y.data}),[2,y];case 3:throw g=o.sent(),new i((null==g?void 0:g.message)||v,{originError:g});case 4:return[2]}}))}))}}if(!(null==a?void 0:a.sqlBaseUrl))throw f=new Error("不支持的操作: ".concat(c)),new i(f.message||v,{originError:f,code:g,requestId:"N/A"});return function(t){return n(void 0,0,void 0,(function(){var n,u,l,f,h,d,p,y,g,m,w,_,S,E,I,O;return o(this,(function(o){switch(o.label){case 0:n=t.params,u=t.templateName,l=t.envType,f="pre"===l?"pre":"prod",h=[a.sqlBaseUrl,f,u,"run"].join("/"),d=Object.entries(n||{}).reduce((function(t,e){var r=e[0],n=e[1];if(void 0!==n){var o="OBJECT";switch(typeof n){case"boolean":o="BOOLEAN";break;case"number":o="NUMBER";break;case"string":o="STRING";break;default:o=Array.isArray(n)?"ARRAY":"OBJECT"}t.push({key:r,type:o,value:"STRING"===o?n:JSON.stringify(n)})}return t}),[]),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,s({url:h,body:JSON.stringify({parameter:d}),method:"POST"})];case 2:if(p=o.sent(),null===(g=null==p?void 0:p.Response)||void 0===g?void 0:g.Error)throw b(null===(w=null===(m=null==p?void 0:p.Response)||void 0===m?void 0:m.Error)||void 0===w?void 0:w.Message,e,c,null===(S=null===(_=null==p?void 0:p.Response)||void 0===_?void 0:_.Error)||void 0===S?void 0:S.Code,null===(E=null==p?void 0:p.Response)||void 0===E?void 0:E.RequestId);return[2,r(r({},null!==(I=null==p?void 0:p.Response)&&void 0!==I?I:{}),{data:null===(O=null==p?void 0:p.Response)||void 0===O?void 0:O.Data})];case 3:throw y=o.sent(),new i((null==y?void 0:y.message)||v,{originError:y});case 4:return[2]}}))}))}}})};function _(t){if(!t)throw new Error("cloud is required");if(!t.callFunction)throw new Error("cloud.callFunction is required");var e=h(t.callFunction.bind(t));return t.models=e,t}var S={init:_,generateHTTPClient:m};t.default=S,t.generateHTTPClient=m,t.init=_,Object.defineProperty(t,"__esModule",{value:!0})}(e)},972:function(t,e,r){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}},o=n(r(2856)),i=r(7170),s=r(2363),a=r(614),u=r(9063),c=r(7505),l=r(9679),f=r(7801),h=r(7596),d=r(8622),p=n(r(4536)).default.version;o.default.registerVersion(p);try{(0,i.registerAuth)(o.default),(0,s.registerFunctions)(o.default),(0,a.registerStorage)(o.default),(0,d.registerDatabase)(o.default),(0,u.registerRealtime)(o.default),(0,c.registerAnalytics)(o.default),(0,l.registerModel)(o.default),(0,f.registerAi)(o.default),(0,h.registerCloudrun)(o.default)}catch(t){}try{window.cloudbase=o.default}catch(t){}e.default=o.default,t.exports=o.default},7801:function(t,e,r){"use strict";r.r(e),r.d(e,{AI:function(){return ne},Bot:function(){return M},SimpleChatModel:function(){return oe},createAi:function(){return ce},models:function(){return ae},registerAi:function(){return fe},utils:function(){return n}});var n={};r.r(n),r.d(n,{ReadableStream:function(){return E},TextDecoderStream:function(){return R},TransformStream:function(){return I},createAsyncIterable:function(){return A},createEventSourceParserTransformStream:function(){return O},createPromise:function(){return N},functionToolToModelTool:function(){return j},intoStandardStream:function(){return P},intoTextStream:function(){return x},isToolCallAssistantMessage:function(){return L},readableStream2JsonObject:function(){return C},toPolyfillReadable:function(){return T}});var o={};r.r(o),r.d(o,{ArkSimpleModel:function(){return at},DSSimpleModel:function(){return ht},DefaultSimpleModel:function(){return qt},HunYuanBetaSimpleModel:function(){return Z},HunYuanExpSimpleModel:function(){return Tt},HunYuanOpenSimpleModel:function(){return xt},HunYuanSimpleModel:function(){return rt},MODELS:function(){return Qt},MoonshotSimpleModel:function(){return St},ReactModel:function(){return Ht},YiSimpleModel:function(){return gt},ZhiPuSimpleModel:function(){return G},toolMap:function(){return Kt}});var i=r(5993),s=function(t,e){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},s(t,e)};function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}s(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function u(t){if(!t)throw new TypeError("Assertion failed")}function c(){}function l(t){return!(e=t,("object"!=typeof e||null===e)&&"function"!=typeof e||"function"!=typeof t.getReader);var e}function f(t){try{return t.getReader({mode:"byob"}).releaseLock(),!0}catch(t){return!1}}function h(t,e){var r=(void 0===e?{}:e).type;return u(l(t)),u(!1===t.locked),"bytes"===(r=d(r))?new g(t):new y(t)}function d(t){var e=String(t);if("bytes"===e)return e;if(void 0===t)return t;throw new RangeError("Invalid type is specified")}var p=function(){function t(t){this._underlyingReader=void 0,this._readerMode=void 0,this._readableStreamController=void 0,this._pendingRead=void 0,this._underlyingStream=t,this._attachDefaultReader()}return t.prototype.start=function(t){this._readableStreamController=t},t.prototype.cancel=function(t){return u(void 0!==this._underlyingReader),this._underlyingReader.cancel(t)},t.prototype._attachDefaultReader=function(){if("default"!==this._readerMode){this._detachReader();var t=this._underlyingStream.getReader();this._readerMode="default",this._attachReader(t)}},t.prototype._attachReader=function(t){var e=this;u(void 0===this._underlyingReader),this._underlyingReader=t;var r=this._underlyingReader.closed;r&&r.then((function(){return e._finishPendingRead()})).then((function(){t===e._underlyingReader&&e._readableStreamController.close()}),(function(r){t===e._underlyingReader&&e._readableStreamController.error(r)})).catch(c)},t.prototype._detachReader=function(){void 0!==this._underlyingReader&&(this._underlyingReader.releaseLock(),this._underlyingReader=void 0,this._readerMode=void 0)},t.prototype._pullWithDefaultReader=function(){var t=this;this._attachDefaultReader();var e=this._underlyingReader.read().then((function(e){var r=t._readableStreamController;e.done?t._tryClose():r.enqueue(e.value)}));return this._setPendingRead(e),e},t.prototype._tryClose=function(){try{this._readableStreamController.close()}catch(t){}},t.prototype._setPendingRead=function(t){var e,r=this,n=function(){r._pendingRead===e&&(r._pendingRead=void 0)};this._pendingRead=e=t.then(n,n)},t.prototype._finishPendingRead=function(){var t=this;if(this._pendingRead){var e=function(){return t._finishPendingRead()};return this._pendingRead.then(e,e)}},t}(),y=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return a(e,t),e.prototype.pull=function(){return this._pullWithDefaultReader()},e}(p);function v(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}var g=function(t){function e(e){var r=this,n=f(e);return(r=t.call(this,e)||this)._supportsByob=n,r}return a(e,t),Object.defineProperty(e.prototype,"type",{get:function(){return"bytes"},enumerable:!1,configurable:!0}),e.prototype._attachByobReader=function(){if("byob"!==this._readerMode){u(this._supportsByob),this._detachReader();var t=this._underlyingStream.getReader({mode:"byob"});this._readerMode="byob",this._attachReader(t)}},e.prototype.pull=function(){if(this._supportsByob){var t=this._readableStreamController.byobRequest;if(t)return this._pullWithByobRequest(t)}return this._pullWithDefaultReader()},e.prototype._pullWithByobRequest=function(t){var e=this;this._attachByobReader();var r=new Uint8Array(t.view.byteLength),n=this._underlyingReader.read(r).then((function(r){var n,o,i;e._readableStreamController,r.done?(e._tryClose(),t.respond(0)):(n=r.value,o=t.view,i=v(n),v(o).set(i,0),t.respond(r.value.byteLength))}));return this._setPendingRead(n),n},e}(p);!function(){function t(t){var e=this;this._writableStreamController=void 0,this._pendingWrite=void 0,this._state="writable",this._storedError=void 0,this._underlyingWriter=t,this._errorPromise=new Promise((function(t,r){e._errorPromiseReject=r})),this._errorPromise.catch(c)}t.prototype.start=function(t){var e=this;this._writableStreamController=t,this._underlyingWriter.closed.then((function(){e._state="closed"})).catch((function(t){return e._finishErroring(t)}))},t.prototype.write=function(t){var e=this,r=this._underlyingWriter;if(null===r.desiredSize)return r.ready;var n=r.write(t);n.catch((function(t){return e._finishErroring(t)})),r.ready.catch((function(t){return e._startErroring(t)}));var o=Promise.race([n,this._errorPromise]);return this._setPendingWrite(o),o},t.prototype.close=function(){var t=this;return void 0===this._pendingWrite?this._underlyingWriter.close():this._finishPendingWrite().then((function(){return t.close()}))},t.prototype.abort=function(t){if("errored"!==this._state)return this._underlyingWriter.abort(t)},t.prototype._setPendingWrite=function(t){var e,r=this,n=function(){r._pendingWrite===e&&(r._pendingWrite=void 0)};this._pendingWrite=e=t.then(n,n)},t.prototype._finishPendingWrite=function(){var t=this;if(void 0===this._pendingWrite)return Promise.resolve();var e=function(){return t._finishPendingWrite()};return this._pendingWrite.then(e,e)},t.prototype._startErroring=function(t){var e=this;if("writable"===this._state){this._state="erroring",this._storedError=t;var r=function(){return e._finishErroring(t)};void 0===this._pendingWrite?r():this._finishPendingWrite().then(r,r),this._writableStreamController.error(t)}},t.prototype._finishErroring=function(t){"writable"===this._state&&this._startErroring(t),"erroring"===this._state&&(this._state="errored",this._errorPromiseReject(this._storedError))}}(),function(){function t(t,e){var r=this;this._transformStreamController=void 0,this._onRead=function(t){if(!t.done)return r._transformStreamController.enqueue(t.value),r._reader.read().then(r._onRead)},this._onError=function(t){r._flushReject(t),r._transformStreamController.error(t),r._reader.cancel(t).catch(c),r._writer.abort(t).catch(c)},this._onTerminate=function(){r._flushResolve(),r._transformStreamController.terminate();var t=new TypeError("TransformStream terminated");r._writer.abort(t).catch(c)},this._reader=t,this._writer=e,this._flushPromise=new Promise((function(t,e){r._flushResolve=t,r._flushReject=e}))}t.prototype.start=function(t){this._transformStreamController=t,this._reader.read().then(this._onRead).then(this._onTerminate,this._onError);var e=this._reader.closed;e&&e.then(this._onTerminate,this._onError)},t.prototype.transform=function(t){return this._writer.write(t)},t.prototype.flush=function(){var t=this;return this._writer.close().then((function(){return t._flushPromise}))}}();var m=[239,187,191],b=r(4410),w=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},_=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},S=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,r=t[Symbol.asyncIterator];return r?r.call(t):(t="function"==typeof __values?__values(t):t[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(r){e[r]=t[r]&&function(e){return new Promise((function(n,o){!function(t,e,r,n){Promise.resolve(n).then((function(e){t({value:e,done:r})}),e)}(n,o,(e=t[r](e)).done,e.value)}))}}},E=i.Pz,I=i.GJ,O=function(){var t;return new I({start:function(e){t=function(t){var e,r,n,o,i,s,a;return u(),{feed:function(t){r=r?r+t:t,e&&function(t){return m.every((function(e,r){return t.charCodeAt(r)===e}))}(r)&&(r=r.slice(m.length)),e=!1;for(var i=r.length,s=0,a=!1;s<i;){a&&("\n"===r[s]&&(s+=1),a=!1);for(var u=-1,l=o,f=void 0,h=n;u<0&&h<i;h++)":"===(f=r[h])&&l<0?l=h-s:"\r"===f?(a=!0,u=h-s):"\n"===f&&(u=h-s);if(u<0){n=i-s,o=l;break}n=0,o=-1,c(r,s,l,u),s+=u+1}s===i?r="":s>0&&(r=r.slice(s))},reset:u};function u(){e=!0,r="",n=0,o=-1,i=void 0,s=void 0,a=""}function c(e,r,n,o){if(0===o)return a.length>0&&(t({type:"event",id:i,event:s||void 0,data:a.slice(0,-1)}),a="",i=void 0),void(s=void 0);var u,c=n<0,l=e.slice(r,r+(c?o:n)),f=r+(u=c?o:" "===e[r+n+1]?n+2:n+1),h=o-u,d=e.slice(f,f+h).toString();if("data"===l)a+=d?"".concat(d,"\n"):"\n";else if("event"===l)s=d;else if("id"!==l||d.includes("\0")){if("retry"===l){var p=parseInt(d,10);Number.isNaN(p)||t({type:"reconnect-interval",value:p})}}else i=d}}((function(t){"event"===t.type&&e.enqueue(t)}))},transform:function(e){t.feed(e)}})},T=function(t){u(function(t){return!!function(t){if("function"!=typeof t)return!1;var e=!1;try{new t({start:function(){e=!0}})}catch(t){}return e}(t)&&!!l(new t)}(t));var e=function(t){try{return new t({type:"bytes"}),!0}catch(t){return!1}}(t);return function(r,n){var o=(void 0===n?{}:n).type;if("bytes"!==(o=d(o))||e||(o=void 0),r.constructor===t&&("bytes"!==o||f(r)))return r;if("bytes"===o){var i=h(r,{type:o});return new t(i)}return i=h(r),new t(i)}}(E),R=function(){function t(t,e){void 0===t&&(t="utf-8"),void 0===e&&(e={});var r=this;this.transform=new I({transform:function(t,e){var n=r.handle.decode(new Uint8Array(t),{stream:!0});n&&e.enqueue(n)},flush:function(t){var e=r.handle.decode();e&&t.enqueue(e),t.terminate()}}),this.handle=new b.TextDecoder(t,e)}return Object.defineProperty(t.prototype,"encoding",{get:function(){return this.handle.encoding},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fatal",{get:function(){return this.handle.fatal},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ignoreBOM",{get:function(){return this.handle.ignoreBOM},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"readable",{get:function(){return this.transform.readable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"writable",{get:function(){return this.transform.writable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,Symbol.toStringTag,{get:function(){return"TextDecoderStream"},enumerable:!1,configurable:!0}),t}();function A(t){var e=t;return e[Symbol.asyncIterator]=function(){var e=t.getReader();return{next:function(){return w(this,void 0,void 0,(function(){var t,r,n;return _(this,(function(o){switch(o.label){case 0:return[4,e.read()];case 1:return t=o.sent(),r=t.done,n=t.value,[2,r?{done:!0,value:void 0}:{done:!1,value:n}]}}))}))}}},e}function P(t){return A(t.pipeThrough(new R).pipeThrough(O()).pipeThrough(new I({transform:function(t,e){try{var r=JSON.parse(t.data);e.enqueue(r)}catch(r){"[DONE]"!==t.data?console.warn("Error when transforming event source data to json",r,t):e.terminate()}}})))}function x(t){return A(T(t).pipeThrough(new R))}function C(t){var e,r,n,o;return w(this,void 0,void 0,(function(){var i,s,a,u,c,l;return _(this,(function(f){switch(f.label){case 0:i=x(t),s="",f.label=1;case 1:f.trys.push([1,6,7,12]),a=!0,u=S(i),f.label=2;case 2:return[4,u.next()];case 3:if(c=f.sent(),e=c.done)return[3,5];o=c.value,a=!1;try{s+=o}finally{a=!0}f.label=4;case 4:return[3,2];case 5:return[3,12];case 6:return l=f.sent(),r={error:l},[3,12];case 7:return f.trys.push([7,,10,11]),a||e||!(n=u.return)?[3,9]:[4,n.call(u)];case 8:f.sent(),f.label=9;case 9:return[3,11];case 10:if(r)throw r.error;return[7];case 11:return[7];case 12:return[2,JSON.parse(s)]}}))}))}function N(){var t,e;return{promise:new Promise((function(r,n){t=r,e=n})),res:t,rej:e}}function L(t){var e;return"assistant"===t.role&&"tool_calls"in t&&null!=(null===(e=t.tool_calls)||void 0===e?void 0:e[0])}function j(t){return{type:"function",function:{description:t.description,name:t.name,parameters:t.parameters}}}var U=function(){return U=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},U.apply(this,arguments)},k=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},D=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},q=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r},M=function(){function t(t,e){this.baseUrl=e;var r=arguments[2];this.req="string"==typeof r?function(e){var n=e.headers,o=void 0===n?{}:n,i=q(e,["headers"]);return t(U(U({},i),{headers:U(U({},o),{Authorization:"Bearer ".concat(r)})}))}:t}return t.prototype.list=function(t,e){return this.req({method:"get",url:this.join("bots"),data:t,timeout:null==e?void 0:e.timeout})},t.prototype.create=function(t,e){var r=t.botInfo;return this.req({method:"post",url:this.join("bots"),data:r,timeout:null==e?void 0:e.timeout})},t.prototype.get=function(t,e){var r=t.botId;return this.req({method:"get",url:this.join("bots/".concat(r)),timeout:null==e?void 0:e.timeout})},t.prototype.update=function(t,e){var r=t.botId,n=t.botInfo;return this.req({method:"PATCH",url:this.join("bots/".concat(r)),data:n,timeout:null==e?void 0:e.timeout})},t.prototype.delete=function(t,e){var r=t.botId;return this.req({method:"delete",url:this.join("bots/".concat(r)),timeout:null==e?void 0:e.timeout})},t.prototype.getChatRecords=function(t,e){return this.req({method:"get",url:this.join("bots/".concat(t.botId,"/records")),data:t,timeout:null==e?void 0:e.timeout})},t.prototype.sendFeedback=function(t,e){var r=t.userFeedback;return this.req({method:"post",url:this.join("bots/".concat(r.botId,"/feedback")),data:r,timeout:null==e?void 0:e.timeout})},t.prototype.getFeedback=function(t,e){return this.req({method:"get",url:this.join("bots/".concat(t.botId,"/feedback")),data:t,timeout:null==e?void 0:e.timeout})},t.prototype.uploadFiles=function(t,e){return k(this,void 0,void 0,(function(){return D(this,(function(r){return[2,this.req({method:"post",url:this.join("bots/".concat(t.botId,"/files")),data:t,timeout:null==e?void 0:e.timeout})]}))}))},t.prototype.createConversation=function(t,e){var r=t.botId,n=q(t,["botId"]);return k(this,void 0,void 0,(function(){return D(this,(function(t){return[2,this.req({method:"post",url:this.join("bots/".concat(r,"/conversation")),data:n,timeout:null==e?void 0:e.timeout})]}))}))},t.prototype.getConversation=function(t,e){var r=t.pageSize,n=void 0===r?10:r,o=t.pageNumber,i=void 0===o?1:o,s=t.botId,a=q(t,["pageSize","pageNumber","botId"]);return k(this,void 0,void 0,(function(){var t,r;return D(this,(function(o){if(i<1)throw new Error("pageNumber must be greater than 0");return t=n*(i-1),r=n,[2,this.req({method:"get",url:this.join("bots/".concat(s,"/conversation")),data:U(U({},a),{offset:t,limit:r}),timeout:null==e?void 0:e.timeout})]}))}))},t.prototype.deleteConversation=function(t,e){var r=t.botId,n=t.conversationId,o=q(t,["botId","conversationId"]);return k(this,void 0,void 0,(function(){return D(this,(function(t){return[2,this.req({method:"delete",url:this.join("bots/".concat(r,"/conversation/").concat(n)),data:o,timeout:null==e?void 0:e.timeout})]}))}))},t.prototype.speechToText=function(t,e){return k(this,void 0,void 0,(function(){return D(this,(function(r){return[2,this.req({method:"post",url:this.join("bots/".concat(t.botId,"/speech-to-text")),data:t,timeout:null==e?void 0:e.timeout})]}))}))},t.prototype.textToSpeech=function(t,e){return k(this,void 0,void 0,(function(){return D(this,(function(r){return[2,this.req({method:"post",url:this.join("bots/".concat(t.botId,"/text-to-speech")),data:t,timeout:null==e?void 0:e.timeout})]}))}))},t.prototype.getTextToSpeechResult=function(t,e){return k(this,void 0,void 0,(function(){return D(this,(function(r){return[2,this.req({method:"get",url:this.join("bots/".concat(t.botId,"/text-to-speech")),data:t,timeout:null==e?void 0:e.timeout})]}))}))},t.prototype.getRecommendQuestions=function(t,e){return k(this,void 0,void 0,(function(){var r;return D(this,(function(n){switch(n.label){case 0:return[4,this.req({method:"post",url:this.join("bots/".concat(t.botId,"/recommend-questions")),data:t,stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return r=n.sent(),[2,new B(r)]}}))}))},t.prototype.generateBot=function(t,e){return k(this,void 0,void 0,(function(){var r;return D(this,(function(n){switch(n.label){case 0:return[4,this.req({method:"post",url:this.join("generate-bot"),data:t,stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return r=n.sent(),[2,new B(r)]}}))}))},t.prototype.getPreview=function(t,e){return k(this,void 0,void 0,(function(){var r;return D(this,(function(n){switch(n.label){case 0:return[4,this.req({method:"post",url:this.join("preview"),data:t,stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return r=n.sent(),[2,new B(r)]}}))}))},t.prototype.generateImage=function(t,e){return this.req({method:"post",url:this.join("generate-image"),data:t,timeout:null==e?void 0:e.timeout})},t.prototype.sendMessage=function(t,e){return k(this,void 0,void 0,(function(){var r;return D(this,(function(n){switch(n.label){case 0:return[4,this.req({method:"post",url:this.join("bots/".concat(t.botId,"/send-message")),data:t,stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return r=n.sent(),[2,new B(r)]}}))}))},t.prototype.join=function(t){return"".concat(this.baseUrl,"/").concat(t)},t}(),B=function(){function t(t){var e=T(t);this._eventSourceStream=e.pipeThrough(new R).pipeThrough(O())}return Object.defineProperty(t.prototype,"teeedStream",{get:function(){var t=this._eventSourceStream.tee(),e=t[0],r=t[1];return this._eventSourceStream=r,e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"eventSourceStream",{get:function(){return A(this.teeedStream)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dataStream",{get:function(){return A(this.eventSourceStream.pipeThrough(new I({transform:function(t,e){try{var r=JSON.parse(t.data);e.enqueue(r)}catch(r){"[DONE]"!==t.data?console.warn("Error when transforming event source data to json",r,t):e.terminate()}}})))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textStream",{get:function(){return A(this.dataStream.pipeThrough(new I({transform:function(t,e){var r;e.enqueue(null!==(r=null==t?void 0:t.content)&&void 0!==r?r:"")}})))},enumerable:!1,configurable:!0}),t}(),W=function(){return W=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},W.apply(this,arguments)},F=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},V=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};function H(t){var e=t.messages,r=t.model,n=t.temperature,o=t.tool_choice,i=t.tools,s=t.top_p;return W(W({},t),{messages:e,model:r,temperature:n,tool_choice:(o&&"auto"!==o&&console.warn("`tool_choice` is not 'auto'"),o),tools:i,top_p:s})}var G=function(){function t(t,e,r){this.req=t,this.baseUrl=e,this.subUrl="zhipu/api/paas/v4/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return F(this,void 0,void 0,(function(){var r,n;return V(this,(function(o){switch(o.label){case 0:return r=H(t),[4,this.req({url:this.url,data:W(W({},r),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return n=o.sent(),[2,W(W({},n),{rawResponse:n})]}}))}))},t.prototype.doStream=function(t,e){return F(this,void 0,void 0,(function(){var r,n,o,i;return V(this,(function(s){switch(s.label){case 0:return r=H(t),n=null,[4,this.req({url:this.url,data:W(W({},r),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return o=s.sent(),i=T(o),[2,A(P(i).pipeThrough(new I({transform:function(t,e){var r=t.choices.map((function(t){var e=t.delta;return null==n&&(n=L(e)),n?W(W({},t),{finish_reason:"tool_calls",delta:e}):t})),o=W(W({},t),{choices:r});e.enqueue(W(W({},o),{rawResponse:t}))}})))]}}))}))},t}(),$=function(){return $=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},$.apply(this,arguments)};function K(t){var e=t.messages,r=t.model,n=t.temperature,o=t.tool_choice,i=t.tools,s=t.top_p;return $($({},t),{messages:(e.forEach((function(t){"tool_calls"in t&&t.tool_calls.filter((function(t){return"function"!==t.type})).forEach((function(e){return console.warn("`type` in tool_call is not 'function'",e,t)}))})),e),model:r,tools:function(){if(i)return i.forEach((function(t){"function"!==t.type&&console.warn("`type` in tool is not 'function'",t)})),i}(),top_p:s,tool_choice:o,temperature:n})}function z(t){return"object"!=typeof t||null==t?t:Array.isArray(t)?t.map((function(t){return z(t)})):Object.entries(t).reduce((function(t,e){var r,n=e[0],o=e[1];return t["_"===(r=n.replace(/[A-Z]/g,(function(t){return"_".concat(t.toLowerCase())}))).charAt(0)?r.slice(1):r]="object"==typeof o?z(o):o,t}),{})}var J=function(){return J=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},J.apply(this,arguments)},Y=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},Q=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},Z=function(){function t(t,e,r){this.req=t,this.baseUrl=e,this.subUrl="hunyuan-beta/openapi/v1/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return Y(this,void 0,void 0,(function(){var r;return Q(this,(function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:J(J({},K(t)),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return r=n.sent(),[2,J(J({},r),{rawResponse:r})]}}))}))},t.prototype.doStream=function(t,e){return Y(this,void 0,void 0,(function(){var r,n,o;return Q(this,(function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:J(J({},K(t)),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return n=i.sent(),o=T(n),[2,A(P(o).pipeThrough(new I({transform:function(t,e){var n=t.choices.map((function(t){var e=t.delta;return null==r&&(r=L(e)),r?J(J({},t),{finish_reason:"tool_calls",delta:e}):t})),o=J(J({},t),{choices:n});e.enqueue(J(J({},o),{rawResponse:t}))}})))]}}))}))},t}(),X=function(){return X=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},X.apply(this,arguments)},tt=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},et=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},rt=function(){function t(t,e,r){this.req=t,this.baseUrl=e,this.subUrl="hunyuan",null!=r&&(this.subUrl=r)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return tt(this,void 0,void 0,(function(){var r,n;return et(this,(function(o){switch(o.label){case 0:return[4,this.req({url:this.url,headers:{"X-Tc-Action":"ChatCompletions"},data:X(X({},K(t)),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return r=o.sent(),n=z(r.Response),[2,X(X({},n),{rawResponse:r})]}}))}))},t.prototype.doStream=function(t,e){return tt(this,void 0,void 0,(function(){var r,n,o;return et(this,(function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,headers:{"X-Tc-Action":"ChatCompletions"},data:X(X({},t),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return n=i.sent(),o=T(n),[2,A(P(o).pipeThrough(new I({transform:function(t,e){var n=z(t),o=n.choices.map((function(t){var e=t.delta;return null==r&&(r=L(e)),r?X(X({},t),{finish_reason:"tool_calls",delta:e}):t})),i=X(X({},n),{choices:o});e.enqueue(X(X({},i),{rawResponse:t}))}})))]}}))}))},t}(),nt=function(){return nt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},nt.apply(this,arguments)},ot=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},it=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};function st(t){var e=t.messages,r=t.model,n=t.temperature,o=t.tools,i=t.top_p;return nt(nt({},t),{messages:e,model:r,tools:o,top_p:i,temperature:n})}var at=function(){function t(t,e,r){this.req=t,this.baseUrl=e,this.subUrl="ark/api/v3/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return ot(this,void 0,void 0,(function(){var r;return it(this,(function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:nt(nt({},st(t)),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return r=n.sent(),[2,nt(nt({},r),{rawResponse:r})]}}))}))},t.prototype.doStream=function(t,e){return ot(this,void 0,void 0,(function(){var r,n,o;return it(this,(function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:nt(nt({},st(t)),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return n=i.sent(),o=T(n),[2,A(P(o).pipeThrough(new I({transform:function(t,e){var n=t.choices.map((function(t){var e=t.delta;return null==r&&(r=L(e)),r?nt(nt({},t),{finish_reason:"tool_calls",delta:e}):t})),o=nt(nt({},t),{choices:n});e.enqueue(nt(nt({},o),{rawResponse:t}))}})))]}}))}))},t}(),ut=function(){return ut=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},ut.apply(this,arguments)},ct=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},lt=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};function ft(t){var e=t.messages,r=t.model,n=t.temperature,o=t.tools,i=t.top_p;return ut(ut({},t),{messages:e,model:r,tools:o,top_p:i,temperature:n})}var ht=function(){function t(t,e,r){this.req=t,this.baseUrl=e,this.subUrl="dashscope/compatible-mode/v1/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return ct(this,void 0,void 0,(function(){var r;return lt(this,(function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:ut(ut({},ft(t)),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return r=n.sent(),[2,ut(ut({},r),{rawResponse:r})]}}))}))},t.prototype.doStream=function(t,e){return ct(this,void 0,void 0,(function(){var r,n,o;return lt(this,(function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:ut(ut({},ft(t)),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return n=i.sent(),o=T(n),[2,A(P(o).pipeThrough(new I({transform:function(t,e){var n=t.choices.map((function(t){var e=Object.assign(t.delta,{role:"assistant"});return null==r&&(r=L(e)),ut(ut({},t),r?{finish_reason:"tool_calls",delta:e}:{delta:e})})),o=ut(ut({},t),{choices:n});e.enqueue(ut(ut({},o),{rawResponse:t}))}})))]}}))}))},t}(),dt=function(){return dt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},dt.apply(this,arguments)},pt=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},yt=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};function vt(t){var e=t.messages,r=t.model,n=t.temperature,o=t.tools,i=t.top_p;return dt(dt({},t),{messages:e,model:r,tools:o,top_p:i,temperature:n})}var gt=function(){function t(t,e,r){this.req=t,this.baseUrl=e,this.subUrl="01-ai/v1/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return pt(this,void 0,void 0,(function(){var r;return yt(this,(function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:dt(dt({},vt(t)),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return r=n.sent(),[2,dt(dt({},r),{rawResponse:r})]}}))}))},t.prototype.doStream=function(t,e){return pt(this,void 0,void 0,(function(){var r,n,o,i,s;return yt(this,(function(a){switch(a.label){case 0:return r=null,[4,this.req({url:this.url,data:dt(dt({},vt(t)),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return n=a.sent(),o=T(n),i=P(o),s=i.pipeThrough(new I({transform:function(t,e){var n,o,i,s,a,u;if((null===(i=null===(o=null===(n=null==t?void 0:t.choices)||void 0===n?void 0:n[0])||void 0===o?void 0:o.delta)||void 0===i?void 0:i.content)||(null===(u=null===(a=null===(s=null==t?void 0:t.choices)||void 0===s?void 0:s[0])||void 0===a?void 0:a.delta)||void 0===u?void 0:u.tool_calls)){var c=t.choices.map((function(t){var e=Object.assign(t.delta,{role:"assistant"});return null==r&&(r=L(e)),dt(dt({},t),r?{finish_reason:"tool_calls",delta:e}:{delta:e})})),l=dt(dt({},t),{choices:c});e.enqueue(dt(dt({},l),{rawResponse:t}))}}})),[2,A(s)]}}))}))},t}(),mt=function(){return mt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},mt.apply(this,arguments)},bt=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},wt=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};function _t(t){var e=t.messages,r=t.model,n=t.temperature,o=t.tools,i=t.top_p;return mt(mt({},t),{messages:e,model:r,tools:o,top_p:i,temperature:n})}var St=function(){function t(t,e,r){this.req=t,this.baseUrl=e,this.subUrl="moonshot/v1/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return bt(this,void 0,void 0,(function(){var r;return wt(this,(function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:mt(mt({},_t(t)),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return r=n.sent(),[2,mt(mt({},r),{rawResponse:r})]}}))}))},t.prototype.doStream=function(t,e){return bt(this,void 0,void 0,(function(){var r,n,o;return wt(this,(function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:mt(mt({},_t(t)),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return n=i.sent(),o=T(n),[2,A(P(o).pipeThrough(new I({transform:function(t,e){var n=t.choices.map((function(t){var e=t.delta;return null==r&&(r=L(e)),r?mt(mt({},t),{finish_reason:"tool_calls",delta:e}):t})),o=mt(mt({},t),{choices:n});e.enqueue(mt(mt({},o),{rawResponse:t}))}})))]}}))}))},t}(),Et=function(){return Et=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Et.apply(this,arguments)},It=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},Ot=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},Tt=function(){function t(t,e,r){this.req=t,this.baseUrl=e,this.subUrl="hunyuan-exp/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t){return It(this,void 0,void 0,(function(){var e;return Ot(this,(function(r){switch(r.label){case 0:return[4,this.req({url:this.url,data:Et(Et({},K(t)),{stream:!1}),stream:!1})];case 1:return e=r.sent(),[2,Et(Et({},e),{rawResponse:e})]}}))}))},t.prototype.doStream=function(t){return It(this,void 0,void 0,(function(){var e,r,n;return Ot(this,(function(o){switch(o.label){case 0:return e=null,[4,this.req({url:this.url,data:Et(Et({},K(t)),{stream:!0}),stream:!0})];case 1:return r=o.sent(),n=T(r),[2,A(P(n).pipeThrough(new I({transform:function(t,r){var n=t.choices.map((function(t){var r=t.delta;return null==e&&(e=L(r)),e?Et(Et({},t),{finish_reason:"tool_calls",delta:r}):t})),o=Et(Et({},t),{choices:n});r.enqueue(Et(Et({},o),{rawResponse:t}))}})))]}}))}))},t}(),Rt=function(){return Rt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Rt.apply(this,arguments)},At=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},Pt=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},xt=function(){function t(t,e,r){this.req=t,this.baseUrl=e,this.subUrl="hunyuan-open/v1/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return At(this,void 0,void 0,(function(){var r;return Pt(this,(function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:Rt(Rt({},K(t)),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return r=n.sent(),[2,Rt(Rt({},r),{rawResponse:r})]}}))}))},t.prototype.doStream=function(t,e){return At(this,void 0,void 0,(function(){var r,n,o;return Pt(this,(function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:Rt(Rt({},K(t)),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return n=i.sent(),o=T(n),[2,A(P(o).pipeThrough(new I({transform:function(t,e){var n=t.choices.map((function(t){var e=t.delta;return null==r&&(r=L(e)),r?Rt(Rt({},t),{finish_reason:"tool_calls",delta:e}):t})),o=Rt(Rt({},t),{choices:n});e.enqueue(Rt(Rt({},o),{rawResponse:t}))}})))]}}))}))},t}(),Ct=function(){return Ct=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Ct.apply(this,arguments)},Nt=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},Lt=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},jt=function(){function t(t,e,r){this.req=t,this.baseUrl=e,this.subUrl="deepseek/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return Nt(this,void 0,void 0,(function(){var r;return Lt(this,(function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:Ct(Ct({},t),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return r=n.sent(),[2,Ct(Ct({},r),{rawResponse:r})]}}))}))},t.prototype.doStream=function(t,e){return Nt(this,void 0,void 0,(function(){var r,n,o;return Lt(this,(function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:Ct(Ct({},t),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return n=i.sent(),o=T(n),[2,A(P(o).pipeThrough(new I({transform:function(t,e){var n=t.choices.map((function(t){var e=t.delta;return null==r&&(r=L(e)),r?Ct(Ct({},t),{finish_reason:"tool_calls",delta:e}):t})),o=Ct(Ct({},t),{choices:n});e.enqueue(Ct(Ct({},o),{rawResponse:t}))}})))]}}))}))},t}(),Ut=function(){return Ut=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Ut.apply(this,arguments)},kt=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},Dt=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},qt=function(){function t(t,e,r){void 0===r&&(r=""),this.req=t,this.baseUrl=e,this.subUrl=r}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t){return kt(this,void 0,void 0,(function(){var e;return Dt(this,(function(r){switch(r.label){case 0:return[4,this.req({url:this.url,data:Ut(Ut({},t),{stream:!1}),stream:!1})];case 1:return e=r.sent(),[2,Ut(Ut({},e),{rawResponse:e})]}}))}))},t.prototype.doStream=function(t){return kt(this,void 0,void 0,(function(){var e,r,n;return Dt(this,(function(o){switch(o.label){case 0:return e=null,[4,this.req({url:this.url,data:Ut(Ut({},t),{stream:!0}),stream:!0})];case 1:return r=o.sent(),n=T(r),[2,A(P(n).pipeThrough(new I({transform:function(t,r){var n=t.choices.map((function(t){var r=t.delta;return null==e&&(e=L(r)),e?Ut(Ut({},t),{finish_reason:"tool_calls",delta:r}):t})),o=Ut(Ut({},t),{choices:n});r.enqueue(Ut(Ut({},o),{rawResponse:t}))}})))]}}))}))},t}(),Mt=function(){return Mt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Mt.apply(this,arguments)},Bt=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},Wt=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},Ft=function(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))};function Vt(t){var e,r=t.onStepFinish,n=t.abortSignal,o=t.maxSteps,i=t.topP,s=t.toolChoice,a=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}(t,["onStepFinish","abortSignal","maxSteps","topP","toolChoice"]);if(null!=o&&o<1)throw new Error("`maxSteps` muse be greater than 0.");return[{onStepFinish:r,abortSignal:n,maxSteps:o},Mt(Mt({},a),{tools:null===(e=a.tools)||void 0===e?void 0:e.map((function(t){return"fn"in t?j(t):t})),top_p:null!=i?i:a.top_p,tool_choice:null!=s?s:a.tool_choice})]}var Ht=function(){function t(t){this.model=t}return t.prototype.generateText=function(t,e){var r,n;return Bt(this,void 0,void 0,(function(){var o,i,s,a,u,c,l,f,h,d,p,y,v,g,m,b,w,_,S,E,I,O=this;return Wt(this,(function(T){switch(T.label){case 0:return o=[],i={completion_tokens:0,prompt_tokens:0,total_tokens:0},s=Vt(t),a=s[0],u=a.onStepFinish,c=a.maxSteps,l=void 0===c?10:c,f=s[1],[4,(h=function(){return O.model.doGenerate(f,e)})()];case 1:d=T.sent(),p=1,d.rawResponse&&o.push(d.rawResponse),y=null,T.label=2;case 2:if(!(p<l&&null!=(y=Gt(d))))return[3,9];v=Jt(d.usage),Yt(i,v),T.label=3;case 3:return T.trys.push([3,7,,8]),[4,zt(y)];case 4:return g=T.sent(),m=d.choices[0],[4,null==u?void 0:u({finishReason:m.finish_reason,messages:f.messages.slice(),text:m.message.content,toolCall:y,toolResult:g,stepUsage:v,totalUsage:Object.assign({},i)})];case 5:return T.sent(),$t(f.messages,m.message,g),[4,h()];case 6:return(d=T.sent()).rawResponse&&o.push(d.rawResponse),p+=1,[3,8];case 7:return b=T.sent(),[2,{text:"",messages:f.messages,usage:i,error:b,rawResponses:o}];case 8:return[3,2];case 9:return w=null===(r=null==d?void 0:d.choices)||void 0===r?void 0:r[0],_=null==w?void 0:w.message,S=null!==(n=null==_?void 0:_.content)&&void 0!==n?n:"",E=_?Ft(Ft([],f.messages,!0),[_],!1):f.messages,I=Jt(d.usage),Yt(i,I),[4,null==u?void 0:u({finishReason:w.finish_reason,messages:E.slice(),text:S,toolCall:Gt(d),toolResult:null,stepUsage:I,totalUsage:Object.assign({},i)})];case 10:return T.sent(),[2,{text:S,messages:E,usage:i,rawResponses:o}]}}))}))},t.prototype.streamText=function(t,e){var r;return Bt(this,void 0,void 0,(function(){var n,o,i,s,a,u,c,l,f,h,d,p,y,v,g,m,b,w,_,S,E,O,T,R,P,x,C,L,j,U,k,D,q,M,B,W,F=this;return Wt(this,(function(V){switch(V.label){case 0:return n={completion_tokens:0,prompt_tokens:0,total_tokens:0},o=Vt(t),i=o[0],s=i.onStepFinish,a=i.maxSteps,u=void 0===a?10:a,c=o[1],[4,(l=function(){return F.model.doStream(c,e)})()];case 1:f=V.sent(),h=1,d=null,p=function(){var t=f.tee(),e=t[0],r=t[1];return f=A(e),function(t){var e,r,n,o,i,s,a,u,c,l;return Bt(this,void 0,void 0,(function(){var f,h,d,p,y,v,g,m,b,w,_,S,E;return Wt(this,(function(I){switch(I.label){case 0:f={completion_tokens:0,prompt_tokens:0,total_tokens:0},h=A(t),p={role:"assistant",content:"",tool_calls:[d={id:"",function:{name:"",arguments:""},type:""}]},I.label=1;case 1:I.trys.push([1,6,7,12]),y=!0,v=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,r=t[Symbol.asyncIterator];return r?r.call(t):(t="function"==typeof __values?__values(t):t[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(r){e[r]=t[r]&&function(e){return new Promise((function(n,o){!function(t,e,r,n){Promise.resolve(n).then((function(e){t({value:e,done:r})}),e)}(n,o,(e=t[r](e)).done,e.value)}))}}}(h),I.label=2;case 2:return[4,v.next()];case 3:if(g=I.sent(),e=g.done)return[3,5];o=g.value,y=!1;try{if(!(b=null==(m=o)?void 0:m.choices[0]))return[2,null];if(w=b.finish_reason,_=b.delta,"tool_calls"!==w)return[2,null];if(!_)return[3,4];if(_.content&&(p.content+=_.content),!("tool_calls"in _))return[3,4];(null==(S=null===(i=null==_?void 0:_.tool_calls)||void 0===i?void 0:i[0])?void 0:S.id)&&(d.id=S.id),(null==S?void 0:S.type)&&(d.type=S.type),(null===(s=null==S?void 0:S.function)||void 0===s?void 0:s.name)&&(d.function.name=S.function.name),(null===(a=null==S?void 0:S.function)||void 0===a?void 0:a.arguments)&&(d.function.arguments+=S.function.arguments),(null===(u=null==m?void 0:m.usage)||void 0===u?void 0:u.completion_tokens)&&(f.completion_tokens=m.usage.completion_tokens),(null===(c=null==m?void 0:m.usage)||void 0===c?void 0:c.prompt_tokens)&&(f.prompt_tokens=m.usage.prompt_tokens),(null===(l=null==m?void 0:m.usage)||void 0===l?void 0:l.total_tokens)&&(f.total_tokens=m.usage.total_tokens)}finally{y=!0}I.label=4;case 4:return[3,2];case 5:return[3,12];case 6:return E=I.sent(),r={error:E},[3,12];case 7:return I.trys.push([7,,10,11]),y||e||!(n=v.return)?[3,9]:[4,n.call(v)];case 8:I.sent(),I.label=9;case 9:return[3,11];case 10:if(r)throw r.error;return[7];case 11:return[7];case 12:return[2,{message:p,usage:f}]}}))}))}(r)},V.label=2;case 2:return(y=h<u)?[4,p()]:[3,4];case 3:y=null!=(d=V.sent()),V.label=4;case 4:if(!y)return[3,11];v=d.message,g=d.usage,Yt(n,g),m=null===(r=v.tool_calls)||void 0===r?void 0:r[0],V.label=5;case 5:return V.trys.push([5,9,,10]),[4,zt(m)];case 6:return b=V.sent(),[4,null==s?void 0:s({finishReason:"tool_calls",messages:c.messages.slice(),text:v.content,toolCall:m,toolResult:b,stepUsage:g,totalUsage:Object.assign({},n)})];case 7:return V.sent(),$t(c.messages,v,b),[4,l()];case 8:return f=V.sent(),[3,10];case 9:return w=V.sent(),_=f.tee(),S=_[0],E=_[1],[2,{messages:Promise.resolve(c.messages),dataStream:A(S),textStream:A(E.pipeThrough(new I({transform:function(t,e){var r,n,o,i=null===(o=null===(n=null===(r=null==t?void 0:t.choices)||void 0===r?void 0:r[0])||void 0===n?void 0:n.delta)||void 0===o?void 0:o.content;"string"==typeof i&&e.enqueue(i)}}))),usage:Promise.resolve(n),error:w}];case 10:return[3,2];case 11:return[4,p()];case 12:return(d=V.sent())?(O=d.message,T=d.usage,Yt(n,T),R=Ft(Ft([],c.messages,!0),[O],!1),s({messages:R.slice(),finishReason:"tool_call",stepUsage:T,text:O.content,toolCall:O.tool_calls[0],totalUsage:Object.assign({},n)}),P=f.tee(),x=P[0],C=P[1],[2,{messages:Promise.resolve(Ft(Ft([],c.messages,!0),[O],!1)),dataStream:A(x),textStream:A(C.pipeThrough(new I({transform:function(t,e){var r,n,o,i=null===(o=null===(n=null===(r=null==t?void 0:t.choices)||void 0===r?void 0:r[0])||void 0===n?void 0:n.delta)||void 0===o?void 0:o.content;"string"==typeof i&&e.enqueue(i)}}))),usage:Promise.resolve(n)}]):(L=N(),j=N(),U={role:"assistant",content:""},k="",D={completion_tokens:0,prompt_tokens:0,total_tokens:0},q=f.pipeThrough(new I({transform:function(t,e){var r,n,o,i,s,a,u,c,l=null===(o=null===(n=null===(r=null==t?void 0:t.choices)||void 0===r?void 0:r[0])||void 0===n?void 0:n.delta)||void 0===o?void 0:o.content;"string"==typeof l&&(U.content+=l);var f=null===(s=null===(i=null==t?void 0:t.choices)||void 0===i?void 0:i[0])||void 0===s?void 0:s.finish_reason;f&&(k=f),(null===(a=null==t?void 0:t.usage)||void 0===a?void 0:a.completion_tokens)&&(D.completion_tokens=t.usage.completion_tokens),(null===(u=null==t?void 0:t.usage)||void 0===u?void 0:u.prompt_tokens)&&(D.prompt_tokens=t.usage.prompt_tokens),(null===(c=null==t?void 0:t.usage)||void 0===c?void 0:c.total_tokens)&&(D.total_tokens=t.usage.total_tokens),e.enqueue(t)},flush:function(){L.res(Ft(Ft([],c.messages,!0),[U],!1)),Yt(n,D),j.res(Object.assign({},n)),null==s||s({messages:Ft(Ft([],c.messages,!0),[U],!1),finishReason:k,text:U.content,stepUsage:D,totalUsage:Object.assign({},n)})}})),M=q.tee(),B=M[0],W=M[1],[2,{messages:L.promise,dataStream:A(B),textStream:A(W.pipeThrough(new I({transform:function(t,e){var r,n,o,i=null===(o=null===(n=null===(r=null==t?void 0:t.choices)||void 0===r?void 0:r[0])||void 0===n?void 0:n.delta)||void 0===o?void 0:o.content;"string"==typeof i&&e.enqueue(i)}}))),usage:j.promise}])}}))}))},t}();function Gt(t){var e,r=null===(e=null==t?void 0:t.choices)||void 0===e?void 0:e[0];if(!r)return null;var n=r.finish_reason,o=r.message;return"tool_calls"!==n?null:o&&L(o)?o.tool_calls[0]:null}function $t(t,e,r){t.push(e,{role:"tool",tool_call_id:e.tool_calls[0].id,content:JSON.stringify(r)})}var Kt=new Map;function zt(t){return Kt.get(t.function.name)(JSON.parse(t.function.arguments))}function Jt(t){var e,r,n;return{completion_tokens:null!==(e=null==t?void 0:t.completion_tokens)&&void 0!==e?e:0,prompt_tokens:null!==(r=null==t?void 0:t.prompt_tokens)&&void 0!==r?r:0,total_tokens:null!==(n=null==t?void 0:t.total_tokens)&&void 0!==n?n:0}}function Yt(t,e){t.completion_tokens+=e.completion_tokens,t.prompt_tokens+=e.prompt_tokens,t.total_tokens+=e.total_tokens}var Qt={hunyuan:rt,"hunyuan-beta":Z,ark:at,dashscope:ht,"01-ai":gt,moonshot:St,zhipu:G,"hunyuan-exp":Tt,"hunyuan-open":xt,deepseek:jt},Zt=r(3616),Xt=function(){return Xt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Xt.apply(this,arguments)},te=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},ee=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},re=Qt,ne=function(){function t(t,e,r){var n=this;this.req=t,this.baseUrl=e,this.modelRequest=function(t){var e=t.url,r=t.data,o=t.headers,i=t.stream,s=t.timeout;return te(n,void 0,void 0,(function(){var t,n,a,u,c,l,f;return ee(this,(function(h){switch(h.label){case 0:return t={"Content-Type":"application/json"},i&&Object.assign(t,{Accept:"text/event-stream"}),[4,this.req.fetch({method:"post",headers:Xt(Xt((c={},c[null===(l=this.i18n)||void 0===l?void 0:l.LANG_HEADER_KEY]=null===(f=this.i18n)||void 0===f?void 0:f.lang,c),t),o),body:JSON.stringify(r),url:e,stream:i,timeout:s})];case 1:return n=h.sent(),a=n.data,u=n.header,[2,this.handleResponseData(a,u)]}}))}))},this.botRequest=function(t){var e=t.method,r=t.url,o=t.data,i=void 0===o?{}:o,s=t.headers,a=t.stream,u=t.timeout;return te(n,void 0,void 0,(function(){var t,n,o,c,l,f,h,d;return ee(this,(function(p){switch(p.label){case 0:return"get"!==e?[3,2]:(t=this.handleResponseData,[4,this.req.fetch({url:"".concat(r,"?").concat((y=i,Object.entries(y).map((function(t){var e=t[0],r=t[1];return"".concat(e,"=").concat(r)})).join("&"))),method:e,headers:s,stream:a,timeout:u})]);case 1:return[2,t.apply(this,[p.sent().data])];case 2:return n={"Content-Type":"application/json"},a&&Object.assign(n,{Accept:"text/event-stream"}),[4,this.req.fetch({url:r,body:JSON.stringify(i),headers:Xt(Xt((f={},f[null===(h=this.i18n)||void 0===h?void 0:h.LANG_HEADER_KEY]=null===(d=this.i18n)||void 0===d?void 0:d.lang,f),n),s),stream:a,method:e,timeout:u})];case 3:return o=p.sent(),c=o.data,l=o.header,[2,this.handleResponseData(c,l)]}var y}))}))},this.aiBaseUrl="".concat(e,"/ai"),this.aiBotBaseUrl="".concat(e,"/aibot"),this.bot=new M(this.botRequest,this.aiBotBaseUrl),this.i18n=r,Zt.RR.$.on(Zt.RR.P,(function(t){var e;n.i18n=(null===(e=t.data)||void 0===e?void 0:e.i18n)||n.i18n}))}return t.prototype.handleResponseData=function(t,e){var r,n;return te(this,void 0,void 0,(function(){var o,i;return ee(this,(function(s){switch(s.label){case 0:return o="".concat(this.i18n.t("请检查调用方式,或前往云开发 AI+ 首页查看文档"),":https://tcb.cloud.tencent.com/dev#/ai"),"object"==typeof t&&t&&"then"in t?[4,t]:[3,2];case 1:if("object"==typeof(i=s.sent())&&i&&"code"in i&&"NORMAL"!==i.code)throw new Error("".concat(this.i18n.t("AI+ 请求出错,错误码"),":").concat(i.code,",").concat(this.i18n.t("错误信息"),":").concat(i.message,"\n").concat(o,"\n").concat(JSON.stringify(i,null,2)));return[2,t];case 2:return(null===(n=null===(r=null==e?void 0:e.get)||void 0===r?void 0:r.call(e,"content-type"))||void 0===n?void 0:n.includes("application/json"))?[4,C(t)]:[3,4];case 3:if("object"==typeof(i=s.sent())&&i&&"code"in i&&"NORMAL"!==i.code)throw new Error("".concat(this.i18n.t("AI+ 请求出错,错误码"),":").concat(i.code,",").concat(this.i18n.t("错误信息"),":").concat(i.message,"\n").concat(o,"\n").concat(JSON.stringify(i,null,2)));s.label=4;case 4:return[2,t]}}))}))},t.prototype.createModel=function(t,e){var r,n=re[t];if(n)r=new n(this.modelRequest,this.aiBaseUrl);else{var o="string"==typeof(null==e?void 0:e.defaultModelSubUrl)?e.defaultModelSubUrl:"/chat/completions";r=new qt(this.modelRequest,this.aiBaseUrl,"".concat(t).concat(o))}return new Ht(r)},t.prototype.registerModel=function(t,e){null==re[t]?re[t]=e:console.warn("AI model ".concat(t," already exists!"))},t.prototype.registerFunctionTool=function(t){Kt.has(t.name)&&console.warn("AI function tool ".concat(t.name," already exists and will be overwritten!")),Kt.set(t.name,t.fn)},t}(),oe=function(){},ie=function(){return ie=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},ie.apply(this,arguments)},se=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r},ae=se(o,["MODELS"]),ue=function(t){var e=t.getAccessToken,r=t.req;return{download:r.download,post:r.post,upload:r.upload,fetch:function(t){return n=void 0,o=void 0,s=function(){var n,o,i,s,a;return function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}(this,(function(u){switch(u.label){case 0:if("function"!=typeof r.fetch)throw new Error("req.fetch is not a function");return n=t.token,o=t.headers,i=void 0===o?{}:o,s=se(t,["token","headers"]),null==n?[3,1]:(a=n,[3,3]);case 1:return[4,e()];case 2:a=u.sent().accessToken,u.label=3;case 3:return[2,r.fetch(ie({headers:ie({Authorization:"Bearer ".concat(a)},i)},s))]}}))},new((i=void 0)||(i=Promise))((function(t,e){function r(t){try{u(s.next(t))}catch(t){e(t)}}function a(t){try{u(s.throw(t))}catch(t){e(t)}}function u(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i((function(t){t(n)}))).then(r,a)}u((s=s.apply(n,o||[])).next())}));var n,o,i,s}}};function ce(t){var e=t.env,r=t.baseUrl,n=t.req,o=t.getAccessToken,i=t.handleReqInstance,s=t.i18n;return new ne(function(){if(null==i){if(null==o)throw new Error("`getAccessToken` is required when `handleReqInstance` is not provided!");return ue({req:n,getAccessToken:o})}return i({req:n})}(),function(){if(null!=r)return r;if(null==e)throw new Error("`env` is required when `baseUrl` is not provided!");return"https://".concat(e,".api.tcloudbasegateway.com/v1")}(),s)}var le={name:"ai",entity:{ai:function(t){var e,r=this,n=this.request;if(null==n.fetch)throw new Error("cloudbase.request.fetch() unimplemented!");return ce({req:n,baseUrl:null!==(e=null==t?void 0:t.baseUrl)&&void 0!==e?e:function(){var t=r.getEndPointWithKey("GATEWAY"),e=t.BASE_URL,n=t.PROTOCOL;return"".concat(n).concat(e)}(),handleReqInstance:function(t){return t.req},i18n:this.config.i18n})}}};function fe(t){try{t.registerComponent(le)}catch(t){console.warn(t)}}},7505:function(t,e,r){"use strict";r.r(e),r.d(e,{registerAnalytics:function(){return h}});var n=r(3616),o=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},i=n._G.Sg,s=n._G.vM,a=n.BM.D,u="analytics",c=["mall"],l=new(function(){function t(){}return t.prototype.analytics=function(t){return e=this,r=void 0,o=function(){var e,r,n;return function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}(this,(function(o){if(!function(t){if("Object"!==Object.prototype.toString.call(t).slice(8,-1))return!1;var e=t.report_data,r=t.report_type;return!1!==c.includes(r)&&"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(u,".analytics] invalid report data")}));return e=void 0===t.report_data.action_time?Math.floor(Date.now()/1e3):t.report_data.action_time,r={analytics_scene:t.report_type,analytics_data:Object.assign({},t.report_data,{action_time:e})},n={requestData:r},this.request.send("analytics.report",n),[2]}))},new((n=void 0)||(n=Promise))((function(t,i){function s(t){try{u(o.next(t))}catch(t){i(t)}}function a(t){try{u(o.throw(t))}catch(t){i(t)}}function u(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n((function(t){t(r)}))).then(s,a)}u((o=o.apply(e,r||[])).next())}));var e,r,n,o},function(t,e,r,n){var o,i=arguments.length,s=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);i>3&&s&&Object.defineProperty(e,r,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}()),f={name:u,entity:{analytics:l.analytics}};try{cloudbase.registerComponent(f)}catch(t){}function h(t){try{t.registerComponent(f)}catch(t){console.warn(t)}}},2856:function(t,e,r){"use strict";r.r(e),r.d(e,{LANGS:function(){return F},cloudbase:function(){return yt},default:function(){return vt},getBaseEndPoint:function(){return x}});var n=r(3616),o=r(190),i=function(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))},s=n._G.Sg,a={};function u(t,e){var r=e.name,n=e.namespace,o=e.entity,u=e.injectEvents,l=e.IIFE,f=void 0!==l&&l;if(a[r]||n&&t[n])throw new Error(JSON.stringify({code:s.INVALID_OPERATION,msg:"Duplicate component ".concat(r)}));if(f){if(!o||"function"!=typeof o)throw new Error(JSON.stringify({code:s.INVALID_PARAMS,msg:"IIFE component's entity must be a function"}));o.call(t)}if(a[r]=e,n?t.prototype[n]=o:c(t.prototype,o),u){var h=u.bus,d=u.events;if(!h||!d||0===d.length)return;var p=t.prototype.fire||function(){};t.prototype.events||(t.prototype.events={}),(t.prototype.events||{})[r]?t.prototype.events[r].events=i(i([],t.prototype.events[r].events,!0),d,!0):t.prototype.events[r]={bus:h,events:d},t.prototype.fire=function(t,e){p(t,e);for(var r=0,n=Object.keys(this.events);r<n.length;r++){var o=n[r],i=this.events[o],s=i.bus;if(i.events.includes(t)){s.fire(t,e);break}}}}}function c(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 r=0,n=Object.keys(e);r<n.length;r++){var o=n[r];Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=c(t[o],e[o]))}return t}var l={},f=function(){return f=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},f.apply(this,arguments)},h=n.Fs.q,d={},p={};function y(t){var e=t.env,r=t.platformInfo,n={userInfoKey:"".concat("user_info","_").concat(e)};d[e]=d[e]||new h(f(f({},t),{keys:n,platformInfo:r})),p[e]=p[e]||new h(f(f({},t),{keys:n,platformInfo:r,persistence:"local"}))}function v(t){return p[t]}var g=function(){return g=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},g.apply(this,arguments)},m=n._G.tC,b=n._G.pM,w="",_="@cloudbase/js-sdk";function S(){return w}var E,I=[],O=["env","endPointKey","region"],T="https:";function R(t){return I.find((function(e){return O.filter((function(e){return null!=t[e]})).every((function(r){return e[r]===t[r]}))}))}function A(t){var e,r,n=R(t);n?(null!=t.baseUrl&&(n.baseUrl=t.baseUrl),null!=t.protocol&&(n.protocol=t.protocol)):I.push(g(g({},t),{protocol:null!==(e=t.protocol)&&void 0!==e?e:T})),"CLOUD_API"===t.endPointKey&&b(null!==(r=t.protocol)&&void 0!==r?r:T)}function P(t,e,r){return R({env:t,endPointKey:e,region:r})}function x(t){var e=P(t,"CLOUD_API"),r=e.protocol,n=e.baseUrl;return"".concat(r).concat(n).match(/(http(s)?:)?\/\/([^/?#]*)/)[0]}!function(t){t.NULL="NULL",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.PHONE="PHONE"}(E||(E={}));var C=function(){return C=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},C.apply(this,arguments)},N=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},L=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},j=n._G.Sg,U=n.P6.genSeqId,k=n.P6.isFormData,D=n.P6.formatUrl,q=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"];function M(t,e,r){var n=t[e];t[e]=function(e){var o={},i={};r.forEach((function(r){var n=r.call(t,e),s=n.data,a=n.headers;Object.assign(o,s),Object.assign(i,a)}));var s=e.data;return s&&(k(s)?Object.keys(o).forEach((function(t){s.append(t,o[t])})):e.data=C(C({},s),o)),e.headers=C(C({},e.headers||{}),i),n.call(t,e)}}function B(){var t=U();return{data:{seqId:t},headers:{"X-SDK-Version":"@cloudbase/js-sdk/".concat(S()),"x-seqid":t}}}var W,F,V=function(){function t(t){var e=this;this.throwWhenRequestFail=!1,this.config=t;var r={timeout:this.config.timeout,timeoutMsg:"[@cloudbase/js-sdk] 请求在".concat(this.config.timeout/1e3,"s内未完成,已中断"),restrictedMethods:["post","put"]};this.reqClass=new l.adapter.reqClass(r),this.throwWhenRequestFail=t.throw||!1,this.localCache=v(this.config.env),M(this.reqClass,"post",[B]),M(this.reqClass,"upload",[B]),M(this.reqClass,"download",[B]),n.RR.$.on(n.RR.P,(function(t){var r;e.config.i18n=(null===(r=t.data)||void 0===r?void 0:r.i18n)||e.config.i18n}))}return t.prototype.getDefaultHeaders=function(){var t,e,r;return(t={})[null===(e=this.config.i18n)||void 0===e?void 0:e.LANG_HEADER_KEY]=null===(r=this.config.i18n)||void 0===r?void 0:r.lang,t},t.prototype.post=function(t){return N(this,void 0,void 0,(function(){return L(this,(function(e){switch(e.label){case 0:return[4,this.reqClass.post(C(C({},t),{headers:C(C({},t.headers),this.getDefaultHeaders())}))];case 1:return[2,e.sent()]}}))}))},t.prototype.upload=function(t){return N(this,void 0,void 0,(function(){return L(this,(function(e){switch(e.label){case 0:return[4,this.reqClass.upload(C(C({},t),{headers:C(C({},t.headers),this.getDefaultHeaders())}))];case 1:return[2,e.sent()]}}))}))},t.prototype.download=function(t){return N(this,void 0,void 0,(function(){return L(this,(function(e){switch(e.label){case 0:return[4,this.reqClass.download(C(C({},t),{headers:C(C({},t.headers),this.getDefaultHeaders())}))];case 1:return[2,e.sent()]}}))}))},t.prototype.getBaseEndPoint=function(){return x(this.config.env)},t.prototype.getOauthAccessTokenV2=function(t){return N(this,void 0,void 0,(function(){var e,r;return L(this,(function(n){switch(n.label){case 0:return[4,t.getAccessToken()];case 1:return e=n.sent(),[4,t.getCredentials()];case 2:return r=n.sent(),[2,{accessToken:e,accessTokenExpire:new Date(r.expires_at).getTime()}]}}))}))},t.prototype.request=function(t,e,r){var n,o;return N(this,void 0,void 0,(function(){var i,s,a,u,c,l,f,h,d,p,y,v,g,m,b,w,_,S,E,I;return L(this,(function(O){switch(O.label){case 0:if(i="x-tcb-trace_".concat(this.config.env),s="application/x-www-form-urlencoded",a=C({action:t,dataVersion:"2020-01-10",env:this.config.env},e),-1!==q.indexOf(t))return[3,2];if(!(u=this.config._fromApp).oauthInstance)throw new Error("you can't request without auth");return c=u.oauthInstance,l=c.oauth2client,f=a,[4,this.getOauthAccessTokenV2(l)];case 1:f.access_token=O.sent().accessToken,O.label=2;case 2:return"storage.uploadFile"===t?(h=new FormData,Object.keys(h).forEach((function(t){Object.prototype.hasOwnProperty.call(h,t)&&void 0!==h[t]&&h.append(t,a[t])})),s="multipart/form-data"):(s="application/json;charset=UTF-8",h={},Object.keys(a).forEach((function(t){void 0!==a[t]&&(h[t]=a[t])}))),d={headers:C({"content-type":s},this.getDefaultHeaders())},(null==r?void 0:r.onUploadProgress)&&(d.onUploadProgress=r.onUploadProgress),this.config.region&&(d.headers["X-TCB-Region"]=this.config.region),(p=this.localCache.getStore(i))&&(d.headers["X-TCB-Trace"]=p),y=void 0!==(null==r?void 0:r.parse)?r.parse:e.parse,v=void 0!==(null==r?void 0:r.inQuery)?r.inQuery:e.inQuery,g=void 0!==(null==r?void 0:r.search)?r.search:e.search,m=C(C({},(null==r?void 0:r.defaultQuery)||{}),{env:this.config.env}),y&&(m.parse=!0),v&&(m=C(C({},v),m)),b=P(this.config.env,"CLOUD_API"),w=b.baseUrl,_=b.protocol,S=r.pathname?D(_,"".concat(null===(n=x(this.config.env))||void 0===n?void 0:n.replace(/^https?:/,""),"/").concat(r.pathname),m):D(_,w,m),g&&(S+=g),[4,this.post(C({url:S,data:h},d))];case 3:if(E=O.sent(),(I=null===(o=E.header)||void 0===o?void 0:o["x-tcb-trace"])&&this.localCache.setStore(i,I),200!==Number(E.status)&&200!==Number(E.statusCode)||!E.data)throw new Error("network request error");return[2,E]}}))}))},t.prototype.fetch=function(t){var e,r,n,o,i,s,a,u;return N(this,void 0,void 0,(function(){var c,l,f,h,d,p,y,v=this;return L(this,(function(g){switch(g.label){case 0:c=t.token,l=t.headers,f=void 0===l?{}:l,h=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}(t,["token","headers"]),d=function(){return N(v,void 0,void 0,(function(){var t,e,r;return L(this,(function(n){switch(n.label){case 0:if(null!=c)return[2,c];if(!(t=this.config._fromApp).oauthInstance)throw new Error("you can't request without auth");return e=t.oauthInstance,r=e.oauth2client,[4,this.getOauthAccessTokenV2(r)];case 1:return[2,n.sent().accessToken]}}))}))},p=function(){return N(v,void 0,void 0,(function(){var t,e,r,n,o;return L(this,(function(i){switch(i.label){case 0:return e=(t=this.reqClass).fetch,n={},o={"X-SDK-Version":"@cloudbase/js-sdk/".concat(S())},r="Bearer ".concat,[4,d()];case 1:return[2,e.apply(t,[C.apply(void 0,[(n.headers=C.apply(void 0,[C.apply(void 0,[(o.Authorization=r.apply("Bearer ",[i.sent()]),o),this.getDefaultHeaders()]),f]),n),h])])]}}))}))},g.label=1;case 1:return g.trys.push([1,3,,6]),[4,p()];case 2:return[2,g.sent()];case 3:if("ACCESS_TOKEN_EXPIRED"!==(null==(y=g.sent())?void 0:y.code))return[3,5];if("function"!=typeof(null===(o=null===(n=null===(r=null===(e=this.config)||void 0===e?void 0:e._fromApp)||void 0===r?void 0:r.oauthInstance)||void 0===n?void 0:n.authApi)||void 0===o?void 0:o.refreshTokenForce))throw y;return[4,null===(u=null===(a=null===(s=null===(i=this.config)||void 0===i?void 0:i._fromApp)||void 0===s?void 0:s.oauthInstance)||void 0===a?void 0:a.authApi)||void 0===u?void 0:u.refreshTokenForce()];case 4:return g.sent(),[2,p()];case 5:throw y;case 6:return[2]}}))}))},t.prototype.send=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),N(this,void 0,void 0,(function(){var n;return L(this,(function(o){switch(o.label){case 0:return[4,this.request(t,e,C(C({},r),{onUploadProgress:e.onUploadProgress}))];case 1:if((n=o.sent()).data.code&&this.throwWhenRequestFail)throw new Error(JSON.stringify({code:j.OPERATION_FAIL,msg:"[".concat(n.data.code,"] ").concat(n.data.message)}));return[2,n.data]}}))}))},t}(),H={};!function(t){t.ZH="zh-CN",t.EN="en-US"}(F||(F={}));var G=((W={})[F.EN]={"请检查调用方式,或前往云开发 AI+ 首页查看文档":"Please check the calling method or visit the AI+ homepage to view the documentation","AI+ 请求出错,错误码":"AI+ request error, error code","错误信息":"error message","未实现":"not implemented","小程序不支持 wasm 加载":"wasm loading is not supported in mini programs","小程序不支持动态 js 加载":"dynamic js loading is not supported in mini programs","请求超时":"request timeout","缺少 privatelink sdk 地址":"missing privatelink sdk address"},W),$=function(t,e){var r;return(null===(r=G[e])||void 0===r?void 0:r[t])||t},K=function(t,e){var r,o,i=function(t){return"lang_".concat(t.clientId||t.env)}(e),s=(t.adapter||{}).localStorage,a=e.lang||(null===(r=null==s?void 0:s.getItem)||void 0===r?void 0:r.call(s,i))||F.ZH;return null===(o=null==s?void 0:s.setItem)||void 0===o||o.call(s,i,a),new Proxy({t:function(t){return $(t,a)},LANG_HEADER_KEY:"Accept-Language",lang:a},{get:function(t,e){var r;return"lang"===e&&(null===(r=null==s?void 0:s.getItem)||void 0===r?void 0:r.call(s,i))||t[e]},set:function(t,e,r){var o;return"lang"===e&&r!==t[e]&&(t[e]=r,t.t=function(t){return $(t,r)},null===(o=null==s?void 0:s.setItem)||void 0===o||o.call(s,i,r),n.RR.$.fire(n.RR.P,{i18n:t})),t[e]=r,!0}})},z=r(794),J=function(){return J=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},J.apply(this,arguments)},Y=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},Q=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};function Z(t,e){var r,n,o;return Y(this,void 0,void 0,(function(){var i,s,a,u,c,l,f,h,d,p,y,v,g,m,b;return Q(this,(function(w){switch(w.label){case 0:if(s=(i=t||{}).name,a=i.body,u=i.path,c=void 0===u?"":u,l=i.method,f=void 0===l?"POST":l,h=i.headers,d=void 0===h?{}:h,p=i.token,!s)throw new Error(JSON.stringify({code:z.ERRORS.INVALID_PARAMS,msg:"[apis] invalid api name"}));return y=this.getEndPointWithKey("GATEWAY"),v=y.BASE_URL,g=y.PROTOCOL,m="".concat(g).concat(v,"/apis/").concat(s),b=c.startsWith("/")?c:"/".concat(c),[4,this.request.fetch(J({url:"".concat(m).concat(b),method:f||"POST",headers:J({"Content-Type":"application/json; charset=utf-8"},d),body:a,token:(null===(r=null==p?void 0:p.trim)||void 0===r?void 0:r.call(p))||(null===(o=null===(n=d.Authorization)||void 0===n?void 0:n.replace)||void 0===o?void 0:o.call(n,/^Bearer /,""))||""},e))];case 1:return[4,w.sent().data];case 2:return[2,w.sent()]}}))}))}var X=["GET","POST","PUT","DELETE","HEAD","OPTIONS","PATCH","REQUEST"];function tt(t){var e=this;return new Proxy({},{get:function(r,n){if("string"!=typeof n)throw new Error("[apis] method must be string");var o=n.toLocaleUpperCase();if(!X.includes(o))throw new Error("[apis] invalid method: ".concat(n));return function(r,n){return Y(e,void 0,void 0,(function(){return Q(this,(function(e){switch(e.label){case 0:return[4,Z.call(this,J({name:t,method:("REQUEST"===o?r.method:o)||"POST"},r),n)];case 1:return[2,e.sent()]}}))}))}}})}function et(){var t=this;return new Proxy({},{get:function(e,r){if("string"==typeof r)return tt.call(t,r)}})}var rt=function(){return rt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},rt.apply(this,arguments)},nt=function(t,e,r,n){var o,i=arguments.length,s=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s},ot=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},it=n.j$.Fk,st=n.j$.xY,at=n._G.Sg,ut=n._G.vM,ct=n.P6.printWarn,lt=n.BM.D,ft={timeout:15e3,persistence:"local"},ht=6e5,dt={},pt=function(){function t(t){this.cloudbaseConfig=t||this.cloudbaseConfig,this.authInstance=null,this.oauthInstance=null,this.version=S()}return Object.defineProperty(t.prototype,"config",{get:function(){return this.cloudbaseConfig},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"platform",{get:function(){return l},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cache",{get:function(){return t=this.cloudbaseConfig.env,d[t];var t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCache",{get:function(){return v(this.cloudbaseConfig.env)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"request",{get:function(){return t=this.cloudbaseConfig.env,H[t];var t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"apis",{get:function(){return et.call(this)},enumerable:!1,configurable:!0}),t.prototype.init=function(e){var r;if(!e.env)throw new Error(JSON.stringify({code:at.INVALID_PARAMS,msg:"env must not be specified"}));l.adapter||this.useDefaultAdapter();var n={timeout:e.timeout||5e3,timeoutMsg:"[".concat(_,"][REQUEST TIMEOUT] request had been abort since didn't finished within").concat(e.timeout/1e3,"s")};this.requestClient=new l.adapter.reqClass(n),this.cloudbaseConfig=rt(rt(rt({},ft),e),{i18n:K(l,e)}),delete this.cloudbaseConfig.lang,this.cloudbaseConfig.timeout=this.formatTimeout(this.cloudbaseConfig.timeout);var o=this.cloudbaseConfig,i=o.env,s=o.persistence,a=o.debug,u=o.timeout,c=o.oauthClient,f=o.i18n;y({env:i,persistence:s,debug:a,platformInfo:this.platform}),function(t,e){A({env:t,region:e,baseUrl:e?"//".concat(t,".").concat(e,".tcb-api.tencentcloudapi.com/web"):"//".concat(t,".ap-shanghai.tcb-api.tencentcloudapi.com/web"),protocol:void 0,endPointKey:"CLOUD_API"})}(i,e.region||""),function(t){A({endPointKey:"GATEWAY",env:t,baseUrl:"//".concat(t,".api.tcloudbasegateway.com/v1"),protocol:void 0})}(i);var h=new t(this.cloudbaseConfig);return function(t){H[t.env]=new V(C(C({},t),{throw:!0}))}({env:i,region:e.region||"",timeout:u,oauthClient:c,_fromApp:h,i18n:f}),h.requestClient=this.requestClient,null===(r=null==this?void 0:this.fire)||void 0===r||r.call(this,"cloudbase_init",h),h},t.prototype.updateConfig=function(t){var e=t.persistence,r=t.debug;this.cloudbaseConfig.persistence=e,this.cloudbaseConfig.debug=r,y({env:this.cloudbaseConfig.env,persistence:e,debug:r,platformInfo:this.platform})},t.prototype.updateLang=function(t){var e;t&&t!==(null===(e=this.cloudbaseConfig.i18n)||void 0===e?void 0:e.lang)&&(this.cloudbaseConfig.i18n.lang=t)},t.prototype.registerExtension=function(t){dt[t.name]=t},t.prototype.invokeExtension=function(t,e){return r=this,n=void 0,i=function(){var r;return function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}(this,(function(n){switch(n.label){case 0:if(!(r=dt[t]))throw new Error(JSON.stringify({code:at.INVALID_PARAMS,msg:"extension:".concat(t," must be registered before invoke")}));return[4,r.invoke(e,this)];case 1:return[2,n.sent()]}}))},new((o=void 0)||(o=Promise))((function(t,e){function s(t){try{u(i.next(t))}catch(t){e(t)}}function a(t){try{u(i.throw(t))}catch(t){e(t)}}function u(e){var r;e.done?t(e.value):(r=e.value,r instanceof o?r:new o((function(t){t(r)}))).then(s,a)}u((i=i.apply(r,n||[])).next())}));var r,n,o,i},t.prototype.useAdapters=function(t,e){var r=it(t,e)||{},n=r.adapter,o=r.runtime;n&&(l.adapter=n),o&&(l.runtime=o)},t.prototype.registerHook=function(e){!function(t,e){var r=e.entity,n=e.target;if(Object.prototype.hasOwnProperty.call(t,n))throw new Error(JSON.stringify({code:s.INVALID_OPERATION,msg:"target:".concat(n," is not exist")}));var o=t.prototype[n];if("function"!=typeof o)throw new Error(JSON.stringify({code:s.INVALID_OPERATION,msg:"target:".concat(n," is not a function which is the only type supports hook")}));t.prototype[n]=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return r.call.apply(r,i([this],t,!1)),o.call.apply(o,i([this],t,!1))}}(t,e)},t.prototype.registerComponent=function(e){u(t,e)},t.prototype.registerVersion=function(t){!function(t){w=t}(t),this.version=t},t.prototype.registerSdkName=function(t){!function(t){_=t,m(t)}(t)},t.prototype.registerEndPoint=function(t,e){A({baseUrl:t,protocol:e,env:this.config.env,endPointKey:"CLOUD_API"})},t.prototype.registerEndPointWithKey=function(t){A({env:this.config.env,endPointKey:t.key,baseUrl:t.url,protocol:t.protocol})},t.prototype.getEndPointWithKey=function(t){var e=P(this.config.env,t);return{BASE_URL:e.baseUrl,PROTOCOL:e.protocol}},t.prototype.parseCaptcha=function(t){var e={},r=t.match(/^(data:.*?)(\?[^#\s]*)?$/);if(r){t=r[1];var o=r[2];o&&(e=n.P6.parseQueryString(o))}var i=e.token,s=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}(e,["token"]);return/^data:/.test(t)&&!i?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(t)}:i?{state:s.state,token:i,captchaData:t}:{error:"unimplemented",error_description:"need to impl captcha data"}},t.prototype.useDefaultAdapter=function(){var t=st(),e=t.adapter,r=t.runtime;l.adapter=e,l.runtime=r},t.prototype.formatTimeout=function(t){switch(!0){case t>ht:return ct(at.INVALID_PARAMS,"timeout is greater than maximum value[10min]"),ht;case t<100:return ct(at.INVALID_PARAMS,"timeout is less than maximum value[100ms]"),100;default:return t}},nt([lt({mode:"sync",title:"Cloudbase 初始化失败",messages:["请确认以下各项:"," 1 - 调用 cloudbase.init() 的语法或参数是否正确"," 2 - 如果是非浏览器环境,是否配置了安全应用来源(https://docs.cloudbase.net/api-reference/webv3/adapter#%E7%AC%AC-2-%E6%AD%A5%E9%85%8D%E7%BD%AE%E5%AE%89%E5%85%A8%E5%BA%94%E7%94%A8%E6%9D%A5%E6%BA%90)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(ut)]}),ot("design:type",Function),ot("design:paramtypes",[Object]),ot("design:returntype",t)],t.prototype,"init",null),nt([lt({title:"调用扩展能力失败",messages:["请确认以下各项:"," 1 - 调用 invokeExtension() 的语法或参数是否正确"," 2 - 被调用的扩展能力是否已经安装并通过 registerExtension() 注册","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(ut)]}),ot("design:type",Function),ot("design:paramtypes",[String,Object]),ot("design:returntype",Promise)],t.prototype,"invokeExtension",null),t}(),yt=new pt;yt.useAdapters(o.ZP);var vt=yt},7170:function(t,e,r){"use strict";r.r(e),r.d(e,{Auth:function(){return St},LoginState:function(){return _t},generateAuthInstance:function(){return Et},registerAuth:function(){return Ot}});var n,o,i,s,a,u,c="/auth";function l(){return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(t=>{var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))}!function(t){t.AUTH_SIGN_UP_URL="/v1/signup",t.AUTH_TOKEN_URL="/v1/token",t.AUTH_REVOKE_URL="/v1/revoke",t.WEDA_USER_URL="/v1/plugin/weda/userinfo",t.AUTH_RESET_PASSWORD="/v1/reset",t.AUTH_GET_DEVICE_CODE="/v1/device/code",t.CHECK_USERNAME="/v1/checkUsername",t.CHECK_IF_USER_EXIST="/v1/checkIfUserExist",t.GET_PROVIDER_TYPE="/v1/mgr/provider/providerSubType",t.AUTH_SIGN_IN_URL="/v1/signin",t.AUTH_SIGN_IN_ANONYMOUSLY_URL="/v1/signin/anonymously",t.AUTH_SIGN_IN_WITH_PROVIDER_URL="/v1/signin/with/provider",t.AUTH_SIGN_IN_WITH_WECHAT_URL="/v1/signin/wechat/noauth",t.AUTH_SIGN_IN_CUSTOM="/v1/signin/custom",t.PROVIDER_TOKEN_URL="/v1/provider/token",t.PROVIDER_URI_URL="/v1/provider/uri",t.USER_ME_URL="/v1/user/me",t.AUTH_SIGNOUT_URL="/v1/user/signout",t.USER_QUERY_URL="/v1/user/query",t.USER_PRIFILE_URL="/v1/user/profile",t.USER_BASIC_EDIT_URL="/v1/user/basic/edit",t.USER_TRANS_BY_PROVIDER_URL="/v1/user/trans/by/provider",t.PROVIDER_LIST="/v1/user/provider",t.PROVIDER_BIND_URL="/v1/user/provider/bind",t.PROVIDER_UNBIND_URL="/v1/user/provider",t.CHECK_PWD_URL="/v1/user/sudo",t.SUDO_URL="/v1/user/sudo",t.BIND_CONTACT_URL="/v1/user/contact",t.AUTH_SET_PASSWORD="/v1/user/password",t.AUTHORIZE_DEVICE_URL="/v1/user/device/authorize",t.AUTHORIZE_URL="/v1/user/authorize",t.AUTHORIZE_INFO_URL="/v1/user/authorize/info",t.AUTHORIZED_DEVICES_DELETE_URL="/v1/user/authorized/devices/",t.AUTH_REVOKE_ALL_URL="/v1/user/revoke/all",t.GET_USER_BEHAVIOR_LOG="/v1/user/security/history",t.VERIFICATION_URL="/v1/verification",t.VERIFY_URL="/v1/verification/verify",t.CAPTCHA_DATA_URL="/v1/captcha/data",t.VERIFY_CAPTCHA_DATA_URL="/v1/captcha/data/verify",t.GET_CAPTCHA_URL="/v1/captcha/init",t.GET_MINIPROGRAM_QRCODE="/v1/qrcode/generate",t.GET_MINIPROGRAM_QRCODE_STATUS="/v1/qrcode/get/status"}(n||(n={})),function(t){t.AUTH_SIGN_IN_URL="/v2/signin/username",t.AUTH_TOKEN_URL="/v2/token",t.USER_ME_URL="/v2/user/me",t.VERIFY_URL="/v2/signin/verificationcode",t.AUTH_SIGN_IN_WITH_PROVIDER_URL="/v2/signin/with/provider",t.AUTH_PUBLIC_KEY="/v2/signin/publichkey",t.AUTH_RESET_PASSWORD="/v2/signin/password/update"}(o||(o={})),function(t){t.REGISTER="REGISTER",t.SIGN_IN="SIGN_IN",t.PASSWORD_RESET="PASSWORD_RESET",t.EMAIL_ADDRESS_CHANGE="EMAIL_ADDRESS_CHANGE",t.PHONE_NUMBER_CHANGE="PHONE_NUMBER_CHANGE"}(i||(i={})),(u=s||(s={})).UNREACHABLE="unreachable",u.LOCAL="local",u.CANCELLED="cancelled",u.UNKNOWN="unknown",u.UNAUTHENTICATED="unauthenticated",u.RESOURCE_EXHAUSTED="resource_exhausted",u.FAILED_PRECONDITION="failed_precondition",u.INVALID_ARGUMENT="invalid_argument",u.DEADLINE_EXCEEDED="deadline_exceeded",u.NOT_FOUND="not_found",u.ALREADY_EXISTS="already_exists",u.PERMISSION_DENIED="permission_denied",u.ABORTED="aborted",u.OUT_OF_RANGE="out_of_range",u.UNIMPLEMENTED="unimplemented",u.INTERNAL="internal",u.UNAVAILABLE="unavailable",u.DATA_LOSS="data_loss",u.INVALID_PASSWORD="invalid_password",u.PASSWORD_NOT_SET="password_not_set",u.INVALID_STATUS="invalid_status",u.USER_PENDING="user_pending",u.USER_BLOCKED="user_blocked",u.INVALID_VERIFICATION_CODE="invalid_verification_code",u.TWO_FACTOR_REQUIRED="two_factor_required",u.INVALID_TWO_FACTOR="invalid_two_factor",u.INVALID_TWO_FACTOR_RECOVERY="invalid_two_factor_recovery",u.UNDER_REVIEW="under_review",u.INVALID_REQUEST="invalid_request",u.UNAUTHORIZED_CLIENT="unauthorized_client",u.ACCESS_DENIED="access_denied",u.UNSUPPORTED_RESPONSE_TYPE="unsupported_response_type",u.INVALID_SCOPE="invalid_scope",u.INVALID_GRANT="invalid_grant",u.SERVER_ERROR="server_error",u.TEMPORARILY_UNAVAILABLE="temporarily_unavailable",u.INTERACTION_REQUIRED="interaction_required",u.LOGIN_REQUIRED="login_required",u.ACCOUNT_SELECTION_REQUIRED="account_selection_required",u.CONSENT_REQUIRED="consent_required",u.INVALID_REQUEST_URI="invalid_request_uri",u.INVALID_REQUEST_OBJECT="invalid_request_object",u.REQUEST_NOT_SUPPORTED="request_not_supported",u.REQUEST_URI_NOT_SUPPORTED="request_uri_not_supported",u.REGISTRATION_NOT_SUPPORTED="registration_not_supported",u.CAPTCHA_REQUIRED="captcha_required",u.CAPTCHA_INVALID="captcha_invalid",function(t){t.CLIENT_ID="client_id",t.CLIENT_SECRET="client_secret",t.RESPONSE_TYPE="response_type",t.SCOPE="scope",t.STATE="state",t.REDIRECT_URI="redirect_uri",t.ERROR="error",t.ERROR_DESCRIPTION="error_description",t.ERROR_URI="error_uri",t.GRANT_TYPE="grant_type",t.CODE="code",t.ACCESS_TOKEN="access_token",t.TOKEN_TYPE="token_type",t.EXPIRES_IN="expires_in",t.USERNAME="username",t.PASSWORD="password",t.REFRESH_TOKEN="refresh_token"}(a||(a={}));var f=r(4655);function h(t,e,r,n,o,i,s){try{var a=t[i](s),u=a.value}catch(t){return void r(t)}a.done?e(u):Promise.resolve(u).then(n,o)}function d(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function s(t){h(i,n,o,s,a,"next",t)}function a(t){h(i,n,o,s,a,"throw",t)}s(void 0)}))}}var p=new Map;class y{constructor(t){this.clientId=(null==t?void 0:t.clientId)||"",p=p||new Map}run(t,e){var r=this;return d((function*(){t="".concat(r.clientId,"_").concat(t);var n=p.get(t);return n||(n=new Promise(((n,o)=>{d((function*(){try{yield r.runIdlePromise();var i=e();n(yield i)}catch(t){o(t)}finally{p.delete(t)}}))()})),p.set(t,n)),n}))()}runIdlePromise(){return Promise.resolve()}}var v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",g=r(3616);function m(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function b(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?m(Object(r),!0).forEach((function(e){w(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):m(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function w(t,e,r){return(e=function(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _(t,e,r,n,o,i,s){try{var a=t[i](s),u=a.value}catch(t){return void r(t)}a.done?e(u):Promise.resolve(u).then(n,o)}function S(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function s(t){_(i,n,o,s,a,"next",t)}function a(t){_(i,n,o,s,a,"throw",t)}s(void 0)}))}}var E="x-request-id",I="x-device-id",O="device_id",T=function(){var t=S((function*(t,e){var r=null,n=null;try{var o=Object.assign({},e);o.method||(o.method="GET"),o.body&&"string"!=typeof o.body&&(o.body=JSON.stringify(o.body));var i=yield fetch(t,o),a=yield i.json();null!=a&&a.error?(n=a).error_uri=new URL(t).pathname:r=a}catch(e){n={error:s.UNREACHABLE,error_description:e.message,error_uri:new URL(t).pathname}}if(n)throw n;return r}));return function(e,r){return t.apply(this,arguments)}}(),R=new class{constructor(t){this._env=(null==t?void 0:t.env)||""}getItem(t){var e=this;return S((function*(){return window.localStorage.getItem("".concat(t).concat(e._env))}))()}removeItem(t){var e=this;return S((function*(){window.localStorage.removeItem("".concat(t).concat(e._env))}))()}setItem(t,e){var r=this;return S((function*(){window.localStorage.setItem("".concat(t).concat(r._env),e)}))()}getItemSync(t){return window.localStorage.getItem("".concat(t).concat(this._env))}removeItemSync(t){window.localStorage.removeItem("".concat(t).concat(this._env))}setItemSync(t,e){window.localStorage.setItem("".concat(t).concat(this._env),e)}};function A(t){var e=!0;return null!=t&&t.expires_at&&null!=t&&t.access_token&&(e=t.expires_at<new Date),e}class P{constructor(t){this.credentials=null,this.singlePromise=null,this.tokenSectionName=t.tokenSectionName,this.storage=t.storage,this.clientId=t.clientId,this.singlePromise=new y({clientId:this.clientId})}getStorageCredentialsSync(){var t=null,e=this.storage.getItemSync(this.tokenSectionName);if(null!=e)try{var r;null!==(r=t=JSON.parse(e))&&void 0!==r&&r.expires_at&&(t.expires_at=new Date(t.expires_at))}catch(e){this.storage.removeItem(this.tokenSectionName),t=null}return t}setCredentials(t){var e=this;return S((function*(){if(null!=t&&t.expires_in){if(null!=t&&t.expires_at||(t.expires_at=new Date(Date.now()+1e3*(t.expires_in-30))),e.storage){var r=JSON.stringify(t);yield e.storage.setItem(e.tokenSectionName,r)}e.credentials=t}else e.storage&&(yield e.storage.removeItem(e.tokenSectionName)),e.credentials=null}))()}getCredentials(){var t=this;return S((function*(){return t.singlePromise.run("getCredentials",S((function*(){return A(t.credentials)&&(t.credentials=yield t.getStorageCredentials()),t.credentials})))}))()}getStorageCredentials(){var t=this;return S((function*(){return t.singlePromise.run("_getStorageCredentials",S((function*(){var e=null,r=yield t.storage.getItem(t.tokenSectionName);if(null!=r)try{var n;null!==(n=e=JSON.parse(r))&&void 0!==n&&n.expires_at&&(e.expires_at=new Date(e.expires_at))}catch(r){yield t.storage.removeItem(t.tokenSectionName),e=null}return e})))}))()}}class x{constructor(t){this.singlePromise=null,t.clientSecret||(t.clientSecret=""),!t.clientId&&t.env&&(t.clientId=t.env),this.apiOrigin=t.apiOrigin,this.apiPath=t.apiPath||c,this.clientId=t.clientId,this.i18n=t.i18n,this.singlePromise=new y({clientId:this.clientId}),this.retry=this.formatRetry(t.retry,x.defaultRetry),t.baseRequest?this.baseRequest=t.baseRequest:this.baseRequest=T,this.tokenInURL=t.tokenInURL,this.headers=t.headers,this.storage=t.storage||R,this.localCredentials=new P({tokenSectionName:"credentials_".concat(t.clientId),storage:this.storage,clientId:t.clientId}),this.clientSecret=t.clientSecret,t.clientId&&(this.basicAuth="Basic ".concat(function(t){for(var e,r,n,o,i="",s=0,a=(t=String(t)).length%3;s<t.length;){if((r=t.charCodeAt(s++))>255||(n=t.charCodeAt(s++))>255||(o=t.charCodeAt(s++))>255)throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.");i+=v.charAt((e=r<<16|n<<8|o)>>18&63)+v.charAt(e>>12&63)+v.charAt(e>>6&63)+v.charAt(63&e)}return a?i.slice(0,a-3)+"===".substring(a):i}("".concat(t.clientId,":").concat(this.clientSecret)))),this.wxCloud=t.wxCloud;try{(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})()&&void 0===this.wxCloud&&t.env&&(wx.cloud.init({env:t.env}),this.wxCloud=wx.cloud)}catch(t){}this.refreshTokenFunc=t.refreshTokenFunc||this.defaultRefreshTokenFunc,this.anonymousSignInFunc=t.anonymousSignInFunc,this.onCredentialsError=t.onCredentialsError,g.RR.$.on(g.RR.P,(t=>{var e;this.i18n=(null===(e=t.data)||void 0===e?void 0:e.i18n)||this.i18n}))}setCredentials(t){return this.localCredentials.setCredentials(t)}getAccessToken(){var t=this;return S((function*(){var e=yield t.getCredentials();if(null!=e&&e.access_token)return Promise.resolve(e.access_token);var r={error:s.UNAUTHENTICATED};return Promise.reject(r)}))()}request(t,e){var r=this;return S((function*(){var n,o,i,a;e||(e={});var u=r.formatRetry(e.retry,r.retry);if(e.headers=b(b({},e.headers),{},{[null===(n=r.i18n)||void 0===n?void 0:n.LANG_HEADER_KEY]:null===(o=r.i18n)||void 0===o?void 0:o.lang}),r.headers&&(e.headers=b(b({},r.headers),e.headers)),e.headers[E]||(e.headers[E]=l()),!e.headers[I]){var c=yield r.getDeviceId();e.headers[I]=c}if(null!==(i=e)&&void 0!==i&&i.withBasicAuth&&r.basicAuth&&(e.headers.Authorization=r.basicAuth),null!==(a=e)&&void 0!==a&&a.withCredentials){var f=yield r.getCredentials();f&&(r.tokenInURL?(t.indexOf("?")<0&&(t+="?"),t+="access_token=".concat(f.access_token)):e.headers.Authorization="".concat(f.token_type," ").concat(f.access_token))}else r.clientId&&t.indexOf("client_id")<0&&(t+=t.indexOf("?")<0?"?":"&",t+="client_id=".concat(r.clientId));t.startsWith("/")&&(t="".concat(r.apiOrigin).concat(r.apiPath).concat(t));for(var h=null,d=u+1,p=0;p<d;p++){try{h=e.useWxCloud?yield r.wxCloudCallFunction(t,e):yield r.baseRequest(t,e);break}catch(t){if(e.withCredentials&&t&&t.error===s.UNAUTHENTICATED)return yield r.setCredentials(null),Promise.reject(t);if(p===u||!t||"unreachable"!==t.error)return Promise.reject(t)}yield r.sleep(x.retryInterval)}return h}))()}wxCloudCallFunction(t,e){var r=this;return S((function*(){var n=null,o=null;try{var i,a="";try{a=yield wx.getRendererUserAgent()}catch(t){}var{result:u}=yield r.wxCloud.callFunction({name:"httpOverCallFunction",data:{url:t,method:e.method,headers:b({origin:"https://servicewechat.com","User-Agent":a},e.headers),body:e.body}});null!=u&&null!==(i=u.body)&&void 0!==i&&i.error_code?(o=null==u?void 0:u.body).error_uri=(0,f.y)(t):n=null==u?void 0:u.body}catch(e){o={error:s.UNREACHABLE,error_description:e.message,error_uri:(0,f.y)(t)}}if(o)throw o;return n}))()}getCredentials(){var t=this;return S((function*(){var e=yield t.localCredentials.getCredentials();if(!e){var r,n="credentials not found";return null===(r=t.onCredentialsError)||void 0===r||r.call(t,{msg:n}),t.unAuthenticatedError(n)}if(A(e))if(e.refresh_token)try{e=yield t.refreshToken(e)}catch(r){var o;if("anonymous"!==e.scope)return null===(o=t.onCredentialsError)||void 0===o||o.call(t,{msg:r.error_description}),Promise.reject(r);e=yield t.anonymousLogin(e)}else{if("anonymous"!==e.scope){var i,s="no refresh token found in credentials";return null===(i=t.onCredentialsError)||void 0===i||i.call(t,{msg:s}),t.unAuthenticatedError(s)}e=yield t.anonymousLogin(e)}return e}))()}getCredentialsSync(){return this.localCredentials.getStorageCredentialsSync()}getCredentialsAsync(){return this.getCredentials()}getScope(){var t=this;return S((function*(){var e=yield t.localCredentials.getCredentials();if(!e){var r,n="credentials not found";return null===(r=t.onCredentialsError)||void 0===r||r.call(t,{msg:n}),t.unAuthenticatedError(n)}return e.scope}))()}getGroups(){var t=this;return S((function*(){var e=yield t.localCredentials.getCredentials();if(!e){var r,n="credentials not found";return null===(r=t.onCredentialsError)||void 0===r||r.call(t,{msg:n}),t.unAuthenticatedError(n)}return e.groups}))()}refreshToken(t){var e=this;return S((function*(){return e.singlePromise.run("_refreshToken",S((function*(){if(!t||!t.refresh_token){var r,n="no refresh token found in credentials";return null===(r=e.onCredentialsError)||void 0===r||r.call(e,{msg:n}),e.unAuthenticatedError(n)}try{var o=yield e.refreshTokenFunc(t.refresh_token,t);return yield e.localCredentials.setCredentials(o),o}catch(t){var i;if(t.error===s.INVALID_GRANT){var a;yield e.localCredentials.setCredentials(null);var u=t.error_description;return null===(a=e.onCredentialsError)||void 0===a||a.call(e,{msg:u}),e.unAuthenticatedError(u)}return null===(i=e.onCredentialsError)||void 0===i||i.call(e,{msg:t.error_description}),Promise.reject(t)}})))}))()}anonymousLogin(t){var e=this;return S((function*(){return e.singlePromise.run("_anonymousLogin",S((function*(){if(e.anonymousSignInFunc){var r=yield e.anonymousSignInFunc(t);t=r||(yield e.localCredentials.getCredentials())}else t=yield e.anonymousSignIn(t);return t})))}))()}checkRetry(t){var e=null;if(("number"!=typeof t||t<x.minRetry||t>x.maxRetry)&&(e={error:s.UNREACHABLE,error_description:"wrong options param: retry"}),e)throw e;return t}formatRetry(t,e){return void 0===t?e:this.checkRetry(t)}sleep(t){return S((function*(){return new Promise((e=>{setTimeout((()=>{e()}),t)}))}))()}anonymousSignIn(t){var e=this;return S((function*(){return e.singlePromise.run("_anonymous",S((function*(){if(!t||"anonymous"!==t.scope)return e.unAuthenticatedError("no anonymous in credentials");try{var r=yield e.request(n.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",withBasicAuth:!0,body:{}});return yield e.localCredentials.setCredentials(r),r}catch(t){return t.error===s.INVALID_GRANT?(yield e.localCredentials.setCredentials(null),e.unAuthenticatedError(t.error_description)):Promise.reject(t)}})))}))()}defaultRefreshTokenFunc(t,e){var r=this;return S((function*(){if(void 0===t||""===t){var i,s="refresh token not found";return null===(i=r.onCredentialsError)||void 0===i||i.call(r,{msg:s}),r.unAuthenticatedError(s)}var a=n.AUTH_TOKEN_URL;return"v2"===(null==e?void 0:e.version)&&(a=o.AUTH_TOKEN_URL),b(b({},yield r.request(a,{method:"POST",body:{client_id:r.clientId,client_secret:r.clientSecret,grant_type:"refresh_token",refresh_token:t}})),{},{version:(null==e?void 0:e.version)||"v1"})}))()}getDeviceId(){var t=this;return S((function*(){if(t.deviceID)return t.deviceID;var e=yield t.storage.getItem(O);return"string"==typeof e&&e.length>=16&&e.length<=48||(e=l(),yield t.storage.setItem(O,e)),t.deviceID=e,e}))()}unAuthenticatedError(t){var e={error:s.UNAUTHENTICATED,error_description:t};return Promise.reject(e)}}function C(){if("undefined"==typeof globalThis)return!1;var{wx:t}=globalThis;if(void 0===t)return!1;if(void 0===globalThis.Page)return!1;if(!t.getSystemInfoSync)return!1;if(!t.getStorageSync)return!1;if(!t.setStorageSync)return!1;if(!t.connectSocket)return!1;if(!t.request)return!1;try{if(!t.getSystemInfoSync())return!1;if("qq"===t.getSystemInfoSync().AppPlatform)return!1}catch(t){return!1}return!0}x.defaultRetry=2,x.minRetry=0,x.maxRetry=5,x.retryInterval=1e3;var N=!1;function L(){N=N||void 0!==typeof window&&"miniprogram"===window.__wxjs_environment}try{C()||(N=N||!!navigator.userAgent.match(/miniprogram/i)||"miniprogram"===window.__wxjs_environment,window&&window.WeixinJSBridge&&window.WeixinJSBridge.invoke?L():"undefined"!=typeof document&&document.addEventListener("WeixinJSBridgeReady",L,!1))}catch(t){}function j(){return N}var U=class{constructor(t){if(this.params={},"string"==typeof t)this.parse(t);else if(t&&"object"==typeof t)for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&this.append(e,t[e])}parse(t){t.split("&").forEach((t=>{var[e,r]=t.split("=").map(decodeURIComponent);this.append(e,r)}))}append(t,e){this.params[t]?this.params[t]=this.params[t].concat([e]):this.params[t]=[e]}get(t){return this.params[t]?this.params[t][0]:null}getAll(t){return this.params[t]||[]}delete(t){delete this.params[t]}has(t){return Object.prototype.hasOwnProperty.call(this.params,t)}set(t,e){this.params[t]=[e]}toString(){var t=this,e=[],r=function(r){Object.prototype.hasOwnProperty.call(t.params,r)&&t.params[r].forEach((t=>{e.push("".concat(encodeURIComponent(r),"=").concat(encodeURIComponent(t)))}))};for(var n in this.params)r(n);return e.join("&")}};function k(t,e,r,n,o,i,s){try{var a=t[i](s),u=a.value}catch(t){return void r(t)}a.done?e(u):Promise.resolve(u).then(n,o)}function D(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function s(t){k(i,n,o,s,a,"next",t)}function a(t){k(i,n,o,s,a,"throw",t)}s(void 0)}))}}class q{constructor(t){t.openURIWithCallback||(t.openURIWithCallback=this.getDefaultOpenURIWithCallback()),t.storage||(t.storage=R),this.config=t,this.tokenSectionName="captcha_".concat(t.clientId)}isMatch(){var t,e;return(null===(t=this.config)||void 0===t||null===(t=t.adapter)||void 0===t||null===(e=t.isMatch)||void 0===e?void 0:e.call(t))||C()}request(t,e){var r=this;return D((function*(){e||(e={}),e.method||(e.method="GET");var n,o="".concat(e.method,":").concat(t),i=t;e.withCaptcha&&(i=yield r.appendCaptchaTokenToURL(t,o,!1));try{n=yield r.config.request(i,e)}catch(n){return n.error===s.CAPTCHA_REQUIRED||n.error===s.CAPTCHA_INVALID?(t=yield r.appendCaptchaTokenToURL(t,o,n.error===s.CAPTCHA_INVALID),r.config.request(t,e)):Promise.reject(n)}return n}))()}getDefaultOpenURIWithCallback(){if(!this.isMatch()&&!j()&&(window.location.search.indexOf("__captcha")>0&&(document.body.style.display="none"),null===document.getElementById("captcha_panel_wrap"))){var t=document.createElement("div");t.style.cssText="background-color: rgba(0, 0, 0, 0.7);position: fixed;left: 0px;right: 0px;top: 0px;bottom: 0px;padding: 9vw 0 0 0;display: none;z-index:100;",t.setAttribute("id","captcha_panel_wrap"),setTimeout((()=>{document.body.appendChild(t)}),0)}return this.defaultOpenURIWithCallback}defaultOpenURIWithCallback(t,e){return D((function*(){var{width:r="355px",height:n="355px"}=e||{};if(t.match(/^(data:.*)$/))return Promise.reject({error:s.UNIMPLEMENTED,error_description:"need to impl captcha data"});var o=document.getElementById("captcha_panel_wrap"),i=document.createElement("iframe");return o.innerHTML="",i.setAttribute("src",t),i.setAttribute("id","review-panel-iframe"),i.style.cssText="min-width:".concat(r,";display:block;height:").concat(n,";margin:0 auto;background-color: rgb(255, 255, 255);border: none;"),o.appendChild(i),o.style.display="block",new Promise(((t,e)=>{i.onload=function(){try{var r=window.location,n=i.contentWindow.location;if(n.host+n.pathname===r.host+r.pathname){o.style.display="none";var s=new U(n.search),a=s.get("captcha_token");return a?t({captcha_token:a,expires_in:Number(s.get("expires_in"))}):e({error:s.get("error"),error_description:s.get("error_description")})}o.style.display="block"}catch(t){o.style.display="block"}}}))}))()}getCaptchaToken(t,e){var r=this;return D((function*(){if(!t){var o=yield r.findCaptchaToken();if(o)return o}var i;if(r.isMatch()||j()){var s=yield r.config.request(n.CAPTCHA_DATA_URL,{method:"POST",body:{state:e,redirect_uri:""},withCredentials:!1});i={url:"".concat(s.data,"?state=").concat(encodeURIComponent(e),"&token=").concat(encodeURIComponent(s.token))}}else{var a="".concat(window.location.origin+window.location.pathname,"?__captcha=on");if((i=yield r.config.request(n.GET_CAPTCHA_URL,{method:"POST",body:{client_id:r.config.clientId,redirect_uri:a,state:e},withCredentials:!1})).captcha_token){var u={captcha_token:i.captcha_token,expires_in:i.expires_in};return r.saveCaptchaToken(u),i.captcha_token}}var c=yield r.config.openURIWithCallback(i.url);return r.saveCaptchaToken(c),c.captcha_token}))()}appendCaptchaTokenToURL(t,e,r){var n=this;return D((function*(){var o=yield n.getCaptchaToken(r,e);return t.indexOf("?")>0?t+="&captcha_token=".concat(o):t+="?captcha_token=".concat(o),t}))()}saveCaptchaToken(t){var e=this;return D((function*(){t.expires_at=new Date(Date.now()+1e3*(t.expires_in-10));var r=JSON.stringify(t);yield e.config.storage.setItem(e.tokenSectionName,r)}))()}findCaptchaToken(){var t=this;return D((function*(){var e=yield t.config.storage.getItem(t.tokenSectionName);if(null!=e)try{var r=JSON.parse(e);return null!=r&&r.expires_at&&(r.expires_at=new Date(r.expires_at)),r.expires_at<new Date?null:r.captcha_token}catch(e){return yield t.config.storage.removeItem(t.tokenSectionName),null}return null}))()}}var M=["provider_redirect_uri","other_params"];function B(t,e,r,n,o,i,s){try{var a=t[i](s),u=a.value}catch(t){return void r(t)}a.done?e(u):Promise.resolve(u).then(n,o)}function W(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function s(t){B(i,n,o,s,a,"next",t)}function a(t){B(i,n,o,s,a,"throw",t)}s(void 0)}))}}function F(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function V(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?F(Object(r),!0).forEach((function(e){H(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):F(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function H(t,e,r){return(e=function(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function G(t,e){try{var n;if(((null==e||null===(n=e.root)||void 0===n?void 0:n.globalThis)||globalThis).IS_MP_BUILD)return}catch(e){if(t)return(()=>{try{return r(7171)}catch(t){return}})()}}class ${static parseParamsToSearch(t){return Object.keys(t).forEach((e=>{t[e]||delete t[e]})),new U(t).toString()}constructor(t){var{request:e}=t,r=t.credentialsClient;if(!r){var n={apiOrigin:t.apiOrigin,apiPath:t.apiPath,clientId:t.clientId,storage:t.storage,env:t.env,baseRequest:t.baseRequest,anonymousSignInFunc:t.anonymousSignInFunc,wxCloud:t.wxCloud,onCredentialsError:t.onCredentialsError,headers:t.headers||{},i18n:t.i18n};r=new x(n)}if(!e){var o=r.request.bind(r),i=new q(V({clientId:t.clientId,request:o,storage:t.storage,adapter:t.adapter},t.captchaOptions));e=i.request.bind(i)}this.config={env:t.env,apiOrigin:t.apiOrigin,apiPath:t.apiPath,clientId:t.clientId,request:e,credentialsClient:r,storage:t.storage||R,adapter:t.adapter}}getParamsByVersion(t,e){var r,i=(0,f.I)(t),s=(null===(r={v2:o}[null==i?void 0:i.version])||void 0===r?void 0:r[e])||n[e];return i&&delete i.version,{params:i,url:s}}signIn(t){var e=this;return W((function*(){var r=t.version||"v1",n=e.getParamsByVersion(t,"AUTH_SIGN_IN_URL");n.params.query&&delete n.params.query;var o=yield e.getEncryptParams(n.params),i=yield e.config.request(n.url,{method:"POST",body:o});return yield e.config.credentialsClient.setCredentials(V(V({},i),{},{version:r})),Promise.resolve(i)}))()}signInAnonymously(){var t=arguments,e=this;return W((function*(){var r=t.length>0&&void 0!==t[0]?t[0]:{},o=t.length>1&&void 0!==t[1]&&t[1],i=yield e.config.request(n.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",body:r,useWxCloud:o});return yield e.config.credentialsClient.setCredentials(i),Promise.resolve(i)}))()}signUp(t){var e=this;return W((function*(){var r=yield e.config.request(n.AUTH_SIGN_UP_URL,{method:"POST",body:t});return yield e.config.credentialsClient.setCredentials(r),Promise.resolve(r)}))()}signOut(t){var e=this;return W((function*(){var r={};if(t){try{r=yield e.config.request(n.AUTH_SIGNOUT_URL,{method:"POST",withCredentials:!0,body:t})}catch(t){t.error!==s.UNAUTHENTICATED&&console.log("sign_out_error",t)}return yield e.config.credentialsClient.setCredentials(),r}var o=yield e.config.credentialsClient.getAccessToken(),i=yield e.config.request(n.AUTH_REVOKE_URL,{method:"POST",body:{token:o}});return yield e.config.credentialsClient.setCredentials(),Promise.resolve(i)}))()}revokeAllDevices(){var t=this;return W((function*(){yield t.config.request(n.AUTH_REVOKE_ALL_URL,{method:"DELETE",withCredentials:!0})}))()}revokeDevice(t){var e=this;return W((function*(){yield e.config.request(n.AUTHORIZED_DEVICES_DELETE_URL+t.device_id,{method:"DELETE",withCredentials:!0})}))()}getVerification(t,e){var r=this;return W((function*(){var o=!1;return("CUR_USER"===t.target||(yield r.hasLoginState()))&&(o=!0),r.config.request(n.VERIFICATION_URL,{method:"POST",body:t,withCaptcha:(null==e?void 0:e.withCaptcha)||!1,withCredentials:o})}))()}verify(t){var e=this;return W((function*(){var r=e.getParamsByVersion(t,"VERIFY_URL"),n=yield e.config.request(r.url,{method:"POST",body:r.params});return"v2"===(null==t?void 0:t.version)&&(yield e.config.credentialsClient.setCredentials(V(V({},n),{},{version:"v2"}))),n}))()}genProviderRedirectUri(t){var e=this;return W((function*(){var{provider_redirect_uri:r,other_params:o={}}=t,i=function(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r={};for(var n in t)if({}.hasOwnProperty.call(t,n)){if(e.includes(n))continue;r[n]=t[n]}return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)r=i[n],e.includes(r)||{}.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,M);r&&!i.redirect_uri&&(i.redirect_uri=r);var s="".concat(n.PROVIDER_URI_URL,"?").concat($.parseParamsToSearch(i));return Object.keys(o).forEach((t=>{var e=o[t];("sign_out_uri"!==t||(null==e?void 0:e.length)>0)&&(s+="&other_params[".concat(t,"]=").concat(encodeURIComponent(e)))})),e.config.request(s,{method:"GET"})}))()}grantProviderToken(t){var e=arguments,r=this;return W((function*(){var o=e.length>1&&void 0!==e[1]&&e[1];return r.config.request(n.PROVIDER_TOKEN_URL,{method:"POST",body:t,useWxCloud:o})}))()}patchProviderToken(t){var e=this;return W((function*(){return e.config.request(n.PROVIDER_TOKEN_URL,{method:"PATCH",body:t})}))()}signInWithProvider(t){var e=arguments,r=this;return W((function*(){var n=e.length>1&&void 0!==e[1]&&e[1],o=r.getParamsByVersion(t,"AUTH_SIGN_IN_WITH_PROVIDER_URL"),i=yield r.config.request(o.url,{method:"POST",body:o.params,useWxCloud:n});return yield r.config.credentialsClient.setCredentials(V(V({},i),{},{version:(null==t?void 0:t.version)||"v1"})),Promise.resolve(i)}))()}signInCustom(t){var e=this;return W((function*(){var r=yield e.config.request(n.AUTH_SIGN_IN_CUSTOM,{method:"POST",body:t});return yield e.config.credentialsClient.setCredentials(r),Promise.resolve(r)}))()}signInWithWechat(){var t=arguments,e=this;return W((function*(){var r=t.length>0&&void 0!==t[0]?t[0]:{},o=yield e.config.request(n.AUTH_SIGN_IN_WITH_WECHAT_URL,{method:"POST",body:r});return yield e.config.credentialsClient.setCredentials(o),Promise.resolve(o)}))()}bindWithProvider(t){var e=this;return W((function*(){return e.config.request(n.PROVIDER_BIND_URL,{method:"POST",body:t,withCredentials:!0})}))()}getUserProfile(t){var e=this;return W((function*(){return e.getUserInfo(t)}))()}getUserInfo(){var t=arguments,e=this;return W((function*(){var r,n=t.length>0&&void 0!==t[0]?t[0]:{},o=e.getParamsByVersion(n,"USER_ME_URL");if(null!==(r=o.params)&&void 0!==r&&r.query){var i=new U(o.params.query);o.url+="?".concat(i.toString())}var s=yield e.config.request(o.url,{method:"GET",withCredentials:!0});return s.sub&&(s.uid=s.sub),s}))()}getWedaUserInfo(){var t=this;return W((function*(){return yield t.config.request(n.WEDA_USER_URL,{method:"GET",withCredentials:!0})}))()}deleteMe(t){var e=this;return W((function*(){var r=e.getParamsByVersion(t,"USER_ME_URL"),n="".concat(r.url,"?").concat($.parseParamsToSearch(r.params));return e.config.request(n,{method:"DELETE",withCredentials:!0})}))()}hasLoginState(){var t=this;return W((function*(){try{return yield t.config.credentialsClient.getAccessToken(),!0}catch(t){return!1}}))()}hasLoginStateSync(){return this.config.credentialsClient.getCredentialsSync()}getLoginState(){var t=this;return W((function*(){return t.config.credentialsClient.getCredentialsAsync()}))()}transByProvider(t){var e=this;return W((function*(){return e.config.request(n.USER_TRANS_BY_PROVIDER_URL,{method:"PATCH",body:t,withCredentials:!0})}))()}grantToken(t){var e=this;return W((function*(){var r=e.getParamsByVersion(t,"AUTH_TOKEN_URL");return e.config.request(r.url,{method:"POST",body:r.params})}))()}getProviders(){var t=this;return W((function*(){return t.config.request(n.PROVIDER_LIST,{method:"GET",withCredentials:!0})}))()}unbindProvider(t){var e=this;return W((function*(){return e.config.request("".concat(n.PROVIDER_UNBIND_URL,"/").concat(t.provider_id),{method:"DELETE",withCredentials:!0})}))()}checkPassword(t){var e=this;return W((function*(){return e.config.request("".concat(n.CHECK_PWD_URL),{method:"POST",withCredentials:!0,body:t})}))()}editContact(t){var e=this;return W((function*(){return e.config.request("".concat(n.BIND_CONTACT_URL),{method:"PATCH",withCredentials:!0,body:t})}))()}setPassword(t){var e=this;return W((function*(){return e.config.request("".concat(n.AUTH_SET_PASSWORD),{method:"PATCH",withCredentials:!0,body:t})}))()}updatePasswordByOld(t){var e=this;return W((function*(){var r=yield e.sudo({password:t.old_password});return e.setPassword({sudo_token:r.sudo_token,new_password:t.new_password})}))()}sudo(t){var e=this;return W((function*(){return e.config.request("".concat(n.SUDO_URL),{method:"POST",withCredentials:!0,body:t})}))()}sendVerificationCodeToCurrentUser(t){var e=this;return W((function*(){return t.target="CUR_USER",e.config.request(n.VERIFICATION_URL,{method:"POST",body:t,withCredentials:!0,withCaptcha:!0})}))()}changeBoundProvider(t){var e=this;return W((function*(){return e.config.request("".concat(n.PROVIDER_LIST,"/").concat(t.provider_id,"/trans"),{method:"POST",body:{provider_trans_token:t.trans_token},withCredentials:!0})}))()}setUserProfile(t){var e=this;return W((function*(){return e.config.request(n.USER_PRIFILE_URL,{method:"PATCH",body:t,withCredentials:!0})}))()}updateUserBasicInfo(t){var e=this;return W((function*(){return e.config.request(n.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:t})}))()}queryUserProfile(t){var e=this;return W((function*(){var r=new U(t);return e.config.request("".concat(n.USER_QUERY_URL,"?").concat(r.toString()),{method:"GET",withCredentials:!0})}))()}setCustomSignFunc(t){this.getCustomSignTicketFn=t}signInWithCustomTicket(){var t=this;return W((function*(){var e=t.getCustomSignTicketFn;if(!e)return Promise.reject({error:"failed_precondition",error_description:"please use setCustomSignFunc to set custom sign function"});var r=yield e();return t.signInCustom({provider_id:"custom",ticket:r})}))()}resetPassword(t){var e=this;return W((function*(){return e.config.request(n.AUTH_RESET_PASSWORD,{method:"POST",body:t})}))()}authorize(t){var e=this;return W((function*(){return e.config.request(n.AUTHORIZE_URL,{method:"POST",withCredentials:!0,body:t})}))()}authorizeDevice(t){var e=this;return W((function*(){return e.config.request(n.AUTHORIZE_DEVICE_URL,{method:"POST",withCredentials:!0,body:t})}))()}deviceAuthorize(t){var e=this;return W((function*(){return e.config.request(n.AUTH_GET_DEVICE_CODE,{method:"POST",body:t,withCredentials:!0})}))()}authorizeInfo(t){var e=this;return W((function*(){var r="".concat(n.AUTHORIZE_INFO_URL,"?").concat($.parseParamsToSearch(t)),o=!0,i=!1;return(yield e.hasLoginState())&&(i=!0,o=!1),e.config.request(r,{method:"GET",withBasicAuth:o,withCredentials:i})}))()}checkUsername(t){var e=this;return W((function*(){return e.config.request(n.CHECK_USERNAME,{method:"GET",body:t,withCredentials:!0})}))()}checkIfUserExist(t){var e=this;return W((function*(){var r=new U(t);return e.config.request("".concat(n.CHECK_IF_USER_EXIST,"?").concat(r.toString()),{method:"GET"})}))()}loginScope(){var t=this;return W((function*(){return t.config.credentialsClient.getScope()}))()}loginGroups(){var t=this;return W((function*(){return t.config.credentialsClient.getGroups()}))()}refreshTokenForce(t){var e=this;return W((function*(){var r=yield e.config.credentialsClient.getCredentials();return yield e.config.credentialsClient.refreshToken(V(V({},r),{},{version:(null==t?void 0:t.version)||"v1"}))}))()}getCredentials(){var t=this;return W((function*(){return t.config.credentialsClient.getCredentials()}))()}getPublicKey(){var t=this;return W((function*(){return t.config.request(o.AUTH_PUBLIC_KEY,{method:"POST",body:{}})}))()}getEncryptParams(t){var e=this;return W((function*(){var{isEncrypt:r}=t;delete t.isEncrypt;var n=(0,f.I)(t),o=G(r,e.config.adapter);if(!o)return t;var i="",s="";try{var a=yield e.getPublicKey();if(i=a.public_key,s=a.public_key_thumbprint,!i||!s)throw a}catch(t){throw t}return{params:o.getEncryptInfo({publicKey:i,payload:n}),public_key_thumbprint:s}}))()}getProviderSubType(){var t=this;return W((function*(){return t.config.request(n.GET_PROVIDER_TYPE,{method:"POST",body:{provider_id:"weda"}})}))()}verifyCaptchaData(t){var e=this;return W((function*(){var{token:r,key:o}=t;return e.config.request(n.VERIFY_CAPTCHA_DATA_URL,{method:"POST",body:{token:r,key:o},withCredentials:!1})}))()}createCaptchaData(t){var e=this;return W((function*(){var{state:r,redirect_uri:o}=t;return e.config.request(n.CAPTCHA_DATA_URL,{method:"POST",body:{state:r,redirect_uri:o},withCredentials:!1})}))()}getMiniProgramCode(t){var e=this;return W((function*(){return e.config.request(n.GET_MINIPROGRAM_QRCODE,{method:"POST",body:t})}))()}getMiniProgramQrCodeStatus(t){var e=this;return W((function*(){return e.config.request(n.GET_MINIPROGRAM_QRCODE_STATUS,{method:"POST",body:t})}))()}getUserBehaviorLog(t){var e=this;return W((function*(){var r="".concat(n.GET_USER_BEHAVIOR_LOG,"?").concat({LOGIN:"query[action]=USER_LOGIN",MODIFY:"ne_query[action]=USER_LOGIN"}[t.type],"&limit=").concat(t.limit).concat(t.page_token?"&page_token=".concat(t.page_token):"");return e.config.request(r,{method:"GET",withCredentials:!0})}))()}modifyPassword(t){var e=this;return W((function*(){var r="",o="",i=G(!0,e.config.adapter);if(!i)throw new Error("do not support encrypt, a encrypt util required.");try{var s=yield e.getPublicKey();if(r=s.public_key,o=s.public_key_thumbprint,!r||!o)throw s}catch(t){throw t}var a=t.password?i.getEncryptInfo({publicKey:r,payload:t.password}):"",u=i.getEncryptInfo({publicKey:r,payload:t.new_password});return e.config.request(n.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:{user_id:t.user_id,encrypt_password:a,encrypt_new_password:u,public_key_thumbprint:o}})}))()}modifyPasswordWithoutLogin(t){var e=this;return W((function*(){var r="",n="",i=G(!0,e.config.adapter);if(!i)throw new Error("do not support encrypt, a encrypt util required.");try{var s=yield e.getPublicKey();if(r=s.public_key,n=s.public_key_thumbprint,!r||!n)throw s}catch(t){throw t}var a=t.password?i.getEncryptInfo({publicKey:r,payload:t.password}):"",u=i.getEncryptInfo({publicKey:r,payload:t.new_password});return e.config.request(o.AUTH_RESET_PASSWORD,{method:"POST",body:{username:t.username,password:a,new_password:u,public_key_thumbprint:n}})}))()}}function K(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function z(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?K(Object(r),!0).forEach((function(e){J(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):K(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function J(t,e,r){return(e=function(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}class Y{constructor(t){var{apiOrigin:e,apiPath:r=c,clientId:n,env:o,storage:i,request:s,baseRequest:a,anonymousSignInFunc:u,wxCloud:l,adapter:f,onCredentialsError:h,headers:d,i18n:p}=t;this.oauth2client=new x({apiOrigin:e,apiPath:r,clientId:n,env:o,storage:i,baseRequest:a||s,anonymousSignInFunc:u,wxCloud:l,onCredentialsError:h,headers:d||{},i18n:p}),this.authApi=new $(z(z({credentialsClient:this.oauth2client},t),{},{request:s?this.oauth2client.request.bind(this.oauth2client):void 0,adapter:f}))}}var Q=r(5605),Z=r(794),X=r(141),tt=r(9689),et=r(6197),rt=r(190),nt=r(8182),ot=function(){return ot=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},ot.apply(this,arguments)},it=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},st=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},at=function(){function t(t){var e,r;try{this.localStorage=(null==t?void 0:t.localStorage)||((null===(r=null===(e=null==t?void 0:t.adapter)||void 0===e?void 0:e.root)||void 0===r?void 0:r.globalThis)||globalThis).localStorage}catch(e){this.localStorage=(null==t?void 0:t.localStorage)||{}}}return t.prototype.getItem=function(t){return it(this,void 0,void 0,(function(){return st(this,(function(e){return[2,this.localStorage.getItem(t)]}))}))},t.prototype.removeItem=function(t){return it(this,void 0,void 0,(function(){return st(this,(function(e){return this.localStorage.removeItem(t),[2]}))}))},t.prototype.setItem=function(t,e){return it(this,void 0,void 0,(function(){return st(this,(function(r){return this.localStorage.setItem(t,e),[2]}))}))},t.prototype.getItemSync=function(t){return this.localStorage.getItem(t)},t.prototype.setItemSync=function(t,e){this.localStorage.setItem(t,e)},t.prototype.removeItemSync=function(t){this.localStorage.removeItem(t)},t}(),ut=/^[^:]+:\/\/[^/]+(\/[^?#]+)/,ct=function(t,e){var r,n,o,i,s=null===(r=null==e?void 0:e.headers)||void 0===r?void 0:r["x-request-id"];return t||(t={}),((null==t?void 0:t.code)||(null===(n=null==t?void 0:t.data)||void 0===n?void 0:n.error_code))&&(t={error:t.code||t.data.error,error_description:t.data.error_description||t.message||t.code||t.data.error_code,request_id:t.requestId,error_code:null===(o=t.data)||void 0===o?void 0:o.error_code}),(null==t?void 0:t.request_id)||(t.request_id=t.request_id||s),(null==t?void 0:t.error)?(t.error_uri=(i=null==e?void 0:e.url,ut.test(i)?RegExp.$1:i),t):(null==t?void 0:t.data)||{}},lt=function(t){return t.adapter&&"default"!==t.adapter.type?function(t,e){var r=ot({},t);try{if(!(null==t?void 0:t.storage)&&(null==e?void 0:e.localStorage)&&(r.storage=new at({localStorage:e.localStorage,adapter:e})),!t.captchaOptions&&(null==e?void 0:e.captchaOptions)&&(r.captchaOptions=e.captchaOptions),!t.baseRequest&&!t.request&&(null==e?void 0:e.reqClass)){var n=new e.reqClass({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});r.baseRequest=function(t,e){var r;return it(this,void 0,void 0,(function(){var o,i,s,a;return st(this,(function(u){switch(u.label){case 0:if(o={},i=(null===(r=e.method)||void 0===r?void 0:r.toLocaleLowerCase())||"get","function"!=typeof(s=null==n?void 0:n[i]))throw new Error("invalid 【".concat(i,"】 request method"));u.label=1;case 1:return u.trys.push([1,3,,4]),e.headers["content-type"]&&!e.headers["content-type"].includes("application/json")||"string"==typeof e.body||(e.data=e.data||e.body,e.body=JSON.stringify(e.body)),[4,s(ot({url:t},e))];case 2:return o=u.sent(),o=ct(o,ot(ot({},e),{url:t})),[3,4];case 3:throw a=u.sent(),o=a,a;case 4:if(null==o?void 0:o.error)throw o;return[2,o]}}))}))}}}catch(t){console.error("user adapter generate fail:",t)}return r}(t,t.adapter):function(t,e){if(!rt.ZP.isMatch()||t.storage&&t.baseRequest)return t;var r=ot({},t),n={};try{var o=rt.ZP.genAdapter(),i=o.localStorage,s=o.reqClass;if(i&&(n.storage=new at({localStorage:i,adapter:e})),s){var a=new s({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});n.request=function(t){return function(e,r){return it(this,void 0,void 0,(function(){return st(this,(function(n){return[2,new Promise((function(n,o){var i=Object.assign({},r);i.body&&"string"!=typeof i.body&&(i.body=JSON.stringify(i.body));var s=wx.request({url:e,data:i.body,timeout:t._timeout,method:i.method||"GET",header:i.headers,success:function(t){(t=ct(t,ot(ot({},r),{url:e}))).error&&o(t),n(t)},fail:function(t){o({error:"unreachable",error_description:t.message})},complete:function(e){if(e&&e.errMsg&&t._timeout&&-1!==t._restrictedMethods.indexOf("request")&&"request:fail timeout"===e.errMsg){console.warn(t._timeoutMsg);try{s.abort()}catch(t){}}}})}))]}))}))}}(a)}return r.captchaOptions&&(n.baseRequest=n.request,n.request=void 0),ot(ot({},r),n)}catch(t){console.error("adapter generate fail:",t)}return r}(t,t.adapter)},ft=function(){return ft=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},ft.apply(this,arguments)},ht=function(t,e,r,n){var o,i=arguments.length,s=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s},dt=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},pt=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},yt=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},vt="credentials_error",gt="loginStateChanged",mt=new tt.CloudbaseEventEmitter,bt=function(t){mt.fire(gt,ft(ft({},t),{eventType:vt}))},wt=function(){function t(t){var e=t.cache,r=t.oauthInstance;this.cache=e,this.oauthInstance=r,this.setUserInfo()}return t.prototype.checkLocalInfo=function(){return pt(this,void 0,void 0,(function(){return yt(this,(function(t){return this.uid=this.getLocalUserInfo("uid"),this.gender=this.getLocalUserInfo("gender"),this.picture=this.getLocalUserInfo("picture"),this.email=this.getLocalUserInfo("email"),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),this.username=this.getLocalUserInfo("username"),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]}))}))},t.prototype.checkLocalInfoAsync=function(){return pt(this,void 0,void 0,(function(){var t,e,r,n;return yt(this,(function(o){switch(o.label){case 0:return t=this,[4,this.getLocalUserInfoAsync("uid")];case 1:return t.uid=o.sent(),e=this,[4,this.getLocalUserInfoAsync("gender")];case 2:return e.gender=o.sent(),this.picture=this.getLocalUserInfo("picture"),r=this,[4,this.getLocalUserInfoAsync("email")];case 3:return r.email=o.sent(),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),n=this,[4,this.getLocalUserInfoAsync("username")];case 4:return n.username=o.sent(),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]}}))}))},t.prototype.update=function(t){return pt(this,void 0,void 0,(function(){var e;return yt(this,(function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.setUserProfile(ft({},t))];case 1:return e=r.sent(),this.setLocalUserInfo(e),[2]}}))}))},t.prototype.updateUserBasicInfo=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.updateUserBasicInfo(ft({},t))];case 1:return e.sent(),this.setLocalUserInfo({username:t.username}),[2]}}))}))},t.prototype.updatePassword=function(t,e){return this.oauthInstance.authApi.updatePasswordByOld({old_password:e,new_password:t})},t.prototype.updateUsername=function(t){return"string"!=typeof t&&(0,Q.throwError)(Z.ERRORS.INVALID_PARAMS,"username must be a string"),this.update({username:t})},t.prototype.refresh=function(t){return pt(this,void 0,void 0,(function(){var e;return yt(this,(function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.getUserInfo(t)];case 1:return e=r.sent(),this.setLocalUserInfo(e),[2,e]}}))}))},t.prototype.getLocalUserInfo=function(t){var e=this.cache.keys.userInfoKey;return this.cache.getStore(e)[t]},t.prototype.getLocalUserInfoAsync=function(t){return pt(this,void 0,void 0,(function(){var e;return yt(this,(function(r){switch(r.label){case 0:return e=this.cache.keys.userInfoKey,[4,this.cache.getStoreAsync(e)];case 1:return[2,r.sent()[t]]}}))}))},t.prototype.setUserInfo=function(){var t=this,e=this.cache.keys.userInfoKey,r=this.cache.getStore(e);["uid","email","name","gender","picture","email_verified","phone_number","birthdate","zoneinfo","locale","sub","created_from","providers","username"].forEach((function(e){t[e]=r[e]}))},t.prototype.setLocalUserInfo=function(t){var e=this.cache.keys.userInfoKey;this.cache.setStore(e,t),this.setUserInfo()},ht([(0,X.catchErrorsDecorator)({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[Object]),dt("design:returntype",Promise)],t.prototype,"update",null),ht([(0,X.catchErrorsDecorator)({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[String,String]),dt("design:returntype",void 0)],t.prototype,"updatePassword",null),ht([(0,X.catchErrorsDecorator)({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[String]),dt("design:returntype",void 0)],t.prototype,"updateUsername",null),ht([(0,X.catchErrorsDecorator)({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[Object]),dt("design:returntype",Promise)],t.prototype,"refresh",null),t}(),_t=function(){function t(t){var e=t.envId,r=t.cache,n=t.oauthInstance;e||(0,Q.throwError)(Z.ERRORS.INVALID_PARAMS,"envId is not defined"),this.cache=r,this.oauthInstance=n,this.user=new wt({cache:this.cache,oauthInstance:n})}return t.prototype.checkLocalState=function(){var t;this.oauthLoginState=null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.hasLoginStateSync(),this.user.checkLocalInfo()},t.prototype.checkLocalStateAsync=function(){var t;return pt(this,void 0,void 0,(function(){return yt(this,(function(e){switch(e.label){case 0:return[4,null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.getLoginState()];case 1:return e.sent(),[4,this.user.checkLocalInfoAsync()];case 2:return e.sent(),[2]}}))}))},t}(),St=function(){function t(t){this.config=t,this.cache=t.cache,this.oauthInstance=t.oauthInstance}return t.prototype.bindPhoneNumber=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.editContact(t)]}))}))},t.prototype.unbindProvider=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.unbindProvider(t)]}))}))},t.prototype.bindEmail=function(t){return this.oauthInstance.authApi.editContact(t)},t.prototype.verify=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.verify(t)]}))}))},t.prototype.getVerification=function(t,e){return pt(this,void 0,void 0,(function(){return yt(this,(function(r){return[2,this.oauthInstance.authApi.getVerification(t,e)]}))}))},Object.defineProperty(t.prototype,"currentUser",{get:function(){if("async"!==this.cache.mode){var t=this.hasLoginState();return t&&t.user||null}(0,Q.printWarn)(Z.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrentUser insteed")},enumerable:!1,configurable:!0}),t.prototype.getCurrentUser=function(){return pt(this,void 0,void 0,(function(){var t;return yt(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.signInAnonymously=function(t){return void 0===t&&(t={}),pt(this,void 0,void 0,(function(){return yt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInAnonymously(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.signInAnonymouslyInWx=function(t){var e=(void 0===t?{}:t).useWxCloud;return pt(this,void 0,void 0,(function(){var t,r,n=this;return yt(this,(function(o){switch(o.label){case 0:if(!rt.ZP.isMatch())throw Error("wx api undefined");return t=wx.getAccountInfoSync().miniProgram,r=function(r){return pt(n,void 0,void 0,(function(){var n,o;return yt(this,(function(i){switch(i.label){case 0:n=void 0,o=void 0,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==t?void 0:t.appId,provider_code:r,provider_params:{provider_code_type:"open_id",appid:null==t?void 0:t.appId}},e)];case 2:if((null==(n=i.sent())?void 0:n.error_code)||!n.provider_token)throw n;return[4,this.oauthInstance.authApi.signInAnonymously({provider_token:n.provider_token},e)];case 3:if(null==(o=i.sent())?void 0:o.error_code)throw o;return[3,5];case 4:throw i.sent();case 5:return[2]}}))}))},[4,new Promise((function(t,e){wx.login({success:function(o){return pt(n,void 0,void 0,(function(){var n;return yt(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,r(o.code)];case 1:return i.sent(),t(!0),[3,3];case 2:return n=i.sent(),e(n),[3,3];case 3:return[2]}}))}))},fail:function(t){var r=new Error(null==t?void 0:t.errMsg);r.code=null==t?void 0:t.errno,e(r)}})}))];case 1:return o.sent(),[2,this.createLoginState(void 0,{asyncRefreshUser:!0})]}}))}))},t.prototype.bindOpenId=function(){return pt(this,void 0,void 0,(function(){var t,e,r=this;return yt(this,(function(n){switch(n.label){case 0:if(!rt.ZP.isMatch())throw Error("wx api undefined");return t=wx.getAccountInfoSync().miniProgram,e=function(e){return pt(r,void 0,void 0,(function(){var r;return yt(this,(function(n){switch(n.label){case 0:r=void 0,n.label=1;case 1:return n.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==t?void 0:t.appId,provider_code:e,provider_params:{provider_code_type:"open_id",appid:null==t?void 0:t.appId}})];case 2:if((null==(r=n.sent())?void 0:r.error_code)||!r.provider_token)throw r;return[4,this.oauthInstance.authApi.bindWithProvider({provider_token:r.provider_token})];case 3:return n.sent(),[3,5];case 4:throw n.sent();case 5:return[2]}}))}))},[4,new Promise((function(t,n){wx.login({success:function(o){return pt(r,void 0,void 0,(function(){var r;return yt(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,e(o.code)];case 1:return i.sent(),t(!0),[3,3];case 2:return r=i.sent(),n(r),[3,3];case 3:return[2]}}))}))},fail:function(t){var e=new Error(null==t?void 0:t.errMsg);e.code=null==t?void 0:t.errno,n(e)}})}))];case 1:return n.sent(),[2]}}))}))},t.prototype.signInWithOpenId=function(t){var e=(void 0===t?{}:t).useWxCloud,r=void 0===e||e;return pt(this,void 0,void 0,(function(){var t,e,n=this;return yt(this,(function(o){switch(o.label){case 0:if(!rt.ZP.isMatch())throw Error("wx api undefined");return t=wx.getAccountInfoSync().miniProgram,e=function(e){return pt(n,void 0,void 0,(function(){var n,o;return yt(this,(function(i){switch(i.label){case 0:n=void 0,o=void 0,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==t?void 0:t.appId,provider_code:e,provider_params:{provider_code_type:"open_id",appid:null==t?void 0:t.appId}},r)];case 2:if((null==(n=i.sent())?void 0:n.error_code)||!n.provider_token)throw n;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:n.provider_token},r)];case 3:if(null==(o=i.sent())?void 0:o.error_code)throw o;return[3,5];case 4:throw i.sent();case 5:return[4,this.oauthInstance.oauth2client.setCredentials(o)];case 6:return i.sent(),[2]}}))}))},[4,new Promise((function(t,r){wx.login({success:function(o){return pt(n,void 0,void 0,(function(){var n;return yt(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,e(o.code)];case 1:return i.sent(),t(!0),[3,3];case 2:return n=i.sent(),r(n),[3,3];case 3:return[2]}}))}))},fail:function(t){var e=new Error(null==t?void 0:t.errMsg);e.code=null==t?void 0:t.errno,r(e)}})}))];case 1:return o.sent(),[2,this.createLoginState()]}}))}))},t.prototype.signInWithUnionId=function(){return pt(this,void 0,void 0,(function(){var t=this;return yt(this,(function(e){switch(e.label){case 0:if(!rt.ZP.isMatch())throw Error("wx api undefined");e.label=1;case 1:return e.trys.push([1,3,,4]),[4,new Promise((function(e,r){var n=wx.getAccountInfoSync().miniProgram;wx.login({success:function(o){return pt(t,void 0,void 0,(function(){var t,i,s,a,u;return yt(this,(function(c){switch(c.label){case 0:t=null==n?void 0:n.appId,c.label=1;case 1:return c.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_code:o.code,provider_id:t,provider_params:{provider_code_type:"union_id",appid:null==n?void 0:n.appId}})];case 2:return i=c.sent(),(s=i.provider_token)?[4,this.oauthInstance.authApi.signInWithProvider({provider_id:t,provider_token:s})]:(r(i),[2]);case 3:return(null==(a=c.sent())?void 0:a.error_code)?(r(a),[2]):(e(!0),[3,5]);case 4:return u=c.sent(),r(u),[3,5];case 5:return[2]}}))}))},fail:function(t){var e=new Error(null==t?void 0:t.errMsg);e.code=null==t?void 0:t.errno,r(e)}})}))];case 2:return e.sent(),[3,4];case 3:throw e.sent();case 4:return[2,this.createLoginState()]}}))}))},t.prototype.signInWithPhoneAuth=function(t){var e=t.phoneCode,r=void 0===e?"":e;return pt(this,void 0,void 0,(function(){var t,e,n,o,i;return yt(this,(function(s){switch(s.label){case 0:if(!rt.ZP.isMatch())throw Error("wx api undefined");return t=wx.getAccountInfoSync().miniProgram,e={provider_params:{provider_code_type:"phone"},provider_id:t.appId},[4,wx.login()];case 1:n=s.sent().code,e.provider_code=n,s.label=2;case 2:return s.trys.push([2,6,,7]),[4,this.oauthInstance.authApi.grantProviderToken(e)];case 3:if((o=s.sent()).error_code)throw o;return[4,this.oauthInstance.authApi.patchProviderToken({provider_token:o.provider_token,provider_id:t.appId,provider_params:{code:r,provider_code_type:"phone"}})];case 4:if((o=s.sent()).error_code)throw o;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:o.provider_token})];case 5:if(null==(i=s.sent())?void 0:i.error_code)throw i;return[3,7];case 6:throw s.sent();case 7:return[2,this.createLoginState()]}}))}))},t.prototype.signInWithSms=function(t){var e=t.verificationInfo,r=void 0===e?{verification_id:"",is_user:!1}:e,n=t.verificationCode,o=void 0===n?"":n,i=t.phoneNum,s=void 0===i?"":i,a=t.bindInfo,u=void 0===a?void 0:a;return pt(this,void 0,void 0,(function(){return yt(this,(function(t){try{return[2,this.signInWithUsername({verificationInfo:r,verificationCode:o,bindInfo:u,username:s,loginType:"sms"})]}catch(t){throw t}return[2]}))}))},t.prototype.signInWithEmail=function(t){var e=t.verificationInfo,r=void 0===e?{verification_id:"",is_user:!1}:e,n=t.verificationCode,o=void 0===n?"":n,i=t.bindInfo,s=void 0===i?void 0:i,a=t.email,u=void 0===a?"":a;return pt(this,void 0,void 0,(function(){return yt(this,(function(t){try{return[2,this.signInWithUsername({verificationInfo:r,verificationCode:o,bindInfo:s,username:u,loginType:"email"})]}catch(t){throw t}return[2]}))}))},t.prototype.setCustomSignFunc=function(t){this.oauthInstance.authApi.setCustomSignFunc(t)},t.prototype.signInWithCustomTicket=function(){return pt(this,void 0,void 0,(function(){return yt(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signInWithCustomTicket()];case 1:return t.sent(),[2,this.createLoginState()]}}))}))},t.prototype.signIn=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signIn(t)];case 1:return e.sent(),[2,this.createLoginState(t)]}}))}))},t.prototype.signUp=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signUp(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.setPassword=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.setPassword(t)]}))}))},t.prototype.isUsernameRegistered=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){switch(e.label){case 0:return"string"!=typeof t&&(0,Q.throwError)(Z.ERRORS.INVALID_PARAMS,"username must be a string"),[4,this.oauthInstance.authApi.checkIfUserExist({username:t})];case 1:return[2,e.sent().exist]}}))}))},t.prototype.signOut=function(t){return pt(this,void 0,void 0,(function(){var e,r;return yt(this,(function(n){switch(n.label){case 0:return e=this.cache.keys.userInfoKey,[4,this.oauthInstance.authApi.signOut(t)];case 1:return r=n.sent(),[4,this.cache.removeStoreAsync(e)];case 2:return n.sent(),mt.fire(gt,{eventType:"sign_out"}),[2,r]}}))}))},t.prototype.hasLoginState=function(){var t;if("async"!==this.cache.mode)return(null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.hasLoginStateSync())?new _t({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance}):null;(0,Q.printWarn)(Z.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState insteed")},t.prototype.getLoginState=function(){return pt(this,void 0,void 0,(function(){var t;return yt(this,(function(e){switch(e.label){case 0:t=null,e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.oauthInstance.authApi.getLoginState()];case 2:return t=e.sent(),[3,4];case 3:return e.sent(),[2,null];case 4:return t?[2,new _t({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})]:[2,null]}}))}))},t.prototype.getUserInfo=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.getUserInfo(t)]}))}))},t.prototype.getWedaUserInfo=function(){return pt(this,void 0,void 0,(function(){return yt(this,(function(t){return[2,this.oauthInstance.authApi.getWedaUserInfo()]}))}))},t.prototype.updateUserBasicInfo=function(t){return pt(this,void 0,void 0,(function(){var e;return yt(this,(function(r){switch(r.label){case 0:return[4,this.getLoginState()];case 1:return(e=r.sent())?[4,e.user.updateUserBasicInfo(t)]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},t.prototype.getAuthHeader=function(){return console.error("Auth.getAuthHeader API 已废弃"),{}},t.prototype.bindWithProvider=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.bindWithProvider(t)]}))}))},t.prototype.queryUser=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.queryUserProfile(t)]}))}))},t.prototype.getAccessToken=function(){return pt(this,void 0,void 0,(function(){return yt(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.oauth2client.getAccessToken()];case 1:return[2,{accessToken:t.sent(),env:this.config.env}]}}))}))},t.prototype.grantProviderToken=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.grantProviderToken(t)]}))}))},t.prototype.patchProviderToken=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.patchProviderToken(t)]}))}))},t.prototype.signInWithProvider=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInWithProvider(t)];case 1:return e.sent(),[2,this.createLoginState(t)]}}))}))},t.prototype.signInWithWechat=function(t){return void 0===t&&(t={}),pt(this,void 0,void 0,(function(){return yt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInWithWechat(t)];case 1:return e.sent(),[2,this.createLoginState(t)]}}))}))},t.prototype.grantToken=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.grantToken(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.genProviderRedirectUri=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.genProviderRedirectUri(t)]}))}))},t.prototype.resetPassword=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.resetPassword(t)]}))}))},t.prototype.deviceAuthorize=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.deviceAuthorize(t)]}))}))},t.prototype.sudo=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.sudo(t)]}))}))},t.prototype.deleteMe=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.deleteMe(t)]}))}))},t.prototype.getProviders=function(){return pt(this,void 0,void 0,(function(){return yt(this,(function(t){return[2,this.oauthInstance.authApi.getProviders()]}))}))},t.prototype.loginScope=function(){return pt(this,void 0,void 0,(function(){return yt(this,(function(t){return[2,this.oauthInstance.authApi.loginScope()]}))}))},t.prototype.loginGroups=function(){return pt(this,void 0,void 0,(function(){return yt(this,(function(t){return[2,this.oauthInstance.authApi.loginGroups()]}))}))},t.prototype.onLoginStateChanged=function(t){return pt(this,void 0,void 0,(function(){var e,r=this;return yt(this,(function(n){switch(n.label){case 0:return mt.on(gt,(function(e){return pt(r,void 0,void 0,(function(){var r,n,o;return yt(this,(function(i){switch(i.label){case 0:return(null===(o=null==e?void 0:e.data)||void 0===o?void 0:o.eventType)===vt?[3,2]:[4,this.getLoginState()];case 1:return n=i.sent(),[3,3];case 2:n={},i.label=3;case 3:return r=n,t.call(this,ft(ft({},e),r)),[2]}}))}))})),[4,this.getLoginState()];case 1:return e=n.sent(),t.call(this,e),[2]}}))}))},t.prototype.refreshTokenForce=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.refreshTokenForce(t)]}))}))},t.prototype.getCredentials=function(){return pt(this,void 0,void 0,(function(){return yt(this,(function(t){return[2,this.oauthInstance.authApi.getCredentials()]}))}))},t.prototype.setCredentials=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.oauth2client.setCredentials(t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getProviderSubType=function(){return pt(this,void 0,void 0,(function(){return yt(this,(function(t){return[2,this.oauthInstance.authApi.getProviderSubType()]}))}))},t.prototype.createCaptchaData=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.createCaptchaData(t)]}))}))},t.prototype.verifyCaptchaData=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.verifyCaptchaData(t)]}))}))},t.prototype.getMiniProgramQrCode=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.getMiniProgramCode(t)]}))}))},t.prototype.getMiniProgramQrCodeStatus=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.getMiniProgramQrCodeStatus(t)]}))}))},t.prototype.modifyPassword=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.modifyPassword(t)]}))}))},t.prototype.modifyPasswordWithoutLogin=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.modifyPasswordWithoutLogin(t)]}))}))},t.prototype.getUserBehaviorLog=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.getUserBehaviorLog(t)]}))}))},t.prototype.toDefaultLoginPage=function(t){return void 0===t&&(t={}),pt(this,void 0,void 0,(function(){var e,r,n,o;return yt(this,(function(i){return e=t.config_version||"env",rt.ZP.isMatch()?wx.navigateTo({url:"/packages/$wd_system/pages/login/index"}):(r=t.redirect_uri||window.location.href,n=new URL(r),o="".concat(n.origin,"/__auth/?app_id=").concat(t.app_id||"","&env_id=").concat(this.config.env,"&client_id=").concat(this.config.clientId,"&config_version=").concat(e,"&redirect_uri=").concat(encodeURIComponent(r)),window.location.href=o),[2]}))}))},t.prototype.createLoginState=function(t,e){return pt(this,void 0,void 0,(function(){var r;return yt(this,(function(n){switch(n.label){case 0:return[4,(r=new _t({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})).checkLocalStateAsync()];case 1:return n.sent(),(null==e?void 0:e.asyncRefreshUser)?(r.user.refresh(t),[3,4]):[3,2];case 2:return[4,r.user.refresh(t)];case 3:n.sent(),n.label=4;case 4:return mt.fire(gt,{eventType:"sign_in"}),[2,r]}}))}))},t.prototype.signInWithUsername=function(t){var e=t.verificationInfo,r=void 0===e?{verification_id:"",is_user:!1}:e,n=t.verificationCode,o=void 0===n?"":n,i=t.username,s=void 0===i?"":i,a=t.bindInfo,u=void 0===a?void 0:a,c=t.loginType,l=void 0===c?"":c;return pt(this,void 0,void 0,(function(){var t,e,n,i,a,c,f;return yt(this,(function(h){switch(h.label){case 0:return h.trys.push([0,8,,9]),[4,this.oauthInstance.authApi.verify({verification_id:r.verification_id,verification_code:o})];case 1:if(null==(t=h.sent())?void 0:t.error_code)throw t;return e=t.verification_token,n="+86 ".concat(s),i={phone_number:n},"email"===l&&(i={email:n=s}),r.is_user?[4,this.oauthInstance.authApi.signIn({username:n,verification_token:e})]:[3,5];case 2:if(null==(a=h.sent())?void 0:a.error_code)throw a;return u?[4,this.oauthInstance.authApi.bindWithProvider({provider_token:null==u?void 0:u.providerToken})]:[3,4];case 3:if(null==(c=h.sent())?void 0:c.error_code)throw c;h.label=4;case 4:return[3,7];case 5:return[4,this.oauthInstance.authApi.signUp(ft(ft({},i),{verification_token:e,provider_token:null==u?void 0:u.providerId}))];case 6:if(null==(f=h.sent())?void 0:f.error_code)throw f;h.label=7;case 7:return[2,this.createLoginState()];case 8:throw h.sent();case 9:return[2]}}))}))},ht([(0,X.catchErrorsDecorator)({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[Object]),dt("design:returntype",Promise)],t.prototype,"bindPhoneNumber",null),ht([(0,X.catchErrorsDecorator)({title:"解除三方绑定失败",messages:["请确认以下各项:"," 1 - 调用 auth().unbindProvider() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[Object]),dt("design:returntype",Promise)],t.prototype,"unbindProvider",null),ht([(0,X.catchErrorsDecorator)({title:"绑定邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[Object]),dt("design:returntype",void 0)],t.prototype,"bindEmail",null),ht([(0,X.catchErrorsDecorator)({title:"验证码验证失败",messages:["请确认以下各项:"," 1 - 调用 auth().verify() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[Object]),dt("design:returntype",Promise)],t.prototype,"verify",null),ht([(0,X.catchErrorsDecorator)({title:"获取验证码失败",messages:["请确认以下各项:"," 1 - 调用 auth().getVerification() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[Object,Object]),dt("design:returntype",Promise)],t.prototype,"getVerification",null),ht([(0,X.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrentUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[]),dt("design:returntype",Promise)],t.prototype,"getCurrentUser",null),ht([(0,X.catchErrorsDecorator)({title:"匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymously() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[Object]),dt("design:returntype",Promise)],t.prototype,"signInAnonymously",null),ht([(0,X.catchErrorsDecorator)({title:"小程序匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymouslyInWx() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[Object]),dt("design:returntype",Promise)],t.prototype,"signInAnonymouslyInWx",null),ht([(0,X.catchErrorsDecorator)({title:"小程序绑定OpenID失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序openId静默登录"," 2 - 调用 auth().bindOpenId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[]),dt("design:returntype",Promise)],t.prototype,"bindOpenId",null),ht([(0,X.catchErrorsDecorator)({title:"小程序openId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序openId静默登录"," 2 - 调用 auth().signInWithOpenId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[Object]),dt("design:returntype",Promise)],t.prototype,"signInWithOpenId",null),ht([(0,X.catchErrorsDecorator)({title:"小程序unionId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序unionId静默登录"," 2 - 调用 auth().signInWithUnionId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[]),dt("design:returntype",Promise)],t.prototype,"signInWithUnionId",null),ht([(0,X.catchErrorsDecorator)({title:"小程序手机号授权登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序手机号授权登录"," 2 - 调用 auth().signInWithPhoneAuth() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[Object]),dt("design:returntype",Promise)],t.prototype,"signInWithPhoneAuth",null),ht([(0,X.catchErrorsDecorator)({title:"短信验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序短信验证码登陆"," 2 - 调用 auth().signInWithSms() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[Object]),dt("design:returntype",Promise)],t.prototype,"signInWithSms",null),ht([(0,X.catchErrorsDecorator)({title:"邮箱验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了邮箱登陆"," 2 - 调用 auth().signInWithEmail() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[Object]),dt("design:returntype",Promise)],t.prototype,"signInWithEmail",null),ht([(0,X.catchErrorsDecorator)({title:"自定义登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了自定义登录"," 2 - 调用 auth().signInWithCustomTicket() 的语法或参数是否正确"," 3 - ticket 是否归属于当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[]),dt("design:returntype",Promise)],t.prototype,"signInWithCustomTicket",null),ht([(0,X.catchErrorsDecorator)({title:"注册失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了指定登录方式"," 2 - 调用 auth().signUp() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[Object]),dt("design:returntype",Promise)],t.prototype,"signUp",null),ht([(0,X.catchErrorsDecorator)({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[String]),dt("design:returntype",Promise)],t.prototype,"isUsernameRegistered",null),ht([(0,X.catchErrorsDecorator)({title:"用户登出失败",messages:["请确认以下各项:"," 1 - 调用 auth().signOut() 的语法或参数是否正确"," 2 - 当前用户是否为匿名登录(匿名登录不支持signOut)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[Object]),dt("design:returntype",Promise)],t.prototype,"signOut",null),ht([(0,X.catchErrorsDecorator)({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[]),dt("design:returntype",Promise)],t.prototype,"getLoginState",null),ht([(0,X.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[Object]),dt("design:returntype",Promise)],t.prototype,"getUserInfo",null),ht([(0,X.catchErrorsDecorator)({title:"获取微搭插件用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getWedaUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[]),dt("design:returntype",Promise)],t.prototype,"getWedaUserInfo",null),ht([(0,X.catchErrorsDecorator)({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindWithProvider() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[Object]),dt("design:returntype",Promise)],t.prototype,"bindWithProvider",null),ht([(0,X.catchErrorsDecorator)({title:"获取身份源类型",messages:["请确认以下各项:"," 1 - 调用 auth().getProviderSubType() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[]),dt("design:returntype",Promise)],t.prototype,"getProviderSubType",null),t}();function Et(t,e){var r=t.region,n=void 0===r?"ap-shanghai":r,o=t.i18n,i=(null==e?void 0:e.platform)||(0,nt.useDefaultAdapter)(),s=i.runtime,a=i.adapter,u=e||{},l=u.env,f=u.clientId,h=u.debug,d=u.cache,p=u.app,y=(e||{}).apiOrigin;y||(y="https://".concat(l,".").concat(n,".tcb-api.tencentcloudapi.com"));var v={env:l,clientId:f,i18n:o},g=new Y(lt(ft(ft({},v),{apiOrigin:y,apiPath:(null==t?void 0:t.apiPath)||c,storage:null==t?void 0:t.storage,baseRequest:null==t?void 0:t.baseRequest,request:null==t?void 0:t.request,anonymousSignInFunc:null==t?void 0:t.anonymousSignInFunc,captchaOptions:null==t?void 0:t.captchaOptions,wxCloud:null==t?void 0:t.wxCloud,adapter:a,onCredentialsError:bt,headers:t.headers||{}})));return{authInstance:new St(ft(ft({},v),{region:n,persistence:t.persistence,debug:h,cache:d||new et.CloudbaseCache({persistence:t.persistence,keys:{userInfoKey:"user_info_".concat(l)},platformInfo:i}),runtime:s||"web",_fromApp:p,oauthInstance:g})),oauthInstance:g}}var It={name:"auth",namespace:"auth",entity:function(t){if(void 0===t&&(t={region:"",persistence:"local",apiPath:c}),this.authInstance)return(0,Q.printWarn)(Z.ERRORS.INVALID_OPERATION,"every cloudbase instance should has only one auth object"),this.authInstance;var e=this.platform.adapter,r=t.persistence||e.primaryStorage;r&&r!==this.config.persistence&&this.updateConfig({persistence:r});var n=Et(ft(ft({wxCloud:this.config.wxCloud,storage:this.config.storage},t),{persistence:this.config.persistence,i18n:this.config.i18n}),{env:this.config.env,clientId:this.config.clientId,apiOrigin:this.request.getBaseEndPoint(),platform:this.platform,cache:this.cache,app:this,debug:this.config.debug}),o=n.authInstance,i=n.oauthInstance;return this.oauthInstance=i,this.authInstance=o,this.authInstance}};try{cloudbase.registerComponent(It)}catch(t){}function Ot(t){try{t.registerComponent(It)}catch(t){console.warn(t)}}},8622:function(t,e,r){"use strict";r.r(e),r.d(e,{registerDatabase:function(){return Dr}});var n,o,i={};r.r(i),r.d(i,{LineString:function(){return H},MultiLineString:function(){return J},MultiPoint:function(){return K},MultiPolygon:function(){return Q},Point:function(){return ot},Polygon:function(){return $}}),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,u="Object",c="GeoPoint",l="GeoLineString",f="GeoPolygon",h="GeoMultiPoint",d="GeoMultiLineString",p="GeoMultiPolygon",y="Date",v="ServerDate",g=["desc","asc"],m=["<","<=","==",">=",">"];!function(t){t.lt="<",t.gt=">",t.lte="<=",t.gte=">=",t.eq="=="}(s||(s={})),(n={})[s.eq]="$eq",n[s.lt]="$lt",n[s.lte]="$lte",n[s.gt]="$gt",n[s.gte]="$gte",function(t){t.WHERE="WHERE",t.DOC="DOC"}(a||(a={}));var b,w=(b=function(t,e){return b=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},b(t,e)},function(t,e){function r(){this.constructor=t}b(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),_=[],S={},E=function(t){function e(e,r){if(r!==S)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 r=0,n=_.length;r<n;r++)if(_[r].target===t)return _[r].instance;var o=new e(t,S);return _.push({target:t,instance:o}),o},e}((function(t){Object.defineProperties(this,{target:{enumerable:!1,writable:!1,configurable:!1,value:t}})})),I=E,O=I.for("UNSET_FIELD_NAME"),T=I.for("UPDATE_COMMAND"),R=I.for("QUERY_COMMAND"),A=I.for("LOGIC_COMMAND"),P=I.for("GEO_POINT"),x=I.for("SYMBOL_GEO_LINE_STRING"),C=I.for("SYMBOL_GEO_POLYGON"),N=I.for("SYMBOL_GEO_MULTI_POINT"),L=I.for("SYMBOL_GEO_MULTI_LINE_STRING"),j=I.for("SYMBOL_GEO_MULTI_POLYGON"),U=I.for("SERVER_DATE"),k=I.for("REGEXP"),D=function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},q=function(t){return"object"===D(t)},M=function(t){return"number"===D(t)},B=function(t){return Array.isArray(t)},W=function(t){return"date"===D(t)},F=function(t){return"regexp"===D(t)},V=function(t){return t&&t._internalType instanceof E},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,r;if("LineString"!==t.type||!B(t.coordinates))return!1;try{for(var n=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(t.coordinates),o=n.next();!o.done;o=n.next()){var i=o.value;if(!M(i[0])||!M(i[1]))return!1}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}return!0},t.isClosed=function(t){var e=t.points[0],r=t.points[t.points.length-1];if(e.latitude===r.latitude&&e.longitude===r.longitude)return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return x},enumerable:!0,configurable:!0}),t}(),G=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},$=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,r,n,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 u=(n=void 0,G(a)),c=u.next();!c.done;c=u.next()){var l=c.value;if(!M(l[0])||!M(l[1]))return!1}}catch(t){n={error:t}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}finally{if(n)throw n.error}}}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}return!0},t.isCloseLineString=function(t){var e=t[0],r=t[t.length-1];return e[0]===r[0]&&e[1]===r[1]},Object.defineProperty(t.prototype,"_internalType",{get:function(){return j},enumerable:!0,configurable:!0}),t}(),K=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,r;if("MultiPoint"!==t.type||!B(t.coordinates))return!1;try{for(var n=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(t.coordinates),o=n.next();!o.done;o=n.next()){var i=o.value;if(!M(i[0])||!M(i[1]))return!1}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return N},enumerable:!0,configurable:!0}),t}(),z=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},J=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,r,n,o;if("MultiLineString"!==t.type||!B(t.coordinates))return!1;try{for(var i=z(t.coordinates),s=i.next();!s.done;s=i.next()){var a=s.value;try{for(var u=(n=void 0,z(a)),c=u.next();!c.done;c=u.next()){var l=c.value;if(!M(l[0])||!M(l[1]))return!1}}catch(t){n={error:t}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}finally{if(n)throw n.error}}}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return L},enumerable:!0,configurable:!0}),t}(),Y=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Q=function(){function t(t){var e,r;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 n=Y(t),o=n.next();!o.done;o=n.next()){var i=o.value;if(!(i instanceof $))throw new TypeError('"polygon" must be of type Polygon[]. Received type '+typeof i+"[]")}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}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,r,n,o,i,s;if("MultiPolygon"!==t.type||!B(t.coordinates))return!1;try{for(var a=Y(t.coordinates),u=a.next();!u.done;u=a.next()){var c=u.value;try{for(var l=(n=void 0,Y(c)),f=l.next();!f.done;f=l.next()){var h=f.value;try{for(var d=(i=void 0,Y(h)),p=d.next();!p.done;p=d.next()){var y=p.value;if(!M(y[0])||!M(y[1]))return!1}}catch(t){i={error:t}}finally{try{p&&!p.done&&(s=d.return)&&s.call(d)}finally{if(i)throw i.error}}}}catch(t){n={error:t}}finally{try{f&&!f.done&&(o=l.return)&&o.call(l)}finally{if(n)throw n.error}}}}catch(t){e={error:t}}finally{try{u&&!u.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return C},enumerable:!0,configurable:!0}),t}(),Z=function(){function t(t){var e=(void 0===t?{}:t).offset,r=void 0===e?0:e;this.offset=r}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 X(t){return new Z(t)}var tt,et=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s},rt=function(){function t(){}return t.formatResDocumentData=function(e){return e.map((function(e){return t.formatField(e)}))},t.formatField=function(e){var r=Object.keys(e),n={};return Array.isArray(e)&&(n=[]),r.forEach((function(r){var o,i=e[r];switch(t.whichType(i)){case c:o=new ot(i.coordinates[0],i.coordinates[1]);break;case l:o=new H(i.coordinates.map((function(t){return new ot(t[0],t[1])})));break;case f:o=new $(i.coordinates.map((function(t){return new H(t.map((function(t){var e=et(t,2),r=e[0],n=e[1];return new ot(r,n)})))})));break;case h:o=new K(i.coordinates.map((function(t){return new ot(t[0],t[1])})));break;case d:o=new J(i.coordinates.map((function(t){return new H(t.map((function(t){var e=et(t,2),r=e[0],n=e[1];return new ot(r,n)})))})));break;case p:o=new Q(i.coordinates.map((function(t){return new $(t.map((function(t){return new H(t.map((function(t){var e=et(t,2),r=e[0],n=e[1];return new ot(r,n)})))})))})));break;case y:o=new Date(1e3*i.$timestamp);break;case u:case"Array":o=t.formatField(i);break;case v:o=new Date(i.$date);break;default:o=i}Array.isArray(n)?n.push(o):n[r]=o})),n},t.whichType=function(t){var e=Object.prototype.toString.call(t).slice(8,-1);if(e===y)return"BsonDate";if(e===u){if(t instanceof ot)return c;if(t instanceof Date)return y;if(t instanceof Z)return v;t.$timestamp?e=y:t.$date?e=v:ot.validate(t)?e=c:H.validate(t)?e=l:$.validate(t)?e=f:K.validate(t)?e=h:J.validate(t)?e=d:Q.validate(t)&&(e=p)}return e},t.generateDocId=function(){for(var t="",e=0;e<24;e++)t+="ABCDEFabcdef0123456789".charAt(Math.floor(22*Math.random()));return t},t}(),nt=function(){function t(){}return t.isGeopoint=function(t,e){if("Number"!==rt.whichType(e))throw new Error("Geo Point must be number type");var r=Math.abs(e);if("latitude"===t&&r>90)throw new Error("latitude should be a number ranges from -90 to 90");if("longitude"===t&&r>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===g.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){nt.isGeopoint("longitude",t),nt.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)&&nt.isGeopoint("longitude",t.coordinates[0])&&nt.isGeopoint("latitude",t.coordinates[1])},Object.defineProperty(t.prototype,"_internalType",{get:function(){return P},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 r=new Promise((function(e,r){t=function(t,n){return t?r(t):e(n)}}));return t.promise=r,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,r){this._internalType=T,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=t,this.operands=e,this.fieldName=r||O}return t.prototype._setFieldName=function(e){return new t(this.operator,this.operands,e)},t}();function ut(t){return t&&t instanceof at&&t._internalType===T}!function(t){t.AND="and",t.OR="or",t.NOT="not",t.NOR="nor"}(st||(st={}));var ct=function(){function t(t,e,r){if(this._internalType=A,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=t,this.operands=e,this.fieldName=r||O,this.fieldName!==O)if(Array.isArray(e)){e=e.slice(),this.operands=e;for(var n=0,o=e.length;n<o;n++)(lt(i=e[n])||pt(i))&&(e[n]=i._setFieldName(this.fieldName))}else{var i;(lt(i=e)||pt(i))&&(e=i._setFieldName(this.fieldName))}}return t.prototype._setFieldName=function(e){var r=this.operands.map((function(r){return r instanceof t?r._setFieldName(e):r}));return new t(this.operator,r,e)},t.prototype.and=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var n=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return n.unshift(this),new t(st.AND,n,this.fieldName)},t.prototype.or=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var n=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return n.unshift(this),new t(st.OR,n,this.fieldName)},t}();function lt(t){return t&&t instanceof ct&&t._internalType===A}var ft,ht=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},t(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();!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"}(ft||(ft={}));var dt=function(t){function e(e,r,n){var o=t.call(this,e,r,n)||this;return o.operator=e,o._internalType=R,o}return ht(e,t),e.prototype.toJSON=function(){var t,e;switch(this.operator){case ft.IN:case ft.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 r=new e(ft.EQ,[t],this.fieldName);return this.and(r)},e.prototype.neq=function(t){var r=new e(ft.NEQ,[t],this.fieldName);return this.and(r)},e.prototype.gt=function(t){var r=new e(ft.GT,[t],this.fieldName);return this.and(r)},e.prototype.gte=function(t){var r=new e(ft.GTE,[t],this.fieldName);return this.and(r)},e.prototype.lt=function(t){var r=new e(ft.LT,[t],this.fieldName);return this.and(r)},e.prototype.lte=function(t){var r=new e(ft.LTE,[t],this.fieldName);return this.and(r)},e.prototype.in=function(t){var r=new e(ft.IN,t,this.fieldName);return this.and(r)},e.prototype.nin=function(t){var r=new e(ft.NIN,t,this.fieldName);return this.and(r)},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&&!M(t.maxDistance))throw new TypeError('"maxDistance" must be of type Number. Received type '+typeof t.maxDistance);if(void 0!==t.minDistance&&!M(t.minDistance))throw new TypeError('"minDistance" must be of type Number. Received type '+typeof t.minDistance);var r=new e(ft.GEO_NEAR,[t],this.fieldName);return this.and(r)},e.prototype.geoWithin=function(t){if(!(t.geometry instanceof Q||t.geometry instanceof $))throw new TypeError('"geometry" must be of type Polygon or MultiPolygon. Received type '+typeof t.geometry);var r=new e(ft.GEO_WITHIN,[t],this.fieldName);return this.and(r)},e.prototype.geoIntersects=function(t){if(!(t.geometry instanceof ot||t.geometry instanceof H||t.geometry instanceof $||t.geometry instanceof K||t.geometry instanceof J||t.geometry instanceof Q))throw new TypeError('"geometry" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type '+typeof t.geometry);var r=new e(ft.GEO_INTERSECTS,[t],this.fieldName);return this.and(r)},e}(ct);function pt(t){return t&&t instanceof dt&&t._internalType===R}function yt(t){return pt(t)}var vt={};for(var gt in ft)vt[gt]="$"+gt;for(var gt in st)vt[gt]="$"+gt;for(var gt in tt)vt[gt]="$"+gt;function mt(t){return vt[t]||"$"+t}vt[ft.NEQ]="$ne",vt[tt.REMOVE]="$unset",vt[tt.SHIFT]="$pop",vt[tt.UNSHIFT]="$push";var bt=function(){return bt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},bt.apply(this,arguments)},wt=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s},_t=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(wt(arguments[e]));return t};function St(t){return Et(t,[t])}function Et(t,e){if(!V(t)){if(W(t))return{$date:+t};if(F(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 Et(t,_t(e,[t]))}));if(q(t)){var r=bt({},t);for(var n in r){if(e.indexOf(r[n])>-1)throw new Error("Cannot convert circular structure to JSON");r[n]=Et(r[n],_t(e,[r[n]]))}return r}return t}switch(t._internalType){case P:return t.toJSON();case U:case k:return t.parse();default:return t.toJSON?t.toJSON():t}}var It=function(){return It=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},It.apply(this,arguments)},Ot=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s},Tt=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Ot(arguments[e]));return t};function Rt(t,e,r,n){var o=It({},t);for(var i in t)if(!/^\$/.test(i)){var s=t[i];if(s&&q(s)&&!e(s)){if(n.indexOf(s)>-1)throw new Error("Cannot convert circular structure to JSON");var a=Rt(s,e,Tt(r,[i]),Tt(n,[s]));o[i]=a;var u=!1;for(var c in a)/^\$/.test(c)?u=!0:(o[i+"."+c]=a[c],delete o[i][c]);u||delete o[i]}}return o}function At(t){return Rt(t,xt,[],[t])}function Pt(t,e,r){for(var n in e[r]||delete t[r],e)t[n]?B(t[n])?t[n].push(e[n]):q(t[n])?q(e[n])?Object.assign(t[n],e[n]):(console.warn("unmergable condition, query is object but condition is "+D(e)+", can only overwrite",e,r),t[n]=e[n]):(console.warn("to-merge query is of type "+D(t)+", can only overwrite",t,e,r),t[n]=e[n]):t[n]=e[n]}function xt(t){return V(t)||W(t)||F(t)}function Ct(t){return St(t)}var Nt=function(){function t(){}return t.encode=function(e){return(new t).encodeUpdate(e)},t.prototype.encodeUpdate=function(t){return ut(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,r,n,o,i=mt(t.operator);return t.operator===tt.REMOVE?((e={})[i]=((r={})[t.fieldName]="",r),e):((n={})[i]=((o={})[t.fieldName]=t.operands[0],o),n)},t.prototype.encodeArrayUpdateCommand=function(t){var e,r,n,o,i,s,a,u,c,l,f=mt(t.operator);switch(t.operator){case tt.PUSH:var h=void 0;return h=B(t.operands)?{$each:t.operands.map(Ct)}:t.operands,(e={})[f]=((r={})[t.fieldName]=h,r),e;case tt.UNSHIFT:return h={$each:t.operands.map(Ct),$position:0},(n={})[f]=((o={})[t.fieldName]=h,o),n;case tt.POP:return(i={})[f]=((s={})[t.fieldName]=1,s),i;case tt.SHIFT:return(a={})[f]=((u={})[t.fieldName]=-1,u),a;default:return(c={})[f]=((l={})[t.fieldName]=Ct(t.operands),l),c}},t.prototype.encodeUpdateObject=function(t){var e=At(t);for(var r in e)if(!/^\$/.test(r)){var n=e[r];if(ut(n))e[r]=n._setFieldName(r),Pt(e,this.encodeUpdateCommand(e[r]),r);else{e[r]=n=Ct(n);var o=new at(tt.SET,[n],r);Pt(e,this.encodeUpdateCommand(o),r)}}return e},t}(),Lt={};function jt(t){if(!jr.wsClientClass)throw new Error("to use realtime you must import realtime module first");var e=t.config.env;return Lt[e]||(Lt[e]=new jr.wsClientClass({context:{appConfig:{docSizeLimit:1e3,realtimePingInterval:1e4,realtimePongWaitTimeout:5e3,request:new jr.reqClass(t.config)}}})),Lt[e]}for(var Ut=function(){return Ut=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Ut.apply(this,arguments)},kt=function(){function t(t,e,r,n){var o=this;void 0===n&&(n={}),this.watch=function(t){return jt(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=r,this.request=new jr.reqClass(this._db.config),this.projection=n}return t.prototype.create=function(t,e){e=e||it();var r={collectionName:this._coll,data:St(t)};return this.id&&(r._id=this.id),this.request.send("database.addDocument",r).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 r=!1,n=function(t){if("object"==typeof t)for(var e in t)t[e]instanceof at?r=!0:"object"==typeof t[e]&&n(t[e])};if(n(t),r)return Promise.resolve({code:"DATABASE_REQUEST_FAILED",message:"update operator complicit"});var o={collectionName:this._coll,queryType:a.DOC,data:St(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 r={_id:this.id},n={collectionName:this._coll,data:Nt.encode(t),query:r,queryType:a.DOC,multi:!1,merge:!0,upsert:!1};return this.request.send("database.updateDocument",n).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},r={collectionName:this._coll,query:e,queryType:a.DOC,multi:!1};return this.request.send("database.deleteDocument",r).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},r={collectionName:this._coll,query:e,queryType:a.DOC,multi:!1,projection:this.projection};return this.request.send("database.queryDocument",r).then((function(e){if(e.code)t(0,e);else{var r=rt.formatResDocumentData(e.data.list);t(0,{data:r,requestId:e.requestId})}})).catch((function(e){t(e)})),t.promise},t.prototype.field=function(e){for(var r in e)e[r]?e[r]=1:e[r]=0;return new t(this._db,this._coll,this.id,e)},t}(),Dt=function(){function t(){}return t.encode=function(t){return(new qt).encodeQuery(t)},t}(),qt=function(){function t(){}return t.prototype.encodeQuery=function(t,e){var r;return xt(t)?lt(t)?this.encodeLogicCommand(t):pt(t)?this.encodeQueryCommand(t):((r={})[e]=this.encodeQueryObject(t),r):q(t)?this.encodeQueryObject(t):t},t.prototype.encodeRegExp=function(t){return{$regex:t.source,$options:t.flags}},t.prototype.encodeLogicCommand=function(t){var e,r,n,o,i,s,a,u=this;switch(t.operator){case st.NOR:case st.AND:case st.OR:var c=mt(t.operator),l=t.operands.map((function(e){return u.encodeQuery(e,t.fieldName)}));return(e={})[c]=l,e;case st.NOT:c=mt(t.operator);var f=t.operands[0];return F(f)?((r={})[t.fieldName]=((n={})[c]=this.encodeRegExp(f),n),r):(l=this.encodeQuery(f)[t.fieldName],(o={})[t.fieldName]=((i={})[c]=l,i),o);default:if(c=mt(t.operator),1===t.operands.length){var h=this.encodeQuery(t.operands[0]);return(s={})[c]=h,s}return l=t.operands.map(this.encodeQuery.bind(this)),(a={})[c]=l,a}},t.prototype.encodeQueryCommand=function(t){return yt(t),this.encodeComparisonCommand(t)},t.prototype.encodeComparisonCommand=function(t){var e,r,n,o,i,s,a,u,c;if(t.fieldName===O)throw new Error("Cannot encode a comparison command with unset field name");var l=mt(t.operator);switch(t.operator){case ft.EQ:case ft.NEQ:case ft.LT:case ft.LTE:case ft.GT:case ft.GTE:case ft.ELEM_MATCH:case ft.EXISTS:case ft.SIZE:case ft.MOD:return(e={})[t.fieldName]=((r={})[l]=Ct(t.operands[0]),r),e;case ft.IN:case ft.NIN:case ft.ALL:return(n={})[t.fieldName]=((o={})[l]=Ct(t.operands),o),n;case ft.GEO_NEAR:var f=t.operands[0];return(i={})[t.fieldName]={$nearSphere:{$geometry:f.geometry.toJSON(),$maxDistance:f.maxDistance,$minDistance:f.minDistance}},i;case ft.GEO_WITHIN:return f=t.operands[0],(s={})[t.fieldName]={$geoWithin:{$geometry:f.geometry.toJSON()}},s;case ft.GEO_INTERSECTS:return f=t.operands[0],(a={})[t.fieldName]={$geoIntersects:{$geometry:f.geometry.toJSON()}},a;default:return(u={})[t.fieldName]=((c={})[l]=Ct(t.operands[0]),c),u}},t.prototype.encodeQueryObject=function(t){var e=At(t);for(var r in e){var n=e[r];if(lt(n)){e[r]=n._setFieldName(r);var o=this.encodeLogicCommand(e[r]);this.mergeConditionAfterEncode(e,o,r)}else yt(n)?(e[r]=n._setFieldName(r),o=this.encodeComparisonCommand(e[r]),this.mergeConditionAfterEncode(e,o,r)):xt(n)&&(e[r]=Ct(n))}return e},t.prototype.mergeConditionAfterEncode=function(t,e,r){for(var n in e[r]||delete t[r],e)t[n]?B(t[n])?t[n]=t[n].concat(e[n]):q(t[n])?q(e[n])?Object.assign(t,e):(console.warn("unmergable condition, query is object but condition is "+D(e)+", can only overwrite",e,r),t[n]=e[n]):(console.warn("to-merge query is of type "+D(t)+", can only overwrite",t,e,r),t[n]=e[n]):t[n]=e[n]},t}(),Mt=function(){return Mt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Mt.apply(this,arguments)},Bt=function(){function t(t,e,r,n,o){var i=this;this.watch=function(t){return jt(i._db).watch(Mt(Mt({},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=r,this._fieldOrders=n||[],this._queryOptions=o||{},this._request=new jr.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 r={collectionName:this._coll,queryType:a.WHERE};return this._fieldFilters&&(r.query=this._fieldFilters),e.length>0&&(r.order=e),this._queryOptions.offset&&(r.offset=this._queryOptions.offset),this._queryOptions.limit?r.limit=this._queryOptions.limit<1e3?this._queryOptions.limit:1e3:r.limit=100,this._queryOptions.projection&&(r.projection=this._queryOptions.projection),this._request.send("database.queryDocument",r).then((function(e){if(e.code)t(0,e);else{var r={data:rt.formatResDocumentData(e.data.list),requestId:e.requestId};e.total&&(r.total=e.total),e.limit&&(r.limit=e.limit),e.offset&&(r.offset=e.offset),t(0,r)}})).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 r=Object.keys(e),n=r.some((function(t){return void 0!==e[t]}));if(r.length&&!n)throw Error(o.QueryParamValueError);return new t(this._db,this._coll,Dt.encode(e),this._fieldOrders,this._queryOptions)},t.prototype.orderBy=function(e,r){nt.isFieldPath(e),nt.isFieldOrder(r);var n={field:e,direction:r},o=this._fieldOrders.concat(n);return new t(this._db,this._coll,this._fieldFilters,o,this._queryOptions)},t.prototype.limit=function(e){nt.isInteger("limit",e);var r=Mt({},this._queryOptions);return r.limit=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,r)},t.prototype.skip=function(e){nt.isInteger("offset",e);var r=Mt({},this._queryOptions);return r.offset=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,r)},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 r={collectionName:this._coll,query:this._fieldFilters,queryType:a.WHERE,multi:!0,merge:!0,upsert:!1,data:Nt.encode(t)};return this._request.send("database.updateDocument",r).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 r in e)e[r]?"object"!=typeof e[r]&&(e[r]=1):e[r]=0;var n=Mt({},this._queryOptions);return n.projection=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},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}(),Wt=[],Ft=[],Vt="undefined"!=typeof Uint8Array?Uint8Array:Array,Ht="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Gt=0;Gt<64;++Gt)Wt[Gt]=Ht[Gt],Ft[Ht.charCodeAt(Gt)]=Gt;function $t(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function Kt(t,e,r){for(var n,o,i=[],s=e;s<r;s+=3)n=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]),i.push(Wt[(o=n)>>18&63]+Wt[o>>12&63]+Wt[o>>6&63]+Wt[63&o]);return i.join("")}Ft["-".charCodeAt(0)]=62,Ft["_".charCodeAt(0)]=63;var zt=function(t){var e,r,n=$t(t),o=n[0],i=n[1],s=new Vt(function(t,e,r){return 3*(e+r)/4-r}(0,o,i)),a=0,u=i>0?o-4:o;for(r=0;r<u;r+=4)e=Ft[t.charCodeAt(r)]<<18|Ft[t.charCodeAt(r+1)]<<12|Ft[t.charCodeAt(r+2)]<<6|Ft[t.charCodeAt(r+3)],s[a++]=e>>16&255,s[a++]=e>>8&255,s[a++]=255&e;return 2===i&&(e=Ft[t.charCodeAt(r)]<<2|Ft[t.charCodeAt(r+1)]>>4,s[a++]=255&e),1===i&&(e=Ft[t.charCodeAt(r)]<<10|Ft[t.charCodeAt(r+1)]<<4|Ft[t.charCodeAt(r+2)]>>2,s[a++]=e>>8&255,s[a++]=255&e),s},Jt=function(t){for(var e,r=t.length,n=r%3,o=[],i=16383,s=0,a=r-n;s<a;s+=i)o.push(Kt(t,s,s+i>a?a:s+i));return 1===n?(e=t[r-1],o.push(Wt[e>>2]+Wt[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],o.push(Wt[e>>10]+Wt[e>>4&63]+Wt[e<<2&63]+"=")),o.join("")},Yt=function(t,e,r,n,o){var i,s,a=8*o-n-1,u=(1<<a)-1,c=u>>1,l=-7,f=r?o-1:0,h=r?-1:1,d=t[e+f];for(f+=h,i=d&(1<<-l)-1,d>>=-l,l+=a;l>0;i=256*i+t[e+f],f+=h,l-=8);for(s=i&(1<<-l)-1,i>>=-l,l+=n;l>0;s=256*s+t[e+f],f+=h,l-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),i-=c}return(d?-1:1)*s*Math.pow(2,i-n)},Qt=function(t,e,r,n,o,i){var s,a,u,c=8*i-o-1,l=(1<<c)-1,f=l>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:i-1,p=n?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=l):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+f>=1?h/u:h*Math.pow(2,1-f))*u>=2&&(s++,u/=2),s+f>=l?(a=0,s=l):s+f>=1?(a=(e*u-1)*Math.pow(2,o),s+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,o),s=0));o>=8;t[r+d]=255&a,d+=p,a/=256,o-=8);for(s=s<<o|a,c+=o;c>0;t[r+d]=255&s,d+=p,s/=256,c-=8);t[r+d-p]|=128*y},Zt=function(t,e){return function(t,e){var r="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 n=2147483647;function o(t){if(t>n)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,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return u(t)}return s(t,e,r)}function s(t,e,r){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 r=0|h(t,e),n=o(r),s=n.write(t,e);return s!==r&&(n=n.slice(0,s)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(q(t,Uint8Array)){var e=new Uint8Array(t);return l(e.buffer,e.byteOffset,e.byteLength)}return c(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(q(t,ArrayBuffer)||t&&q(t.buffer,ArrayBuffer))return l(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(q(t,SharedArrayBuffer)||t&&q(t.buffer,SharedArrayBuffer)))return l(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');var n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return i.from(n,e,r);var s=function(t){if(i.isBuffer(t)){var e=0|f(t.length),r=o(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||M(t.length)?o(0):c(t):"Buffer"===t.type&&Array.isArray(t.data)?c(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,r);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 u(t){return a(t),o(t<0?0:0|f(t))}function c(t){for(var e=t.length<0?0:0|f(t.length),r=o(e),n=0;n<e;n+=1)r[n]=255&t[n];return r}function l(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');var n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,i.prototype),n}function f(t){if(t>=n)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n.toString(16)+" bytes");return 0|t}function h(t,e){if(i.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||q(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 r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return U(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return k(t).length;default:if(o)return n?-1:U(t).length;e=(""+e).toLowerCase(),o=!0}}function d(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return R(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return O(this,e,r);case"latin1":case"binary":return T(this,e,r);case"base64":return S(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function y(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),M(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=i.from(e,n)),i.isBuffer(e))return 0===e.length?-1:v(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):v(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,o){var i,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){var l=-1;for(i=r;i<a;i++)if(c(t,i)===c(e,-1===l?0:i-l)){if(-1===l&&(l=i),i-l+1===u)return l*s}else-1!==l&&(i-=i-l),l=-1}else for(r+u>a&&(r=a-u),i=r;i>=0;i--){for(var f=!0,h=0;h<u;h++)if(c(t,i+h)!==c(e,h)){f=!1;break}if(f)return i}return-1}function g(t,e,r,n){r=Number(r)||0;var o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var s=0;s<n;++s){var a=parseInt(e.substr(2*s,2),16);if(M(a))return s;t[r+s]=a}return s}function m(t,e,r,n){return D(U(e,t.length-r),t,r,n)}function b(t,e,r,n){return D(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function w(t,e,r,n){return D(k(e),t,r,n)}function _(t,e,r,n){return D(function(t,e){for(var r,n,o,i=[],s=0;s<t.length&&!((e-=2)<0);++s)n=(r=t.charCodeAt(s))>>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function S(t,e,r){return 0===e&&r===t.length?Jt(t):Jt(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o<r;){var i,s,a,u,c=t[o],l=null,f=c>239?4:c>223?3:c>191?2:1;if(o+f<=r)switch(f){case 1:c<128&&(l=c);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&c)<<6|63&i)>127&&(l=u);break;case 3:i=t[o+1],s=t[o+2],128==(192&i)&&128==(192&s)&&(u=(15&c)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:i=t[o+1],s=t[o+2],a=t[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(l=u)}null===l?(l=65533,f=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),o+=f}return function(t){var e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);for(var r="",n=0;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=I));return r}(n)}e.kMaxLength=n,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,r){return s(t,e,r)},Object.setPrototypeOf(i.prototype,Uint8Array.prototype),Object.setPrototypeOf(i,Uint8Array),i.alloc=function(t,e,r){return function(t,e,r){return a(t),t<=0?o(t):void 0!==e?"string"==typeof r?o(t).fill(e,r):o(t).fill(e):o(t)}(t,e,r)},i.allocUnsafe=function(t){return u(t)},i.allocUnsafeSlow=function(t){return u(t)},i.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==i.prototype},i.compare=function(t,e){if(q(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),q(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 r=t.length,n=e.length,o=0,s=Math.min(r,n);o<s;++o)if(t[o]!==e[o]){r=t[o],n=e[o];break}return r<n?-1:n<r?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 r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=i.allocUnsafe(e),o=0;for(r=0;r<t.length;++r){var s=t[r];if(q(s,Uint8Array))o+s.length>n.length?i.from(s).copy(n,o):Uint8Array.prototype.set.call(n,s,o);else{if(!i.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,o)}o+=s.length}return n},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)p(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)p(this,e,e+3),p(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)p(this,e,e+7),p(this,e+1,e+6),p(this,e+2,e+5),p(this,e+3,e+4);return this},i.prototype.toString=function(){var t=this.length;return 0===t?"":0===arguments.length?E(this,0,t):d.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="",r=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},r&&(i.prototype[r]=i.prototype.inspect),i.prototype.compare=function(t,e,r,n,o){if(q(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===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;for(var s=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),u=Math.min(s,a),c=this.slice(n,o),l=t.slice(e,r),f=0;f<u;++f)if(c[f]!==l[f]){s=c[f],a=l[f];break}return s<a?-1:a<s?1:0},i.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},i.prototype.indexOf=function(t,e,r){return y(this,t,e,r,!0)},i.prototype.lastIndexOf=function(t,e,r){return y(this,t,e,r,!1)},i.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return m(this,t,e,r);case"ascii":case"latin1":case"binary":return b(this,t,e,r);case"base64":return w(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).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,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(127&t[o]);return n}function T(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function R(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var o="",i=e;i<r;++i)o+=B[t[i]];return o}function A(t,e,r){for(var n=t.slice(e,r),o="",i=0;i<n.length-1;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function P(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function x(t,e,r,n,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(r+n>t.length)throw new RangeError("Index out of range")}function C(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function N(t,e,r,n,o){return e=+e,r>>>=0,o||C(t,0,r,4),Qt(t,e,r,n,23,4),r+4}function L(t,e,r,n,o){return e=+e,r>>>=0,o||C(t,0,r,8),Qt(t,e,r,n,52,8),r+8}i.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);var n=this.subarray(t,e);return Object.setPrototypeOf(n,i.prototype),n},i.prototype.readUintLE=i.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||P(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n},i.prototype.readUintBE=i.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||P(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},i.prototype.readUint8=i.prototype.readUInt8=function(t,e){return t>>>=0,e||P(t,1,this.length),this[t]},i.prototype.readUint16LE=i.prototype.readUInt16LE=function(t,e){return t>>>=0,e||P(t,2,this.length),this[t]|this[t+1]<<8},i.prototype.readUint16BE=i.prototype.readUInt16BE=function(t,e){return t>>>=0,e||P(t,2,this.length),this[t]<<8|this[t+1]},i.prototype.readUint32LE=i.prototype.readUInt32LE=function(t,e){return t>>>=0,e||P(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||P(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},i.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||P(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*e)),n},i.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||P(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},i.prototype.readInt8=function(t,e){return t>>>=0,e||P(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},i.prototype.readInt16LE=function(t,e){t>>>=0,e||P(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},i.prototype.readInt16BE=function(t,e){t>>>=0,e||P(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},i.prototype.readInt32LE=function(t,e){return t>>>=0,e||P(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||P(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||P(t,4,this.length),Yt(this,t,!0,23,4)},i.prototype.readFloatBE=function(t,e){return t>>>=0,e||P(t,4,this.length),Yt(this,t,!1,23,4)},i.prototype.readDoubleLE=function(t,e){return t>>>=0,e||P(t,8,this.length),Yt(this,t,!0,52,8)},i.prototype.readDoubleBE=function(t,e){return t>>>=0,e||P(t,8,this.length),Yt(this,t,!1,52,8)},i.prototype.writeUintLE=i.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||x(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=t/o&255;return e+r},i.prototype.writeUintBE=i.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||x(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},i.prototype.writeUint8=i.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,1,255,0),this[e]=255&t,e+1},i.prototype.writeUint16LE=i.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||x(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,r){return t=+t,e>>>=0,r||x(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,r){return t=+t,e>>>=0,r||x(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,r){return t=+t,e>>>=0,r||x(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,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);x(this,t,e,r,o-1,-o)}var i=0,s=1,a=0;for(this[e]=255&t;++i<r&&(s*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/s|0)-a&255;return e+r},i.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);x(this,t,e,r,o-1,-o)}var i=r-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+r},i.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},i.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||x(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,r){return t=+t,e>>>=0,r||x(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,r){return N(this,t,e,!0,r)},i.prototype.writeFloatBE=function(t,e,r){return N(this,t,e,!1,r)},i.prototype.writeDoubleLE=function(t,e,r){return L(this,t,e,!0,r)},i.prototype.writeDoubleBE=function(t,e,r){return L(this,t,e,!1,r)},i.prototype.copy=function(t,e,r,n){if(!i.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var o=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),o},i.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!i.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var o=t.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(t=o)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var s;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(s=e;s<r;++s)this[s]=t;else{var a=i.isBuffer(t)?t:i.from(t,n),u=a.length;if(0===u)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(s=0;s<r-e;++s)this[s+e]=a[s%u]}return this};var j=/[^+/0-9A-Za-z-_]/g;function U(t,e){var r;e=e||1/0;for(var n=t.length,o=null,i=[],s=0;s<n;++s){if((r=t.charCodeAt(s))>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function k(t){return zt(function(t){if((t=(t=t.split("=")[0]).trim().replace(j,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function D(t,e,r,n){for(var o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function q(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function M(t){return t!=t}var B=function(){for(var t="0123456789abcdef",e=new Array(256),r=0;r<16;++r)for(var n=16*r,o=0;o<16;++o)e[n+o]=t[r]+t[o];return e}()}(e={exports:{}},e.exports),e.exports}(),Xt=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 r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},te(t,e)};function ee(t,e){function r(){this.constructor=t}te(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var re=function(t){function e(r){var n=t.call(this,r)||this;return Object.setPrototypeOf(n,e.prototype),n}return ee(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return"BSONError"},enumerable:!1,configurable:!0}),e}(Error),ne=function(t){function e(r){var n=t.call(this,r)||this;return Object.setPrototypeOf(n,e.prototype),n}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 r.g&&r.g)||Function("return this")()}var se=function(t){var e,r="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(r);for(var n=Xt.alloc(t),o=0;o<t;++o)n[o]=Math.floor(256*Math.random());return n},ae=function(){if("undefined"!=typeof window){var t=window.crypto||window.msCrypto;if(t&&t.getRandomValues)return function(e){return t.getRandomValues(Xt.alloc(e))}}return void 0!==r.g&&r.g.crypto&&r.g.crypto.getRandomValues?function(t){return r.g.crypto.getRandomValues(Xt.alloc(t))}:se}();function ue(t){return"[object Uint8Array]"===Object.prototype.toString.call(t)}function ce(t){return"object"==typeof t&&null!==t}function le(t,e){var r=!1;return function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return r||(console.warn(e),r=!0),t.apply(this,n)}}function fe(t){if(ArrayBuffer.isView(t))return Xt.from(t.buffer,t.byteOffset,t.byteLength);if(e=t,["[object ArrayBuffer]","[object SharedArrayBuffer]"].includes(Object.prototype.toString.call(e)))return Xt.from(t);var e;throw new ne("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,de=function(t){return"string"==typeof t&&he.test(t)},pe=function(t){if(!de(t))throw new ne('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 Xt.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")},ve=(Math.pow(2,63),Math.pow(2,63),Math.pow(2,53)),ge=-Math.pow(2,53),me=function(){function t(e,r){if(!(this instanceof t))return new t(e,r);if(!(null==e||"string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||Array.isArray(e)))throw new ne("Binary can only be constructed from string, Buffer, TypedArray, or Array<number>");this.sub_type=null!=r?r:t.BSON_BINARY_SUBTYPE_DEFAULT,null==e?(this.buffer=Xt.alloc(t.BUFFER_SIZE),this.position=0):("string"==typeof e?this.buffer=Xt.from(e,"binary"):Array.isArray(e)?this.buffer=Xt.from(e):this.buffer=fe(e),this.position=this.buffer.byteLength)}return t.prototype.put=function(e){if("string"==typeof e&&1!==e.length)throw new ne("only accepts single character String");if("number"!=typeof e&&1!==e.length)throw new ne("only accepts single character Uint8Array or Array");var r;if((r="string"==typeof e?e.charCodeAt(0):"number"==typeof e?e:e[0])<0||r>255)throw new ne("only accepts number in a valid unsigned byte range 0-255");if(this.buffer.length>this.position)this.buffer[this.position++]=r;else{var n=Xt.alloc(t.BUFFER_SIZE+this.buffer.length);this.buffer.copy(n,0,0,this.buffer.length),this.buffer=n,this.buffer[this.position++]=r}},t.prototype.write=function(t,e){if(e="number"==typeof e?e:this.position,this.buffer.length<e+t.length){var r=Xt.alloc(this.buffer.length+t.length);this.buffer.copy(r,0,0,this.buffer.length),this.buffer=r}ArrayBuffer.isView(t)?(this.buffer.set(fe(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"),r=Number(this.sub_type).toString(16);return t.legacy?{$binary:e,$type:1===r.length?"0"+r:r}:{$binary:{base64:e,subType:1===r.length?"0"+r:r}}},t.prototype.toUUID=function(){if(this.sub_type===t.SUBTYPE_UUID)return new be(this.buffer.slice(0,this.position));throw new re('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,r){var n,o;if(r=r||{},"$binary"in e?r.legacy&&"string"==typeof e.$binary&&"$type"in e?(o=e.$type?parseInt(e.$type,16):0,n=Xt.from(e.$binary,"base64")):"string"!=typeof e.$binary&&(o=e.$binary.subType?parseInt(e.$binary.subType,16):0,n=Xt.from(e.$binary.base64,"base64")):"$uuid"in e&&(o=4,n=pe(e.$uuid)),!n)throw new ne("Unexpected Binary Extended JSON format ".concat(JSON.stringify(e)));return 4===o?new be(n):new t(n,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 be=function(t){function e(r){var n,o,i=this;if(null==r)n=e.generate();else if(r instanceof e)n=Xt.from(r.buffer),o=r.__id;else if(ArrayBuffer.isView(r)&&16===r.byteLength)n=fe(r);else{if("string"!=typeof r)throw new ne("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).");n=pe(r)}return(i=t.call(this,n,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 r=ye(this.id,t);return e.cacheHexString&&(this.__id=r),r},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,Xt.from(t)},e.isValid=function(t){return!!t&&(t instanceof e||("string"==typeof t?de(t):!(!ue(t)||16!==t.length||64!=(240&t[6])||128&~t[8])))},e.createFromHexString=function(t){return new e(pe(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,r){if(!(this instanceof t))return new t(e,r);this.code=e,this.scope=r}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 _e=function(){function t(e,r,n,o){if(!(this instanceof t))return new t(e,r,n,o);var i=e.split(".");2===i.length&&(n=i.shift(),e=i.shift()),this.collection=e,this.oid=r,this.db=n,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 r=Object.assign({},e);return delete r.$ref,delete r.$id,delete r.$db,new t(e.$ref,e.$id,e.$db,r)},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(_e.prototype,"_bsontype",{value:"DBRef"});var Se=void 0;try{Se=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(n){}var Ee=4294967296,Ie=0x10000000000000000,Oe=Ie/2,Te={},Re={},Ae=function(){function t(e,r,n){if(void 0===e&&(e=0),!(this instanceof t))return new t(e,r,n);"bigint"==typeof e?Object.assign(this,t.fromBigInt(e,!!r)):"string"==typeof e?Object.assign(this,t.fromString(e,!!r)):(this.low=0|e,this.high=0|r,this.unsigned=!!n),Object.defineProperty(this,"__isLong__",{value:!0,configurable:!1,writable:!1,enumerable:!1})}return t.fromBits=function(e,r,n){return new t(e,r,n)},t.fromInt=function(e,r){var n,o,i;return r?(i=0<=(e>>>=0)&&e<256)&&(o=Re[e])?o:(n=t.fromBits(e,(0|e)<0?-1:0,!0),i&&(Re[e]=n),n):(i=-128<=(e|=0)&&e<128)&&(o=Te[e])?o:(n=t.fromBits(e,e<0?-1:0,!1),i&&(Te[e]=n),n)},t.fromNumber=function(e,r){if(isNaN(e))return r?t.UZERO:t.ZERO;if(r){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,r).neg():t.fromBits(e%Ee|0,e/Ee|0,r)},t.fromBigInt=function(e,r){return t.fromString(e.toString(),r)},t.fromString=function(e,r,n){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t.ZERO;if("number"==typeof r?(n=r,r=!1):r=!!r,(n=n||10)<2||36<n)throw RangeError("radix");var o;if((o=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===o)return t.fromString(e.substring(1),r,n).neg();for(var i=t.fromNumber(Math.pow(n,8)),s=t.ZERO,a=0;a<e.length;a+=8){var u=Math.min(8,e.length-a),c=parseInt(e.substring(a,a+u),n);if(u<8){var l=t.fromNumber(Math.pow(n,u));s=s.mul(l).add(t.fromNumber(c))}else s=(s=s.mul(i)).add(t.fromNumber(c))}return s.unsigned=r,s},t.fromBytes=function(e,r,n){return n?t.fromBytesLE(e,r):t.fromBytesBE(e,r)},t.fromBytesLE=function(e,r){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,r)},t.fromBytesBE=function(e,r){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],r)},t.isLong=function(t){return ce(t)&&!0===t.__isLong__},t.fromValue=function(e,r){return"number"==typeof e?t.fromNumber(e,r):"string"==typeof e?t.fromString(e,r):t.fromBits(e.low,e.high,"boolean"==typeof r?r:e.unsigned)},t.prototype.add=function(e){t.isLong(e)||(e=t.fromValue(e));var r=this.high>>>16,n=65535&this.high,o=this.low>>>16,i=65535&this.low,s=e.high>>>16,a=65535&e.high,u=e.low>>>16,c=0,l=0,f=0,h=0;return f+=(h+=i+(65535&e.low))>>>16,h&=65535,l+=(f+=o+u)>>>16,f&=65535,c+=(l+=n+a)>>>16,l&=65535,c+=r+s,c&=65535,t.fromBits(f<<16|h,c<<16|l,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 r=this.isNegative(),n=e.isNegative();return r&&!n?-1:!r&&n?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(Se){if(!this.unsigned&&-2147483648===this.high&&-1===e.low&&-1===e.high)return this;var r=(this.unsigned?Se.div_u:Se.div_s)(this.low,this.high,e.low,e.high);return t.fromBits(r,Se.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?t.UZERO:t.ZERO;var n,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:(n=this.shr(1).div(e).shl(1)).eq(t.ZERO)?e.isNegative()?t.ONE:t.NEG_ONE:(o=this.sub(e.mul(n)),i=n.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);){n=Math.max(1,Math.floor(o.toNumber()/e.toNumber()));for(var s=Math.ceil(Math.log(n)/Math.LN2),a=s<=48?1:Math.pow(2,s-48),u=t.fromNumber(n),c=u.mul(e);c.isNegative()||c.gt(o);)n-=a,c=(u=t.fromNumber(n,this.unsigned)).mul(e);u.isZero()&&(u=t.ONE),i=i.add(u),o=o.sub(c)}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,r=0!==this.high?this.high:this.low;for(e=31;e>0&&!(r&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)),Se){var r=(this.unsigned?Se.rem_u:Se.rem_s)(this.low,this.high,e.low,e.high);return t.fromBits(r,Se.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)),Se){var r=Se.mul(this.low,this.high,e.low,e.high);return t.fromBits(r,Se.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 n=this.high>>>16,o=65535&this.high,i=this.low>>>16,s=65535&this.low,a=e.high>>>16,u=65535&e.high,c=e.low>>>16,l=65535&e.low,f=0,h=0,d=0,p=0;return d+=(p+=s*l)>>>16,p&=65535,h+=(d+=i*l)>>>16,d&=65535,h+=(d+=s*c)>>>16,d&=65535,f+=(h+=o*l)>>>16,h&=65535,f+=(h+=i*c)>>>16,h&=65535,f+=(h+=s*u)>>>16,h&=65535,f+=n*l+o*c+i*u+s*a,f&=65535,t.fromBits(d<<16|p,f<<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 r=this.high;if(e<32){var n=this.low;return t.fromBits(n>>>e|r<<32-e,r>>>e,this.unsigned)}return 32===e?t.fromBits(r,0,this.unsigned):t.fromBits(r>>>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)*Ee+(this.low>>>0):this.high*Ee+(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 r=t.fromNumber(e),n=this.div(r),o=n.mul(r).sub(this);return n.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 u=s.div(i),c=(s.sub(u.mul(i)).toInt()>>>0).toString(e);if((s=u).isZero())return c+a;for(;c.length<6;)c="0"+c;a=""+c+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,r){var n=t.fromString(e.$numberLong);return r&&r.relaxed?n.toNumber():n},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(Ae.prototype,"__isLong__",{value:!0}),Object.defineProperty(Ae.prototype,"_bsontype",{value:"Long"});var Pe=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,xe=/^(\+|-)?(Infinity|inf)$/i,Ce=/^(\+|-)?NaN$/i,Ne=6111,Le=-6176,je=[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(),ke=[120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),De=/^([-+])?(\d+)?$/;function qe(t){return!isNaN(parseInt(t,10))}function Me(t){var e=Ae.fromNumber(1e9),r=Ae.fromNumber(0);if(!(t.parts[0]||t.parts[1]||t.parts[2]||t.parts[3]))return{quotient:t,rem:r};for(var n=0;n<=3;n++)r=(r=r.shiftLeft(32)).add(new Ae(t.parts[n],0)),t.parts[n]=r.div(e).low,r=r.modulo(e);return{quotient:t,rem:r}}function Be(t,e){throw new ne('"'.concat(t,'" is not a valid Decimal128 string - ').concat(e))}var We=function(){function t(e){if(!(this instanceof t))return new t(e);if("string"==typeof e)this.bytes=t.fromString(e).bytes;else{if(!ue(e))throw new ne("Decimal128 must take a Buffer or string");if(16!==e.byteLength)throw new ne("Decimal128 must take a Buffer of 16 bytes");this.bytes=e}}return t.fromString=function(e){var r,n=!1,o=!1,i=!1,s=0,a=0,u=0,c=0,l=0,f=[0],h=0,d=0,p=0,y=0,v=0,g=0,m=new Ae(0,0),b=new Ae(0,0),w=0;if(e.length>=7e3)throw new ne(e+" not a valid Decimal128 string");var _=e.match(Pe),S=e.match(xe),E=e.match(Ce);if(!_&&!S&&!E||0===e.length)throw new ne(e+" not a valid Decimal128 string");if(_){var I=_[2],O=_[4],T=_[5],R=_[6];O&&void 0===R&&Be(e,"missing exponent power"),O&&void 0===I&&Be(e,"missing exponent base"),void 0===O&&(T||R)&&Be(e,"missing e before exponent")}if("+"!==e[w]&&"-"!==e[w]||(n="-"===e[w++]),!qe(e[w])&&"."!==e[w]){if("i"===e[w]||"I"===e[w])return new t(Xt.from(n?Ue:ke));if("N"===e[w])return new t(Xt.from(je))}for(;qe(e[w])||"."===e[w];)"."!==e[w]?(h<34&&("0"!==e[w]||i)&&(i||(l=a),i=!0,f[d++]=parseInt(e[w],10),h+=1),i&&(u+=1),o&&(c+=1),a+=1,w+=1):(o&&Be(e,"contains multiple periods"),o=!0,w+=1);if(o&&!a)throw new ne(e+" not a valid Decimal128 string");if("e"===e[w]||"E"===e[w]){var A=e.substr(++w).match(De);if(!A||!A[2])return new t(Xt.from(je));v=parseInt(A[0],10),w+=A[0].length}if(e[w])return new t(Xt.from(je));if(p=0,h){if(y=h-1,1!==(s=u))for(;0===f[l+s-1];)s-=1}else p=0,y=0,f[0]=0,u=1,h=1,s=0;for(v<=c&&c-v>16384?v=Le:v-=c;v>Ne;){if((y+=1)-p>34){if(f.join("").match(/^0+$/)){v=Ne;break}Be(e,"overflow")}v-=1}for(;v<Le||h<u;){if(0===y&&s<h){v=Le,s=0;break}if(h<u?u-=1:y-=1,v<Ne)v+=1;else{if(f.join("").match(/^0+$/)){v=Ne;break}Be(e,"overflow")}}if(y-p+1<s){var P=a;o&&(l+=1,P+=1),n&&(l+=1,P+=1);var x=parseInt(e[l+y+1],10),C=0;if(x>=5&&(C=1,5===x))for(C=f[y]%2==1?1:0,g=l+y+2;g<P;g++)if(parseInt(e[g],10)){C=1;break}if(C)for(var N=y;N>=0;N--)if(++f[N]>9&&(f[N]=0,0===N)){if(!(v<Ne))return new t(Xt.from(n?Ue:ke));v+=1,f[N]=1}}if(m=Ae.fromNumber(0),b=Ae.fromNumber(0),0===s)m=Ae.fromNumber(0),b=Ae.fromNumber(0);else if(y-p<17)for(N=p,b=Ae.fromNumber(f[N++]),m=new Ae(0,0);N<=y;N++)b=(b=b.multiply(Ae.fromNumber(10))).add(Ae.fromNumber(f[N]));else{for(N=p,m=Ae.fromNumber(f[N++]);N<=y-17;N++)m=(m=m.multiply(Ae.fromNumber(10))).add(Ae.fromNumber(f[N]));for(b=Ae.fromNumber(f[N++]);N<=y;N++)b=(b=b.multiply(Ae.fromNumber(10))).add(Ae.fromNumber(f[N]))}var L,j,U,k,D=function(t,e){if(!t&&!e)return{high:Ae.fromNumber(0),low:Ae.fromNumber(0)};var r=t.shiftRightUnsigned(32),n=new Ae(t.getLowBits(),0),o=e.shiftRightUnsigned(32),i=new Ae(e.getLowBits(),0),s=r.multiply(o),a=r.multiply(i),u=n.multiply(o),c=n.multiply(i);return s=s.add(a.shiftRightUnsigned(32)),a=new Ae(a.getLowBits(),0).add(u).add(c.shiftRightUnsigned(32)),{high:s=s.add(a.shiftRightUnsigned(32)),low:c=a.shiftLeft(32).add(new Ae(c.getLowBits(),0))}}(m,Ae.fromString("100000000000000000"));D.low=D.low.add(b),j=b,((U=(L=D.low).high>>>0)<(k=j.high>>>0)||U===k&&L.low>>>0<j.low>>>0)&&(D.high=D.high.add(Ae.fromNumber(1))),r=v+6176;var q={low:Ae.fromNumber(0),high:Ae.fromNumber(0)};D.high.shiftRightUnsigned(49).and(Ae.fromNumber(1)).equals(Ae.fromNumber(1))?(q.high=q.high.or(Ae.fromNumber(3).shiftLeft(61)),q.high=q.high.or(Ae.fromNumber(r).and(Ae.fromNumber(16383).shiftLeft(47))),q.high=q.high.or(D.high.and(Ae.fromNumber(0x7fffffffffff)))):(q.high=q.high.or(Ae.fromNumber(16383&r).shiftLeft(49)),q.high=q.high.or(D.high.and(Ae.fromNumber(562949953421311)))),q.low=D.low,n&&(q.high=q.high.or(Ae.fromString("9223372036854775808")));var M=Xt.alloc(16);return w=0,M[w++]=255&q.low.low,M[w++]=q.low.low>>8&255,M[w++]=q.low.low>>16&255,M[w++]=q.low.low>>24&255,M[w++]=255&q.low.high,M[w++]=q.low.high>>8&255,M[w++]=q.low.high>>16&255,M[w++]=q.low.high>>24&255,M[w++]=255&q.high.low,M[w++]=q.high.low>>8&255,M[w++]=q.high.low>>16&255,M[w++]=q.high.low>>24&255,M[w++]=255&q.high.high,M[w++]=q.high.high>>8&255,M[w++]=q.high.high>>16&255,M[w++]=q.high.high>>24&255,new t(M)},t.prototype.toString=function(){for(var t,e=0,r=new Array(36),n=0;n<r.length;n++)r[n]=0;var o,i,s,a=0,u=!1,c={parts:[0,0,0,0]},l=[];a=0;var f=this.bytes,h=f[a++]|f[a++]<<8|f[a++]<<16|f[a++]<<24,d=f[a++]|f[a++]<<8|f[a++]<<16|f[a++]<<24,p=f[a++]|f[a++]<<8|f[a++]<<16|f[a++]<<24,y=f[a++]|f[a++]<<8|f[a++]<<16|f[a++]<<24;a=0,(new Ae(h,d),new Ae(p,y)).lessThan(Ae.ZERO)&&l.push("-");var v=y>>26&31;if(v>>3==3){if(30===v)return l.join("")+"Infinity";if(31===v)return"NaN";t=y>>15&16383,o=8+(y>>14&1)}else o=y>>14&7,t=y>>17&16383;var g=t-6176;if(c.parts[0]=(16383&y)+((15&o)<<14),c.parts[1]=p,c.parts[2]=d,c.parts[3]=h,0===c.parts[0]&&0===c.parts[1]&&0===c.parts[2]&&0===c.parts[3])u=!0;else for(s=3;s>=0;s--){var m=0,b=Me(c);if(c=b.quotient,m=b.rem.low)for(i=8;i>=0;i--)r[9*s+i]=m%10,m=Math.floor(m/10)}if(u)e=1,r[a]=0;else for(e=36;!r[a];)e-=1,a+=1;var w=e-1+g;if(w>=34||w<=-7||g>0){if(e>34)return l.push("".concat(0)),g>0?l.push("E+".concat(g)):g<0&&l.push("E".concat(g)),l.join("");for(l.push("".concat(r[a++])),(e-=1)&&l.push("."),n=0;n<e;n++)l.push("".concat(r[a++]));l.push("E"),w>0?l.push("+".concat(w)):l.push("".concat(w))}else if(g>=0)for(n=0;n<e;n++)l.push("".concat(r[a++]));else{var _=e+g;if(_>0)for(n=0;n<_;n++)l.push("".concat(r[a++]));else l.push("0");for(l.push(".");_++<0;)l.push("0");for(n=0;n<e-Math.max(_-1,0);n++)l.push("".concat(r[a++]))}return l.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(We.prototype,"_bsontype",{value:"Decimal128"});var Fe=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,r){var n=parseFloat(e.$numberDouble);return r&&r.relaxed?n:new t(n)},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(Fe.prototype,"_bsontype",{value:"Double"});var Ve=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,r){return r&&r.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(Ve.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 $e=new RegExp("^[0-9a-fA-F]{24}$"),Ke=null,ze=Symbol("id"),Je=function(){function t(e){if(!(this instanceof t))return new t(e);var r;if("object"==typeof e&&e&&"id"in e){if("string"!=typeof e.id&&!ArrayBuffer.isView(e.id))throw new ne("Argument passed in must have an id that is of type string or Buffer");r="toHexString"in e&&"function"==typeof e.toHexString?Xt.from(e.toHexString(),"hex"):e.id}else r=e;if(null==r||"number"==typeof r)this[ze]=t.generate("number"==typeof r?r:void 0);else if(ArrayBuffer.isView(r)&&12===r.byteLength)this[ze]=r instanceof Xt?r:fe(r);else{if("string"!=typeof r)throw new ne("Argument passed in does not match the accepted types");if(12===r.length){var n=Xt.from(r);if(12!==n.byteLength)throw new ne("Argument passed in must be a string of 12 bytes");this[ze]=n}else{if(24!==r.length||!$e.test(r))throw new ne("Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer");this[ze]=Xt.from(r,"hex")}}t.cacheHexString&&(this.__id=this.id.toString("hex"))}return Object.defineProperty(t.prototype,"id",{get:function(){return this[ze]},set:function(e){this[ze]=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 r=t.getInc(),n=Xt.alloc(12);return n.writeUInt32BE(e,0),null===Ke&&(Ke=ae(5)),n[4]=Ke[0],n[5]=Ke[1],n[6]=Ke[2],n[7]=Ke[3],n[8]=Ke[4],n[11]=255&r,n[10]=r>>8&255,n[9]=r>>16&255,n},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[ze][11]===e[ze][11]&&this[ze].equals(e[ze]);if("string"==typeof e&&t.isValid(e)&&12===e.length&&ue(this.id))return e===Xt.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 Xt.from(e).equals(this.id);if("object"==typeof e&&"toHexString"in e&&"function"==typeof e.toHexString){var r=e.toHexString(),n=this.toHexString().toLowerCase();return"string"==typeof r&&r.toLowerCase()===n}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 r=Xt.from([0,0,0,0,0,0,0,0,0,0,0,0]);return r.writeUInt32BE(e,0),new t(r)},t.createFromHexString=function(e){if(void 0===e||null!=e&&24!==e.length)throw new ne("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");return new t(Xt.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(Je.prototype,"generate",{value:le((function(t){return Je.generate(t)}),"Please use the static `ObjectId.generate(time)` instead")}),Object.defineProperty(Je.prototype,"getInc",{value:le((function(){return Je.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(Je.prototype,"get_inc",{value:le((function(){return Je.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(Je,"get_inc",{value:le((function(){return Je.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(Je.prototype,"_bsontype",{value:"ObjectID"});var Ye=function(){function t(e,r){if(!(this instanceof t))return new t(e,r);if(this.pattern=e,this.options=(null!=r?r:"").split("").sort().join(""),-1!==this.pattern.indexOf("\0"))throw new re("BSON Regex patterns cannot contain null bytes, found: ".concat(JSON.stringify(this.pattern)));if(-1!==this.options.indexOf("\0"))throw new re("BSON Regex options cannot contain null bytes, found: ".concat(JSON.stringify(this.options)));for(var n=0;n<this.options.length;n++)if("i"!==this.options[n]&&"m"!==this.options[n]&&"x"!==this.options[n]&&"l"!==this.options[n]&&"s"!==this.options[n]&&"u"!==this.options[n])throw new re("The regular expression option [".concat(this.options[n],"] 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 ne("Unexpected BSONRegExp EJSON object form: ".concat(JSON.stringify(e)))},t}();Object.defineProperty(Ye.prototype,"_bsontype",{value:"BSONRegExp"});var Qe=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(Qe.prototype,"_bsontype",{value:"Symbol"});var Ze=function(t){function e(r,n){var o=this;return o instanceof e?(o=Ae.isLong(r)?t.call(this,r.low,r.high,!0)||this:ce(r)&&void 0!==r.t&&void 0!==r.i?t.call(this,r.i,r.t,!0)||this:t.call(this,r,n,!0)||this,Object.defineProperty(o,"_bsontype",{value:"Timestamp",writable:!1,configurable:!1,enumerable:!1}),o):new e(r,n)}return ee(e,t),e.prototype.toJSON=function(){return{$timestamp:this.toString()}},e.fromInt=function(t){return new e(Ae.fromInt(t,!0))},e.fromNumber=function(t){return new e(Ae.fromNumber(t,!0))},e.fromBits=function(t,r){return new e(t,r)},e.fromString=function(t,r){return new e(Ae.fromString(t,!0,r))},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=Ae.MAX_UNSIGNED_VALUE,e}(Ae);var Xe=2147483647,tr=-2147483648,er=0x8000000000000000,rr=-0x8000000000000000,nr={$oid:Je,$binary:me,$uuid:me,$symbol:Qe,$numberInt:Ve,$numberDecimal:We,$numberDouble:Fe,$numberLong:Ae,$minKey:Ge,$maxKey:He,$regex:Ye,$regularExpression:Ye,$timestamp:Ze};function or(t,e){if(void 0===e&&(e={}),"number"==typeof t){if(e.relaxed||e.legacy)return t;if(Math.floor(t)===t){if(t>=tr&&t<=Xe)return new Ve(t);if(t>=rr&&t<=er)return Ae.fromNumber(t)}return new Fe(t)}if(null==t||"object"!=typeof t)return t;if(t.$undefined)return null;for(var r=Object.keys(t).filter((function(e){return e.startsWith("$")&&null!=t[e]})),n=0;n<r.length;n++){var o=nr[r[n]];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)):Ae.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=or(t.$scope)),we.fromExtendedJSON(t)}if(function(t){return ce(t)&&null!=t.$id&&"string"==typeof t.$ref&&(null==t.$db||"string"==typeof t.$db)}(t)||t.$dbPointer){var u=t.$ref?t:t.$dbPointer;if(u instanceof _e)return u;var c=Object.keys(u).filter((function(t){return t.startsWith("$")})),l=!0;if(c.forEach((function(t){-1===["$ref","$id","$db"].indexOf(t)&&(l=!1)})),l)return _e.fromExtendedJSON(u)}return t}function ir(t){var e=t.toISOString();return 0!==t.getUTCMilliseconds()?e:e.slice(0,-5)+"Z"}function sr(t,e){if(("object"==typeof t||"function"==typeof t)&&null!==t){var r=e.seenObjects.findIndex((function(e){return e.obj===t}));if(-1!==r){var n=e.seenObjects.map((function(t){return t.propertyName})),o=n.slice(0,r).map((function(t){return"".concat(t," -> ")})).join(""),i=n[r],s=" -> "+n.slice(r+1,n.length-1).map((function(t){return"".concat(t," -> ")})).join(""),a=n[n.length-1],u=" ".repeat(o.length+i.length/2),c="-".repeat(s.length+(i.length+a.length)/2-1);throw new ne("Converting circular structure to EJSON:\n"+" ".concat(o).concat(i).concat(s).concat(a,"\n")+" ".concat(u,"\\").concat(c,"/"))}e.seenObjects[e.seenObjects.length-1].obj=t}if(Array.isArray(t))return function(t,e){return t.map((function(t,r){e.seenObjects.push({propertyName:"index ".concat(r),obj:null});try{return sr(t,e)}finally{e.seenObjects.pop()}}))}(t,e);if(void 0===t)return null;if(t instanceof Date||ce(h=t)&&"[object Date]"===Object.prototype.toString.call(h)){var l=t.getTime(),f=l>-1&&l<2534023188e5;return e.legacy?e.relaxed&&f?{$date:t.getTime()}:{$date:ir(t)}:e.relaxed&&f?{$date:ir(t)}:{$date:{$numberLong:t.getTime().toString()}}}var h;if(!("number"!=typeof t||e.relaxed&&isFinite(t))){if(Math.floor(t)===t){var d=t>=rr&&t<=er;if(t>=tr&&t<=Xe)return{$numberInt:t.toString()};if(d)return{$numberLong:t.toString()}}return{$numberDouble:t.toString()}}if(t instanceof RegExp||function(t){return"[object RegExp]"===Object.prototype.toString.call(t)}(t)){var p=t.flags;if(void 0===p){var y=t.toString().match(/[gimuy]*$/);y&&(p=y[0])}return new Ye(t.source,p).toExtendedJSON(e)}return null!=t&&"object"==typeof t?function(t,e){if(null==t||"object"!=typeof t)throw new re("not an object instance");var r=t._bsontype;if(void 0===r){var n={};for(var o in t){e.seenObjects.push({propertyName:o,obj:null});try{var i=sr(t[o],e);"__proto__"===o?Object.defineProperty(n,o,{value:i,writable:!0,enumerable:!0,configurable:!0}):n[o]=i}finally{e.seenObjects.pop()}}return n}if(function(t){return ce(t)&&Reflect.has(t,"_bsontype")&&"string"==typeof t._bsontype}(t)){var s=t;if("function"!=typeof s.toExtendedJSON){var a=ur[t._bsontype];if(!a)throw new ne("Unrecognized or invalid _bsontype: "+t._bsontype);s=a(s)}return"Code"===r&&s.scope?s=new we(s.code,sr(s.scope,e)):"DBRef"===r&&s.oid&&(s=new _e(sr(s.collection,e),sr(s.oid,e),sr(s.db,e),sr(s.fields,e))),s.toExtendedJSON(e)}throw new re("_bsontype must be a string, but was: "+typeof r)}(t,e):t}var ar,ur={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 _e(t.collection||t.namespace,t.oid,t.db,t.fields)},Decimal128:function(t){return new We(t.bytes)},Double:function(t){return new Fe(t.value)},Int32:function(t){return new Ve(t.value)},Long:function(t){return Ae.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 Je(t)},ObjectId:function(t){return new Je(t)},BSONRegExp:function(t){return new Ye(t.pattern,t.options)},Symbol:function(t){return new Qe(t.value)},Timestamp:function(t){return Ze.fromBits(t.low,t.high)}};!function(t){function e(t,e){var r=Object.assign({},{relaxed:!0,legacy:!1},e);return"boolean"==typeof r.relaxed&&(r.strict=!r.relaxed),"boolean"==typeof r.strict&&(r.relaxed=!r.strict),JSON.parse(t,(function(t,e){if(-1!==t.indexOf("\0"))throw new re("BSON Document field names cannot contain null bytes, found: ".concat(JSON.stringify(t)));return or(e,r)}))}function r(t,e,r,n){null!=r&&"object"==typeof r&&(n=r,r=0),null==e||"object"!=typeof e||Array.isArray(e)||(n=e,e=void 0,r=0);var o=sr(t,Object.assign({relaxed:!0,legacy:!1},n,{seenObjects:[{propertyName:"(root)",obj:null}]}));return JSON.stringify(o,e,r)}t.parse=e,t.stringify=r,t.serialize=function(t,e){return e=e||{},JSON.parse(r(t,e))},t.deserialize=function(t,r){return r=r||{},e(JSON.stringify(t),r)}}(ar||(ar={}));var cr=ie();cr.Map?cr.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 r=t[e],n=r[0],o=r[1];this._keys.push(n),this._values[n]={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 r=t._keys[e++];return{value:void 0!==r?[r,t._values[r].v]:void 0,done:void 0===r}}}},t.prototype.forEach=function(t,e){e=e||this;for(var r=0;r<this._keys.length;r++){var n=this._keys[r];t.call(e,this._values[n].v,n,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 r=t._keys[e++];return{value:void 0!==r?r:void 0,done:void 0===r}}}},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 r=t._keys[e++];return{value:void 0!==r?t._values[r].v:void 0,done:void 0===r}}}},Object.defineProperty(t.prototype,"size",{get:function(){return this._keys.length},enumerable:!1,configurable:!0})}(),Ae.fromNumber(ve),Ae.fromNumber(ge),new Set(["$db","$ref","$id","$clusterTime"]);var lr=new Uint8Array(8);new DataView(lr.buffer,lr.byteOffset,lr.byteLength);Xt.alloc(17825792);var fr=function(){function t(t,e){this._stages=[],t&&e&&(this._db=t,this._request=new jr.reqClass(this._db.config),this._collectionName=e)}return t.prototype.end=function(){return t=this,e=void 0,n=function(){var t;return function(t,e){var r,n,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(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=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(ar.parse)}]:[2,t]}}))},new((r=void 0)||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}));var t,e,r,n},t.prototype.unwrap=function(){return this._stages},t.prototype.done=function(){return this._stages.map((function(t){var e,r=t.stageKey,n=t.stageValue;return(e={})[r]=JSON.parse(n),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}(),hr=fr,dr=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},t(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),pr=function(t){function e(e,r){return t.call(this,e,r)||this}return dr(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 kt(this._db,this._coll,t)},e.prototype.add=function(t,e){return new kt(this._db,this._coll,void 0).create(t,e)},e.prototype.aggregate=function(){return new hr(this._db,this._coll)},e}(Bt),yr={eq:function(t){return new dt(ft.EQ,[t])},neq:function(t){return new dt(ft.NEQ,[t])},lt:function(t){return new dt(ft.LT,[t])},lte:function(t){return new dt(ft.LTE,[t])},gt:function(t){return new dt(ft.GT,[t])},gte:function(t){return new dt(ft.GTE,[t])},in:function(t){return new dt(ft.IN,t)},nin:function(t){return new dt(ft.NIN,t)},all:function(t){return new dt(ft.ALL,t)},elemMatch:function(t){return new dt(ft.ELEM_MATCH,[t])},exists:function(t){return new dt(ft.EXISTS,[t])},size:function(t){return new dt(ft.SIZE,[t])},mod:function(t){return new dt(ft.MOD,[t])},geoNear:function(t){return new dt(ft.GEO_NEAR,[t])},geoWithin:function(t){return new dt(ft.GEO_WITHIN,[t])},geoIntersects:function(t){return new dt(ft.GEO_INTERSECTS,[t])},and:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=B(arguments[0])?arguments[0]:Array.from(arguments);return new ct(st.AND,r)},nor:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=B(arguments[0])?arguments[0]:Array.from(arguments);return new ct(st.NOR,r)},or:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=B(arguments[0])?arguments[0]:Array.from(arguments);return new ct(st.OR,r)},not:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=B(arguments[0])?arguments[0]:Array.from(arguments);return new ct(st.NOT,r)},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=[],r=0;r<arguments.length;r++)e[r]=arguments[r];if(q(e[0])&&e[0].hasOwnProperty("each")){var n=e[0];t={$each:n.each,$position:n.position,$sort:n.sort,$slice:n.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 r=B(arguments[0])?arguments[0]:Array.from(arguments);return new at(tt.UNSHIFT,r)},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 hr},abs:function(t){return new vr("abs",t)},add:function(t){return new vr("add",t)},ceil:function(t){return new vr("ceil",t)},divide:function(t){return new vr("divide",t)},exp:function(t){return new vr("exp",t)},floor:function(t){return new vr("floor",t)},ln:function(t){return new vr("ln",t)},log:function(t){return new vr("log",t)},log10:function(t){return new vr("log10",t)},mod:function(t){return new vr("mod",t)},multiply:function(t){return new vr("multiply",t)},pow:function(t){return new vr("pow",t)},sqrt:function(t){return new vr("sqrt",t)},subtract:function(t){return new vr("subtract",t)},trunc:function(t){return new vr("trunc",t)},arrayElemAt:function(t){return new vr("arrayElemAt",t)},arrayToObject:function(t){return new vr("arrayToObject",t)},concatArrays:function(t){return new vr("concatArrays",t)},filter:function(t){return new vr("filter",t)},in:function(t){return new vr("in",t)},indexOfArray:function(t){return new vr("indexOfArray",t)},isArray:function(t){return new vr("isArray",t)},map:function(t){return new vr("map",t)},range:function(t){return new vr("range",t)},reduce:function(t){return new vr("reduce",t)},reverseArray:function(t){return new vr("reverseArray",t)},size:function(t){return new vr("size",t)},slice:function(t){return new vr("slice",t)},zip:function(t){return new vr("zip",t)},and:function(t){return new vr("and",t)},not:function(t){return new vr("not",t)},or:function(t){return new vr("or",t)},cmp:function(t){return new vr("cmp",t)},eq:function(t){return new vr("eq",t)},gt:function(t){return new vr("gt",t)},gte:function(t){return new vr("gte",t)},lt:function(t){return new vr("lt",t)},lte:function(t){return new vr("lte",t)},neq:function(t){return new vr("ne",t)},cond:function(t){return new vr("cond",t)},ifNull:function(t){return new vr("ifNull",t)},switch:function(t){return new vr("switch",t)},dateFromParts:function(t){return new vr("dateFromParts",t)},dateFromString:function(t){return new vr("dateFromString",t)},dayOfMonth:function(t){return new vr("dayOfMonth",t)},dayOfWeek:function(t){return new vr("dayOfWeek",t)},dayOfYear:function(t){return new vr("dayOfYear",t)},isoDayOfWeek:function(t){return new vr("isoDayOfWeek",t)},isoWeek:function(t){return new vr("isoWeek",t)},isoWeekYear:function(t){return new vr("isoWeekYear",t)},millisecond:function(t){return new vr("millisecond",t)},minute:function(t){return new vr("minute",t)},month:function(t){return new vr("month",t)},second:function(t){return new vr("second",t)},hour:function(t){return new vr("hour",t)},week:function(t){return new vr("week",t)},year:function(t){return new vr("year",t)},literal:function(t){return new vr("literal",t)},mergeObjects:function(t){return new vr("mergeObjects",t)},objectToArray:function(t){return new vr("objectToArray",t)},allElementsTrue:function(t){return new vr("allElementsTrue",t)},anyElementTrue:function(t){return new vr("anyElementTrue",t)},setDifference:function(t){return new vr("setDifference",t)},setEquals:function(t){return new vr("setEquals",t)},setIntersection:function(t){return new vr("setIntersection",t)},setIsSubset:function(t){return new vr("setIsSubset",t)},setUnion:function(t){return new vr("setUnion",t)},concat:function(t){return new vr("concat",t)},dateToString:function(t){return new vr("dateToString",t)},indexOfBytes:function(t){return new vr("indexOfBytes",t)},indexOfCP:function(t){return new vr("indexOfCP",t)},split:function(t){return new vr("split",t)},strLenBytes:function(t){return new vr("strLenBytes",t)},strLenCP:function(t){return new vr("strLenCP",t)},strcasecmp:function(t){return new vr("strcasecmp",t)},substr:function(t){return new vr("substr",t)},substrBytes:function(t){return new vr("substrBytes",t)},substrCP:function(t){return new vr("substrCP",t)},toLower:function(t){return new vr("toLower",t)},toUpper:function(t){return new vr("toUpper",t)},meta:function(t){return new vr("meta",t)},addToSet:function(t){return new vr("addToSet",t)},avg:function(t){return new vr("avg",t)},first:function(t){return new vr("first",t)},last:function(t){return new vr("last",t)},max:function(t){return new vr("max",t)},min:function(t){return new vr("min",t)},push:function(t){return new vr("push",t)},stdDevPop:function(t){return new vr("stdDevPop",t)},stdDevSamp:function(t){return new vr("stdDevSamp",t)},sum:function(t){return new vr("sum",t)},let:function(t){return new vr("let",t)}},project:{slice:function(t){return new gr("slice",t)},elemMatch:function(t){return new gr("elemMatch",t)}}},vr=function(t,e){this["$"+t]=e},gr=function(t,e){this["$"+t]=e},mr=function(){function t(t){var e=t.regexp,r=t.options;if(!e)throw new TypeError("regexp must be a string");this.$regex=e,this.$options=r}return t.prototype.parse=function(){return{$regex:this.$regex,$options:this.$options}},Object.defineProperty(t.prototype,"_internalType",{get:function(){return k},enumerable:!0,configurable:!0}),t}();function br(t){return new mr(t)}var wr="insert document failed",_r="DATABASE_TRANSACTION_CONFLICT",Sr=function(){return Sr=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Sr.apply(this,arguments)},Er=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},Ir=function(t,e){var r,n,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(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},Or="database.updateDocInTransaction",Tr=function(){function t(t,e,r){this._coll=e,this.id=r,this._transaction=t,this._request=this._transaction.getRequestMethod(),this._transactionId=this._transaction.getTransactionId()}return t.prototype.create=function(t){return Er(this,void 0,void 0,(function(){var e,r,n,o;return Ir(this,(function(i){switch(i.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,data:ar.stringify(St(t),{relaxed:!1})},this.id&&(e._id=this.id),[4,this._request.send("database.insertDocInTransaction",e)];case 1:if((r=i.sent()).code)throw r;if(n=ar.parse(r.inserted),1==(o=ar.parse(r.ok))&&1==n)return[2,Sr(Sr({},r),{ok:o,inserted:n})];throw new Error(wr)}}))}))},t.prototype.get=function(){return Er(this,void 0,void 0,(function(){var t,e;return Ir(this,(function(r){switch(r.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=r.sent()).code)throw e;return[2,{data:"null"!==e.data?rt.formatField(ar.parse(e.data)):ar.parse(e.data),requestId:e.requestId}]}}))}))},t.prototype.set=function(t){return Er(this,void 0,void 0,(function(){var e,r;return Ir(this,(function(n){switch(n.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:ar.stringify(St(t),{relaxed:!1}),upsert:!0},[4,this._request.send(Or,e)];case 1:if((r=n.sent()).code)throw r;return[2,Sr(Sr({},r),{updated:ar.parse(r.updated),upserted:r.upserted?JSON.parse(r.upserted):null})]}}))}))},t.prototype.update=function(t){return Er(this,void 0,void 0,(function(){var e,r;return Ir(this,(function(n){switch(n.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:ar.stringify(Nt.encode(t),{relaxed:!1})},[4,this._request.send(Or,e)];case 1:if((r=n.sent()).code)throw r;return[2,Sr(Sr({},r),{updated:ar.parse(r.updated)})]}}))}))},t.prototype.delete=function(){return Er(this,void 0,void 0,(function(){var t,e;return Ir(this,(function(r){switch(r.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=r.sent()).code)throw e;return[2,Sr(Sr({},e),{deleted:ar.parse(e.deleted)})]}}))}))},t}(),Rr=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},t(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),Ar=function(t){function e(e,r){return t.call(this,e,r)||this}return Rr(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 Tr(this._transaction,this._coll,t)},e.prototype.add=function(t){var e;return void 0!==t._id&&(e=t._id),new Tr(this._transaction,this._coll,e).create(t)},e}((function(t,e){this._coll=e,this._transaction=t})),Pr=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},xr=function(t,e){var r,n,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(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},Cr=function(){function t(t){this._db=t,this._request=new jr.reqClass(this._db.config),this.aborted=!1,this.commited=!1,this.inited=!1}return t.prototype.init=function(){return Pr(this,void 0,void 0,(function(){var t;return xr(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 Ar(this,t)},t.prototype.getTransactionId=function(){return this._id},t.prototype.getRequestMethod=function(){return this._request},t.prototype.commit=function(){return Pr(this,void 0,void 0,(function(){var t,e;return xr(this,(function(r){switch(r.label){case 0:return t={transactionId:this._id},[4,this._request.send("database.commitTransaction",t)];case 1:if((e=r.sent()).code)throw e;return this.commited=!0,[2,e]}}))}))},t.prototype.rollback=function(t){return Pr(this,void 0,void 0,(function(){var e,r;return xr(this,(function(n){switch(n.label){case 0:return e={transactionId:this._id},[4,this._request.send("database.abortTransaction",e)];case 1:if((r=n.sent()).code)throw r;return this.aborted=!0,this.abortReason=t,[2,r]}}))}))},t}();function Nr(){return Pr(this,void 0,void 0,(function(){var t;return xr(this,(function(e){switch(e.label){case 0:return[4,(t=new Cr(this)).init()];case 1:return e.sent(),[2,t]}}))}))}function Lr(t,e){return void 0===e&&(e=3),Pr(this,void 0,void 0,(function(){var r,n,o,i,s=this;return xr(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,10]),[4,(r=new Cr(this)).init()];case 1:return a.sent(),[4,t(r)];case 2:if(n=a.sent(),!0===r.aborted)throw r.abortReason;return[4,r.commit()];case 3:return a.sent(),[2,n];case 4:if(o=a.sent(),!1===r.inited)throw o;return i=function(t){return Pr(s,void 0,void 0,(function(){return xr(this,(function(e){switch(e.label){case 0:if(r.aborted||r.commited)return[3,5];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,r.rollback()];case 2:case 3:return e.sent(),[3,4];case 4:throw t;case 5:if(!0===r.aborted)throw r.abortReason;throw t}}))}))},e<=0?[4,i(o)]:[3,6];case 5:a.sent(),a.label=6;case 6:return o&&o.code===_r?[4,Lr.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 jr=function(){function t(t){this.config=t,this.Geo=i,this.serverDate=X,this.command=yr,this.RegExp=br,this.startTransaction=Nr,this.runTransaction=Lr,this.logicCommand=ct,this.updateCommand=at,this.queryCommand=dt}return t.prototype.collection=function(t){if(!t)throw new Error("Collection name is required");return new pr(this,t)},t.prototype.createCollection=function(e){var r={collectionName:e};return new t.reqClass(this.config).send("database.addCollection",r)},t}(),Ur=function(){return Ur=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Ur.apply(this,arguments)},kr={name:"database",entity:{database:function(t){var e=this.platform,r=e.adapter,n=e.runtime;return jr.reqClass=this.request.constructor,jr.getAccessToken=this.authInstance?this.authInstance.getAccessToken.bind(this.authInstance):function(){return""},jr.runtime=n,this.wsClientClass&&(jr.wsClass=r.wsClass,jr.wsClientClass=this.wsClientClass),jr.ws||(jr.ws=null),new jr(Ur(Ur(Ur({},this.config),{_fromApp:this}),t))}}};try{cloudbase.registerComponent(kr)}catch(t){}function Dr(t){try{t.registerComponent(kr)}catch(t){console.warn(t)}}},7596:function(t,e,r){"use strict";r.r(e),r.d(e,{registerCloudrun:function(){return h},requestContainer:function(){return c}});var n=r(3616),o=function(){return o=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},o.apply(this,arguments)},i=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},s=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},a=n._G.Sg,u="cloudrun";function c(t){return i(this,void 0,void 0,(function(){var e,r,n,o,i,a,u,c,l;return s(this,(function(s){switch(s.label){case 0:return e=t.name,r=t.data,n=t.path,o=void 0===n?"":n,i=t.method,a=t.header,u=void 0===a?{}:a,c="https://".concat(this.config.env,".api.tcloudbasegateway.com/v1/cloudrun/").concat(e),l=o.startsWith("/")?o:"/".concat(o),[4,this.request.fetch({method:i||"POST",headers:Object.assign({},{"Content-Type":"application/json; charset=utf-8"},u),body:r,url:"".concat(c).concat(l)})];case 1:return[4,s.sent().data];case 2:return[2,s.sent()]}}))}))}var l=new(function(){function t(){}return t.prototype.callContainer=function(t){return i(this,void 0,void 0,(function(){var e,r,n;return s(this,(function(i){switch(i.label){case 0:if(e=t.name,r=t.data,!e)throw new Error(JSON.stringify({code:a.INVALID_PARAMS,msg:"[".concat(u,".callContainer] invalid name")}));try{n=r?JSON.stringify(r):""}catch(t){throw new Error(JSON.stringify({code:a.INVALID_PARAMS,msg:"[".concat(u,".callContainer] invalid data")}))}return[4,c.call(this,o(o({},t),{data:n}))];case 1:return[2,i.sent()]}}))}))},t}()),f={name:u,entity:{callContainer:l.callContainer}};try{cloudbase.registerComponent(f)}catch(t){}function h(t){try{t.registerComponent(f)}catch(t){console.warn(t)}}},2363:function(t,e,r){"use strict";r.r(e),r.d(e,{registerFunctions:function(){return y}});var n=r(3616),o=r(7596),i=function(){return i=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},i.apply(this,arguments)},s=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},a=n._G.eX,u=n._G.Sg,c=n._G.vM,l=n.P6.execCallback,f=n.BM.D,h="functions",d=new(function(){function t(){}return t.prototype.callFunction=function(t,e){var r,s,c,f,d,p;return c=this,f=void 0,p=function(){var c,f,d,p,y,v,g,m,b,w,_,S,E,I,O,T,R,A,P;return function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}(this,(function(x){switch(x.label){case 0:if(c=t.name,f=t.data,d=t.query,p=t.parse,y=t.search,v=t.type,g=t.path,m=void 0===g?"":g,b=t.method,w=t.header,_=void 0===w?{}:w,!c)throw new Error(JSON.stringify({code:u.INVALID_PARAMS,msg:"[".concat(h,".callFunction] invalid function name")}));try{S=f?JSON.stringify(f):""}catch(t){throw new Error(JSON.stringify({code:u.INVALID_PARAMS,msg:"[".concat(h,".callFunction] invalid data")}))}return"cloudrun"!==v?[3,2]:(E=n.P6.generateRequestId(),[4,o.requestContainer.call(this,{name:c,data:S,path:m,method:b,header:i(i({},_),{"X-Request-Id":E})})]);case 1:return[2,{result:A=x.sent(),requestId:E}];case 2:I="functions.invokeFunction",O={inQuery:d,parse:p,search:y,function_name:c,request_data:S},T=this.request,x.label=3;case 3:return x.trys.push([3,5,,6]),[4,T.send(I,O,{defaultQuery:(null===(r=null==f?void 0:f.params)||void 0===r?void 0:r.action)?{action:null===(s=null==f?void 0:f.params)||void 0===s?void 0:s.action}:{}})];case 4:if((R=x.sent()).code)return[2,l(e,null,R)];if(A=R.data.response_data,p)return[2,l(e,null,{result:A,requestId:R.requestId})];try{return A=JSON.parse(R.data.response_data),[2,l(e,null,{result:A,requestId:R.requestId})]}catch(t){l(e,new Error("[".concat(a(),"][").concat(u.INVALID_PARAMS,"][").concat(h,".callFunction] response data must be json")))}return[3,6];case 5:return P=x.sent(),l(e,P),[3,6];case 6:return[2]}}))},new((d=void 0)||(d=Promise))((function(t,e){function r(t){try{o(p.next(t))}catch(t){e(t)}}function n(t){try{o(p.throw(t))}catch(t){e(t)}}function o(e){var o;e.done?t(e.value):(o=e.value,o instanceof d?o:new d((function(t){t(o)}))).then(r,n)}o((p=p.apply(c,f||[])).next())}))},function(t,e,r,n){var o,i=arguments.length,s=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);i>3&&s&&Object.defineProperty(e,r,s)}([f({customInfo:{className:"Cloudbase",methodName:"callFunction"},title:"函数调用失败",messages:["请确认以下各项:"," 1 - 调用 callFunction() 的语法或参数是否正确"," 2 - 当前环境下是否存在此函数"," 3 - 函数安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(c)]}),s("design:type",Function),s("design:paramtypes",[Object,Function]),s("design:returntype",Promise)],t.prototype,"callFunction",null),t}()),p={name:h,entity:{callFunction:d.callFunction}};try{cloudbase.registerComponent(p)}catch(t){}function y(t){try{t.registerComponent(p)}catch(t){console.warn(t)}}},9679:function(t,e,r){"use strict";r.r(e),r.d(e,{lazyGetEntity:function(){return d},registerModel:function(){return g}});var n=r(5304),o=r(3616),i={};for(var s in n)["default","lazyGetEntity","registerModel"].indexOf(s)<0&&(i[s]=function(t){return n[t]}.bind(0,s));r.d(e,i);var a=function(){return a=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},a.apply(this,arguments)},u=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},c=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},l=o.U3.yE,f="models",h=new WeakMap;function d(t){return new Proxy({},{get:function(e,r){var o=h.get(t);return o||(o=function(t){var e=this,r=t.callFunction.bind(t),o=t.request.fetch.bind(t.request),i=t.getEndPointWithKey("GATEWAY"),s=i.BASE_URL,l=i.PROTOCOL,f="".concat(l).concat(s,"/model"),h="".concat(l).concat(s,"/sql"),d=(0,n.generateHTTPClient)(r,(function(t){return u(e,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,o(a(a({},t),{headers:a({"Content-Type":"application/json"},t.headers)}))];case 1:return[4,e.sent().data];case 2:return[2,e.sent()]}}))}))}),f,{sqlBaseUrl:h});return d}(t),h.set(t,o)),o[r]}})}var p="cloudbase_init",y=new l;y.on(p,(function(t){var e=t.data;Object.assign(e,{models:d(e)})}));var v={name:f,namespace:f,entity:new Proxy({},{get:function(t,e){console.warn("【deprecated】Accessing Cloudbase.prototype.models.".concat(e,"."))}}),injectEvents:{bus:y,events:[p]}};try{cloudbase.registerComponent(v)}catch(t){}function g(t){try{t.registerComponent(v)}catch(t){console.warn(t)}}},7171:function(t,e,r){"use strict";var n;if(r.r(e),r.d(e,{getEncryptInfo:function(){return M}}),!globalThis.IS_MP_BUILD){var o="undefined"!=typeof globalThis?globalThis.navigator:window.globalThis,i="0123456789abcdefghijklmnopqrstuvwxyz";function B(t){return i.charAt(t)}function W(t,e){return t&e}function F(t,e){return t|e}function V(t,e){return t^e}function H(t,e){return t&~e}function G(t){if(0==t)return-1;var e=0;return 65535&t||(t>>=16,e+=16),255&t||(t>>=8,e+=8),15&t||(t>>=4,e+=4),3&t||(t>>=2,e+=2),1&t||++e,e}function $(t){for(var e=0;0!=t;)t&=t-1,++e;return e}var s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function K(t){var e,r,n="";for(e=0;e+3<=t.length;e+=3)r=parseInt(t.substring(e,e+3),16),n+=s.charAt(r>>6)+s.charAt(63&r);for(e+1==t.length?(r=parseInt(t.substring(e,e+1),16),n+=s.charAt(r<<2)):e+2==t.length&&(r=parseInt(t.substring(e,e+2),16),n+=s.charAt(r>>2)+s.charAt((3&r)<<4));(3&n.length)>0;)n+="=";return n}function z(t){var e,r="",n=0,o=0;for(e=0;e<t.length&&"="!=t.charAt(e);++e){var i=s.indexOf(t.charAt(e));i<0||(0==n?(r+=B(i>>2),o=3&i,n=1):1==n?(r+=B(o<<2|i>>4),o=15&i,n=2):2==n?(r+=B(o),r+=B(i>>2),o=3&i,n=3):(r+=B(o<<2|i>>4),r+=B(15&i),n=0))}return 1==n&&(r+=B(o<<2)),r}var a,u,c={decode:function(t){var e;if(void 0===a){var r="0123456789ABCDEF";for(a={},e=0;e<16;++e)a[r.charAt(e)]=e;for(r=r.toLowerCase(),e=10;e<16;++e)a[r.charAt(e)]=e;for(e=0;e<8;++e)a[" \f\n\r\t \u2028\u2029".charAt(e)]=-1}var n=[],o=0,i=0;for(e=0;e<t.length;++e){var s=t.charAt(e);if("="==s)break;if(-1!=(s=a[s])){if(void 0===s)throw new Error("Illegal character at offset "+e);o|=s,++i>=2?(n[n.length]=o,o=0,i=0):o<<=4}}if(i)throw new Error("Hex encoding incomplete: 4 bits missing");return n}},l={decode:function(t){var e;if(void 0===u){for(u=Object.create(null),e=0;e<64;++e)u["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e)]=e;for(e=0;e<9;++e)u["= \f\n\r\t \u2028\u2029".charAt(e)]=-1}var r=[],n=0,o=0;for(e=0;e<t.length;++e){var i=t.charAt(e);if("="==i)break;if(-1!=(i=u[i])){if(void 0===i)throw new Error("Illegal character at offset "+e);n|=i,++o>=4?(r[r.length]=n>>16,r[r.length]=n>>8&255,r[r.length]=255&n,n=0,o=0):n<<=6}}switch(o){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:r[r.length]=n>>10;break;case 3:r[r.length]=n>>16,r[r.length]=n>>8&255}return r},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(t){var e=l.re.exec(t);if(e)if(e[1])t=e[1];else{if(!e[2])throw new Error("RegExp out of sync");t=e[2]}return l.decode(t)}},f=1e13;class J{constructor(t){this.buf=[+t||0]}mulAdd(t,e){var r,n,o=this.buf,i=o.length;for(r=0;r<i;++r)(n=o[r]*t+e)<f?e=0:n-=(e=0|n/f)*f,o[r]=n;e>0&&(o[r]=e)}sub(t){var e,r,n=this.buf,o=n.length;for(e=0;e<o;++e)(r=n[e]-t)<0?(r+=f,t=1):t=0,n[e]=r;for(;0===n[n.length-1];)n.pop()}toString(t){if(10!=(t||10))throw new Error("only base 10 is supported");for(var e=this.buf,r=e[e.length-1].toString(),n=e.length-2;n>=0;--n)r+=(f+e[n]).toString().substring(1);return r}valueOf(){for(var t=this.buf,e=0,r=t.length-1;r>=0;--r)e=e*f+t[r];return e}simplify(){var t=this.buf;return 1==t.length?t[0]:this}}var h,d=/^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/,p=/^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;function Y(t,e){return t.length>e&&(t=t.substring(0,e)+"…"),t}class Q{constructor(t,e){this.hexDigits="0123456789ABCDEF",t instanceof Q?(this.enc=t.enc,this.pos=t.pos):(this.enc=t,this.pos=e)}get(t){if(void 0===t&&(t=this.pos++),t>=this.enc.length)throw new Error("Requesting byte offset "+t+" on a stream of length "+this.enc.length);return"string"==typeof this.enc?this.enc.charCodeAt(t):this.enc[t]}hexByte(t){return this.hexDigits.charAt(t>>4&15)+this.hexDigits.charAt(15&t)}hexDump(t,e,r){for(var n="",o=t;o<e;++o)if(n+=this.hexByte(this.get(o)),!0!==r)switch(15&o){case 7:n+=" ";break;case 15:n+="\n";break;default:n+=" "}return n}isASCII(t,e){for(var r=t;r<e;++r){var n=this.get(r);if(n<32||n>176)return!1}return!0}parseStringISO(t,e){for(var r="",n=t;n<e;++n)r+=String.fromCharCode(this.get(n));return r}parseStringUTF(t,e){for(var r="",n=t;n<e;){var o=this.get(n++);r+=o<128?String.fromCharCode(o):o>191&&o<224?String.fromCharCode((31&o)<<6|63&this.get(n++)):String.fromCharCode((15&o)<<12|(63&this.get(n++))<<6|63&this.get(n++))}return r}parseStringBMP(t,e){for(var r,n,o="",i=t;i<e;)r=this.get(i++),n=this.get(i++),o+=String.fromCharCode(r<<8|n);return o}parseTime(t,e,r){var n=this.parseStringISO(t,e),o=(r?d:p).exec(n);return o?(r&&(o[1]=+o[1],o[1]+=+o[1]<70?2e3:1900),n=o[1]+"-"+o[2]+"-"+o[3]+" "+o[4],o[5]&&(n+=":"+o[5],o[6]&&(n+=":"+o[6],o[7]&&(n+="."+o[7]))),o[8]&&(n+=" UTC","Z"!=o[8]&&(n+=o[8],o[9]&&(n+=":"+o[9]))),n):"Unrecognized time: "+n}parseInteger(t,e){for(var r,n=this.get(t),o=n>127,i=o?255:0,s="";n==i&&++t<e;)n=this.get(t);if(0==(r=e-t))return o?-1:0;if(r>4){for(s=n,r<<=3;!(128&(+s^i));)s=+s<<1,--r;s="("+r+" bit)\n"}o&&(n-=256);for(var a=new J(n),u=t+1;u<e;++u)a.mulAdd(256,this.get(u));return s+a.toString()}parseBitString(t,e,r){for(var n=this.get(t),o="("+((e-t-1<<3)-n)+" bit)\n",i="",s=t+1;s<e;++s){for(var a=this.get(s),u=s==e-1?n:0,c=7;c>=u;--c)i+=a>>c&1?"1":"0";if(i.length>r)return o+Y(i,r)}return o+i}parseOctetString(t,e,r){if(this.isASCII(t,e))return Y(this.parseStringISO(t,e),r);var n=e-t,o="("+n+" byte)\n";n>(r/=2)&&(e=t+r);for(var i=t;i<e;++i)o+=this.hexByte(this.get(i));return n>r&&(o+="…"),o}parseOID(t,e,r){for(var n="",o=new J,i=0,s=t;s<e;++s){var a=this.get(s);if(o.mulAdd(128,127&a),i+=7,!(128&a)){if(""===n)if((o=o.simplify())instanceof J)o.sub(80),n="2."+o.toString();else{var u=o<80?o<40?0:1:2;n=u+"."+(o-40*u)}else n+="."+o.toString();if(n.length>r)return Y(n,r);o=new J,i=0}}return i>0&&(n+=".incomplete"),n}}class Z{constructor(t,e,r,n,o){if(!(n instanceof X))throw new Error("Invalid tag value.");this.stream=t,this.header=e,this.length=r,this.tag=n,this.sub=o}typeName(){switch(this.tag.tagClass){case 0:switch(this.tag.tagNumber){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER";case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString";case 30:return"BMPString"}return"Universal_"+this.tag.tagNumber.toString();case 1:return"Application_"+this.tag.tagNumber.toString();case 2:return"["+this.tag.tagNumber.toString()+"]";case 3:return"Private_"+this.tag.tagNumber.toString()}}content(t){if(void 0===this.tag)return null;void 0===t&&(t=1/0);var e=this.posContent(),r=Math.abs(this.length);if(!this.tag.isUniversal())return null!==this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+r,t);switch(this.tag.tagNumber){case 1:return 0===this.stream.get(e)?"false":"true";case 2:return this.stream.parseInteger(e,e+r);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(e,e+r,t);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+r,t);case 6:return this.stream.parseOID(e,e+r,t);case 16:case 17:return null!==this.sub?"("+this.sub.length+" elem)":"(no elem)";case 12:return Y(this.stream.parseStringUTF(e,e+r),t);case 18:case 19:case 20:case 21:case 22:case 26:return Y(this.stream.parseStringISO(e,e+r),t);case 30:return Y(this.stream.parseStringBMP(e,e+r),t);case 23:case 24:return this.stream.parseTime(e,e+r,23==this.tag.tagNumber)}return null}toString(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(null===this.sub?"null":this.sub.length)+"]"}toPrettyString(t){void 0===t&&(t="");var e=t+this.typeName()+" @"+this.stream.pos;if(this.length>=0&&(e+="+"),e+=this.length,this.tag.tagConstructed?e+=" (constructed)":!this.tag.isUniversal()||3!=this.tag.tagNumber&&4!=this.tag.tagNumber||null===this.sub||(e+=" (encapsulates)"),e+="\n",null!==this.sub){t+=" ";for(var r=0,n=this.sub.length;r<n;++r)e+=this.sub[r].toPrettyString(t)}return e}posStart(){return this.stream.pos}posContent(){return this.stream.pos+this.header}posEnd(){return this.stream.pos+this.header+Math.abs(this.length)}toHexString(){return this.stream.hexDump(this.posStart(),this.posEnd(),!0)}static decodeLength(t){var e=t.get(),r=127&e;if(r==e)return r;if(r>6)throw new Error("Length over 48 bits not supported at position "+(t.pos-1));if(0===r)return null;e=0;for(var n=0;n<r;++n)e=256*e+t.get();return e}getHexStringValue(){var t=this.toHexString(),e=2*this.header,r=2*this.length;return t.substr(e,r)}static decode(t){var e;e=t instanceof Q?t:new Q(t,0);var r=new Q(e),n=new X(e),o=Z.decodeLength(e),i=e.pos,s=i-r.pos,a=null,u=function(){var t=[];if(null!==o){for(var r=i+o;e.pos<r;)t[t.length]=Z.decode(e);if(e.pos!=r)throw new Error("Content size is not correct for container starting at offset "+i)}else try{for(;;){var n=Z.decode(e);if(n.tag.isEOC())break;t[t.length]=n}o=i-e.pos}catch(t){throw new Error("Exception while decoding undefined length content: "+t)}return t};if(n.tagConstructed)a=u();else if(n.isUniversal()&&(3==n.tagNumber||4==n.tagNumber))try{if(3==n.tagNumber&&0!=e.get())throw new Error("BIT STRINGs with unused bits cannot encapsulate.");a=u();for(var c=0;c<a.length;++c)if(a[c].tag.isEOC())throw new Error("EOC is not supposed to be actual content.")}catch(t){a=null}if(null===a){if(null===o)throw new Error("We can't skip over an invalid tag with undefined length at offset "+i);e.pos=i+Math.abs(o)}return new Z(r,s,o,n,a)}}class X{constructor(t){var e=t.get();if(this.tagClass=e>>6,this.tagConstructed=!!(32&e),this.tagNumber=31&e,31==this.tagNumber){var r=new J;do{e=t.get(),r.mulAdd(128,127&e)}while(128&e);this.tagNumber=r.simplify()}}isUniversal(){return 0===this.tagClass}isEOC(){return 0===this.tagClass&&0===this.tagNumber}}var y=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],v=(1<<26)/y[y.length-1];class tt{constructor(t,e,r){null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}toString(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,n=(1<<e)-1,o=!1,i="",s=this.t,a=this.DB-s*this.DB%e;if(s-- >0)for(a<this.DB&&(r=this[s]>>a)>0&&(o=!0,i=B(r));s>=0;)a<e?(r=(this[s]&(1<<a)-1)<<e-a,r|=this[--s]>>(a+=this.DB-e)):(r=this[s]>>(a-=e)&n,a<=0&&(a+=this.DB,--s)),r>0&&(o=!0),o&&(i+=B(r));return o?i:"0"}negate(){var t=et();return tt.ZERO.subTo(this,t),t}abs(){return this.s<0?this.negate():this}compareTo(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0}bitLength(){return this.t<=0?0:this.DB*(this.t-1)+ut(this[this.t-1]^this.s&this.DM)}mod(t){var e=et();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(tt.ZERO)>0&&t.subTo(e,e),e}modPowInt(t,e){var r;return r=t<256||e.isEven()?new m(e):new b(e),this.exp(t,r)}clone(){var t=et();return this.copyTo(t),t}intValue(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]}byteValue(){return 0==this.t?this.s:this[0]<<24>>24}shortValue(){return 0==this.t?this.s:this[0]<<16>>16}signum(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1}toByteArray(){var t=this.t,e=[];e[0]=this.s;var r,n=this.DB-t*this.DB%8,o=0;if(t-- >0)for(n<this.DB&&(r=this[t]>>n)!=(this.s&this.DM)>>n&&(e[o++]=r|this.s<<this.DB-n);t>=0;)n<8?(r=(this[t]&(1<<n)-1)<<8-n,r|=this[--t]>>(n+=this.DB-8)):(r=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),128&r&&(r|=-256),0==o&&(128&this.s)!=(128&r)&&++o,(o>0||r!=this.s)&&(e[o++]=r);return e}equals(t){return 0==this.compareTo(t)}min(t){return this.compareTo(t)<0?this:t}max(t){return this.compareTo(t)>0?this:t}and(t){var e=et();return this.bitwiseTo(t,W,e),e}or(t){var e=et();return this.bitwiseTo(t,F,e),e}xor(t){var e=et();return this.bitwiseTo(t,V,e),e}andNot(t){var e=et();return this.bitwiseTo(t,H,e),e}not(){for(var t=et(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t}shiftLeft(t){var e=et();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e}shiftRight(t){var e=et();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e}getLowestSetBit(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+G(this[t]);return this.s<0?this.t*this.DB:-1}bitCount(){for(var t=0,e=this.s&this.DM,r=0;r<this.t;++r)t+=$(this[r]^e);return t}testBit(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:!!(this[e]&1<<t%this.DB)}setBit(t){return this.changeBit(t,F)}clearBit(t){return this.changeBit(t,H)}flipBit(t){return this.changeBit(t,V)}add(t){var e=et();return this.addTo(t,e),e}subtract(t){var e=et();return this.subTo(t,e),e}multiply(t){var e=et();return this.multiplyTo(t,e),e}divide(t){var e=et();return this.divRemTo(t,e,null),e}remainder(t){var e=et();return this.divRemTo(t,null,e),e}divideAndRemainder(t){var e=et(),r=et();return this.divRemTo(t,e,r),[e,r]}modPow(t,e){var r,n,o=t.bitLength(),i=at(1);if(o<=0)return i;r=o<18?1:o<48?3:o<144?4:o<768?5:6,n=o<8?new m(e):e.isEven()?new w(e):new b(e);var s=[],a=3,u=r-1,c=(1<<r)-1;if(s[1]=n.convert(this),r>1){var l=et();for(n.sqrTo(s[1],l);a<=c;)s[a]=et(),n.mulTo(l,s[a-2],s[a]),a+=2}var f,h,d=t.t-1,p=!0,y=et();for(o=ut(t[d])-1;d>=0;){for(o>=u?f=t[d]>>o-u&c:(f=(t[d]&(1<<o+1)-1)<<u-o,d>0&&(f|=t[d-1]>>this.DB+o-u)),a=r;!(1&f);)f>>=1,--a;if((o-=a)<0&&(o+=this.DB,--d),p)s[f].copyTo(i),p=!1;else{for(;a>1;)n.sqrTo(i,y),n.sqrTo(y,i),a-=2;a>0?n.sqrTo(i,y):(h=i,i=y,y=h),n.mulTo(y,s[f],i)}for(;d>=0&&!(t[d]&1<<o);)n.sqrTo(i,y),h=i,i=y,y=h,--o<0&&(o=this.DB-1,--d)}return n.revert(i)}modInverse(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return tt.ZERO;for(var r=t.clone(),n=this.clone(),o=at(1),i=at(0),s=at(0),a=at(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),e?(o.isEven()&&i.isEven()||(o.addTo(this,o),i.subTo(t,i)),o.rShiftTo(1,o)):i.isEven()||i.subTo(t,i),i.rShiftTo(1,i);for(;n.isEven();)n.rShiftTo(1,n),e?(s.isEven()&&a.isEven()||(s.addTo(this,s),a.subTo(t,a)),s.rShiftTo(1,s)):a.isEven()||a.subTo(t,a),a.rShiftTo(1,a);r.compareTo(n)>=0?(r.subTo(n,r),e&&o.subTo(s,o),i.subTo(a,i)):(n.subTo(r,n),e&&s.subTo(o,s),a.subTo(i,a))}return 0!=n.compareTo(tt.ONE)?tt.ZERO:a.compareTo(t)>=0?a.subtract(t):a.signum()<0?(a.addTo(t,a),a.signum()<0?a.add(t):a):a}pow(t){return this.exp(t,new g)}gcd(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var o=e.getLowestSetBit(),i=r.getLowestSetBit();if(i<0)return e;for(o<i&&(i=o),i>0&&(e.rShiftTo(i,e),r.rShiftTo(i,r));e.signum()>0;)(o=e.getLowestSetBit())>0&&e.rShiftTo(o,e),(o=r.getLowestSetBit())>0&&r.rShiftTo(o,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return i>0&&r.lShiftTo(i,r),r}isProbablePrime(t){var e,r=this.abs();if(1==r.t&&r[0]<=y[y.length-1]){for(e=0;e<y.length;++e)if(r[0]==y[e])return!0;return!1}if(r.isEven())return!1;for(e=1;e<y.length;){for(var n=y[e],o=e+1;o<y.length&&n<v;)n*=y[o++];for(n=r.modInt(n);e<o;)if(n%y[e++]==0)return!1}return r.millerRabin(t)}copyTo(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s}fromInt(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0}fromString(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var n=t.length,o=!1,i=0;--n>=0;){var s=8==r?255&+t[n]:st(t,n);s<0?"-"==t.charAt(n)&&(o=!0):(o=!1,0==i?this[this.t++]=s:i+r>this.DB?(this[this.t-1]|=(s&(1<<this.DB-i)-1)<<i,this[this.t++]=s>>this.DB-i):this[this.t-1]|=s<<i,(i+=r)>=this.DB&&(i-=this.DB))}8==r&&128&+t[0]&&(this.s=-1,i>0&&(this[this.t-1]|=(1<<this.DB-i)-1<<i)),this.clamp(),o&&tt.ZERO.subTo(this,this)}clamp(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t}dlShiftTo(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s}drShiftTo(t,e){for(var r=t;r<this.t;++r)e[r-t]=this[r];e.t=Math.max(this.t-t,0),e.s=this.s}lShiftTo(t,e){for(var r=t%this.DB,n=this.DB-r,o=(1<<n)-1,i=Math.floor(t/this.DB),s=this.s<<r&this.DM,a=this.t-1;a>=0;--a)e[a+i+1]=this[a]>>n|s,s=(this[a]&o)<<r;for(a=i-1;a>=0;--a)e[a]=0;e[i]=s,e.t=this.t+i+1,e.s=this.s,e.clamp()}rShiftTo(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var n=t%this.DB,o=this.DB-n,i=(1<<n)-1;e[0]=this[r]>>n;for(var s=r+1;s<this.t;++s)e[s-r-1]|=(this[s]&i)<<o,e[s-r]=this[s]>>n;n>0&&(e[this.t-r-1]|=(this.s&i)<<o),e.t=this.t-r,e.clamp()}}subTo(t,e){for(var r=0,n=0,o=Math.min(t.t,this.t);r<o;)n+=this[r]-t[r],e[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n-=t.s;r<this.t;)n+=this[r],e[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n-=t[r],e[r++]=n&this.DM,n>>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[r++]=this.DV+n:n>0&&(e[r++]=n),e.t=r,e.clamp()}multiplyTo(t,e){var r=this.abs(),n=t.abs(),o=r.t;for(e.t=o+n.t;--o>=0;)e[o]=0;for(o=0;o<n.t;++o)e[o+r.t]=r.am(0,n[o],e,o,0,r.t);e.s=0,e.clamp(),this.s!=t.s&&tt.ZERO.subTo(e,e)}squareTo(t){for(var e=this.abs(),r=t.t=2*e.t;--r>=0;)t[r]=0;for(r=0;r<e.t-1;++r){var n=e.am(r,e[r],t,2*r,0,1);(t[r+e.t]+=e.am(r+1,2*e[r],t,2*r+1,n,e.t-r-1))>=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()}divRemTo(t,e,r){var n=t.abs();if(!(n.t<=0)){var o=this.abs();if(o.t<n.t)return null!=e&&e.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=et());var i=et(),s=this.s,a=t.s,u=this.DB-ut(n[n.t-1]);u>0?(n.lShiftTo(u,i),o.lShiftTo(u,r)):(n.copyTo(i),o.copyTo(r));var c=i.t,l=i[c-1];if(0!=l){var f=l*(1<<this.F1)+(c>1?i[c-2]>>this.F2:0),h=this.FV/f,d=(1<<this.F1)/f,p=1<<this.F2,y=r.t,v=y-c,g=null==e?et():e;for(i.dlShiftTo(v,g),r.compareTo(g)>=0&&(r[r.t++]=1,r.subTo(g,r)),tt.ONE.dlShiftTo(c,g),g.subTo(i,i);i.t<c;)i[i.t++]=0;for(;--v>=0;){var m=r[--y]==l?this.DM:Math.floor(r[y]*h+(r[y-1]+p)*d);if((r[y]+=i.am(0,m,r,v,0,c))<m)for(i.dlShiftTo(v,g),r.subTo(g,r);r[y]<--m;)r.subTo(g,r)}null!=e&&(r.drShiftTo(c,e),s!=a&&tt.ZERO.subTo(e,e)),r.t=c,r.clamp(),u>0&&r.rShiftTo(u,r),s<0&&tt.ZERO.subTo(r,r)}}}invDigit(){if(this.t<1)return 0;var t=this[0];if(!(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e}isEven(){return 0==(this.t>0?1&this[0]:this.s)}exp(t,e){if(t>4294967295||t<1)return tt.ONE;var r=et(),n=et(),o=e.convert(this),i=ut(t)-1;for(o.copyTo(r);--i>=0;)if(e.sqrTo(r,n),(t&1<<i)>0)e.mulTo(n,o,r);else{var s=r;r=n,n=s}return e.revert(r)}chunkSize(t){return Math.floor(Math.LN2*this.DB/Math.log(t))}toRadix(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),n=at(r),o=et(),i=et(),s="";for(this.divRemTo(n,o,i);o.signum()>0;)s=(r+i.intValue()).toString(t).substr(1)+s,o.divRemTo(n,o,i);return i.intValue().toString(t)+s}fromRadix(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),n=Math.pow(e,r),o=!1,i=0,s=0,a=0;a<t.length;++a){var u=st(t,a);u<0?"-"==t.charAt(a)&&0==this.signum()&&(o=!0):(s=e*s+u,++i>=r&&(this.dMultiply(n),this.dAddOffset(s,0),i=0,s=0))}i>0&&(this.dMultiply(Math.pow(e,i)),this.dAddOffset(s,0)),o&&tt.ZERO.subTo(this,this)}fromNumber(t,e,r){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(tt.ONE.shiftLeft(t-1),F,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(tt.ONE.shiftLeft(t-1),this);else{var n=[],o=7&t;n.length=1+(t>>3),e.nextBytes(n),o>0?n[0]&=(1<<o)-1:n[0]=0,this.fromString(n,256)}}bitwiseTo(t,e,r){var n,o,i=Math.min(t.t,this.t);for(n=0;n<i;++n)r[n]=e(this[n],t[n]);if(t.t<this.t){for(o=t.s&this.DM,n=i;n<this.t;++n)r[n]=e(this[n],o);r.t=this.t}else{for(o=this.s&this.DM,n=i;n<t.t;++n)r[n]=e(o,t[n]);r.t=t.t}r.s=e(this.s,t.s),r.clamp()}changeBit(t,e){var r=tt.ONE.shiftLeft(t);return this.bitwiseTo(r,e,r),r}addTo(t,e){for(var r=0,n=0,o=Math.min(t.t,this.t);r<o;)n+=this[r]+t[r],e[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n+=t.s;r<this.t;)n+=this[r],e[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n+=t[r],e[r++]=n&this.DM,n>>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[r++]=n:n<-1&&(e[r++]=this.DV+n),e.t=r,e.clamp()}dMultiply(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()}dAddOffset(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}}multiplyLowerTo(t,e,r){var n=Math.min(this.t+t.t,e);for(r.s=0,r.t=n;n>0;)r[--n]=0;for(var o=r.t-this.t;n<o;++n)r[n+this.t]=this.am(0,t[n],r,n,0,this.t);for(o=Math.min(t.t,e);n<o;++n)this.am(0,t[n],r,n,0,e-n);r.clamp()}multiplyUpperTo(t,e,r){--e;var n=r.t=this.t+t.t-e;for(r.s=0;--n>=0;)r[n]=0;for(n=Math.max(e-this.t,0);n<t.t;++n)r[this.t+n-e]=this.am(e-n,t[n],r,0,0,this.t+n-e);r.clamp(),r.drShiftTo(1,r)}modInt(t){if(t<=0)return 0;var e=this.DV%t,r=this.s<0?t-1:0;if(this.t>0)if(0==e)r=this[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this[n])%t;return r}millerRabin(t){var e=this.subtract(tt.ONE),r=e.getLowestSetBit();if(r<=0)return!1;var n=e.shiftRight(r);(t=t+1>>1)>y.length&&(t=y.length);for(var o=et(),i=0;i<t;++i){o.fromInt(y[Math.floor(Math.random()*y.length)]);var s=o.modPow(n,this);if(0!=s.compareTo(tt.ONE)&&0!=s.compareTo(e)){for(var a=1;a++<r&&0!=s.compareTo(e);)if(0==(s=s.modPowInt(2,this)).compareTo(tt.ONE))return!1;if(0!=s.compareTo(e))return!1}}return!0}square(){var t=et();return this.squareTo(t),t}gcda(t,e){var r=this.s<0?this.negate():this.clone(),n=t.s<0?t.negate():t.clone();if(r.compareTo(n)<0){var o=r;r=n,n=o}var i=r.getLowestSetBit(),s=n.getLowestSetBit();if(s<0)e(r);else{i<s&&(s=i),s>0&&(r.rShiftTo(s,r),n.rShiftTo(s,n));var a=()=>{(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),(i=n.getLowestSetBit())>0&&n.rShiftTo(i,n),r.compareTo(n)>=0?(r.subTo(n,r),r.rShiftTo(1,r)):(n.subTo(r,n),n.rShiftTo(1,n)),r.signum()>0?setTimeout(a,0):(s>0&&n.lShiftTo(s,n),setTimeout((function(){e(n)}),0))};setTimeout(a,10)}}fromNumberAsync(t,e,r,n){if("number"==typeof e)if(t<2)this.fromInt(1);else{this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(tt.ONE.shiftLeft(t-1),F,this),this.isEven()&&this.dAddOffset(1,0);var o=this,i=function(){o.dAddOffset(2,0),o.bitLength()>t&&o.subTo(tt.ONE.shiftLeft(t-1),o),o.isProbablePrime(e)?setTimeout((function(){n()}),0):setTimeout(i,0)};setTimeout(i,0)}else{var s=[],a=7&t;s.length=1+(t>>3),e.nextBytes(s),a>0?s[0]&=(1<<a)-1:s[0]=0,this.fromString(s,256)}}}var g=function(){function t(){}return t.prototype.convert=function(t){return t},t.prototype.revert=function(t){return t},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},t.prototype.sqrTo=function(t,e){t.squareTo(e)},t}(),m=function(){function t(t){this.m=t}return t.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},t.prototype.revert=function(t){return t},t.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),b=function(){function t(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}return t.prototype.convert=function(t){var e=et();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(tt.ZERO)>0&&this.m.subTo(e,e),e},t.prototype.revert=function(t){var e=et();return t.copyTo(e),this.reduce(e),e},t.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var r=32767&t[e],n=r*this.mpl+((r*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),w=function(){function t(t){this.m=t,this.r2=et(),this.q3=et(),tt.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t)}return t.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=et();return t.copyTo(e),this.reduce(e),e},t.prototype.revert=function(t){return t},t.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}();function et(){return new tt(null)}function rt(t,e){return new tt(t,e)}function nt(t,e,r,n,o,i){for(;--i>=0;){var s=e*this[t++]+r[n]+o;o=Math.floor(s/67108864),r[n++]=67108863&s}return o}function ot(t,e,r,n,o,i){for(var s=32767&e,a=e>>15;--i>=0;){var u=32767&this[t],c=this[t++]>>15,l=a*u+c*s;o=((u=s*u+((32767&l)<<15)+r[n]+(1073741823&o))>>>30)+(l>>>15)+a*c+(o>>>30),r[n++]=1073741823&u}return o}function it(t,e,r,n,o,i){for(var s=16383&e,a=e>>14;--i>=0;){var u=16383&this[t],c=this[t++]>>14,l=a*u+c*s;o=((u=s*u+((16383&l)<<14)+r[n]+o)>>28)+(l>>14)+a*c,r[n++]=268435455&u}return o}void 0!==o&&"Microsoft Internet Explorer"==(null==o?void 0:o.appName)?(tt.prototype.am=ot,h=30):"Netscape"!=(null==o?void 0:o.appName)?(tt.prototype.am=nt,h=26):(tt.prototype.am=it,h=28),tt.prototype.DB=h,tt.prototype.DM=(1<<h)-1,tt.prototype.DV=1<<h,tt.prototype.FV=Math.pow(2,52),tt.prototype.F1=52-h,tt.prototype.F2=2*h-52;var _,S,E=[];for(_="0".charCodeAt(0),S=0;S<=9;++S)E[_++]=S;for(_="a".charCodeAt(0),S=10;S<36;++S)E[_++]=S;for(_="A".charCodeAt(0),S=10;S<36;++S)E[_++]=S;function st(t,e){var r=E[t.charCodeAt(e)];return null==r?-1:r}function at(t){var e=et();return e.fromInt(t),e}function ut(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}tt.ZERO=at(0),tt.ONE=at(1);class ct{constructor(){this.i=0,this.j=0,this.S=[]}init(t){var e,r,n;for(e=0;e<256;++e)this.S[e]=e;for(r=0,e=0;e<256;++e)r=r+this.S[e]+t[e%t.length]&255,n=this.S[e],this.S[e]=this.S[r],this.S[r]=n;this.i=0,this.j=0}next(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]}}var I,O,T=null;if(null==T){var R,A,P,x;T=[],O=0;var C=void 0;if(null!==(R=window)&&void 0!==R&&R.crypto&&null!==(A=window)&&void 0!==A&&A.crypto.getRandomValues){var N,L=new Uint32Array(256);for(null===(N=window)||void 0===N||N.crypto.getRandomValues(L),C=0;C<L.length;++C)T[O++]=255&L[C]}var j,U=function(t){var e,r,n;if(this.count=this.count||0,this.count>=256||O>=256){if(null!==(e=window)&&void 0!==e&&e.removeEventListener)null===(n=window)||void 0===n||n.removeEventListener("mousemove",U,!1);else if(null!==(r=window)&&void 0!==r&&r.detachEvent){var o;null===(o=window)||void 0===o||o.detachEvent("onmousemove",U)}}else try{var i=t.x+t.y;T[O++]=255&i,this.count+=1}catch(t){}};if(null!==(P=window)&&void 0!==P&&P.addEventListener)null===(j=window)||void 0===j||j.addEventListener("mousemove",U,!1);else if(null!==(x=window)&&void 0!==x&&x.attachEvent){var k;null===(k=window)||void 0===k||k.attachEvent("onmousemove",U)}}function lt(){if(null==I){for(I=new ct;O<256;){var t=Math.floor(65536*Math.random());T[O++]=255&t}for(I.init(T),O=0;O<T.length;++O)T[O]=0;O=0}return I.next()}class ft{constructor(){}nextBytes(t){for(var e=0;e<t.length;++e)t[e]=lt()}}function ht(t,e){if(e<t.length+11)return console.error("Message too long for RSA"),null;for(var r=[],n=t.length-1;n>=0&&e>0;){var o=t.charCodeAt(n--);o<128?r[--e]=o:o>127&&o<2048?(r[--e]=63&o|128,r[--e]=o>>6|192):(r[--e]=63&o|128,r[--e]=o>>6&63|128,r[--e]=o>>12|224)}r[--e]=0;for(var i=new ft,s=[];e>2;){for(s[0]=0;0==s[0];)i.nextBytes(s);r[--e]=s[0]}return r[--e]=2,r[--e]=0,new tt(r)}class dt{constructor(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}doPublic(t){return t.modPowInt(this.e,this.n)}doPrivate(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),r=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(r)<0;)e=e.add(this.p);return e.subtract(r).multiply(this.coeff).mod(this.p).multiply(this.q).add(r)}setPublic(t,e){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=rt(t,16),this.e=parseInt(e,16)):console.error("Invalid RSA public key")}encrypt(t){var e=ht(t,this.n.bitLength()+7>>3);if(null==e)return null;var r=this.doPublic(e);if(null==r)return null;var n=r.toString(16);return 1&n.length?"0"+n:n}encryptLong(t){var e=this,r=(this.n.bitLength()+7>>3)-11;try{var n="";return t.length>r?(t.match(/.{1,117}/g).forEach((function(t){var r=e.encrypt(t);n+=r})),K(n)):K(this.encrypt(t))}catch(t){return!1}}decryptLong(t){var e=this,r=this.n.bitLength()+7>>3;t=z(t);try{if(t.length>r){var n="";return t.match(/.{1,256}/g).forEach((function(t){var r=e.decrypt(t);n+=r})),n}return this.decrypt(t)}catch(t){return!1}}setPrivate(t,e,r){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=rt(t,16),this.e=parseInt(e,16),this.d=rt(r,16)):console.error("Invalid RSA private key")}setPrivateEx(t,e,r,n,o,i,s,a){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=rt(t,16),this.e=parseInt(e,16),this.d=rt(r,16),this.p=rt(n,16),this.q=rt(o,16),this.dmp1=rt(i,16),this.dmq1=rt(s,16),this.coeff=rt(a,16)):console.error("Invalid RSA private key")}generate(t,e){var r=new ft,n=t>>1;this.e=parseInt(e,16);for(var o=new tt(e,16);;){for(;this.p=new tt(t-n,1,r),0!=this.p.subtract(tt.ONE).gcd(o).compareTo(tt.ONE)||!this.p.isProbablePrime(10););for(;this.q=new tt(n,1,r),0!=this.q.subtract(tt.ONE).gcd(o).compareTo(tt.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var i=this.p;this.p=this.q,this.q=i}var s=this.p.subtract(tt.ONE),a=this.q.subtract(tt.ONE),u=s.multiply(a);if(0==u.gcd(o).compareTo(tt.ONE)){this.n=this.p.multiply(this.q),this.d=o.modInverse(u),this.dmp1=this.d.mod(s),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}}decrypt(t){var e=rt(t,16),r=this.doPrivate(e);return null==r?null:pt(r,this.n.bitLength()+7>>3)}generateAsync(t,e,r){var n=new ft,o=t>>1;this.e=parseInt(e,16);var i=new tt(e,16),s=this,a=()=>{var e=()=>{if(s.p.compareTo(s.q)<=0){var t=s.p;s.p=s.q,s.q=t}var e=s.p.subtract(tt.ONE),n=s.q.subtract(tt.ONE),o=e.multiply(n);0==o.gcd(i).compareTo(tt.ONE)?(s.n=s.p.multiply(s.q),s.d=i.modInverse(o),s.dmp1=s.d.mod(e),s.dmq1=s.d.mod(n),s.coeff=s.q.modInverse(s.p),setTimeout((function(){r()}),0)):setTimeout(a,0)},u=()=>{s.q=et(),s.q.fromNumberAsync(o,1,n,(function(){s.q.subtract(tt.ONE).gcda(i,(function(t){0==t.compareTo(tt.ONE)&&s.q.isProbablePrime(10)?setTimeout(e,0):setTimeout(u,0)}))}))},c=()=>{s.p=et(),s.p.fromNumberAsync(t-o,1,n,(function(){s.p.subtract(tt.ONE).gcda(i,(function(t){0==t.compareTo(tt.ONE)&&s.p.isProbablePrime(10)?setTimeout(u,0):setTimeout(c,0)}))}))};setTimeout(c,0)};setTimeout(a,0)}}function pt(t,e){for(var r=t.toByteArray(),n=0;n<r.length&&0==r[n];)++n;if(r.length-n!=e-1||2!=r[n])return null;for(++n;0!=r[n];)if(++n>=r.length)return null;for(var o="";++n<r.length;){var i=255&r[n];i<128?o+=String.fromCharCode(i):i>191&&i<224?(o+=String.fromCharCode((31&i)<<6|63&r[n+1]),++n):(o+=String.fromCharCode((15&i)<<12|(63&r[n+1])<<6|63&r[n+2]),n+=2)}return o}class yt extends dt{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";super(),t&&("string"==typeof t?this.parseKey(t):(this.hasPrivateKeyProperty(t)||this.hasPublicKeyProperty(t))&&this.parsePropertiesFrom(t))}parseKey(t){try{var e=0,r=0,n=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(t)?c.decode(t):l.unarmor(t),o=Z.decode(n);if(3===o.sub.length&&(o=o.sub[2].sub[0]),9===o.sub.length){e=o.sub[1].getHexStringValue(),this.n=rt(e,16),r=o.sub[2].getHexStringValue(),this.e=parseInt(r,16);var i=o.sub[3].getHexStringValue();this.d=rt(i,16);var s=o.sub[4].getHexStringValue();this.p=rt(s,16);var a=o.sub[5].getHexStringValue();this.q=rt(a,16);var u=o.sub[6].getHexStringValue();this.dmp1=rt(u,16);var f=o.sub[7].getHexStringValue();this.dmq1=rt(f,16);var h=o.sub[8].getHexStringValue();this.coeff=rt(h,16)}else{if(2!==o.sub.length)return!1;var d=o.sub[1].sub[0];e=d.sub[0].getHexStringValue(),this.n=rt(e,16),r=d.sub[1].getHexStringValue(),this.e=parseInt(r,16)}return!0}catch(t){return!1}}hasPublicKeyProperty(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")}hasPrivateKeyProperty(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")&&t.hasOwnProperty("d")&&t.hasOwnProperty("p")&&t.hasOwnProperty("q")&&t.hasOwnProperty("dmp1")&&t.hasOwnProperty("dmq1")&&t.hasOwnProperty("coeff")}parsePropertiesFrom(t){this.n=t.n,this.e=t.e,t.hasOwnProperty("d")&&(this.d=t.d,this.p=t.p,this.q=t.q,this.dmp1=t.dmp1,this.dmq1=t.dmq1,this.coeff=t.coeff)}}(n=function(t){t=t||{},this.default_key_size=parseInt(t.default_key_size,10)||1024,this.default_public_exponent=t.default_public_exponent||"010001",this.log=t.log||!1,this.key=null}).prototype.setKey=function(t){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new yt(t)},n.prototype.setPrivateKey=function(t){this.setKey(t)},n.prototype.setPublicKey=function(t){this.setKey(t)},n.prototype.decrypt=function(t){try{return this.getKey().decrypt(z(t))}catch(t){return!1}},n.prototype.encrypt=function(t){try{return K(this.getKey().encrypt(t))}catch(t){return!1}},n.prototype.encryptLong=function(t){try{for(var e=this.getKey().encryptLong(t)||"",r=this.getKey().decryptLong(e)||"",n=0,o=/null$/g;o.test(r)&&(n++,e=this.getKey().encryptLong(t)||"",r=this.getKey().decryptLong(e)||"",!(n>10)););return e}catch(t){return!1}},n.prototype.getKey=function(t){if(!this.key){if(this.key=new yt,t&&"[object Function]"==={}.toString.call(t))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,t);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},n.version="3.1.4"}var D=n,q=r(4655),M=function(){var{publicKey:t="",payload:e={}}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!t)return"";try{var r=(0,q.I)(e),n=new D;return n.setPublicKey(t),n.encryptLong("object"==typeof r?JSON.stringify(r):r)}catch(t){console.error("encrypt error:",t)}return""}},4655:function(t,e,r){"use strict";r.d(e,{I:function(){return n},y:function(){return o}});var n=t=>{var e=e=>{for(var r in t)t.hasOwnProperty(r)&&(e[r]=n(t[r]));return e},r=null==t?"NullOrUndefined":Object.prototype.toString.call(t).slice(8,-1);if(["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"].includes(r))return t.slice();switch(r){case"Object":return e(Object.create(Object.getPrototypeOf(t)));case"Array":return e([]);case"Date":return new Date(t.valueOf());case"RegExp":return new RegExp(t.source,(t.global?"g":"")+(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.sticky?"y":"")+(t.unicode?"u":""));default:return t}},o=t=>{var e=t.match(/^(?:http(s)?:\/\/[^\/]+)?(\/[^\?#]*)/);return e&&e[2]||""}},9063:function(t,e,r){"use strict";r.r(e),r.d(e,{registerRealtime:function(){return W}});var n=r(6765),o=r.n(n),i=r(7195),s=r.n(i),a=r(9850),u=r.n(a);function c(t){return void 0===t&&(t=""),"".concat(t?"".concat(t,"_"):"").concat(+new Date,"_").concat(Math.random())}var l,f,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}})},d=function(t){var e,r,n=t.id,o=t.docChanges,i=t.docs,s=t.msgType,a=t.type;Object.defineProperties(this,{id:{get:function(){return n},enumerable:!0},docChanges:{get:function(){return e||(e=JSON.parse(JSON.stringify(o))),e},enumerable:!0},docs:{get:function(){return r||(r=JSON.parse(JSON.stringify(i))),r},enumerable:!0},msgType:{get:function(){return s},enumerable:!0},type:{get:function(){return a},enumerable:!0}})},p=(l=function(t,e){return l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},l(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 r(){this.constructor=t}l(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),y=function(t){function e(e){var r=t.call(this,"Watch Error ".concat(JSON.stringify(e.msgData)," (requestid: ").concat(e.requestId,")"))||this;return r.isRealtimeErrorMessageError=!0,r.payload=e,r}return p(e,t),e}(Error),v=function(t){return null==t?void 0:t.isRealtimeErrorMessageError},g=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 p(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 p(e,t),e}(Error),b=function(t){function e(e){var r=t.call(this,e.errMsg)||this;return r.errCode="UNKNOWN_ERROR",Object.defineProperties(r,{message:{get:function(){return"errCode: ".concat(this.errCode," ").concat(w[this.errCode]||""," | errMsg: ").concat(this.errMsg)},set:function(t){this.errMsg=t}}}),r.errCode=e.errCode||"UNKNOWN_ERROR",r.errMsg=e.errMsg,r}return p(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"},_=function(t){return void 0===t&&(t=0),new Promise((function(e){return setTimeout(e,t)}))},S=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},E=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},I=function(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||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"}(f||(f={}));var O=function(){function t(t){var e=this;this.watchStatus=f.INITING,this.wsLogin=function(t,r){return S(e,void 0,void 0,(function(){var e;return E(this,(function(n){switch(n.label){case 0:return this.watchStatus=f.LOGGINGIN,[4,this.login(t,r)];case 1:return e=n.sent(),this.envId||(this.envId=e.envId),[2,e]}}))}))},this.initWatch=function(t){return S(e,void 0,void 0,(function(){var e,r=this;return E(this,(function(n){switch(n.label){case 0:if(null!==this.initWatchPromise&&void 0!==this.initWatchPromise)return[2,this.initWatchPromise];this.initWatchPromise=new Promise((function(e,n){S(r,void 0,void 0,(function(){var r,o,i,s,a,u,l,h,p,y;return E(this,(function(v){switch(v.label){case 0:return v.trys.push([0,3,,4]),this.watchStatus===f.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,e()]):[4,this.wsLogin(this.envId,t)];case 1:return r=v.sent().envId,this.watchStatus===f.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,e()]):(this.watchStatus=f.INITING,o={watchId:this.watchId,requestId:c(),msgType:"INIT_WATCH",msgData:{envId:r,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=v.sent(),s=i.msgData,a=s.events,u=s.currEvent,this.sessionInfo={queryID:i.msgData.queryID,currentEventId:u-1,currentDocs:[]},a.length>0){for(l=0,h=a;l<h.length;l++)h[l].ID=u;this.handleServerEvents(i)}else this.sessionInfo.currentEventId=u,p=new d({id:u,docChanges:[],docs:[],type:"init"}),this.listener.onChange(p),this.scheduleSendACK();return this.onWatchStart(this,this.sessionInfo.queryID),this.watchStatus=f.ACTIVE,this.availableRetries.INIT_WATCH=2,e(),[3,4];case 3:return y=v.sent(),this.handleWatchEstablishmentError(y,{operationName:"INIT_WATCH",resolve:e,reject:n}),[3,4];case 4:return[2]}}))}))})),e=!1,n.label=1;case 1:return n.trys.push([1,,3,4]),[4,this.initWatchPromise];case 2:return n.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 S(e,void 0,void 0,(function(){var e,r=this;return E(this,(function(n){switch(n.label){case 0:if(null!==this.rebuildWatchPromise&&void 0!==this.rebuildWatchPromise)return[2,this.rebuildWatchPromise];this.rebuildWatchPromise=new Promise((function(e,n){S(r,void 0,void 0,(function(){var r,o,i,s;return E(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),this.watchStatus===f.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,e()]):[4,this.wsLogin(this.envId,t)];case 1:if(r=a.sent().envId,!this.sessionInfo)throw new Error("can not rebuildWatch without a successful initWatch (lack of sessionInfo)");return this.watchStatus===f.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,e()]):(this.watchStatus=f.REBUILDING,o={watchId:this.watchId,requestId:c(),msgType:"REBUILD_WATCH",msgData:{envId:r,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=f.ACTIVE,this.availableRetries.REBUILD_WATCH=2,e(),[3,4];case 3:return s=a.sent(),this.handleWatchEstablishmentError(s,{operationName:"REBUILD_WATCH",resolve:e,reject:n}),[3,4];case 4:return[2]}}))}))})),e=!1,n.label=1;case 1:return n.trys.push([1,,3,4]),[4,this.rebuildWatchPromise];case 2:return n.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,r){return S(e,void 0,void 0,(function(){var e,n,o,i=this;return E(this,(function(s){return e="INIT_WATCH"===r.operationName,n=function(){i.closeWithError(new b({errCode:e?w.SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:w.SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL,errMsg:t})),r.reject(t)},o=function(t){i.useRetryTicket(r.operationName)?e?(i.initWatchPromise=void 0,r.resolve(i.initWatch(t))):(i.rebuildWatchPromise=void 0,r.resolve(i.rebuildWatch(t))):n()},this.handleCommonError(t,{onSignError:function(){return o(!0)},onTimeoutError:function(){return o(!1)},onNotRetryableError:n,onCancelledError:r.reject,onUnknownError:function(){S(i,void 0,void 0,(function(){var t,e=this;return E(this,(function(n){switch(n.label){case 0:return n.trys.push([0,8,,9]),t=function(){return S(e,void 0,void 0,(function(){return E(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 n.sent(),[3,7];case 2:return[4,_(100)];case 3:return n.sent(),this.watchStatus!==f.PAUSED?[3,4]:(r.reject(new m("".concat(r.operationName," cancelled due to pause after unknownError"))),[3,7]);case 4:return this.isWSConnected()?[3,6]:[4,t()];case 5:return n.sent(),[3,7];case 6:o(!1),n.label=7;case 7:return[3,9];case 8:return n.sent(),o(!0),[3,9];case 9:return[2]}}))}))}}),[2]}))}))},this.closeWatch=function(){return S(e,void 0,void 0,(function(){var t,e,r;return E(this,(function(n){switch(n.label){case 0:if(t=this.sessionInfo?this.sessionInfo.queryID:"",this.watchStatus!==f.ACTIVE)return this.watchStatus=f.CLOSED,this.onWatchClose(this,t),[2];n.label=1;case 1:return n.trys.push([1,3,4,5]),this.watchStatus=f.CLOSING,e={watchId:this.watchId,requestId:c(),msgType:"CLOSE_WATCH",msgData:null},[4,this.send({msg:e})];case 2:return n.sent(),this.sessionInfo=void 0,this.watchStatus=f.CLOSED,[3,5];case 3:return r=n.sent(),this.closeWithError(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL,errMsg:r})),[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 S(e,void 0,void 0,(function(){var t,e,r;return E(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this.watchStatus!==f.ACTIVE?(this.scheduleSendACK(),[2]):this.sessionInfo?(t={watchId:this.watchId,requestId:c(),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 n.sent(),this.scheduleSendACK(),[3,3];case 2:if(e=n.sent(),v(e))switch((r=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 b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:r.msgData.code})),[2]}return this.availableRetries.CHECK_LAST&&this.availableRetries.CHECK_LAST>0?(this.availableRetries.CHECK_LAST-=1,this.scheduleSendACK()):this.closeWithError(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:e})),[3,3];case 3:return[2]}}))}))},this.handleCommonError=function(t,e){if(v(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:function(){e.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 f.PAUSED:if("ERROR"!==t.msgType)return;break;case f.LOGGINGIN:case f.INITING:case f.REBUILDING:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received while ".concat(this.watchStatus));case f.CLOSED:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received when the watch has closed");case f.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 b({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=f.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=f.PAUSED,console.log("[realtime] client paused (".concat(this.collectionName," ").concat(this.query,") (watchId ").concat(this.watchId,")"))},t.prototype.resume=function(){return S(this,void 0,void 0,(function(){var t;return E(this,(function(e){switch(e.label){case 0:this.watchStatus=f.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]-=1,console.log("[realtime] ".concat(t," use a retry ticket, now only ").concat(this.availableRetries[t]," retry left")),!0)},t.prototype.handleServerEvents=function(t){return S(this,void 0,void 0,(function(){var e;return E(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.scheduleSendACK(),[4,this.handleServerEventsInternel(t)];case 1:return r.sent(),this.postHandleServerEventsValidityCheck(t),[3,3];case 2:throw e=r.sent(),console.error("[realtime listener] internal non-fatal error: handle server events failed with error: ",e),e;case 3:return[2]}}))}))},t.prototype.handleServerEventsInternel=function(t){return S(this,void 0,void 0,(function(){var e,r,n,i,a,c,l,f,h,p,y,v;return E(this,(function(g){switch(g.label){case 0:if(e=t.requestId,r=t.msgData.events,n=t.msgType,!r.length||!this.sessionInfo)return[2];i=this.sessionInfo;try{a=r.map(T)}catch(t){return this.closeWithError(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA,errMsg:t})),[2]}c=I([],i.currentDocs,!0),l=!1,f=function(r,f){var p,y,v,g,m,_,S,O,T,R,A,P;return E(this,(function(E){switch(E.label){case 0:return p=a[r],i.currentEventId>=p.id?(!a[r-1]||p.id>a[r-1].id?console.warn("[realtime] duplicate event received, cur ".concat(i.currentEventId," but got ").concat(p.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!==p.id-1)return[3,2];switch(p.dataType){case"update":if(!p.doc)switch(p.queueType){case"update":case"dequeue":if(y=c.find((function(t){return t._id===p.docId})),y){if(v=u()(y),p.updatedFields&&Object.keys(p.updatedFields).forEach((function(t){o()(v,t,p.updatedFields[t])})),p.removedFields)for(g=0,m=p.removedFields;g<m.length;g++)_=m[g],s()(v,_);p.doc=v}else console.error("[realtime listener] internal non-fatal server error: unexpected update dataType event where no doc is associated.");break;case"enqueue":throw O=new b({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(O),O}break;case"replace":if(!p.doc)throw O=new b({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(O),O;break;case"remove":(S=c.find((function(t){return t._id===p.docId})))?p.doc=S:console.error("[realtime listener] internal non-fatal server error: unexpected remove event where no doc is associated.");break;case"limit":if(!p.doc)switch(p.queueType){case"dequeue":(S=c.find((function(t){return t._id===p.docId})))?p.doc=S:console.error("[realtime listener] internal non-fatal server error: unexpected limit dataType event where no doc is associated.");break;case"enqueue":throw O=new b({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(O),O}}switch(p.queueType){case"init":l?c.push(p.doc):(l=!0,c=[p.doc]);break;case"enqueue":c.push(p.doc);break;case"dequeue":T=c.findIndex((function(t){return t._id===p.docId})),T>-1?c.splice(T,1):console.error("[realtime listener] internal non-fatal server error: unexpected dequeue event where no doc is associated.");break;case"update":T=c.findIndex((function(t){return t._id===p.docId})),T>-1?c[T]=p.doc:console.error("[realtime listener] internal non-fatal server error: unexpected queueType update event where no doc is associated.")}return(r===f-1||a[r+1]&&a[r+1].id!==p.id)&&(R=I([],c,!0),A=a.slice(0,r+1).filter((function(t){return t.id===p.id})),h.sessionInfo.currentEventId=p.id,h.sessionInfo.currentDocs=c,P=new d({id:p.id,docChanges:A,docs:R,msgType:n}),h.listener.onChange(P)),[3,4];case 2:return console.warn("[realtime listener] event received is out of order, cur ".concat(h.sessionInfo.currentEventId," but got ").concat(p.id)),[4,h.rebuildWatch()];case 3:return E.sent(),[2,{value:void 0}];case 4:return[2]}}))},h=this,p=0,y=a.length,g.label=1;case 1:return p<y?[5,f(p,y)]:[3,4];case 2:if("object"==typeof(v=g.sent()))return[2,v.value];g.label=3;case 3:return p++,[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 T(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 R,A={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"}(R||(R={}));var P=function(t,e){var r=A[t],n=r?"".concat(r.name,", code ").concat(t,", reason ").concat(e||r.description):"code ".concat(t);return new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED,errMsg:n})},x=null,C="web";function N(){return x}function L(){return C}function j(t){C=t}var U=function(){return U=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},U.apply(this,arguments)},k=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},D=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},q=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 k(e,void 0,void 0,(function(){var e=this;return D(this,(function(r){return[2,new Promise((function(r,n){k(e,void 0,void 0,(function(){var e,o,i,s,a,u,c,l,f=this;return D(this,(function(h){switch(h.label){case 0:o=!1,i=!1,s=function(t){o=!0,e&&clearTimeout(e),r(t)},a=function(t){i=!0,e&&clearTimeout(e),n(t)},t.timeout&&(e=setTimeout((function(){k(f,void 0,void 0,(function(){return D(this,(function(t){switch(t.label){case 0:return o&&i?[3,2]:[4,_(0)];case 1:t.sent(),o&&i||a(new g("wsclient.send timedout")),t.label=2;case 2:return[2]}}))}))}),t.timeout)),h.label=1;case 1:return h.trys.push([1,8,,9]),void 0===this.wsInitPromise&&null===this.wsInitPromise?[3,3]:[4,this.wsInitPromise];case 2:h.sent(),h.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&&(u={resolve:s,reject:a,skipOnMessage:t.skipOnMessage},this.wsResponseWait.set(t.msg.requestId,u)),h.label=4;case 4:return h.trys.push([4,6,,7]),[4,this.ws.send(JSON.stringify(t.msg))];case 5:return h.sent(),t.waitResponse||s(void 0),[3,7];case 6:return(c=h.sent())&&(a(c),t.waitResponse&&this.wsResponseWait.delete(t.msg.requestId)),[3,7];case 7:return[3,9];case 8:return l=h.sent(),a(l),[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,r){return void 0===r&&(r=e.maxReconnect),k(e,void 0,void 0,(function(){var e=this;return D(this,(function(n){switch(n.label){case 0:if(t&&this.reconnectState)return[2];if(t&&(this.reconnectState=!0),void 0!==this.wsInitPromise&&null!==this.wsInitPromise)return[2,this.wsInitPromise];t&&this.pauseClients(),this.close(R.ReconnectWebSocket),this.wsInitPromise=new Promise((function(n,o){k(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 r=e.wsUrl||"wss://tcb-ws.tencentcloudapi.com",n=N();s.ws=n?new n(r):new WebSocket(r),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(),n(),t&&(this.resumeClients(),this.reconnectState=!1),[3,11];case 6:return i=a.sent(),console.error("[realtime] initWebSocketConnection connect fail",i),r>0?(this.wsInitPromise=void 0,[4,_(this.reconnectInterval)]):[3,9];case 7:a.sent(),t&&(this.reconnectState=!1),a.label=8;case 8:return n(this.initWebSocketConnection(t,r-1)),[3,10];case 9:o(i),t&&this.closeAllClients(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL,errMsg:i})),a.label=10;case 10:return[3,11];case 11:return[2]}}))}))})),n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,this.wsInitPromise];case 2:return n.sent(),this.wsReadySubsribers.forEach((function(t){return(0,t.resolve)()})),[3,5];case 3:return n.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,r){if(!e.ws)throw new Error("can not initWebSocketEvent, ws not exists");var n=!1;e.ws.onopen=function(e){console.warn("[realtime] ws event: open",e),n=!0,t()},e.ws.onerror=function(t){e.logins=new Map,n?(console.error("[realtime] ws event: error",t),e.clearHeartbeat(),e.virtualWSClient.forEach((function(e){return e.closeWithError(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR,errMsg:t}))}))):(console.error("[realtime] ws open failed with ws event: error",t),r(t))},e.ws.onclose=function(t){switch(console.warn("[realtime] ws event: close",t),e.logins=new Map,e.clearHeartbeat(),t.code){case R.ReconnectWebSocket:case R.NoRealtimeListeners:break;case R.HeartbeatPingError:case R.HeartbeatPongTimeoutError:case R.NormalClosure:case R.AbnormalClosure:e.maxReconnect>0?e.initWebSocketConnection(!0,e.maxReconnect):e.closeAllClients(P(t.code));break;case R.NoAuthentication:e.closeAllClients(P(t.code,t.reason));break;default:e.maxReconnect>0?e.initWebSocketConnection(!0,e.maxReconnect):e.closeAllClients(P(t.code))}},e.ws.onmessage=function(t){var r,n,o=(null===(r=t.data)||void 0===r?void 0:r.data)||t.data;e.heartbeat();try{n="string"==typeof o?JSON.parse(o):o}catch(t){throw new Error("[realtime] onMessage parse res.data error: ".concat(t))}if("ERROR"===n.msgType){var i=null;e.virtualWSClient.forEach((function(t){t.watchId===n.watchId&&(i=t)})),i&&i.listener.onError(n)}var s=e.wsResponseWait.get(n.requestId);if(s){try{"ERROR"===n.msgType?s.reject(new y(n)):s.resolve(n)}catch(t){console.error("ws onMessage responseWaitSpec.resolve(msg) errored:",t)}finally{e.wsResponseWait.delete(n.requestId)}if(s.skipOnMessage)return}if("PONG"!==n.msgType){var a=n.watchId&&e.watchIdClientMap.get(n.watchId);if(a)a.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":(a=e.queryIdClientMap.get(n.msgData.queryID))&&a.onMessage(n);break;default:for(var u=0,c=Array.from(e.watchIdClientMap.entries());u<c.length;u++){c[u][1].onMessage(n);break}}}else if(e.lastPingSendTS){var l=Date.now()-e.lastPingSendTS;if(l>1e4)return void console.warn("[realtime] untrusted rtt observed: ".concat(l));e.rttObserved.length>=3&&e.rttObserved.splice(0,e.rttObserved.length-3+1),e.rttObserved.push(l)}},e.heartbeat()}))},this.isWSConnected=function(){return Boolean(e.ws&&1===e.ws.readyState)},this.onceWSConnected=function(){return k(e,void 0,void 0,(function(){var t=this;return D(this,(function(e){return this.isWSConnected()?[2]:null!==this.wsInitPromise&&void 0!==this.wsInitPromise?[2,this.wsInitPromise]:[2,new Promise((function(e,r){t.wsReadySubsribers.push({resolve:e,reject:r})}))]}))}))},this.webLogin=function(t,r){return k(e,void 0,void 0,(function(){var e,n,o,i,s,a,u,l,f=this;return D(this,(function(h){switch(h.label){case 0:if(!r)if(t){if(e=this.logins.get(t)){if(e.loggedIn&&e.loginResult)return[2,e.loginResult];if(null!==e.loggingInPromise&&void 0!==e.loggingInPromise)return[2,e.loggingInPromise]}}else if(null!==(null==(n=this.logins.get(""))?void 0:n.loggingInPromise)&&void 0!==(null==n?void 0:n.loggingInPromise))return[2,n.loggingInPromise];o=new Promise((function(t,e){k(f,void 0,void 0,(function(){var r,n,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 r=a.sent(),n={envId:r.envId||"",accessToken:"",referrer:"web",sdkVersion:"",dataVersion:""},o={watchId:void 0,requestId:c(),msgType:"LOGIN",msgData:n,exMsgData:{runtime:L(),signStr:r.signStr,secretVersion:r.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:r.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(),(u=t&&this.logins.get(t))&&u===i&&u.loginStartTS===s)return i.loggedIn=!0,i.loggingInPromise=void 0,i.loginStartTS=void 0,i.loginResult=a,[2,a];if(u){if(u.loggedIn&&u.loginResult)return[2,u.loginResult];if(null!==u.loggingInPromise&&void 0!==u.loggingInPromise)return[2,u.loggingInPromise];throw new Error("ws unexpected login info")}throw new Error("ws login info reset");case 3:throw l=h.sent(),i.loggedIn=!1,i.loggingInPromise=void 0,i.loginStartTS=void 0,i.loginResult=void 0,l;case 4:return[2]}}))}))},this.getWsSign=function(){return k(e,void 0,void 0,(function(){var t,e,r,n,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:L()})]);case 1:if((e=a.sent()).code)throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败: ".concat(e.code));if(e.data)return r=e.data,n=r.signStr,o=r.wsUrl,i=r.secretVersion,s=r.envId,[2,{signStr:n,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 k(e,void 0,void 0,(function(){var t;return D(this,(function(e){switch(e.label){case 0:return t={watchId:void 0,requestId:c(),msgType:"PING",msgData:null},[4,this.send({msg:t})];case 1:return e.sent(),[2]}}))}))},this.onWatchStart=function(t,r){e.queryIdClientMap.set(r,t)},this.onWatchClose=function(t,r){r&&e.queryIdClientMap.delete(r),e.watchIdClientMap.delete(t.watchId),e.virtualWSClient.delete(t),e.virtualWSClient.size||e.close(R.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,A[t].name),this.ws=void 0)},t.prototype.watch=function(t){this.ws||void 0!==this.wsInitPromise&&null!==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(){k(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+=1,t.heartbeat(!0)):t.initWebSocketConnection(!0)}),this.context.appConfig.realtimePongWaitTimeout),[3,3];case 2:return e.sent(),this.pingFailed<2?(this.pingFailed+=1,this.heartbeat()):this.close(R.HeartbeatPingError),[3,3];case 3:return[2]}}))}))}),t?0:this.context.appConfig.realtimePingInterval)},t}(),M={target:"database",entity:function(){var t,e=this.platform,r=e.adapter,n=e.runtime;t=r.wsClass,x=t,j(n)}},B={name:"realtime",IIFE:!0,entity:function(){this.prototype.wsClientClass=q}};try{cloudbase.registerComponent(B),cloudbase.registerHook(M)}catch(t){}function W(t){try{t.registerComponent(B),t.registerHook(M)}catch(t){console.warn(t)}}},614:function(t,e,r){"use strict";r.r(e),r.d(e,{registerStorage:function(){return _}});var n,o=r(3616),i=function(){return i=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},i.apply(this,arguments)},s=function(t,e,r,n){var o,i=arguments.length,s=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s},a=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},u=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},c=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};!function(t){t.put="put",t.post="post"}(n||(n={}));var l=o._G.eX,f=o._G.Sg,h=o._G.vM,d=o.P6.isArray,p=o.P6.isString,y=o.P6.isPalinObject,v=o.P6.execCallback,g=o.BM.D,m="storage",b=new(function(){function t(){}return t.prototype.uploadFile=function(t,e){return u(this,void 0,void 0,(function(){var r,o,s,a,u,h,d,y,g,b,w,_,S,E,I,O,T,R,A,P,x,C,N,L,j;return c(this,(function(c){switch(c.label){case 0:if(r=t.cloudPath,o=t.filePath,s=t.onUploadProgress,a=t.method,u=void 0===a?"put":a,h=t.headers,d=void 0===h?{}:h,!p(r)||!o)throw new Error(JSON.stringify({code:f.INVALID_PARAMS,msg:"[".concat(m,".uploadFile] invalid params")}));return y={put:n.put,post:n.post}[u.toLocaleLowerCase()]||n.put,g=this.request,b={path:r,method:y},y===n.put&&(b.headers=d),[4,g.send("storage.getUploadMetadata",b)];case 1:return w=c.sent(),_=w.data,S=_.url,E=_.authorization,I=_.token,O=_.fileId,T=_.cosFileId,R=_.download_url,A=w.requestId,x=i(i({},P={url:S,file:o,name:r,onUploadProgress:s}),{method:n.put,headers:i(i({},d),{authorization:E,"x-cos-meta-fileid":T,"x-cos-security-token":I})}),C=i(i({},P),{method:n.post,data:{key:r,signature:E,"x-cos-meta-fileid":T,success_action_status:"201","x-cos-security-token":I}}),(j={})[n.put]={params:x,isSuccess:function(t){return t>=200&&t<300}},j[n.post]={params:C,isSuccess:function(t){return 201===t}},N=j,[4,g.upload(N[y].params)];case 2:return L=c.sent(),N[y].isSuccess(L.statusCode)?[2,v(e,null,{fileID:O,download_url:R,requestId:A})]:[2,v(e,new Error("[".concat(l(),"][").concat(f.OPERATION_FAIL,"][").concat(m,"]:").concat(L.data)))]}}))}))},t.prototype.getUploadMetadata=function(t,e){return u(this,void 0,void 0,(function(){var r,n,o,i,s;return c(this,(function(a){switch(a.label){case 0:if(r=t.cloudPath,!p(r))throw new Error(JSON.stringify({code:f.INVALID_PARAMS,msg:"[".concat(m,".getUploadMetadata] invalid cloudPath")}));n=this.request,o="storage.getUploadMetadata",a.label=1;case 1:return a.trys.push([1,3,,4]),[4,n.send(o,{path:r})];case 2:return i=a.sent(),[2,v(e,null,i)];case 3:return s=a.sent(),[2,v(e,s)];case 4:return[2]}}))}))},t.prototype.deleteFile=function(t,e){return u(this,void 0,void 0,(function(){var r,n,o,i,s,a;return c(this,(function(u){switch(u.label){case 0:if(!(r=t.fileList)||!d(r)||0===r.length)throw new Error(JSON.stringify({code:f.INVALID_PARAMS,msg:"[".concat(m,".deleteFile] fileList must not be empty")}));for(n=0,o=r;n<o.length;n++)if(!(i=o[n])||!p(i))throw new Error(JSON.stringify({code:f.INVALID_PARAMS,msg:"[".concat(m,".deleteFile] fileID must be string")}));return[4,this.request.send("storage.batchDeleteFile",{fileid_list:r})];case 1:return(s=u.sent()).code?[2,v(e,null,s)]:(a={fileList:s.data.delete_list,requestId:s.requestId},[2,v(e,null,a)])}}))}))},t.prototype.getTempFileURL=function(t,e){return u(this,void 0,void 0,(function(){var r,n,o,i,s,a;return c(this,(function(u){switch(u.label){case 0:if(!(r=t.fileList)||!d(r)||0===r.length)throw new Error(JSON.stringify({code:f.INVALID_PARAMS,msg:"[".concat(m,".getTempFileURL] fileList must not be empty")}));for(n=[],o=0,i=r;o<i.length;o++)if(s=i[o],y(s)){if(!Object.prototype.hasOwnProperty.call(s,"fileID")||!Object.prototype.hasOwnProperty.call(s,"maxAge"))throw new Error(JSON.stringify({code:f.INVALID_PARAMS,msg:"[".concat(m,".getTempFileURL] file info must include fileID and maxAge")}));n.push({fileid:s.fileID,max_age:s.maxAge})}else{if(!p(s))throw new Error(JSON.stringify({code:f.INVALID_PARAMS,msg:"[".concat(m,".getTempFileURL] invalid fileList")}));n.push({fileid:s})}return[4,this.request.send("storage.batchGetDownloadUrl",{file_list:n})];case 1:return(a=u.sent()).code?[2,v(e,null,a)]:[2,v(e,null,{fileList:a.data.download_list,requestId:a.requestId})]}}))}))},t.prototype.downloadFile=function(t,e){return u(this,void 0,void 0,(function(){var r,n,o,i,s,a;return c(this,(function(u){switch(u.label){case 0:if(r=t.fileID,!p(r))throw new Error(JSON.stringify({code:f.INVALID_PARAMS,msg:"[".concat(m,".getTempFileURL] fileID must be string")}));return[4,this.getTempFileURL.call(this,{fileList:[{fileID:r,maxAge:600}]})];case 1:return n=u.sent(),"SUCCESS"!==(o=n.fileList[0]).code?[2,v(e,o)]:(i=this.request,s=encodeURI(o.download_url),[4,i.download({url:s})]);case 2:return a=u.sent(),[2,v(e,null,a)]}}))}))},s([g({customInfo:{className:"Cloudbase",methodName:"uploadFile"},title:"上传文件失败",messages:["请确认以下各项:"," 1 - 调用 uploadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(h)]}),a("design:type",Function),a("design:paramtypes",[Object,Function]),a("design:returntype",Promise)],t.prototype,"uploadFile",null),s([g({customInfo:{className:"Cloudbase",methodName:"getUploadMetadata"},title:"获取上传元信息失败",messages:["请确认以下各项:"," 1 - 调用 getUploadMetadata() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(h)]}),a("design:type",Function),a("design:paramtypes",[Object,Function]),a("design:returntype",Promise)],t.prototype,"getUploadMetadata",null),s([g({customInfo:{className:"Cloudbase",methodName:"deleteFile"},title:"删除文件失败",messages:["请确认以下各项:"," 1 - 调用 deleteFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(h)]}),a("design:type",Function),a("design:paramtypes",[Object,Function]),a("design:returntype",Promise)],t.prototype,"deleteFile",null),s([g({customInfo:{className:"Cloudbase",methodName:"getTempFileURL"},title:"获取文件下载链接",messages:["请确认以下各项:"," 1 - 调用 getTempFileURL() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(h)]}),a("design:type",Function),a("design:paramtypes",[Object,Function]),a("design:returntype",Promise)],t.prototype,"getTempFileURL",null),s([g({customInfo:{className:"Cloudbase",methodName:"downloadFile"},title:"下载文件失败",messages:["请确认以下各项:"," 1 - 调用 downloadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(h)]}),a("design:type",Function),a("design:paramtypes",[Object,Function]),a("design:returntype",Promise)],t.prototype,"downloadFile",null),t}()),w={name:m,entity:{uploadFile:b.uploadFile,deleteFile:b.deleteFile,getTempFileURL:b.getTempFileURL,downloadFile:b.downloadFile,getUploadMetadata:b.getUploadMetadata}};try{cloudbase.registerComponent(w)}catch(t){}function _(t){try{t.registerComponent(w)}catch(t){console.warn(t)}}},8182:function(t,e,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},n.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&o(e,t,r);return i(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.useDefaultAdapter=e.useAdapters=e.RUNTIME=void 0;var a,u=s(r(4274)),c=r(5605);!function(t){t.WEB="web",t.WX_MP="wx_mp"}(a=e.RUNTIME||(e.RUNTIME={})),e.useAdapters=function(t,e){for(var r=0,o=(0,c.isArray)(t)?t:[t];r<o.length;r++){var i=o[r],s=i.isMatch,a=i.genAdapter,u=i.runtime;if(s())return{adapter:n({isMatch:s},a(e)),runtime:u}}},e.useDefaultAdapter=function(){return{adapter:u.genAdapter(),runtime:a.WEB}}},4274:function(t,e,r){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(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 r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__assign||function(){return i=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},i.apply(this,arguments)},s=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.WebRequest=e.genAdapter=void 0;var u=r(2829),c=r(5605),l=r(2946),f=function(t){function e(e){var r=t.call(this)||this,n=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=o||"请求超时",r.restrictedMethods=i||["get","post","upload","download"],r}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,r=t.file,n=t.name,o=t.method,s=t.headers,a=void 0===s?{}:s,u={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",c=new FormData;return"post"===u?(Object.keys(e).forEach((function(t){c.append(t,e[t])})),c.append("key",n),c.append("file",r),this.request(i(i({},t),{data:c,method:u}),this.restrictedMethods.includes("upload"))):this.request(i(i({},t),{method:"put",headers:a,body:r}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return s(this,void 0,void 0,(function(){var e,r,n,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,r=window.URL.createObjectURL(new Blob([e])),n=decodeURIComponent(new URL(t.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=r,o.setAttribute("download",n),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(r),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.fetch=function(t){var e;return s(this,void 0,void 0,(function(){var r,n,o,u,c,l,f,h,d,p,y,v=this;return a(this,(function(g){switch(g.label){case 0:return r=new AbortController,n=t.url,o=t.enableAbort,u=void 0!==o&&o,c=t.stream,l=void 0!==c&&c,f=t.signal,h=t.timeout,d=null!=h?h:this.timeout,f&&(f.aborted&&r.abort(),f.addEventListener("abort",(function(){return r.abort()}))),p=null,u&&d&&(p=setTimeout((function(){console.warn(v.timeoutMsg),r.abort(new Error(v.timeoutMsg))}),d)),[4,fetch(n,i(i({},t),{signal:r.signal})).then((function(t){return s(v,void 0,void 0,(function(){var e,r,n;return a(this,(function(o){switch(o.label){case 0:return clearTimeout(p),t.ok?(e=t,[3,3]):[3,1];case 1:return n=(r=Promise).reject,[4,t.json()];case 2:e=n.apply(r,[o.sent()]),o.label=3;case 3:return[2,e]}}))}))})).catch((function(t){return clearTimeout(p),Promise.reject(t)}))];case 1:return y=g.sent(),[2,{data:l?y.body:(null===(e=y.headers.get("content-type"))||void 0===e?void 0:e.includes("application/json"))?y.json():y.text(),statusCode:y.status,header:y.headers}]}}))}))},e.prototype.request=function(t,e){var r=this;void 0===e&&(e=!1);var n=String(t.method).toLowerCase()||"get";return new Promise((function(o){var i,s,a=t.url,u=t.headers,f=void 0===u?{}:u,h=t.data,d=t.responseType,p=t.withCredentials,y=t.body,v=t.onUploadProgress,g=(0,c.formatUrl)((0,l.getProtocol)(),a,"get"===n?h:{}),m=new XMLHttpRequest;m.open(n,g),d&&(m.responseType=d),Object.keys(f).forEach((function(t){m.setRequestHeader(t,f[t])})),v&&m.upload.addEventListener("progress",v),m.onreadystatechange=function(){var t={};if(4===m.readyState){var e=m.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};e.forEach((function(t){var e=t.split(": "),n=e.shift().toLowerCase(),o=e.join(": ");r[n]=o})),t.header=r,t.statusCode=m.status;try{t.data="blob"===d?m.response:JSON.parse(m.responseText)}catch(e){t.data="blob"===d?m.response:m.responseText}clearTimeout(i),o(t)}},e&&r.timeout&&(i=setTimeout((function(){console.warn(r.timeoutMsg),m.abort()}),r.timeout)),s=(0,c.isFormData)(h)?h:"application/x-www-form-urlencoded"===f["content-type"]?(0,c.toQueryString)(h):y||(h?JSON.stringify(h):void 0),p&&(m.withCredentials=!0),m.send(s)}))},e}(u.AbstractSDKRequest);e.WebRequest=f,e.genAdapter=function(){return{type:"default",root:window,reqClass:f,wsClass:WebSocket,localStorage:localStorage}}},2946: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 r="@cloudbase/js-sdk";e.setSdkName=function(t){r=t},e.getSdkName=function(){return r};var n="https:";e.setProtocol=function(t){n=t},e.getProtocol=function(){return n},e.IS_DEBUG_MODE=!1,e.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},6205: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,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.OATUH_LOGINTYPE=void 0,o(r(2946),e),o(r(6205),e),e.OATUH_LOGINTYPE="constants"},7718:function(t,e,r){"use strict";var n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.catchErrorsDecorator=void 0;var i=r(5605),s=r(794),a=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(a=-1!==navigator.userAgent.indexOf("Firefox"));var u=a?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,c=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function l(t){var e=t.err,r=t.className,n=t.methodName,o=t.sourceLink;if(!o)return null;var i,s=e.stack.split("\n"),u=a?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]\\s*\\(.*\\)$")),l=a?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]")),f=s.findIndex((function(t){return u.test(t)}));if(-1!==f){var h=s.filter((function(t,e){return e>f}));h.unshift(s[f].replace(l,"".concat(r,".").concat(n)).replace(c,o)),(i=new Error).stack="".concat(a?"@debugger":"Error","\n").concat(h.join("\n"))}return i}e.catchErrorsDecorator=function(t){var e=t.mode,r=void 0===e?"async":e,a=t.customInfo,f=void 0===a?{}:a,h=t.title,d=t.messages,p=void 0===d?[]:d;return function(t,e,a){if(s.IS_DEBUG_MODE){var d=f.className||t.constructor.name,y=f.methodName||e,v=a.value,g=function(){var t="",e=(new Error).stack.split("\n"),r=e.findIndex((function(t){return u.test(t)}));if(-1!==r){var n=c.exec(e[r+1]||"");t=n?n[0]:""}return t}();a.value="sync"===r?function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=l({err:new Error,className:d,methodName:y,sourceLink:g});try{return v.apply(this,t)}catch(t){var n=t,o=t.message,s=t.error,a=t.error_description,u={title:h||"".concat(d,".").concat(y," failed"),content:[{type:"error",body:t}]};if(o&&/^\{.*\}$/.test(o)){var c=JSON.parse(o);u.subtitle=o,c.code&&(r?(r.code=c.code,r.msg=c.msg):(t.code=c.code,t.message=c.msg),n=r||t,u.content=p.map((function(t){return{type:"info",body:t}})))}throw s&&a&&(u.subtitle=a,r?(r.code=s,r.msg=a):(t.code=s,t.message=a),n=r||t,u.content=p.map((function(t){return{type:"info",body:t}}))),(0,i.printGroupLog)(u),n}}:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n(this,void 0,void 0,(function(){var e,r,n,s,a,u,c,f;return o(this,(function(o){switch(o.label){case 0:e=l({err:new Error,className:d,methodName:y,sourceLink:g}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,v.apply(this,t)];case 2:return[2,o.sent()];case 3:throw r=o.sent(),n=r,s=r.message,a=r.error,u=r.error_description,c={title:h||"".concat(d,".").concat(y," failed"),content:[{type:"error",body:r}]},s&&/^\{.*\}$/.test(s)&&(f=JSON.parse(s),c.subtitle=f,f.code&&(e?(e.code=f.code,e.message=f.msg):(r.code=f.code,r.message=f.msg),n=e||r,c.content=p.map((function(t){return{type:"info",body:t}})))),a&&u&&(c.subtitle=u,e?(e.code=a,e.msg=u):(r.code=a,r.message=u),n=e||r,c.content=p.map((function(t){return{type:"info",body:t}}))),(0,i.printGroupLog)(c),n;case 4:return[2]}}))}))}}}}},141:function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),o(r(7718),e)},6197:function(t,e,r){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(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 r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},s=this&&this.__generator||function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.CloudbaseCache=void 0;var a=r(2829),u=r(5605),c=r(794),l=function(t){function e(e){var r=t.call(this)||this;return r.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),r}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),f=function(){function t(t){this.keys={};var e=t.persistence,r=t.platformInfo,n=void 0===r?{}:r,o=t.keys,i=void 0===o?{}:o;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||e,this.storage=function(t,e){switch(t){case"local":default:return e.localStorage?e.localStorage:((0,u.printWarn)(c.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new l(e.root));case"none":return new l(e.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(t.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),t.prototype.setStore=function(t,e,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(n))}catch(t){throw new Error(JSON.stringify({code:c.ERRORS.OPERATION_FAIL,msg:"[".concat((0,c.getSdkName)(),"][").concat(c.ERRORS.OPERATION_FAIL,"]setStore failed"),info:t}))}}else(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,r){return i(this,void 0,void 0,(function(){var n;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]),n={version:r||"localCachev1",content:e},[4,this.storage.setItem(t,JSON.stringify(n))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},t.prototype.getStore=function(t,e){var r;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!0})||void 0===r?void 0:r.tcb_token))return{IS_MP_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(t){return""}e=e||"localCachev1";var n=this.storage.getItem(t);return n&&n.indexOf(e)>=0?JSON.parse(n).content:""}(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){var r;return i(this,void 0,void 0,(function(){var n;return s(this,(function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!0})||void 0===r?void 0:r.tcb_token))return[2,{IS_MP_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(t){return[2,""]}return e=e||"localCachev1",[4,this.storage.getItem(t)];case 1:return(n=o.sent())&&n.indexOf(e)>=0?[2,JSON.parse(n).content]:[2,""]}}))}))},t.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):(0,u.printWarn)(c.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=f},9689:function(t,e,r){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(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 r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__spreadArray||function(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||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=r(5605),a=function(t,e){this.data=e||null,this.name=t};e.CloudbaseEvent=a;var u=function(t){function e(e,r){var n=t.call(this,"error",{error:e,data:r})||this;return n.error=e,n}return o(e,t),e}(a);e.IErrorEvent=u;var c=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){return function(t,e,r){r[t]=r[t]||[],r[t].push(e)}(t,e,this.listeners),this},t.prototype.off=function(t,e){return function(t,e,r){if(null==r?void 0:r[t]){var n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if((0,s.isInstanceOf)(t,u))return console.error(t.error),this;var r=(0,s.isString)(t)?new a(t,e||{}):t,n=r.name;if(this.listens(n)){r.target=this;for(var o=0,c=this.listeners[n]?i([],this.listeners[n],!0):[];o<c.length;o++)c[o].call(this,r)}return this},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}();e.CloudbaseEventEmitter=c;var l=new c;e.addEventListener=function(t,e){l.on(t,e)},e.activateEvent=function(t,e){void 0===e&&(e={}),l.fire(t,e)},e.removeEventListener=function(t,e){l.off(t,e)}},5605:function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.parseQueryString=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.formatUrl=e.generateRequestId=e.genSeqId=e.isFormData=e.isInstanceOf=e.isNull=e.isPalinObject=e.isUndefined=e.isString=e.isArray=void 0;var n=r(794);e.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},e.isString=function(t){return"string"==typeof t},e.isUndefined=function(t){return void 0===t},e.isPalinObject=function(t){return"[object Object]"===Object.prototype.toString.call(t)},e.isNull=function(t){return"[object Null]"===Object.prototype.toString.call(t)},e.isInstanceOf=function(t,e){return t instanceof e},e.isFormData=function(t){return"[object FormData]"===Object.prototype.toString.call(t)},e.genSeqId=function(){return Math.random().toString(16).slice(2)},e.generateRequestId=function(){var t=(new Date).getTime(),e=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(r){var n=16*Math.random();return t>0?(n=(t+n)%16|0,t=Math.floor(t/16)):(n=(e+n)%16|0,e=Math.floor(e/16)),("x"===r?n:7&n|8).toString(16)}))},e.formatUrl=function(t,e,r){void 0===r&&(r={});var n=/\?/.test(e),o="";return Object.keys(r).forEach((function(t){""===o?!n&&(e+="?"):o+="&",o+="".concat(t,"=").concat(encodeURIComponent(r[t]))})),/^http(s)?:\/\//.test(e+=o)?e:"".concat(t).concat(e)},e.toQueryString=function(t){void 0===t&&(t={});var e=[];return Object.keys(t).forEach((function(r){e.push("".concat(r,"=").concat(encodeURIComponent(t[r])))})),e.join("&")},e.getQuery=function(t,e){if("undefined"==typeof window)return!1;var r=e||window.location.search,n=new RegExp("(^|&)".concat(t,"=([^&]*)(&|$)")),o=r.substr(r.indexOf("?")+1).match(n);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 r=e.split("?")[0],n=[],o=-1!==e.indexOf("?")?e.split("?")[1]:"";if(""!==o){for(var i=(n=o.split("&")).length-1;i>=0;i-=1)n[i].split("=")[0]===t&&n.splice(i,1);r="".concat(r,"?").concat(n.join("&"))}return r},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 r=new Promise((function(e,r){t=function(t,n){return t?r(t):e(n)}}));return t.promise=r,t},e.execCallback=function(t,e,r){if(void 0===r&&(r=null),t&&"function"==typeof t)return t(e,r);if(e)throw e;return r},e.printWarn=function(t,e){console.warn("[".concat((0,n.getSdkName)(),"][").concat(t,"]:").concat(e))},e.printError=function(t,e){console.error({code:t,msg:"[".concat((0,n.getSdkName)(),"][").concat(t,"]:").concat(e)})},e.printInfo=function(t,e){console.log("[".concat((0,n.getSdkName)(),"][").concat(t,"]:").concat(e))},e.throwError=function(t,e){throw new Error(JSON.stringify({code:t,msg:"[".concat((0,n.getSdkName)(),"][").concat(t,"]:").concat(e)}))},e.printGroupLog=function(t){var e,r=t.title,n=t.subtitle,o=void 0===n?"":n,i=t.content,s=void 0===i?[]:i,a=t.printTrace,u=void 0!==a&&a,c=t.collapsed;void 0!==c&&c?(console.groupCollapsed||console.error)(r,o):(console.group||console.error)(r,o);for(var l=0,f=s;l<f.length;l++){var h=f[l],d=h.type,p=h.body;switch(d){case"info":console.log(p);break;case"warn":console.warn(p);break;case"error":console.error(p)}}u&&(console.trace||console.log)("stack trace:"),null===(e=console.groupEnd)||void 0===e||e.call(console)},e.sleep=function(t){return void 0===t&&(t=0),new Promise((function(e){return setTimeout(e,t)}))},e.transformPhone=function(t){return"+86".concat(t)},e.parseQueryString=function(t){t=t.replace(/^\?/,"");var e={};return t.split("&").forEach((function(t){var r=t.split("="),n=r[0],o=r[1];n=decodeURIComponent(n),o=decodeURIComponent(o),n&&(e[n]?Array.isArray(e[n])?e[n].push(o):e[n]=[e[n],o]:e[n]=o)})),e}},3616:function(t,e,r){"use strict";r.d(e,{j$:function(){return i},Fs:function(){return s},_G:function(){return n},U3:function(){return a},BM:function(){return c},RR:function(){return u},P6:function(){return o}});var n={};r.r(n),r.d(n,{vM:function(){return v},Sg:function(){return g},Fk:function(){return y},eX:function(){return h},pM:function(){return p},tC:function(){return f}});var o={};r.r(o),r.d(o,{createPromiseCallback:function(){return L},execCallback:function(){return j},formatUrl:function(){return A},genSeqId:function(){return T},generateRequestId:function(){return R},getHash:function(){return C},getQuery:function(){return x},isArray:function(){return b},isFormData:function(){return O},isInstanceOf:function(){return I},isNull:function(){return E},isPalinObject:function(){return S},isString:function(){return w},isUndefined:function(){return _},parseQueryString:function(){return H},printError:function(){return k},printGroupLog:function(){return M},printInfo:function(){return D},printWarn:function(){return U},removeParam:function(){return N},sleep:function(){return B},throwError:function(){return q},toQueryString:function(){return P},transformPhone:function(){return W}});var i={};r.r(i),r.d(i,{Fk:function(){return Q},xY:function(){return Z}});var s={};r.r(s),r.d(s,{q:function(){return nt}});var a={};r.r(a),r.d(a,{yE:function(){return at}});var u={};r.r(u),r.d(u,{P:function(){return ct},$:function(){return ut}});var c={};r.r(c),r.d(c,{D:function(){return yt}});var l="@cloudbase/js-sdk";function f(t){l=t}function h(){return l}var d="https:";function p(t){d=t}var y=!1,v="https://support.qq.com/products/148793",g={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"},m=r(2829);function b(t){return"[object Array]"===Object.prototype.toString.call(t)}function w(t){return"string"==typeof t}function _(t){return void 0===t}function S(t){return"[object Object]"===Object.prototype.toString.call(t)}function E(t){return"[object Null]"===Object.prototype.toString.call(t)}function I(t,e){return t instanceof e}function O(t){return"[object FormData]"===Object.prototype.toString.call(t)}function T(){return Math.random().toString(16).slice(2)}function R(){var t=(new Date).getTime(),e=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(r){var n=16*Math.random();return t>0?(n=(t+n)%16|0,t=Math.floor(t/16)):(n=(e+n)%16|0,e=Math.floor(e/16)),("x"===r?n:7&n|8).toString(16)}))}function A(t,e,r){void 0===r&&(r={});var n=/\?/.test(e),o="";return Object.keys(r).forEach((function(t){""===o?!n&&(e+="?"):o+="&",o+="".concat(t,"=").concat(encodeURIComponent(r[t]))})),/^http(s)?:\/\//.test(e+=o)?e:"".concat(t).concat(e)}function P(t){void 0===t&&(t={});var e=[];return Object.keys(t).forEach((function(r){e.push("".concat(r,"=").concat(encodeURIComponent(t[r])))})),e.join("&")}function x(t,e){if("undefined"==typeof window)return!1;var r=e||window.location.search,n=new RegExp("(^|&)".concat(t,"=([^&]*)(&|$)")),o=r.substr(r.indexOf("?")+1).match(n);return null!=o?o[2]:""}var C=function(t){if("undefined"==typeof window)return"";var e=window.location.hash.match(new RegExp("[#?&/]".concat(t,"=([^&#]*)")));return e?e[1]:""};function N(t,e){var r=e.split("?")[0],n=[],o=-1!==e.indexOf("?")?e.split("?")[1]:"";if(""!==o){for(var i=(n=o.split("&")).length-1;i>=0;i-=1)n[i].split("=")[0]===t&&n.splice(i,1);r="".concat(r,"?").concat(n.join("&"))}return r}function L(){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 r=new Promise((function(e,r){t=function(t,n){return t?r(t):e(n)}}));return t.promise=r,t}function j(t,e,r){if(void 0===r&&(r=null),t&&"function"==typeof t)return t(e,r);if(e)throw e;return r}function U(t,e){console.warn("[".concat(h(),"][").concat(t,"]:").concat(e))}function k(t,e){console.error({code:t,msg:"[".concat(h(),"][").concat(t,"]:").concat(e)})}function D(t,e){console.log("[".concat(h(),"][").concat(t,"]:").concat(e))}function q(t,e){throw new Error(JSON.stringify({code:t,msg:"[".concat(h(),"][").concat(t,"]:").concat(e)}))}function M(t){var e,r=t.title,n=t.subtitle,o=void 0===n?"":n,i=t.content,s=void 0===i?[]:i,a=t.printTrace,u=void 0!==a&&a,c=t.collapsed;void 0!==c&&c?(console.groupCollapsed||console.error)(r,o):(console.group||console.error)(r,o);for(var l=0,f=s;l<f.length;l++){var h=f[l],d=h.type,p=h.body;switch(d){case"info":console.log(p);break;case"warn":console.warn(p);break;case"error":console.error(p)}}u&&(console.trace||console.log)("stack trace:"),null===(e=console.groupEnd)||void 0===e||e.call(console)}var B=function(t){return void 0===t&&(t=0),new Promise((function(e){return setTimeout(e,t)}))};function W(t){return"+86".concat(t)}var F,V,H=function(t){t=t.replace(/^\?/,"");var e={};return t.split("&").forEach((function(t){var r=t.split("="),n=r[0],o=r[1];n=decodeURIComponent(n),o=decodeURIComponent(o),n&&(e[n]?Array.isArray(e[n])?e[n].push(o):e[n]=[e[n],o]:e[n]=o)})),e},G=(F=function(t,e){return F=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},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 r(){this.constructor=t}F(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),$=function(){return $=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},$.apply(this,arguments)},K=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},z=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},J=function(t){function e(e){var r=t.call(this)||this,n=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=o||"请求超时",r.restrictedMethods=i||["get","post","upload","download"],r}return G(e,t),e.prototype.get=function(t){return this.request($($({},t),{method:"get"}),this.restrictedMethods.includes("get"))},e.prototype.post=function(t){return this.request($($({},t),{method:"post"}),this.restrictedMethods.includes("post"))},e.prototype.put=function(t){return this.request($($({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,r=t.file,n=t.name,o=t.method,i=t.headers,s=void 0===i?{}:i,a={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",u=new FormData;return"post"===a?(Object.keys(e).forEach((function(t){u.append(t,e[t])})),u.append("key",n),u.append("file",r),this.request($($({},t),{data:u,method:a}),this.restrictedMethods.includes("upload"))):this.request($($({},t),{method:"put",headers:s,body:r}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return K(this,void 0,void 0,(function(){var e,r,n,o;return z(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.get($($({},t),{headers:{},responseType:"blob"}))];case 1:return e=i.sent().data,r=window.URL.createObjectURL(new Blob([e])),n=decodeURIComponent(new URL(t.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=r,o.setAttribute("download",n),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(r),document.body.removeChild(o),[3,3];case 2:return i.sent(),[3,3];case 3:return[2,new Promise((function(e){e({statusCode:200,tempFilePath:t.url})}))]}}))}))},e.prototype.fetch=function(t){var e;return K(this,void 0,void 0,(function(){var r,n,o,i,s,a,u,c,l,f,h,d=this;return z(this,(function(p){switch(p.label){case 0:return r=new AbortController,n=t.url,o=t.enableAbort,i=void 0!==o&&o,s=t.stream,a=void 0!==s&&s,u=t.signal,c=t.timeout,l=null!=c?c:this.timeout,u&&(u.aborted&&r.abort(),u.addEventListener("abort",(function(){return r.abort()}))),f=null,i&&l&&(f=setTimeout((function(){console.warn(d.timeoutMsg),r.abort(new Error(d.timeoutMsg))}),l)),[4,fetch(n,$($({},t),{signal:r.signal})).then((function(t){return K(d,void 0,void 0,(function(){var e,r,n;return z(this,(function(o){switch(o.label){case 0:return clearTimeout(f),t.ok?(e=t,[3,3]):[3,1];case 1:return n=(r=Promise).reject,[4,t.json()];case 2:e=n.apply(r,[o.sent()]),o.label=3;case 3:return[2,e]}}))}))})).catch((function(t){return clearTimeout(f),Promise.reject(t)}))];case 1:return h=p.sent(),[2,{data:a?h.body:(null===(e=h.headers.get("content-type"))||void 0===e?void 0:e.includes("application/json"))?h.json():h.text(),statusCode:h.status,header:h.headers}]}}))}))},e.prototype.request=function(t,e){var r=this;void 0===e&&(e=!1);var n=String(t.method).toLowerCase()||"get";return new Promise((function(o){var i,s,a=t.url,u=t.headers,c=void 0===u?{}:u,l=t.data,f=t.responseType,h=t.withCredentials,p=t.body,y=t.onUploadProgress,v=A(d,a,"get"===n?l:{}),g=new XMLHttpRequest;g.open(n,v),f&&(g.responseType=f),Object.keys(c).forEach((function(t){g.setRequestHeader(t,c[t])})),y&&g.upload.addEventListener("progress",y),g.onreadystatechange=function(){var t={};if(4===g.readyState){var e=g.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};e.forEach((function(t){var e=t.split(": "),n=e.shift().toLowerCase(),o=e.join(": ");r[n]=o})),t.header=r,t.statusCode=g.status;try{t.data="blob"===f?g.response:JSON.parse(g.responseText)}catch(e){t.data="blob"===f?g.response:g.responseText}clearTimeout(i),o(t)}},e&&r.timeout&&(i=setTimeout((function(){console.warn(r.timeoutMsg),g.abort()}),r.timeout)),s=O(l)?l:"application/x-www-form-urlencoded"===c["content-type"]?P(l):p||(l?JSON.stringify(l):void 0),h&&(g.withCredentials=!0),g.send(s)}))},e}(m.AbstractSDKRequest),Y=function(){return Y=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Y.apply(this,arguments)};function Q(t,e){for(var r=0,n=b(t)?t:[t];r<n.length;r++){var o=n[r],i=o.isMatch,s=o.genAdapter,a=o.runtime;if(i())return{adapter:Y({isMatch:i},s(e)),runtime:a}}}function Z(){return{adapter:{type:"default",root:window,reqClass:J,wsClass:WebSocket,localStorage:localStorage},runtime:V.WEB}}!function(t){t.WEB="web",t.WX_MP="wx_mp"}(V||(V={}));var X=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),tt=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},et=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},rt=function(t){function e(e){var r=t.call(this)||this;return r.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),r}return X(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}(m.AbstractStorage),nt=function(){function t(t){this.keys={};var e=t.persistence,r=t.platformInfo,n=void 0===r?{}:r,o=t.keys,i=void 0===o?{}:o;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||e,this.storage=function(t,e){switch(t){case"local":default:return e.localStorage?e.localStorage:(U(g.INVALID_PARAMS,"localStorage is not supported on current platform"),new rt(e.root));case"none":return new rt(e.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(t.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),t.prototype.setStore=function(t,e,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(n))}catch(t){throw new Error(JSON.stringify({code:g.OPERATION_FAIL,msg:"[".concat(h(),"][").concat(g.OPERATION_FAIL,"]setStore failed"),info:t}))}}else U(g.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,r){return tt(this,void 0,void 0,(function(){var n;return et(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]),n={version:r||"localCachev1",content:e},[4,this.storage.setItem(t,JSON.stringify(n))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},t.prototype.getStore=function(t,e){var r;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!0})||void 0===r?void 0:r.tcb_token))return{IS_MP_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(t){return""}e=e||"localCachev1";var n=this.storage.getItem(t);return n&&n.indexOf(e)>=0?JSON.parse(n).content:""}U(g.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){var r;return tt(this,void 0,void 0,(function(){var n;return et(this,(function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!0})||void 0===r?void 0:r.tcb_token))return[2,{IS_MP_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(t){return[2,""]}return e=e||"localCachev1",[4,this.storage.getItem(t)];case 1:return(n=o.sent())&&n.indexOf(e)>=0?[2,JSON.parse(n).content]:[2,""]}}))}))},t.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):U(g.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},t.prototype.removeStoreAsync=function(t){return tt(this,void 0,void 0,(function(){return et(this,(function(e){switch(e.label){case 0:return[4,this.storage.removeItem(t)];case 1:return e.sent(),[2]}}))}))},t}(),ot=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),it=function(t,e){this.data=e||null,this.name=t},st=function(t){function e(e,r){var n=t.call(this,"error",{error:e,data:r})||this;return n.error=e,n}return ot(e,t),e}(it),at=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){return function(t,e,r){r[t]=r[t]||[],r[t].push(e)}(t,e,this.listeners),this},t.prototype.off=function(t,e){return function(t,e,r){if(null==r?void 0:r[t]){var n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if(I(t,st))return console.error(t.error),this;var r=w(t)?new it(t,e||{}):t,n=r.name;if(this.listens(n)){r.target=this;for(var o=0,i=this.listeners[n]?function(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))}([],this.listeners[n],!0):[];o<i.length;o++)i[o].call(this,r)}return this},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}();new at;var ut=new at,ct="lang_change",lt=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},ft=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},ht=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(ht=-1!==navigator.userAgent.indexOf("Firefox"));var dt=ht?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,pt=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function yt(t){var e=t.mode,r=void 0===e?"async":e,n=t.customInfo,o=void 0===n?{}:n,i=t.title,s=t.messages,a=void 0===s?[]:s;return function(t,e,n){if(y){var s=o.className||t.constructor.name,u=o.methodName||e,c=n.value,l=function(){var t="",e=(new Error).stack.split("\n"),r=e.findIndex((function(t){return dt.test(t)}));if(-1!==r){var n=pt.exec(e[r+1]||"");t=n?n[0]:""}return t}();n.value="sync"===r?function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=vt({err:new Error,className:s,methodName:u,sourceLink:l});try{return c.apply(this,t)}catch(t){var n=t,o=t.message,f=t.error,h=t.error_description,d={title:i||"".concat(s,".").concat(u," failed"),content:[{type:"error",body:t}]};if(o&&/^\{.*\}$/.test(o)){var p=JSON.parse(o);d.subtitle=o,p.code&&(r?(r.code=p.code,r.msg=p.msg):(t.code=p.code,t.message=p.msg),n=r||t,d.content=a.map((function(t){return{type:"info",body:t}})))}throw f&&h&&(d.subtitle=h,r?(r.code=f,r.msg=h):(t.code=f,t.message=h),n=r||t,d.content=a.map((function(t){return{type:"info",body:t}}))),M(d),n}}:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return lt(this,void 0,void 0,(function(){var e,r,n,o,f,h,d,p;return ft(this,(function(y){switch(y.label){case 0:e=vt({err:new Error,className:s,methodName:u,sourceLink:l}),y.label=1;case 1:return y.trys.push([1,3,,4]),[4,c.apply(this,t)];case 2:return[2,y.sent()];case 3:throw r=y.sent(),n=r,o=r.message,f=r.error,h=r.error_description,d={title:i||"".concat(s,".").concat(u," failed"),content:[{type:"error",body:r}]},o&&/^\{.*\}$/.test(o)&&(p=JSON.parse(o),d.subtitle=p,p.code&&(e?(e.code=p.code,e.message=p.msg):(r.code=p.code,r.message=p.msg),n=e||r,d.content=a.map((function(t){return{type:"info",body:t}})))),f&&h&&(d.subtitle=h,e?(e.code=f,e.msg=h):(r.code=f,r.message=h),n=e||r,d.content=a.map((function(t){return{type:"info",body:t}}))),M(d),n;case 4:return[2]}}))}))}}}}function vt(t){var e=t.err,r=t.className,n=t.methodName,o=t.sourceLink;if(!o)return null;var i,s=e.stack.split("\n"),a=ht?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]\\s*\\(.*\\)$")),u=ht?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]")),c=s.findIndex((function(t){return a.test(t)}));if(-1!==c){var l=s.filter((function(t,e){return e>c}));l.unshift(s[c].replace(u,"".concat(r,".").concat(n)).replace(pt,o)),(i=new Error).stack="".concat(ht?"@debugger":"Error","\n").concat(l.join("\n"))}return i}function gt(t){this.message=t}function mt(t){this.message=t}gt.prototype=new Error,gt.prototype.name="InvalidCharacterError","undefined"!=typeof window&&window.atob&&window.atob.bind(window),mt.prototype=new Error,mt.prototype.name="InvalidTokenError"},9515:function(t,e,r){var n=r(8761)(r(7772),"DataView");t.exports=n},9612:function(t,e,r){var n=r(2118),o=r(6909),i=r(8138),s=r(4174),a=r(7942);function u(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}u.prototype.clear=n,u.prototype.delete=o,u.prototype.get=i,u.prototype.has=s,u.prototype.set=a,t.exports=u},235:function(t,e,r){var n=r(3945),o=r(1846),i=r(8028),s=r(2344),a=r(4769);function u(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}u.prototype.clear=n,u.prototype.delete=o,u.prototype.get=i,u.prototype.has=s,u.prototype.set=a,t.exports=u},326:function(t,e,r){var n=r(8761)(r(7772),"Map");t.exports=n},6738:function(t,e,r){var n=r(2411),o=r(6417),i=r(6928),s=r(9493),a=r(4150);function u(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}u.prototype.clear=n,u.prototype.delete=o,u.prototype.get=i,u.prototype.has=s,u.prototype.set=a,t.exports=u},2760:function(t,e,r){var n=r(8761)(r(7772),"Promise");t.exports=n},2143:function(t,e,r){var n=r(8761)(r(7772),"Set");t.exports=n},6571:function(t,e,r){var n=r(235),o=r(5243),i=r(2858),s=r(4417),a=r(8605),u=r(1418);function c(t){var e=this.__data__=new n(t);this.size=e.size}c.prototype.clear=o,c.prototype.delete=i,c.prototype.get=s,c.prototype.has=a,c.prototype.set=u,t.exports=c},857:function(t,e,r){var n=r(7772).Symbol;t.exports=n},9162:function(t,e,r){var n=r(7772).Uint8Array;t.exports=n},3215:function(t,e,r){var n=r(8761)(r(7772),"WeakMap");t.exports=n},2517:function(t){t.exports=function(t,e){for(var r=-1,n=null==t?0:t.length;++r<n&&!1!==e(t[r],r,t););return t}},7552:function(t){t.exports=function(t,e){for(var r=-1,n=null==t?0:t.length,o=0,i=[];++r<n;){var s=t[r];e(s,r,t)&&(i[o++]=s)}return i}},1634:function(t,e,r){var n=r(6473),o=r(9631),i=r(6152),s=r(3226),a=r(9045),u=r(7598),c=Object.prototype.hasOwnProperty;t.exports=function(t,e){var r=i(t),l=!r&&o(t),f=!r&&!l&&s(t),h=!r&&!l&&!f&&u(t),d=r||l||f||h,p=d?n(t.length,String):[],y=p.length;for(var v in t)!e&&!c.call(t,v)||d&&("length"==v||f&&("offset"==v||"parent"==v)||h&&("buffer"==v||"byteLength"==v||"byteOffset"==v)||a(v,y))||p.push(v);return p}},343:function(t){t.exports=function(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r<n;)o[r]=e(t[r],r,t);return o}},5067:function(t){t.exports=function(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}},91:function(t,e,r){var n=r(3940),o=r(1225),i=Object.prototype.hasOwnProperty;t.exports=function(t,e,r){var s=t[e];i.call(t,e)&&o(s,r)&&(void 0!==r||e in t)||n(t,e,r)}},2218:function(t,e,r){var n=r(1225);t.exports=function(t,e){for(var r=t.length;r--;)if(n(t[r][0],e))return r;return-1}},7993:function(t,e,r){var n=r(752),o=r(249);t.exports=function(t,e){return t&&n(e,o(e),t)}},5906:function(t,e,r){var n=r(752),o=r(8582);t.exports=function(t,e){return t&&n(e,o(e),t)}},3940:function(t,e,r){var n=r(3043);t.exports=function(t,e,r){"__proto__"==e&&n?n(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}},8874:function(t,e,r){var n=r(6571),o=r(2517),i=r(91),s=r(7993),a=r(5906),u=r(2175),c=r(1522),l=r(7680),f=r(9987),h=r(3483),d=r(6939),p=r(940),y=r(9917),v=r(8222),g=r(8725),m=r(6152),b=r(3226),w=r(4714),_=r(9259),S=r(3679),E=r(249),I=r(8582),O="[object Arguments]",T="[object Function]",R="[object Object]",A={};A[O]=A["[object Array]"]=A["[object ArrayBuffer]"]=A["[object DataView]"]=A["[object Boolean]"]=A["[object Date]"]=A["[object Float32Array]"]=A["[object Float64Array]"]=A["[object Int8Array]"]=A["[object Int16Array]"]=A["[object Int32Array]"]=A["[object Map]"]=A["[object Number]"]=A[R]=A["[object RegExp]"]=A["[object Set]"]=A["[object String]"]=A["[object Symbol]"]=A["[object Uint8Array]"]=A["[object Uint8ClampedArray]"]=A["[object Uint16Array]"]=A["[object Uint32Array]"]=!0,A["[object Error]"]=A[T]=A["[object WeakMap]"]=!1,t.exports=function t(e,r,P,x,C,N){var L,j=1&r,U=2&r,k=4&r;if(P&&(L=C?P(e,x,C,N):P(e)),void 0!==L)return L;if(!_(e))return e;var D=m(e);if(D){if(L=y(e),!j)return c(e,L)}else{var q=p(e),M=q==T||"[object GeneratorFunction]"==q;if(b(e))return u(e,j);if(q==R||q==O||M&&!C){if(L=U||M?{}:g(e),!j)return U?f(e,a(L,e)):l(e,s(L,e))}else{if(!A[q])return C?e:{};L=v(e,q,j)}}N||(N=new n);var B=N.get(e);if(B)return B;N.set(e,L),S(e)?e.forEach((function(n){L.add(t(n,r,P,n,e,N))})):w(e)&&e.forEach((function(n,o){L.set(o,t(n,r,P,o,e,N))}));var W=D?void 0:(k?U?d:h:U?I:E)(e);return o(W||e,(function(n,o){W&&(n=e[o=n]),i(L,o,t(n,r,P,o,e,N))})),L}},9413:function(t,e,r){var n=r(9259),o=Object.create,i=function(){function t(){}return function(e){if(!n(e))return{};if(o)return o(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();t.exports=i},3324:function(t,e,r){var n=r(7297),o=r(3812);t.exports=function(t,e){for(var r=0,i=(e=n(e,t)).length;null!=t&&r<i;)t=t[o(e[r++])];return r&&r==i?t:void 0}},1897:function(t,e,r){var n=r(5067),o=r(6152);t.exports=function(t,e,r){var i=e(t);return o(t)?i:n(i,r(t))}},3366:function(t,e,r){var n=r(857),o=r(2107),i=r(7157),s=n?n.toStringTag:void 0;t.exports=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":s&&s in Object(t)?o(t):i(t)}},5183:function(t,e,r){var n=r(3366),o=r(5125);t.exports=function(t){return o(t)&&"[object Arguments]"==n(t)}},4511:function(t,e,r){var n=r(940),o=r(5125);t.exports=function(t){return o(t)&&"[object Map]"==n(t)}},6840:function(t,e,r){var n=r(1049),o=r(7394),i=r(9259),s=r(7035),a=/^\[object .+?Constructor\]$/,u=Function.prototype,c=Object.prototype,l=u.toString,f=c.hasOwnProperty,h=RegExp("^"+l.call(f).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");t.exports=function(t){return!(!i(t)||o(t))&&(n(t)?h:a).test(s(t))}},8436:function(t,e,r){var n=r(940),o=r(5125);t.exports=function(t){return o(t)&&"[object Set]"==n(t)}},5522:function(t,e,r){var n=r(3366),o=r(1158),i=r(5125),s={};s["[object Float32Array]"]=s["[object Float64Array]"]=s["[object Int8Array]"]=s["[object Int16Array]"]=s["[object Int32Array]"]=s["[object Uint8Array]"]=s["[object Uint8ClampedArray]"]=s["[object Uint16Array]"]=s["[object Uint32Array]"]=!0,s["[object Arguments]"]=s["[object Array]"]=s["[object ArrayBuffer]"]=s["[object Boolean]"]=s["[object DataView]"]=s["[object Date]"]=s["[object Error]"]=s["[object Function]"]=s["[object Map]"]=s["[object Number]"]=s["[object Object]"]=s["[object RegExp]"]=s["[object Set]"]=s["[object String]"]=s["[object WeakMap]"]=!1,t.exports=function(t){return i(t)&&o(t.length)&&!!s[n(t)]}},6411:function(t,e,r){var n=r(6001),o=r(4248),i=Object.prototype.hasOwnProperty;t.exports=function(t){if(!n(t))return o(t);var e=[];for(var r in Object(t))i.call(t,r)&&"constructor"!=r&&e.push(r);return e}},8390:function(t,e,r){var n=r(9259),o=r(6001),i=r(2966),s=Object.prototype.hasOwnProperty;t.exports=function(t){if(!n(t))return i(t);var e=o(t),r=[];for(var a in t)("constructor"!=a||!e&&s.call(t,a))&&r.push(a);return r}},2857:function(t,e,r){var n=r(91),o=r(7297),i=r(9045),s=r(9259),a=r(3812);t.exports=function(t,e,r,u){if(!s(t))return t;for(var c=-1,l=(e=o(e,t)).length,f=l-1,h=t;null!=h&&++c<l;){var d=a(e[c]),p=r;if("__proto__"===d||"constructor"===d||"prototype"===d)return t;if(c!=f){var y=h[d];void 0===(p=u?u(y,d,h):void 0)&&(p=s(y)?y:i(e[c+1])?[]:{})}n(h,d,p),h=h[d]}return t}},9872:function(t){t.exports=function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n<o;)i[n]=t[n+e];return i}},6473:function(t){t.exports=function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}},1054:function(t,e,r){var n=r(857),o=r(343),i=r(6152),s=r(4795),a=n?n.prototype:void 0,u=a?a.toString:void 0;t.exports=function t(e){if("string"==typeof e)return e;if(i(e))return o(e,t)+"";if(s(e))return u?u.call(e):"";var r=e+"";return"0"==r&&1/e==-1/0?"-0":r}},7826:function(t){t.exports=function(t){return function(e){return t(e)}}},9078:function(t,e,r){var n=r(7297),o=r(6974),i=r(2721),s=r(3812);t.exports=function(t,e){return e=n(e,t),null==(t=i(t,e))||delete t[s(o(e))]}},7297:function(t,e,r){var n=r(6152),o=r(1401),i=r(4452),s=r(6188);t.exports=function(t,e){return n(t)?t:o(t,e)?[t]:i(s(t))}},9882:function(t,e,r){var n=r(9162);t.exports=function(t){var e=new t.constructor(t.byteLength);return new n(e).set(new n(t)),e}},2175:function(t,e,r){t=r.nmd(t);var n=r(7772),o=e&&!e.nodeType&&e,i=o&&t&&!t.nodeType&&t,s=i&&i.exports===o?n.Buffer:void 0,a=s?s.allocUnsafe:void 0;t.exports=function(t,e){if(e)return t.slice();var r=t.length,n=a?a(r):new t.constructor(r);return t.copy(n),n}},4727:function(t,e,r){var n=r(9882);t.exports=function(t,e){var r=e?n(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}},6058:function(t){var e=/\w*$/;t.exports=function(t){var r=new t.constructor(t.source,e.exec(t));return r.lastIndex=t.lastIndex,r}},169:function(t,e,r){var n=r(857),o=n?n.prototype:void 0,i=o?o.valueOf:void 0;t.exports=function(t){return i?Object(i.call(t)):{}}},6190:function(t,e,r){var n=r(9882);t.exports=function(t,e){var r=e?n(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}},1522:function(t){t.exports=function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}},752:function(t,e,r){var n=r(91),o=r(3940);t.exports=function(t,e,r,i){var s=!r;r||(r={});for(var a=-1,u=e.length;++a<u;){var c=e[a],l=i?i(r[c],t[c],c,r,t):void 0;void 0===l&&(l=t[c]),s?o(r,c,l):n(r,c,l)}return r}},7680:function(t,e,r){var n=r(752),o=r(633);t.exports=function(t,e){return n(t,o(t),e)}},9987:function(t,e,r){var n=r(752),o=r(2680);t.exports=function(t,e){return n(t,o(t),e)}},4019:function(t,e,r){var n=r(7772)["__core-js_shared__"];t.exports=n},3043:function(t,e,r){var n=r(8761),o=function(){try{var t=n(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();t.exports=o},1242:function(t,e,r){var n="object"==typeof r.g&&r.g&&r.g.Object===Object&&r.g;t.exports=n},3483:function(t,e,r){var n=r(1897),o=r(633),i=r(249);t.exports=function(t){return n(t,i,o)}},6939:function(t,e,r){var n=r(1897),o=r(2680),i=r(8582);t.exports=function(t){return n(t,i,o)}},7937:function(t,e,r){var n=r(8304);t.exports=function(t,e){var r=t.__data__;return n(e)?r["string"==typeof e?"string":"hash"]:r.map}},8761:function(t,e,r){var n=r(6840),o=r(8109);t.exports=function(t,e){var r=o(t,e);return n(r)?r:void 0}},7353:function(t,e,r){var n=r(241)(Object.getPrototypeOf,Object);t.exports=n},2107:function(t,e,r){var n=r(857),o=Object.prototype,i=o.hasOwnProperty,s=o.toString,a=n?n.toStringTag:void 0;t.exports=function(t){var e=i.call(t,a),r=t[a];try{t[a]=void 0;var n=!0}catch(t){}var o=s.call(t);return n&&(e?t[a]=r:delete t[a]),o}},633:function(t,e,r){var n=r(7552),o=r(981),i=Object.prototype.propertyIsEnumerable,s=Object.getOwnPropertySymbols,a=s?function(t){return null==t?[]:(t=Object(t),n(s(t),(function(e){return i.call(t,e)})))}:o;t.exports=a},2680:function(t,e,r){var n=r(5067),o=r(7353),i=r(633),s=r(981),a=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)n(e,i(t)),t=o(t);return e}:s;t.exports=a},940:function(t,e,r){var n=r(9515),o=r(326),i=r(2760),s=r(2143),a=r(3215),u=r(3366),c=r(7035),l="[object Map]",f="[object Promise]",h="[object Set]",d="[object WeakMap]",p="[object DataView]",y=c(n),v=c(o),g=c(i),m=c(s),b=c(a),w=u;(n&&w(new n(new ArrayBuffer(1)))!=p||o&&w(new o)!=l||i&&w(i.resolve())!=f||s&&w(new s)!=h||a&&w(new a)!=d)&&(w=function(t){var e=u(t),r="[object Object]"==e?t.constructor:void 0,n=r?c(r):"";if(n)switch(n){case y:return p;case v:return l;case g:return f;case m:return h;case b:return d}return e}),t.exports=w},8109:function(t){t.exports=function(t,e){return null==t?void 0:t[e]}},2118:function(t,e,r){var n=r(9191);t.exports=function(){this.__data__=n?n(null):{},this.size=0}},6909:function(t){t.exports=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}},8138:function(t,e,r){var n=r(9191),o=Object.prototype.hasOwnProperty;t.exports=function(t){var e=this.__data__;if(n){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return o.call(e,t)?e[t]:void 0}},4174:function(t,e,r){var n=r(9191),o=Object.prototype.hasOwnProperty;t.exports=function(t){var e=this.__data__;return n?void 0!==e[t]:o.call(e,t)}},7942:function(t,e,r){var n=r(9191);t.exports=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=n&&void 0===e?"__lodash_hash_undefined__":e,this}},9917:function(t){var e=Object.prototype.hasOwnProperty;t.exports=function(t){var r=t.length,n=new t.constructor(r);return r&&"string"==typeof t[0]&&e.call(t,"index")&&(n.index=t.index,n.input=t.input),n}},8222:function(t,e,r){var n=r(9882),o=r(4727),i=r(6058),s=r(169),a=r(6190);t.exports=function(t,e,r){var u=t.constructor;switch(e){case"[object ArrayBuffer]":return n(t);case"[object Boolean]":case"[object Date]":return new u(+t);case"[object DataView]":return o(t,r);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return a(t,r);case"[object Map]":case"[object Set]":return new u;case"[object Number]":case"[object String]":return new u(t);case"[object RegExp]":return i(t);case"[object Symbol]":return s(t)}}},8725:function(t,e,r){var n=r(9413),o=r(7353),i=r(6001);t.exports=function(t){return"function"!=typeof t.constructor||i(t)?{}:n(o(t))}},9045:function(t){var e=/^(?:0|[1-9]\d*)$/;t.exports=function(t,r){var n=typeof t;return!!(r=null==r?9007199254740991:r)&&("number"==n||"symbol"!=n&&e.test(t))&&t>-1&&t%1==0&&t<r}},1401:function(t,e,r){var n=r(6152),o=r(4795),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;t.exports=function(t,e){if(n(t))return!1;var r=typeof t;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!o(t))||s.test(t)||!i.test(t)||null!=e&&t in Object(e)}},8304:function(t){t.exports=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}},7394:function(t,e,r){var n,o=r(4019),i=(n=/[^.]+$/.exec(o&&o.keys&&o.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"";t.exports=function(t){return!!i&&i in t}},6001:function(t){var e=Object.prototype;t.exports=function(t){var r=t&&t.constructor;return t===("function"==typeof r&&r.prototype||e)}},3945:function(t){t.exports=function(){this.__data__=[],this.size=0}},1846:function(t,e,r){var n=r(2218),o=Array.prototype.splice;t.exports=function(t){var e=this.__data__,r=n(e,t);return!(r<0||(r==e.length-1?e.pop():o.call(e,r,1),--this.size,0))}},8028:function(t,e,r){var n=r(2218);t.exports=function(t){var e=this.__data__,r=n(e,t);return r<0?void 0:e[r][1]}},2344:function(t,e,r){var n=r(2218);t.exports=function(t){return n(this.__data__,t)>-1}},4769:function(t,e,r){var n=r(2218);t.exports=function(t,e){var r=this.__data__,o=n(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}},2411:function(t,e,r){var n=r(9612),o=r(235),i=r(326);t.exports=function(){this.size=0,this.__data__={hash:new n,map:new(i||o),string:new n}}},6417:function(t,e,r){var n=r(7937);t.exports=function(t){var e=n(this,t).delete(t);return this.size-=e?1:0,e}},6928:function(t,e,r){var n=r(7937);t.exports=function(t){return n(this,t).get(t)}},9493:function(t,e,r){var n=r(7937);t.exports=function(t){return n(this,t).has(t)}},4150:function(t,e,r){var n=r(7937);t.exports=function(t,e){var r=n(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}},7777:function(t,e,r){var n=r(733);t.exports=function(t){var e=n(t,(function(t){return 500===r.size&&r.clear(),t})),r=e.cache;return e}},9191:function(t,e,r){var n=r(8761)(Object,"create");t.exports=n},4248:function(t,e,r){var n=r(241)(Object.keys,Object);t.exports=n},2966:function(t){t.exports=function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}},4146:function(t,e,r){t=r.nmd(t);var n=r(1242),o=e&&!e.nodeType&&e,i=o&&t&&!t.nodeType&&t,s=i&&i.exports===o&&n.process,a=function(){try{return i&&i.require&&i.require("util").types||s&&s.binding&&s.binding("util")}catch(t){}}();t.exports=a},7157:function(t){var e=Object.prototype.toString;t.exports=function(t){return e.call(t)}},241:function(t){t.exports=function(t,e){return function(r){return t(e(r))}}},2721:function(t,e,r){var n=r(3324),o=r(9872);t.exports=function(t,e){return e.length<2?t:n(t,o(e,0,-1))}},7772:function(t,e,r){var n=r(1242),o="object"==typeof self&&self&&self.Object===Object&&self,i=n||o||Function("return this")();t.exports=i},5243:function(t,e,r){var n=r(235);t.exports=function(){this.__data__=new n,this.size=0}},2858:function(t){t.exports=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}},4417:function(t){t.exports=function(t){return this.__data__.get(t)}},8605:function(t){t.exports=function(t){return this.__data__.has(t)}},1418:function(t,e,r){var n=r(235),o=r(326),i=r(6738);t.exports=function(t,e){var r=this.__data__;if(r instanceof n){var s=r.__data__;if(!o||s.length<199)return s.push([t,e]),this.size=++r.size,this;r=this.__data__=new i(s)}return r.set(t,e),this.size=r.size,this}},4452:function(t,e,r){var n=r(7777),o=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,i=/\\(\\)?/g,s=n((function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(o,(function(t,r,n,o){e.push(n?o.replace(i,"$1"):r||t)})),e}));t.exports=s},3812:function(t,e,r){var n=r(4795);t.exports=function(t){if("string"==typeof t||n(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}},7035:function(t){var e=Function.prototype.toString;t.exports=function(t){if(null!=t){try{return e.call(t)}catch(t){}try{return t+""}catch(t){}}return""}},9850:function(t,e,r){var n=r(8874);t.exports=function(t){return n(t,5)}},1225:function(t){t.exports=function(t,e){return t===e||t!=t&&e!=e}},9631:function(t,e,r){var n=r(5183),o=r(5125),i=Object.prototype,s=i.hasOwnProperty,a=i.propertyIsEnumerable,u=n(function(){return arguments}())?n:function(t){return o(t)&&s.call(t,"callee")&&!a.call(t,"callee")};t.exports=u},6152:function(t){var e=Array.isArray;t.exports=e},7878:function(t,e,r){var n=r(1049),o=r(1158);t.exports=function(t){return null!=t&&o(t.length)&&!n(t)}},3226:function(t,e,r){t=r.nmd(t);var n=r(7772),o=r(6330),i=e&&!e.nodeType&&e,s=i&&t&&!t.nodeType&&t,a=s&&s.exports===i?n.Buffer:void 0,u=(a?a.isBuffer:void 0)||o;t.exports=u},1049:function(t,e,r){var n=r(3366),o=r(9259);t.exports=function(t){if(!o(t))return!1;var e=n(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}},1158:function(t){t.exports=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}},4714:function(t,e,r){var n=r(4511),o=r(7826),i=r(4146),s=i&&i.isMap,a=s?o(s):n;t.exports=a},9259:function(t){t.exports=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}},5125:function(t){t.exports=function(t){return null!=t&&"object"==typeof t}},3679:function(t,e,r){var n=r(8436),o=r(7826),i=r(4146),s=i&&i.isSet,a=s?o(s):n;t.exports=a},4795:function(t,e,r){var n=r(3366),o=r(5125);t.exports=function(t){return"symbol"==typeof t||o(t)&&"[object Symbol]"==n(t)}},7598:function(t,e,r){var n=r(5522),o=r(7826),i=r(4146),s=i&&i.isTypedArray,a=s?o(s):n;t.exports=a},249:function(t,e,r){var n=r(1634),o=r(6411),i=r(7878);t.exports=function(t){return i(t)?n(t):o(t)}},8582:function(t,e,r){var n=r(1634),o=r(8390),i=r(7878);t.exports=function(t){return i(t)?n(t,!0):o(t)}},6974:function(t){t.exports=function(t){var e=null==t?0:t.length;return e?t[e-1]:void 0}},733:function(t,e,r){var n=r(6738);function o(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var r=function(){var n=arguments,o=e?e.apply(this,n):n[0],i=r.cache;if(i.has(o))return i.get(o);var s=t.apply(this,n);return r.cache=i.set(o,s)||i,s};return r.cache=new(o.Cache||n),r}o.Cache=n,t.exports=o},6765:function(t,e,r){var n=r(2857);t.exports=function(t,e,r){return null==t?t:n(t,e,r)}},981:function(t){t.exports=function(){return[]}},6330:function(t){t.exports=function(){return!1}},6188:function(t,e,r){var n=r(1054);t.exports=function(t){return null==t?"":n(t)}},7195:function(t,e,r){var n=r(9078);t.exports=function(t,e){return null==t||n(t,e)}},5047:function(t){var e=function(t){"use strict";var e,r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var i=e&&e.prototype instanceof g?e:g,s=Object.create(i.prototype),a=new x(n||[]);return o(s,"_invoke",{value:T(t,r,a)}),s}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function g(){}function m(){}function b(){}var w={};c(w,s,(function(){return this}));var _=Object.getPrototypeOf,S=_&&_(_(C([])));S&&S!==r&&n.call(S,s)&&(w=S);var E=b.prototype=g.prototype=Object.create(w);function I(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(o,i,s,a){var u=f(t[o],t,i);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,s,a)}),(function(t){r("throw",t,s,a)})):e.resolve(l).then((function(t){c.value=t,s(c)}),(function(t){return r("throw",t,s,a)}))}a(u.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function T(t,r,n){var o=h;return function(i,s){if(o===p)throw new Error("Generator is already running");if(o===y){if("throw"===i)throw s;return{value:e,done:!0}}for(n.method=i,n.arg=s;;){var a=n.delegate;if(a){var u=R(a,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=p;var c=f(t,r,n);if("normal"===c.type){if(o=n.done?y:d,c.arg===v)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(o=y,n.method="throw",n.arg=c.arg)}}}function R(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,R(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var i=f(o,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,v;var s=i.arg;return s?s.done?(r[t.resultName]=s.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,v):s:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function x(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function C(t){if(null!=t){var r=t[s];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}throw new TypeError(typeof t+" is not iterable")}return m.prototype=b,o(E,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:m,configurable:!0}),m.displayName=c(b,u,"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,b):(t.__proto__=b,c(t,u,"GeneratorFunction")),t.prototype=Object.create(E),t},t.awrap=function(t){return{__await:t}},I(O.prototype),c(O.prototype,a,(function(){return this})),t.AsyncIterator=O,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var s=new O(l(e,r,n,o),i);return t.isGeneratorFunction(r)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},I(E),c(E,u,"Generator"),c(E,s,(function(){return this})),c(E,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=C,x.prototype={constructor:x,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(P),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=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 r=this;function o(n,o){return a.type="throw",a.arg=t,r.next=n,o&&(r.method="next",r.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 u=n.call(s,"catchLoc"),c=n.call(s,"finallyLoc");if(u&&c){if(this.prev<s.catchLoc)return o(s.catchLoc,!0);if(this.prev<s.finallyLoc)return o(s.finallyLoc)}else if(u){if(this.prev<s.catchLoc)return o(s.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return o(s.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.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,v):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),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),P(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;P(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:C(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),v}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}},4410:function(t,e,r){var n,o;void 0===(o="function"==typeof(n=function(){"use strict";var t=void 0!==r.g?r.g:self;if(void 0!==t.TextEncoder&&void 0!==t.TextDecoder)return{TextEncoder:t.TextEncoder,TextDecoder:t.TextDecoder};var e=["utf8","utf-8","unicode-1-1-utf-8"];return{TextEncoder:function(t){if(e.indexOf(t)<0&&null!=t)throw new RangeError("Invalid encoding type. Only utf-8 is supported");this.encoding="utf-8",this.encode=function(t){if("string"!=typeof t)throw new TypeError("passed argument must be of type string");var e=unescape(encodeURIComponent(t)),r=new Uint8Array(e.length);return e.split("").forEach((function(t,e){r[e]=t.charCodeAt(0)})),r}},TextDecoder:function(t,r){if(e.indexOf(t)<0&&null!=t)throw new RangeError("Invalid encoding type. Only utf-8 is supported");if(this.encoding="utf-8",this.ignoreBOM=!1,this.fatal=void 0!==r&&"fatal"in r&&r.fatal,"boolean"!=typeof this.fatal)throw new TypeError("fatal flag must be boolean");this.decode=function(t,e){if(void 0===t)return"";if("boolean"!=typeof(void 0!==e&&"stream"in e&&e.stream))throw new TypeError("stream option must be boolean");if(ArrayBuffer.isView(t)){var r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength),n=new Array(r.length);return r.forEach((function(t,e){n[e]=String.fromCharCode(t)})),decodeURIComponent(escape(n.join("")))}throw new TypeError("passed argument must be an array buffer view")}}}})?n.apply(e,[]):n)||(t.exports=o)},5993:function(t,e,r){"use strict";function n(){}function o(t){return"object"==typeof t&&null!==t||"function"==typeof t}r.d(e,{GJ:function(){return rn},Pz:function(){return Lr}});const i=n;function s(t,e){try{Object.defineProperty(t,"name",{value:e,configurable:!0})}catch(t){}}const a=Promise,u=Promise.resolve.bind(a),c=Promise.prototype.then,l=Promise.reject.bind(a),f=u;function h(t){return new a(t)}function d(t){return h((e=>e(t)))}function p(t){return l(t)}function y(t,e,r){return c.call(t,e,r)}function v(t,e,r){y(y(t,e,r),void 0,i)}function g(t,e){v(t,e)}function m(t,e){v(t,void 0,e)}function b(t,e,r){return y(t,e,r)}function w(t){y(t,void 0,i)}let _=t=>{if("function"==typeof queueMicrotask)_=queueMicrotask;else{const t=d(void 0);_=e=>y(t,e)}return _(t)};function S(t,e,r){if("function"!=typeof t)throw new TypeError("Argument is not a function");return Function.prototype.apply.call(t,e,r)}function E(t,e,r){try{return d(S(t,e,r))}catch(t){return p(t)}}class I{constructor(){this._cursor=0,this._size=0,this._front={_elements:[],_next:void 0},this._back=this._front,this._cursor=0,this._size=0}get length(){return this._size}push(t){const e=this._back;let r=e;16383===e._elements.length&&(r={_elements:[],_next:void 0}),e._elements.push(t),r!==e&&(this._back=r,e._next=r),++this._size}shift(){const t=this._front;let e=t;const r=this._cursor;let n=r+1;const o=t._elements,i=o[r];return 16384===n&&(e=t._next,n=0),--this._size,this._cursor=n,t!==e&&(this._front=e),o[r]=void 0,i}forEach(t){let e=this._cursor,r=this._front,n=r._elements;for(;!(e===n.length&&void 0===r._next||e===n.length&&(r=r._next,n=r._elements,e=0,0===n.length));)t(n[e]),++e}peek(){const t=this._front,e=this._cursor;return t._elements[e]}}const O=Symbol("[[AbortSteps]]"),T=Symbol("[[ErrorSteps]]"),R=Symbol("[[CancelSteps]]"),A=Symbol("[[PullSteps]]"),P=Symbol("[[ReleaseSteps]]");function x(t,e){t._ownerReadableStream=e,e._reader=t,"readable"===e._state?j(t):"closed"===e._state?function(t){j(t),D(t)}(t):U(t,e._storedError)}function C(t,e){return Mr(t._ownerReadableStream,e)}function N(t){const e=t._ownerReadableStream;"readable"===e._state?k(t,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")):function(t){U(t,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness"))}(t),e._readableStreamController[P](),e._reader=void 0,t._ownerReadableStream=void 0}function L(t){return new TypeError("Cannot "+t+" a stream using a released reader")}function j(t){t._closedPromise=h(((e,r)=>{t._closedPromise_resolve=e,t._closedPromise_reject=r}))}function U(t,e){j(t),k(t,e)}function k(t,e){void 0!==t._closedPromise_reject&&(w(t._closedPromise),t._closedPromise_reject(e),t._closedPromise_resolve=void 0,t._closedPromise_reject=void 0)}function D(t){void 0!==t._closedPromise_resolve&&(t._closedPromise_resolve(void 0),t._closedPromise_resolve=void 0,t._closedPromise_reject=void 0)}const q=Number.isFinite||function(t){return"number"==typeof t&&isFinite(t)},M=Math.trunc||function(t){return t<0?Math.ceil(t):Math.floor(t)};function B(t,e){if(void 0!==t&&"object"!=typeof(r=t)&&"function"!=typeof r)throw new TypeError(`${e} is not an object.`);var r}function W(t,e){if("function"!=typeof t)throw new TypeError(`${e} is not a function.`)}function F(t,e){if(!function(t){return"object"==typeof t&&null!==t||"function"==typeof t}(t))throw new TypeError(`${e} is not an object.`)}function V(t,e,r){if(void 0===t)throw new TypeError(`Parameter ${e} is required in '${r}'.`)}function H(t,e,r){if(void 0===t)throw new TypeError(`${e} is required in '${r}'.`)}function G(t){return Number(t)}function $(t){return 0===t?0:t}function K(t,e){const r=Number.MAX_SAFE_INTEGER;let n=Number(t);if(n=$(n),!q(n))throw new TypeError(`${e} is not a finite number`);if(n=function(t){return $(M(t))}(n),n<0||n>r)throw new TypeError(`${e} is outside the accepted range of 0 to ${r}, inclusive`);return q(n)&&0!==n?n:0}function z(t,e){if(!Dr(t))throw new TypeError(`${e} is not a ReadableStream.`)}function J(t){return new tt(t)}function Y(t,e){t._reader._readRequests.push(e)}function Q(t,e,r){const n=t._reader._readRequests.shift();r?n._closeSteps():n._chunkSteps(e)}function Z(t){return t._reader._readRequests.length}function X(t){const e=t._reader;return void 0!==e&&!!et(e)}class tt{constructor(t){if(V(t,1,"ReadableStreamDefaultReader"),z(t,"First parameter"),qr(t))throw new TypeError("This stream has already been locked for exclusive reading by another reader");x(this,t),this._readRequests=new I}get closed(){return et(this)?this._closedPromise:p(ot("closed"))}cancel(t=void 0){return et(this)?void 0===this._ownerReadableStream?p(L("cancel")):C(this,t):p(ot("cancel"))}read(){if(!et(this))return p(ot("read"));if(void 0===this._ownerReadableStream)return p(L("read from"));let t,e;const r=h(((r,n)=>{t=r,e=n}));return rt(this,{_chunkSteps:e=>t({value:e,done:!1}),_closeSteps:()=>t({value:void 0,done:!0}),_errorSteps:t=>e(t)}),r}releaseLock(){if(!et(this))throw ot("releaseLock");void 0!==this._ownerReadableStream&&function(t){N(t),nt(t,new TypeError("Reader was released"))}(this)}}function et(t){return!!o(t)&&!!Object.prototype.hasOwnProperty.call(t,"_readRequests")&&t instanceof tt}function rt(t,e){const r=t._ownerReadableStream;r._disturbed=!0,"closed"===r._state?e._closeSteps():"errored"===r._state?e._errorSteps(r._storedError):r._readableStreamController[A](e)}function nt(t,e){const r=t._readRequests;t._readRequests=new I,r.forEach((t=>{t._errorSteps(e)}))}function ot(t){return new TypeError(`ReadableStreamDefaultReader.prototype.${t} can only be used on a ReadableStreamDefaultReader`)}var it,st,at;function ut(t){return t.slice()}function ct(t,e,r,n,o){new Uint8Array(t).set(new Uint8Array(r,n,o),e)}Object.defineProperties(tt.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),s(tt.prototype.cancel,"cancel"),s(tt.prototype.read,"read"),s(tt.prototype.releaseLock,"releaseLock"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(tt.prototype,Symbol.toStringTag,{value:"ReadableStreamDefaultReader",configurable:!0});let lt=t=>(lt="function"==typeof t.transfer?t=>t.transfer():"function"==typeof structuredClone?t=>structuredClone(t,{transfer:[t]}):t=>t,lt(t)),ft=t=>(ft="boolean"==typeof t.detached?t=>t.detached:t=>0===t.byteLength,ft(t));function ht(t,e,r){if(t.slice)return t.slice(e,r);const n=r-e,o=new ArrayBuffer(n);return ct(o,0,t,e,n),o}function dt(t,e){const r=t[e];if(null!=r){if("function"!=typeof r)throw new TypeError(`${String(e)} is not a function`);return r}}function pt(t){try{const e=t.done,r=t.value;return y(f(r),(t=>({done:e,value:t})))}catch(t){return p(t)}}const yt=null!==(at=null!==(it=Symbol.asyncIterator)&&void 0!==it?it:null===(st=Symbol.for)||void 0===st?void 0:st.call(Symbol,"Symbol.asyncIterator"))&&void 0!==at?at:"@@asyncIterator";function vt(t,e="sync",r){if(void 0===r)if("async"===e){if(void 0===(r=dt(t,yt)))return function(t){const e={next(){let e;try{e=gt(t)}catch(t){return p(t)}return pt(e)},return(e){let r;try{const n=dt(t.iterator,"return");if(void 0===n)return d({done:!0,value:e});r=S(n,t.iterator,[e])}catch(t){return p(t)}return o(r)?pt(r):p(new TypeError("The iterator.return() method must return an object"))}};return{iterator:e,nextMethod:e.next,done:!1}}(vt(t,"sync",dt(t,Symbol.iterator)))}else r=dt(t,Symbol.iterator);if(void 0===r)throw new TypeError("The object is not iterable");const n=S(r,t,[]);if(!o(n))throw new TypeError("The iterator method must return an object");return{iterator:n,nextMethod:n.next,done:!1}}function gt(t){const e=S(t.nextMethod,t.iterator,[]);if(!o(e))throw new TypeError("The iterator.next() method must return an object");return e}class mt{constructor(t,e){this._ongoingPromise=void 0,this._isFinished=!1,this._reader=t,this._preventCancel=e}next(){const t=()=>this._nextSteps();return this._ongoingPromise=this._ongoingPromise?b(this._ongoingPromise,t,t):t(),this._ongoingPromise}return(t){const e=()=>this._returnSteps(t);return this._ongoingPromise?b(this._ongoingPromise,e,e):e()}_nextSteps(){if(this._isFinished)return Promise.resolve({value:void 0,done:!0});const t=this._reader;let e,r;const n=h(((t,n)=>{e=t,r=n}));return rt(t,{_chunkSteps:t=>{this._ongoingPromise=void 0,_((()=>e({value:t,done:!1})))},_closeSteps:()=>{this._ongoingPromise=void 0,this._isFinished=!0,N(t),e({value:void 0,done:!0})},_errorSteps:e=>{this._ongoingPromise=void 0,this._isFinished=!0,N(t),r(e)}}),n}_returnSteps(t){if(this._isFinished)return Promise.resolve({value:t,done:!0});this._isFinished=!0;const e=this._reader;if(!this._preventCancel){const r=C(e,t);return N(e),b(r,(()=>({value:t,done:!0})))}return N(e),d({value:t,done:!0})}}const bt={next(){return wt(this)?this._asyncIteratorImpl.next():p(_t("next"))},return(t){return wt(this)?this._asyncIteratorImpl.return(t):p(_t("return"))},[yt](){return this}};function wt(t){if(!o(t))return!1;if(!Object.prototype.hasOwnProperty.call(t,"_asyncIteratorImpl"))return!1;try{return t._asyncIteratorImpl instanceof mt}catch(t){return!1}}function _t(t){return new TypeError(`ReadableStreamAsyncIterator.${t} can only be used on a ReadableSteamAsyncIterator`)}Object.defineProperty(bt,yt,{enumerable:!1});const St=Number.isNaN||function(t){return t!=t};function Et(t){const e=ht(t.buffer,t.byteOffset,t.byteOffset+t.byteLength);return new Uint8Array(e)}function It(t){const e=t._queue.shift();return t._queueTotalSize-=e.size,t._queueTotalSize<0&&(t._queueTotalSize=0),e.value}function Ot(t,e,r){if("number"!=typeof(n=r)||St(n)||n<0||r===1/0)throw new RangeError("Size must be a finite, non-NaN, non-negative number.");var n;t._queue.push({value:e,size:r}),t._queueTotalSize+=r}function Tt(t){t._queue=new I,t._queueTotalSize=0}function Rt(t){return t===DataView}class At{constructor(){throw new TypeError("Illegal constructor")}get view(){if(!Ct(this))throw re("view");return this._view}respond(t){if(!Ct(this))throw re("respond");if(V(t,1,"respond"),t=K(t,"First parameter"),void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");if(ft(this._view.buffer))throw new TypeError("The BYOB request's buffer has been detached and so cannot be used as a response");Xt(this._associatedReadableByteStreamController,t)}respondWithNewView(t){if(!Ct(this))throw re("respondWithNewView");if(V(t,1,"respondWithNewView"),!ArrayBuffer.isView(t))throw new TypeError("You can only respond with array buffer views");if(void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");if(ft(t.buffer))throw new TypeError("The given view's buffer has been detached and so cannot be used as a response");te(this._associatedReadableByteStreamController,t)}}Object.defineProperties(At.prototype,{respond:{enumerable:!0},respondWithNewView:{enumerable:!0},view:{enumerable:!0}}),s(At.prototype.respond,"respond"),s(At.prototype.respondWithNewView,"respondWithNewView"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(At.prototype,Symbol.toStringTag,{value:"ReadableStreamBYOBRequest",configurable:!0});class Pt{constructor(){throw new TypeError("Illegal constructor")}get byobRequest(){if(!xt(this))throw ne("byobRequest");return Qt(this)}get desiredSize(){if(!xt(this))throw ne("desiredSize");return Zt(this)}close(){if(!xt(this))throw ne("close");if(this._closeRequested)throw new TypeError("The stream has already been closed; do not close it again!");const t=this._controlledReadableByteStream._state;if("readable"!==t)throw new TypeError(`The stream (in ${t} state) is not in the readable state and cannot be closed`);Kt(this)}enqueue(t){if(!xt(this))throw ne("enqueue");if(V(t,1,"enqueue"),!ArrayBuffer.isView(t))throw new TypeError("chunk must be an array buffer view");if(0===t.byteLength)throw new TypeError("chunk must have non-zero byteLength");if(0===t.buffer.byteLength)throw new TypeError("chunk's buffer must have non-zero byteLength");if(this._closeRequested)throw new TypeError("stream is closed or draining");const e=this._controlledReadableByteStream._state;if("readable"!==e)throw new TypeError(`The stream (in ${e} state) is not in the readable state and cannot be enqueued to`);zt(this,t)}error(t=void 0){if(!xt(this))throw ne("error");Jt(this,t)}[R](t){Lt(this),Tt(this);const e=this._cancelAlgorithm(t);return $t(this),e}[A](t){const e=this._controlledReadableByteStream;if(this._queueTotalSize>0)return void Yt(this,t);const r=this._autoAllocateChunkSize;if(void 0!==r){let n;try{n=new ArrayBuffer(r)}catch(e){return void t._errorSteps(e)}const o={buffer:n,bufferByteLength:r,byteOffset:0,byteLength:r,bytesFilled:0,minimumFill:1,elementSize:1,viewConstructor:Uint8Array,readerType:"default"};this._pendingPullIntos.push(o)}Y(e,t),Nt(this)}[P](){if(this._pendingPullIntos.length>0){const t=this._pendingPullIntos.peek();t.readerType="none",this._pendingPullIntos=new I,this._pendingPullIntos.push(t)}}}function xt(t){return!!o(t)&&!!Object.prototype.hasOwnProperty.call(t,"_controlledReadableByteStream")&&t instanceof Pt}function Ct(t){return!!o(t)&&!!Object.prototype.hasOwnProperty.call(t,"_associatedReadableByteStreamController")&&t instanceof At}function Nt(t){const e=function(t){const e=t._controlledReadableByteStream;return"readable"===e._state&&(!t._closeRequested&&(!!t._started&&(!!(X(e)&&Z(e)>0)||(!!(ue(e)&&ae(e)>0)||Zt(t)>0))))}(t);e&&(t._pulling?t._pullAgain=!0:(t._pulling=!0,v(t._pullAlgorithm(),(()=>(t._pulling=!1,t._pullAgain&&(t._pullAgain=!1,Nt(t)),null)),(e=>(Jt(t,e),null)))))}function Lt(t){Ft(t),t._pendingPullIntos=new I}function jt(t,e){let r=!1;"closed"===t._state&&(r=!0);const n=Ut(e);"default"===e.readerType?Q(t,n,r):function(t,e,r){const n=t._reader._readIntoRequests.shift();r?n._closeSteps(e):n._chunkSteps(e)}(t,n,r)}function Ut(t){const e=t.bytesFilled,r=t.elementSize;return new t.viewConstructor(t.buffer,t.byteOffset,e/r)}function kt(t,e,r,n){t._queue.push({buffer:e,byteOffset:r,byteLength:n}),t._queueTotalSize+=n}function Dt(t,e,r,n){let o;try{o=ht(e,r,r+n)}catch(e){throw Jt(t,e),e}kt(t,o,0,n)}function qt(t,e){e.bytesFilled>0&&Dt(t,e.buffer,e.byteOffset,e.bytesFilled),Gt(t)}function Mt(t,e){const r=Math.min(t._queueTotalSize,e.byteLength-e.bytesFilled),n=e.bytesFilled+r;let o=r,i=!1;const s=n-n%e.elementSize;s>=e.minimumFill&&(o=s-e.bytesFilled,i=!0);const a=t._queue;for(;o>0;){const r=a.peek(),n=Math.min(o,r.byteLength),i=e.byteOffset+e.bytesFilled;ct(e.buffer,i,r.buffer,r.byteOffset,n),r.byteLength===n?a.shift():(r.byteOffset+=n,r.byteLength-=n),t._queueTotalSize-=n,Bt(0,n,e),o-=n}return i}function Bt(t,e,r){r.bytesFilled+=e}function Wt(t){0===t._queueTotalSize&&t._closeRequested?($t(t),Br(t._controlledReadableByteStream)):Nt(t)}function Ft(t){null!==t._byobRequest&&(t._byobRequest._associatedReadableByteStreamController=void 0,t._byobRequest._view=null,t._byobRequest=null)}function Vt(t){for(;t._pendingPullIntos.length>0;){if(0===t._queueTotalSize)return;const e=t._pendingPullIntos.peek();Mt(t,e)&&(Gt(t),jt(t._controlledReadableByteStream,e))}}function Ht(t,e){const r=t._pendingPullIntos.peek();Ft(t),"closed"===t._controlledReadableByteStream._state?function(t,e){"none"===e.readerType&&Gt(t);const r=t._controlledReadableByteStream;if(ue(r))for(;ae(r)>0;)jt(r,Gt(t))}(t,r):function(t,e,r){if(Bt(0,e,r),"none"===r.readerType)return qt(t,r),void Vt(t);if(r.bytesFilled<r.minimumFill)return;Gt(t);const n=r.bytesFilled%r.elementSize;if(n>0){const e=r.byteOffset+r.bytesFilled;Dt(t,r.buffer,e-n,n)}r.bytesFilled-=n,jt(t._controlledReadableByteStream,r),Vt(t)}(t,e,r),Nt(t)}function Gt(t){return t._pendingPullIntos.shift()}function $t(t){t._pullAlgorithm=void 0,t._cancelAlgorithm=void 0}function Kt(t){const e=t._controlledReadableByteStream;if(!t._closeRequested&&"readable"===e._state)if(t._queueTotalSize>0)t._closeRequested=!0;else{if(t._pendingPullIntos.length>0){const e=t._pendingPullIntos.peek();if(e.bytesFilled%e.elementSize!=0){const e=new TypeError("Insufficient bytes to fill elements in the given buffer");throw Jt(t,e),e}}$t(t),Br(e)}}function zt(t,e){const r=t._controlledReadableByteStream;if(t._closeRequested||"readable"!==r._state)return;const{buffer:n,byteOffset:o,byteLength:i}=e;if(ft(n))throw new TypeError("chunk's buffer is detached and so cannot be enqueued");const s=lt(n);if(t._pendingPullIntos.length>0){const e=t._pendingPullIntos.peek();if(ft(e.buffer))throw new TypeError("The BYOB request's buffer has been detached and so cannot be filled with an enqueued chunk");Ft(t),e.buffer=lt(e.buffer),"none"===e.readerType&&qt(t,e)}X(r)?(function(t){const e=t._controlledReadableByteStream._reader;for(;e._readRequests.length>0;){if(0===t._queueTotalSize)return;Yt(t,e._readRequests.shift())}}(t),0===Z(r)?kt(t,s,o,i):(t._pendingPullIntos.length>0&&Gt(t),Q(r,new Uint8Array(s,o,i),!1))):ue(r)?(kt(t,s,o,i),Vt(t)):kt(t,s,o,i),Nt(t)}function Jt(t,e){const r=t._controlledReadableByteStream;"readable"===r._state&&(Lt(t),Tt(t),$t(t),Wr(r,e))}function Yt(t,e){const r=t._queue.shift();t._queueTotalSize-=r.byteLength,Wt(t);const n=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);e._chunkSteps(n)}function Qt(t){if(null===t._byobRequest&&t._pendingPullIntos.length>0){const e=t._pendingPullIntos.peek(),r=new Uint8Array(e.buffer,e.byteOffset+e.bytesFilled,e.byteLength-e.bytesFilled),n=Object.create(At.prototype);!function(t,e,r){t._associatedReadableByteStreamController=e,t._view=r}(n,t,r),t._byobRequest=n}return t._byobRequest}function Zt(t){const e=t._controlledReadableByteStream._state;return"errored"===e?null:"closed"===e?0:t._strategyHWM-t._queueTotalSize}function Xt(t,e){const r=t._pendingPullIntos.peek();if("closed"===t._controlledReadableByteStream._state){if(0!==e)throw new TypeError("bytesWritten must be 0 when calling respond() on a closed stream")}else{if(0===e)throw new TypeError("bytesWritten must be greater than 0 when calling respond() on a readable stream");if(r.bytesFilled+e>r.byteLength)throw new RangeError("bytesWritten out of range")}r.buffer=lt(r.buffer),Ht(t,e)}function te(t,e){const r=t._pendingPullIntos.peek();if("closed"===t._controlledReadableByteStream._state){if(0!==e.byteLength)throw new TypeError("The view's length must be 0 when calling respondWithNewView() on a closed stream")}else if(0===e.byteLength)throw new TypeError("The view's length must be greater than 0 when calling respondWithNewView() on a readable stream");if(r.byteOffset+r.bytesFilled!==e.byteOffset)throw new RangeError("The region specified by view does not match byobRequest");if(r.bufferByteLength!==e.buffer.byteLength)throw new RangeError("The buffer of view has different capacity than byobRequest");if(r.bytesFilled+e.byteLength>r.byteLength)throw new RangeError("The region specified by view is larger than byobRequest");const n=e.byteLength;r.buffer=lt(e.buffer),Ht(t,n)}function ee(t,e,r,n,o,i,s){e._controlledReadableByteStream=t,e._pullAgain=!1,e._pulling=!1,e._byobRequest=null,e._queue=e._queueTotalSize=void 0,Tt(e),e._closeRequested=!1,e._started=!1,e._strategyHWM=i,e._pullAlgorithm=n,e._cancelAlgorithm=o,e._autoAllocateChunkSize=s,e._pendingPullIntos=new I,t._readableStreamController=e,v(d(r()),(()=>(e._started=!0,Nt(e),null)),(t=>(Jt(e,t),null)))}function re(t){return new TypeError(`ReadableStreamBYOBRequest.prototype.${t} can only be used on a ReadableStreamBYOBRequest`)}function ne(t){return new TypeError(`ReadableByteStreamController.prototype.${t} can only be used on a ReadableByteStreamController`)}function oe(t,e){if("byob"!=(t=`${t}`))throw new TypeError(`${e} '${t}' is not a valid enumeration value for ReadableStreamReaderMode`);return t}function ie(t){return new ce(t)}function se(t,e){t._reader._readIntoRequests.push(e)}function ae(t){return t._reader._readIntoRequests.length}function ue(t){const e=t._reader;return void 0!==e&&!!le(e)}Object.defineProperties(Pt.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},byobRequest:{enumerable:!0},desiredSize:{enumerable:!0}}),s(Pt.prototype.close,"close"),s(Pt.prototype.enqueue,"enqueue"),s(Pt.prototype.error,"error"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Pt.prototype,Symbol.toStringTag,{value:"ReadableByteStreamController",configurable:!0});class ce{constructor(t){if(V(t,1,"ReadableStreamBYOBReader"),z(t,"First parameter"),qr(t))throw new TypeError("This stream has already been locked for exclusive reading by another reader");if(!xt(t._readableStreamController))throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");x(this,t),this._readIntoRequests=new I}get closed(){return le(this)?this._closedPromise:p(de("closed"))}cancel(t=void 0){return le(this)?void 0===this._ownerReadableStream?p(L("cancel")):C(this,t):p(de("cancel"))}read(t,e={}){if(!le(this))return p(de("read"));if(!ArrayBuffer.isView(t))return p(new TypeError("view must be an array buffer view"));if(0===t.byteLength)return p(new TypeError("view must have non-zero byteLength"));if(0===t.buffer.byteLength)return p(new TypeError("view's buffer must have non-zero byteLength"));if(ft(t.buffer))return p(new TypeError("view's buffer has been detached"));let r;try{r=function(t,e){var r;return B(t,e),{min:K(null!==(r=null==t?void 0:t.min)&&void 0!==r?r:1,`${e} has member 'min' that`)}}(e,"options")}catch(t){return p(t)}const n=r.min;if(0===n)return p(new TypeError("options.min must be greater than 0"));if(function(t){return Rt(t.constructor)}(t)){if(n>t.byteLength)return p(new RangeError("options.min must be less than or equal to view's byteLength"))}else if(n>t.length)return p(new RangeError("options.min must be less than or equal to view's length"));if(void 0===this._ownerReadableStream)return p(L("read from"));let o,i;const s=h(((t,e)=>{o=t,i=e}));return fe(this,t,n,{_chunkSteps:t=>o({value:t,done:!1}),_closeSteps:t=>o({value:t,done:!0}),_errorSteps:t=>i(t)}),s}releaseLock(){if(!le(this))throw de("releaseLock");void 0!==this._ownerReadableStream&&function(t){N(t),he(t,new TypeError("Reader was released"))}(this)}}function le(t){return!!o(t)&&!!Object.prototype.hasOwnProperty.call(t,"_readIntoRequests")&&t instanceof ce}function fe(t,e,r,n){const o=t._ownerReadableStream;o._disturbed=!0,"errored"===o._state?n._errorSteps(o._storedError):function(t,e,r,n){const o=t._controlledReadableByteStream,i=e.constructor,s=function(t){return Rt(t)?1:t.BYTES_PER_ELEMENT}(i),{byteOffset:a,byteLength:u}=e,c=r*s;let l;try{l=lt(e.buffer)}catch(t){return void n._errorSteps(t)}const f={buffer:l,bufferByteLength:l.byteLength,byteOffset:a,byteLength:u,bytesFilled:0,minimumFill:c,elementSize:s,viewConstructor:i,readerType:"byob"};if(t._pendingPullIntos.length>0)return t._pendingPullIntos.push(f),void se(o,n);if("closed"!==o._state){if(t._queueTotalSize>0){if(Mt(t,f)){const e=Ut(f);return Wt(t),void n._chunkSteps(e)}if(t._closeRequested){const e=new TypeError("Insufficient bytes to fill elements in the given buffer");return Jt(t,e),void n._errorSteps(e)}}t._pendingPullIntos.push(f),se(o,n),Nt(t)}else{const t=new i(f.buffer,f.byteOffset,0);n._closeSteps(t)}}(o._readableStreamController,e,r,n)}function he(t,e){const r=t._readIntoRequests;t._readIntoRequests=new I,r.forEach((t=>{t._errorSteps(e)}))}function de(t){return new TypeError(`ReadableStreamBYOBReader.prototype.${t} can only be used on a ReadableStreamBYOBReader`)}function pe(t,e){const{highWaterMark:r}=t;if(void 0===r)return e;if(St(r)||r<0)throw new RangeError("Invalid highWaterMark");return r}function ye(t){const{size:e}=t;return e||(()=>1)}function ve(t,e){B(t,e);const r=null==t?void 0:t.highWaterMark,n=null==t?void 0:t.size;return{highWaterMark:void 0===r?void 0:G(r),size:void 0===n?void 0:ge(n,`${e} has member 'size' that`)}}function ge(t,e){return W(t,e),e=>G(t(e))}function me(t,e,r){return W(t,r),r=>E(t,e,[r])}function be(t,e,r){return W(t,r),()=>E(t,e,[])}function we(t,e,r){return W(t,r),r=>S(t,e,[r])}function _e(t,e,r){return W(t,r),(r,n)=>E(t,e,[r,n])}function Se(t,e){if(!Re(t))throw new TypeError(`${e} is not a WritableStream.`)}Object.defineProperties(ce.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),s(ce.prototype.cancel,"cancel"),s(ce.prototype.read,"read"),s(ce.prototype.releaseLock,"releaseLock"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(ce.prototype,Symbol.toStringTag,{value:"ReadableStreamBYOBReader",configurable:!0});const Ee="function"==typeof AbortController;class Ie{constructor(t={},e={}){void 0===t?t=null:F(t,"First parameter");const r=ve(e,"Second parameter"),n=function(t,e){B(t,e);const r=null==t?void 0:t.abort,n=null==t?void 0:t.close,o=null==t?void 0:t.start,i=null==t?void 0:t.type,s=null==t?void 0:t.write;return{abort:void 0===r?void 0:me(r,t,`${e} has member 'abort' that`),close:void 0===n?void 0:be(n,t,`${e} has member 'close' that`),start:void 0===o?void 0:we(o,t,`${e} has member 'start' that`),write:void 0===s?void 0:_e(s,t,`${e} has member 'write' that`),type:i}}(t,"First parameter");if(Te(this),void 0!==n.type)throw new RangeError("Invalid type is specified");const o=ye(r);!function(t,e,r,n){const o=Object.create(He.prototype);let i,s,a,u;i=void 0!==e.start?()=>e.start(o):()=>{},s=void 0!==e.write?t=>e.write(t,o):()=>d(void 0),a=void 0!==e.close?()=>e.close():()=>d(void 0),u=void 0!==e.abort?t=>e.abort(t):()=>d(void 0),$e(t,o,i,s,a,u,r,n)}(this,n,pe(r,1),o)}get locked(){if(!Re(this))throw Xe("locked");return Ae(this)}abort(t=void 0){return Re(this)?Ae(this)?p(new TypeError("Cannot abort a stream that already has a writer")):Pe(this,t):p(Xe("abort"))}close(){return Re(this)?Ae(this)?p(new TypeError("Cannot close a stream that already has a writer")):je(this)?p(new TypeError("Cannot close an already-closing stream")):xe(this):p(Xe("close"))}getWriter(){if(!Re(this))throw Xe("getWriter");return Oe(this)}}function Oe(t){return new De(t)}function Te(t){t._state="writable",t._storedError=void 0,t._writer=void 0,t._writableStreamController=void 0,t._writeRequests=new I,t._inFlightWriteRequest=void 0,t._closeRequest=void 0,t._inFlightCloseRequest=void 0,t._pendingAbortRequest=void 0,t._backpressure=!1}function Re(t){return!!o(t)&&!!Object.prototype.hasOwnProperty.call(t,"_writableStreamController")&&t instanceof Ie}function Ae(t){return void 0!==t._writer}function Pe(t,e){var r;if("closed"===t._state||"errored"===t._state)return d(void 0);t._writableStreamController._abortReason=e,null===(r=t._writableStreamController._abortController)||void 0===r||r.abort(e);const n=t._state;if("closed"===n||"errored"===n)return d(void 0);if(void 0!==t._pendingAbortRequest)return t._pendingAbortRequest._promise;let o=!1;"erroring"===n&&(o=!0,e=void 0);const i=h(((r,n)=>{t._pendingAbortRequest={_promise:void 0,_resolve:r,_reject:n,_reason:e,_wasAlreadyErroring:o}}));return t._pendingAbortRequest._promise=i,o||Ne(t,e),i}function xe(t){const e=t._state;if("closed"===e||"errored"===e)return p(new TypeError(`The stream (in ${e} state) is not in the writable state and cannot be closed`));const r=h(((e,r)=>{const n={_resolve:e,_reject:r};t._closeRequest=n})),n=t._writer;var o;return void 0!==n&&t._backpressure&&"writable"===e&&fr(n),Ot(o=t._writableStreamController,Ve,0),Je(o),r}function Ce(t,e){"writable"!==t._state?Le(t):Ne(t,e)}function Ne(t,e){const r=t._writableStreamController;t._state="erroring",t._storedError=e;const n=t._writer;void 0!==n&&Be(n,e),!function(t){return void 0!==t._inFlightWriteRequest||void 0!==t._inFlightCloseRequest}(t)&&r._started&&Le(t)}function Le(t){t._state="errored",t._writableStreamController[T]();const e=t._storedError;if(t._writeRequests.forEach((t=>{t._reject(e)})),t._writeRequests=new I,void 0===t._pendingAbortRequest)return void Ue(t);const r=t._pendingAbortRequest;if(t._pendingAbortRequest=void 0,r._wasAlreadyErroring)return r._reject(e),void Ue(t);v(t._writableStreamController[O](r._reason),(()=>(r._resolve(),Ue(t),null)),(e=>(r._reject(e),Ue(t),null)))}function je(t){return void 0!==t._closeRequest||void 0!==t._inFlightCloseRequest}function Ue(t){void 0!==t._closeRequest&&(t._closeRequest._reject(t._storedError),t._closeRequest=void 0);const e=t._writer;void 0!==e&&ir(e,t._storedError)}function ke(t,e){const r=t._writer;void 0!==r&&e!==t._backpressure&&(e?function(t){ar(t)}(r):fr(r)),t._backpressure=e}Object.defineProperties(Ie.prototype,{abort:{enumerable:!0},close:{enumerable:!0},getWriter:{enumerable:!0},locked:{enumerable:!0}}),s(Ie.prototype.abort,"abort"),s(Ie.prototype.close,"close"),s(Ie.prototype.getWriter,"getWriter"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Ie.prototype,Symbol.toStringTag,{value:"WritableStream",configurable:!0});class De{constructor(t){if(V(t,1,"WritableStreamDefaultWriter"),Se(t,"First parameter"),Ae(t))throw new TypeError("This stream has already been locked for exclusive writing by another writer");this._ownerWritableStream=t,t._writer=this;const e=t._state;if("writable"===e)!je(t)&&t._backpressure?ar(this):cr(this),nr(this);else if("erroring"===e)ur(this,t._storedError),nr(this);else if("closed"===e)cr(this),nr(this),sr(this);else{const e=t._storedError;ur(this,e),or(this,e)}}get closed(){return qe(this)?this._closedPromise:p(er("closed"))}get desiredSize(){if(!qe(this))throw er("desiredSize");if(void 0===this._ownerWritableStream)throw rr("desiredSize");return function(t){const e=t._ownerWritableStream,r=e._state;return"errored"===r||"erroring"===r?null:"closed"===r?0:ze(e._writableStreamController)}(this)}get ready(){return qe(this)?this._readyPromise:p(er("ready"))}abort(t=void 0){return qe(this)?void 0===this._ownerWritableStream?p(rr("abort")):function(t,e){return Pe(t._ownerWritableStream,e)}(this,t):p(er("abort"))}close(){if(!qe(this))return p(er("close"));const t=this._ownerWritableStream;return void 0===t?p(rr("close")):je(t)?p(new TypeError("Cannot close an already-closing stream")):Me(this)}releaseLock(){if(!qe(this))throw er("releaseLock");void 0!==this._ownerWritableStream&&We(this)}write(t=void 0){return qe(this)?void 0===this._ownerWritableStream?p(rr("write to")):Fe(this,t):p(er("write"))}}function qe(t){return!!o(t)&&!!Object.prototype.hasOwnProperty.call(t,"_ownerWritableStream")&&t instanceof De}function Me(t){return xe(t._ownerWritableStream)}function Be(t,e){"pending"===t._readyPromiseState?lr(t,e):function(t,e){ur(t,e)}(t,e)}function We(t){const e=t._ownerWritableStream,r=new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");Be(t,r),function(t,e){"pending"===t._closedPromiseState?ir(t,e):function(t,e){or(t,e)}(t,e)}(t,r),e._writer=void 0,t._ownerWritableStream=void 0}function Fe(t,e){const r=t._ownerWritableStream,n=r._writableStreamController,o=function(t,e){try{return t._strategySizeAlgorithm(e)}catch(e){return Ye(t,e),1}}(n,e);if(r!==t._ownerWritableStream)return p(rr("write to"));const i=r._state;if("errored"===i)return p(r._storedError);if(je(r)||"closed"===i)return p(new TypeError("The stream is closing or closed and cannot be written to"));if("erroring"===i)return p(r._storedError);const s=function(t){return h(((e,r)=>{const n={_resolve:e,_reject:r};t._writeRequests.push(n)}))}(r);return function(t,e,r){try{Ot(t,e,r)}catch(e){return void Ye(t,e)}const n=t._controlledWritableStream;je(n)||"writable"!==n._state||ke(n,Qe(t)),Je(t)}(n,e,o),s}Object.defineProperties(De.prototype,{abort:{enumerable:!0},close:{enumerable:!0},releaseLock:{enumerable:!0},write:{enumerable:!0},closed:{enumerable:!0},desiredSize:{enumerable:!0},ready:{enumerable:!0}}),s(De.prototype.abort,"abort"),s(De.prototype.close,"close"),s(De.prototype.releaseLock,"releaseLock"),s(De.prototype.write,"write"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(De.prototype,Symbol.toStringTag,{value:"WritableStreamDefaultWriter",configurable:!0});const Ve={};class He{constructor(){throw new TypeError("Illegal constructor")}get abortReason(){if(!Ge(this))throw tr("abortReason");return this._abortReason}get signal(){if(!Ge(this))throw tr("signal");if(void 0===this._abortController)throw new TypeError("WritableStreamDefaultController.prototype.signal is not supported");return this._abortController.signal}error(t=void 0){if(!Ge(this))throw tr("error");"writable"===this._controlledWritableStream._state&&Ze(this,t)}[O](t){const e=this._abortAlgorithm(t);return Ke(this),e}[T](){Tt(this)}}function Ge(t){return!!o(t)&&!!Object.prototype.hasOwnProperty.call(t,"_controlledWritableStream")&&t instanceof He}function $e(t,e,r,n,o,i,s,a){e._controlledWritableStream=t,t._writableStreamController=e,e._queue=void 0,e._queueTotalSize=void 0,Tt(e),e._abortReason=void 0,e._abortController=function(){if(Ee)return new AbortController}(),e._started=!1,e._strategySizeAlgorithm=a,e._strategyHWM=s,e._writeAlgorithm=n,e._closeAlgorithm=o,e._abortAlgorithm=i;const u=Qe(e);ke(t,u),v(d(r()),(()=>(e._started=!0,Je(e),null)),(r=>(e._started=!0,Ce(t,r),null)))}function Ke(t){t._writeAlgorithm=void 0,t._closeAlgorithm=void 0,t._abortAlgorithm=void 0,t._strategySizeAlgorithm=void 0}function ze(t){return t._strategyHWM-t._queueTotalSize}function Je(t){const e=t._controlledWritableStream;if(!t._started)return;if(void 0!==e._inFlightWriteRequest)return;if("erroring"===e._state)return void Le(e);if(0===t._queue.length)return;const r=t._queue.peek().value;r===Ve?function(t){const e=t._controlledWritableStream;(function(t){t._inFlightCloseRequest=t._closeRequest,t._closeRequest=void 0})(e),It(t);const r=t._closeAlgorithm();Ke(t),v(r,(()=>(function(t){t._inFlightCloseRequest._resolve(void 0),t._inFlightCloseRequest=void 0,"erroring"===t._state&&(t._storedError=void 0,void 0!==t._pendingAbortRequest&&(t._pendingAbortRequest._resolve(),t._pendingAbortRequest=void 0)),t._state="closed";const e=t._writer;void 0!==e&&sr(e)}(e),null)),(t=>(function(t,e){t._inFlightCloseRequest._reject(e),t._inFlightCloseRequest=void 0,void 0!==t._pendingAbortRequest&&(t._pendingAbortRequest._reject(e),t._pendingAbortRequest=void 0),Ce(t,e)}(e,t),null)))}(t):function(t,e){const r=t._controlledWritableStream;!function(t){t._inFlightWriteRequest=t._writeRequests.shift()}(r),v(t._writeAlgorithm(e),(()=>{!function(t){t._inFlightWriteRequest._resolve(void 0),t._inFlightWriteRequest=void 0}(r);const e=r._state;if(It(t),!je(r)&&"writable"===e){const e=Qe(t);ke(r,e)}return Je(t),null}),(e=>("writable"===r._state&&Ke(t),function(t,e){t._inFlightWriteRequest._reject(e),t._inFlightWriteRequest=void 0,Ce(t,e)}(r,e),null)))}(t,r)}function Ye(t,e){"writable"===t._controlledWritableStream._state&&Ze(t,e)}function Qe(t){return ze(t)<=0}function Ze(t,e){const r=t._controlledWritableStream;Ke(t),Ne(r,e)}function Xe(t){return new TypeError(`WritableStream.prototype.${t} can only be used on a WritableStream`)}function tr(t){return new TypeError(`WritableStreamDefaultController.prototype.${t} can only be used on a WritableStreamDefaultController`)}function er(t){return new TypeError(`WritableStreamDefaultWriter.prototype.${t} can only be used on a WritableStreamDefaultWriter`)}function rr(t){return new TypeError("Cannot "+t+" a stream using a released writer")}function nr(t){t._closedPromise=h(((e,r)=>{t._closedPromise_resolve=e,t._closedPromise_reject=r,t._closedPromiseState="pending"}))}function or(t,e){nr(t),ir(t,e)}function ir(t,e){void 0!==t._closedPromise_reject&&(w(t._closedPromise),t._closedPromise_reject(e),t._closedPromise_resolve=void 0,t._closedPromise_reject=void 0,t._closedPromiseState="rejected")}function sr(t){void 0!==t._closedPromise_resolve&&(t._closedPromise_resolve(void 0),t._closedPromise_resolve=void 0,t._closedPromise_reject=void 0,t._closedPromiseState="resolved")}function ar(t){t._readyPromise=h(((e,r)=>{t._readyPromise_resolve=e,t._readyPromise_reject=r})),t._readyPromiseState="pending"}function ur(t,e){ar(t),lr(t,e)}function cr(t){ar(t),fr(t)}function lr(t,e){void 0!==t._readyPromise_reject&&(w(t._readyPromise),t._readyPromise_reject(e),t._readyPromise_resolve=void 0,t._readyPromise_reject=void 0,t._readyPromiseState="rejected")}function fr(t){void 0!==t._readyPromise_resolve&&(t._readyPromise_resolve(void 0),t._readyPromise_resolve=void 0,t._readyPromise_reject=void 0,t._readyPromiseState="fulfilled")}Object.defineProperties(He.prototype,{abortReason:{enumerable:!0},signal:{enumerable:!0},error:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(He.prototype,Symbol.toStringTag,{value:"WritableStreamDefaultController",configurable:!0});const hr="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof global?global:void 0,dr=function(){const t=null==hr?void 0:hr.DOMException;return function(t){if("function"!=typeof t&&"object"!=typeof t)return!1;if("DOMException"!==t.name)return!1;try{return new t,!0}catch(t){return!1}}(t)?t:void 0}()||function(){const t=function(t,e){this.message=t||"",this.name=e||"Error",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)};return s(t,"DOMException"),t.prototype=Object.create(Error.prototype),Object.defineProperty(t.prototype,"constructor",{value:t,writable:!0,configurable:!0}),t}();function pr(t,e,r,o,i,s){const a=J(t),u=Oe(e);t._disturbed=!0;let c=!1,l=d(void 0);return h(((f,b)=>{let _;if(void 0!==s){if(_=()=>{const r=void 0!==s.reason?s.reason:new dr("Aborted","AbortError"),n=[];o||n.push((()=>"writable"===e._state?Pe(e,r):d(void 0))),i||n.push((()=>"readable"===t._state?Mr(t,r):d(void 0))),R((()=>Promise.all(n.map((t=>t())))),!0,r)},s.aborted)return void _();s.addEventListener("abort",_)}var S,E,I;if(T(t,a._closedPromise,(t=>(o?A(!0,t):R((()=>Pe(e,t)),!0,t),null))),T(e,u._closedPromise,(e=>(i?A(!0,e):R((()=>Mr(t,e)),!0,e),null))),S=t,E=a._closedPromise,I=()=>(r?A():R((()=>function(t){const e=t._ownerWritableStream,r=e._state;return je(e)||"closed"===r?d(void 0):"errored"===r?p(e._storedError):Me(t)}(u))),null),"closed"===S._state?I():g(E,I),je(e)||"closed"===e._state){const e=new TypeError("the destination writable stream closed before all data could be piped to it");i?A(!0,e):R((()=>Mr(t,e)),!0,e)}function O(){const t=l;return y(l,(()=>t!==l?O():void 0))}function T(t,e,r){"errored"===t._state?r(t._storedError):m(e,r)}function R(t,r,n){function o(){return v(t(),(()=>P(r,n)),(t=>P(!0,t))),null}c||(c=!0,"writable"!==e._state||je(e)?o():g(O(),o))}function A(t,r){c||(c=!0,"writable"!==e._state||je(e)?P(t,r):g(O(),(()=>P(t,r))))}function P(t,e){return We(u),N(a),void 0!==s&&s.removeEventListener("abort",_),t?b(e):f(void 0),null}w(h(((t,e)=>{!function r(o){o?t():y(c?d(!0):y(u._readyPromise,(()=>h(((t,e)=>{rt(a,{_chunkSteps:e=>{l=y(Fe(u,e),void 0,n),t(!1)},_closeSteps:()=>t(!0),_errorSteps:e})})))),r,e)}(!1)})))}))}class yr{constructor(){throw new TypeError("Illegal constructor")}get desiredSize(){if(!vr(this))throw Tr("desiredSize");return Er(this)}close(){if(!vr(this))throw Tr("close");if(!Ir(this))throw new TypeError("The stream is not in a state that permits close");wr(this)}enqueue(t=void 0){if(!vr(this))throw Tr("enqueue");if(!Ir(this))throw new TypeError("The stream is not in a state that permits enqueue");return _r(this,t)}error(t=void 0){if(!vr(this))throw Tr("error");Sr(this,t)}[R](t){Tt(this);const e=this._cancelAlgorithm(t);return br(this),e}[A](t){const e=this._controlledReadableStream;if(this._queue.length>0){const r=It(this);this._closeRequested&&0===this._queue.length?(br(this),Br(e)):gr(this),t._chunkSteps(r)}else Y(e,t),gr(this)}[P](){}}function vr(t){return!!o(t)&&!!Object.prototype.hasOwnProperty.call(t,"_controlledReadableStream")&&t instanceof yr}function gr(t){mr(t)&&(t._pulling?t._pullAgain=!0:(t._pulling=!0,v(t._pullAlgorithm(),(()=>(t._pulling=!1,t._pullAgain&&(t._pullAgain=!1,gr(t)),null)),(e=>(Sr(t,e),null)))))}function mr(t){const e=t._controlledReadableStream;return!!Ir(t)&&!!t._started&&(!!(qr(e)&&Z(e)>0)||Er(t)>0)}function br(t){t._pullAlgorithm=void 0,t._cancelAlgorithm=void 0,t._strategySizeAlgorithm=void 0}function wr(t){if(!Ir(t))return;const e=t._controlledReadableStream;t._closeRequested=!0,0===t._queue.length&&(br(t),Br(e))}function _r(t,e){if(!Ir(t))return;const r=t._controlledReadableStream;if(qr(r)&&Z(r)>0)Q(r,e,!1);else{let r;try{r=t._strategySizeAlgorithm(e)}catch(e){throw Sr(t,e),e}try{Ot(t,e,r)}catch(e){throw Sr(t,e),e}}gr(t)}function Sr(t,e){const r=t._controlledReadableStream;"readable"===r._state&&(Tt(t),br(t),Wr(r,e))}function Er(t){const e=t._controlledReadableStream._state;return"errored"===e?null:"closed"===e?0:t._strategyHWM-t._queueTotalSize}function Ir(t){const e=t._controlledReadableStream._state;return!t._closeRequested&&"readable"===e}function Or(t,e,r,n,o,i,s){e._controlledReadableStream=t,e._queue=void 0,e._queueTotalSize=void 0,Tt(e),e._started=!1,e._closeRequested=!1,e._pullAgain=!1,e._pulling=!1,e._strategySizeAlgorithm=s,e._strategyHWM=i,e._pullAlgorithm=n,e._cancelAlgorithm=o,t._readableStreamController=e,v(d(r()),(()=>(e._started=!0,gr(e),null)),(t=>(Sr(e,t),null)))}function Tr(t){return new TypeError(`ReadableStreamDefaultController.prototype.${t} can only be used on a ReadableStreamDefaultController`)}function Rr(t){return o(e=t)&&void 0!==e.getReader?function(t){let e;return e=jr(n,(function(){let r;try{r=t.read()}catch(r){return p(r)}return b(r,(t=>{if(!o(t))throw new TypeError("The promise returned by the reader.read() method must fulfill with an object");if(t.done)wr(e._readableStreamController);else{const r=t.value;_r(e._readableStreamController,r)}}))}),(function(e){try{return d(t.cancel(e))}catch(e){return p(e)}}),0),e}(t.getReader()):function(t){let e;const r=vt(t,"async");return e=jr(n,(function(){let t;try{t=gt(r)}catch(t){return p(t)}return b(d(t),(t=>{if(!o(t))throw new TypeError("The promise returned by the iterator.next() method must fulfill with an object");if(t.done)wr(e._readableStreamController);else{const r=t.value;_r(e._readableStreamController,r)}}))}),(function(t){const e=r.iterator;let n;try{n=dt(e,"return")}catch(t){return p(t)}return void 0===n?d(void 0):b(E(n,e,[t]),(t=>{if(!o(t))throw new TypeError("The promise returned by the iterator.return() method must fulfill with an object")}))}),0),e}(t);var e}function Ar(t,e,r){return W(t,r),r=>E(t,e,[r])}function Pr(t,e,r){return W(t,r),r=>E(t,e,[r])}function xr(t,e,r){return W(t,r),r=>S(t,e,[r])}function Cr(t,e){if("bytes"!=(t=`${t}`))throw new TypeError(`${e} '${t}' is not a valid enumeration value for ReadableStreamType`);return t}function Nr(t,e){B(t,e);const r=null==t?void 0:t.preventAbort,n=null==t?void 0:t.preventCancel,o=null==t?void 0:t.preventClose,i=null==t?void 0:t.signal;return void 0!==i&&function(t,e){if(!function(t){if("object"!=typeof t||null===t)return!1;try{return"boolean"==typeof t.aborted}catch(t){return!1}}(t))throw new TypeError(`${e} is not an AbortSignal.`)}(i,`${e} has member 'signal' that`),{preventAbort:Boolean(r),preventCancel:Boolean(n),preventClose:Boolean(o),signal:i}}Object.defineProperties(yr.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},desiredSize:{enumerable:!0}}),s(yr.prototype.close,"close"),s(yr.prototype.enqueue,"enqueue"),s(yr.prototype.error,"error"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(yr.prototype,Symbol.toStringTag,{value:"ReadableStreamDefaultController",configurable:!0});class Lr{constructor(t={},e={}){void 0===t?t=null:F(t,"First parameter");const r=ve(e,"Second parameter"),n=function(t,e){B(t,e);const r=t,n=null==r?void 0:r.autoAllocateChunkSize,o=null==r?void 0:r.cancel,i=null==r?void 0:r.pull,s=null==r?void 0:r.start,a=null==r?void 0:r.type;return{autoAllocateChunkSize:void 0===n?void 0:K(n,`${e} has member 'autoAllocateChunkSize' that`),cancel:void 0===o?void 0:Ar(o,r,`${e} has member 'cancel' that`),pull:void 0===i?void 0:Pr(i,r,`${e} has member 'pull' that`),start:void 0===s?void 0:xr(s,r,`${e} has member 'start' that`),type:void 0===a?void 0:Cr(a,`${e} has member 'type' that`)}}(t,"First parameter");if(kr(this),"bytes"===n.type){if(void 0!==r.size)throw new RangeError("The strategy for a byte stream cannot have a size function");!function(t,e,r){const n=Object.create(Pt.prototype);let o,i,s;o=void 0!==e.start?()=>e.start(n):()=>{},i=void 0!==e.pull?()=>e.pull(n):()=>d(void 0),s=void 0!==e.cancel?t=>e.cancel(t):()=>d(void 0);const a=e.autoAllocateChunkSize;if(0===a)throw new TypeError("autoAllocateChunkSize must be greater than 0");ee(t,n,o,i,s,r,a)}(this,n,pe(r,0))}else{const t=ye(r);!function(t,e,r,n){const o=Object.create(yr.prototype);let i,s,a;i=void 0!==e.start?()=>e.start(o):()=>{},s=void 0!==e.pull?()=>e.pull(o):()=>d(void 0),a=void 0!==e.cancel?t=>e.cancel(t):()=>d(void 0),Or(t,o,i,s,a,r,n)}(this,n,pe(r,1),t)}}get locked(){if(!Dr(this))throw Fr("locked");return qr(this)}cancel(t=void 0){return Dr(this)?qr(this)?p(new TypeError("Cannot cancel a stream that already has a reader")):Mr(this,t):p(Fr("cancel"))}getReader(t=void 0){if(!Dr(this))throw Fr("getReader");return void 0===function(t,e){B(t,e);const r=null==t?void 0:t.mode;return{mode:void 0===r?void 0:oe(r,`${e} has member 'mode' that`)}}(t,"First parameter").mode?J(this):ie(this)}pipeThrough(t,e={}){if(!Dr(this))throw Fr("pipeThrough");V(t,1,"pipeThrough");const r=function(t,e){B(t,e);const r=null==t?void 0:t.readable;H(r,"readable","ReadableWritablePair"),z(r,`${e} has member 'readable' that`);const n=null==t?void 0:t.writable;return H(n,"writable","ReadableWritablePair"),Se(n,`${e} has member 'writable' that`),{readable:r,writable:n}}(t,"First parameter"),n=Nr(e,"Second parameter");if(qr(this))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream");if(Ae(r.writable))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream");return w(pr(this,r.writable,n.preventClose,n.preventAbort,n.preventCancel,n.signal)),r.readable}pipeTo(t,e={}){if(!Dr(this))return p(Fr("pipeTo"));if(void 0===t)return p("Parameter 1 is required in 'pipeTo'.");if(!Re(t))return p(new TypeError("ReadableStream.prototype.pipeTo's first argument must be a WritableStream"));let r;try{r=Nr(e,"Second parameter")}catch(t){return p(t)}return qr(this)?p(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream")):Ae(t)?p(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream")):pr(this,t,r.preventClose,r.preventAbort,r.preventCancel,r.signal)}tee(){if(!Dr(this))throw Fr("tee");return ut(function(t){return xt(t._readableStreamController)?function(t){let e,r,n,o,i,s=J(t),a=!1,u=!1,c=!1,l=!1,f=!1;const p=h((t=>{i=t}));function y(t){m(t._closedPromise,(e=>(t!==s||(Jt(n._readableStreamController,e),Jt(o._readableStreamController,e),l&&f||i(void 0)),null)))}function v(){le(s)&&(N(s),s=J(t),y(s)),rt(s,{_chunkSteps:e=>{_((()=>{u=!1,c=!1;const r=e;let s=e;if(!l&&!f)try{s=Et(e)}catch(e){return Jt(n._readableStreamController,e),Jt(o._readableStreamController,e),void i(Mr(t,e))}l||zt(n._readableStreamController,r),f||zt(o._readableStreamController,s),a=!1,u?b():c&&w()}))},_closeSteps:()=>{a=!1,l||Kt(n._readableStreamController),f||Kt(o._readableStreamController),n._readableStreamController._pendingPullIntos.length>0&&Xt(n._readableStreamController,0),o._readableStreamController._pendingPullIntos.length>0&&Xt(o._readableStreamController,0),l&&f||i(void 0)},_errorSteps:()=>{a=!1}})}function g(e,r){et(s)&&(N(s),s=ie(t),y(s));const h=r?o:n,d=r?n:o;fe(s,e,1,{_chunkSteps:e=>{_((()=>{u=!1,c=!1;const n=r?f:l;if(r?l:f)n||te(h._readableStreamController,e);else{let r;try{r=Et(e)}catch(e){return Jt(h._readableStreamController,e),Jt(d._readableStreamController,e),void i(Mr(t,e))}n||te(h._readableStreamController,e),zt(d._readableStreamController,r)}a=!1,u?b():c&&w()}))},_closeSteps:t=>{a=!1;const e=r?f:l,n=r?l:f;e||Kt(h._readableStreamController),n||Kt(d._readableStreamController),void 0!==t&&(e||te(h._readableStreamController,t),!n&&d._readableStreamController._pendingPullIntos.length>0&&Xt(d._readableStreamController,0)),e&&n||i(void 0)},_errorSteps:()=>{a=!1}})}function b(){if(a)return u=!0,d(void 0);a=!0;const t=Qt(n._readableStreamController);return null===t?v():g(t._view,!1),d(void 0)}function w(){if(a)return c=!0,d(void 0);a=!0;const t=Qt(o._readableStreamController);return null===t?v():g(t._view,!0),d(void 0)}function S(){}return n=Ur(S,b,(function(n){if(l=!0,e=n,f){const n=ut([e,r]),o=Mr(t,n);i(o)}return p})),o=Ur(S,w,(function(n){if(f=!0,r=n,l){const n=ut([e,r]),o=Mr(t,n);i(o)}return p})),y(s),[n,o]}(t):function(t){const e=J(t);let r,n,o,i,s,a=!1,u=!1,c=!1,l=!1;const f=h((t=>{s=t}));function p(){return a?(u=!0,d(void 0)):(a=!0,rt(e,{_chunkSteps:t=>{_((()=>{u=!1;const e=t,r=t;c||_r(o._readableStreamController,e),l||_r(i._readableStreamController,r),a=!1,u&&p()}))},_closeSteps:()=>{a=!1,c||wr(o._readableStreamController),l||wr(i._readableStreamController),c&&l||s(void 0)},_errorSteps:()=>{a=!1}}),d(void 0))}function y(){}return o=jr(y,p,(function(e){if(c=!0,r=e,l){const e=ut([r,n]),o=Mr(t,e);s(o)}return f})),i=jr(y,p,(function(e){if(l=!0,n=e,c){const e=ut([r,n]),o=Mr(t,e);s(o)}return f})),m(e._closedPromise,(t=>(Sr(o._readableStreamController,t),Sr(i._readableStreamController,t),c&&l||s(void 0),null))),[o,i]}(t)}(this))}values(t=void 0){if(!Dr(this))throw Fr("values");return function(t,e){const r=J(t),n=new mt(r,e),o=Object.create(bt);return o._asyncIteratorImpl=n,o}(this,function(t){B(t,"First parameter");const e=null==t?void 0:t.preventCancel;return{preventCancel:Boolean(e)}}(t).preventCancel)}[yt](t){return this.values(t)}static from(t){return Rr(t)}}function jr(t,e,r,n=1,o=()=>1){const i=Object.create(Lr.prototype);return kr(i),Or(i,Object.create(yr.prototype),t,e,r,n,o),i}function Ur(t,e,r){const n=Object.create(Lr.prototype);return kr(n),ee(n,Object.create(Pt.prototype),t,e,r,0,void 0),n}function kr(t){t._state="readable",t._reader=void 0,t._storedError=void 0,t._disturbed=!1}function Dr(t){return!!o(t)&&!!Object.prototype.hasOwnProperty.call(t,"_readableStreamController")&&t instanceof Lr}function qr(t){return void 0!==t._reader}function Mr(t,e){if(t._disturbed=!0,"closed"===t._state)return d(void 0);if("errored"===t._state)return p(t._storedError);Br(t);const r=t._reader;if(void 0!==r&&le(r)){const t=r._readIntoRequests;r._readIntoRequests=new I,t.forEach((t=>{t._closeSteps(void 0)}))}return b(t._readableStreamController[R](e),n)}function Br(t){t._state="closed";const e=t._reader;if(void 0!==e&&(D(e),et(e))){const t=e._readRequests;e._readRequests=new I,t.forEach((t=>{t._closeSteps()}))}}function Wr(t,e){t._state="errored",t._storedError=e;const r=t._reader;void 0!==r&&(k(r,e),et(r)?nt(r,e):he(r,e))}function Fr(t){return new TypeError(`ReadableStream.prototype.${t} can only be used on a ReadableStream`)}function Vr(t,e){B(t,e);const r=null==t?void 0:t.highWaterMark;return H(r,"highWaterMark","QueuingStrategyInit"),{highWaterMark:G(r)}}Object.defineProperties(Lr,{from:{enumerable:!0}}),Object.defineProperties(Lr.prototype,{cancel:{enumerable:!0},getReader:{enumerable:!0},pipeThrough:{enumerable:!0},pipeTo:{enumerable:!0},tee:{enumerable:!0},values:{enumerable:!0},locked:{enumerable:!0}}),s(Lr.from,"from"),s(Lr.prototype.cancel,"cancel"),s(Lr.prototype.getReader,"getReader"),s(Lr.prototype.pipeThrough,"pipeThrough"),s(Lr.prototype.pipeTo,"pipeTo"),s(Lr.prototype.tee,"tee"),s(Lr.prototype.values,"values"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Lr.prototype,Symbol.toStringTag,{value:"ReadableStream",configurable:!0}),Object.defineProperty(Lr.prototype,yt,{value:Lr.prototype.values,writable:!0,configurable:!0});const Hr=t=>t.byteLength;s(Hr,"size");class Gr{constructor(t){V(t,1,"ByteLengthQueuingStrategy"),t=Vr(t,"First parameter"),this._byteLengthQueuingStrategyHighWaterMark=t.highWaterMark}get highWaterMark(){if(!Kr(this))throw $r("highWaterMark");return this._byteLengthQueuingStrategyHighWaterMark}get size(){if(!Kr(this))throw $r("size");return Hr}}function $r(t){return new TypeError(`ByteLengthQueuingStrategy.prototype.${t} can only be used on a ByteLengthQueuingStrategy`)}function Kr(t){return!!o(t)&&!!Object.prototype.hasOwnProperty.call(t,"_byteLengthQueuingStrategyHighWaterMark")&&t instanceof Gr}Object.defineProperties(Gr.prototype,{highWaterMark:{enumerable:!0},size:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Gr.prototype,Symbol.toStringTag,{value:"ByteLengthQueuingStrategy",configurable:!0});const zr=()=>1;s(zr,"size");class Jr{constructor(t){V(t,1,"CountQueuingStrategy"),t=Vr(t,"First parameter"),this._countQueuingStrategyHighWaterMark=t.highWaterMark}get highWaterMark(){if(!Qr(this))throw Yr("highWaterMark");return this._countQueuingStrategyHighWaterMark}get size(){if(!Qr(this))throw Yr("size");return zr}}function Yr(t){return new TypeError(`CountQueuingStrategy.prototype.${t} can only be used on a CountQueuingStrategy`)}function Qr(t){return!!o(t)&&!!Object.prototype.hasOwnProperty.call(t,"_countQueuingStrategyHighWaterMark")&&t instanceof Jr}function Zr(t,e,r){return W(t,r),r=>E(t,e,[r])}function Xr(t,e,r){return W(t,r),r=>S(t,e,[r])}function tn(t,e,r){return W(t,r),(r,n)=>E(t,e,[r,n])}function en(t,e,r){return W(t,r),r=>E(t,e,[r])}Object.defineProperties(Jr.prototype,{highWaterMark:{enumerable:!0},size:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Jr.prototype,Symbol.toStringTag,{value:"CountQueuingStrategy",configurable:!0});class rn{constructor(t={},e={},r={}){void 0===t&&(t=null);const n=ve(e,"Second parameter"),o=ve(r,"Third parameter"),i=function(t,e){B(t,e);const r=null==t?void 0:t.cancel,n=null==t?void 0:t.flush,o=null==t?void 0:t.readableType,i=null==t?void 0:t.start,s=null==t?void 0:t.transform,a=null==t?void 0:t.writableType;return{cancel:void 0===r?void 0:en(r,t,`${e} has member 'cancel' that`),flush:void 0===n?void 0:Zr(n,t,`${e} has member 'flush' that`),readableType:o,start:void 0===i?void 0:Xr(i,t,`${e} has member 'start' that`),transform:void 0===s?void 0:tn(s,t,`${e} has member 'transform' that`),writableType:a}}(t,"First parameter");if(void 0!==i.readableType)throw new RangeError("Invalid readableType specified");if(void 0!==i.writableType)throw new RangeError("Invalid writableType specified");const s=pe(o,0),a=ye(o),u=pe(n,1),c=ye(n);let l;!function(t,e,r,n,o,i){function s(){return e}t._writable=function(t,e,r,n,o=1,i=()=>1){const s=Object.create(Ie.prototype);return Te(s),$e(s,Object.create(He.prototype),t,e,r,n,o,i),s}(s,(function(e){return function(t,e){const r=t._transformStreamController;return t._backpressure?b(t._backpressureChangePromise,(()=>{const n=t._writable;if("erroring"===n._state)throw n._storedError;return dn(r,e)})):dn(r,e)}(t,e)}),(function(){return function(t){const e=t._transformStreamController;if(void 0!==e._finishPromise)return e._finishPromise;const r=t._readable;e._finishPromise=h(((t,r)=>{e._finishPromise_resolve=t,e._finishPromise_reject=r}));const n=e._flushAlgorithm();return fn(e),v(n,(()=>("errored"===r._state?vn(e,r._storedError):(wr(r._readableStreamController),yn(e)),null)),(t=>(Sr(r._readableStreamController,t),vn(e,t),null))),e._finishPromise}(t)}),(function(e){return function(t,e){const r=t._transformStreamController;if(void 0!==r._finishPromise)return r._finishPromise;const n=t._readable;r._finishPromise=h(((t,e)=>{r._finishPromise_resolve=t,r._finishPromise_reject=e}));const o=r._cancelAlgorithm(e);return fn(r),v(o,(()=>("errored"===n._state?vn(r,n._storedError):(Sr(n._readableStreamController,e),yn(r)),null)),(t=>(Sr(n._readableStreamController,t),vn(r,t),null))),r._finishPromise}(t,e)}),r,n),t._readable=jr(s,(function(){return function(t){return un(t,!1),t._backpressureChangePromise}(t)}),(function(e){return function(t,e){const r=t._transformStreamController;if(void 0!==r._finishPromise)return r._finishPromise;const n=t._writable;r._finishPromise=h(((t,e)=>{r._finishPromise_resolve=t,r._finishPromise_reject=e}));const o=r._cancelAlgorithm(e);return fn(r),v(o,(()=>("errored"===n._state?vn(r,n._storedError):(Ye(n._writableStreamController,e),an(t),yn(r)),null)),(e=>(Ye(n._writableStreamController,e),an(t),vn(r,e),null))),r._finishPromise}(t,e)}),o,i),t._backpressure=void 0,t._backpressureChangePromise=void 0,t._backpressureChangePromise_resolve=void 0,un(t,!0),t._transformStreamController=void 0}(this,h((t=>{l=t})),u,c,s,a),function(t,e){const r=Object.create(cn.prototype);let n,o,i;n=void 0!==e.transform?t=>e.transform(t,r):t=>{try{return hn(r,t),d(void 0)}catch(t){return p(t)}},o=void 0!==e.flush?()=>e.flush(r):()=>d(void 0),i=void 0!==e.cancel?t=>e.cancel(t):()=>d(void 0),function(t,e,r,n,o){e._controlledTransformStream=t,t._transformStreamController=e,e._transformAlgorithm=r,e._flushAlgorithm=n,e._cancelAlgorithm=o,e._finishPromise=void 0,e._finishPromise_resolve=void 0,e._finishPromise_reject=void 0}(t,r,n,o,i)}(this,i),void 0!==i.start?l(i.start(this._transformStreamController)):l(void 0)}get readable(){if(!nn(this))throw gn("readable");return this._readable}get writable(){if(!nn(this))throw gn("writable");return this._writable}}function nn(t){return!!o(t)&&!!Object.prototype.hasOwnProperty.call(t,"_transformStreamController")&&t instanceof rn}function on(t,e){Sr(t._readable._readableStreamController,e),sn(t,e)}function sn(t,e){fn(t._transformStreamController),Ye(t._writable._writableStreamController,e),an(t)}function an(t){t._backpressure&&un(t,!1)}function un(t,e){void 0!==t._backpressureChangePromise&&t._backpressureChangePromise_resolve(),t._backpressureChangePromise=h((e=>{t._backpressureChangePromise_resolve=e})),t._backpressure=e}Object.defineProperties(rn.prototype,{readable:{enumerable:!0},writable:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(rn.prototype,Symbol.toStringTag,{value:"TransformStream",configurable:!0});class cn{constructor(){throw new TypeError("Illegal constructor")}get desiredSize(){if(!ln(this))throw pn("desiredSize");return Er(this._controlledTransformStream._readable._readableStreamController)}enqueue(t=void 0){if(!ln(this))throw pn("enqueue");hn(this,t)}error(t=void 0){if(!ln(this))throw pn("error");var e;e=t,on(this._controlledTransformStream,e)}terminate(){if(!ln(this))throw pn("terminate");!function(t){const e=t._controlledTransformStream;wr(e._readable._readableStreamController),sn(e,new TypeError("TransformStream terminated"))}(this)}}function ln(t){return!!o(t)&&!!Object.prototype.hasOwnProperty.call(t,"_controlledTransformStream")&&t instanceof cn}function fn(t){t._transformAlgorithm=void 0,t._flushAlgorithm=void 0,t._cancelAlgorithm=void 0}function hn(t,e){const r=t._controlledTransformStream,n=r._readable._readableStreamController;if(!Ir(n))throw new TypeError("Readable side is not in a state that permits enqueue");try{_r(n,e)}catch(t){throw sn(r,t),r._readable._storedError}const o=function(t){return!mr(t)}(n);o!==r._backpressure&&un(r,!0)}function dn(t,e){return b(t._transformAlgorithm(e),void 0,(e=>{throw on(t._controlledTransformStream,e),e}))}function pn(t){return new TypeError(`TransformStreamDefaultController.prototype.${t} can only be used on a TransformStreamDefaultController`)}function yn(t){void 0!==t._finishPromise_resolve&&(t._finishPromise_resolve(),t._finishPromise_resolve=void 0,t._finishPromise_reject=void 0)}function vn(t,e){void 0!==t._finishPromise_reject&&(w(t._finishPromise),t._finishPromise_reject(e),t._finishPromise_resolve=void 0,t._finishPromise_reject=void 0)}function gn(t){return new TypeError(`TransformStream.prototype.${t} can only be used on a TransformStream`)}Object.defineProperties(cn.prototype,{enqueue:{enumerable:!0},error:{enumerable:!0},terminate:{enumerable:!0},desiredSize:{enumerable:!0}}),s(cn.prototype.enqueue,"enqueue"),s(cn.prototype.error,"error"),s(cn.prototype.terminate,"terminate"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(cn.prototype,Symbol.toStringTag,{value:"TransformStreamDefaultController",configurable:!0})},4536:function(t){"use strict";t.exports={version:"2.19.7"}}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={id:n,loaded:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.loaded=!0,i.exports}return r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,{a:e}),e},r.d=function(t,e){for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.nmd=function(t){return t.paths=[],t.children||(t.children=[]),t},r(5047),r(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={2829:function(t,e,r){"use strict";var n;r.r(e),r.d(e,{AbstractSDKRequest:function(){return o},AbstractStorage:function(){return i},StorageType:function(){return n},formatUrl:function(){return s}}),function(t){t.local="local",t.none="none",t.session="session"}(n||(n={}));var o=function(){},i=function(){};function s(t,e,r){void 0===r&&(r={});var n=/\?/.test(e),o="";for(var i in r)""===o?!n&&(e+="?"):o+="&",o+=i+"="+encodeURIComponent(r[i]);return/^http(s)?\:\/\//.test(e+=o)?e:""+t+e}},190:function(t,e,r){"use strict";var n,o=r(2829),i=r(5993),s=(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},n(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),a=function(){return a=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},a.apply(this,arguments)},u="Error when aborting requestTask",c=function(t){function e(e){void 0===e&&(e={});var r=t.call(this)||this,n=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return r._timeout=n||0,r._timeoutMsg=o||"请求超时",r._restrictedMethods=i||["get","post","upload","download"],r}return s(e,t),e.prototype.post=function(t){var e=this;return new Promise((function(r,n){var i=t.url,s=t.data,a=t.headers,u=wx.request({url:(0,o.formatUrl)("https:",i),data:s,timeout:e._timeout,method:"POST",header:a,success:function(t){r(t)},fail:function(t){n(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{u.abort()}catch(t){}}}})}))},e.prototype.upload=function(t){var e=this,r=this;return new Promise((function(n){return o=e,i=void 0,u=function(){var e,o,i,s,u,c;return function(t,e){var r,n,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(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}(this,(function(l){return e=t.url,o=t.file,i=t.data,s=t.headers,u=t.onUploadProgress,c=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)),n(e)},fail:function(t){n(t)},complete:function(t){if(t&&t.errMsg&&r._timeout&&-1!==r._restrictedMethods.indexOf("upload")&&"request:fail timeout"===t.errMsg){console.warn(r._timeoutMsg);try{c.abort()}catch(t){}}}}),u&&c.onProgressUpdate((function(t){u(t)})),[2]}))},new((s=void 0)||(s=Promise))((function(t,e){function r(t){try{a(u.next(t))}catch(t){e(t)}}function n(t){try{a(u.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(r,n)}a((u=u.apply(o,i||[])).next())}));var o,i,s,u}))},e.prototype.download=function(t){var e=this,r=this;return new Promise((function(n,i){var s=t.url,a=t.headers,u=wx.downloadFile({url:(0,o.formatUrl)("https:",s),header:a,timeout:e._timeout,success:function(t){200===t.statusCode&&t.tempFilePath?n({statusCode:200,tempFilePath:t.tempFilePath}):n(t)},fail:function(t){i(t)},complete:function(t){if(t&&t.errMsg&&r._timeout&&-1!==r._restrictedMethods.indexOf("download")&&"request:fail timeout"===t.errMsg){console.warn(r._timeoutMsg);try{u.abort()}catch(t){}}}})}))},e.prototype.fetch=function(t){var e=t.url,r=t.body,n=t.enableAbort,s=t.headers,a=t.method,c=t.stream,l=void 0!==c&&c,f=t.signal,h=t.timeout,d=this,p=null!=h?h:this._timeout,y=null,v=new i.Pz({start:function(t){y=t},cancel:function(){y=null}});return new Promise((function(t,i){l&&t({data:v});var c=wx.request({url:(0,o.formatUrl)("https:",e),data:r,timeout:p,method:a.toUpperCase(),header:s,success:function(e){var r;null===(r=y)||void 0===r||r.close(),!l&&t(e)},fail:function(t){var e;if(null===(e=y)||void 0===e||e.close(),i(t),l)throw t},complete:function(t){if(t&&t.errMsg&&p&&-1!==d._restrictedMethods.indexOf("post")&&n&&"request:fail timeout"===t.errMsg){console.warn(d._timeoutMsg);try{c.abort()}catch(t){console.warn(u,t)}}},enableChunked:l});if(c.onChunkReceived((function(t){var e;null===(e=y)||void 0===e||e.enqueue(new Uint8Array(t.data))})),f){var h=function(){try{c.abort()}catch(t){console.warn(u,t)}};f.aborted?h():f.addEventListener("abort",(function(){return h()}))}}))},e}(o.AbstractSDKRequest),l={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 r=wx.connectSocket(a({url:t},e));return{set onopen(t){r.onOpen(t)},set onmessage(t){r.onMessage(t)},set onclose(t){r.onClose(t)},set onerror(t){r.onError(t)},send:function(t){return r.send({data:t})},close:function(t,e){return r.close({code:t,reason:e})},get readyState(){return r.readyState},CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3}},h={genAdapter:function(){return{root:{},reqClass:c,wsClass:f,localStorage:l,primaryStorage:o.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"};e.ZP=h},5304:function(t,e){!function(t){"use strict";var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},e(t,r)};var r=function(){return r=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)};function n(t,e,r,n){return new(r||(r=Promise))((function(e,o){function i(t){try{a(n.next(t))}catch(t){o(t)}}function s(t){try{a(n.throw(t))}catch(t){o(t)}}function a(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r((function(t){t(n)}))).then(i,s)}a((n=n.apply(t,[])).next())}))}function o(t,e){var r,n,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(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}var i=function(t){function r(e,r){var n=t.call(this,e)||this;return n.name="WxCloudSDKError",n.code=null==r?void 0:r.code,n.requestId=null==r?void 0:r.requestId,n.originError=null==r?void 0:r.originError,n}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}(r,t),r}(Error);function s(){return"undefined"!=typeof window&&window||"undefined"!=typeof globalThis&&globalThis}function a(){try{var t=s();if(!t)return;return"undefined"==typeof wx?s().location.href:t.__wxRoute}catch(t){}}var u=function(t){var e=t.dataSourceName,r=t.methodName,u=t.params,c=t.realMethodName,l=t.callFunction,f=t.envType,h=void 0===f?"prod":f,d=t.mode;return n(void 0,0,void 0,(function(){var t,n,f,p,y,v;return o(this,(function(o){switch(o.label){case 0:t={data:{},requestId:""},o.label=1;case 1:return o.trys.push([1,3,,4]),[4,l({name:"lowcode-datasource",data:{dataSourceName:e,methodName:r,params:u,userAgent:(m=s(),(null==m?void 0:m.navigator)?m.navigator.userAgent:"undefined"!=typeof wx&&wx.getSystemInfo?(wx.getSystemInfo({success:function(t){t&&(g=["brand","model","version","system","platform","SDKVersion","language"].map((function(e){return"".concat(e,": ").concat(t[e])})).join(", "))}}),g):void 0),referrer:a(),"x-sdk-version":"1.5.0",envType:h,mode:d}})];case 2:if(n=o.sent(),f=(null===(y=null==n?void 0:n.result)||void 0===y?void 0:y.requestId)||(null==n?void 0:n.requestId)||(null==n?void 0:n.requestID),null==n?void 0:n.result.code)throw new i("【错误】".concat(null==n?void 0:n.result.message,"\n【操作】调用 models.").concat(e?"".concat(e,"."):"").concat(c,"\n【错误码】").concat(null==n?void 0:n.result.code,"\n【请求ID】").concat(f||"N/A"),{code:null==n?void 0:n.result.code,requestId:f});return t.data=(null===(v=null==n?void 0:n.result)||void 0===v?void 0:v.data)||{},t.requestId=f,[3,4];case 3:throw"WxCloudSDKError"===(p=o.sent()).name?p:(console.log(p),new i("【错误】".concat(p.message,"\n 【操作】调用 models.").concat(e?"".concat(e,"."):"").concat(c,"\n 【请求ID】N/A"),{code:"UnknownError",originError:p}));case 4:return[2,t]}var g,m}))}))},c=function(t){var e=t.sql,r=t.params,i=t.config,s=t.callFunction,a=t.unsafe,c=void 0!==a&&a;return n(void 0,0,void 0,(function(){return o(this,(function(t){return[2,u({realMethodName:"$runSQL",methodName:"callWedaApi",params:{action:"RunMysqlCommand",data:{sqlTemplate:e,config:i,parameter:c?"":Object.entries(r||{}).reduce((function(t,e){var r=e[0],n=e[1];if(void 0!==n){var o="OBJECT";switch(typeof n){case"boolean":o="BOOLEAN";break;case"number":o="NUMBER";break;case"string":o="STRING";break;default:o=Array.isArray(n)?"ARRAY":"OBJECT"}t.push({key:r,type:o,value:"STRING"===o?n:JSON.stringify(n)})}return t}),[])||[]}},callFunction:s,mode:"sdk"})]}))}))},l=function(t){return{$runSQL:function(e,i,s){return n(this,0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return[4,c({sql:e,params:i,config:r(r({},s),{preparedStatements:!0}),callFunction:t})];case 1:return[2,n.sent()]}}))}))},$runSQLRaw:function(e,i){return n(this,0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return[4,c({sql:e,params:[],config:r(r({},i),{preparedStatements:!1}),callFunction:t})];case 1:return[2,n.sent()]}}))}))}}},f={create:{methodName:"wedaCreateV2"},createMany:{methodName:"wedaBatchCreateV2"},update:{methodName:"wedaUpdateV2"},upsert:{methodName:"wedaUpsertV2"},updateMany:{methodName:"wedaBatchUpdateV2"},delete:{methodName:"wedaDeleteV2"},deleteMany:{methodName:"wedaBatchDeleteV2"},get:{methodName:"wedaGetItemV2",defaultParams:{filter:{where:{}},select:{$master:!0}}},list:{methodName:"wedaGetRecordsV2",defaultParams:{filter:{where:{}},select:{$master:!0}}}},h=function(t){var e=l(t);return new Proxy({},{get:function(s,a){if("string"==typeof a)return Object.prototype.hasOwnProperty.call(e,a)?e[a]:function(t,e){return new Proxy({},{get:function(s,a){var c=f[a];if(!c){var l=new Error("不支持的操作: ".concat(a));throw new i(l.message||"Unknown error occurred",{originError:l,code:"NotSupported",requestId:"N/A"})}return function(i){return n(void 0,0,void 0,(function(){var n,s,l,f,h;return o(this,(function(o){switch(o.label){case 0:return n=r(r({},c.defaultParams||{}),i||{}),[4,u({callFunction:e,dataSourceName:t,methodName:c.methodName,realMethodName:a,params:n,envType:null==i?void 0:i.envType})];case 1:return s=o.sent(),l={data:{}},f=c.responseKey,l.data=f?null===(h=null==s?void 0:s.data)||void 0===h?void 0:h[f]:null==s?void 0:s.data,[2,l]}}))}))}}})}(a,t)}})},d={filter:{where:{}},select:{$master:!0}};function p(t){return{getUrl:function(e){return"".concat(e,"/").concat(t)},method:"post"}}var y={get:r(r({},p("get")),{defaultParams:r({},d)}),list:r(r({},p("list")),{defaultParams:r({},d)}),create:p("create"),createMany:p("createMany"),update:r(r({},p("update")),{method:"put"}),updateMany:r(r({},p("updateMany")),{method:"put"}),upsert:p("upsert"),delete:p("delete"),deleteMany:p("deleteMany")},v="Unknown error occurred",g="NotSupported",m=function(t,e,r,n){var o=l(t);return new Proxy({},{get:function(t,i){if("string"==typeof i)return Object.prototype.hasOwnProperty.call(o,i)?o[i]:w(r,i,e,n)}})},b=function(t,e,r,n,o){return new i("【错误】".concat(t,"\n【操作】调用 models.").concat(e,".").concat(r,"\n【错误码】").concat(n,"\n【请求ID】").concat(o),{code:n,requestId:o})},w=function(t,e,s,a){return new Proxy({},{get:function(u,c){if("runSQLTemplate"!==c){var l=y[c];if(!l){var f=new Error("不支持的操作: ".concat(c));throw new i(f.message||v,{originError:f,code:g,requestId:"N/A"})}return function(r){return void 0===r&&(r={}),n(void 0,0,void 0,(function(){var n,a,u,f,h,d,p,y,g,m;return o(this,(function(o){switch(o.label){case 0:n=l.getUrl,a=l.method,u=l.defaultParams,f=void 0===u?{}:u,h=Object.assign({},f,r),d="pre"===h.envType?"pre":"prod",p=[t,d,n(e)].join("/"),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,s({url:p,body:JSON.stringify(h),method:a})];case 2:if((y=o.sent()).code)throw b(null==y?void 0:y.message,e,c,null==y?void 0:y.code,null==y?void 0:y.requestId);return"get"===c&&Object.assign(y,{data:null!==(m=y.data.record)&&void 0!==m?m:y.data}),[2,y];case 3:throw g=o.sent(),new i((null==g?void 0:g.message)||v,{originError:g});case 4:return[2]}}))}))}}if(!(null==a?void 0:a.sqlBaseUrl))throw f=new Error("不支持的操作: ".concat(c)),new i(f.message||v,{originError:f,code:g,requestId:"N/A"});return function(t){return n(void 0,0,void 0,(function(){var n,u,l,f,h,d,p,y,g,m,w,_,S,E,I,O;return o(this,(function(o){switch(o.label){case 0:n=t.params,u=t.templateName,l=t.envType,f="pre"===l?"pre":"prod",h=[a.sqlBaseUrl,f,u,"run"].join("/"),d=Object.entries(n||{}).reduce((function(t,e){var r=e[0],n=e[1];if(void 0!==n){var o="OBJECT";switch(typeof n){case"boolean":o="BOOLEAN";break;case"number":o="NUMBER";break;case"string":o="STRING";break;default:o=Array.isArray(n)?"ARRAY":"OBJECT"}t.push({key:r,type:o,value:"STRING"===o?n:JSON.stringify(n)})}return t}),[]),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,s({url:h,body:JSON.stringify({parameter:d}),method:"POST"})];case 2:if(p=o.sent(),null===(g=null==p?void 0:p.Response)||void 0===g?void 0:g.Error)throw b(null===(w=null===(m=null==p?void 0:p.Response)||void 0===m?void 0:m.Error)||void 0===w?void 0:w.Message,e,c,null===(S=null===(_=null==p?void 0:p.Response)||void 0===_?void 0:_.Error)||void 0===S?void 0:S.Code,null===(E=null==p?void 0:p.Response)||void 0===E?void 0:E.RequestId);return[2,r(r({},null!==(I=null==p?void 0:p.Response)&&void 0!==I?I:{}),{data:null===(O=null==p?void 0:p.Response)||void 0===O?void 0:O.Data})];case 3:throw y=o.sent(),new i((null==y?void 0:y.message)||v,{originError:y});case 4:return[2]}}))}))}}})};function _(t){if(!t)throw new Error("cloud is required");if(!t.callFunction)throw new Error("cloud.callFunction is required");var e=h(t.callFunction.bind(t));return t.models=e,t}var S={init:_,generateHTTPClient:m};t.default=S,t.generateHTTPClient=m,t.init=_,Object.defineProperty(t,"__esModule",{value:!0})}(e)},972:function(t,e,r){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}},o=n(r(2856)),i=r(7170),s=r(2363),a=r(614),u=r(9063),c=r(7505),l=r(9679),f=r(7801),h=r(7596),d=r(8622),p=n(r(4536)).default.version;o.default.registerVersion(p);try{(0,i.registerAuth)(o.default),(0,s.registerFunctions)(o.default),(0,a.registerStorage)(o.default),(0,d.registerDatabase)(o.default),(0,u.registerRealtime)(o.default),(0,c.registerAnalytics)(o.default),(0,l.registerModel)(o.default),(0,f.registerAi)(o.default),(0,h.registerCloudrun)(o.default)}catch(t){}try{window.cloudbase=o.default}catch(t){}e.default=o.default,t.exports=o.default},7801:function(t,e,r){"use strict";r.r(e),r.d(e,{AI:function(){return ne},Bot:function(){return M},SimpleChatModel:function(){return oe},createAi:function(){return ce},models:function(){return ae},registerAi:function(){return fe},utils:function(){return n}});var n={};r.r(n),r.d(n,{ReadableStream:function(){return E},TextDecoderStream:function(){return R},TransformStream:function(){return I},createAsyncIterable:function(){return A},createEventSourceParserTransformStream:function(){return O},createPromise:function(){return N},functionToolToModelTool:function(){return j},intoStandardStream:function(){return P},intoTextStream:function(){return x},isToolCallAssistantMessage:function(){return L},readableStream2JsonObject:function(){return C},toPolyfillReadable:function(){return T}});var o={};r.r(o),r.d(o,{ArkSimpleModel:function(){return at},DSSimpleModel:function(){return ht},DefaultSimpleModel:function(){return qt},HunYuanBetaSimpleModel:function(){return Z},HunYuanExpSimpleModel:function(){return Tt},HunYuanOpenSimpleModel:function(){return xt},HunYuanSimpleModel:function(){return rt},MODELS:function(){return Qt},MoonshotSimpleModel:function(){return St},ReactModel:function(){return Ht},YiSimpleModel:function(){return gt},ZhiPuSimpleModel:function(){return G},toolMap:function(){return Kt}});var i=r(5993),s=function(t,e){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},s(t,e)};function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}s(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function u(t){if(!t)throw new TypeError("Assertion failed")}function c(){}function l(t){return!(e=t,("object"!=typeof e||null===e)&&"function"!=typeof e||"function"!=typeof t.getReader);var e}function f(t){try{return t.getReader({mode:"byob"}).releaseLock(),!0}catch(t){return!1}}function h(t,e){var r=(void 0===e?{}:e).type;return u(l(t)),u(!1===t.locked),"bytes"===(r=d(r))?new g(t):new y(t)}function d(t){var e=String(t);if("bytes"===e)return e;if(void 0===t)return t;throw new RangeError("Invalid type is specified")}var p=function(){function t(t){this._underlyingReader=void 0,this._readerMode=void 0,this._readableStreamController=void 0,this._pendingRead=void 0,this._underlyingStream=t,this._attachDefaultReader()}return t.prototype.start=function(t){this._readableStreamController=t},t.prototype.cancel=function(t){return u(void 0!==this._underlyingReader),this._underlyingReader.cancel(t)},t.prototype._attachDefaultReader=function(){if("default"!==this._readerMode){this._detachReader();var t=this._underlyingStream.getReader();this._readerMode="default",this._attachReader(t)}},t.prototype._attachReader=function(t){var e=this;u(void 0===this._underlyingReader),this._underlyingReader=t;var r=this._underlyingReader.closed;r&&r.then((function(){return e._finishPendingRead()})).then((function(){t===e._underlyingReader&&e._readableStreamController.close()}),(function(r){t===e._underlyingReader&&e._readableStreamController.error(r)})).catch(c)},t.prototype._detachReader=function(){void 0!==this._underlyingReader&&(this._underlyingReader.releaseLock(),this._underlyingReader=void 0,this._readerMode=void 0)},t.prototype._pullWithDefaultReader=function(){var t=this;this._attachDefaultReader();var e=this._underlyingReader.read().then((function(e){var r=t._readableStreamController;e.done?t._tryClose():r.enqueue(e.value)}));return this._setPendingRead(e),e},t.prototype._tryClose=function(){try{this._readableStreamController.close()}catch(t){}},t.prototype._setPendingRead=function(t){var e,r=this,n=function(){r._pendingRead===e&&(r._pendingRead=void 0)};this._pendingRead=e=t.then(n,n)},t.prototype._finishPendingRead=function(){var t=this;if(this._pendingRead){var e=function(){return t._finishPendingRead()};return this._pendingRead.then(e,e)}},t}(),y=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return a(e,t),e.prototype.pull=function(){return this._pullWithDefaultReader()},e}(p);function v(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}var g=function(t){function e(e){var r=this,n=f(e);return(r=t.call(this,e)||this)._supportsByob=n,r}return a(e,t),Object.defineProperty(e.prototype,"type",{get:function(){return"bytes"},enumerable:!1,configurable:!0}),e.prototype._attachByobReader=function(){if("byob"!==this._readerMode){u(this._supportsByob),this._detachReader();var t=this._underlyingStream.getReader({mode:"byob"});this._readerMode="byob",this._attachReader(t)}},e.prototype.pull=function(){if(this._supportsByob){var t=this._readableStreamController.byobRequest;if(t)return this._pullWithByobRequest(t)}return this._pullWithDefaultReader()},e.prototype._pullWithByobRequest=function(t){var e=this;this._attachByobReader();var r=new Uint8Array(t.view.byteLength),n=this._underlyingReader.read(r).then((function(r){var n,o,i;e._readableStreamController,r.done?(e._tryClose(),t.respond(0)):(n=r.value,o=t.view,i=v(n),v(o).set(i,0),t.respond(r.value.byteLength))}));return this._setPendingRead(n),n},e}(p);!function(){function t(t){var e=this;this._writableStreamController=void 0,this._pendingWrite=void 0,this._state="writable",this._storedError=void 0,this._underlyingWriter=t,this._errorPromise=new Promise((function(t,r){e._errorPromiseReject=r})),this._errorPromise.catch(c)}t.prototype.start=function(t){var e=this;this._writableStreamController=t,this._underlyingWriter.closed.then((function(){e._state="closed"})).catch((function(t){return e._finishErroring(t)}))},t.prototype.write=function(t){var e=this,r=this._underlyingWriter;if(null===r.desiredSize)return r.ready;var n=r.write(t);n.catch((function(t){return e._finishErroring(t)})),r.ready.catch((function(t){return e._startErroring(t)}));var o=Promise.race([n,this._errorPromise]);return this._setPendingWrite(o),o},t.prototype.close=function(){var t=this;return void 0===this._pendingWrite?this._underlyingWriter.close():this._finishPendingWrite().then((function(){return t.close()}))},t.prototype.abort=function(t){if("errored"!==this._state)return this._underlyingWriter.abort(t)},t.prototype._setPendingWrite=function(t){var e,r=this,n=function(){r._pendingWrite===e&&(r._pendingWrite=void 0)};this._pendingWrite=e=t.then(n,n)},t.prototype._finishPendingWrite=function(){var t=this;if(void 0===this._pendingWrite)return Promise.resolve();var e=function(){return t._finishPendingWrite()};return this._pendingWrite.then(e,e)},t.prototype._startErroring=function(t){var e=this;if("writable"===this._state){this._state="erroring",this._storedError=t;var r=function(){return e._finishErroring(t)};void 0===this._pendingWrite?r():this._finishPendingWrite().then(r,r),this._writableStreamController.error(t)}},t.prototype._finishErroring=function(t){"writable"===this._state&&this._startErroring(t),"erroring"===this._state&&(this._state="errored",this._errorPromiseReject(this._storedError))}}(),function(){function t(t,e){var r=this;this._transformStreamController=void 0,this._onRead=function(t){if(!t.done)return r._transformStreamController.enqueue(t.value),r._reader.read().then(r._onRead)},this._onError=function(t){r._flushReject(t),r._transformStreamController.error(t),r._reader.cancel(t).catch(c),r._writer.abort(t).catch(c)},this._onTerminate=function(){r._flushResolve(),r._transformStreamController.terminate();var t=new TypeError("TransformStream terminated");r._writer.abort(t).catch(c)},this._reader=t,this._writer=e,this._flushPromise=new Promise((function(t,e){r._flushResolve=t,r._flushReject=e}))}t.prototype.start=function(t){this._transformStreamController=t,this._reader.read().then(this._onRead).then(this._onTerminate,this._onError);var e=this._reader.closed;e&&e.then(this._onTerminate,this._onError)},t.prototype.transform=function(t){return this._writer.write(t)},t.prototype.flush=function(){var t=this;return this._writer.close().then((function(){return t._flushPromise}))}}();var m=[239,187,191],b=r(4410),w=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},_=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},S=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,r=t[Symbol.asyncIterator];return r?r.call(t):(t="function"==typeof __values?__values(t):t[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(r){e[r]=t[r]&&function(e){return new Promise((function(n,o){!function(t,e,r,n){Promise.resolve(n).then((function(e){t({value:e,done:r})}),e)}(n,o,(e=t[r](e)).done,e.value)}))}}},E=i.Pz,I=i.GJ,O=function(){var t;return new I({start:function(e){t=function(t){var e,r,n,o,i,s,a;return u(),{feed:function(t){r=r?r+t:t,e&&function(t){return m.every((function(e,r){return t.charCodeAt(r)===e}))}(r)&&(r=r.slice(m.length)),e=!1;for(var i=r.length,s=0,a=!1;s<i;){a&&("\n"===r[s]&&(s+=1),a=!1);for(var u=-1,l=o,f=void 0,h=n;u<0&&h<i;h++)":"===(f=r[h])&&l<0?l=h-s:"\r"===f?(a=!0,u=h-s):"\n"===f&&(u=h-s);if(u<0){n=i-s,o=l;break}n=0,o=-1,c(r,s,l,u),s+=u+1}s===i?r="":s>0&&(r=r.slice(s))},reset:u};function u(){e=!0,r="",n=0,o=-1,i=void 0,s=void 0,a=""}function c(e,r,n,o){if(0===o)return a.length>0&&(t({type:"event",id:i,event:s||void 0,data:a.slice(0,-1)}),a="",i=void 0),void(s=void 0);var u,c=n<0,l=e.slice(r,r+(c?o:n)),f=r+(u=c?o:" "===e[r+n+1]?n+2:n+1),h=o-u,d=e.slice(f,f+h).toString();if("data"===l)a+=d?"".concat(d,"\n"):"\n";else if("event"===l)s=d;else if("id"!==l||d.includes("\0")){if("retry"===l){var p=parseInt(d,10);Number.isNaN(p)||t({type:"reconnect-interval",value:p})}}else i=d}}((function(t){"event"===t.type&&e.enqueue(t)}))},transform:function(e){t.feed(e)}})},T=function(t){u(function(t){return!!function(t){if("function"!=typeof t)return!1;var e=!1;try{new t({start:function(){e=!0}})}catch(t){}return e}(t)&&!!l(new t)}(t));var e=function(t){try{return new t({type:"bytes"}),!0}catch(t){return!1}}(t);return function(r,n){var o=(void 0===n?{}:n).type;if("bytes"!==(o=d(o))||e||(o=void 0),r.constructor===t&&("bytes"!==o||f(r)))return r;if("bytes"===o){var i=h(r,{type:o});return new t(i)}return i=h(r),new t(i)}}(E),R=function(){function t(t,e){void 0===t&&(t="utf-8"),void 0===e&&(e={});var r=this;this.transform=new I({transform:function(t,e){var n=r.handle.decode(new Uint8Array(t),{stream:!0});n&&e.enqueue(n)},flush:function(t){var e=r.handle.decode();e&&t.enqueue(e),t.terminate()}}),this.handle=new b.TextDecoder(t,e)}return Object.defineProperty(t.prototype,"encoding",{get:function(){return this.handle.encoding},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fatal",{get:function(){return this.handle.fatal},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ignoreBOM",{get:function(){return this.handle.ignoreBOM},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"readable",{get:function(){return this.transform.readable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"writable",{get:function(){return this.transform.writable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,Symbol.toStringTag,{get:function(){return"TextDecoderStream"},enumerable:!1,configurable:!0}),t}();function A(t){var e=t;return e[Symbol.asyncIterator]=function(){var e=t.getReader();return{next:function(){return w(this,void 0,void 0,(function(){var t,r,n;return _(this,(function(o){switch(o.label){case 0:return[4,e.read()];case 1:return t=o.sent(),r=t.done,n=t.value,[2,r?{done:!0,value:void 0}:{done:!1,value:n}]}}))}))}}},e}function P(t){return A(t.pipeThrough(new R).pipeThrough(O()).pipeThrough(new I({transform:function(t,e){try{var r=JSON.parse(t.data);e.enqueue(r)}catch(r){"[DONE]"!==t.data?console.warn("Error when transforming event source data to json",r,t):e.terminate()}}})))}function x(t){return A(T(t).pipeThrough(new R))}function C(t){var e,r,n,o;return w(this,void 0,void 0,(function(){var i,s,a,u,c,l;return _(this,(function(f){switch(f.label){case 0:i=x(t),s="",f.label=1;case 1:f.trys.push([1,6,7,12]),a=!0,u=S(i),f.label=2;case 2:return[4,u.next()];case 3:if(c=f.sent(),e=c.done)return[3,5];o=c.value,a=!1;try{s+=o}finally{a=!0}f.label=4;case 4:return[3,2];case 5:return[3,12];case 6:return l=f.sent(),r={error:l},[3,12];case 7:return f.trys.push([7,,10,11]),a||e||!(n=u.return)?[3,9]:[4,n.call(u)];case 8:f.sent(),f.label=9;case 9:return[3,11];case 10:if(r)throw r.error;return[7];case 11:return[7];case 12:return[2,JSON.parse(s)]}}))}))}function N(){var t,e;return{promise:new Promise((function(r,n){t=r,e=n})),res:t,rej:e}}function L(t){var e;return"assistant"===t.role&&"tool_calls"in t&&null!=(null===(e=t.tool_calls)||void 0===e?void 0:e[0])}function j(t){return{type:"function",function:{description:t.description,name:t.name,parameters:t.parameters}}}var U=function(){return U=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},U.apply(this,arguments)},k=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},D=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},q=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r},M=function(){function t(t,e){this.baseUrl=e;var r=arguments[2];this.req="string"==typeof r?function(e){var n=e.headers,o=void 0===n?{}:n,i=q(e,["headers"]);return t(U(U({},i),{headers:U(U({},o),{Authorization:"Bearer ".concat(r)})}))}:t}return t.prototype.list=function(t,e){return this.req({method:"get",url:this.join("bots"),data:t,timeout:null==e?void 0:e.timeout})},t.prototype.create=function(t,e){var r=t.botInfo;return this.req({method:"post",url:this.join("bots"),data:r,timeout:null==e?void 0:e.timeout})},t.prototype.get=function(t,e){var r=t.botId;return this.req({method:"get",url:this.join("bots/".concat(r)),timeout:null==e?void 0:e.timeout})},t.prototype.update=function(t,e){var r=t.botId,n=t.botInfo;return this.req({method:"PATCH",url:this.join("bots/".concat(r)),data:n,timeout:null==e?void 0:e.timeout})},t.prototype.delete=function(t,e){var r=t.botId;return this.req({method:"delete",url:this.join("bots/".concat(r)),timeout:null==e?void 0:e.timeout})},t.prototype.getChatRecords=function(t,e){return this.req({method:"get",url:this.join("bots/".concat(t.botId,"/records")),data:t,timeout:null==e?void 0:e.timeout})},t.prototype.sendFeedback=function(t,e){var r=t.userFeedback;return this.req({method:"post",url:this.join("bots/".concat(r.botId,"/feedback")),data:r,timeout:null==e?void 0:e.timeout})},t.prototype.getFeedback=function(t,e){return this.req({method:"get",url:this.join("bots/".concat(t.botId,"/feedback")),data:t,timeout:null==e?void 0:e.timeout})},t.prototype.uploadFiles=function(t,e){return k(this,void 0,void 0,(function(){return D(this,(function(r){return[2,this.req({method:"post",url:this.join("bots/".concat(t.botId,"/files")),data:t,timeout:null==e?void 0:e.timeout})]}))}))},t.prototype.createConversation=function(t,e){var r=t.botId,n=q(t,["botId"]);return k(this,void 0,void 0,(function(){return D(this,(function(t){return[2,this.req({method:"post",url:this.join("bots/".concat(r,"/conversation")),data:n,timeout:null==e?void 0:e.timeout})]}))}))},t.prototype.getConversation=function(t,e){var r=t.pageSize,n=void 0===r?10:r,o=t.pageNumber,i=void 0===o?1:o,s=t.botId,a=q(t,["pageSize","pageNumber","botId"]);return k(this,void 0,void 0,(function(){var t,r;return D(this,(function(o){if(i<1)throw new Error("pageNumber must be greater than 0");return t=n*(i-1),r=n,[2,this.req({method:"get",url:this.join("bots/".concat(s,"/conversation")),data:U(U({},a),{offset:t,limit:r}),timeout:null==e?void 0:e.timeout})]}))}))},t.prototype.deleteConversation=function(t,e){var r=t.botId,n=t.conversationId,o=q(t,["botId","conversationId"]);return k(this,void 0,void 0,(function(){return D(this,(function(t){return[2,this.req({method:"delete",url:this.join("bots/".concat(r,"/conversation/").concat(n)),data:o,timeout:null==e?void 0:e.timeout})]}))}))},t.prototype.speechToText=function(t,e){return k(this,void 0,void 0,(function(){return D(this,(function(r){return[2,this.req({method:"post",url:this.join("bots/".concat(t.botId,"/speech-to-text")),data:t,timeout:null==e?void 0:e.timeout})]}))}))},t.prototype.textToSpeech=function(t,e){return k(this,void 0,void 0,(function(){return D(this,(function(r){return[2,this.req({method:"post",url:this.join("bots/".concat(t.botId,"/text-to-speech")),data:t,timeout:null==e?void 0:e.timeout})]}))}))},t.prototype.getTextToSpeechResult=function(t,e){return k(this,void 0,void 0,(function(){return D(this,(function(r){return[2,this.req({method:"get",url:this.join("bots/".concat(t.botId,"/text-to-speech")),data:t,timeout:null==e?void 0:e.timeout})]}))}))},t.prototype.getRecommendQuestions=function(t,e){return k(this,void 0,void 0,(function(){var r;return D(this,(function(n){switch(n.label){case 0:return[4,this.req({method:"post",url:this.join("bots/".concat(t.botId,"/recommend-questions")),data:t,stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return r=n.sent(),[2,new B(r)]}}))}))},t.prototype.generateBot=function(t,e){return k(this,void 0,void 0,(function(){var r;return D(this,(function(n){switch(n.label){case 0:return[4,this.req({method:"post",url:this.join("generate-bot"),data:t,stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return r=n.sent(),[2,new B(r)]}}))}))},t.prototype.getPreview=function(t,e){return k(this,void 0,void 0,(function(){var r;return D(this,(function(n){switch(n.label){case 0:return[4,this.req({method:"post",url:this.join("preview"),data:t,stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return r=n.sent(),[2,new B(r)]}}))}))},t.prototype.generateImage=function(t,e){return this.req({method:"post",url:this.join("generate-image"),data:t,timeout:null==e?void 0:e.timeout})},t.prototype.sendMessage=function(t,e){return k(this,void 0,void 0,(function(){var r;return D(this,(function(n){switch(n.label){case 0:return[4,this.req({method:"post",url:this.join("bots/".concat(t.botId,"/send-message")),data:t,stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return r=n.sent(),[2,new B(r)]}}))}))},t.prototype.join=function(t){return"".concat(this.baseUrl,"/").concat(t)},t}(),B=function(){function t(t){var e=T(t);this._eventSourceStream=e.pipeThrough(new R).pipeThrough(O())}return Object.defineProperty(t.prototype,"teeedStream",{get:function(){var t=this._eventSourceStream.tee(),e=t[0],r=t[1];return this._eventSourceStream=r,e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"eventSourceStream",{get:function(){return A(this.teeedStream)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dataStream",{get:function(){return A(this.eventSourceStream.pipeThrough(new I({transform:function(t,e){try{var r=JSON.parse(t.data);e.enqueue(r)}catch(r){"[DONE]"!==t.data?console.warn("Error when transforming event source data to json",r,t):e.terminate()}}})))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textStream",{get:function(){return A(this.dataStream.pipeThrough(new I({transform:function(t,e){var r;e.enqueue(null!==(r=null==t?void 0:t.content)&&void 0!==r?r:"")}})))},enumerable:!1,configurable:!0}),t}(),W=function(){return W=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},W.apply(this,arguments)},F=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},V=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};function H(t){var e=t.messages,r=t.model,n=t.temperature,o=t.tool_choice,i=t.tools,s=t.top_p;return W(W({},t),{messages:e,model:r,temperature:n,tool_choice:(o&&"auto"!==o&&console.warn("`tool_choice` is not 'auto'"),o),tools:i,top_p:s})}var G=function(){function t(t,e,r){this.req=t,this.baseUrl=e,this.subUrl="zhipu/api/paas/v4/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return F(this,void 0,void 0,(function(){var r,n;return V(this,(function(o){switch(o.label){case 0:return r=H(t),[4,this.req({url:this.url,data:W(W({},r),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return n=o.sent(),[2,W(W({},n),{rawResponse:n})]}}))}))},t.prototype.doStream=function(t,e){return F(this,void 0,void 0,(function(){var r,n,o,i;return V(this,(function(s){switch(s.label){case 0:return r=H(t),n=null,[4,this.req({url:this.url,data:W(W({},r),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return o=s.sent(),i=T(o),[2,A(P(i).pipeThrough(new I({transform:function(t,e){var r=t.choices.map((function(t){var e=t.delta;return null==n&&(n=L(e)),n?W(W({},t),{finish_reason:"tool_calls",delta:e}):t})),o=W(W({},t),{choices:r});e.enqueue(W(W({},o),{rawResponse:t}))}})))]}}))}))},t}(),$=function(){return $=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},$.apply(this,arguments)};function K(t){var e=t.messages,r=t.model,n=t.temperature,o=t.tool_choice,i=t.tools,s=t.top_p;return $($({},t),{messages:(e.forEach((function(t){"tool_calls"in t&&t.tool_calls.filter((function(t){return"function"!==t.type})).forEach((function(e){return console.warn("`type` in tool_call is not 'function'",e,t)}))})),e),model:r,tools:function(){if(i)return i.forEach((function(t){"function"!==t.type&&console.warn("`type` in tool is not 'function'",t)})),i}(),top_p:s,tool_choice:o,temperature:n})}function z(t){return"object"!=typeof t||null==t?t:Array.isArray(t)?t.map((function(t){return z(t)})):Object.entries(t).reduce((function(t,e){var r,n=e[0],o=e[1];return t["_"===(r=n.replace(/[A-Z]/g,(function(t){return"_".concat(t.toLowerCase())}))).charAt(0)?r.slice(1):r]="object"==typeof o?z(o):o,t}),{})}var J=function(){return J=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},J.apply(this,arguments)},Y=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},Q=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},Z=function(){function t(t,e,r){this.req=t,this.baseUrl=e,this.subUrl="hunyuan-beta/openapi/v1/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return Y(this,void 0,void 0,(function(){var r;return Q(this,(function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:J(J({},K(t)),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return r=n.sent(),[2,J(J({},r),{rawResponse:r})]}}))}))},t.prototype.doStream=function(t,e){return Y(this,void 0,void 0,(function(){var r,n,o;return Q(this,(function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:J(J({},K(t)),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return n=i.sent(),o=T(n),[2,A(P(o).pipeThrough(new I({transform:function(t,e){var n=t.choices.map((function(t){var e=t.delta;return null==r&&(r=L(e)),r?J(J({},t),{finish_reason:"tool_calls",delta:e}):t})),o=J(J({},t),{choices:n});e.enqueue(J(J({},o),{rawResponse:t}))}})))]}}))}))},t}(),X=function(){return X=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},X.apply(this,arguments)},tt=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},et=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},rt=function(){function t(t,e,r){this.req=t,this.baseUrl=e,this.subUrl="hunyuan",null!=r&&(this.subUrl=r)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return tt(this,void 0,void 0,(function(){var r,n;return et(this,(function(o){switch(o.label){case 0:return[4,this.req({url:this.url,headers:{"X-Tc-Action":"ChatCompletions"},data:X(X({},K(t)),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return r=o.sent(),n=z(r.Response),[2,X(X({},n),{rawResponse:r})]}}))}))},t.prototype.doStream=function(t,e){return tt(this,void 0,void 0,(function(){var r,n,o;return et(this,(function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,headers:{"X-Tc-Action":"ChatCompletions"},data:X(X({},t),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return n=i.sent(),o=T(n),[2,A(P(o).pipeThrough(new I({transform:function(t,e){var n=z(t),o=n.choices.map((function(t){var e=t.delta;return null==r&&(r=L(e)),r?X(X({},t),{finish_reason:"tool_calls",delta:e}):t})),i=X(X({},n),{choices:o});e.enqueue(X(X({},i),{rawResponse:t}))}})))]}}))}))},t}(),nt=function(){return nt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},nt.apply(this,arguments)},ot=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},it=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};function st(t){var e=t.messages,r=t.model,n=t.temperature,o=t.tools,i=t.top_p;return nt(nt({},t),{messages:e,model:r,tools:o,top_p:i,temperature:n})}var at=function(){function t(t,e,r){this.req=t,this.baseUrl=e,this.subUrl="ark/api/v3/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return ot(this,void 0,void 0,(function(){var r;return it(this,(function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:nt(nt({},st(t)),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return r=n.sent(),[2,nt(nt({},r),{rawResponse:r})]}}))}))},t.prototype.doStream=function(t,e){return ot(this,void 0,void 0,(function(){var r,n,o;return it(this,(function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:nt(nt({},st(t)),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return n=i.sent(),o=T(n),[2,A(P(o).pipeThrough(new I({transform:function(t,e){var n=t.choices.map((function(t){var e=t.delta;return null==r&&(r=L(e)),r?nt(nt({},t),{finish_reason:"tool_calls",delta:e}):t})),o=nt(nt({},t),{choices:n});e.enqueue(nt(nt({},o),{rawResponse:t}))}})))]}}))}))},t}(),ut=function(){return ut=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},ut.apply(this,arguments)},ct=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},lt=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};function ft(t){var e=t.messages,r=t.model,n=t.temperature,o=t.tools,i=t.top_p;return ut(ut({},t),{messages:e,model:r,tools:o,top_p:i,temperature:n})}var ht=function(){function t(t,e,r){this.req=t,this.baseUrl=e,this.subUrl="dashscope/compatible-mode/v1/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return ct(this,void 0,void 0,(function(){var r;return lt(this,(function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:ut(ut({},ft(t)),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return r=n.sent(),[2,ut(ut({},r),{rawResponse:r})]}}))}))},t.prototype.doStream=function(t,e){return ct(this,void 0,void 0,(function(){var r,n,o;return lt(this,(function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:ut(ut({},ft(t)),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return n=i.sent(),o=T(n),[2,A(P(o).pipeThrough(new I({transform:function(t,e){var n=t.choices.map((function(t){var e=Object.assign(t.delta,{role:"assistant"});return null==r&&(r=L(e)),ut(ut({},t),r?{finish_reason:"tool_calls",delta:e}:{delta:e})})),o=ut(ut({},t),{choices:n});e.enqueue(ut(ut({},o),{rawResponse:t}))}})))]}}))}))},t}(),dt=function(){return dt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},dt.apply(this,arguments)},pt=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},yt=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};function vt(t){var e=t.messages,r=t.model,n=t.temperature,o=t.tools,i=t.top_p;return dt(dt({},t),{messages:e,model:r,tools:o,top_p:i,temperature:n})}var gt=function(){function t(t,e,r){this.req=t,this.baseUrl=e,this.subUrl="01-ai/v1/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return pt(this,void 0,void 0,(function(){var r;return yt(this,(function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:dt(dt({},vt(t)),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return r=n.sent(),[2,dt(dt({},r),{rawResponse:r})]}}))}))},t.prototype.doStream=function(t,e){return pt(this,void 0,void 0,(function(){var r,n,o,i,s;return yt(this,(function(a){switch(a.label){case 0:return r=null,[4,this.req({url:this.url,data:dt(dt({},vt(t)),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return n=a.sent(),o=T(n),i=P(o),s=i.pipeThrough(new I({transform:function(t,e){var n,o,i,s,a,u;if((null===(i=null===(o=null===(n=null==t?void 0:t.choices)||void 0===n?void 0:n[0])||void 0===o?void 0:o.delta)||void 0===i?void 0:i.content)||(null===(u=null===(a=null===(s=null==t?void 0:t.choices)||void 0===s?void 0:s[0])||void 0===a?void 0:a.delta)||void 0===u?void 0:u.tool_calls)){var c=t.choices.map((function(t){var e=Object.assign(t.delta,{role:"assistant"});return null==r&&(r=L(e)),dt(dt({},t),r?{finish_reason:"tool_calls",delta:e}:{delta:e})})),l=dt(dt({},t),{choices:c});e.enqueue(dt(dt({},l),{rawResponse:t}))}}})),[2,A(s)]}}))}))},t}(),mt=function(){return mt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},mt.apply(this,arguments)},bt=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},wt=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};function _t(t){var e=t.messages,r=t.model,n=t.temperature,o=t.tools,i=t.top_p;return mt(mt({},t),{messages:e,model:r,tools:o,top_p:i,temperature:n})}var St=function(){function t(t,e,r){this.req=t,this.baseUrl=e,this.subUrl="moonshot/v1/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return bt(this,void 0,void 0,(function(){var r;return wt(this,(function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:mt(mt({},_t(t)),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return r=n.sent(),[2,mt(mt({},r),{rawResponse:r})]}}))}))},t.prototype.doStream=function(t,e){return bt(this,void 0,void 0,(function(){var r,n,o;return wt(this,(function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:mt(mt({},_t(t)),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return n=i.sent(),o=T(n),[2,A(P(o).pipeThrough(new I({transform:function(t,e){var n=t.choices.map((function(t){var e=t.delta;return null==r&&(r=L(e)),r?mt(mt({},t),{finish_reason:"tool_calls",delta:e}):t})),o=mt(mt({},t),{choices:n});e.enqueue(mt(mt({},o),{rawResponse:t}))}})))]}}))}))},t}(),Et=function(){return Et=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Et.apply(this,arguments)},It=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},Ot=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},Tt=function(){function t(t,e,r){this.req=t,this.baseUrl=e,this.subUrl="hunyuan-exp/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t){return It(this,void 0,void 0,(function(){var e;return Ot(this,(function(r){switch(r.label){case 0:return[4,this.req({url:this.url,data:Et(Et({},K(t)),{stream:!1}),stream:!1})];case 1:return e=r.sent(),[2,Et(Et({},e),{rawResponse:e})]}}))}))},t.prototype.doStream=function(t){return It(this,void 0,void 0,(function(){var e,r,n;return Ot(this,(function(o){switch(o.label){case 0:return e=null,[4,this.req({url:this.url,data:Et(Et({},K(t)),{stream:!0}),stream:!0})];case 1:return r=o.sent(),n=T(r),[2,A(P(n).pipeThrough(new I({transform:function(t,r){var n=t.choices.map((function(t){var r=t.delta;return null==e&&(e=L(r)),e?Et(Et({},t),{finish_reason:"tool_calls",delta:r}):t})),o=Et(Et({},t),{choices:n});r.enqueue(Et(Et({},o),{rawResponse:t}))}})))]}}))}))},t}(),Rt=function(){return Rt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Rt.apply(this,arguments)},At=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},Pt=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},xt=function(){function t(t,e,r){this.req=t,this.baseUrl=e,this.subUrl="hunyuan-open/v1/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return At(this,void 0,void 0,(function(){var r;return Pt(this,(function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:Rt(Rt({},K(t)),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return r=n.sent(),[2,Rt(Rt({},r),{rawResponse:r})]}}))}))},t.prototype.doStream=function(t,e){return At(this,void 0,void 0,(function(){var r,n,o;return Pt(this,(function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:Rt(Rt({},K(t)),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return n=i.sent(),o=T(n),[2,A(P(o).pipeThrough(new I({transform:function(t,e){var n=t.choices.map((function(t){var e=t.delta;return null==r&&(r=L(e)),r?Rt(Rt({},t),{finish_reason:"tool_calls",delta:e}):t})),o=Rt(Rt({},t),{choices:n});e.enqueue(Rt(Rt({},o),{rawResponse:t}))}})))]}}))}))},t}(),Ct=function(){return Ct=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Ct.apply(this,arguments)},Nt=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},Lt=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},jt=function(){function t(t,e,r){this.req=t,this.baseUrl=e,this.subUrl="deepseek/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return Nt(this,void 0,void 0,(function(){var r;return Lt(this,(function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:Ct(Ct({},t),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return r=n.sent(),[2,Ct(Ct({},r),{rawResponse:r})]}}))}))},t.prototype.doStream=function(t,e){return Nt(this,void 0,void 0,(function(){var r,n,o;return Lt(this,(function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:Ct(Ct({},t),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return n=i.sent(),o=T(n),[2,A(P(o).pipeThrough(new I({transform:function(t,e){var n=t.choices.map((function(t){var e=t.delta;return null==r&&(r=L(e)),r?Ct(Ct({},t),{finish_reason:"tool_calls",delta:e}):t})),o=Ct(Ct({},t),{choices:n});e.enqueue(Ct(Ct({},o),{rawResponse:t}))}})))]}}))}))},t}(),Ut=function(){return Ut=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Ut.apply(this,arguments)},kt=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},Dt=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},qt=function(){function t(t,e,r){void 0===r&&(r=""),this.req=t,this.baseUrl=e,this.subUrl=r}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t){return kt(this,void 0,void 0,(function(){var e;return Dt(this,(function(r){switch(r.label){case 0:return[4,this.req({url:this.url,data:Ut(Ut({},t),{stream:!1}),stream:!1})];case 1:return e=r.sent(),[2,Ut(Ut({},e),{rawResponse:e})]}}))}))},t.prototype.doStream=function(t){return kt(this,void 0,void 0,(function(){var e,r,n;return Dt(this,(function(o){switch(o.label){case 0:return e=null,[4,this.req({url:this.url,data:Ut(Ut({},t),{stream:!0}),stream:!0})];case 1:return r=o.sent(),n=T(r),[2,A(P(n).pipeThrough(new I({transform:function(t,r){var n=t.choices.map((function(t){var r=t.delta;return null==e&&(e=L(r)),e?Ut(Ut({},t),{finish_reason:"tool_calls",delta:r}):t})),o=Ut(Ut({},t),{choices:n});r.enqueue(Ut(Ut({},o),{rawResponse:t}))}})))]}}))}))},t}(),Mt=function(){return Mt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Mt.apply(this,arguments)},Bt=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},Wt=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},Ft=function(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))};function Vt(t){var e,r=t.onStepFinish,n=t.abortSignal,o=t.maxSteps,i=t.topP,s=t.toolChoice,a=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}(t,["onStepFinish","abortSignal","maxSteps","topP","toolChoice"]);if(null!=o&&o<1)throw new Error("`maxSteps` muse be greater than 0.");return[{onStepFinish:r,abortSignal:n,maxSteps:o},Mt(Mt({},a),{tools:null===(e=a.tools)||void 0===e?void 0:e.map((function(t){return"fn"in t?j(t):t})),top_p:null!=i?i:a.top_p,tool_choice:null!=s?s:a.tool_choice})]}var Ht=function(){function t(t){this.model=t}return t.prototype.generateText=function(t,e){var r,n;return Bt(this,void 0,void 0,(function(){var o,i,s,a,u,c,l,f,h,d,p,y,v,g,m,b,w,_,S,E,I,O=this;return Wt(this,(function(T){switch(T.label){case 0:return o=[],i={completion_tokens:0,prompt_tokens:0,total_tokens:0},s=Vt(t),a=s[0],u=a.onStepFinish,c=a.maxSteps,l=void 0===c?10:c,f=s[1],[4,(h=function(){return O.model.doGenerate(f,e)})()];case 1:d=T.sent(),p=1,d.rawResponse&&o.push(d.rawResponse),y=null,T.label=2;case 2:if(!(p<l&&null!=(y=Gt(d))))return[3,9];v=Jt(d.usage),Yt(i,v),T.label=3;case 3:return T.trys.push([3,7,,8]),[4,zt(y)];case 4:return g=T.sent(),m=d.choices[0],[4,null==u?void 0:u({finishReason:m.finish_reason,messages:f.messages.slice(),text:m.message.content,toolCall:y,toolResult:g,stepUsage:v,totalUsage:Object.assign({},i)})];case 5:return T.sent(),$t(f.messages,m.message,g),[4,h()];case 6:return(d=T.sent()).rawResponse&&o.push(d.rawResponse),p+=1,[3,8];case 7:return b=T.sent(),[2,{text:"",messages:f.messages,usage:i,error:b,rawResponses:o}];case 8:return[3,2];case 9:return w=null===(r=null==d?void 0:d.choices)||void 0===r?void 0:r[0],_=null==w?void 0:w.message,S=null!==(n=null==_?void 0:_.content)&&void 0!==n?n:"",E=_?Ft(Ft([],f.messages,!0),[_],!1):f.messages,I=Jt(d.usage),Yt(i,I),[4,null==u?void 0:u({finishReason:w.finish_reason,messages:E.slice(),text:S,toolCall:Gt(d),toolResult:null,stepUsage:I,totalUsage:Object.assign({},i)})];case 10:return T.sent(),[2,{text:S,messages:E,usage:i,rawResponses:o}]}}))}))},t.prototype.streamText=function(t,e){var r;return Bt(this,void 0,void 0,(function(){var n,o,i,s,a,u,c,l,f,h,d,p,y,v,g,m,b,w,_,S,E,O,T,R,P,x,C,L,j,U,k,D,q,M,B,W,F=this;return Wt(this,(function(V){switch(V.label){case 0:return n={completion_tokens:0,prompt_tokens:0,total_tokens:0},o=Vt(t),i=o[0],s=i.onStepFinish,a=i.maxSteps,u=void 0===a?10:a,c=o[1],[4,(l=function(){return F.model.doStream(c,e)})()];case 1:f=V.sent(),h=1,d=null,p=function(){var t=f.tee(),e=t[0],r=t[1];return f=A(e),function(t){var e,r,n,o,i,s,a,u,c,l;return Bt(this,void 0,void 0,(function(){var f,h,d,p,y,v,g,m,b,w,_,S,E;return Wt(this,(function(I){switch(I.label){case 0:f={completion_tokens:0,prompt_tokens:0,total_tokens:0},h=A(t),p={role:"assistant",content:"",tool_calls:[d={id:"",function:{name:"",arguments:""},type:""}]},I.label=1;case 1:I.trys.push([1,6,7,12]),y=!0,v=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,r=t[Symbol.asyncIterator];return r?r.call(t):(t="function"==typeof __values?__values(t):t[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(r){e[r]=t[r]&&function(e){return new Promise((function(n,o){!function(t,e,r,n){Promise.resolve(n).then((function(e){t({value:e,done:r})}),e)}(n,o,(e=t[r](e)).done,e.value)}))}}}(h),I.label=2;case 2:return[4,v.next()];case 3:if(g=I.sent(),e=g.done)return[3,5];o=g.value,y=!1;try{if(!(b=null==(m=o)?void 0:m.choices[0]))return[2,null];if(w=b.finish_reason,_=b.delta,"tool_calls"!==w)return[2,null];if(!_)return[3,4];if(_.content&&(p.content+=_.content),!("tool_calls"in _))return[3,4];(null==(S=null===(i=null==_?void 0:_.tool_calls)||void 0===i?void 0:i[0])?void 0:S.id)&&(d.id=S.id),(null==S?void 0:S.type)&&(d.type=S.type),(null===(s=null==S?void 0:S.function)||void 0===s?void 0:s.name)&&(d.function.name=S.function.name),(null===(a=null==S?void 0:S.function)||void 0===a?void 0:a.arguments)&&(d.function.arguments+=S.function.arguments),(null===(u=null==m?void 0:m.usage)||void 0===u?void 0:u.completion_tokens)&&(f.completion_tokens=m.usage.completion_tokens),(null===(c=null==m?void 0:m.usage)||void 0===c?void 0:c.prompt_tokens)&&(f.prompt_tokens=m.usage.prompt_tokens),(null===(l=null==m?void 0:m.usage)||void 0===l?void 0:l.total_tokens)&&(f.total_tokens=m.usage.total_tokens)}finally{y=!0}I.label=4;case 4:return[3,2];case 5:return[3,12];case 6:return E=I.sent(),r={error:E},[3,12];case 7:return I.trys.push([7,,10,11]),y||e||!(n=v.return)?[3,9]:[4,n.call(v)];case 8:I.sent(),I.label=9;case 9:return[3,11];case 10:if(r)throw r.error;return[7];case 11:return[7];case 12:return[2,{message:p,usage:f}]}}))}))}(r)},V.label=2;case 2:return(y=h<u)?[4,p()]:[3,4];case 3:y=null!=(d=V.sent()),V.label=4;case 4:if(!y)return[3,11];v=d.message,g=d.usage,Yt(n,g),m=null===(r=v.tool_calls)||void 0===r?void 0:r[0],V.label=5;case 5:return V.trys.push([5,9,,10]),[4,zt(m)];case 6:return b=V.sent(),[4,null==s?void 0:s({finishReason:"tool_calls",messages:c.messages.slice(),text:v.content,toolCall:m,toolResult:b,stepUsage:g,totalUsage:Object.assign({},n)})];case 7:return V.sent(),$t(c.messages,v,b),[4,l()];case 8:return f=V.sent(),[3,10];case 9:return w=V.sent(),_=f.tee(),S=_[0],E=_[1],[2,{messages:Promise.resolve(c.messages),dataStream:A(S),textStream:A(E.pipeThrough(new I({transform:function(t,e){var r,n,o,i=null===(o=null===(n=null===(r=null==t?void 0:t.choices)||void 0===r?void 0:r[0])||void 0===n?void 0:n.delta)||void 0===o?void 0:o.content;"string"==typeof i&&e.enqueue(i)}}))),usage:Promise.resolve(n),error:w}];case 10:return[3,2];case 11:return[4,p()];case 12:return(d=V.sent())?(O=d.message,T=d.usage,Yt(n,T),R=Ft(Ft([],c.messages,!0),[O],!1),s({messages:R.slice(),finishReason:"tool_call",stepUsage:T,text:O.content,toolCall:O.tool_calls[0],totalUsage:Object.assign({},n)}),P=f.tee(),x=P[0],C=P[1],[2,{messages:Promise.resolve(Ft(Ft([],c.messages,!0),[O],!1)),dataStream:A(x),textStream:A(C.pipeThrough(new I({transform:function(t,e){var r,n,o,i=null===(o=null===(n=null===(r=null==t?void 0:t.choices)||void 0===r?void 0:r[0])||void 0===n?void 0:n.delta)||void 0===o?void 0:o.content;"string"==typeof i&&e.enqueue(i)}}))),usage:Promise.resolve(n)}]):(L=N(),j=N(),U={role:"assistant",content:""},k="",D={completion_tokens:0,prompt_tokens:0,total_tokens:0},q=f.pipeThrough(new I({transform:function(t,e){var r,n,o,i,s,a,u,c,l=null===(o=null===(n=null===(r=null==t?void 0:t.choices)||void 0===r?void 0:r[0])||void 0===n?void 0:n.delta)||void 0===o?void 0:o.content;"string"==typeof l&&(U.content+=l);var f=null===(s=null===(i=null==t?void 0:t.choices)||void 0===i?void 0:i[0])||void 0===s?void 0:s.finish_reason;f&&(k=f),(null===(a=null==t?void 0:t.usage)||void 0===a?void 0:a.completion_tokens)&&(D.completion_tokens=t.usage.completion_tokens),(null===(u=null==t?void 0:t.usage)||void 0===u?void 0:u.prompt_tokens)&&(D.prompt_tokens=t.usage.prompt_tokens),(null===(c=null==t?void 0:t.usage)||void 0===c?void 0:c.total_tokens)&&(D.total_tokens=t.usage.total_tokens),e.enqueue(t)},flush:function(){L.res(Ft(Ft([],c.messages,!0),[U],!1)),Yt(n,D),j.res(Object.assign({},n)),null==s||s({messages:Ft(Ft([],c.messages,!0),[U],!1),finishReason:k,text:U.content,stepUsage:D,totalUsage:Object.assign({},n)})}})),M=q.tee(),B=M[0],W=M[1],[2,{messages:L.promise,dataStream:A(B),textStream:A(W.pipeThrough(new I({transform:function(t,e){var r,n,o,i=null===(o=null===(n=null===(r=null==t?void 0:t.choices)||void 0===r?void 0:r[0])||void 0===n?void 0:n.delta)||void 0===o?void 0:o.content;"string"==typeof i&&e.enqueue(i)}}))),usage:j.promise}])}}))}))},t}();function Gt(t){var e,r=null===(e=null==t?void 0:t.choices)||void 0===e?void 0:e[0];if(!r)return null;var n=r.finish_reason,o=r.message;return"tool_calls"!==n?null:o&&L(o)?o.tool_calls[0]:null}function $t(t,e,r){t.push(e,{role:"tool",tool_call_id:e.tool_calls[0].id,content:JSON.stringify(r)})}var Kt=new Map;function zt(t){return Kt.get(t.function.name)(JSON.parse(t.function.arguments))}function Jt(t){var e,r,n;return{completion_tokens:null!==(e=null==t?void 0:t.completion_tokens)&&void 0!==e?e:0,prompt_tokens:null!==(r=null==t?void 0:t.prompt_tokens)&&void 0!==r?r:0,total_tokens:null!==(n=null==t?void 0:t.total_tokens)&&void 0!==n?n:0}}function Yt(t,e){t.completion_tokens+=e.completion_tokens,t.prompt_tokens+=e.prompt_tokens,t.total_tokens+=e.total_tokens}var Qt={hunyuan:rt,"hunyuan-beta":Z,ark:at,dashscope:ht,"01-ai":gt,moonshot:St,zhipu:G,"hunyuan-exp":Tt,"hunyuan-open":xt,deepseek:jt},Zt=r(3616),Xt=function(){return Xt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Xt.apply(this,arguments)},te=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},ee=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},re=Qt,ne=function(){function t(t,e,r){var n=this;this.req=t,this.baseUrl=e,this.modelRequest=function(t){var e=t.url,r=t.data,o=t.headers,i=t.stream,s=t.timeout;return te(n,void 0,void 0,(function(){var t,n,a,u,c,l,f;return ee(this,(function(h){switch(h.label){case 0:return t={"Content-Type":"application/json"},i&&Object.assign(t,{Accept:"text/event-stream"}),[4,this.req.fetch({method:"post",headers:Xt(Xt((c={},c[null===(l=this.i18n)||void 0===l?void 0:l.LANG_HEADER_KEY]=null===(f=this.i18n)||void 0===f?void 0:f.lang,c),t),o),body:JSON.stringify(r),url:e,stream:i,timeout:s})];case 1:return n=h.sent(),a=n.data,u=n.header,[2,this.handleResponseData(a,u)]}}))}))},this.botRequest=function(t){var e=t.method,r=t.url,o=t.data,i=void 0===o?{}:o,s=t.headers,a=t.stream,u=t.timeout;return te(n,void 0,void 0,(function(){var t,n,o,c,l,f,h,d;return ee(this,(function(p){switch(p.label){case 0:return"get"!==e?[3,2]:(t=this.handleResponseData,[4,this.req.fetch({url:"".concat(r,"?").concat((y=i,Object.entries(y).map((function(t){var e=t[0],r=t[1];return"".concat(e,"=").concat(r)})).join("&"))),method:e,headers:s,stream:a,timeout:u})]);case 1:return[2,t.apply(this,[p.sent().data])];case 2:return n={"Content-Type":"application/json"},a&&Object.assign(n,{Accept:"text/event-stream"}),[4,this.req.fetch({url:r,body:JSON.stringify(i),headers:Xt(Xt((f={},f[null===(h=this.i18n)||void 0===h?void 0:h.LANG_HEADER_KEY]=null===(d=this.i18n)||void 0===d?void 0:d.lang,f),n),s),stream:a,method:e,timeout:u})];case 3:return o=p.sent(),c=o.data,l=o.header,[2,this.handleResponseData(c,l)]}var y}))}))},this.aiBaseUrl="".concat(e,"/ai"),this.aiBotBaseUrl="".concat(e,"/aibot"),this.bot=new M(this.botRequest,this.aiBotBaseUrl),this.i18n=r,Zt.RR.$.on(Zt.RR.P,(function(t){var e;n.i18n=(null===(e=t.data)||void 0===e?void 0:e.i18n)||n.i18n}))}return t.prototype.handleResponseData=function(t,e){var r,n;return te(this,void 0,void 0,(function(){var o,i;return ee(this,(function(s){switch(s.label){case 0:return o="".concat(this.i18n.t("请检查调用方式,或前往云开发 AI+ 首页查看文档"),":https://tcb.cloud.tencent.com/dev#/ai"),"object"==typeof t&&t&&"then"in t?[4,t]:[3,2];case 1:if("object"==typeof(i=s.sent())&&i&&"code"in i&&"NORMAL"!==i.code)throw new Error("".concat(this.i18n.t("AI+ 请求出错,错误码"),":").concat(i.code,",").concat(this.i18n.t("错误信息"),":").concat(i.message,"\n").concat(o,"\n").concat(JSON.stringify(i,null,2)));return[2,t];case 2:return(null===(n=null===(r=null==e?void 0:e.get)||void 0===r?void 0:r.call(e,"content-type"))||void 0===n?void 0:n.includes("application/json"))?[4,C(t)]:[3,4];case 3:if("object"==typeof(i=s.sent())&&i&&"code"in i&&"NORMAL"!==i.code)throw new Error("".concat(this.i18n.t("AI+ 请求出错,错误码"),":").concat(i.code,",").concat(this.i18n.t("错误信息"),":").concat(i.message,"\n").concat(o,"\n").concat(JSON.stringify(i,null,2)));s.label=4;case 4:return[2,t]}}))}))},t.prototype.createModel=function(t,e){var r,n=re[t];if(n)r=new n(this.modelRequest,this.aiBaseUrl);else{var o="string"==typeof(null==e?void 0:e.defaultModelSubUrl)?e.defaultModelSubUrl:"/chat/completions";r=new qt(this.modelRequest,this.aiBaseUrl,"".concat(t).concat(o))}return new Ht(r)},t.prototype.registerModel=function(t,e){null==re[t]?re[t]=e:console.warn("AI model ".concat(t," already exists!"))},t.prototype.registerFunctionTool=function(t){Kt.has(t.name)&&console.warn("AI function tool ".concat(t.name," already exists and will be overwritten!")),Kt.set(t.name,t.fn)},t}(),oe=function(){},ie=function(){return ie=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},ie.apply(this,arguments)},se=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r},ae=se(o,["MODELS"]),ue=function(t){var e=t.getAccessToken,r=t.req;return{download:r.download,post:r.post,upload:r.upload,fetch:function(t){return n=void 0,o=void 0,s=function(){var n,o,i,s,a;return function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}(this,(function(u){switch(u.label){case 0:if("function"!=typeof r.fetch)throw new Error("req.fetch is not a function");return n=t.token,o=t.headers,i=void 0===o?{}:o,s=se(t,["token","headers"]),null==n?[3,1]:(a=n,[3,3]);case 1:return[4,e()];case 2:a=u.sent().accessToken,u.label=3;case 3:return[2,r.fetch(ie({headers:ie({Authorization:"Bearer ".concat(a)},i)},s))]}}))},new((i=void 0)||(i=Promise))((function(t,e){function r(t){try{u(s.next(t))}catch(t){e(t)}}function a(t){try{u(s.throw(t))}catch(t){e(t)}}function u(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i((function(t){t(n)}))).then(r,a)}u((s=s.apply(n,o||[])).next())}));var n,o,i,s}}};function ce(t){var e=t.env,r=t.baseUrl,n=t.req,o=t.getAccessToken,i=t.handleReqInstance,s=t.i18n;return new ne(function(){if(null==i){if(null==o)throw new Error("`getAccessToken` is required when `handleReqInstance` is not provided!");return ue({req:n,getAccessToken:o})}return i({req:n})}(),function(){if(null!=r)return r;if(null==e)throw new Error("`env` is required when `baseUrl` is not provided!");return"https://".concat(e,".api.tcloudbasegateway.com/v1")}(),s)}var le={name:"ai",entity:{ai:function(t){var e,r=this,n=this.request;if(null==n.fetch)throw new Error("cloudbase.request.fetch() unimplemented!");return ce({req:n,baseUrl:null!==(e=null==t?void 0:t.baseUrl)&&void 0!==e?e:function(){var t=r.getEndPointWithKey("GATEWAY"),e=t.BASE_URL,n=t.PROTOCOL;return"".concat(n).concat(e)}(),handleReqInstance:function(t){return t.req},i18n:this.config.i18n})}}};function fe(t){try{t.registerComponent(le)}catch(t){console.warn(t)}}},7505:function(t,e,r){"use strict";r.r(e),r.d(e,{registerAnalytics:function(){return h}});var n=r(3616),o=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},i=n._G.Sg,s=n._G.vM,a=n.BM.D,u="analytics",c=["mall"],l=new(function(){function t(){}return t.prototype.analytics=function(t){return e=this,r=void 0,o=function(){var e,r,n;return function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}(this,(function(o){if(!function(t){if("Object"!==Object.prototype.toString.call(t).slice(8,-1))return!1;var e=t.report_data,r=t.report_type;return!1!==c.includes(r)&&"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(u,".analytics] invalid report data")}));return e=void 0===t.report_data.action_time?Math.floor(Date.now()/1e3):t.report_data.action_time,r={analytics_scene:t.report_type,analytics_data:Object.assign({},t.report_data,{action_time:e})},n={requestData:r},this.request.send("analytics.report",n),[2]}))},new((n=void 0)||(n=Promise))((function(t,i){function s(t){try{u(o.next(t))}catch(t){i(t)}}function a(t){try{u(o.throw(t))}catch(t){i(t)}}function u(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n((function(t){t(r)}))).then(s,a)}u((o=o.apply(e,r||[])).next())}));var e,r,n,o},function(t,e,r,n){var o,i=arguments.length,s=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);i>3&&s&&Object.defineProperty(e,r,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}()),f={name:u,entity:{analytics:l.analytics}};try{cloudbase.registerComponent(f)}catch(t){}function h(t){try{t.registerComponent(f)}catch(t){console.warn(t)}}},2856:function(t,e,r){"use strict";r.r(e),r.d(e,{LANGS:function(){return F},cloudbase:function(){return yt},default:function(){return vt},getBaseEndPoint:function(){return x}});var n=r(3616),o=r(190),i=function(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))},s=n._G.Sg,a={};function u(t,e){var r=e.name,n=e.namespace,o=e.entity,u=e.injectEvents,l=e.IIFE,f=void 0!==l&&l;if(a[r]||n&&t[n])throw new Error(JSON.stringify({code:s.INVALID_OPERATION,msg:"Duplicate component ".concat(r)}));if(f){if(!o||"function"!=typeof o)throw new Error(JSON.stringify({code:s.INVALID_PARAMS,msg:"IIFE component's entity must be a function"}));o.call(t)}if(a[r]=e,n?t.prototype[n]=o:c(t.prototype,o),u){var h=u.bus,d=u.events;if(!h||!d||0===d.length)return;var p=t.prototype.fire||function(){};t.prototype.events||(t.prototype.events={}),(t.prototype.events||{})[r]?t.prototype.events[r].events=i(i([],t.prototype.events[r].events,!0),d,!0):t.prototype.events[r]={bus:h,events:d},t.prototype.fire=function(t,e){p(t,e);for(var r=0,n=Object.keys(this.events);r<n.length;r++){var o=n[r],i=this.events[o],s=i.bus;if(i.events.includes(t)){s.fire(t,e);break}}}}}function c(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 r=0,n=Object.keys(e);r<n.length;r++){var o=n[r];Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=c(t[o],e[o]))}return t}var l={},f=function(){return f=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},f.apply(this,arguments)},h=n.Fs.q,d={},p={};function y(t){var e=t.env,r=t.platformInfo,n={userInfoKey:"".concat("user_info","_").concat(e)};d[e]=d[e]||new h(f(f({},t),{keys:n,platformInfo:r})),p[e]=p[e]||new h(f(f({},t),{keys:n,platformInfo:r,persistence:"local"}))}function v(t){return p[t]}var g=function(){return g=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},g.apply(this,arguments)},m=n._G.tC,b=n._G.pM,w="",_="@cloudbase/js-sdk";function S(){return w}var E,I=[],O=["env","endPointKey","region"],T="https:";function R(t){return I.find((function(e){return O.filter((function(e){return null!=t[e]})).every((function(r){return e[r]===t[r]}))}))}function A(t){var e,r,n=R(t);n?(null!=t.baseUrl&&(n.baseUrl=t.baseUrl),null!=t.protocol&&(n.protocol=t.protocol)):I.push(g(g({},t),{protocol:null!==(e=t.protocol)&&void 0!==e?e:T})),"CLOUD_API"===t.endPointKey&&b(null!==(r=t.protocol)&&void 0!==r?r:T)}function P(t,e,r){return R({env:t,endPointKey:e,region:r})}function x(t){var e=P(t,"CLOUD_API"),r=e.protocol,n=e.baseUrl;return"".concat(r).concat(n).match(/(http(s)?:)?\/\/([^/?#]*)/)[0]}!function(t){t.NULL="NULL",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.PHONE="PHONE"}(E||(E={}));var C=function(){return C=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},C.apply(this,arguments)},N=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},L=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},j=n._G.Sg,U=n.P6.genSeqId,k=n.P6.isFormData,D=n.P6.formatUrl,q=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"];function M(t,e,r){var n=t[e];t[e]=function(e){var o={},i={};r.forEach((function(r){var n=r.call(t,e),s=n.data,a=n.headers;Object.assign(o,s),Object.assign(i,a)}));var s=e.data;return s&&(k(s)?Object.keys(o).forEach((function(t){s.append(t,o[t])})):e.data=C(C({},s),o)),e.headers=C(C({},e.headers||{}),i),n.call(t,e)}}function B(){var t=U();return{data:{seqId:t},headers:{"X-SDK-Version":"@cloudbase/js-sdk/".concat(S()),"x-seqid":t}}}var W,F,V=function(){function t(t){var e=this;this.throwWhenRequestFail=!1,this.config=t;var r={timeout:this.config.timeout,timeoutMsg:"[@cloudbase/js-sdk] 请求在".concat(this.config.timeout/1e3,"s内未完成,已中断"),restrictedMethods:["post","put"]};this.reqClass=new l.adapter.reqClass(r),this.throwWhenRequestFail=t.throw||!1,this.localCache=v(this.config.env),M(this.reqClass,"post",[B]),M(this.reqClass,"upload",[B]),M(this.reqClass,"download",[B]),n.RR.$.on(n.RR.P,(function(t){var r;e.config.i18n=(null===(r=t.data)||void 0===r?void 0:r.i18n)||e.config.i18n}))}return t.prototype.getDefaultHeaders=function(){var t,e,r;return(t={})[null===(e=this.config.i18n)||void 0===e?void 0:e.LANG_HEADER_KEY]=null===(r=this.config.i18n)||void 0===r?void 0:r.lang,t},t.prototype.post=function(t){return N(this,void 0,void 0,(function(){return L(this,(function(e){switch(e.label){case 0:return[4,this.reqClass.post(C(C({},t),{headers:C(C({},t.headers),this.getDefaultHeaders())}))];case 1:return[2,e.sent()]}}))}))},t.prototype.upload=function(t){return N(this,void 0,void 0,(function(){return L(this,(function(e){switch(e.label){case 0:return[4,this.reqClass.upload(C(C({},t),{headers:C(C({},t.headers),this.getDefaultHeaders())}))];case 1:return[2,e.sent()]}}))}))},t.prototype.download=function(t){return N(this,void 0,void 0,(function(){return L(this,(function(e){switch(e.label){case 0:return[4,this.reqClass.download(C(C({},t),{headers:C(C({},t.headers),this.getDefaultHeaders())}))];case 1:return[2,e.sent()]}}))}))},t.prototype.getBaseEndPoint=function(){return x(this.config.env)},t.prototype.getOauthAccessTokenV2=function(t){return N(this,void 0,void 0,(function(){var e,r;return L(this,(function(n){switch(n.label){case 0:return[4,t.getAccessToken()];case 1:return e=n.sent(),[4,t.getCredentials()];case 2:return r=n.sent(),[2,{accessToken:e,accessTokenExpire:new Date(r.expires_at).getTime()}]}}))}))},t.prototype.request=function(t,e,r){var n,o;return N(this,void 0,void 0,(function(){var i,s,a,u,c,l,f,h,d,p,y,v,g,m,b,w,_,S,E,I;return L(this,(function(O){switch(O.label){case 0:if(i="x-tcb-trace_".concat(this.config.env),s="application/x-www-form-urlencoded",a=C({action:t,dataVersion:"2020-01-10",env:this.config.env},e),-1!==q.indexOf(t))return[3,2];if(!(u=this.config._fromApp).oauthInstance)throw new Error("you can't request without auth");return c=u.oauthInstance,l=c.oauth2client,f=a,[4,this.getOauthAccessTokenV2(l)];case 1:f.access_token=O.sent().accessToken,O.label=2;case 2:return"storage.uploadFile"===t?(h=new FormData,Object.keys(h).forEach((function(t){Object.prototype.hasOwnProperty.call(h,t)&&void 0!==h[t]&&h.append(t,a[t])})),s="multipart/form-data"):(s="application/json;charset=UTF-8",h={},Object.keys(a).forEach((function(t){void 0!==a[t]&&(h[t]=a[t])}))),d={headers:C({"content-type":s},this.getDefaultHeaders())},(null==r?void 0:r.onUploadProgress)&&(d.onUploadProgress=r.onUploadProgress),this.config.region&&(d.headers["X-TCB-Region"]=this.config.region),(p=this.localCache.getStore(i))&&(d.headers["X-TCB-Trace"]=p),y=void 0!==(null==r?void 0:r.parse)?r.parse:e.parse,v=void 0!==(null==r?void 0:r.inQuery)?r.inQuery:e.inQuery,g=void 0!==(null==r?void 0:r.search)?r.search:e.search,m=C(C({},(null==r?void 0:r.defaultQuery)||{}),{env:this.config.env}),y&&(m.parse=!0),v&&(m=C(C({},v),m)),b=P(this.config.env,"CLOUD_API"),w=b.baseUrl,_=b.protocol,S=r.pathname?D(_,"".concat(null===(n=x(this.config.env))||void 0===n?void 0:n.replace(/^https?:/,""),"/").concat(r.pathname),m):D(_,w,m),g&&(S+=g),[4,this.post(C({url:S,data:h},d))];case 3:if(E=O.sent(),(I=null===(o=E.header)||void 0===o?void 0:o["x-tcb-trace"])&&this.localCache.setStore(i,I),200!==Number(E.status)&&200!==Number(E.statusCode)||!E.data)throw new Error("network request error");return[2,E]}}))}))},t.prototype.fetch=function(t){var e,r,n,o,i,s,a,u;return N(this,void 0,void 0,(function(){var c,l,f,h,d,p,y,v=this;return L(this,(function(g){switch(g.label){case 0:c=t.token,l=t.headers,f=void 0===l?{}:l,h=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}(t,["token","headers"]),d=function(){return N(v,void 0,void 0,(function(){var t,e,r;return L(this,(function(n){switch(n.label){case 0:if(null!=c)return[2,c];if(!(t=this.config._fromApp).oauthInstance)throw new Error("you can't request without auth");return e=t.oauthInstance,r=e.oauth2client,[4,this.getOauthAccessTokenV2(r)];case 1:return[2,n.sent().accessToken]}}))}))},p=function(){return N(v,void 0,void 0,(function(){var t,e,r,n,o;return L(this,(function(i){switch(i.label){case 0:return e=(t=this.reqClass).fetch,n={},o={"X-SDK-Version":"@cloudbase/js-sdk/".concat(S())},r="Bearer ".concat,[4,d()];case 1:return[2,e.apply(t,[C.apply(void 0,[(n.headers=C.apply(void 0,[C.apply(void 0,[(o.Authorization=r.apply("Bearer ",[i.sent()]),o),this.getDefaultHeaders()]),f]),n),h])])]}}))}))},g.label=1;case 1:return g.trys.push([1,3,,6]),[4,p()];case 2:return[2,g.sent()];case 3:if("ACCESS_TOKEN_EXPIRED"!==(null==(y=g.sent())?void 0:y.code))return[3,5];if("function"!=typeof(null===(o=null===(n=null===(r=null===(e=this.config)||void 0===e?void 0:e._fromApp)||void 0===r?void 0:r.oauthInstance)||void 0===n?void 0:n.authApi)||void 0===o?void 0:o.refreshTokenForce))throw y;return[4,null===(u=null===(a=null===(s=null===(i=this.config)||void 0===i?void 0:i._fromApp)||void 0===s?void 0:s.oauthInstance)||void 0===a?void 0:a.authApi)||void 0===u?void 0:u.refreshTokenForce()];case 4:return g.sent(),[2,p()];case 5:throw y;case 6:return[2]}}))}))},t.prototype.send=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),N(this,void 0,void 0,(function(){var n;return L(this,(function(o){switch(o.label){case 0:return[4,this.request(t,e,C(C({},r),{onUploadProgress:e.onUploadProgress}))];case 1:if((n=o.sent()).data.code&&this.throwWhenRequestFail)throw new Error(JSON.stringify({code:j.OPERATION_FAIL,msg:"[".concat(n.data.code,"] ").concat(n.data.message)}));return[2,n.data]}}))}))},t}(),H={};!function(t){t.ZH="zh-CN",t.EN="en-US"}(F||(F={}));var G=((W={})[F.EN]={"请检查调用方式,或前往云开发 AI+ 首页查看文档":"Please check the calling method or visit the AI+ homepage to view the documentation","AI+ 请求出错,错误码":"AI+ request error, error code","错误信息":"error message","未实现":"not implemented","小程序不支持 wasm 加载":"wasm loading is not supported in mini programs","小程序不支持动态 js 加载":"dynamic js loading is not supported in mini programs","请求超时":"request timeout","缺少 privatelink sdk 地址":"missing privatelink sdk address"},W),$=function(t,e){var r;return(null===(r=G[e])||void 0===r?void 0:r[t])||t},K=function(t,e){var r,o,i=function(t){return"lang_".concat(t.clientId||t.env)}(e),s=(t.adapter||{}).localStorage,a=e.lang||(null===(r=null==s?void 0:s.getItem)||void 0===r?void 0:r.call(s,i))||F.ZH;return null===(o=null==s?void 0:s.setItem)||void 0===o||o.call(s,i,a),new Proxy({t:function(t){return $(t,a)},LANG_HEADER_KEY:"Accept-Language",lang:a},{get:function(t,e){var r;return"lang"===e&&(null===(r=null==s?void 0:s.getItem)||void 0===r?void 0:r.call(s,i))||t[e]},set:function(t,e,r){var o;return"lang"===e&&r!==t[e]&&(t[e]=r,t.t=function(t){return $(t,r)},null===(o=null==s?void 0:s.setItem)||void 0===o||o.call(s,i,r),n.RR.$.fire(n.RR.P,{i18n:t})),t[e]=r,!0}})},z=r(794),J=function(){return J=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},J.apply(this,arguments)},Y=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},Q=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};function Z(t,e){var r,n,o;return Y(this,void 0,void 0,(function(){var i,s,a,u,c,l,f,h,d,p,y,v,g,m,b;return Q(this,(function(w){switch(w.label){case 0:if(s=(i=t||{}).name,a=i.body,u=i.path,c=void 0===u?"":u,l=i.method,f=void 0===l?"POST":l,h=i.headers,d=void 0===h?{}:h,p=i.token,!s)throw new Error(JSON.stringify({code:z.ERRORS.INVALID_PARAMS,msg:"[apis] invalid api name"}));return y=this.getEndPointWithKey("GATEWAY"),v=y.BASE_URL,g=y.PROTOCOL,m="".concat(g).concat(v,"/apis/").concat(s),b=c.startsWith("/")?c:"/".concat(c),[4,this.request.fetch(J({url:"".concat(m).concat(b),method:f||"POST",headers:J({"Content-Type":"application/json; charset=utf-8"},d),body:a,token:(null===(r=null==p?void 0:p.trim)||void 0===r?void 0:r.call(p))||(null===(o=null===(n=d.Authorization)||void 0===n?void 0:n.replace)||void 0===o?void 0:o.call(n,/^Bearer /,""))||""},e))];case 1:return[4,w.sent().data];case 2:return[2,w.sent()]}}))}))}var X=["GET","POST","PUT","DELETE","HEAD","OPTIONS","PATCH","REQUEST"];function tt(t){var e=this;return new Proxy({},{get:function(r,n){if("string"!=typeof n)throw new Error("[apis] method must be string");var o=n.toLocaleUpperCase();if(!X.includes(o))throw new Error("[apis] invalid method: ".concat(n));return function(r,n){return Y(e,void 0,void 0,(function(){return Q(this,(function(e){switch(e.label){case 0:return[4,Z.call(this,J({name:t,method:("REQUEST"===o?r.method:o)||"POST"},r),n)];case 1:return[2,e.sent()]}}))}))}}})}function et(){var t=this;return new Proxy({},{get:function(e,r){if("string"==typeof r)return tt.call(t,r)}})}var rt=function(){return rt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},rt.apply(this,arguments)},nt=function(t,e,r,n){var o,i=arguments.length,s=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s},ot=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},it=n.j$.Fk,st=n.j$.xY,at=n._G.Sg,ut=n._G.vM,ct=n.P6.printWarn,lt=n.BM.D,ft={timeout:15e3,persistence:"local"},ht=6e5,dt={},pt=function(){function t(t){this.cloudbaseConfig=t||this.cloudbaseConfig,this.authInstance=null,this.oauthInstance=null,this.version=S()}return Object.defineProperty(t.prototype,"config",{get:function(){return this.cloudbaseConfig},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"platform",{get:function(){return l},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cache",{get:function(){return t=this.cloudbaseConfig.env,d[t];var t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCache",{get:function(){return v(this.cloudbaseConfig.env)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"request",{get:function(){return t=this.cloudbaseConfig.env,H[t];var t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"apis",{get:function(){return et.call(this)},enumerable:!1,configurable:!0}),t.prototype.init=function(e){var r;if(!e.env)throw new Error(JSON.stringify({code:at.INVALID_PARAMS,msg:"env must not be specified"}));l.adapter||this.useDefaultAdapter();var n={timeout:e.timeout||5e3,timeoutMsg:"[".concat(_,"][REQUEST TIMEOUT] request had been abort since didn't finished within").concat(e.timeout/1e3,"s")};this.requestClient=new l.adapter.reqClass(n),this.cloudbaseConfig=rt(rt(rt({},ft),e),{i18n:K(l,e)}),delete this.cloudbaseConfig.lang,this.cloudbaseConfig.timeout=this.formatTimeout(this.cloudbaseConfig.timeout);var o=this.cloudbaseConfig,i=o.env,s=o.persistence,a=o.debug,u=o.timeout,c=o.oauthClient,f=o.i18n;y({env:i,persistence:s,debug:a,platformInfo:this.platform}),function(t,e){A({env:t,region:e,baseUrl:e?"//".concat(t,".").concat(e,".tcb-api.tencentcloudapi.com/web"):"//".concat(t,".ap-shanghai.tcb-api.tencentcloudapi.com/web"),protocol:void 0,endPointKey:"CLOUD_API"})}(i,e.region||""),function(t){A({endPointKey:"GATEWAY",env:t,baseUrl:"//".concat(t,".api.tcloudbasegateway.com/v1"),protocol:void 0})}(i);var h=new t(this.cloudbaseConfig);return function(t){H[t.env]=new V(C(C({},t),{throw:!0}))}({env:i,region:e.region||"",timeout:u,oauthClient:c,_fromApp:h,i18n:f}),h.requestClient=this.requestClient,null===(r=null==this?void 0:this.fire)||void 0===r||r.call(this,"cloudbase_init",h),h},t.prototype.updateConfig=function(t){var e=t.persistence,r=t.debug;this.cloudbaseConfig.persistence=e,this.cloudbaseConfig.debug=r,y({env:this.cloudbaseConfig.env,persistence:e,debug:r,platformInfo:this.platform})},t.prototype.updateLang=function(t){var e;t&&t!==(null===(e=this.cloudbaseConfig.i18n)||void 0===e?void 0:e.lang)&&(this.cloudbaseConfig.i18n.lang=t)},t.prototype.registerExtension=function(t){dt[t.name]=t},t.prototype.invokeExtension=function(t,e){return r=this,n=void 0,i=function(){var r;return function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}(this,(function(n){switch(n.label){case 0:if(!(r=dt[t]))throw new Error(JSON.stringify({code:at.INVALID_PARAMS,msg:"extension:".concat(t," must be registered before invoke")}));return[4,r.invoke(e,this)];case 1:return[2,n.sent()]}}))},new((o=void 0)||(o=Promise))((function(t,e){function s(t){try{u(i.next(t))}catch(t){e(t)}}function a(t){try{u(i.throw(t))}catch(t){e(t)}}function u(e){var r;e.done?t(e.value):(r=e.value,r instanceof o?r:new o((function(t){t(r)}))).then(s,a)}u((i=i.apply(r,n||[])).next())}));var r,n,o,i},t.prototype.useAdapters=function(t,e){var r=it(t,e)||{},n=r.adapter,o=r.runtime;n&&(l.adapter=n),o&&(l.runtime=o)},t.prototype.registerHook=function(e){!function(t,e){var r=e.entity,n=e.target;if(Object.prototype.hasOwnProperty.call(t,n))throw new Error(JSON.stringify({code:s.INVALID_OPERATION,msg:"target:".concat(n," is not exist")}));var o=t.prototype[n];if("function"!=typeof o)throw new Error(JSON.stringify({code:s.INVALID_OPERATION,msg:"target:".concat(n," is not a function which is the only type supports hook")}));t.prototype[n]=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return r.call.apply(r,i([this],t,!1)),o.call.apply(o,i([this],t,!1))}}(t,e)},t.prototype.registerComponent=function(e){u(t,e)},t.prototype.registerVersion=function(t){!function(t){w=t}(t),this.version=t},t.prototype.registerSdkName=function(t){!function(t){_=t,m(t)}(t)},t.prototype.registerEndPoint=function(t,e){A({baseUrl:t,protocol:e,env:this.config.env,endPointKey:"CLOUD_API"})},t.prototype.registerEndPointWithKey=function(t){A({env:this.config.env,endPointKey:t.key,baseUrl:t.url,protocol:t.protocol})},t.prototype.getEndPointWithKey=function(t){var e=P(this.config.env,t);return{BASE_URL:e.baseUrl,PROTOCOL:e.protocol}},t.prototype.parseCaptcha=function(t){var e={},r=t.match(/^(data:.*?)(\?[^#\s]*)?$/);if(r){t=r[1];var o=r[2];o&&(e=n.P6.parseQueryString(o))}var i=e.token,s=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}(e,["token"]);return/^data:/.test(t)&&!i?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(t)}:i?{state:s.state,token:i,captchaData:t}:{error:"unimplemented",error_description:"need to impl captcha data"}},t.prototype.useDefaultAdapter=function(){var t=st(),e=t.adapter,r=t.runtime;l.adapter=e,l.runtime=r},t.prototype.formatTimeout=function(t){switch(!0){case t>ht:return ct(at.INVALID_PARAMS,"timeout is greater than maximum value[10min]"),ht;case t<100:return ct(at.INVALID_PARAMS,"timeout is less than maximum value[100ms]"),100;default:return t}},nt([lt({mode:"sync",title:"Cloudbase 初始化失败",messages:["请确认以下各项:"," 1 - 调用 cloudbase.init() 的语法或参数是否正确"," 2 - 如果是非浏览器环境,是否配置了安全应用来源(https://docs.cloudbase.net/api-reference/webv3/adapter#%E7%AC%AC-2-%E6%AD%A5%E9%85%8D%E7%BD%AE%E5%AE%89%E5%85%A8%E5%BA%94%E7%94%A8%E6%9D%A5%E6%BA%90)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(ut)]}),ot("design:type",Function),ot("design:paramtypes",[Object]),ot("design:returntype",t)],t.prototype,"init",null),nt([lt({title:"调用扩展能力失败",messages:["请确认以下各项:"," 1 - 调用 invokeExtension() 的语法或参数是否正确"," 2 - 被调用的扩展能力是否已经安装并通过 registerExtension() 注册","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(ut)]}),ot("design:type",Function),ot("design:paramtypes",[String,Object]),ot("design:returntype",Promise)],t.prototype,"invokeExtension",null),t}(),yt=new pt;yt.useAdapters(o.ZP);var vt=yt},7170:function(t,e,r){"use strict";r.r(e),r.d(e,{Auth:function(){return St},LoginState:function(){return _t},generateAuthInstance:function(){return Et},registerAuth:function(){return Ot}});var n,o,i,s,a,u,c="/auth";function l(){return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(t=>{var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))}!function(t){t.AUTH_SIGN_UP_URL="/v1/signup",t.AUTH_TOKEN_URL="/v1/token",t.AUTH_REVOKE_URL="/v1/revoke",t.WEDA_USER_URL="/v1/plugin/weda/userinfo",t.AUTH_RESET_PASSWORD="/v1/reset",t.AUTH_GET_DEVICE_CODE="/v1/device/code",t.CHECK_USERNAME="/v1/checkUsername",t.CHECK_IF_USER_EXIST="/v1/checkIfUserExist",t.GET_PROVIDER_TYPE="/v1/mgr/provider/providerSubType",t.AUTH_SIGN_IN_URL="/v1/signin",t.AUTH_SIGN_IN_ANONYMOUSLY_URL="/v1/signin/anonymously",t.AUTH_SIGN_IN_WITH_PROVIDER_URL="/v1/signin/with/provider",t.AUTH_SIGN_IN_WITH_WECHAT_URL="/v1/signin/wechat/noauth",t.AUTH_SIGN_IN_CUSTOM="/v1/signin/custom",t.PROVIDER_TOKEN_URL="/v1/provider/token",t.PROVIDER_URI_URL="/v1/provider/uri",t.USER_ME_URL="/v1/user/me",t.AUTH_SIGNOUT_URL="/v1/user/signout",t.USER_QUERY_URL="/v1/user/query",t.USER_PRIFILE_URL="/v1/user/profile",t.USER_BASIC_EDIT_URL="/v1/user/basic/edit",t.USER_TRANS_BY_PROVIDER_URL="/v1/user/trans/by/provider",t.PROVIDER_LIST="/v1/user/provider",t.PROVIDER_BIND_URL="/v1/user/provider/bind",t.PROVIDER_UNBIND_URL="/v1/user/provider",t.CHECK_PWD_URL="/v1/user/sudo",t.SUDO_URL="/v1/user/sudo",t.BIND_CONTACT_URL="/v1/user/contact",t.AUTH_SET_PASSWORD="/v1/user/password",t.AUTHORIZE_DEVICE_URL="/v1/user/device/authorize",t.AUTHORIZE_URL="/v1/user/authorize",t.AUTHORIZE_INFO_URL="/v1/user/authorize/info",t.AUTHORIZED_DEVICES_DELETE_URL="/v1/user/authorized/devices/",t.AUTH_REVOKE_ALL_URL="/v1/user/revoke/all",t.GET_USER_BEHAVIOR_LOG="/v1/user/security/history",t.VERIFICATION_URL="/v1/verification",t.VERIFY_URL="/v1/verification/verify",t.CAPTCHA_DATA_URL="/v1/captcha/data",t.VERIFY_CAPTCHA_DATA_URL="/v1/captcha/data/verify",t.GET_CAPTCHA_URL="/v1/captcha/init",t.GET_MINIPROGRAM_QRCODE="/v1/qrcode/generate",t.GET_MINIPROGRAM_QRCODE_STATUS="/v1/qrcode/get/status"}(n||(n={})),function(t){t.AUTH_SIGN_IN_URL="/v2/signin/username",t.AUTH_TOKEN_URL="/v2/token",t.USER_ME_URL="/v2/user/me",t.VERIFY_URL="/v2/signin/verificationcode",t.AUTH_SIGN_IN_WITH_PROVIDER_URL="/v2/signin/with/provider",t.AUTH_PUBLIC_KEY="/v2/signin/publichkey",t.AUTH_RESET_PASSWORD="/v2/signin/password/update"}(o||(o={})),function(t){t.REGISTER="REGISTER",t.SIGN_IN="SIGN_IN",t.PASSWORD_RESET="PASSWORD_RESET",t.EMAIL_ADDRESS_CHANGE="EMAIL_ADDRESS_CHANGE",t.PHONE_NUMBER_CHANGE="PHONE_NUMBER_CHANGE"}(i||(i={})),(u=s||(s={})).UNREACHABLE="unreachable",u.LOCAL="local",u.CANCELLED="cancelled",u.UNKNOWN="unknown",u.UNAUTHENTICATED="unauthenticated",u.RESOURCE_EXHAUSTED="resource_exhausted",u.FAILED_PRECONDITION="failed_precondition",u.INVALID_ARGUMENT="invalid_argument",u.DEADLINE_EXCEEDED="deadline_exceeded",u.NOT_FOUND="not_found",u.ALREADY_EXISTS="already_exists",u.PERMISSION_DENIED="permission_denied",u.ABORTED="aborted",u.OUT_OF_RANGE="out_of_range",u.UNIMPLEMENTED="unimplemented",u.INTERNAL="internal",u.UNAVAILABLE="unavailable",u.DATA_LOSS="data_loss",u.INVALID_PASSWORD="invalid_password",u.PASSWORD_NOT_SET="password_not_set",u.INVALID_STATUS="invalid_status",u.USER_PENDING="user_pending",u.USER_BLOCKED="user_blocked",u.INVALID_VERIFICATION_CODE="invalid_verification_code",u.TWO_FACTOR_REQUIRED="two_factor_required",u.INVALID_TWO_FACTOR="invalid_two_factor",u.INVALID_TWO_FACTOR_RECOVERY="invalid_two_factor_recovery",u.UNDER_REVIEW="under_review",u.INVALID_REQUEST="invalid_request",u.UNAUTHORIZED_CLIENT="unauthorized_client",u.ACCESS_DENIED="access_denied",u.UNSUPPORTED_RESPONSE_TYPE="unsupported_response_type",u.INVALID_SCOPE="invalid_scope",u.INVALID_GRANT="invalid_grant",u.SERVER_ERROR="server_error",u.TEMPORARILY_UNAVAILABLE="temporarily_unavailable",u.INTERACTION_REQUIRED="interaction_required",u.LOGIN_REQUIRED="login_required",u.ACCOUNT_SELECTION_REQUIRED="account_selection_required",u.CONSENT_REQUIRED="consent_required",u.INVALID_REQUEST_URI="invalid_request_uri",u.INVALID_REQUEST_OBJECT="invalid_request_object",u.REQUEST_NOT_SUPPORTED="request_not_supported",u.REQUEST_URI_NOT_SUPPORTED="request_uri_not_supported",u.REGISTRATION_NOT_SUPPORTED="registration_not_supported",u.CAPTCHA_REQUIRED="captcha_required",u.CAPTCHA_INVALID="captcha_invalid",function(t){t.CLIENT_ID="client_id",t.CLIENT_SECRET="client_secret",t.RESPONSE_TYPE="response_type",t.SCOPE="scope",t.STATE="state",t.REDIRECT_URI="redirect_uri",t.ERROR="error",t.ERROR_DESCRIPTION="error_description",t.ERROR_URI="error_uri",t.GRANT_TYPE="grant_type",t.CODE="code",t.ACCESS_TOKEN="access_token",t.TOKEN_TYPE="token_type",t.EXPIRES_IN="expires_in",t.USERNAME="username",t.PASSWORD="password",t.REFRESH_TOKEN="refresh_token"}(a||(a={}));var f=r(4655);function h(t,e,r,n,o,i,s){try{var a=t[i](s),u=a.value}catch(t){return void r(t)}a.done?e(u):Promise.resolve(u).then(n,o)}function d(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function s(t){h(i,n,o,s,a,"next",t)}function a(t){h(i,n,o,s,a,"throw",t)}s(void 0)}))}}var p=new Map;class y{constructor(t){this.clientId=(null==t?void 0:t.clientId)||"",p=p||new Map}run(t,e){var r=this;return d((function*(){t="".concat(r.clientId,"_").concat(t);var n=p.get(t);return n||(n=new Promise(((n,o)=>{d((function*(){try{yield r.runIdlePromise();var i=e();n(yield i)}catch(t){o(t)}finally{p.delete(t)}}))()})),p.set(t,n)),n}))()}runIdlePromise(){return Promise.resolve()}}var v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",g=r(3616);function m(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function b(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?m(Object(r),!0).forEach((function(e){w(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):m(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function w(t,e,r){return(e=function(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _(t,e,r,n,o,i,s){try{var a=t[i](s),u=a.value}catch(t){return void r(t)}a.done?e(u):Promise.resolve(u).then(n,o)}function S(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function s(t){_(i,n,o,s,a,"next",t)}function a(t){_(i,n,o,s,a,"throw",t)}s(void 0)}))}}var E="x-request-id",I="x-device-id",O="device_id",T=function(){var t=S((function*(t,e){var r=null,n=null;try{var o=Object.assign({},e);o.method||(o.method="GET"),o.body&&"string"!=typeof o.body&&(o.body=JSON.stringify(o.body));var i=yield fetch(t,o),a=yield i.json();null!=a&&a.error?(n=a).error_uri=new URL(t).pathname:r=a}catch(e){n={error:s.UNREACHABLE,error_description:e.message,error_uri:new URL(t).pathname}}if(n)throw n;return r}));return function(e,r){return t.apply(this,arguments)}}(),R=new class{constructor(t){this._env=(null==t?void 0:t.env)||""}getItem(t){var e=this;return S((function*(){return window.localStorage.getItem("".concat(t).concat(e._env))}))()}removeItem(t){var e=this;return S((function*(){window.localStorage.removeItem("".concat(t).concat(e._env))}))()}setItem(t,e){var r=this;return S((function*(){window.localStorage.setItem("".concat(t).concat(r._env),e)}))()}getItemSync(t){return window.localStorage.getItem("".concat(t).concat(this._env))}removeItemSync(t){window.localStorage.removeItem("".concat(t).concat(this._env))}setItemSync(t,e){window.localStorage.setItem("".concat(t).concat(this._env),e)}};function A(t){var e=!0;return null!=t&&t.expires_at&&null!=t&&t.access_token&&(e=t.expires_at<new Date),e}class P{constructor(t){this.credentials=null,this.singlePromise=null,this.tokenSectionName=t.tokenSectionName,this.storage=t.storage,this.clientId=t.clientId,this.singlePromise=new y({clientId:this.clientId}),this.credentials=t.credentials||null,this.credentials&&this.setCredentials(this.credentials)}getStorageCredentialsSync(){var t=null,e=this.storage.getItemSync(this.tokenSectionName);if(null!=e)try{var r;null!==(r=t=JSON.parse(e))&&void 0!==r&&r.expires_at&&(t.expires_at=new Date(t.expires_at))}catch(e){this.storage.removeItem(this.tokenSectionName),t=null}return t}setCredentials(t){var e=this;return S((function*(){if(null!=t&&t.expires_in){if(null!=t&&t.expires_at||(t.expires_at=new Date(Date.now()+1e3*(t.expires_in-30))),e.storage){var r=JSON.stringify(t);yield e.storage.setItem(e.tokenSectionName,r)}e.credentials=t}else e.storage&&(yield e.storage.removeItem(e.tokenSectionName)),e.credentials=null}))()}getCredentials(){var t=this;return S((function*(){return t.singlePromise.run("getCredentials",S((function*(){return A(t.credentials)&&(t.credentials=yield t.getStorageCredentials()),t.credentials})))}))()}getStorageCredentials(){var t=this;return S((function*(){return t.singlePromise.run("_getStorageCredentials",S((function*(){var e=null,r=yield t.storage.getItem(t.tokenSectionName);if(null!=r)try{var n;null!==(n=e=JSON.parse(r))&&void 0!==n&&n.expires_at&&(e.expires_at=new Date(e.expires_at))}catch(r){yield t.storage.removeItem(t.tokenSectionName),e=null}return e})))}))()}}class x{constructor(t){this.singlePromise=null,t.clientSecret||(t.clientSecret=""),!t.clientId&&t.env&&(t.clientId=t.env),this.apiOrigin=t.apiOrigin,this.apiPath=t.apiPath||c,this.clientId=t.clientId,this.i18n=t.i18n,this.publishable_key=t.publishable_key,this.singlePromise=new y({clientId:this.clientId}),this.retry=this.formatRetry(t.retry,x.defaultRetry),t.baseRequest?this.baseRequest=t.baseRequest:this.baseRequest=T,this.tokenInURL=t.tokenInURL,this.headers=t.headers,this.storage=t.storage||R,this.localCredentials=new P({tokenSectionName:"credentials_".concat(t.clientId),storage:this.storage,clientId:t.clientId,credentials:this.publishable_key?{access_token:this.publishable_key,token_type:"Bearer",scope:"publishable_key",expires_at:new Date(+new Date+ +new Date),expires_in:+new Date+ +new Date}:null}),this.clientSecret=t.clientSecret,t.clientId&&(this.basicAuth="Basic ".concat(function(t){for(var e,r,n,o,i="",s=0,a=(t=String(t)).length%3;s<t.length;){if((r=t.charCodeAt(s++))>255||(n=t.charCodeAt(s++))>255||(o=t.charCodeAt(s++))>255)throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.");i+=v.charAt((e=r<<16|n<<8|o)>>18&63)+v.charAt(e>>12&63)+v.charAt(e>>6&63)+v.charAt(63&e)}return a?i.slice(0,a-3)+"===".substring(a):i}("".concat(t.clientId,":").concat(this.clientSecret)))),this.wxCloud=t.wxCloud;try{(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})()&&void 0===this.wxCloud&&t.env&&(wx.cloud.init({env:t.env}),this.wxCloud=wx.cloud)}catch(t){}this.refreshTokenFunc=t.refreshTokenFunc||this.defaultRefreshTokenFunc,this.anonymousSignInFunc=t.anonymousSignInFunc,this.onCredentialsError=t.onCredentialsError,g.RR.$.on(g.RR.P,(t=>{var e;this.i18n=(null===(e=t.data)||void 0===e?void 0:e.i18n)||this.i18n}))}setCredentials(t){return this.localCredentials.setCredentials(t)}getAccessToken(){var t=this;return S((function*(){var e=yield t.getCredentials();if(null!=e&&e.access_token)return Promise.resolve(e.access_token);var r={error:s.UNAUTHENTICATED};return Promise.reject(r)}))()}request(t,e){var r=this;return S((function*(){var n,o,i,a;e||(e={});var u=r.formatRetry(e.retry,r.retry);if(e.headers=b(b({},e.headers),{},{[null===(n=r.i18n)||void 0===n?void 0:n.LANG_HEADER_KEY]:null===(o=r.i18n)||void 0===o?void 0:o.lang}),r.headers&&(e.headers=b(b({},r.headers),e.headers)),e.headers[E]||(e.headers[E]=l()),!e.headers[I]){var c=yield r.getDeviceId();e.headers[I]=c}if(null!==(i=e)&&void 0!==i&&i.withBasicAuth&&r.basicAuth&&(e.headers.Authorization=r.basicAuth),null!==(a=e)&&void 0!==a&&a.withCredentials){var f=yield r.getCredentials();f&&(r.tokenInURL?(t.indexOf("?")<0&&(t+="?"),t+="access_token=".concat(f.access_token)):e.headers.Authorization="".concat(f.token_type," ").concat(f.access_token))}else r.clientId&&t.indexOf("client_id")<0&&(t+=t.indexOf("?")<0?"?":"&",t+="client_id=".concat(r.clientId));t.startsWith("/")&&(t="".concat(r.apiOrigin).concat(r.apiPath).concat(t));for(var h=null,d=u+1,p=0;p<d;p++){try{h=e.useWxCloud?yield r.wxCloudCallFunction(t,e):yield r.baseRequest(t,e);break}catch(t){if(e.withCredentials&&t&&t.error===s.UNAUTHENTICATED)return yield r.setCredentials(null),Promise.reject(t);if(p===u||!t||"unreachable"!==t.error)return Promise.reject(t)}yield r.sleep(x.retryInterval)}return h}))()}wxCloudCallFunction(t,e){var r=this;return S((function*(){var n=null,o=null;try{var i,a="";try{a=yield wx.getRendererUserAgent()}catch(t){}var{result:u}=yield r.wxCloud.callFunction({name:"httpOverCallFunction",data:{url:t,method:e.method,headers:b({origin:"https://servicewechat.com","User-Agent":a},e.headers),body:e.body}});null!=u&&null!==(i=u.body)&&void 0!==i&&i.error_code?(o=null==u?void 0:u.body).error_uri=(0,f.y)(t):n=null==u?void 0:u.body}catch(e){o={error:s.UNREACHABLE,error_description:e.message,error_uri:(0,f.y)(t)}}if(o)throw o;return n}))()}getCredentials(){var t=this;return S((function*(){var e=yield t.localCredentials.getCredentials();if(!e){var r,n="credentials not found";return null===(r=t.onCredentialsError)||void 0===r||r.call(t,{msg:n}),t.unAuthenticatedError(n)}if(A(e))if(e.refresh_token)try{e=yield t.refreshToken(e)}catch(r){var o;if("anonymous"!==e.scope)return null===(o=t.onCredentialsError)||void 0===o||o.call(t,{msg:r.error_description}),Promise.reject(r);e=yield t.anonymousLogin(e)}else{if("anonymous"!==e.scope){var i,s="no refresh token found in credentials";return null===(i=t.onCredentialsError)||void 0===i||i.call(t,{msg:s}),t.unAuthenticatedError(s)}e=yield t.anonymousLogin(e)}return e}))()}getCredentialsSync(){return this.localCredentials.getStorageCredentialsSync()}getCredentialsAsync(){return this.getCredentials()}getScope(){var t=this;return S((function*(){var e=yield t.localCredentials.getCredentials();if(!e){var r,n="credentials not found";return null===(r=t.onCredentialsError)||void 0===r||r.call(t,{msg:n}),t.unAuthenticatedError(n)}return e.scope}))()}getGroups(){var t=this;return S((function*(){var e=yield t.localCredentials.getCredentials();if(!e){var r,n="credentials not found";return null===(r=t.onCredentialsError)||void 0===r||r.call(t,{msg:n}),t.unAuthenticatedError(n)}return e.groups}))()}refreshToken(t){var e=this;return S((function*(){return e.singlePromise.run("_refreshToken",S((function*(){if(!t||!t.refresh_token){var r,n="no refresh token found in credentials";return null===(r=e.onCredentialsError)||void 0===r||r.call(e,{msg:n}),e.unAuthenticatedError(n)}try{var o=yield e.refreshTokenFunc(t.refresh_token,t);return yield e.localCredentials.setCredentials(o),o}catch(t){var i;if(t.error===s.INVALID_GRANT){var a;yield e.localCredentials.setCredentials(null);var u=t.error_description;return null===(a=e.onCredentialsError)||void 0===a||a.call(e,{msg:u}),e.unAuthenticatedError(u)}return null===(i=e.onCredentialsError)||void 0===i||i.call(e,{msg:t.error_description}),Promise.reject(t)}})))}))()}anonymousLogin(t){var e=this;return S((function*(){return e.singlePromise.run("_anonymousLogin",S((function*(){if(e.anonymousSignInFunc){var r=yield e.anonymousSignInFunc(t);t=r||(yield e.localCredentials.getCredentials())}else t=yield e.anonymousSignIn(t);return t})))}))()}checkRetry(t){var e=null;if(("number"!=typeof t||t<x.minRetry||t>x.maxRetry)&&(e={error:s.UNREACHABLE,error_description:"wrong options param: retry"}),e)throw e;return t}formatRetry(t,e){return void 0===t?e:this.checkRetry(t)}sleep(t){return S((function*(){return new Promise((e=>{setTimeout((()=>{e()}),t)}))}))()}anonymousSignIn(t){var e=this;return S((function*(){return e.singlePromise.run("_anonymous",S((function*(){if(!t||"anonymous"!==t.scope)return e.unAuthenticatedError("no anonymous in credentials");try{var r=yield e.request(n.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",withBasicAuth:!0,body:{}});return yield e.localCredentials.setCredentials(r),r}catch(t){return t.error===s.INVALID_GRANT?(yield e.localCredentials.setCredentials(null),e.unAuthenticatedError(t.error_description)):Promise.reject(t)}})))}))()}defaultRefreshTokenFunc(t,e){var r=this;return S((function*(){if(void 0===t||""===t){var i,s="refresh token not found";return null===(i=r.onCredentialsError)||void 0===i||i.call(r,{msg:s}),r.unAuthenticatedError(s)}var a=n.AUTH_TOKEN_URL;return"v2"===(null==e?void 0:e.version)&&(a=o.AUTH_TOKEN_URL),b(b({},yield r.request(a,{method:"POST",body:{client_id:r.clientId,client_secret:r.clientSecret,grant_type:"refresh_token",refresh_token:t}})),{},{version:(null==e?void 0:e.version)||"v1"})}))()}getDeviceId(){var t=this;return S((function*(){if(t.deviceID)return t.deviceID;var e=yield t.storage.getItem(O);return"string"==typeof e&&e.length>=16&&e.length<=48||(e=l(),yield t.storage.setItem(O,e)),t.deviceID=e,e}))()}unAuthenticatedError(t){var e={error:s.UNAUTHENTICATED,error_description:t};return Promise.reject(e)}}function C(){if("undefined"==typeof globalThis)return!1;var{wx:t}=globalThis;if(void 0===t)return!1;if(void 0===globalThis.Page)return!1;if(!t.getSystemInfoSync)return!1;if(!t.getStorageSync)return!1;if(!t.setStorageSync)return!1;if(!t.connectSocket)return!1;if(!t.request)return!1;try{if(!t.getSystemInfoSync())return!1;if("qq"===t.getSystemInfoSync().AppPlatform)return!1}catch(t){return!1}return!0}x.defaultRetry=2,x.minRetry=0,x.maxRetry=5,x.retryInterval=1e3;var N=!1;function L(){N=N||void 0!==typeof window&&"miniprogram"===window.__wxjs_environment}try{C()||(N=N||!!navigator.userAgent.match(/miniprogram/i)||"miniprogram"===window.__wxjs_environment,window&&window.WeixinJSBridge&&window.WeixinJSBridge.invoke?L():"undefined"!=typeof document&&document.addEventListener("WeixinJSBridgeReady",L,!1))}catch(t){}function j(){return N}var U=class{constructor(t){if(this.params={},"string"==typeof t)this.parse(t);else if(t&&"object"==typeof t)for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&this.append(e,t[e])}parse(t){t.split("&").forEach((t=>{var[e,r]=t.split("=").map(decodeURIComponent);this.append(e,r)}))}append(t,e){this.params[t]?this.params[t]=this.params[t].concat([e]):this.params[t]=[e]}get(t){return this.params[t]?this.params[t][0]:null}getAll(t){return this.params[t]||[]}delete(t){delete this.params[t]}has(t){return Object.prototype.hasOwnProperty.call(this.params,t)}set(t,e){this.params[t]=[e]}toString(){var t=this,e=[],r=function(r){Object.prototype.hasOwnProperty.call(t.params,r)&&t.params[r].forEach((t=>{e.push("".concat(encodeURIComponent(r),"=").concat(encodeURIComponent(t)))}))};for(var n in this.params)r(n);return e.join("&")}};function k(t,e,r,n,o,i,s){try{var a=t[i](s),u=a.value}catch(t){return void r(t)}a.done?e(u):Promise.resolve(u).then(n,o)}function D(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function s(t){k(i,n,o,s,a,"next",t)}function a(t){k(i,n,o,s,a,"throw",t)}s(void 0)}))}}class q{constructor(t){t.openURIWithCallback||(t.openURIWithCallback=this.getDefaultOpenURIWithCallback()),t.storage||(t.storage=R),this.config=t,this.tokenSectionName="captcha_".concat(t.clientId)}isMatch(){var t,e;return(null===(t=this.config)||void 0===t||null===(t=t.adapter)||void 0===t||null===(e=t.isMatch)||void 0===e?void 0:e.call(t))||C()}request(t,e){var r=this;return D((function*(){e||(e={}),e.method||(e.method="GET");var n,o="".concat(e.method,":").concat(t),i=t;e.withCaptcha&&(i=yield r.appendCaptchaTokenToURL(t,o,!1));try{n=yield r.config.request(i,e)}catch(n){return n.error===s.CAPTCHA_REQUIRED||n.error===s.CAPTCHA_INVALID?(t=yield r.appendCaptchaTokenToURL(t,o,n.error===s.CAPTCHA_INVALID),r.config.request(t,e)):Promise.reject(n)}return n}))()}getDefaultOpenURIWithCallback(){if(!this.isMatch()&&!j()&&(window.location.search.indexOf("__captcha")>0&&(document.body.style.display="none"),null===document.getElementById("captcha_panel_wrap"))){var t=document.createElement("div");t.style.cssText="background-color: rgba(0, 0, 0, 0.7);position: fixed;left: 0px;right: 0px;top: 0px;bottom: 0px;padding: 9vw 0 0 0;display: none;z-index:100;",t.setAttribute("id","captcha_panel_wrap"),setTimeout((()=>{document.body.appendChild(t)}),0)}return this.defaultOpenURIWithCallback}defaultOpenURIWithCallback(t,e){return D((function*(){var{width:r="355px",height:n="355px"}=e||{};if(t.match(/^(data:.*)$/))return Promise.reject({error:s.UNIMPLEMENTED,error_description:"need to impl captcha data"});var o=document.getElementById("captcha_panel_wrap"),i=document.createElement("iframe");return o.innerHTML="",i.setAttribute("src",t),i.setAttribute("id","review-panel-iframe"),i.style.cssText="min-width:".concat(r,";display:block;height:").concat(n,";margin:0 auto;background-color: rgb(255, 255, 255);border: none;"),o.appendChild(i),o.style.display="block",new Promise(((t,e)=>{i.onload=function(){try{var r=window.location,n=i.contentWindow.location;if(n.host+n.pathname===r.host+r.pathname){o.style.display="none";var s=new U(n.search),a=s.get("captcha_token");return a?t({captcha_token:a,expires_in:Number(s.get("expires_in"))}):e({error:s.get("error"),error_description:s.get("error_description")})}o.style.display="block"}catch(t){o.style.display="block"}}}))}))()}getCaptchaToken(t,e){var r=this;return D((function*(){if(!t){var o=yield r.findCaptchaToken();if(o)return o}var i;if(r.isMatch()||j()){var s=yield r.config.request(n.CAPTCHA_DATA_URL,{method:"POST",body:{state:e,redirect_uri:""},withCredentials:!1});i={url:"".concat(s.data,"?state=").concat(encodeURIComponent(e),"&token=").concat(encodeURIComponent(s.token))}}else{var a="".concat(window.location.origin+window.location.pathname,"?__captcha=on");if((i=yield r.config.request(n.GET_CAPTCHA_URL,{method:"POST",body:{client_id:r.config.clientId,redirect_uri:a,state:e},withCredentials:!1})).captcha_token){var u={captcha_token:i.captcha_token,expires_in:i.expires_in};return r.saveCaptchaToken(u),i.captcha_token}}var c=yield r.config.openURIWithCallback(i.url);return r.saveCaptchaToken(c),c.captcha_token}))()}appendCaptchaTokenToURL(t,e,r){var n=this;return D((function*(){var o=yield n.getCaptchaToken(r,e);return t.indexOf("?")>0?t+="&captcha_token=".concat(o):t+="?captcha_token=".concat(o),t}))()}saveCaptchaToken(t){var e=this;return D((function*(){t.expires_at=new Date(Date.now()+1e3*(t.expires_in-10));var r=JSON.stringify(t);yield e.config.storage.setItem(e.tokenSectionName,r)}))()}findCaptchaToken(){var t=this;return D((function*(){var e=yield t.config.storage.getItem(t.tokenSectionName);if(null!=e)try{var r=JSON.parse(e);return null!=r&&r.expires_at&&(r.expires_at=new Date(r.expires_at)),r.expires_at<new Date?null:r.captcha_token}catch(e){return yield t.config.storage.removeItem(t.tokenSectionName),null}return null}))()}}var M=["provider_redirect_uri","other_params"];function B(t,e,r,n,o,i,s){try{var a=t[i](s),u=a.value}catch(t){return void r(t)}a.done?e(u):Promise.resolve(u).then(n,o)}function W(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function s(t){B(i,n,o,s,a,"next",t)}function a(t){B(i,n,o,s,a,"throw",t)}s(void 0)}))}}function F(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function V(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?F(Object(r),!0).forEach((function(e){H(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):F(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function H(t,e,r){return(e=function(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function G(t,e){try{var n;if(((null==e||null===(n=e.root)||void 0===n?void 0:n.globalThis)||globalThis).IS_MP_BUILD)return}catch(e){if(t)return(()=>{try{return r(7171)}catch(t){return}})()}}class ${static parseParamsToSearch(t){return Object.keys(t).forEach((e=>{t[e]||delete t[e]})),new U(t).toString()}constructor(t){var{request:e}=t,r=t.credentialsClient;if(!r){var n={apiOrigin:t.apiOrigin,apiPath:t.apiPath,clientId:t.clientId,storage:t.storage,env:t.env,baseRequest:t.baseRequest,anonymousSignInFunc:t.anonymousSignInFunc,wxCloud:t.wxCloud,onCredentialsError:t.onCredentialsError,headers:t.headers||{},i18n:t.i18n,publishable_key:t.publishable_key};r=new x(n)}if(!e){var o=r.request.bind(r),i=new q(V({clientId:t.clientId,request:o,storage:t.storage,adapter:t.adapter},t.captchaOptions));e=i.request.bind(i)}this.config={env:t.env,apiOrigin:t.apiOrigin,apiPath:t.apiPath,clientId:t.clientId,request:e,credentialsClient:r,storage:t.storage||R,adapter:t.adapter}}getParamsByVersion(t,e){var r,i=(0,f.I)(t),s=(null===(r={v2:o}[null==i?void 0:i.version])||void 0===r?void 0:r[e])||n[e];return i&&delete i.version,{params:i,url:s}}signIn(t){var e=this;return W((function*(){var r=t.version||"v1",n=e.getParamsByVersion(t,"AUTH_SIGN_IN_URL");n.params.query&&delete n.params.query;var o=yield e.getEncryptParams(n.params),i=yield e.config.request(n.url,{method:"POST",body:o});return yield e.config.credentialsClient.setCredentials(V(V({},i),{},{version:r})),Promise.resolve(i)}))()}signInAnonymously(){var t=arguments,e=this;return W((function*(){var r=t.length>0&&void 0!==t[0]?t[0]:{},o=t.length>1&&void 0!==t[1]&&t[1],i=yield e.config.request(n.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",body:r,useWxCloud:o});return yield e.config.credentialsClient.setCredentials(i),Promise.resolve(i)}))()}signUp(t){var e=this;return W((function*(){var r=yield e.config.request(n.AUTH_SIGN_UP_URL,{method:"POST",body:t});return yield e.config.credentialsClient.setCredentials(r),Promise.resolve(r)}))()}signOut(t){var e=this;return W((function*(){var r={};if(t){try{r=yield e.config.request(n.AUTH_SIGNOUT_URL,{method:"POST",withCredentials:!0,body:t})}catch(t){t.error!==s.UNAUTHENTICATED&&console.log("sign_out_error",t)}return yield e.config.credentialsClient.setCredentials(),r}var o=yield e.config.credentialsClient.getAccessToken(),i=yield e.config.request(n.AUTH_REVOKE_URL,{method:"POST",body:{token:o}});return yield e.config.credentialsClient.setCredentials(),Promise.resolve(i)}))()}revokeAllDevices(){var t=this;return W((function*(){yield t.config.request(n.AUTH_REVOKE_ALL_URL,{method:"DELETE",withCredentials:!0})}))()}revokeDevice(t){var e=this;return W((function*(){yield e.config.request(n.AUTHORIZED_DEVICES_DELETE_URL+t.device_id,{method:"DELETE",withCredentials:!0})}))()}getVerification(t,e){var r=this;return W((function*(){var o=!1;return("CUR_USER"===t.target||(yield r.hasLoginState()))&&(o=!0),r.config.request(n.VERIFICATION_URL,{method:"POST",body:t,withCaptcha:(null==e?void 0:e.withCaptcha)||!1,withCredentials:o})}))()}verify(t){var e=this;return W((function*(){var r=e.getParamsByVersion(t,"VERIFY_URL"),n=yield e.config.request(r.url,{method:"POST",body:r.params});return"v2"===(null==t?void 0:t.version)&&(yield e.config.credentialsClient.setCredentials(V(V({},n),{},{version:"v2"}))),n}))()}genProviderRedirectUri(t){var e=this;return W((function*(){var{provider_redirect_uri:r,other_params:o={}}=t,i=function(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r={};for(var n in t)if({}.hasOwnProperty.call(t,n)){if(e.includes(n))continue;r[n]=t[n]}return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)r=i[n],e.includes(r)||{}.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(t,M);r&&!i.redirect_uri&&(i.redirect_uri=r);var s="".concat(n.PROVIDER_URI_URL,"?").concat($.parseParamsToSearch(i));return Object.keys(o).forEach((t=>{var e=o[t];("sign_out_uri"!==t||(null==e?void 0:e.length)>0)&&(s+="&other_params[".concat(t,"]=").concat(encodeURIComponent(e)))})),e.config.request(s,{method:"GET"})}))()}grantProviderToken(t){var e=arguments,r=this;return W((function*(){var o=e.length>1&&void 0!==e[1]&&e[1];return r.config.request(n.PROVIDER_TOKEN_URL,{method:"POST",body:t,useWxCloud:o})}))()}patchProviderToken(t){var e=this;return W((function*(){return e.config.request(n.PROVIDER_TOKEN_URL,{method:"PATCH",body:t})}))()}signInWithProvider(t){var e=arguments,r=this;return W((function*(){var n=e.length>1&&void 0!==e[1]&&e[1],o=r.getParamsByVersion(t,"AUTH_SIGN_IN_WITH_PROVIDER_URL"),i=yield r.config.request(o.url,{method:"POST",body:o.params,useWxCloud:n});return yield r.config.credentialsClient.setCredentials(V(V({},i),{},{version:(null==t?void 0:t.version)||"v1"})),Promise.resolve(i)}))()}signInCustom(t){var e=this;return W((function*(){var r=yield e.config.request(n.AUTH_SIGN_IN_CUSTOM,{method:"POST",body:t});return yield e.config.credentialsClient.setCredentials(r),Promise.resolve(r)}))()}signInWithWechat(){var t=arguments,e=this;return W((function*(){var r=t.length>0&&void 0!==t[0]?t[0]:{},o=yield e.config.request(n.AUTH_SIGN_IN_WITH_WECHAT_URL,{method:"POST",body:r});return yield e.config.credentialsClient.setCredentials(o),Promise.resolve(o)}))()}bindWithProvider(t){var e=this;return W((function*(){return e.config.request(n.PROVIDER_BIND_URL,{method:"POST",body:t,withCredentials:!0})}))()}getUserProfile(t){var e=this;return W((function*(){return e.getUserInfo(t)}))()}getUserInfo(){var t=arguments,e=this;return W((function*(){var r,n=t.length>0&&void 0!==t[0]?t[0]:{},o=e.getParamsByVersion(n,"USER_ME_URL");if(null!==(r=o.params)&&void 0!==r&&r.query){var i=new U(o.params.query);o.url+="?".concat(i.toString())}var s=yield e.config.request(o.url,{method:"GET",withCredentials:!0});return s.sub&&(s.uid=s.sub),s}))()}getWedaUserInfo(){var t=this;return W((function*(){return yield t.config.request(n.WEDA_USER_URL,{method:"GET",withCredentials:!0})}))()}deleteMe(t){var e=this;return W((function*(){var r=e.getParamsByVersion(t,"USER_ME_URL"),n="".concat(r.url,"?").concat($.parseParamsToSearch(r.params));return e.config.request(n,{method:"DELETE",withCredentials:!0})}))()}hasLoginState(){var t=this;return W((function*(){try{return yield t.config.credentialsClient.getAccessToken(),!0}catch(t){return!1}}))()}hasLoginStateSync(){return this.config.credentialsClient.getCredentialsSync()}getLoginState(){var t=this;return W((function*(){return t.config.credentialsClient.getCredentialsAsync()}))()}transByProvider(t){var e=this;return W((function*(){return e.config.request(n.USER_TRANS_BY_PROVIDER_URL,{method:"PATCH",body:t,withCredentials:!0})}))()}grantToken(t){var e=this;return W((function*(){var r=e.getParamsByVersion(t,"AUTH_TOKEN_URL");return e.config.request(r.url,{method:"POST",body:r.params})}))()}getProviders(){var t=this;return W((function*(){return t.config.request(n.PROVIDER_LIST,{method:"GET",withCredentials:!0})}))()}unbindProvider(t){var e=this;return W((function*(){return e.config.request("".concat(n.PROVIDER_UNBIND_URL,"/").concat(t.provider_id),{method:"DELETE",withCredentials:!0})}))()}checkPassword(t){var e=this;return W((function*(){return e.config.request("".concat(n.CHECK_PWD_URL),{method:"POST",withCredentials:!0,body:t})}))()}editContact(t){var e=this;return W((function*(){return e.config.request("".concat(n.BIND_CONTACT_URL),{method:"PATCH",withCredentials:!0,body:t})}))()}setPassword(t){var e=this;return W((function*(){return e.config.request("".concat(n.AUTH_SET_PASSWORD),{method:"PATCH",withCredentials:!0,body:t})}))()}updatePasswordByOld(t){var e=this;return W((function*(){var r=yield e.sudo({password:t.old_password});return e.setPassword({sudo_token:r.sudo_token,new_password:t.new_password})}))()}sudo(t){var e=this;return W((function*(){return e.config.request("".concat(n.SUDO_URL),{method:"POST",withCredentials:!0,body:t})}))()}sendVerificationCodeToCurrentUser(t){var e=this;return W((function*(){return t.target="CUR_USER",e.config.request(n.VERIFICATION_URL,{method:"POST",body:t,withCredentials:!0,withCaptcha:!0})}))()}changeBoundProvider(t){var e=this;return W((function*(){return e.config.request("".concat(n.PROVIDER_LIST,"/").concat(t.provider_id,"/trans"),{method:"POST",body:{provider_trans_token:t.trans_token},withCredentials:!0})}))()}setUserProfile(t){var e=this;return W((function*(){return e.config.request(n.USER_PRIFILE_URL,{method:"PATCH",body:t,withCredentials:!0})}))()}updateUserBasicInfo(t){var e=this;return W((function*(){return e.config.request(n.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:t})}))()}queryUserProfile(t){var e=this;return W((function*(){var r=new U(t);return e.config.request("".concat(n.USER_QUERY_URL,"?").concat(r.toString()),{method:"GET",withCredentials:!0})}))()}setCustomSignFunc(t){this.getCustomSignTicketFn=t}signInWithCustomTicket(){var t=this;return W((function*(){var e=t.getCustomSignTicketFn;if(!e)return Promise.reject({error:"failed_precondition",error_description:"please use setCustomSignFunc to set custom sign function"});var r=yield e();return t.signInCustom({provider_id:"custom",ticket:r})}))()}resetPassword(t){var e=this;return W((function*(){return e.config.request(n.AUTH_RESET_PASSWORD,{method:"POST",body:t})}))()}authorize(t){var e=this;return W((function*(){return e.config.request(n.AUTHORIZE_URL,{method:"POST",withCredentials:!0,body:t})}))()}authorizeDevice(t){var e=this;return W((function*(){return e.config.request(n.AUTHORIZE_DEVICE_URL,{method:"POST",withCredentials:!0,body:t})}))()}deviceAuthorize(t){var e=this;return W((function*(){return e.config.request(n.AUTH_GET_DEVICE_CODE,{method:"POST",body:t,withCredentials:!0})}))()}authorizeInfo(t){var e=this;return W((function*(){var r="".concat(n.AUTHORIZE_INFO_URL,"?").concat($.parseParamsToSearch(t)),o=!0,i=!1;return(yield e.hasLoginState())&&(i=!0,o=!1),e.config.request(r,{method:"GET",withBasicAuth:o,withCredentials:i})}))()}checkUsername(t){var e=this;return W((function*(){return e.config.request(n.CHECK_USERNAME,{method:"GET",body:t,withCredentials:!0})}))()}checkIfUserExist(t){var e=this;return W((function*(){var r=new U(t);return e.config.request("".concat(n.CHECK_IF_USER_EXIST,"?").concat(r.toString()),{method:"GET"})}))()}loginScope(){var t=this;return W((function*(){return t.config.credentialsClient.getScope()}))()}loginGroups(){var t=this;return W((function*(){return t.config.credentialsClient.getGroups()}))()}refreshTokenForce(t){var e=this;return W((function*(){var r=yield e.config.credentialsClient.getCredentials();return yield e.config.credentialsClient.refreshToken(V(V({},r),{},{version:(null==t?void 0:t.version)||"v1"}))}))()}getCredentials(){var t=this;return W((function*(){return t.config.credentialsClient.getCredentials()}))()}getPublicKey(){var t=this;return W((function*(){return t.config.request(o.AUTH_PUBLIC_KEY,{method:"POST",body:{}})}))()}getEncryptParams(t){var e=this;return W((function*(){var{isEncrypt:r}=t;delete t.isEncrypt;var n=(0,f.I)(t),o=G(r,e.config.adapter);if(!o)return t;var i="",s="";try{var a=yield e.getPublicKey();if(i=a.public_key,s=a.public_key_thumbprint,!i||!s)throw a}catch(t){throw t}return{params:o.getEncryptInfo({publicKey:i,payload:n}),public_key_thumbprint:s}}))()}getProviderSubType(){var t=this;return W((function*(){return t.config.request(n.GET_PROVIDER_TYPE,{method:"POST",body:{provider_id:"weda"}})}))()}verifyCaptchaData(t){var e=this;return W((function*(){var{token:r,key:o}=t;return e.config.request(n.VERIFY_CAPTCHA_DATA_URL,{method:"POST",body:{token:r,key:o},withCredentials:!1})}))()}createCaptchaData(t){var e=this;return W((function*(){var{state:r,redirect_uri:o}=t;return e.config.request(n.CAPTCHA_DATA_URL,{method:"POST",body:{state:r,redirect_uri:o},withCredentials:!1})}))()}getMiniProgramCode(t){var e=this;return W((function*(){return e.config.request(n.GET_MINIPROGRAM_QRCODE,{method:"POST",body:t})}))()}getMiniProgramQrCodeStatus(t){var e=this;return W((function*(){return e.config.request(n.GET_MINIPROGRAM_QRCODE_STATUS,{method:"POST",body:t})}))()}getUserBehaviorLog(t){var e=this;return W((function*(){var r="".concat(n.GET_USER_BEHAVIOR_LOG,"?").concat({LOGIN:"query[action]=USER_LOGIN",MODIFY:"ne_query[action]=USER_LOGIN"}[t.type],"&limit=").concat(t.limit).concat(t.page_token?"&page_token=".concat(t.page_token):"");return e.config.request(r,{method:"GET",withCredentials:!0})}))()}modifyPassword(t){var e=this;return W((function*(){var r="",o="",i=G(!0,e.config.adapter);if(!i)throw new Error("do not support encrypt, a encrypt util required.");try{var s=yield e.getPublicKey();if(r=s.public_key,o=s.public_key_thumbprint,!r||!o)throw s}catch(t){throw t}var a=t.password?i.getEncryptInfo({publicKey:r,payload:t.password}):"",u=i.getEncryptInfo({publicKey:r,payload:t.new_password});return e.config.request(n.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:{user_id:t.user_id,encrypt_password:a,encrypt_new_password:u,public_key_thumbprint:o}})}))()}modifyPasswordWithoutLogin(t){var e=this;return W((function*(){var r="",n="",i=G(!0,e.config.adapter);if(!i)throw new Error("do not support encrypt, a encrypt util required.");try{var s=yield e.getPublicKey();if(r=s.public_key,n=s.public_key_thumbprint,!r||!n)throw s}catch(t){throw t}var a=t.password?i.getEncryptInfo({publicKey:r,payload:t.password}):"",u=i.getEncryptInfo({publicKey:r,payload:t.new_password});return e.config.request(o.AUTH_RESET_PASSWORD,{method:"POST",body:{username:t.username,password:a,new_password:u,public_key_thumbprint:n}})}))()}}function K(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function z(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?K(Object(r),!0).forEach((function(e){J(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):K(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function J(t,e,r){return(e=function(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}class Y{constructor(t){var{apiOrigin:e,apiPath:r=c,clientId:n,env:o,storage:i,request:s,baseRequest:a,anonymousSignInFunc:u,wxCloud:l,adapter:f,onCredentialsError:h,headers:d,i18n:p,publishable_key:y}=t;this.oauth2client=new x({apiOrigin:e,apiPath:r,clientId:n,env:o,storage:i,baseRequest:a||s,anonymousSignInFunc:u,wxCloud:l,onCredentialsError:h,headers:d||{},i18n:p,publishable_key:y}),this.authApi=new $(z(z({credentialsClient:this.oauth2client},t),{},{request:s?this.oauth2client.request.bind(this.oauth2client):void 0,adapter:f}))}}var Q=r(5605),Z=r(794),X=r(141),tt=r(9689),et=r(6197),rt=r(190),nt=r(8182),ot=function(){return ot=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},ot.apply(this,arguments)},it=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},st=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},at=function(){function t(t){var e,r;try{this.localStorage=(null==t?void 0:t.localStorage)||((null===(r=null===(e=null==t?void 0:t.adapter)||void 0===e?void 0:e.root)||void 0===r?void 0:r.globalThis)||globalThis).localStorage}catch(e){this.localStorage=(null==t?void 0:t.localStorage)||{}}}return t.prototype.getItem=function(t){return it(this,void 0,void 0,(function(){return st(this,(function(e){return[2,this.localStorage.getItem(t)]}))}))},t.prototype.removeItem=function(t){return it(this,void 0,void 0,(function(){return st(this,(function(e){return this.localStorage.removeItem(t),[2]}))}))},t.prototype.setItem=function(t,e){return it(this,void 0,void 0,(function(){return st(this,(function(r){return this.localStorage.setItem(t,e),[2]}))}))},t.prototype.getItemSync=function(t){return this.localStorage.getItem(t)},t.prototype.setItemSync=function(t,e){this.localStorage.setItem(t,e)},t.prototype.removeItemSync=function(t){this.localStorage.removeItem(t)},t}(),ut=/^[^:]+:\/\/[^/]+(\/[^?#]+)/,ct=function(t,e){var r,n,o,i,s=null===(r=null==e?void 0:e.headers)||void 0===r?void 0:r["x-request-id"];return t||(t={}),((null==t?void 0:t.code)||(null===(n=null==t?void 0:t.data)||void 0===n?void 0:n.error_code))&&(t={error:t.code||t.data.error,error_description:t.data.error_description||t.message||t.code||t.data.error_code,request_id:t.requestId,error_code:null===(o=t.data)||void 0===o?void 0:o.error_code}),(null==t?void 0:t.request_id)||(t.request_id=t.request_id||s),(null==t?void 0:t.error)?(t.error_uri=(i=null==e?void 0:e.url,ut.test(i)?RegExp.$1:i),t):(null==t?void 0:t.data)||{}},lt=function(t){return t.adapter&&"default"!==t.adapter.type?function(t,e){var r=ot({},t);try{if(!(null==t?void 0:t.storage)&&(null==e?void 0:e.localStorage)&&(r.storage=new at({localStorage:e.localStorage,adapter:e})),!t.captchaOptions&&(null==e?void 0:e.captchaOptions)&&(r.captchaOptions=e.captchaOptions),!t.baseRequest&&!t.request&&(null==e?void 0:e.reqClass)){var n=new e.reqClass({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});r.baseRequest=function(t,e){var r;return it(this,void 0,void 0,(function(){var o,i,s,a;return st(this,(function(u){switch(u.label){case 0:if(o={},i=(null===(r=e.method)||void 0===r?void 0:r.toLocaleLowerCase())||"get","function"!=typeof(s=null==n?void 0:n[i]))throw new Error("invalid 【".concat(i,"】 request method"));u.label=1;case 1:return u.trys.push([1,3,,4]),e.headers["content-type"]&&!e.headers["content-type"].includes("application/json")||"string"==typeof e.body||(e.data=e.data||e.body,e.body=JSON.stringify(e.body)),[4,s(ot({url:t},e))];case 2:return o=u.sent(),o=ct(o,ot(ot({},e),{url:t})),[3,4];case 3:throw a=u.sent(),o=a,a;case 4:if(null==o?void 0:o.error)throw o;return[2,o]}}))}))}}}catch(t){console.error("user adapter generate fail:",t)}return r}(t,t.adapter):function(t,e){if(!rt.ZP.isMatch()||t.storage&&t.baseRequest)return t;var r=ot({},t),n={};try{var o=rt.ZP.genAdapter(),i=o.localStorage,s=o.reqClass;if(i&&(n.storage=new at({localStorage:i,adapter:e})),s){var a=new s({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});n.request=function(t){return function(e,r){return it(this,void 0,void 0,(function(){return st(this,(function(n){return[2,new Promise((function(n,o){var i=Object.assign({},r);i.body&&"string"!=typeof i.body&&(i.body=JSON.stringify(i.body));var s=wx.request({url:e,data:i.body,timeout:t._timeout,method:i.method||"GET",header:i.headers,success:function(t){(t=ct(t,ot(ot({},r),{url:e}))).error&&o(t),n(t)},fail:function(t){o({error:"unreachable",error_description:t.message})},complete:function(e){if(e&&e.errMsg&&t._timeout&&-1!==t._restrictedMethods.indexOf("request")&&"request:fail timeout"===e.errMsg){console.warn(t._timeoutMsg);try{s.abort()}catch(t){}}}})}))]}))}))}}(a)}return r.captchaOptions&&(n.baseRequest=n.request,n.request=void 0),ot(ot({},r),n)}catch(t){console.error("adapter generate fail:",t)}return r}(t,t.adapter)},ft=function(){return ft=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},ft.apply(this,arguments)},ht=function(t,e,r,n){var o,i=arguments.length,s=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s},dt=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},pt=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},yt=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},vt="credentials_error",gt="loginStateChanged",mt=new tt.CloudbaseEventEmitter,bt=function(t){mt.fire(gt,ft(ft({},t),{eventType:vt}))},wt=function(){function t(t){var e=t.cache,r=t.oauthInstance;this.cache=e,this.oauthInstance=r,this.setUserInfo()}return t.prototype.checkLocalInfo=function(){return pt(this,void 0,void 0,(function(){return yt(this,(function(t){return this.uid=this.getLocalUserInfo("uid"),this.gender=this.getLocalUserInfo("gender"),this.picture=this.getLocalUserInfo("picture"),this.email=this.getLocalUserInfo("email"),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),this.username=this.getLocalUserInfo("username"),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]}))}))},t.prototype.checkLocalInfoAsync=function(){return pt(this,void 0,void 0,(function(){var t,e,r,n;return yt(this,(function(o){switch(o.label){case 0:return t=this,[4,this.getLocalUserInfoAsync("uid")];case 1:return t.uid=o.sent(),e=this,[4,this.getLocalUserInfoAsync("gender")];case 2:return e.gender=o.sent(),this.picture=this.getLocalUserInfo("picture"),r=this,[4,this.getLocalUserInfoAsync("email")];case 3:return r.email=o.sent(),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),n=this,[4,this.getLocalUserInfoAsync("username")];case 4:return n.username=o.sent(),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]}}))}))},t.prototype.update=function(t){return pt(this,void 0,void 0,(function(){var e;return yt(this,(function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.setUserProfile(ft({},t))];case 1:return e=r.sent(),this.setLocalUserInfo(e),[2]}}))}))},t.prototype.updateUserBasicInfo=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.updateUserBasicInfo(ft({},t))];case 1:return e.sent(),this.setLocalUserInfo({username:t.username}),[2]}}))}))},t.prototype.updatePassword=function(t,e){return this.oauthInstance.authApi.updatePasswordByOld({old_password:e,new_password:t})},t.prototype.updateUsername=function(t){return"string"!=typeof t&&(0,Q.throwError)(Z.ERRORS.INVALID_PARAMS,"username must be a string"),this.update({username:t})},t.prototype.refresh=function(t){return pt(this,void 0,void 0,(function(){var e;return yt(this,(function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.getUserInfo(t)];case 1:return e=r.sent(),this.setLocalUserInfo(e),[2,e]}}))}))},t.prototype.getLocalUserInfo=function(t){var e=this.cache.keys.userInfoKey;return this.cache.getStore(e)[t]},t.prototype.getLocalUserInfoAsync=function(t){return pt(this,void 0,void 0,(function(){var e;return yt(this,(function(r){switch(r.label){case 0:return e=this.cache.keys.userInfoKey,[4,this.cache.getStoreAsync(e)];case 1:return[2,r.sent()[t]]}}))}))},t.prototype.setUserInfo=function(){var t=this,e=this.cache.keys.userInfoKey,r=this.cache.getStore(e);["uid","email","name","gender","picture","email_verified","phone_number","birthdate","zoneinfo","locale","sub","created_from","providers","username"].forEach((function(e){t[e]=r[e]}))},t.prototype.setLocalUserInfo=function(t){var e=this.cache.keys.userInfoKey;this.cache.setStore(e,t),this.setUserInfo()},ht([(0,X.catchErrorsDecorator)({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[Object]),dt("design:returntype",Promise)],t.prototype,"update",null),ht([(0,X.catchErrorsDecorator)({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[String,String]),dt("design:returntype",void 0)],t.prototype,"updatePassword",null),ht([(0,X.catchErrorsDecorator)({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[String]),dt("design:returntype",void 0)],t.prototype,"updateUsername",null),ht([(0,X.catchErrorsDecorator)({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[Object]),dt("design:returntype",Promise)],t.prototype,"refresh",null),t}(),_t=function(){function t(t){var e=t.envId,r=t.cache,n=t.oauthInstance;e||(0,Q.throwError)(Z.ERRORS.INVALID_PARAMS,"envId is not defined"),this.cache=r,this.oauthInstance=n,this.user=new wt({cache:this.cache,oauthInstance:n})}return t.prototype.checkLocalState=function(){var t;this.oauthLoginState=null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.hasLoginStateSync(),this.user.checkLocalInfo()},t.prototype.checkLocalStateAsync=function(){var t;return pt(this,void 0,void 0,(function(){return yt(this,(function(e){switch(e.label){case 0:return[4,null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.getLoginState()];case 1:return e.sent(),[4,this.user.checkLocalInfoAsync()];case 2:return e.sent(),[2]}}))}))},t}(),St=function(){function t(t){this.config=t,this.cache=t.cache,this.oauthInstance=t.oauthInstance,t.publishable_key&&this.createLoginState()}return t.prototype.bindPhoneNumber=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.editContact(t)]}))}))},t.prototype.unbindProvider=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.unbindProvider(t)]}))}))},t.prototype.bindEmail=function(t){return this.oauthInstance.authApi.editContact(t)},t.prototype.verify=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.verify(t)]}))}))},t.prototype.getVerification=function(t,e){return pt(this,void 0,void 0,(function(){return yt(this,(function(r){return[2,this.oauthInstance.authApi.getVerification(t,e)]}))}))},Object.defineProperty(t.prototype,"currentUser",{get:function(){if("async"!==this.cache.mode){var t=this.hasLoginState();return t&&t.user||null}(0,Q.printWarn)(Z.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrentUser insteed")},enumerable:!1,configurable:!0}),t.prototype.getCurrentUser=function(){return pt(this,void 0,void 0,(function(){var t;return yt(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.signInAnonymously=function(t){return void 0===t&&(t={}),pt(this,void 0,void 0,(function(){return yt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInAnonymously(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.signInAnonymouslyInWx=function(t){var e=(void 0===t?{}:t).useWxCloud;return pt(this,void 0,void 0,(function(){var t,r,n=this;return yt(this,(function(o){switch(o.label){case 0:if(!rt.ZP.isMatch())throw Error("wx api undefined");return t=wx.getAccountInfoSync().miniProgram,r=function(r){return pt(n,void 0,void 0,(function(){var n,o;return yt(this,(function(i){switch(i.label){case 0:n=void 0,o=void 0,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==t?void 0:t.appId,provider_code:r,provider_params:{provider_code_type:"open_id",appid:null==t?void 0:t.appId}},e)];case 2:if((null==(n=i.sent())?void 0:n.error_code)||!n.provider_token)throw n;return[4,this.oauthInstance.authApi.signInAnonymously({provider_token:n.provider_token},e)];case 3:if(null==(o=i.sent())?void 0:o.error_code)throw o;return[3,5];case 4:throw i.sent();case 5:return[2]}}))}))},[4,new Promise((function(t,e){wx.login({success:function(o){return pt(n,void 0,void 0,(function(){var n;return yt(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,r(o.code)];case 1:return i.sent(),t(!0),[3,3];case 2:return n=i.sent(),e(n),[3,3];case 3:return[2]}}))}))},fail:function(t){var r=new Error(null==t?void 0:t.errMsg);r.code=null==t?void 0:t.errno,e(r)}})}))];case 1:return o.sent(),[2,this.createLoginState(void 0,{asyncRefreshUser:!0})]}}))}))},t.prototype.bindOpenId=function(){return pt(this,void 0,void 0,(function(){var t,e,r=this;return yt(this,(function(n){switch(n.label){case 0:if(!rt.ZP.isMatch())throw Error("wx api undefined");return t=wx.getAccountInfoSync().miniProgram,e=function(e){return pt(r,void 0,void 0,(function(){var r;return yt(this,(function(n){switch(n.label){case 0:r=void 0,n.label=1;case 1:return n.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==t?void 0:t.appId,provider_code:e,provider_params:{provider_code_type:"open_id",appid:null==t?void 0:t.appId}})];case 2:if((null==(r=n.sent())?void 0:r.error_code)||!r.provider_token)throw r;return[4,this.oauthInstance.authApi.bindWithProvider({provider_token:r.provider_token})];case 3:return n.sent(),[3,5];case 4:throw n.sent();case 5:return[2]}}))}))},[4,new Promise((function(t,n){wx.login({success:function(o){return pt(r,void 0,void 0,(function(){var r;return yt(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,e(o.code)];case 1:return i.sent(),t(!0),[3,3];case 2:return r=i.sent(),n(r),[3,3];case 3:return[2]}}))}))},fail:function(t){var e=new Error(null==t?void 0:t.errMsg);e.code=null==t?void 0:t.errno,n(e)}})}))];case 1:return n.sent(),[2]}}))}))},t.prototype.signInWithOpenId=function(t){var e=(void 0===t?{}:t).useWxCloud,r=void 0===e||e;return pt(this,void 0,void 0,(function(){var t,e,n=this;return yt(this,(function(o){switch(o.label){case 0:if(!rt.ZP.isMatch())throw Error("wx api undefined");return t=wx.getAccountInfoSync().miniProgram,e=function(e){return pt(n,void 0,void 0,(function(){var n,o;return yt(this,(function(i){switch(i.label){case 0:n=void 0,o=void 0,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==t?void 0:t.appId,provider_code:e,provider_params:{provider_code_type:"open_id",appid:null==t?void 0:t.appId}},r)];case 2:if((null==(n=i.sent())?void 0:n.error_code)||!n.provider_token)throw n;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:n.provider_token},r)];case 3:if(null==(o=i.sent())?void 0:o.error_code)throw o;return[3,5];case 4:throw i.sent();case 5:return[4,this.oauthInstance.oauth2client.setCredentials(o)];case 6:return i.sent(),[2]}}))}))},[4,new Promise((function(t,r){wx.login({success:function(o){return pt(n,void 0,void 0,(function(){var n;return yt(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,e(o.code)];case 1:return i.sent(),t(!0),[3,3];case 2:return n=i.sent(),r(n),[3,3];case 3:return[2]}}))}))},fail:function(t){var e=new Error(null==t?void 0:t.errMsg);e.code=null==t?void 0:t.errno,r(e)}})}))];case 1:return o.sent(),[2,this.createLoginState()]}}))}))},t.prototype.signInWithUnionId=function(){return pt(this,void 0,void 0,(function(){var t=this;return yt(this,(function(e){switch(e.label){case 0:if(!rt.ZP.isMatch())throw Error("wx api undefined");e.label=1;case 1:return e.trys.push([1,3,,4]),[4,new Promise((function(e,r){var n=wx.getAccountInfoSync().miniProgram;wx.login({success:function(o){return pt(t,void 0,void 0,(function(){var t,i,s,a,u;return yt(this,(function(c){switch(c.label){case 0:t=null==n?void 0:n.appId,c.label=1;case 1:return c.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_code:o.code,provider_id:t,provider_params:{provider_code_type:"union_id",appid:null==n?void 0:n.appId}})];case 2:return i=c.sent(),(s=i.provider_token)?[4,this.oauthInstance.authApi.signInWithProvider({provider_id:t,provider_token:s})]:(r(i),[2]);case 3:return(null==(a=c.sent())?void 0:a.error_code)?(r(a),[2]):(e(!0),[3,5]);case 4:return u=c.sent(),r(u),[3,5];case 5:return[2]}}))}))},fail:function(t){var e=new Error(null==t?void 0:t.errMsg);e.code=null==t?void 0:t.errno,r(e)}})}))];case 2:return e.sent(),[3,4];case 3:throw e.sent();case 4:return[2,this.createLoginState()]}}))}))},t.prototype.signInWithPhoneAuth=function(t){var e=t.phoneCode,r=void 0===e?"":e;return pt(this,void 0,void 0,(function(){var t,e,n,o,i;return yt(this,(function(s){switch(s.label){case 0:if(!rt.ZP.isMatch())throw Error("wx api undefined");return t=wx.getAccountInfoSync().miniProgram,e={provider_params:{provider_code_type:"phone"},provider_id:t.appId},[4,wx.login()];case 1:n=s.sent().code,e.provider_code=n,s.label=2;case 2:return s.trys.push([2,6,,7]),[4,this.oauthInstance.authApi.grantProviderToken(e)];case 3:if((o=s.sent()).error_code)throw o;return[4,this.oauthInstance.authApi.patchProviderToken({provider_token:o.provider_token,provider_id:t.appId,provider_params:{code:r,provider_code_type:"phone"}})];case 4:if((o=s.sent()).error_code)throw o;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:o.provider_token})];case 5:if(null==(i=s.sent())?void 0:i.error_code)throw i;return[3,7];case 6:throw s.sent();case 7:return[2,this.createLoginState()]}}))}))},t.prototype.signInWithSms=function(t){var e=t.verificationInfo,r=void 0===e?{verification_id:"",is_user:!1}:e,n=t.verificationCode,o=void 0===n?"":n,i=t.phoneNum,s=void 0===i?"":i,a=t.bindInfo,u=void 0===a?void 0:a;return pt(this,void 0,void 0,(function(){return yt(this,(function(t){try{return[2,this.signInWithUsername({verificationInfo:r,verificationCode:o,bindInfo:u,username:s,loginType:"sms"})]}catch(t){throw t}return[2]}))}))},t.prototype.signInWithEmail=function(t){var e=t.verificationInfo,r=void 0===e?{verification_id:"",is_user:!1}:e,n=t.verificationCode,o=void 0===n?"":n,i=t.bindInfo,s=void 0===i?void 0:i,a=t.email,u=void 0===a?"":a;return pt(this,void 0,void 0,(function(){return yt(this,(function(t){try{return[2,this.signInWithUsername({verificationInfo:r,verificationCode:o,bindInfo:s,username:u,loginType:"email"})]}catch(t){throw t}return[2]}))}))},t.prototype.setCustomSignFunc=function(t){this.oauthInstance.authApi.setCustomSignFunc(t)},t.prototype.signInWithCustomTicket=function(){return pt(this,void 0,void 0,(function(){return yt(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signInWithCustomTicket()];case 1:return t.sent(),[2,this.createLoginState()]}}))}))},t.prototype.signIn=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signIn(t)];case 1:return e.sent(),[2,this.createLoginState(t)]}}))}))},t.prototype.signUp=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signUp(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.setPassword=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.setPassword(t)]}))}))},t.prototype.isUsernameRegistered=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){switch(e.label){case 0:return"string"!=typeof t&&(0,Q.throwError)(Z.ERRORS.INVALID_PARAMS,"username must be a string"),[4,this.oauthInstance.authApi.checkIfUserExist({username:t})];case 1:return[2,e.sent().exist]}}))}))},t.prototype.signOut=function(t){return pt(this,void 0,void 0,(function(){var e,r;return yt(this,(function(n){switch(n.label){case 0:return e=this.cache.keys.userInfoKey,[4,this.oauthInstance.authApi.signOut(t)];case 1:return r=n.sent(),[4,this.cache.removeStoreAsync(e)];case 2:return n.sent(),mt.fire(gt,{eventType:"sign_out"}),[2,r]}}))}))},t.prototype.hasLoginState=function(){var t;if("async"!==this.cache.mode)return(null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.hasLoginStateSync())?new _t({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance}):null;(0,Q.printWarn)(Z.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState insteed")},t.prototype.getLoginState=function(){return pt(this,void 0,void 0,(function(){var t;return yt(this,(function(e){switch(e.label){case 0:t=null,e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.oauthInstance.authApi.getLoginState()];case 2:return t=e.sent(),[3,4];case 3:return e.sent(),[2,null];case 4:return t?[2,new _t({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})]:[2,null]}}))}))},t.prototype.getUserInfo=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.getUserInfo(t)]}))}))},t.prototype.getWedaUserInfo=function(){return pt(this,void 0,void 0,(function(){return yt(this,(function(t){return[2,this.oauthInstance.authApi.getWedaUserInfo()]}))}))},t.prototype.updateUserBasicInfo=function(t){return pt(this,void 0,void 0,(function(){var e;return yt(this,(function(r){switch(r.label){case 0:return[4,this.getLoginState()];case 1:return(e=r.sent())?[4,e.user.updateUserBasicInfo(t)]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},t.prototype.getAuthHeader=function(){return console.error("Auth.getAuthHeader API 已废弃"),{}},t.prototype.bindWithProvider=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.bindWithProvider(t)]}))}))},t.prototype.queryUser=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.queryUserProfile(t)]}))}))},t.prototype.getAccessToken=function(){return pt(this,void 0,void 0,(function(){return yt(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.oauth2client.getAccessToken()];case 1:return[2,{accessToken:t.sent(),env:this.config.env}]}}))}))},t.prototype.grantProviderToken=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.grantProviderToken(t)]}))}))},t.prototype.patchProviderToken=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.patchProviderToken(t)]}))}))},t.prototype.signInWithProvider=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInWithProvider(t)];case 1:return e.sent(),[2,this.createLoginState(t)]}}))}))},t.prototype.signInWithWechat=function(t){return void 0===t&&(t={}),pt(this,void 0,void 0,(function(){return yt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInWithWechat(t)];case 1:return e.sent(),[2,this.createLoginState(t)]}}))}))},t.prototype.grantToken=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.grantToken(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.genProviderRedirectUri=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.genProviderRedirectUri(t)]}))}))},t.prototype.resetPassword=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.resetPassword(t)]}))}))},t.prototype.deviceAuthorize=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.deviceAuthorize(t)]}))}))},t.prototype.sudo=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.sudo(t)]}))}))},t.prototype.deleteMe=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.deleteMe(t)]}))}))},t.prototype.getProviders=function(){return pt(this,void 0,void 0,(function(){return yt(this,(function(t){return[2,this.oauthInstance.authApi.getProviders()]}))}))},t.prototype.loginScope=function(){return pt(this,void 0,void 0,(function(){return yt(this,(function(t){return[2,this.oauthInstance.authApi.loginScope()]}))}))},t.prototype.loginGroups=function(){return pt(this,void 0,void 0,(function(){return yt(this,(function(t){return[2,this.oauthInstance.authApi.loginGroups()]}))}))},t.prototype.onLoginStateChanged=function(t){return pt(this,void 0,void 0,(function(){var e,r=this;return yt(this,(function(n){switch(n.label){case 0:return mt.on(gt,(function(e){return pt(r,void 0,void 0,(function(){var r,n,o;return yt(this,(function(i){switch(i.label){case 0:return(null===(o=null==e?void 0:e.data)||void 0===o?void 0:o.eventType)===vt?[3,2]:[4,this.getLoginState()];case 1:return n=i.sent(),[3,3];case 2:n={},i.label=3;case 3:return r=n,t.call(this,ft(ft({},e),r)),[2]}}))}))})),[4,this.getLoginState()];case 1:return e=n.sent(),t.call(this,e),[2]}}))}))},t.prototype.refreshTokenForce=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.refreshTokenForce(t)]}))}))},t.prototype.getCredentials=function(){return pt(this,void 0,void 0,(function(){return yt(this,(function(t){return[2,this.oauthInstance.authApi.getCredentials()]}))}))},t.prototype.setCredentials=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.oauth2client.setCredentials(t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getProviderSubType=function(){return pt(this,void 0,void 0,(function(){return yt(this,(function(t){return[2,this.oauthInstance.authApi.getProviderSubType()]}))}))},t.prototype.createCaptchaData=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.createCaptchaData(t)]}))}))},t.prototype.verifyCaptchaData=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.verifyCaptchaData(t)]}))}))},t.prototype.getMiniProgramQrCode=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.getMiniProgramCode(t)]}))}))},t.prototype.getMiniProgramQrCodeStatus=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.getMiniProgramQrCodeStatus(t)]}))}))},t.prototype.modifyPassword=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.modifyPassword(t)]}))}))},t.prototype.modifyPasswordWithoutLogin=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.modifyPasswordWithoutLogin(t)]}))}))},t.prototype.getUserBehaviorLog=function(t){return pt(this,void 0,void 0,(function(){return yt(this,(function(e){return[2,this.oauthInstance.authApi.getUserBehaviorLog(t)]}))}))},t.prototype.toDefaultLoginPage=function(t){return void 0===t&&(t={}),pt(this,void 0,void 0,(function(){var e,r,n,o;return yt(this,(function(i){return e=t.config_version||"env",rt.ZP.isMatch()?wx.navigateTo({url:"/packages/$wd_system/pages/login/index"}):(r=t.redirect_uri||window.location.href,n=new URL(r),o="".concat(n.origin,"/__auth/?app_id=").concat(t.app_id||"","&env_id=").concat(this.config.env,"&client_id=").concat(this.config.clientId,"&config_version=").concat(e,"&redirect_uri=").concat(encodeURIComponent(r)),window.location.href=o),[2]}))}))},t.prototype.createLoginState=function(t,e){return pt(this,void 0,void 0,(function(){var r;return yt(this,(function(n){switch(n.label){case 0:return[4,(r=new _t({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})).checkLocalStateAsync()];case 1:return n.sent(),(null==e?void 0:e.asyncRefreshUser)?(r.user.refresh(t),[3,4]):[3,2];case 2:return[4,r.user.refresh(t)];case 3:n.sent(),n.label=4;case 4:return mt.fire(gt,{eventType:"sign_in"}),[2,r]}}))}))},t.prototype.signInWithUsername=function(t){var e=t.verificationInfo,r=void 0===e?{verification_id:"",is_user:!1}:e,n=t.verificationCode,o=void 0===n?"":n,i=t.username,s=void 0===i?"":i,a=t.bindInfo,u=void 0===a?void 0:a,c=t.loginType,l=void 0===c?"":c;return pt(this,void 0,void 0,(function(){var t,e,n,i,a,c,f;return yt(this,(function(h){switch(h.label){case 0:return h.trys.push([0,8,,9]),[4,this.oauthInstance.authApi.verify({verification_id:r.verification_id,verification_code:o})];case 1:if(null==(t=h.sent())?void 0:t.error_code)throw t;return e=t.verification_token,n="+86 ".concat(s),i={phone_number:n},"email"===l&&(i={email:n=s}),r.is_user?[4,this.oauthInstance.authApi.signIn({username:n,verification_token:e})]:[3,5];case 2:if(null==(a=h.sent())?void 0:a.error_code)throw a;return u?[4,this.oauthInstance.authApi.bindWithProvider({provider_token:null==u?void 0:u.providerToken})]:[3,4];case 3:if(null==(c=h.sent())?void 0:c.error_code)throw c;h.label=4;case 4:return[3,7];case 5:return[4,this.oauthInstance.authApi.signUp(ft(ft({},i),{verification_token:e,provider_token:null==u?void 0:u.providerId}))];case 6:if(null==(f=h.sent())?void 0:f.error_code)throw f;h.label=7;case 7:return[2,this.createLoginState()];case 8:throw h.sent();case 9:return[2]}}))}))},ht([(0,X.catchErrorsDecorator)({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[Object]),dt("design:returntype",Promise)],t.prototype,"bindPhoneNumber",null),ht([(0,X.catchErrorsDecorator)({title:"解除三方绑定失败",messages:["请确认以下各项:"," 1 - 调用 auth().unbindProvider() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[Object]),dt("design:returntype",Promise)],t.prototype,"unbindProvider",null),ht([(0,X.catchErrorsDecorator)({title:"绑定邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[Object]),dt("design:returntype",void 0)],t.prototype,"bindEmail",null),ht([(0,X.catchErrorsDecorator)({title:"验证码验证失败",messages:["请确认以下各项:"," 1 - 调用 auth().verify() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[Object]),dt("design:returntype",Promise)],t.prototype,"verify",null),ht([(0,X.catchErrorsDecorator)({title:"获取验证码失败",messages:["请确认以下各项:"," 1 - 调用 auth().getVerification() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[Object,Object]),dt("design:returntype",Promise)],t.prototype,"getVerification",null),ht([(0,X.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrentUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[]),dt("design:returntype",Promise)],t.prototype,"getCurrentUser",null),ht([(0,X.catchErrorsDecorator)({title:"匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymously() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[Object]),dt("design:returntype",Promise)],t.prototype,"signInAnonymously",null),ht([(0,X.catchErrorsDecorator)({title:"小程序匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymouslyInWx() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[Object]),dt("design:returntype",Promise)],t.prototype,"signInAnonymouslyInWx",null),ht([(0,X.catchErrorsDecorator)({title:"小程序绑定OpenID失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序openId静默登录"," 2 - 调用 auth().bindOpenId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[]),dt("design:returntype",Promise)],t.prototype,"bindOpenId",null),ht([(0,X.catchErrorsDecorator)({title:"小程序openId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序openId静默登录"," 2 - 调用 auth().signInWithOpenId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[Object]),dt("design:returntype",Promise)],t.prototype,"signInWithOpenId",null),ht([(0,X.catchErrorsDecorator)({title:"小程序unionId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序unionId静默登录"," 2 - 调用 auth().signInWithUnionId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[]),dt("design:returntype",Promise)],t.prototype,"signInWithUnionId",null),ht([(0,X.catchErrorsDecorator)({title:"小程序手机号授权登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序手机号授权登录"," 2 - 调用 auth().signInWithPhoneAuth() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[Object]),dt("design:returntype",Promise)],t.prototype,"signInWithPhoneAuth",null),ht([(0,X.catchErrorsDecorator)({title:"短信验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序短信验证码登陆"," 2 - 调用 auth().signInWithSms() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[Object]),dt("design:returntype",Promise)],t.prototype,"signInWithSms",null),ht([(0,X.catchErrorsDecorator)({title:"邮箱验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了邮箱登陆"," 2 - 调用 auth().signInWithEmail() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[Object]),dt("design:returntype",Promise)],t.prototype,"signInWithEmail",null),ht([(0,X.catchErrorsDecorator)({title:"自定义登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了自定义登录"," 2 - 调用 auth().signInWithCustomTicket() 的语法或参数是否正确"," 3 - ticket 是否归属于当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[]),dt("design:returntype",Promise)],t.prototype,"signInWithCustomTicket",null),ht([(0,X.catchErrorsDecorator)({title:"注册失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了指定登录方式"," 2 - 调用 auth().signUp() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[Object]),dt("design:returntype",Promise)],t.prototype,"signUp",null),ht([(0,X.catchErrorsDecorator)({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[String]),dt("design:returntype",Promise)],t.prototype,"isUsernameRegistered",null),ht([(0,X.catchErrorsDecorator)({title:"用户登出失败",messages:["请确认以下各项:"," 1 - 调用 auth().signOut() 的语法或参数是否正确"," 2 - 当前用户是否为匿名登录(匿名登录不支持signOut)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[Object]),dt("design:returntype",Promise)],t.prototype,"signOut",null),ht([(0,X.catchErrorsDecorator)({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[]),dt("design:returntype",Promise)],t.prototype,"getLoginState",null),ht([(0,X.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[Object]),dt("design:returntype",Promise)],t.prototype,"getUserInfo",null),ht([(0,X.catchErrorsDecorator)({title:"获取微搭插件用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getWedaUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[]),dt("design:returntype",Promise)],t.prototype,"getWedaUserInfo",null),ht([(0,X.catchErrorsDecorator)({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindWithProvider() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[Object]),dt("design:returntype",Promise)],t.prototype,"bindWithProvider",null),ht([(0,X.catchErrorsDecorator)({title:"获取身份源类型",messages:["请确认以下各项:"," 1 - 调用 auth().getProviderSubType() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Z.COMMUNITY_SITE_URL)]}),dt("design:type",Function),dt("design:paramtypes",[]),dt("design:returntype",Promise)],t.prototype,"getProviderSubType",null),t}();function Et(t,e){var r=t.region,n=void 0===r?"ap-shanghai":r,o=t.i18n,i=t.publishable_key,s=(null==e?void 0:e.platform)||(0,nt.useDefaultAdapter)(),a=s.runtime,u=s.adapter,l=e||{},f=l.env,h=l.clientId,d=l.debug,p=l.cache,y=l.app,v=(e||{}).apiOrigin;v||(v="https://".concat(f,".").concat(n,".tcb-api.tencentcloudapi.com"));var g={env:f,clientId:h,i18n:o,publishable_key:i},m=new Y(lt(ft(ft({},g),{apiOrigin:v,apiPath:(null==t?void 0:t.apiPath)||c,storage:null==t?void 0:t.storage,baseRequest:null==t?void 0:t.baseRequest,request:null==t?void 0:t.request,anonymousSignInFunc:null==t?void 0:t.anonymousSignInFunc,captchaOptions:null==t?void 0:t.captchaOptions,wxCloud:null==t?void 0:t.wxCloud,adapter:u,onCredentialsError:bt,headers:t.headers||{}})));return{authInstance:new St(ft(ft({},g),{region:n,persistence:t.persistence,debug:d,cache:p||new et.CloudbaseCache({persistence:t.persistence,keys:{userInfoKey:"user_info_".concat(f)},platformInfo:s}),runtime:a||"web",_fromApp:y,oauthInstance:m})),oauthInstance:m}}var It={name:"auth",namespace:"auth",entity:function(t){if(void 0===t&&(t={region:"",persistence:"local",apiPath:c}),this.authInstance)return(0,Q.printWarn)(Z.ERRORS.INVALID_OPERATION,"every cloudbase instance should has only one auth object"),this.authInstance;var e=this.platform.adapter,r=t.persistence||e.primaryStorage;r&&r!==this.config.persistence&&this.updateConfig({persistence:r});var n=Et(ft(ft({wxCloud:this.config.wxCloud,storage:this.config.storage},t),{persistence:this.config.persistence,i18n:this.config.i18n,publishable_key:this.config.publishable_key}),{env:this.config.env,clientId:this.config.clientId,apiOrigin:this.request.getBaseEndPoint(),platform:this.platform,cache:this.cache,app:this,debug:this.config.debug}),o=n.authInstance,i=n.oauthInstance;return this.oauthInstance=i,this.authInstance=o,this.authInstance}};try{cloudbase.registerComponent(It)}catch(t){}function Ot(t){try{t.registerComponent(It)}catch(t){console.warn(t)}}},8622:function(t,e,r){"use strict";r.r(e),r.d(e,{registerDatabase:function(){return Dr}});var n,o,i={};r.r(i),r.d(i,{LineString:function(){return H},MultiLineString:function(){return J},MultiPoint:function(){return K},MultiPolygon:function(){return Q},Point:function(){return ot},Polygon:function(){return $}}),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,u="Object",c="GeoPoint",l="GeoLineString",f="GeoPolygon",h="GeoMultiPoint",d="GeoMultiLineString",p="GeoMultiPolygon",y="Date",v="ServerDate",g=["desc","asc"],m=["<","<=","==",">=",">"];!function(t){t.lt="<",t.gt=">",t.lte="<=",t.gte=">=",t.eq="=="}(s||(s={})),(n={})[s.eq]="$eq",n[s.lt]="$lt",n[s.lte]="$lte",n[s.gt]="$gt",n[s.gte]="$gte",function(t){t.WHERE="WHERE",t.DOC="DOC"}(a||(a={}));var b,w=(b=function(t,e){return b=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},b(t,e)},function(t,e){function r(){this.constructor=t}b(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),_=[],S={},E=function(t){function e(e,r){if(r!==S)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 r=0,n=_.length;r<n;r++)if(_[r].target===t)return _[r].instance;var o=new e(t,S);return _.push({target:t,instance:o}),o},e}((function(t){Object.defineProperties(this,{target:{enumerable:!1,writable:!1,configurable:!1,value:t}})})),I=E,O=I.for("UNSET_FIELD_NAME"),T=I.for("UPDATE_COMMAND"),R=I.for("QUERY_COMMAND"),A=I.for("LOGIC_COMMAND"),P=I.for("GEO_POINT"),x=I.for("SYMBOL_GEO_LINE_STRING"),C=I.for("SYMBOL_GEO_POLYGON"),N=I.for("SYMBOL_GEO_MULTI_POINT"),L=I.for("SYMBOL_GEO_MULTI_LINE_STRING"),j=I.for("SYMBOL_GEO_MULTI_POLYGON"),U=I.for("SERVER_DATE"),k=I.for("REGEXP"),D=function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},q=function(t){return"object"===D(t)},M=function(t){return"number"===D(t)},B=function(t){return Array.isArray(t)},W=function(t){return"date"===D(t)},F=function(t){return"regexp"===D(t)},V=function(t){return t&&t._internalType instanceof E},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,r;if("LineString"!==t.type||!B(t.coordinates))return!1;try{for(var n=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(t.coordinates),o=n.next();!o.done;o=n.next()){var i=o.value;if(!M(i[0])||!M(i[1]))return!1}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}return!0},t.isClosed=function(t){var e=t.points[0],r=t.points[t.points.length-1];if(e.latitude===r.latitude&&e.longitude===r.longitude)return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return x},enumerable:!0,configurable:!0}),t}(),G=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},$=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,r,n,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 u=(n=void 0,G(a)),c=u.next();!c.done;c=u.next()){var l=c.value;if(!M(l[0])||!M(l[1]))return!1}}catch(t){n={error:t}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}finally{if(n)throw n.error}}}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}return!0},t.isCloseLineString=function(t){var e=t[0],r=t[t.length-1];return e[0]===r[0]&&e[1]===r[1]},Object.defineProperty(t.prototype,"_internalType",{get:function(){return j},enumerable:!0,configurable:!0}),t}(),K=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,r;if("MultiPoint"!==t.type||!B(t.coordinates))return!1;try{for(var n=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(t.coordinates),o=n.next();!o.done;o=n.next()){var i=o.value;if(!M(i[0])||!M(i[1]))return!1}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return N},enumerable:!0,configurable:!0}),t}(),z=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},J=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,r,n,o;if("MultiLineString"!==t.type||!B(t.coordinates))return!1;try{for(var i=z(t.coordinates),s=i.next();!s.done;s=i.next()){var a=s.value;try{for(var u=(n=void 0,z(a)),c=u.next();!c.done;c=u.next()){var l=c.value;if(!M(l[0])||!M(l[1]))return!1}}catch(t){n={error:t}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}finally{if(n)throw n.error}}}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return L},enumerable:!0,configurable:!0}),t}(),Y=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Q=function(){function t(t){var e,r;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 n=Y(t),o=n.next();!o.done;o=n.next()){var i=o.value;if(!(i instanceof $))throw new TypeError('"polygon" must be of type Polygon[]. Received type '+typeof i+"[]")}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}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,r,n,o,i,s;if("MultiPolygon"!==t.type||!B(t.coordinates))return!1;try{for(var a=Y(t.coordinates),u=a.next();!u.done;u=a.next()){var c=u.value;try{for(var l=(n=void 0,Y(c)),f=l.next();!f.done;f=l.next()){var h=f.value;try{for(var d=(i=void 0,Y(h)),p=d.next();!p.done;p=d.next()){var y=p.value;if(!M(y[0])||!M(y[1]))return!1}}catch(t){i={error:t}}finally{try{p&&!p.done&&(s=d.return)&&s.call(d)}finally{if(i)throw i.error}}}}catch(t){n={error:t}}finally{try{f&&!f.done&&(o=l.return)&&o.call(l)}finally{if(n)throw n.error}}}}catch(t){e={error:t}}finally{try{u&&!u.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return C},enumerable:!0,configurable:!0}),t}(),Z=function(){function t(t){var e=(void 0===t?{}:t).offset,r=void 0===e?0:e;this.offset=r}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 X(t){return new Z(t)}var tt,et=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s},rt=function(){function t(){}return t.formatResDocumentData=function(e){return e.map((function(e){return t.formatField(e)}))},t.formatField=function(e){var r=Object.keys(e),n={};return Array.isArray(e)&&(n=[]),r.forEach((function(r){var o,i=e[r];switch(t.whichType(i)){case c:o=new ot(i.coordinates[0],i.coordinates[1]);break;case l:o=new H(i.coordinates.map((function(t){return new ot(t[0],t[1])})));break;case f:o=new $(i.coordinates.map((function(t){return new H(t.map((function(t){var e=et(t,2),r=e[0],n=e[1];return new ot(r,n)})))})));break;case h:o=new K(i.coordinates.map((function(t){return new ot(t[0],t[1])})));break;case d:o=new J(i.coordinates.map((function(t){return new H(t.map((function(t){var e=et(t,2),r=e[0],n=e[1];return new ot(r,n)})))})));break;case p:o=new Q(i.coordinates.map((function(t){return new $(t.map((function(t){return new H(t.map((function(t){var e=et(t,2),r=e[0],n=e[1];return new ot(r,n)})))})))})));break;case y:o=new Date(1e3*i.$timestamp);break;case u:case"Array":o=t.formatField(i);break;case v:o=new Date(i.$date);break;default:o=i}Array.isArray(n)?n.push(o):n[r]=o})),n},t.whichType=function(t){var e=Object.prototype.toString.call(t).slice(8,-1);if(e===y)return"BsonDate";if(e===u){if(t instanceof ot)return c;if(t instanceof Date)return y;if(t instanceof Z)return v;t.$timestamp?e=y:t.$date?e=v:ot.validate(t)?e=c:H.validate(t)?e=l:$.validate(t)?e=f:K.validate(t)?e=h:J.validate(t)?e=d:Q.validate(t)&&(e=p)}return e},t.generateDocId=function(){for(var t="",e=0;e<24;e++)t+="ABCDEFabcdef0123456789".charAt(Math.floor(22*Math.random()));return t},t}(),nt=function(){function t(){}return t.isGeopoint=function(t,e){if("Number"!==rt.whichType(e))throw new Error("Geo Point must be number type");var r=Math.abs(e);if("latitude"===t&&r>90)throw new Error("latitude should be a number ranges from -90 to 90");if("longitude"===t&&r>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===g.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){nt.isGeopoint("longitude",t),nt.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)&&nt.isGeopoint("longitude",t.coordinates[0])&&nt.isGeopoint("latitude",t.coordinates[1])},Object.defineProperty(t.prototype,"_internalType",{get:function(){return P},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 r=new Promise((function(e,r){t=function(t,n){return t?r(t):e(n)}}));return t.promise=r,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,r){this._internalType=T,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=t,this.operands=e,this.fieldName=r||O}return t.prototype._setFieldName=function(e){return new t(this.operator,this.operands,e)},t}();function ut(t){return t&&t instanceof at&&t._internalType===T}!function(t){t.AND="and",t.OR="or",t.NOT="not",t.NOR="nor"}(st||(st={}));var ct=function(){function t(t,e,r){if(this._internalType=A,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=t,this.operands=e,this.fieldName=r||O,this.fieldName!==O)if(Array.isArray(e)){e=e.slice(),this.operands=e;for(var n=0,o=e.length;n<o;n++)(lt(i=e[n])||pt(i))&&(e[n]=i._setFieldName(this.fieldName))}else{var i;(lt(i=e)||pt(i))&&(e=i._setFieldName(this.fieldName))}}return t.prototype._setFieldName=function(e){var r=this.operands.map((function(r){return r instanceof t?r._setFieldName(e):r}));return new t(this.operator,r,e)},t.prototype.and=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var n=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return n.unshift(this),new t(st.AND,n,this.fieldName)},t.prototype.or=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var n=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return n.unshift(this),new t(st.OR,n,this.fieldName)},t}();function lt(t){return t&&t instanceof ct&&t._internalType===A}var ft,ht=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},t(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();!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"}(ft||(ft={}));var dt=function(t){function e(e,r,n){var o=t.call(this,e,r,n)||this;return o.operator=e,o._internalType=R,o}return ht(e,t),e.prototype.toJSON=function(){var t,e;switch(this.operator){case ft.IN:case ft.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 r=new e(ft.EQ,[t],this.fieldName);return this.and(r)},e.prototype.neq=function(t){var r=new e(ft.NEQ,[t],this.fieldName);return this.and(r)},e.prototype.gt=function(t){var r=new e(ft.GT,[t],this.fieldName);return this.and(r)},e.prototype.gte=function(t){var r=new e(ft.GTE,[t],this.fieldName);return this.and(r)},e.prototype.lt=function(t){var r=new e(ft.LT,[t],this.fieldName);return this.and(r)},e.prototype.lte=function(t){var r=new e(ft.LTE,[t],this.fieldName);return this.and(r)},e.prototype.in=function(t){var r=new e(ft.IN,t,this.fieldName);return this.and(r)},e.prototype.nin=function(t){var r=new e(ft.NIN,t,this.fieldName);return this.and(r)},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&&!M(t.maxDistance))throw new TypeError('"maxDistance" must be of type Number. Received type '+typeof t.maxDistance);if(void 0!==t.minDistance&&!M(t.minDistance))throw new TypeError('"minDistance" must be of type Number. Received type '+typeof t.minDistance);var r=new e(ft.GEO_NEAR,[t],this.fieldName);return this.and(r)},e.prototype.geoWithin=function(t){if(!(t.geometry instanceof Q||t.geometry instanceof $))throw new TypeError('"geometry" must be of type Polygon or MultiPolygon. Received type '+typeof t.geometry);var r=new e(ft.GEO_WITHIN,[t],this.fieldName);return this.and(r)},e.prototype.geoIntersects=function(t){if(!(t.geometry instanceof ot||t.geometry instanceof H||t.geometry instanceof $||t.geometry instanceof K||t.geometry instanceof J||t.geometry instanceof Q))throw new TypeError('"geometry" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type '+typeof t.geometry);var r=new e(ft.GEO_INTERSECTS,[t],this.fieldName);return this.and(r)},e}(ct);function pt(t){return t&&t instanceof dt&&t._internalType===R}function yt(t){return pt(t)}var vt={};for(var gt in ft)vt[gt]="$"+gt;for(var gt in st)vt[gt]="$"+gt;for(var gt in tt)vt[gt]="$"+gt;function mt(t){return vt[t]||"$"+t}vt[ft.NEQ]="$ne",vt[tt.REMOVE]="$unset",vt[tt.SHIFT]="$pop",vt[tt.UNSHIFT]="$push";var bt=function(){return bt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},bt.apply(this,arguments)},wt=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s},_t=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(wt(arguments[e]));return t};function St(t){return Et(t,[t])}function Et(t,e){if(!V(t)){if(W(t))return{$date:+t};if(F(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 Et(t,_t(e,[t]))}));if(q(t)){var r=bt({},t);for(var n in r){if(e.indexOf(r[n])>-1)throw new Error("Cannot convert circular structure to JSON");r[n]=Et(r[n],_t(e,[r[n]]))}return r}return t}switch(t._internalType){case P:return t.toJSON();case U:case k:return t.parse();default:return t.toJSON?t.toJSON():t}}var It=function(){return It=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},It.apply(this,arguments)},Ot=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s},Tt=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Ot(arguments[e]));return t};function Rt(t,e,r,n){var o=It({},t);for(var i in t)if(!/^\$/.test(i)){var s=t[i];if(s&&q(s)&&!e(s)){if(n.indexOf(s)>-1)throw new Error("Cannot convert circular structure to JSON");var a=Rt(s,e,Tt(r,[i]),Tt(n,[s]));o[i]=a;var u=!1;for(var c in a)/^\$/.test(c)?u=!0:(o[i+"."+c]=a[c],delete o[i][c]);u||delete o[i]}}return o}function At(t){return Rt(t,xt,[],[t])}function Pt(t,e,r){for(var n in e[r]||delete t[r],e)t[n]?B(t[n])?t[n].push(e[n]):q(t[n])?q(e[n])?Object.assign(t[n],e[n]):(console.warn("unmergable condition, query is object but condition is "+D(e)+", can only overwrite",e,r),t[n]=e[n]):(console.warn("to-merge query is of type "+D(t)+", can only overwrite",t,e,r),t[n]=e[n]):t[n]=e[n]}function xt(t){return V(t)||W(t)||F(t)}function Ct(t){return St(t)}var Nt=function(){function t(){}return t.encode=function(e){return(new t).encodeUpdate(e)},t.prototype.encodeUpdate=function(t){return ut(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,r,n,o,i=mt(t.operator);return t.operator===tt.REMOVE?((e={})[i]=((r={})[t.fieldName]="",r),e):((n={})[i]=((o={})[t.fieldName]=t.operands[0],o),n)},t.prototype.encodeArrayUpdateCommand=function(t){var e,r,n,o,i,s,a,u,c,l,f=mt(t.operator);switch(t.operator){case tt.PUSH:var h=void 0;return h=B(t.operands)?{$each:t.operands.map(Ct)}:t.operands,(e={})[f]=((r={})[t.fieldName]=h,r),e;case tt.UNSHIFT:return h={$each:t.operands.map(Ct),$position:0},(n={})[f]=((o={})[t.fieldName]=h,o),n;case tt.POP:return(i={})[f]=((s={})[t.fieldName]=1,s),i;case tt.SHIFT:return(a={})[f]=((u={})[t.fieldName]=-1,u),a;default:return(c={})[f]=((l={})[t.fieldName]=Ct(t.operands),l),c}},t.prototype.encodeUpdateObject=function(t){var e=At(t);for(var r in e)if(!/^\$/.test(r)){var n=e[r];if(ut(n))e[r]=n._setFieldName(r),Pt(e,this.encodeUpdateCommand(e[r]),r);else{e[r]=n=Ct(n);var o=new at(tt.SET,[n],r);Pt(e,this.encodeUpdateCommand(o),r)}}return e},t}(),Lt={};function jt(t){if(!jr.wsClientClass)throw new Error("to use realtime you must import realtime module first");var e=t.config.env;return Lt[e]||(Lt[e]=new jr.wsClientClass({context:{appConfig:{docSizeLimit:1e3,realtimePingInterval:1e4,realtimePongWaitTimeout:5e3,request:new jr.reqClass(t.config)}}})),Lt[e]}for(var Ut=function(){return Ut=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Ut.apply(this,arguments)},kt=function(){function t(t,e,r,n){var o=this;void 0===n&&(n={}),this.watch=function(t){return jt(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=r,this.request=new jr.reqClass(this._db.config),this.projection=n}return t.prototype.create=function(t,e){e=e||it();var r={collectionName:this._coll,data:St(t)};return this.id&&(r._id=this.id),this.request.send("database.addDocument",r).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 r=!1,n=function(t){if("object"==typeof t)for(var e in t)t[e]instanceof at?r=!0:"object"==typeof t[e]&&n(t[e])};if(n(t),r)return Promise.resolve({code:"DATABASE_REQUEST_FAILED",message:"update operator complicit"});var o={collectionName:this._coll,queryType:a.DOC,data:St(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 r={_id:this.id},n={collectionName:this._coll,data:Nt.encode(t),query:r,queryType:a.DOC,multi:!1,merge:!0,upsert:!1};return this.request.send("database.updateDocument",n).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},r={collectionName:this._coll,query:e,queryType:a.DOC,multi:!1};return this.request.send("database.deleteDocument",r).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},r={collectionName:this._coll,query:e,queryType:a.DOC,multi:!1,projection:this.projection};return this.request.send("database.queryDocument",r).then((function(e){if(e.code)t(0,e);else{var r=rt.formatResDocumentData(e.data.list);t(0,{data:r,requestId:e.requestId})}})).catch((function(e){t(e)})),t.promise},t.prototype.field=function(e){for(var r in e)e[r]?e[r]=1:e[r]=0;return new t(this._db,this._coll,this.id,e)},t}(),Dt=function(){function t(){}return t.encode=function(t){return(new qt).encodeQuery(t)},t}(),qt=function(){function t(){}return t.prototype.encodeQuery=function(t,e){var r;return xt(t)?lt(t)?this.encodeLogicCommand(t):pt(t)?this.encodeQueryCommand(t):((r={})[e]=this.encodeQueryObject(t),r):q(t)?this.encodeQueryObject(t):t},t.prototype.encodeRegExp=function(t){return{$regex:t.source,$options:t.flags}},t.prototype.encodeLogicCommand=function(t){var e,r,n,o,i,s,a,u=this;switch(t.operator){case st.NOR:case st.AND:case st.OR:var c=mt(t.operator),l=t.operands.map((function(e){return u.encodeQuery(e,t.fieldName)}));return(e={})[c]=l,e;case st.NOT:c=mt(t.operator);var f=t.operands[0];return F(f)?((r={})[t.fieldName]=((n={})[c]=this.encodeRegExp(f),n),r):(l=this.encodeQuery(f)[t.fieldName],(o={})[t.fieldName]=((i={})[c]=l,i),o);default:if(c=mt(t.operator),1===t.operands.length){var h=this.encodeQuery(t.operands[0]);return(s={})[c]=h,s}return l=t.operands.map(this.encodeQuery.bind(this)),(a={})[c]=l,a}},t.prototype.encodeQueryCommand=function(t){return yt(t),this.encodeComparisonCommand(t)},t.prototype.encodeComparisonCommand=function(t){var e,r,n,o,i,s,a,u,c;if(t.fieldName===O)throw new Error("Cannot encode a comparison command with unset field name");var l=mt(t.operator);switch(t.operator){case ft.EQ:case ft.NEQ:case ft.LT:case ft.LTE:case ft.GT:case ft.GTE:case ft.ELEM_MATCH:case ft.EXISTS:case ft.SIZE:case ft.MOD:return(e={})[t.fieldName]=((r={})[l]=Ct(t.operands[0]),r),e;case ft.IN:case ft.NIN:case ft.ALL:return(n={})[t.fieldName]=((o={})[l]=Ct(t.operands),o),n;case ft.GEO_NEAR:var f=t.operands[0];return(i={})[t.fieldName]={$nearSphere:{$geometry:f.geometry.toJSON(),$maxDistance:f.maxDistance,$minDistance:f.minDistance}},i;case ft.GEO_WITHIN:return f=t.operands[0],(s={})[t.fieldName]={$geoWithin:{$geometry:f.geometry.toJSON()}},s;case ft.GEO_INTERSECTS:return f=t.operands[0],(a={})[t.fieldName]={$geoIntersects:{$geometry:f.geometry.toJSON()}},a;default:return(u={})[t.fieldName]=((c={})[l]=Ct(t.operands[0]),c),u}},t.prototype.encodeQueryObject=function(t){var e=At(t);for(var r in e){var n=e[r];if(lt(n)){e[r]=n._setFieldName(r);var o=this.encodeLogicCommand(e[r]);this.mergeConditionAfterEncode(e,o,r)}else yt(n)?(e[r]=n._setFieldName(r),o=this.encodeComparisonCommand(e[r]),this.mergeConditionAfterEncode(e,o,r)):xt(n)&&(e[r]=Ct(n))}return e},t.prototype.mergeConditionAfterEncode=function(t,e,r){for(var n in e[r]||delete t[r],e)t[n]?B(t[n])?t[n]=t[n].concat(e[n]):q(t[n])?q(e[n])?Object.assign(t,e):(console.warn("unmergable condition, query is object but condition is "+D(e)+", can only overwrite",e,r),t[n]=e[n]):(console.warn("to-merge query is of type "+D(t)+", can only overwrite",t,e,r),t[n]=e[n]):t[n]=e[n]},t}(),Mt=function(){return Mt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Mt.apply(this,arguments)},Bt=function(){function t(t,e,r,n,o){var i=this;this.watch=function(t){return jt(i._db).watch(Mt(Mt({},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=r,this._fieldOrders=n||[],this._queryOptions=o||{},this._request=new jr.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 r={collectionName:this._coll,queryType:a.WHERE};return this._fieldFilters&&(r.query=this._fieldFilters),e.length>0&&(r.order=e),this._queryOptions.offset&&(r.offset=this._queryOptions.offset),this._queryOptions.limit?r.limit=this._queryOptions.limit<1e3?this._queryOptions.limit:1e3:r.limit=100,this._queryOptions.projection&&(r.projection=this._queryOptions.projection),this._request.send("database.queryDocument",r).then((function(e){if(e.code)t(0,e);else{var r={data:rt.formatResDocumentData(e.data.list),requestId:e.requestId};e.total&&(r.total=e.total),e.limit&&(r.limit=e.limit),e.offset&&(r.offset=e.offset),t(0,r)}})).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 r=Object.keys(e),n=r.some((function(t){return void 0!==e[t]}));if(r.length&&!n)throw Error(o.QueryParamValueError);return new t(this._db,this._coll,Dt.encode(e),this._fieldOrders,this._queryOptions)},t.prototype.orderBy=function(e,r){nt.isFieldPath(e),nt.isFieldOrder(r);var n={field:e,direction:r},o=this._fieldOrders.concat(n);return new t(this._db,this._coll,this._fieldFilters,o,this._queryOptions)},t.prototype.limit=function(e){nt.isInteger("limit",e);var r=Mt({},this._queryOptions);return r.limit=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,r)},t.prototype.skip=function(e){nt.isInteger("offset",e);var r=Mt({},this._queryOptions);return r.offset=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,r)},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 r={collectionName:this._coll,query:this._fieldFilters,queryType:a.WHERE,multi:!0,merge:!0,upsert:!1,data:Nt.encode(t)};return this._request.send("database.updateDocument",r).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 r in e)e[r]?"object"!=typeof e[r]&&(e[r]=1):e[r]=0;var n=Mt({},this._queryOptions);return n.projection=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},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}(),Wt=[],Ft=[],Vt="undefined"!=typeof Uint8Array?Uint8Array:Array,Ht="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Gt=0;Gt<64;++Gt)Wt[Gt]=Ht[Gt],Ft[Ht.charCodeAt(Gt)]=Gt;function $t(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function Kt(t,e,r){for(var n,o,i=[],s=e;s<r;s+=3)n=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]),i.push(Wt[(o=n)>>18&63]+Wt[o>>12&63]+Wt[o>>6&63]+Wt[63&o]);return i.join("")}Ft["-".charCodeAt(0)]=62,Ft["_".charCodeAt(0)]=63;var zt=function(t){var e,r,n=$t(t),o=n[0],i=n[1],s=new Vt(function(t,e,r){return 3*(e+r)/4-r}(0,o,i)),a=0,u=i>0?o-4:o;for(r=0;r<u;r+=4)e=Ft[t.charCodeAt(r)]<<18|Ft[t.charCodeAt(r+1)]<<12|Ft[t.charCodeAt(r+2)]<<6|Ft[t.charCodeAt(r+3)],s[a++]=e>>16&255,s[a++]=e>>8&255,s[a++]=255&e;return 2===i&&(e=Ft[t.charCodeAt(r)]<<2|Ft[t.charCodeAt(r+1)]>>4,s[a++]=255&e),1===i&&(e=Ft[t.charCodeAt(r)]<<10|Ft[t.charCodeAt(r+1)]<<4|Ft[t.charCodeAt(r+2)]>>2,s[a++]=e>>8&255,s[a++]=255&e),s},Jt=function(t){for(var e,r=t.length,n=r%3,o=[],i=16383,s=0,a=r-n;s<a;s+=i)o.push(Kt(t,s,s+i>a?a:s+i));return 1===n?(e=t[r-1],o.push(Wt[e>>2]+Wt[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],o.push(Wt[e>>10]+Wt[e>>4&63]+Wt[e<<2&63]+"=")),o.join("")},Yt=function(t,e,r,n,o){var i,s,a=8*o-n-1,u=(1<<a)-1,c=u>>1,l=-7,f=r?o-1:0,h=r?-1:1,d=t[e+f];for(f+=h,i=d&(1<<-l)-1,d>>=-l,l+=a;l>0;i=256*i+t[e+f],f+=h,l-=8);for(s=i&(1<<-l)-1,i>>=-l,l+=n;l>0;s=256*s+t[e+f],f+=h,l-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),i-=c}return(d?-1:1)*s*Math.pow(2,i-n)},Qt=function(t,e,r,n,o,i){var s,a,u,c=8*i-o-1,l=(1<<c)-1,f=l>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:i-1,p=n?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=l):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+f>=1?h/u:h*Math.pow(2,1-f))*u>=2&&(s++,u/=2),s+f>=l?(a=0,s=l):s+f>=1?(a=(e*u-1)*Math.pow(2,o),s+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,o),s=0));o>=8;t[r+d]=255&a,d+=p,a/=256,o-=8);for(s=s<<o|a,c+=o;c>0;t[r+d]=255&s,d+=p,s/=256,c-=8);t[r+d-p]|=128*y},Zt=function(t,e){return function(t,e){var r="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 n=2147483647;function o(t){if(t>n)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,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return u(t)}return s(t,e,r)}function s(t,e,r){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 r=0|h(t,e),n=o(r),s=n.write(t,e);return s!==r&&(n=n.slice(0,s)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(q(t,Uint8Array)){var e=new Uint8Array(t);return l(e.buffer,e.byteOffset,e.byteLength)}return c(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(q(t,ArrayBuffer)||t&&q(t.buffer,ArrayBuffer))return l(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(q(t,SharedArrayBuffer)||t&&q(t.buffer,SharedArrayBuffer)))return l(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');var n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return i.from(n,e,r);var s=function(t){if(i.isBuffer(t)){var e=0|f(t.length),r=o(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||M(t.length)?o(0):c(t):"Buffer"===t.type&&Array.isArray(t.data)?c(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,r);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 u(t){return a(t),o(t<0?0:0|f(t))}function c(t){for(var e=t.length<0?0:0|f(t.length),r=o(e),n=0;n<e;n+=1)r[n]=255&t[n];return r}function l(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');var n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,i.prototype),n}function f(t){if(t>=n)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n.toString(16)+" bytes");return 0|t}function h(t,e){if(i.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||q(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 r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return U(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return k(t).length;default:if(o)return n?-1:U(t).length;e=(""+e).toLowerCase(),o=!0}}function d(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return R(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return O(this,e,r);case"latin1":case"binary":return T(this,e,r);case"base64":return S(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function y(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),M(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=i.from(e,n)),i.isBuffer(e))return 0===e.length?-1:v(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):v(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,o){var i,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){var l=-1;for(i=r;i<a;i++)if(c(t,i)===c(e,-1===l?0:i-l)){if(-1===l&&(l=i),i-l+1===u)return l*s}else-1!==l&&(i-=i-l),l=-1}else for(r+u>a&&(r=a-u),i=r;i>=0;i--){for(var f=!0,h=0;h<u;h++)if(c(t,i+h)!==c(e,h)){f=!1;break}if(f)return i}return-1}function g(t,e,r,n){r=Number(r)||0;var o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var s=0;s<n;++s){var a=parseInt(e.substr(2*s,2),16);if(M(a))return s;t[r+s]=a}return s}function m(t,e,r,n){return D(U(e,t.length-r),t,r,n)}function b(t,e,r,n){return D(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function w(t,e,r,n){return D(k(e),t,r,n)}function _(t,e,r,n){return D(function(t,e){for(var r,n,o,i=[],s=0;s<t.length&&!((e-=2)<0);++s)n=(r=t.charCodeAt(s))>>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function S(t,e,r){return 0===e&&r===t.length?Jt(t):Jt(t.slice(e,r))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o<r;){var i,s,a,u,c=t[o],l=null,f=c>239?4:c>223?3:c>191?2:1;if(o+f<=r)switch(f){case 1:c<128&&(l=c);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&c)<<6|63&i)>127&&(l=u);break;case 3:i=t[o+1],s=t[o+2],128==(192&i)&&128==(192&s)&&(u=(15&c)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:i=t[o+1],s=t[o+2],a=t[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(l=u)}null===l?(l=65533,f=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),o+=f}return function(t){var e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);for(var r="",n=0;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=I));return r}(n)}e.kMaxLength=n,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,r){return s(t,e,r)},Object.setPrototypeOf(i.prototype,Uint8Array.prototype),Object.setPrototypeOf(i,Uint8Array),i.alloc=function(t,e,r){return function(t,e,r){return a(t),t<=0?o(t):void 0!==e?"string"==typeof r?o(t).fill(e,r):o(t).fill(e):o(t)}(t,e,r)},i.allocUnsafe=function(t){return u(t)},i.allocUnsafeSlow=function(t){return u(t)},i.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==i.prototype},i.compare=function(t,e){if(q(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),q(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 r=t.length,n=e.length,o=0,s=Math.min(r,n);o<s;++o)if(t[o]!==e[o]){r=t[o],n=e[o];break}return r<n?-1:n<r?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 r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=i.allocUnsafe(e),o=0;for(r=0;r<t.length;++r){var s=t[r];if(q(s,Uint8Array))o+s.length>n.length?i.from(s).copy(n,o):Uint8Array.prototype.set.call(n,s,o);else{if(!i.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,o)}o+=s.length}return n},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)p(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)p(this,e,e+3),p(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)p(this,e,e+7),p(this,e+1,e+6),p(this,e+2,e+5),p(this,e+3,e+4);return this},i.prototype.toString=function(){var t=this.length;return 0===t?"":0===arguments.length?E(this,0,t):d.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="",r=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},r&&(i.prototype[r]=i.prototype.inspect),i.prototype.compare=function(t,e,r,n,o){if(q(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===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;for(var s=(o>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),u=Math.min(s,a),c=this.slice(n,o),l=t.slice(e,r),f=0;f<u;++f)if(c[f]!==l[f]){s=c[f],a=l[f];break}return s<a?-1:a<s?1:0},i.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},i.prototype.indexOf=function(t,e,r){return y(this,t,e,r,!0)},i.prototype.lastIndexOf=function(t,e,r){return y(this,t,e,r,!1)},i.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return m(this,t,e,r);case"ascii":case"latin1":case"binary":return b(this,t,e,r);case"base64":return w(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).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,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(127&t[o]);return n}function T(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function R(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var o="",i=e;i<r;++i)o+=B[t[i]];return o}function A(t,e,r){for(var n=t.slice(e,r),o="",i=0;i<n.length-1;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function P(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function x(t,e,r,n,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(r+n>t.length)throw new RangeError("Index out of range")}function C(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function N(t,e,r,n,o){return e=+e,r>>>=0,o||C(t,0,r,4),Qt(t,e,r,n,23,4),r+4}function L(t,e,r,n,o){return e=+e,r>>>=0,o||C(t,0,r,8),Qt(t,e,r,n,52,8),r+8}i.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);var n=this.subarray(t,e);return Object.setPrototypeOf(n,i.prototype),n},i.prototype.readUintLE=i.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||P(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n},i.prototype.readUintBE=i.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||P(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},i.prototype.readUint8=i.prototype.readUInt8=function(t,e){return t>>>=0,e||P(t,1,this.length),this[t]},i.prototype.readUint16LE=i.prototype.readUInt16LE=function(t,e){return t>>>=0,e||P(t,2,this.length),this[t]|this[t+1]<<8},i.prototype.readUint16BE=i.prototype.readUInt16BE=function(t,e){return t>>>=0,e||P(t,2,this.length),this[t]<<8|this[t+1]},i.prototype.readUint32LE=i.prototype.readUInt32LE=function(t,e){return t>>>=0,e||P(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||P(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},i.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||P(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*e)),n},i.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||P(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},i.prototype.readInt8=function(t,e){return t>>>=0,e||P(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},i.prototype.readInt16LE=function(t,e){t>>>=0,e||P(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},i.prototype.readInt16BE=function(t,e){t>>>=0,e||P(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},i.prototype.readInt32LE=function(t,e){return t>>>=0,e||P(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||P(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||P(t,4,this.length),Yt(this,t,!0,23,4)},i.prototype.readFloatBE=function(t,e){return t>>>=0,e||P(t,4,this.length),Yt(this,t,!1,23,4)},i.prototype.readDoubleLE=function(t,e){return t>>>=0,e||P(t,8,this.length),Yt(this,t,!0,52,8)},i.prototype.readDoubleBE=function(t,e){return t>>>=0,e||P(t,8,this.length),Yt(this,t,!1,52,8)},i.prototype.writeUintLE=i.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||x(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=t/o&255;return e+r},i.prototype.writeUintBE=i.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||x(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},i.prototype.writeUint8=i.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,1,255,0),this[e]=255&t,e+1},i.prototype.writeUint16LE=i.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||x(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,r){return t=+t,e>>>=0,r||x(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,r){return t=+t,e>>>=0,r||x(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,r){return t=+t,e>>>=0,r||x(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,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);x(this,t,e,r,o-1,-o)}var i=0,s=1,a=0;for(this[e]=255&t;++i<r&&(s*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/s|0)-a&255;return e+r},i.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);x(this,t,e,r,o-1,-o)}var i=r-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+r},i.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},i.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||x(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||x(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,r){return t=+t,e>>>=0,r||x(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,r){return N(this,t,e,!0,r)},i.prototype.writeFloatBE=function(t,e,r){return N(this,t,e,!1,r)},i.prototype.writeDoubleLE=function(t,e,r){return L(this,t,e,!0,r)},i.prototype.writeDoubleBE=function(t,e,r){return L(this,t,e,!1,r)},i.prototype.copy=function(t,e,r,n){if(!i.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var o=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),o},i.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!i.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var o=t.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(t=o)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var s;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(s=e;s<r;++s)this[s]=t;else{var a=i.isBuffer(t)?t:i.from(t,n),u=a.length;if(0===u)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(s=0;s<r-e;++s)this[s+e]=a[s%u]}return this};var j=/[^+/0-9A-Za-z-_]/g;function U(t,e){var r;e=e||1/0;for(var n=t.length,o=null,i=[],s=0;s<n;++s){if((r=t.charCodeAt(s))>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function k(t){return zt(function(t){if((t=(t=t.split("=")[0]).trim().replace(j,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function D(t,e,r,n){for(var o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function q(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function M(t){return t!=t}var B=function(){for(var t="0123456789abcdef",e=new Array(256),r=0;r<16;++r)for(var n=16*r,o=0;o<16;++o)e[n+o]=t[r]+t[o];return e}()}(e={exports:{}},e.exports),e.exports}(),Xt=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 r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},te(t,e)};function ee(t,e){function r(){this.constructor=t}te(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var re=function(t){function e(r){var n=t.call(this,r)||this;return Object.setPrototypeOf(n,e.prototype),n}return ee(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return"BSONError"},enumerable:!1,configurable:!0}),e}(Error),ne=function(t){function e(r){var n=t.call(this,r)||this;return Object.setPrototypeOf(n,e.prototype),n}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 r.g&&r.g)||Function("return this")()}var se=function(t){var e,r="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(r);for(var n=Xt.alloc(t),o=0;o<t;++o)n[o]=Math.floor(256*Math.random());return n},ae=function(){if("undefined"!=typeof window){var t=window.crypto||window.msCrypto;if(t&&t.getRandomValues)return function(e){return t.getRandomValues(Xt.alloc(e))}}return void 0!==r.g&&r.g.crypto&&r.g.crypto.getRandomValues?function(t){return r.g.crypto.getRandomValues(Xt.alloc(t))}:se}();function ue(t){return"[object Uint8Array]"===Object.prototype.toString.call(t)}function ce(t){return"object"==typeof t&&null!==t}function le(t,e){var r=!1;return function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return r||(console.warn(e),r=!0),t.apply(this,n)}}function fe(t){if(ArrayBuffer.isView(t))return Xt.from(t.buffer,t.byteOffset,t.byteLength);if(e=t,["[object ArrayBuffer]","[object SharedArrayBuffer]"].includes(Object.prototype.toString.call(e)))return Xt.from(t);var e;throw new ne("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,de=function(t){return"string"==typeof t&&he.test(t)},pe=function(t){if(!de(t))throw new ne('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 Xt.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")},ve=(Math.pow(2,63),Math.pow(2,63),Math.pow(2,53)),ge=-Math.pow(2,53),me=function(){function t(e,r){if(!(this instanceof t))return new t(e,r);if(!(null==e||"string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||Array.isArray(e)))throw new ne("Binary can only be constructed from string, Buffer, TypedArray, or Array<number>");this.sub_type=null!=r?r:t.BSON_BINARY_SUBTYPE_DEFAULT,null==e?(this.buffer=Xt.alloc(t.BUFFER_SIZE),this.position=0):("string"==typeof e?this.buffer=Xt.from(e,"binary"):Array.isArray(e)?this.buffer=Xt.from(e):this.buffer=fe(e),this.position=this.buffer.byteLength)}return t.prototype.put=function(e){if("string"==typeof e&&1!==e.length)throw new ne("only accepts single character String");if("number"!=typeof e&&1!==e.length)throw new ne("only accepts single character Uint8Array or Array");var r;if((r="string"==typeof e?e.charCodeAt(0):"number"==typeof e?e:e[0])<0||r>255)throw new ne("only accepts number in a valid unsigned byte range 0-255");if(this.buffer.length>this.position)this.buffer[this.position++]=r;else{var n=Xt.alloc(t.BUFFER_SIZE+this.buffer.length);this.buffer.copy(n,0,0,this.buffer.length),this.buffer=n,this.buffer[this.position++]=r}},t.prototype.write=function(t,e){if(e="number"==typeof e?e:this.position,this.buffer.length<e+t.length){var r=Xt.alloc(this.buffer.length+t.length);this.buffer.copy(r,0,0,this.buffer.length),this.buffer=r}ArrayBuffer.isView(t)?(this.buffer.set(fe(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"),r=Number(this.sub_type).toString(16);return t.legacy?{$binary:e,$type:1===r.length?"0"+r:r}:{$binary:{base64:e,subType:1===r.length?"0"+r:r}}},t.prototype.toUUID=function(){if(this.sub_type===t.SUBTYPE_UUID)return new be(this.buffer.slice(0,this.position));throw new re('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,r){var n,o;if(r=r||{},"$binary"in e?r.legacy&&"string"==typeof e.$binary&&"$type"in e?(o=e.$type?parseInt(e.$type,16):0,n=Xt.from(e.$binary,"base64")):"string"!=typeof e.$binary&&(o=e.$binary.subType?parseInt(e.$binary.subType,16):0,n=Xt.from(e.$binary.base64,"base64")):"$uuid"in e&&(o=4,n=pe(e.$uuid)),!n)throw new ne("Unexpected Binary Extended JSON format ".concat(JSON.stringify(e)));return 4===o?new be(n):new t(n,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 be=function(t){function e(r){var n,o,i=this;if(null==r)n=e.generate();else if(r instanceof e)n=Xt.from(r.buffer),o=r.__id;else if(ArrayBuffer.isView(r)&&16===r.byteLength)n=fe(r);else{if("string"!=typeof r)throw new ne("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).");n=pe(r)}return(i=t.call(this,n,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 r=ye(this.id,t);return e.cacheHexString&&(this.__id=r),r},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,Xt.from(t)},e.isValid=function(t){return!!t&&(t instanceof e||("string"==typeof t?de(t):!(!ue(t)||16!==t.length||64!=(240&t[6])||128&~t[8])))},e.createFromHexString=function(t){return new e(pe(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,r){if(!(this instanceof t))return new t(e,r);this.code=e,this.scope=r}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 _e=function(){function t(e,r,n,o){if(!(this instanceof t))return new t(e,r,n,o);var i=e.split(".");2===i.length&&(n=i.shift(),e=i.shift()),this.collection=e,this.oid=r,this.db=n,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 r=Object.assign({},e);return delete r.$ref,delete r.$id,delete r.$db,new t(e.$ref,e.$id,e.$db,r)},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(_e.prototype,"_bsontype",{value:"DBRef"});var Se=void 0;try{Se=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(n){}var Ee=4294967296,Ie=0x10000000000000000,Oe=Ie/2,Te={},Re={},Ae=function(){function t(e,r,n){if(void 0===e&&(e=0),!(this instanceof t))return new t(e,r,n);"bigint"==typeof e?Object.assign(this,t.fromBigInt(e,!!r)):"string"==typeof e?Object.assign(this,t.fromString(e,!!r)):(this.low=0|e,this.high=0|r,this.unsigned=!!n),Object.defineProperty(this,"__isLong__",{value:!0,configurable:!1,writable:!1,enumerable:!1})}return t.fromBits=function(e,r,n){return new t(e,r,n)},t.fromInt=function(e,r){var n,o,i;return r?(i=0<=(e>>>=0)&&e<256)&&(o=Re[e])?o:(n=t.fromBits(e,(0|e)<0?-1:0,!0),i&&(Re[e]=n),n):(i=-128<=(e|=0)&&e<128)&&(o=Te[e])?o:(n=t.fromBits(e,e<0?-1:0,!1),i&&(Te[e]=n),n)},t.fromNumber=function(e,r){if(isNaN(e))return r?t.UZERO:t.ZERO;if(r){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,r).neg():t.fromBits(e%Ee|0,e/Ee|0,r)},t.fromBigInt=function(e,r){return t.fromString(e.toString(),r)},t.fromString=function(e,r,n){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t.ZERO;if("number"==typeof r?(n=r,r=!1):r=!!r,(n=n||10)<2||36<n)throw RangeError("radix");var o;if((o=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===o)return t.fromString(e.substring(1),r,n).neg();for(var i=t.fromNumber(Math.pow(n,8)),s=t.ZERO,a=0;a<e.length;a+=8){var u=Math.min(8,e.length-a),c=parseInt(e.substring(a,a+u),n);if(u<8){var l=t.fromNumber(Math.pow(n,u));s=s.mul(l).add(t.fromNumber(c))}else s=(s=s.mul(i)).add(t.fromNumber(c))}return s.unsigned=r,s},t.fromBytes=function(e,r,n){return n?t.fromBytesLE(e,r):t.fromBytesBE(e,r)},t.fromBytesLE=function(e,r){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,r)},t.fromBytesBE=function(e,r){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],r)},t.isLong=function(t){return ce(t)&&!0===t.__isLong__},t.fromValue=function(e,r){return"number"==typeof e?t.fromNumber(e,r):"string"==typeof e?t.fromString(e,r):t.fromBits(e.low,e.high,"boolean"==typeof r?r:e.unsigned)},t.prototype.add=function(e){t.isLong(e)||(e=t.fromValue(e));var r=this.high>>>16,n=65535&this.high,o=this.low>>>16,i=65535&this.low,s=e.high>>>16,a=65535&e.high,u=e.low>>>16,c=0,l=0,f=0,h=0;return f+=(h+=i+(65535&e.low))>>>16,h&=65535,l+=(f+=o+u)>>>16,f&=65535,c+=(l+=n+a)>>>16,l&=65535,c+=r+s,c&=65535,t.fromBits(f<<16|h,c<<16|l,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 r=this.isNegative(),n=e.isNegative();return r&&!n?-1:!r&&n?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(Se){if(!this.unsigned&&-2147483648===this.high&&-1===e.low&&-1===e.high)return this;var r=(this.unsigned?Se.div_u:Se.div_s)(this.low,this.high,e.low,e.high);return t.fromBits(r,Se.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?t.UZERO:t.ZERO;var n,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:(n=this.shr(1).div(e).shl(1)).eq(t.ZERO)?e.isNegative()?t.ONE:t.NEG_ONE:(o=this.sub(e.mul(n)),i=n.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);){n=Math.max(1,Math.floor(o.toNumber()/e.toNumber()));for(var s=Math.ceil(Math.log(n)/Math.LN2),a=s<=48?1:Math.pow(2,s-48),u=t.fromNumber(n),c=u.mul(e);c.isNegative()||c.gt(o);)n-=a,c=(u=t.fromNumber(n,this.unsigned)).mul(e);u.isZero()&&(u=t.ONE),i=i.add(u),o=o.sub(c)}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,r=0!==this.high?this.high:this.low;for(e=31;e>0&&!(r&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)),Se){var r=(this.unsigned?Se.rem_u:Se.rem_s)(this.low,this.high,e.low,e.high);return t.fromBits(r,Se.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)),Se){var r=Se.mul(this.low,this.high,e.low,e.high);return t.fromBits(r,Se.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 n=this.high>>>16,o=65535&this.high,i=this.low>>>16,s=65535&this.low,a=e.high>>>16,u=65535&e.high,c=e.low>>>16,l=65535&e.low,f=0,h=0,d=0,p=0;return d+=(p+=s*l)>>>16,p&=65535,h+=(d+=i*l)>>>16,d&=65535,h+=(d+=s*c)>>>16,d&=65535,f+=(h+=o*l)>>>16,h&=65535,f+=(h+=i*c)>>>16,h&=65535,f+=(h+=s*u)>>>16,h&=65535,f+=n*l+o*c+i*u+s*a,f&=65535,t.fromBits(d<<16|p,f<<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 r=this.high;if(e<32){var n=this.low;return t.fromBits(n>>>e|r<<32-e,r>>>e,this.unsigned)}return 32===e?t.fromBits(r,0,this.unsigned):t.fromBits(r>>>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)*Ee+(this.low>>>0):this.high*Ee+(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 r=t.fromNumber(e),n=this.div(r),o=n.mul(r).sub(this);return n.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 u=s.div(i),c=(s.sub(u.mul(i)).toInt()>>>0).toString(e);if((s=u).isZero())return c+a;for(;c.length<6;)c="0"+c;a=""+c+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,r){var n=t.fromString(e.$numberLong);return r&&r.relaxed?n.toNumber():n},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(Ae.prototype,"__isLong__",{value:!0}),Object.defineProperty(Ae.prototype,"_bsontype",{value:"Long"});var Pe=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,xe=/^(\+|-)?(Infinity|inf)$/i,Ce=/^(\+|-)?NaN$/i,Ne=6111,Le=-6176,je=[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(),ke=[120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),De=/^([-+])?(\d+)?$/;function qe(t){return!isNaN(parseInt(t,10))}function Me(t){var e=Ae.fromNumber(1e9),r=Ae.fromNumber(0);if(!(t.parts[0]||t.parts[1]||t.parts[2]||t.parts[3]))return{quotient:t,rem:r};for(var n=0;n<=3;n++)r=(r=r.shiftLeft(32)).add(new Ae(t.parts[n],0)),t.parts[n]=r.div(e).low,r=r.modulo(e);return{quotient:t,rem:r}}function Be(t,e){throw new ne('"'.concat(t,'" is not a valid Decimal128 string - ').concat(e))}var We=function(){function t(e){if(!(this instanceof t))return new t(e);if("string"==typeof e)this.bytes=t.fromString(e).bytes;else{if(!ue(e))throw new ne("Decimal128 must take a Buffer or string");if(16!==e.byteLength)throw new ne("Decimal128 must take a Buffer of 16 bytes");this.bytes=e}}return t.fromString=function(e){var r,n=!1,o=!1,i=!1,s=0,a=0,u=0,c=0,l=0,f=[0],h=0,d=0,p=0,y=0,v=0,g=0,m=new Ae(0,0),b=new Ae(0,0),w=0;if(e.length>=7e3)throw new ne(e+" not a valid Decimal128 string");var _=e.match(Pe),S=e.match(xe),E=e.match(Ce);if(!_&&!S&&!E||0===e.length)throw new ne(e+" not a valid Decimal128 string");if(_){var I=_[2],O=_[4],T=_[5],R=_[6];O&&void 0===R&&Be(e,"missing exponent power"),O&&void 0===I&&Be(e,"missing exponent base"),void 0===O&&(T||R)&&Be(e,"missing e before exponent")}if("+"!==e[w]&&"-"!==e[w]||(n="-"===e[w++]),!qe(e[w])&&"."!==e[w]){if("i"===e[w]||"I"===e[w])return new t(Xt.from(n?Ue:ke));if("N"===e[w])return new t(Xt.from(je))}for(;qe(e[w])||"."===e[w];)"."!==e[w]?(h<34&&("0"!==e[w]||i)&&(i||(l=a),i=!0,f[d++]=parseInt(e[w],10),h+=1),i&&(u+=1),o&&(c+=1),a+=1,w+=1):(o&&Be(e,"contains multiple periods"),o=!0,w+=1);if(o&&!a)throw new ne(e+" not a valid Decimal128 string");if("e"===e[w]||"E"===e[w]){var A=e.substr(++w).match(De);if(!A||!A[2])return new t(Xt.from(je));v=parseInt(A[0],10),w+=A[0].length}if(e[w])return new t(Xt.from(je));if(p=0,h){if(y=h-1,1!==(s=u))for(;0===f[l+s-1];)s-=1}else p=0,y=0,f[0]=0,u=1,h=1,s=0;for(v<=c&&c-v>16384?v=Le:v-=c;v>Ne;){if((y+=1)-p>34){if(f.join("").match(/^0+$/)){v=Ne;break}Be(e,"overflow")}v-=1}for(;v<Le||h<u;){if(0===y&&s<h){v=Le,s=0;break}if(h<u?u-=1:y-=1,v<Ne)v+=1;else{if(f.join("").match(/^0+$/)){v=Ne;break}Be(e,"overflow")}}if(y-p+1<s){var P=a;o&&(l+=1,P+=1),n&&(l+=1,P+=1);var x=parseInt(e[l+y+1],10),C=0;if(x>=5&&(C=1,5===x))for(C=f[y]%2==1?1:0,g=l+y+2;g<P;g++)if(parseInt(e[g],10)){C=1;break}if(C)for(var N=y;N>=0;N--)if(++f[N]>9&&(f[N]=0,0===N)){if(!(v<Ne))return new t(Xt.from(n?Ue:ke));v+=1,f[N]=1}}if(m=Ae.fromNumber(0),b=Ae.fromNumber(0),0===s)m=Ae.fromNumber(0),b=Ae.fromNumber(0);else if(y-p<17)for(N=p,b=Ae.fromNumber(f[N++]),m=new Ae(0,0);N<=y;N++)b=(b=b.multiply(Ae.fromNumber(10))).add(Ae.fromNumber(f[N]));else{for(N=p,m=Ae.fromNumber(f[N++]);N<=y-17;N++)m=(m=m.multiply(Ae.fromNumber(10))).add(Ae.fromNumber(f[N]));for(b=Ae.fromNumber(f[N++]);N<=y;N++)b=(b=b.multiply(Ae.fromNumber(10))).add(Ae.fromNumber(f[N]))}var L,j,U,k,D=function(t,e){if(!t&&!e)return{high:Ae.fromNumber(0),low:Ae.fromNumber(0)};var r=t.shiftRightUnsigned(32),n=new Ae(t.getLowBits(),0),o=e.shiftRightUnsigned(32),i=new Ae(e.getLowBits(),0),s=r.multiply(o),a=r.multiply(i),u=n.multiply(o),c=n.multiply(i);return s=s.add(a.shiftRightUnsigned(32)),a=new Ae(a.getLowBits(),0).add(u).add(c.shiftRightUnsigned(32)),{high:s=s.add(a.shiftRightUnsigned(32)),low:c=a.shiftLeft(32).add(new Ae(c.getLowBits(),0))}}(m,Ae.fromString("100000000000000000"));D.low=D.low.add(b),j=b,((U=(L=D.low).high>>>0)<(k=j.high>>>0)||U===k&&L.low>>>0<j.low>>>0)&&(D.high=D.high.add(Ae.fromNumber(1))),r=v+6176;var q={low:Ae.fromNumber(0),high:Ae.fromNumber(0)};D.high.shiftRightUnsigned(49).and(Ae.fromNumber(1)).equals(Ae.fromNumber(1))?(q.high=q.high.or(Ae.fromNumber(3).shiftLeft(61)),q.high=q.high.or(Ae.fromNumber(r).and(Ae.fromNumber(16383).shiftLeft(47))),q.high=q.high.or(D.high.and(Ae.fromNumber(0x7fffffffffff)))):(q.high=q.high.or(Ae.fromNumber(16383&r).shiftLeft(49)),q.high=q.high.or(D.high.and(Ae.fromNumber(562949953421311)))),q.low=D.low,n&&(q.high=q.high.or(Ae.fromString("9223372036854775808")));var M=Xt.alloc(16);return w=0,M[w++]=255&q.low.low,M[w++]=q.low.low>>8&255,M[w++]=q.low.low>>16&255,M[w++]=q.low.low>>24&255,M[w++]=255&q.low.high,M[w++]=q.low.high>>8&255,M[w++]=q.low.high>>16&255,M[w++]=q.low.high>>24&255,M[w++]=255&q.high.low,M[w++]=q.high.low>>8&255,M[w++]=q.high.low>>16&255,M[w++]=q.high.low>>24&255,M[w++]=255&q.high.high,M[w++]=q.high.high>>8&255,M[w++]=q.high.high>>16&255,M[w++]=q.high.high>>24&255,new t(M)},t.prototype.toString=function(){for(var t,e=0,r=new Array(36),n=0;n<r.length;n++)r[n]=0;var o,i,s,a=0,u=!1,c={parts:[0,0,0,0]},l=[];a=0;var f=this.bytes,h=f[a++]|f[a++]<<8|f[a++]<<16|f[a++]<<24,d=f[a++]|f[a++]<<8|f[a++]<<16|f[a++]<<24,p=f[a++]|f[a++]<<8|f[a++]<<16|f[a++]<<24,y=f[a++]|f[a++]<<8|f[a++]<<16|f[a++]<<24;a=0,(new Ae(h,d),new Ae(p,y)).lessThan(Ae.ZERO)&&l.push("-");var v=y>>26&31;if(v>>3==3){if(30===v)return l.join("")+"Infinity";if(31===v)return"NaN";t=y>>15&16383,o=8+(y>>14&1)}else o=y>>14&7,t=y>>17&16383;var g=t-6176;if(c.parts[0]=(16383&y)+((15&o)<<14),c.parts[1]=p,c.parts[2]=d,c.parts[3]=h,0===c.parts[0]&&0===c.parts[1]&&0===c.parts[2]&&0===c.parts[3])u=!0;else for(s=3;s>=0;s--){var m=0,b=Me(c);if(c=b.quotient,m=b.rem.low)for(i=8;i>=0;i--)r[9*s+i]=m%10,m=Math.floor(m/10)}if(u)e=1,r[a]=0;else for(e=36;!r[a];)e-=1,a+=1;var w=e-1+g;if(w>=34||w<=-7||g>0){if(e>34)return l.push("".concat(0)),g>0?l.push("E+".concat(g)):g<0&&l.push("E".concat(g)),l.join("");for(l.push("".concat(r[a++])),(e-=1)&&l.push("."),n=0;n<e;n++)l.push("".concat(r[a++]));l.push("E"),w>0?l.push("+".concat(w)):l.push("".concat(w))}else if(g>=0)for(n=0;n<e;n++)l.push("".concat(r[a++]));else{var _=e+g;if(_>0)for(n=0;n<_;n++)l.push("".concat(r[a++]));else l.push("0");for(l.push(".");_++<0;)l.push("0");for(n=0;n<e-Math.max(_-1,0);n++)l.push("".concat(r[a++]))}return l.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(We.prototype,"_bsontype",{value:"Decimal128"});var Fe=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,r){var n=parseFloat(e.$numberDouble);return r&&r.relaxed?n:new t(n)},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(Fe.prototype,"_bsontype",{value:"Double"});var Ve=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,r){return r&&r.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(Ve.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 $e=new RegExp("^[0-9a-fA-F]{24}$"),Ke=null,ze=Symbol("id"),Je=function(){function t(e){if(!(this instanceof t))return new t(e);var r;if("object"==typeof e&&e&&"id"in e){if("string"!=typeof e.id&&!ArrayBuffer.isView(e.id))throw new ne("Argument passed in must have an id that is of type string or Buffer");r="toHexString"in e&&"function"==typeof e.toHexString?Xt.from(e.toHexString(),"hex"):e.id}else r=e;if(null==r||"number"==typeof r)this[ze]=t.generate("number"==typeof r?r:void 0);else if(ArrayBuffer.isView(r)&&12===r.byteLength)this[ze]=r instanceof Xt?r:fe(r);else{if("string"!=typeof r)throw new ne("Argument passed in does not match the accepted types");if(12===r.length){var n=Xt.from(r);if(12!==n.byteLength)throw new ne("Argument passed in must be a string of 12 bytes");this[ze]=n}else{if(24!==r.length||!$e.test(r))throw new ne("Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer");this[ze]=Xt.from(r,"hex")}}t.cacheHexString&&(this.__id=this.id.toString("hex"))}return Object.defineProperty(t.prototype,"id",{get:function(){return this[ze]},set:function(e){this[ze]=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 r=t.getInc(),n=Xt.alloc(12);return n.writeUInt32BE(e,0),null===Ke&&(Ke=ae(5)),n[4]=Ke[0],n[5]=Ke[1],n[6]=Ke[2],n[7]=Ke[3],n[8]=Ke[4],n[11]=255&r,n[10]=r>>8&255,n[9]=r>>16&255,n},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[ze][11]===e[ze][11]&&this[ze].equals(e[ze]);if("string"==typeof e&&t.isValid(e)&&12===e.length&&ue(this.id))return e===Xt.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 Xt.from(e).equals(this.id);if("object"==typeof e&&"toHexString"in e&&"function"==typeof e.toHexString){var r=e.toHexString(),n=this.toHexString().toLowerCase();return"string"==typeof r&&r.toLowerCase()===n}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 r=Xt.from([0,0,0,0,0,0,0,0,0,0,0,0]);return r.writeUInt32BE(e,0),new t(r)},t.createFromHexString=function(e){if(void 0===e||null!=e&&24!==e.length)throw new ne("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");return new t(Xt.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(Je.prototype,"generate",{value:le((function(t){return Je.generate(t)}),"Please use the static `ObjectId.generate(time)` instead")}),Object.defineProperty(Je.prototype,"getInc",{value:le((function(){return Je.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(Je.prototype,"get_inc",{value:le((function(){return Je.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(Je,"get_inc",{value:le((function(){return Je.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(Je.prototype,"_bsontype",{value:"ObjectID"});var Ye=function(){function t(e,r){if(!(this instanceof t))return new t(e,r);if(this.pattern=e,this.options=(null!=r?r:"").split("").sort().join(""),-1!==this.pattern.indexOf("\0"))throw new re("BSON Regex patterns cannot contain null bytes, found: ".concat(JSON.stringify(this.pattern)));if(-1!==this.options.indexOf("\0"))throw new re("BSON Regex options cannot contain null bytes, found: ".concat(JSON.stringify(this.options)));for(var n=0;n<this.options.length;n++)if("i"!==this.options[n]&&"m"!==this.options[n]&&"x"!==this.options[n]&&"l"!==this.options[n]&&"s"!==this.options[n]&&"u"!==this.options[n])throw new re("The regular expression option [".concat(this.options[n],"] 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 ne("Unexpected BSONRegExp EJSON object form: ".concat(JSON.stringify(e)))},t}();Object.defineProperty(Ye.prototype,"_bsontype",{value:"BSONRegExp"});var Qe=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(Qe.prototype,"_bsontype",{value:"Symbol"});var Ze=function(t){function e(r,n){var o=this;return o instanceof e?(o=Ae.isLong(r)?t.call(this,r.low,r.high,!0)||this:ce(r)&&void 0!==r.t&&void 0!==r.i?t.call(this,r.i,r.t,!0)||this:t.call(this,r,n,!0)||this,Object.defineProperty(o,"_bsontype",{value:"Timestamp",writable:!1,configurable:!1,enumerable:!1}),o):new e(r,n)}return ee(e,t),e.prototype.toJSON=function(){return{$timestamp:this.toString()}},e.fromInt=function(t){return new e(Ae.fromInt(t,!0))},e.fromNumber=function(t){return new e(Ae.fromNumber(t,!0))},e.fromBits=function(t,r){return new e(t,r)},e.fromString=function(t,r){return new e(Ae.fromString(t,!0,r))},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=Ae.MAX_UNSIGNED_VALUE,e}(Ae);var Xe=2147483647,tr=-2147483648,er=0x8000000000000000,rr=-0x8000000000000000,nr={$oid:Je,$binary:me,$uuid:me,$symbol:Qe,$numberInt:Ve,$numberDecimal:We,$numberDouble:Fe,$numberLong:Ae,$minKey:Ge,$maxKey:He,$regex:Ye,$regularExpression:Ye,$timestamp:Ze};function or(t,e){if(void 0===e&&(e={}),"number"==typeof t){if(e.relaxed||e.legacy)return t;if(Math.floor(t)===t){if(t>=tr&&t<=Xe)return new Ve(t);if(t>=rr&&t<=er)return Ae.fromNumber(t)}return new Fe(t)}if(null==t||"object"!=typeof t)return t;if(t.$undefined)return null;for(var r=Object.keys(t).filter((function(e){return e.startsWith("$")&&null!=t[e]})),n=0;n<r.length;n++){var o=nr[r[n]];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)):Ae.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=or(t.$scope)),we.fromExtendedJSON(t)}if(function(t){return ce(t)&&null!=t.$id&&"string"==typeof t.$ref&&(null==t.$db||"string"==typeof t.$db)}(t)||t.$dbPointer){var u=t.$ref?t:t.$dbPointer;if(u instanceof _e)return u;var c=Object.keys(u).filter((function(t){return t.startsWith("$")})),l=!0;if(c.forEach((function(t){-1===["$ref","$id","$db"].indexOf(t)&&(l=!1)})),l)return _e.fromExtendedJSON(u)}return t}function ir(t){var e=t.toISOString();return 0!==t.getUTCMilliseconds()?e:e.slice(0,-5)+"Z"}function sr(t,e){if(("object"==typeof t||"function"==typeof t)&&null!==t){var r=e.seenObjects.findIndex((function(e){return e.obj===t}));if(-1!==r){var n=e.seenObjects.map((function(t){return t.propertyName})),o=n.slice(0,r).map((function(t){return"".concat(t," -> ")})).join(""),i=n[r],s=" -> "+n.slice(r+1,n.length-1).map((function(t){return"".concat(t," -> ")})).join(""),a=n[n.length-1],u=" ".repeat(o.length+i.length/2),c="-".repeat(s.length+(i.length+a.length)/2-1);throw new ne("Converting circular structure to EJSON:\n"+" ".concat(o).concat(i).concat(s).concat(a,"\n")+" ".concat(u,"\\").concat(c,"/"))}e.seenObjects[e.seenObjects.length-1].obj=t}if(Array.isArray(t))return function(t,e){return t.map((function(t,r){e.seenObjects.push({propertyName:"index ".concat(r),obj:null});try{return sr(t,e)}finally{e.seenObjects.pop()}}))}(t,e);if(void 0===t)return null;if(t instanceof Date||ce(h=t)&&"[object Date]"===Object.prototype.toString.call(h)){var l=t.getTime(),f=l>-1&&l<2534023188e5;return e.legacy?e.relaxed&&f?{$date:t.getTime()}:{$date:ir(t)}:e.relaxed&&f?{$date:ir(t)}:{$date:{$numberLong:t.getTime().toString()}}}var h;if(!("number"!=typeof t||e.relaxed&&isFinite(t))){if(Math.floor(t)===t){var d=t>=rr&&t<=er;if(t>=tr&&t<=Xe)return{$numberInt:t.toString()};if(d)return{$numberLong:t.toString()}}return{$numberDouble:t.toString()}}if(t instanceof RegExp||function(t){return"[object RegExp]"===Object.prototype.toString.call(t)}(t)){var p=t.flags;if(void 0===p){var y=t.toString().match(/[gimuy]*$/);y&&(p=y[0])}return new Ye(t.source,p).toExtendedJSON(e)}return null!=t&&"object"==typeof t?function(t,e){if(null==t||"object"!=typeof t)throw new re("not an object instance");var r=t._bsontype;if(void 0===r){var n={};for(var o in t){e.seenObjects.push({propertyName:o,obj:null});try{var i=sr(t[o],e);"__proto__"===o?Object.defineProperty(n,o,{value:i,writable:!0,enumerable:!0,configurable:!0}):n[o]=i}finally{e.seenObjects.pop()}}return n}if(function(t){return ce(t)&&Reflect.has(t,"_bsontype")&&"string"==typeof t._bsontype}(t)){var s=t;if("function"!=typeof s.toExtendedJSON){var a=ur[t._bsontype];if(!a)throw new ne("Unrecognized or invalid _bsontype: "+t._bsontype);s=a(s)}return"Code"===r&&s.scope?s=new we(s.code,sr(s.scope,e)):"DBRef"===r&&s.oid&&(s=new _e(sr(s.collection,e),sr(s.oid,e),sr(s.db,e),sr(s.fields,e))),s.toExtendedJSON(e)}throw new re("_bsontype must be a string, but was: "+typeof r)}(t,e):t}var ar,ur={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 _e(t.collection||t.namespace,t.oid,t.db,t.fields)},Decimal128:function(t){return new We(t.bytes)},Double:function(t){return new Fe(t.value)},Int32:function(t){return new Ve(t.value)},Long:function(t){return Ae.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 Je(t)},ObjectId:function(t){return new Je(t)},BSONRegExp:function(t){return new Ye(t.pattern,t.options)},Symbol:function(t){return new Qe(t.value)},Timestamp:function(t){return Ze.fromBits(t.low,t.high)}};!function(t){function e(t,e){var r=Object.assign({},{relaxed:!0,legacy:!1},e);return"boolean"==typeof r.relaxed&&(r.strict=!r.relaxed),"boolean"==typeof r.strict&&(r.relaxed=!r.strict),JSON.parse(t,(function(t,e){if(-1!==t.indexOf("\0"))throw new re("BSON Document field names cannot contain null bytes, found: ".concat(JSON.stringify(t)));return or(e,r)}))}function r(t,e,r,n){null!=r&&"object"==typeof r&&(n=r,r=0),null==e||"object"!=typeof e||Array.isArray(e)||(n=e,e=void 0,r=0);var o=sr(t,Object.assign({relaxed:!0,legacy:!1},n,{seenObjects:[{propertyName:"(root)",obj:null}]}));return JSON.stringify(o,e,r)}t.parse=e,t.stringify=r,t.serialize=function(t,e){return e=e||{},JSON.parse(r(t,e))},t.deserialize=function(t,r){return r=r||{},e(JSON.stringify(t),r)}}(ar||(ar={}));var cr=ie();cr.Map?cr.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 r=t[e],n=r[0],o=r[1];this._keys.push(n),this._values[n]={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 r=t._keys[e++];return{value:void 0!==r?[r,t._values[r].v]:void 0,done:void 0===r}}}},t.prototype.forEach=function(t,e){e=e||this;for(var r=0;r<this._keys.length;r++){var n=this._keys[r];t.call(e,this._values[n].v,n,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 r=t._keys[e++];return{value:void 0!==r?r:void 0,done:void 0===r}}}},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 r=t._keys[e++];return{value:void 0!==r?t._values[r].v:void 0,done:void 0===r}}}},Object.defineProperty(t.prototype,"size",{get:function(){return this._keys.length},enumerable:!1,configurable:!0})}(),Ae.fromNumber(ve),Ae.fromNumber(ge),new Set(["$db","$ref","$id","$clusterTime"]);var lr=new Uint8Array(8);new DataView(lr.buffer,lr.byteOffset,lr.byteLength);Xt.alloc(17825792);var fr=function(){function t(t,e){this._stages=[],t&&e&&(this._db=t,this._request=new jr.reqClass(this._db.config),this._collectionName=e)}return t.prototype.end=function(){return t=this,e=void 0,n=function(){var t;return function(t,e){var r,n,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(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=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(ar.parse)}]:[2,t]}}))},new((r=void 0)||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}));var t,e,r,n},t.prototype.unwrap=function(){return this._stages},t.prototype.done=function(){return this._stages.map((function(t){var e,r=t.stageKey,n=t.stageValue;return(e={})[r]=JSON.parse(n),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}(),hr=fr,dr=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},t(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),pr=function(t){function e(e,r){return t.call(this,e,r)||this}return dr(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 kt(this._db,this._coll,t)},e.prototype.add=function(t,e){return new kt(this._db,this._coll,void 0).create(t,e)},e.prototype.aggregate=function(){return new hr(this._db,this._coll)},e}(Bt),yr={eq:function(t){return new dt(ft.EQ,[t])},neq:function(t){return new dt(ft.NEQ,[t])},lt:function(t){return new dt(ft.LT,[t])},lte:function(t){return new dt(ft.LTE,[t])},gt:function(t){return new dt(ft.GT,[t])},gte:function(t){return new dt(ft.GTE,[t])},in:function(t){return new dt(ft.IN,t)},nin:function(t){return new dt(ft.NIN,t)},all:function(t){return new dt(ft.ALL,t)},elemMatch:function(t){return new dt(ft.ELEM_MATCH,[t])},exists:function(t){return new dt(ft.EXISTS,[t])},size:function(t){return new dt(ft.SIZE,[t])},mod:function(t){return new dt(ft.MOD,[t])},geoNear:function(t){return new dt(ft.GEO_NEAR,[t])},geoWithin:function(t){return new dt(ft.GEO_WITHIN,[t])},geoIntersects:function(t){return new dt(ft.GEO_INTERSECTS,[t])},and:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=B(arguments[0])?arguments[0]:Array.from(arguments);return new ct(st.AND,r)},nor:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=B(arguments[0])?arguments[0]:Array.from(arguments);return new ct(st.NOR,r)},or:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=B(arguments[0])?arguments[0]:Array.from(arguments);return new ct(st.OR,r)},not:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=B(arguments[0])?arguments[0]:Array.from(arguments);return new ct(st.NOT,r)},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=[],r=0;r<arguments.length;r++)e[r]=arguments[r];if(q(e[0])&&e[0].hasOwnProperty("each")){var n=e[0];t={$each:n.each,$position:n.position,$sort:n.sort,$slice:n.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 r=B(arguments[0])?arguments[0]:Array.from(arguments);return new at(tt.UNSHIFT,r)},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 hr},abs:function(t){return new vr("abs",t)},add:function(t){return new vr("add",t)},ceil:function(t){return new vr("ceil",t)},divide:function(t){return new vr("divide",t)},exp:function(t){return new vr("exp",t)},floor:function(t){return new vr("floor",t)},ln:function(t){return new vr("ln",t)},log:function(t){return new vr("log",t)},log10:function(t){return new vr("log10",t)},mod:function(t){return new vr("mod",t)},multiply:function(t){return new vr("multiply",t)},pow:function(t){return new vr("pow",t)},sqrt:function(t){return new vr("sqrt",t)},subtract:function(t){return new vr("subtract",t)},trunc:function(t){return new vr("trunc",t)},arrayElemAt:function(t){return new vr("arrayElemAt",t)},arrayToObject:function(t){return new vr("arrayToObject",t)},concatArrays:function(t){return new vr("concatArrays",t)},filter:function(t){return new vr("filter",t)},in:function(t){return new vr("in",t)},indexOfArray:function(t){return new vr("indexOfArray",t)},isArray:function(t){return new vr("isArray",t)},map:function(t){return new vr("map",t)},range:function(t){return new vr("range",t)},reduce:function(t){return new vr("reduce",t)},reverseArray:function(t){return new vr("reverseArray",t)},size:function(t){return new vr("size",t)},slice:function(t){return new vr("slice",t)},zip:function(t){return new vr("zip",t)},and:function(t){return new vr("and",t)},not:function(t){return new vr("not",t)},or:function(t){return new vr("or",t)},cmp:function(t){return new vr("cmp",t)},eq:function(t){return new vr("eq",t)},gt:function(t){return new vr("gt",t)},gte:function(t){return new vr("gte",t)},lt:function(t){return new vr("lt",t)},lte:function(t){return new vr("lte",t)},neq:function(t){return new vr("ne",t)},cond:function(t){return new vr("cond",t)},ifNull:function(t){return new vr("ifNull",t)},switch:function(t){return new vr("switch",t)},dateFromParts:function(t){return new vr("dateFromParts",t)},dateFromString:function(t){return new vr("dateFromString",t)},dayOfMonth:function(t){return new vr("dayOfMonth",t)},dayOfWeek:function(t){return new vr("dayOfWeek",t)},dayOfYear:function(t){return new vr("dayOfYear",t)},isoDayOfWeek:function(t){return new vr("isoDayOfWeek",t)},isoWeek:function(t){return new vr("isoWeek",t)},isoWeekYear:function(t){return new vr("isoWeekYear",t)},millisecond:function(t){return new vr("millisecond",t)},minute:function(t){return new vr("minute",t)},month:function(t){return new vr("month",t)},second:function(t){return new vr("second",t)},hour:function(t){return new vr("hour",t)},week:function(t){return new vr("week",t)},year:function(t){return new vr("year",t)},literal:function(t){return new vr("literal",t)},mergeObjects:function(t){return new vr("mergeObjects",t)},objectToArray:function(t){return new vr("objectToArray",t)},allElementsTrue:function(t){return new vr("allElementsTrue",t)},anyElementTrue:function(t){return new vr("anyElementTrue",t)},setDifference:function(t){return new vr("setDifference",t)},setEquals:function(t){return new vr("setEquals",t)},setIntersection:function(t){return new vr("setIntersection",t)},setIsSubset:function(t){return new vr("setIsSubset",t)},setUnion:function(t){return new vr("setUnion",t)},concat:function(t){return new vr("concat",t)},dateToString:function(t){return new vr("dateToString",t)},indexOfBytes:function(t){return new vr("indexOfBytes",t)},indexOfCP:function(t){return new vr("indexOfCP",t)},split:function(t){return new vr("split",t)},strLenBytes:function(t){return new vr("strLenBytes",t)},strLenCP:function(t){return new vr("strLenCP",t)},strcasecmp:function(t){return new vr("strcasecmp",t)},substr:function(t){return new vr("substr",t)},substrBytes:function(t){return new vr("substrBytes",t)},substrCP:function(t){return new vr("substrCP",t)},toLower:function(t){return new vr("toLower",t)},toUpper:function(t){return new vr("toUpper",t)},meta:function(t){return new vr("meta",t)},addToSet:function(t){return new vr("addToSet",t)},avg:function(t){return new vr("avg",t)},first:function(t){return new vr("first",t)},last:function(t){return new vr("last",t)},max:function(t){return new vr("max",t)},min:function(t){return new vr("min",t)},push:function(t){return new vr("push",t)},stdDevPop:function(t){return new vr("stdDevPop",t)},stdDevSamp:function(t){return new vr("stdDevSamp",t)},sum:function(t){return new vr("sum",t)},let:function(t){return new vr("let",t)}},project:{slice:function(t){return new gr("slice",t)},elemMatch:function(t){return new gr("elemMatch",t)}}},vr=function(t,e){this["$"+t]=e},gr=function(t,e){this["$"+t]=e},mr=function(){function t(t){var e=t.regexp,r=t.options;if(!e)throw new TypeError("regexp must be a string");this.$regex=e,this.$options=r}return t.prototype.parse=function(){return{$regex:this.$regex,$options:this.$options}},Object.defineProperty(t.prototype,"_internalType",{get:function(){return k},enumerable:!0,configurable:!0}),t}();function br(t){return new mr(t)}var wr="insert document failed",_r="DATABASE_TRANSACTION_CONFLICT",Sr=function(){return Sr=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Sr.apply(this,arguments)},Er=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},Ir=function(t,e){var r,n,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(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},Or="database.updateDocInTransaction",Tr=function(){function t(t,e,r){this._coll=e,this.id=r,this._transaction=t,this._request=this._transaction.getRequestMethod(),this._transactionId=this._transaction.getTransactionId()}return t.prototype.create=function(t){return Er(this,void 0,void 0,(function(){var e,r,n,o;return Ir(this,(function(i){switch(i.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,data:ar.stringify(St(t),{relaxed:!1})},this.id&&(e._id=this.id),[4,this._request.send("database.insertDocInTransaction",e)];case 1:if((r=i.sent()).code)throw r;if(n=ar.parse(r.inserted),1==(o=ar.parse(r.ok))&&1==n)return[2,Sr(Sr({},r),{ok:o,inserted:n})];throw new Error(wr)}}))}))},t.prototype.get=function(){return Er(this,void 0,void 0,(function(){var t,e;return Ir(this,(function(r){switch(r.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=r.sent()).code)throw e;return[2,{data:"null"!==e.data?rt.formatField(ar.parse(e.data)):ar.parse(e.data),requestId:e.requestId}]}}))}))},t.prototype.set=function(t){return Er(this,void 0,void 0,(function(){var e,r;return Ir(this,(function(n){switch(n.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:ar.stringify(St(t),{relaxed:!1}),upsert:!0},[4,this._request.send(Or,e)];case 1:if((r=n.sent()).code)throw r;return[2,Sr(Sr({},r),{updated:ar.parse(r.updated),upserted:r.upserted?JSON.parse(r.upserted):null})]}}))}))},t.prototype.update=function(t){return Er(this,void 0,void 0,(function(){var e,r;return Ir(this,(function(n){switch(n.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:ar.stringify(Nt.encode(t),{relaxed:!1})},[4,this._request.send(Or,e)];case 1:if((r=n.sent()).code)throw r;return[2,Sr(Sr({},r),{updated:ar.parse(r.updated)})]}}))}))},t.prototype.delete=function(){return Er(this,void 0,void 0,(function(){var t,e;return Ir(this,(function(r){switch(r.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=r.sent()).code)throw e;return[2,Sr(Sr({},e),{deleted:ar.parse(e.deleted)})]}}))}))},t}(),Rr=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},t(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),Ar=function(t){function e(e,r){return t.call(this,e,r)||this}return Rr(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 Tr(this._transaction,this._coll,t)},e.prototype.add=function(t){var e;return void 0!==t._id&&(e=t._id),new Tr(this._transaction,this._coll,e).create(t)},e}((function(t,e){this._coll=e,this._transaction=t})),Pr=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},xr=function(t,e){var r,n,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(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},Cr=function(){function t(t){this._db=t,this._request=new jr.reqClass(this._db.config),this.aborted=!1,this.commited=!1,this.inited=!1}return t.prototype.init=function(){return Pr(this,void 0,void 0,(function(){var t;return xr(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 Ar(this,t)},t.prototype.getTransactionId=function(){return this._id},t.prototype.getRequestMethod=function(){return this._request},t.prototype.commit=function(){return Pr(this,void 0,void 0,(function(){var t,e;return xr(this,(function(r){switch(r.label){case 0:return t={transactionId:this._id},[4,this._request.send("database.commitTransaction",t)];case 1:if((e=r.sent()).code)throw e;return this.commited=!0,[2,e]}}))}))},t.prototype.rollback=function(t){return Pr(this,void 0,void 0,(function(){var e,r;return xr(this,(function(n){switch(n.label){case 0:return e={transactionId:this._id},[4,this._request.send("database.abortTransaction",e)];case 1:if((r=n.sent()).code)throw r;return this.aborted=!0,this.abortReason=t,[2,r]}}))}))},t}();function Nr(){return Pr(this,void 0,void 0,(function(){var t;return xr(this,(function(e){switch(e.label){case 0:return[4,(t=new Cr(this)).init()];case 1:return e.sent(),[2,t]}}))}))}function Lr(t,e){return void 0===e&&(e=3),Pr(this,void 0,void 0,(function(){var r,n,o,i,s=this;return xr(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,10]),[4,(r=new Cr(this)).init()];case 1:return a.sent(),[4,t(r)];case 2:if(n=a.sent(),!0===r.aborted)throw r.abortReason;return[4,r.commit()];case 3:return a.sent(),[2,n];case 4:if(o=a.sent(),!1===r.inited)throw o;return i=function(t){return Pr(s,void 0,void 0,(function(){return xr(this,(function(e){switch(e.label){case 0:if(r.aborted||r.commited)return[3,5];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,r.rollback()];case 2:case 3:return e.sent(),[3,4];case 4:throw t;case 5:if(!0===r.aborted)throw r.abortReason;throw t}}))}))},e<=0?[4,i(o)]:[3,6];case 5:a.sent(),a.label=6;case 6:return o&&o.code===_r?[4,Lr.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 jr=function(){function t(t){this.config=t,this.Geo=i,this.serverDate=X,this.command=yr,this.RegExp=br,this.startTransaction=Nr,this.runTransaction=Lr,this.logicCommand=ct,this.updateCommand=at,this.queryCommand=dt}return t.prototype.collection=function(t){if(!t)throw new Error("Collection name is required");return new pr(this,t)},t.prototype.createCollection=function(e){var r={collectionName:e};return new t.reqClass(this.config).send("database.addCollection",r)},t}(),Ur=function(){return Ur=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Ur.apply(this,arguments)},kr={name:"database",entity:{database:function(t){var e=this.platform,r=e.adapter,n=e.runtime;return jr.reqClass=this.request.constructor,jr.getAccessToken=this.authInstance?this.authInstance.getAccessToken.bind(this.authInstance):function(){return""},jr.runtime=n,this.wsClientClass&&(jr.wsClass=r.wsClass,jr.wsClientClass=this.wsClientClass),jr.ws||(jr.ws=null),new jr(Ur(Ur(Ur({},this.config),{_fromApp:this}),t))}}};try{cloudbase.registerComponent(kr)}catch(t){}function Dr(t){try{t.registerComponent(kr)}catch(t){console.warn(t)}}},7596:function(t,e,r){"use strict";r.r(e),r.d(e,{registerCloudrun:function(){return h},requestContainer:function(){return c}});var n=r(3616),o=function(){return o=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},o.apply(this,arguments)},i=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},s=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},a=n._G.Sg,u="cloudrun";function c(t){return i(this,void 0,void 0,(function(){var e,r,n,o,i,a,u,c,l;return s(this,(function(s){switch(s.label){case 0:return e=t.name,r=t.data,n=t.path,o=void 0===n?"":n,i=t.method,a=t.header,u=void 0===a?{}:a,c="https://".concat(this.config.env,".api.tcloudbasegateway.com/v1/cloudrun/").concat(e),l=o.startsWith("/")?o:"/".concat(o),[4,this.request.fetch({method:i||"POST",headers:Object.assign({},{"Content-Type":"application/json; charset=utf-8"},u),body:r,url:"".concat(c).concat(l)})];case 1:return[4,s.sent().data];case 2:return[2,s.sent()]}}))}))}var l=new(function(){function t(){}return t.prototype.callContainer=function(t){return i(this,void 0,void 0,(function(){var e,r,n;return s(this,(function(i){switch(i.label){case 0:if(e=t.name,r=t.data,!e)throw new Error(JSON.stringify({code:a.INVALID_PARAMS,msg:"[".concat(u,".callContainer] invalid name")}));try{n=r?JSON.stringify(r):""}catch(t){throw new Error(JSON.stringify({code:a.INVALID_PARAMS,msg:"[".concat(u,".callContainer] invalid data")}))}return[4,c.call(this,o(o({},t),{data:n}))];case 1:return[2,i.sent()]}}))}))},t}()),f={name:u,entity:{callContainer:l.callContainer}};try{cloudbase.registerComponent(f)}catch(t){}function h(t){try{t.registerComponent(f)}catch(t){console.warn(t)}}},2363:function(t,e,r){"use strict";r.r(e),r.d(e,{registerFunctions:function(){return y}});var n=r(3616),o=r(7596),i=function(){return i=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},i.apply(this,arguments)},s=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},a=n._G.eX,u=n._G.Sg,c=n._G.vM,l=n.P6.execCallback,f=n.BM.D,h="functions",d=new(function(){function t(){}return t.prototype.callFunction=function(t,e){var r,s,c,f,d,p;return c=this,f=void 0,p=function(){var c,f,d,p,y,v,g,m,b,w,_,S,E,I,O,T,R,A,P;return function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}(this,(function(x){switch(x.label){case 0:if(c=t.name,f=t.data,d=t.query,p=t.parse,y=t.search,v=t.type,g=t.path,m=void 0===g?"":g,b=t.method,w=t.header,_=void 0===w?{}:w,!c)throw new Error(JSON.stringify({code:u.INVALID_PARAMS,msg:"[".concat(h,".callFunction] invalid function name")}));try{S=f?JSON.stringify(f):""}catch(t){throw new Error(JSON.stringify({code:u.INVALID_PARAMS,msg:"[".concat(h,".callFunction] invalid data")}))}return"cloudrun"!==v?[3,2]:(E=n.P6.generateRequestId(),[4,o.requestContainer.call(this,{name:c,data:S,path:m,method:b,header:i(i({},_),{"X-Request-Id":E})})]);case 1:return[2,{result:A=x.sent(),requestId:E}];case 2:I="functions.invokeFunction",O={inQuery:d,parse:p,search:y,function_name:c,request_data:S},T=this.request,x.label=3;case 3:return x.trys.push([3,5,,6]),[4,T.send(I,O,{defaultQuery:(null===(r=null==f?void 0:f.params)||void 0===r?void 0:r.action)?{action:null===(s=null==f?void 0:f.params)||void 0===s?void 0:s.action}:{}})];case 4:if((R=x.sent()).code)return[2,l(e,null,R)];if(A=R.data.response_data,p)return[2,l(e,null,{result:A,requestId:R.requestId})];try{return A=JSON.parse(R.data.response_data),[2,l(e,null,{result:A,requestId:R.requestId})]}catch(t){l(e,new Error("[".concat(a(),"][").concat(u.INVALID_PARAMS,"][").concat(h,".callFunction] response data must be json")))}return[3,6];case 5:return P=x.sent(),l(e,P),[3,6];case 6:return[2]}}))},new((d=void 0)||(d=Promise))((function(t,e){function r(t){try{o(p.next(t))}catch(t){e(t)}}function n(t){try{o(p.throw(t))}catch(t){e(t)}}function o(e){var o;e.done?t(e.value):(o=e.value,o instanceof d?o:new d((function(t){t(o)}))).then(r,n)}o((p=p.apply(c,f||[])).next())}))},function(t,e,r,n){var o,i=arguments.length,s=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);i>3&&s&&Object.defineProperty(e,r,s)}([f({customInfo:{className:"Cloudbase",methodName:"callFunction"},title:"函数调用失败",messages:["请确认以下各项:"," 1 - 调用 callFunction() 的语法或参数是否正确"," 2 - 当前环境下是否存在此函数"," 3 - 函数安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(c)]}),s("design:type",Function),s("design:paramtypes",[Object,Function]),s("design:returntype",Promise)],t.prototype,"callFunction",null),t}()),p={name:h,entity:{callFunction:d.callFunction}};try{cloudbase.registerComponent(p)}catch(t){}function y(t){try{t.registerComponent(p)}catch(t){console.warn(t)}}},9679:function(t,e,r){"use strict";r.r(e),r.d(e,{lazyGetEntity:function(){return d},registerModel:function(){return g}});var n=r(5304),o=r(3616),i={};for(var s in n)["default","lazyGetEntity","registerModel"].indexOf(s)<0&&(i[s]=function(t){return n[t]}.bind(0,s));r.d(e,i);var a=function(){return a=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},a.apply(this,arguments)},u=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},c=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},l=o.U3.yE,f="models",h=new WeakMap;function d(t){return new Proxy({},{get:function(e,r){var o=h.get(t);return o||(o=function(t){var e=this,r=t.callFunction.bind(t),o=t.request.fetch.bind(t.request),i=t.getEndPointWithKey("GATEWAY"),s=i.BASE_URL,l=i.PROTOCOL,f="".concat(l).concat(s,"/model"),h="".concat(l).concat(s,"/sql"),d=(0,n.generateHTTPClient)(r,(function(t){return u(e,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,o(a(a({},t),{headers:a({"Content-Type":"application/json"},t.headers)}))];case 1:return[4,e.sent().data];case 2:return[2,e.sent()]}}))}))}),f,{sqlBaseUrl:h});return d}(t),h.set(t,o)),o[r]}})}var p="cloudbase_init",y=new l;y.on(p,(function(t){var e=t.data;Object.assign(e,{models:d(e)})}));var v={name:f,namespace:f,entity:new Proxy({},{get:function(t,e){console.warn("【deprecated】Accessing Cloudbase.prototype.models.".concat(e,"."))}}),injectEvents:{bus:y,events:[p]}};try{cloudbase.registerComponent(v)}catch(t){}function g(t){try{t.registerComponent(v)}catch(t){console.warn(t)}}},7171:function(t,e,r){"use strict";var n;if(r.r(e),r.d(e,{getEncryptInfo:function(){return M}}),!globalThis.IS_MP_BUILD){var o="undefined"!=typeof globalThis?globalThis.navigator:window.globalThis,i="0123456789abcdefghijklmnopqrstuvwxyz";function B(t){return i.charAt(t)}function W(t,e){return t&e}function F(t,e){return t|e}function V(t,e){return t^e}function H(t,e){return t&~e}function G(t){if(0==t)return-1;var e=0;return 65535&t||(t>>=16,e+=16),255&t||(t>>=8,e+=8),15&t||(t>>=4,e+=4),3&t||(t>>=2,e+=2),1&t||++e,e}function $(t){for(var e=0;0!=t;)t&=t-1,++e;return e}var s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function K(t){var e,r,n="";for(e=0;e+3<=t.length;e+=3)r=parseInt(t.substring(e,e+3),16),n+=s.charAt(r>>6)+s.charAt(63&r);for(e+1==t.length?(r=parseInt(t.substring(e,e+1),16),n+=s.charAt(r<<2)):e+2==t.length&&(r=parseInt(t.substring(e,e+2),16),n+=s.charAt(r>>2)+s.charAt((3&r)<<4));(3&n.length)>0;)n+="=";return n}function z(t){var e,r="",n=0,o=0;for(e=0;e<t.length&&"="!=t.charAt(e);++e){var i=s.indexOf(t.charAt(e));i<0||(0==n?(r+=B(i>>2),o=3&i,n=1):1==n?(r+=B(o<<2|i>>4),o=15&i,n=2):2==n?(r+=B(o),r+=B(i>>2),o=3&i,n=3):(r+=B(o<<2|i>>4),r+=B(15&i),n=0))}return 1==n&&(r+=B(o<<2)),r}var a,u,c={decode:function(t){var e;if(void 0===a){var r="0123456789ABCDEF";for(a={},e=0;e<16;++e)a[r.charAt(e)]=e;for(r=r.toLowerCase(),e=10;e<16;++e)a[r.charAt(e)]=e;for(e=0;e<8;++e)a[" \f\n\r\t \u2028\u2029".charAt(e)]=-1}var n=[],o=0,i=0;for(e=0;e<t.length;++e){var s=t.charAt(e);if("="==s)break;if(-1!=(s=a[s])){if(void 0===s)throw new Error("Illegal character at offset "+e);o|=s,++i>=2?(n[n.length]=o,o=0,i=0):o<<=4}}if(i)throw new Error("Hex encoding incomplete: 4 bits missing");return n}},l={decode:function(t){var e;if(void 0===u){for(u=Object.create(null),e=0;e<64;++e)u["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e)]=e;for(e=0;e<9;++e)u["= \f\n\r\t \u2028\u2029".charAt(e)]=-1}var r=[],n=0,o=0;for(e=0;e<t.length;++e){var i=t.charAt(e);if("="==i)break;if(-1!=(i=u[i])){if(void 0===i)throw new Error("Illegal character at offset "+e);n|=i,++o>=4?(r[r.length]=n>>16,r[r.length]=n>>8&255,r[r.length]=255&n,n=0,o=0):n<<=6}}switch(o){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:r[r.length]=n>>10;break;case 3:r[r.length]=n>>16,r[r.length]=n>>8&255}return r},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(t){var e=l.re.exec(t);if(e)if(e[1])t=e[1];else{if(!e[2])throw new Error("RegExp out of sync");t=e[2]}return l.decode(t)}},f=1e13;class J{constructor(t){this.buf=[+t||0]}mulAdd(t,e){var r,n,o=this.buf,i=o.length;for(r=0;r<i;++r)(n=o[r]*t+e)<f?e=0:n-=(e=0|n/f)*f,o[r]=n;e>0&&(o[r]=e)}sub(t){var e,r,n=this.buf,o=n.length;for(e=0;e<o;++e)(r=n[e]-t)<0?(r+=f,t=1):t=0,n[e]=r;for(;0===n[n.length-1];)n.pop()}toString(t){if(10!=(t||10))throw new Error("only base 10 is supported");for(var e=this.buf,r=e[e.length-1].toString(),n=e.length-2;n>=0;--n)r+=(f+e[n]).toString().substring(1);return r}valueOf(){for(var t=this.buf,e=0,r=t.length-1;r>=0;--r)e=e*f+t[r];return e}simplify(){var t=this.buf;return 1==t.length?t[0]:this}}var h,d=/^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/,p=/^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;function Y(t,e){return t.length>e&&(t=t.substring(0,e)+"…"),t}class Q{constructor(t,e){this.hexDigits="0123456789ABCDEF",t instanceof Q?(this.enc=t.enc,this.pos=t.pos):(this.enc=t,this.pos=e)}get(t){if(void 0===t&&(t=this.pos++),t>=this.enc.length)throw new Error("Requesting byte offset "+t+" on a stream of length "+this.enc.length);return"string"==typeof this.enc?this.enc.charCodeAt(t):this.enc[t]}hexByte(t){return this.hexDigits.charAt(t>>4&15)+this.hexDigits.charAt(15&t)}hexDump(t,e,r){for(var n="",o=t;o<e;++o)if(n+=this.hexByte(this.get(o)),!0!==r)switch(15&o){case 7:n+=" ";break;case 15:n+="\n";break;default:n+=" "}return n}isASCII(t,e){for(var r=t;r<e;++r){var n=this.get(r);if(n<32||n>176)return!1}return!0}parseStringISO(t,e){for(var r="",n=t;n<e;++n)r+=String.fromCharCode(this.get(n));return r}parseStringUTF(t,e){for(var r="",n=t;n<e;){var o=this.get(n++);r+=o<128?String.fromCharCode(o):o>191&&o<224?String.fromCharCode((31&o)<<6|63&this.get(n++)):String.fromCharCode((15&o)<<12|(63&this.get(n++))<<6|63&this.get(n++))}return r}parseStringBMP(t,e){for(var r,n,o="",i=t;i<e;)r=this.get(i++),n=this.get(i++),o+=String.fromCharCode(r<<8|n);return o}parseTime(t,e,r){var n=this.parseStringISO(t,e),o=(r?d:p).exec(n);return o?(r&&(o[1]=+o[1],o[1]+=+o[1]<70?2e3:1900),n=o[1]+"-"+o[2]+"-"+o[3]+" "+o[4],o[5]&&(n+=":"+o[5],o[6]&&(n+=":"+o[6],o[7]&&(n+="."+o[7]))),o[8]&&(n+=" UTC","Z"!=o[8]&&(n+=o[8],o[9]&&(n+=":"+o[9]))),n):"Unrecognized time: "+n}parseInteger(t,e){for(var r,n=this.get(t),o=n>127,i=o?255:0,s="";n==i&&++t<e;)n=this.get(t);if(0==(r=e-t))return o?-1:0;if(r>4){for(s=n,r<<=3;!(128&(+s^i));)s=+s<<1,--r;s="("+r+" bit)\n"}o&&(n-=256);for(var a=new J(n),u=t+1;u<e;++u)a.mulAdd(256,this.get(u));return s+a.toString()}parseBitString(t,e,r){for(var n=this.get(t),o="("+((e-t-1<<3)-n)+" bit)\n",i="",s=t+1;s<e;++s){for(var a=this.get(s),u=s==e-1?n:0,c=7;c>=u;--c)i+=a>>c&1?"1":"0";if(i.length>r)return o+Y(i,r)}return o+i}parseOctetString(t,e,r){if(this.isASCII(t,e))return Y(this.parseStringISO(t,e),r);var n=e-t,o="("+n+" byte)\n";n>(r/=2)&&(e=t+r);for(var i=t;i<e;++i)o+=this.hexByte(this.get(i));return n>r&&(o+="…"),o}parseOID(t,e,r){for(var n="",o=new J,i=0,s=t;s<e;++s){var a=this.get(s);if(o.mulAdd(128,127&a),i+=7,!(128&a)){if(""===n)if((o=o.simplify())instanceof J)o.sub(80),n="2."+o.toString();else{var u=o<80?o<40?0:1:2;n=u+"."+(o-40*u)}else n+="."+o.toString();if(n.length>r)return Y(n,r);o=new J,i=0}}return i>0&&(n+=".incomplete"),n}}class Z{constructor(t,e,r,n,o){if(!(n instanceof X))throw new Error("Invalid tag value.");this.stream=t,this.header=e,this.length=r,this.tag=n,this.sub=o}typeName(){switch(this.tag.tagClass){case 0:switch(this.tag.tagNumber){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER";case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString";case 30:return"BMPString"}return"Universal_"+this.tag.tagNumber.toString();case 1:return"Application_"+this.tag.tagNumber.toString();case 2:return"["+this.tag.tagNumber.toString()+"]";case 3:return"Private_"+this.tag.tagNumber.toString()}}content(t){if(void 0===this.tag)return null;void 0===t&&(t=1/0);var e=this.posContent(),r=Math.abs(this.length);if(!this.tag.isUniversal())return null!==this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+r,t);switch(this.tag.tagNumber){case 1:return 0===this.stream.get(e)?"false":"true";case 2:return this.stream.parseInteger(e,e+r);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(e,e+r,t);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+r,t);case 6:return this.stream.parseOID(e,e+r,t);case 16:case 17:return null!==this.sub?"("+this.sub.length+" elem)":"(no elem)";case 12:return Y(this.stream.parseStringUTF(e,e+r),t);case 18:case 19:case 20:case 21:case 22:case 26:return Y(this.stream.parseStringISO(e,e+r),t);case 30:return Y(this.stream.parseStringBMP(e,e+r),t);case 23:case 24:return this.stream.parseTime(e,e+r,23==this.tag.tagNumber)}return null}toString(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(null===this.sub?"null":this.sub.length)+"]"}toPrettyString(t){void 0===t&&(t="");var e=t+this.typeName()+" @"+this.stream.pos;if(this.length>=0&&(e+="+"),e+=this.length,this.tag.tagConstructed?e+=" (constructed)":!this.tag.isUniversal()||3!=this.tag.tagNumber&&4!=this.tag.tagNumber||null===this.sub||(e+=" (encapsulates)"),e+="\n",null!==this.sub){t+=" ";for(var r=0,n=this.sub.length;r<n;++r)e+=this.sub[r].toPrettyString(t)}return e}posStart(){return this.stream.pos}posContent(){return this.stream.pos+this.header}posEnd(){return this.stream.pos+this.header+Math.abs(this.length)}toHexString(){return this.stream.hexDump(this.posStart(),this.posEnd(),!0)}static decodeLength(t){var e=t.get(),r=127&e;if(r==e)return r;if(r>6)throw new Error("Length over 48 bits not supported at position "+(t.pos-1));if(0===r)return null;e=0;for(var n=0;n<r;++n)e=256*e+t.get();return e}getHexStringValue(){var t=this.toHexString(),e=2*this.header,r=2*this.length;return t.substr(e,r)}static decode(t){var e;e=t instanceof Q?t:new Q(t,0);var r=new Q(e),n=new X(e),o=Z.decodeLength(e),i=e.pos,s=i-r.pos,a=null,u=function(){var t=[];if(null!==o){for(var r=i+o;e.pos<r;)t[t.length]=Z.decode(e);if(e.pos!=r)throw new Error("Content size is not correct for container starting at offset "+i)}else try{for(;;){var n=Z.decode(e);if(n.tag.isEOC())break;t[t.length]=n}o=i-e.pos}catch(t){throw new Error("Exception while decoding undefined length content: "+t)}return t};if(n.tagConstructed)a=u();else if(n.isUniversal()&&(3==n.tagNumber||4==n.tagNumber))try{if(3==n.tagNumber&&0!=e.get())throw new Error("BIT STRINGs with unused bits cannot encapsulate.");a=u();for(var c=0;c<a.length;++c)if(a[c].tag.isEOC())throw new Error("EOC is not supposed to be actual content.")}catch(t){a=null}if(null===a){if(null===o)throw new Error("We can't skip over an invalid tag with undefined length at offset "+i);e.pos=i+Math.abs(o)}return new Z(r,s,o,n,a)}}class X{constructor(t){var e=t.get();if(this.tagClass=e>>6,this.tagConstructed=!!(32&e),this.tagNumber=31&e,31==this.tagNumber){var r=new J;do{e=t.get(),r.mulAdd(128,127&e)}while(128&e);this.tagNumber=r.simplify()}}isUniversal(){return 0===this.tagClass}isEOC(){return 0===this.tagClass&&0===this.tagNumber}}var y=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],v=(1<<26)/y[y.length-1];class tt{constructor(t,e,r){null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}toString(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,n=(1<<e)-1,o=!1,i="",s=this.t,a=this.DB-s*this.DB%e;if(s-- >0)for(a<this.DB&&(r=this[s]>>a)>0&&(o=!0,i=B(r));s>=0;)a<e?(r=(this[s]&(1<<a)-1)<<e-a,r|=this[--s]>>(a+=this.DB-e)):(r=this[s]>>(a-=e)&n,a<=0&&(a+=this.DB,--s)),r>0&&(o=!0),o&&(i+=B(r));return o?i:"0"}negate(){var t=et();return tt.ZERO.subTo(this,t),t}abs(){return this.s<0?this.negate():this}compareTo(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0}bitLength(){return this.t<=0?0:this.DB*(this.t-1)+ut(this[this.t-1]^this.s&this.DM)}mod(t){var e=et();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(tt.ZERO)>0&&t.subTo(e,e),e}modPowInt(t,e){var r;return r=t<256||e.isEven()?new m(e):new b(e),this.exp(t,r)}clone(){var t=et();return this.copyTo(t),t}intValue(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]}byteValue(){return 0==this.t?this.s:this[0]<<24>>24}shortValue(){return 0==this.t?this.s:this[0]<<16>>16}signum(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1}toByteArray(){var t=this.t,e=[];e[0]=this.s;var r,n=this.DB-t*this.DB%8,o=0;if(t-- >0)for(n<this.DB&&(r=this[t]>>n)!=(this.s&this.DM)>>n&&(e[o++]=r|this.s<<this.DB-n);t>=0;)n<8?(r=(this[t]&(1<<n)-1)<<8-n,r|=this[--t]>>(n+=this.DB-8)):(r=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),128&r&&(r|=-256),0==o&&(128&this.s)!=(128&r)&&++o,(o>0||r!=this.s)&&(e[o++]=r);return e}equals(t){return 0==this.compareTo(t)}min(t){return this.compareTo(t)<0?this:t}max(t){return this.compareTo(t)>0?this:t}and(t){var e=et();return this.bitwiseTo(t,W,e),e}or(t){var e=et();return this.bitwiseTo(t,F,e),e}xor(t){var e=et();return this.bitwiseTo(t,V,e),e}andNot(t){var e=et();return this.bitwiseTo(t,H,e),e}not(){for(var t=et(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t}shiftLeft(t){var e=et();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e}shiftRight(t){var e=et();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e}getLowestSetBit(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+G(this[t]);return this.s<0?this.t*this.DB:-1}bitCount(){for(var t=0,e=this.s&this.DM,r=0;r<this.t;++r)t+=$(this[r]^e);return t}testBit(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:!!(this[e]&1<<t%this.DB)}setBit(t){return this.changeBit(t,F)}clearBit(t){return this.changeBit(t,H)}flipBit(t){return this.changeBit(t,V)}add(t){var e=et();return this.addTo(t,e),e}subtract(t){var e=et();return this.subTo(t,e),e}multiply(t){var e=et();return this.multiplyTo(t,e),e}divide(t){var e=et();return this.divRemTo(t,e,null),e}remainder(t){var e=et();return this.divRemTo(t,null,e),e}divideAndRemainder(t){var e=et(),r=et();return this.divRemTo(t,e,r),[e,r]}modPow(t,e){var r,n,o=t.bitLength(),i=at(1);if(o<=0)return i;r=o<18?1:o<48?3:o<144?4:o<768?5:6,n=o<8?new m(e):e.isEven()?new w(e):new b(e);var s=[],a=3,u=r-1,c=(1<<r)-1;if(s[1]=n.convert(this),r>1){var l=et();for(n.sqrTo(s[1],l);a<=c;)s[a]=et(),n.mulTo(l,s[a-2],s[a]),a+=2}var f,h,d=t.t-1,p=!0,y=et();for(o=ut(t[d])-1;d>=0;){for(o>=u?f=t[d]>>o-u&c:(f=(t[d]&(1<<o+1)-1)<<u-o,d>0&&(f|=t[d-1]>>this.DB+o-u)),a=r;!(1&f);)f>>=1,--a;if((o-=a)<0&&(o+=this.DB,--d),p)s[f].copyTo(i),p=!1;else{for(;a>1;)n.sqrTo(i,y),n.sqrTo(y,i),a-=2;a>0?n.sqrTo(i,y):(h=i,i=y,y=h),n.mulTo(y,s[f],i)}for(;d>=0&&!(t[d]&1<<o);)n.sqrTo(i,y),h=i,i=y,y=h,--o<0&&(o=this.DB-1,--d)}return n.revert(i)}modInverse(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return tt.ZERO;for(var r=t.clone(),n=this.clone(),o=at(1),i=at(0),s=at(0),a=at(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),e?(o.isEven()&&i.isEven()||(o.addTo(this,o),i.subTo(t,i)),o.rShiftTo(1,o)):i.isEven()||i.subTo(t,i),i.rShiftTo(1,i);for(;n.isEven();)n.rShiftTo(1,n),e?(s.isEven()&&a.isEven()||(s.addTo(this,s),a.subTo(t,a)),s.rShiftTo(1,s)):a.isEven()||a.subTo(t,a),a.rShiftTo(1,a);r.compareTo(n)>=0?(r.subTo(n,r),e&&o.subTo(s,o),i.subTo(a,i)):(n.subTo(r,n),e&&s.subTo(o,s),a.subTo(i,a))}return 0!=n.compareTo(tt.ONE)?tt.ZERO:a.compareTo(t)>=0?a.subtract(t):a.signum()<0?(a.addTo(t,a),a.signum()<0?a.add(t):a):a}pow(t){return this.exp(t,new g)}gcd(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var o=e.getLowestSetBit(),i=r.getLowestSetBit();if(i<0)return e;for(o<i&&(i=o),i>0&&(e.rShiftTo(i,e),r.rShiftTo(i,r));e.signum()>0;)(o=e.getLowestSetBit())>0&&e.rShiftTo(o,e),(o=r.getLowestSetBit())>0&&r.rShiftTo(o,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return i>0&&r.lShiftTo(i,r),r}isProbablePrime(t){var e,r=this.abs();if(1==r.t&&r[0]<=y[y.length-1]){for(e=0;e<y.length;++e)if(r[0]==y[e])return!0;return!1}if(r.isEven())return!1;for(e=1;e<y.length;){for(var n=y[e],o=e+1;o<y.length&&n<v;)n*=y[o++];for(n=r.modInt(n);e<o;)if(n%y[e++]==0)return!1}return r.millerRabin(t)}copyTo(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s}fromInt(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0}fromString(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var n=t.length,o=!1,i=0;--n>=0;){var s=8==r?255&+t[n]:st(t,n);s<0?"-"==t.charAt(n)&&(o=!0):(o=!1,0==i?this[this.t++]=s:i+r>this.DB?(this[this.t-1]|=(s&(1<<this.DB-i)-1)<<i,this[this.t++]=s>>this.DB-i):this[this.t-1]|=s<<i,(i+=r)>=this.DB&&(i-=this.DB))}8==r&&128&+t[0]&&(this.s=-1,i>0&&(this[this.t-1]|=(1<<this.DB-i)-1<<i)),this.clamp(),o&&tt.ZERO.subTo(this,this)}clamp(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t}dlShiftTo(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s}drShiftTo(t,e){for(var r=t;r<this.t;++r)e[r-t]=this[r];e.t=Math.max(this.t-t,0),e.s=this.s}lShiftTo(t,e){for(var r=t%this.DB,n=this.DB-r,o=(1<<n)-1,i=Math.floor(t/this.DB),s=this.s<<r&this.DM,a=this.t-1;a>=0;--a)e[a+i+1]=this[a]>>n|s,s=(this[a]&o)<<r;for(a=i-1;a>=0;--a)e[a]=0;e[i]=s,e.t=this.t+i+1,e.s=this.s,e.clamp()}rShiftTo(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var n=t%this.DB,o=this.DB-n,i=(1<<n)-1;e[0]=this[r]>>n;for(var s=r+1;s<this.t;++s)e[s-r-1]|=(this[s]&i)<<o,e[s-r]=this[s]>>n;n>0&&(e[this.t-r-1]|=(this.s&i)<<o),e.t=this.t-r,e.clamp()}}subTo(t,e){for(var r=0,n=0,o=Math.min(t.t,this.t);r<o;)n+=this[r]-t[r],e[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n-=t.s;r<this.t;)n+=this[r],e[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n-=t[r],e[r++]=n&this.DM,n>>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[r++]=this.DV+n:n>0&&(e[r++]=n),e.t=r,e.clamp()}multiplyTo(t,e){var r=this.abs(),n=t.abs(),o=r.t;for(e.t=o+n.t;--o>=0;)e[o]=0;for(o=0;o<n.t;++o)e[o+r.t]=r.am(0,n[o],e,o,0,r.t);e.s=0,e.clamp(),this.s!=t.s&&tt.ZERO.subTo(e,e)}squareTo(t){for(var e=this.abs(),r=t.t=2*e.t;--r>=0;)t[r]=0;for(r=0;r<e.t-1;++r){var n=e.am(r,e[r],t,2*r,0,1);(t[r+e.t]+=e.am(r+1,2*e[r],t,2*r+1,n,e.t-r-1))>=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()}divRemTo(t,e,r){var n=t.abs();if(!(n.t<=0)){var o=this.abs();if(o.t<n.t)return null!=e&&e.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=et());var i=et(),s=this.s,a=t.s,u=this.DB-ut(n[n.t-1]);u>0?(n.lShiftTo(u,i),o.lShiftTo(u,r)):(n.copyTo(i),o.copyTo(r));var c=i.t,l=i[c-1];if(0!=l){var f=l*(1<<this.F1)+(c>1?i[c-2]>>this.F2:0),h=this.FV/f,d=(1<<this.F1)/f,p=1<<this.F2,y=r.t,v=y-c,g=null==e?et():e;for(i.dlShiftTo(v,g),r.compareTo(g)>=0&&(r[r.t++]=1,r.subTo(g,r)),tt.ONE.dlShiftTo(c,g),g.subTo(i,i);i.t<c;)i[i.t++]=0;for(;--v>=0;){var m=r[--y]==l?this.DM:Math.floor(r[y]*h+(r[y-1]+p)*d);if((r[y]+=i.am(0,m,r,v,0,c))<m)for(i.dlShiftTo(v,g),r.subTo(g,r);r[y]<--m;)r.subTo(g,r)}null!=e&&(r.drShiftTo(c,e),s!=a&&tt.ZERO.subTo(e,e)),r.t=c,r.clamp(),u>0&&r.rShiftTo(u,r),s<0&&tt.ZERO.subTo(r,r)}}}invDigit(){if(this.t<1)return 0;var t=this[0];if(!(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e}isEven(){return 0==(this.t>0?1&this[0]:this.s)}exp(t,e){if(t>4294967295||t<1)return tt.ONE;var r=et(),n=et(),o=e.convert(this),i=ut(t)-1;for(o.copyTo(r);--i>=0;)if(e.sqrTo(r,n),(t&1<<i)>0)e.mulTo(n,o,r);else{var s=r;r=n,n=s}return e.revert(r)}chunkSize(t){return Math.floor(Math.LN2*this.DB/Math.log(t))}toRadix(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),n=at(r),o=et(),i=et(),s="";for(this.divRemTo(n,o,i);o.signum()>0;)s=(r+i.intValue()).toString(t).substr(1)+s,o.divRemTo(n,o,i);return i.intValue().toString(t)+s}fromRadix(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),n=Math.pow(e,r),o=!1,i=0,s=0,a=0;a<t.length;++a){var u=st(t,a);u<0?"-"==t.charAt(a)&&0==this.signum()&&(o=!0):(s=e*s+u,++i>=r&&(this.dMultiply(n),this.dAddOffset(s,0),i=0,s=0))}i>0&&(this.dMultiply(Math.pow(e,i)),this.dAddOffset(s,0)),o&&tt.ZERO.subTo(this,this)}fromNumber(t,e,r){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(tt.ONE.shiftLeft(t-1),F,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(tt.ONE.shiftLeft(t-1),this);else{var n=[],o=7&t;n.length=1+(t>>3),e.nextBytes(n),o>0?n[0]&=(1<<o)-1:n[0]=0,this.fromString(n,256)}}bitwiseTo(t,e,r){var n,o,i=Math.min(t.t,this.t);for(n=0;n<i;++n)r[n]=e(this[n],t[n]);if(t.t<this.t){for(o=t.s&this.DM,n=i;n<this.t;++n)r[n]=e(this[n],o);r.t=this.t}else{for(o=this.s&this.DM,n=i;n<t.t;++n)r[n]=e(o,t[n]);r.t=t.t}r.s=e(this.s,t.s),r.clamp()}changeBit(t,e){var r=tt.ONE.shiftLeft(t);return this.bitwiseTo(r,e,r),r}addTo(t,e){for(var r=0,n=0,o=Math.min(t.t,this.t);r<o;)n+=this[r]+t[r],e[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n+=t.s;r<this.t;)n+=this[r],e[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n+=t[r],e[r++]=n&this.DM,n>>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[r++]=n:n<-1&&(e[r++]=this.DV+n),e.t=r,e.clamp()}dMultiply(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()}dAddOffset(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}}multiplyLowerTo(t,e,r){var n=Math.min(this.t+t.t,e);for(r.s=0,r.t=n;n>0;)r[--n]=0;for(var o=r.t-this.t;n<o;++n)r[n+this.t]=this.am(0,t[n],r,n,0,this.t);for(o=Math.min(t.t,e);n<o;++n)this.am(0,t[n],r,n,0,e-n);r.clamp()}multiplyUpperTo(t,e,r){--e;var n=r.t=this.t+t.t-e;for(r.s=0;--n>=0;)r[n]=0;for(n=Math.max(e-this.t,0);n<t.t;++n)r[this.t+n-e]=this.am(e-n,t[n],r,0,0,this.t+n-e);r.clamp(),r.drShiftTo(1,r)}modInt(t){if(t<=0)return 0;var e=this.DV%t,r=this.s<0?t-1:0;if(this.t>0)if(0==e)r=this[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this[n])%t;return r}millerRabin(t){var e=this.subtract(tt.ONE),r=e.getLowestSetBit();if(r<=0)return!1;var n=e.shiftRight(r);(t=t+1>>1)>y.length&&(t=y.length);for(var o=et(),i=0;i<t;++i){o.fromInt(y[Math.floor(Math.random()*y.length)]);var s=o.modPow(n,this);if(0!=s.compareTo(tt.ONE)&&0!=s.compareTo(e)){for(var a=1;a++<r&&0!=s.compareTo(e);)if(0==(s=s.modPowInt(2,this)).compareTo(tt.ONE))return!1;if(0!=s.compareTo(e))return!1}}return!0}square(){var t=et();return this.squareTo(t),t}gcda(t,e){var r=this.s<0?this.negate():this.clone(),n=t.s<0?t.negate():t.clone();if(r.compareTo(n)<0){var o=r;r=n,n=o}var i=r.getLowestSetBit(),s=n.getLowestSetBit();if(s<0)e(r);else{i<s&&(s=i),s>0&&(r.rShiftTo(s,r),n.rShiftTo(s,n));var a=()=>{(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),(i=n.getLowestSetBit())>0&&n.rShiftTo(i,n),r.compareTo(n)>=0?(r.subTo(n,r),r.rShiftTo(1,r)):(n.subTo(r,n),n.rShiftTo(1,n)),r.signum()>0?setTimeout(a,0):(s>0&&n.lShiftTo(s,n),setTimeout((function(){e(n)}),0))};setTimeout(a,10)}}fromNumberAsync(t,e,r,n){if("number"==typeof e)if(t<2)this.fromInt(1);else{this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(tt.ONE.shiftLeft(t-1),F,this),this.isEven()&&this.dAddOffset(1,0);var o=this,i=function(){o.dAddOffset(2,0),o.bitLength()>t&&o.subTo(tt.ONE.shiftLeft(t-1),o),o.isProbablePrime(e)?setTimeout((function(){n()}),0):setTimeout(i,0)};setTimeout(i,0)}else{var s=[],a=7&t;s.length=1+(t>>3),e.nextBytes(s),a>0?s[0]&=(1<<a)-1:s[0]=0,this.fromString(s,256)}}}var g=function(){function t(){}return t.prototype.convert=function(t){return t},t.prototype.revert=function(t){return t},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},t.prototype.sqrTo=function(t,e){t.squareTo(e)},t}(),m=function(){function t(t){this.m=t}return t.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},t.prototype.revert=function(t){return t},t.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),b=function(){function t(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}return t.prototype.convert=function(t){var e=et();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(tt.ZERO)>0&&this.m.subTo(e,e),e},t.prototype.revert=function(t){var e=et();return t.copyTo(e),this.reduce(e),e},t.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var r=32767&t[e],n=r*this.mpl+((r*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),w=function(){function t(t){this.m=t,this.r2=et(),this.q3=et(),tt.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t)}return t.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=et();return t.copyTo(e),this.reduce(e),e},t.prototype.revert=function(t){return t},t.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}();function et(){return new tt(null)}function rt(t,e){return new tt(t,e)}function nt(t,e,r,n,o,i){for(;--i>=0;){var s=e*this[t++]+r[n]+o;o=Math.floor(s/67108864),r[n++]=67108863&s}return o}function ot(t,e,r,n,o,i){for(var s=32767&e,a=e>>15;--i>=0;){var u=32767&this[t],c=this[t++]>>15,l=a*u+c*s;o=((u=s*u+((32767&l)<<15)+r[n]+(1073741823&o))>>>30)+(l>>>15)+a*c+(o>>>30),r[n++]=1073741823&u}return o}function it(t,e,r,n,o,i){for(var s=16383&e,a=e>>14;--i>=0;){var u=16383&this[t],c=this[t++]>>14,l=a*u+c*s;o=((u=s*u+((16383&l)<<14)+r[n]+o)>>28)+(l>>14)+a*c,r[n++]=268435455&u}return o}void 0!==o&&"Microsoft Internet Explorer"==(null==o?void 0:o.appName)?(tt.prototype.am=ot,h=30):"Netscape"!=(null==o?void 0:o.appName)?(tt.prototype.am=nt,h=26):(tt.prototype.am=it,h=28),tt.prototype.DB=h,tt.prototype.DM=(1<<h)-1,tt.prototype.DV=1<<h,tt.prototype.FV=Math.pow(2,52),tt.prototype.F1=52-h,tt.prototype.F2=2*h-52;var _,S,E=[];for(_="0".charCodeAt(0),S=0;S<=9;++S)E[_++]=S;for(_="a".charCodeAt(0),S=10;S<36;++S)E[_++]=S;for(_="A".charCodeAt(0),S=10;S<36;++S)E[_++]=S;function st(t,e){var r=E[t.charCodeAt(e)];return null==r?-1:r}function at(t){var e=et();return e.fromInt(t),e}function ut(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}tt.ZERO=at(0),tt.ONE=at(1);class ct{constructor(){this.i=0,this.j=0,this.S=[]}init(t){var e,r,n;for(e=0;e<256;++e)this.S[e]=e;for(r=0,e=0;e<256;++e)r=r+this.S[e]+t[e%t.length]&255,n=this.S[e],this.S[e]=this.S[r],this.S[r]=n;this.i=0,this.j=0}next(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]}}var I,O,T=null;if(null==T){var R,A,P,x;T=[],O=0;var C=void 0;if(null!==(R=window)&&void 0!==R&&R.crypto&&null!==(A=window)&&void 0!==A&&A.crypto.getRandomValues){var N,L=new Uint32Array(256);for(null===(N=window)||void 0===N||N.crypto.getRandomValues(L),C=0;C<L.length;++C)T[O++]=255&L[C]}var j,U=function(t){var e,r,n;if(this.count=this.count||0,this.count>=256||O>=256){if(null!==(e=window)&&void 0!==e&&e.removeEventListener)null===(n=window)||void 0===n||n.removeEventListener("mousemove",U,!1);else if(null!==(r=window)&&void 0!==r&&r.detachEvent){var o;null===(o=window)||void 0===o||o.detachEvent("onmousemove",U)}}else try{var i=t.x+t.y;T[O++]=255&i,this.count+=1}catch(t){}};if(null!==(P=window)&&void 0!==P&&P.addEventListener)null===(j=window)||void 0===j||j.addEventListener("mousemove",U,!1);else if(null!==(x=window)&&void 0!==x&&x.attachEvent){var k;null===(k=window)||void 0===k||k.attachEvent("onmousemove",U)}}function lt(){if(null==I){for(I=new ct;O<256;){var t=Math.floor(65536*Math.random());T[O++]=255&t}for(I.init(T),O=0;O<T.length;++O)T[O]=0;O=0}return I.next()}class ft{constructor(){}nextBytes(t){for(var e=0;e<t.length;++e)t[e]=lt()}}function ht(t,e){if(e<t.length+11)return console.error("Message too long for RSA"),null;for(var r=[],n=t.length-1;n>=0&&e>0;){var o=t.charCodeAt(n--);o<128?r[--e]=o:o>127&&o<2048?(r[--e]=63&o|128,r[--e]=o>>6|192):(r[--e]=63&o|128,r[--e]=o>>6&63|128,r[--e]=o>>12|224)}r[--e]=0;for(var i=new ft,s=[];e>2;){for(s[0]=0;0==s[0];)i.nextBytes(s);r[--e]=s[0]}return r[--e]=2,r[--e]=0,new tt(r)}class dt{constructor(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}doPublic(t){return t.modPowInt(this.e,this.n)}doPrivate(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),r=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(r)<0;)e=e.add(this.p);return e.subtract(r).multiply(this.coeff).mod(this.p).multiply(this.q).add(r)}setPublic(t,e){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=rt(t,16),this.e=parseInt(e,16)):console.error("Invalid RSA public key")}encrypt(t){var e=ht(t,this.n.bitLength()+7>>3);if(null==e)return null;var r=this.doPublic(e);if(null==r)return null;var n=r.toString(16);return 1&n.length?"0"+n:n}encryptLong(t){var e=this,r=(this.n.bitLength()+7>>3)-11;try{var n="";return t.length>r?(t.match(/.{1,117}/g).forEach((function(t){var r=e.encrypt(t);n+=r})),K(n)):K(this.encrypt(t))}catch(t){return!1}}decryptLong(t){var e=this,r=this.n.bitLength()+7>>3;t=z(t);try{if(t.length>r){var n="";return t.match(/.{1,256}/g).forEach((function(t){var r=e.decrypt(t);n+=r})),n}return this.decrypt(t)}catch(t){return!1}}setPrivate(t,e,r){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=rt(t,16),this.e=parseInt(e,16),this.d=rt(r,16)):console.error("Invalid RSA private key")}setPrivateEx(t,e,r,n,o,i,s,a){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=rt(t,16),this.e=parseInt(e,16),this.d=rt(r,16),this.p=rt(n,16),this.q=rt(o,16),this.dmp1=rt(i,16),this.dmq1=rt(s,16),this.coeff=rt(a,16)):console.error("Invalid RSA private key")}generate(t,e){var r=new ft,n=t>>1;this.e=parseInt(e,16);for(var o=new tt(e,16);;){for(;this.p=new tt(t-n,1,r),0!=this.p.subtract(tt.ONE).gcd(o).compareTo(tt.ONE)||!this.p.isProbablePrime(10););for(;this.q=new tt(n,1,r),0!=this.q.subtract(tt.ONE).gcd(o).compareTo(tt.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var i=this.p;this.p=this.q,this.q=i}var s=this.p.subtract(tt.ONE),a=this.q.subtract(tt.ONE),u=s.multiply(a);if(0==u.gcd(o).compareTo(tt.ONE)){this.n=this.p.multiply(this.q),this.d=o.modInverse(u),this.dmp1=this.d.mod(s),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}}decrypt(t){var e=rt(t,16),r=this.doPrivate(e);return null==r?null:pt(r,this.n.bitLength()+7>>3)}generateAsync(t,e,r){var n=new ft,o=t>>1;this.e=parseInt(e,16);var i=new tt(e,16),s=this,a=()=>{var e=()=>{if(s.p.compareTo(s.q)<=0){var t=s.p;s.p=s.q,s.q=t}var e=s.p.subtract(tt.ONE),n=s.q.subtract(tt.ONE),o=e.multiply(n);0==o.gcd(i).compareTo(tt.ONE)?(s.n=s.p.multiply(s.q),s.d=i.modInverse(o),s.dmp1=s.d.mod(e),s.dmq1=s.d.mod(n),s.coeff=s.q.modInverse(s.p),setTimeout((function(){r()}),0)):setTimeout(a,0)},u=()=>{s.q=et(),s.q.fromNumberAsync(o,1,n,(function(){s.q.subtract(tt.ONE).gcda(i,(function(t){0==t.compareTo(tt.ONE)&&s.q.isProbablePrime(10)?setTimeout(e,0):setTimeout(u,0)}))}))},c=()=>{s.p=et(),s.p.fromNumberAsync(t-o,1,n,(function(){s.p.subtract(tt.ONE).gcda(i,(function(t){0==t.compareTo(tt.ONE)&&s.p.isProbablePrime(10)?setTimeout(u,0):setTimeout(c,0)}))}))};setTimeout(c,0)};setTimeout(a,0)}}function pt(t,e){for(var r=t.toByteArray(),n=0;n<r.length&&0==r[n];)++n;if(r.length-n!=e-1||2!=r[n])return null;for(++n;0!=r[n];)if(++n>=r.length)return null;for(var o="";++n<r.length;){var i=255&r[n];i<128?o+=String.fromCharCode(i):i>191&&i<224?(o+=String.fromCharCode((31&i)<<6|63&r[n+1]),++n):(o+=String.fromCharCode((15&i)<<12|(63&r[n+1])<<6|63&r[n+2]),n+=2)}return o}class yt extends dt{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";super(),t&&("string"==typeof t?this.parseKey(t):(this.hasPrivateKeyProperty(t)||this.hasPublicKeyProperty(t))&&this.parsePropertiesFrom(t))}parseKey(t){try{var e=0,r=0,n=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(t)?c.decode(t):l.unarmor(t),o=Z.decode(n);if(3===o.sub.length&&(o=o.sub[2].sub[0]),9===o.sub.length){e=o.sub[1].getHexStringValue(),this.n=rt(e,16),r=o.sub[2].getHexStringValue(),this.e=parseInt(r,16);var i=o.sub[3].getHexStringValue();this.d=rt(i,16);var s=o.sub[4].getHexStringValue();this.p=rt(s,16);var a=o.sub[5].getHexStringValue();this.q=rt(a,16);var u=o.sub[6].getHexStringValue();this.dmp1=rt(u,16);var f=o.sub[7].getHexStringValue();this.dmq1=rt(f,16);var h=o.sub[8].getHexStringValue();this.coeff=rt(h,16)}else{if(2!==o.sub.length)return!1;var d=o.sub[1].sub[0];e=d.sub[0].getHexStringValue(),this.n=rt(e,16),r=d.sub[1].getHexStringValue(),this.e=parseInt(r,16)}return!0}catch(t){return!1}}hasPublicKeyProperty(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")}hasPrivateKeyProperty(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")&&t.hasOwnProperty("d")&&t.hasOwnProperty("p")&&t.hasOwnProperty("q")&&t.hasOwnProperty("dmp1")&&t.hasOwnProperty("dmq1")&&t.hasOwnProperty("coeff")}parsePropertiesFrom(t){this.n=t.n,this.e=t.e,t.hasOwnProperty("d")&&(this.d=t.d,this.p=t.p,this.q=t.q,this.dmp1=t.dmp1,this.dmq1=t.dmq1,this.coeff=t.coeff)}}(n=function(t){t=t||{},this.default_key_size=parseInt(t.default_key_size,10)||1024,this.default_public_exponent=t.default_public_exponent||"010001",this.log=t.log||!1,this.key=null}).prototype.setKey=function(t){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new yt(t)},n.prototype.setPrivateKey=function(t){this.setKey(t)},n.prototype.setPublicKey=function(t){this.setKey(t)},n.prototype.decrypt=function(t){try{return this.getKey().decrypt(z(t))}catch(t){return!1}},n.prototype.encrypt=function(t){try{return K(this.getKey().encrypt(t))}catch(t){return!1}},n.prototype.encryptLong=function(t){try{for(var e=this.getKey().encryptLong(t)||"",r=this.getKey().decryptLong(e)||"",n=0,o=/null$/g;o.test(r)&&(n++,e=this.getKey().encryptLong(t)||"",r=this.getKey().decryptLong(e)||"",!(n>10)););return e}catch(t){return!1}},n.prototype.getKey=function(t){if(!this.key){if(this.key=new yt,t&&"[object Function]"==={}.toString.call(t))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,t);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},n.version="3.1.4"}var D=n,q=r(4655),M=function(){var{publicKey:t="",payload:e={}}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!t)return"";try{var r=(0,q.I)(e),n=new D;return n.setPublicKey(t),n.encryptLong("object"==typeof r?JSON.stringify(r):r)}catch(t){console.error("encrypt error:",t)}return""}},4655:function(t,e,r){"use strict";r.d(e,{I:function(){return n},y:function(){return o}});var n=t=>{var e=e=>{for(var r in t)t.hasOwnProperty(r)&&(e[r]=n(t[r]));return e},r=null==t?"NullOrUndefined":Object.prototype.toString.call(t).slice(8,-1);if(["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"].includes(r))return t.slice();switch(r){case"Object":return e(Object.create(Object.getPrototypeOf(t)));case"Array":return e([]);case"Date":return new Date(t.valueOf());case"RegExp":return new RegExp(t.source,(t.global?"g":"")+(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.sticky?"y":"")+(t.unicode?"u":""));default:return t}},o=t=>{var e=t.match(/^(?:http(s)?:\/\/[^\/]+)?(\/[^\?#]*)/);return e&&e[2]||""}},9063:function(t,e,r){"use strict";r.r(e),r.d(e,{registerRealtime:function(){return W}});var n=r(6765),o=r.n(n),i=r(7195),s=r.n(i),a=r(9850),u=r.n(a);function c(t){return void 0===t&&(t=""),"".concat(t?"".concat(t,"_"):"").concat(+new Date,"_").concat(Math.random())}var l,f,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}})},d=function(t){var e,r,n=t.id,o=t.docChanges,i=t.docs,s=t.msgType,a=t.type;Object.defineProperties(this,{id:{get:function(){return n},enumerable:!0},docChanges:{get:function(){return e||(e=JSON.parse(JSON.stringify(o))),e},enumerable:!0},docs:{get:function(){return r||(r=JSON.parse(JSON.stringify(i))),r},enumerable:!0},msgType:{get:function(){return s},enumerable:!0},type:{get:function(){return a},enumerable:!0}})},p=(l=function(t,e){return l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},l(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 r(){this.constructor=t}l(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),y=function(t){function e(e){var r=t.call(this,"Watch Error ".concat(JSON.stringify(e.msgData)," (requestid: ").concat(e.requestId,")"))||this;return r.isRealtimeErrorMessageError=!0,r.payload=e,r}return p(e,t),e}(Error),v=function(t){return null==t?void 0:t.isRealtimeErrorMessageError},g=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 p(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 p(e,t),e}(Error),b=function(t){function e(e){var r=t.call(this,e.errMsg)||this;return r.errCode="UNKNOWN_ERROR",Object.defineProperties(r,{message:{get:function(){return"errCode: ".concat(this.errCode," ").concat(w[this.errCode]||""," | errMsg: ").concat(this.errMsg)},set:function(t){this.errMsg=t}}}),r.errCode=e.errCode||"UNKNOWN_ERROR",r.errMsg=e.errMsg,r}return p(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"},_=function(t){return void 0===t&&(t=0),new Promise((function(e){return setTimeout(e,t)}))},S=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},E=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},I=function(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||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"}(f||(f={}));var O=function(){function t(t){var e=this;this.watchStatus=f.INITING,this.wsLogin=function(t,r){return S(e,void 0,void 0,(function(){var e;return E(this,(function(n){switch(n.label){case 0:return this.watchStatus=f.LOGGINGIN,[4,this.login(t,r)];case 1:return e=n.sent(),this.envId||(this.envId=e.envId),[2,e]}}))}))},this.initWatch=function(t){return S(e,void 0,void 0,(function(){var e,r=this;return E(this,(function(n){switch(n.label){case 0:if(null!==this.initWatchPromise&&void 0!==this.initWatchPromise)return[2,this.initWatchPromise];this.initWatchPromise=new Promise((function(e,n){S(r,void 0,void 0,(function(){var r,o,i,s,a,u,l,h,p,y;return E(this,(function(v){switch(v.label){case 0:return v.trys.push([0,3,,4]),this.watchStatus===f.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,e()]):[4,this.wsLogin(this.envId,t)];case 1:return r=v.sent().envId,this.watchStatus===f.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,e()]):(this.watchStatus=f.INITING,o={watchId:this.watchId,requestId:c(),msgType:"INIT_WATCH",msgData:{envId:r,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=v.sent(),s=i.msgData,a=s.events,u=s.currEvent,this.sessionInfo={queryID:i.msgData.queryID,currentEventId:u-1,currentDocs:[]},a.length>0){for(l=0,h=a;l<h.length;l++)h[l].ID=u;this.handleServerEvents(i)}else this.sessionInfo.currentEventId=u,p=new d({id:u,docChanges:[],docs:[],type:"init"}),this.listener.onChange(p),this.scheduleSendACK();return this.onWatchStart(this,this.sessionInfo.queryID),this.watchStatus=f.ACTIVE,this.availableRetries.INIT_WATCH=2,e(),[3,4];case 3:return y=v.sent(),this.handleWatchEstablishmentError(y,{operationName:"INIT_WATCH",resolve:e,reject:n}),[3,4];case 4:return[2]}}))}))})),e=!1,n.label=1;case 1:return n.trys.push([1,,3,4]),[4,this.initWatchPromise];case 2:return n.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 S(e,void 0,void 0,(function(){var e,r=this;return E(this,(function(n){switch(n.label){case 0:if(null!==this.rebuildWatchPromise&&void 0!==this.rebuildWatchPromise)return[2,this.rebuildWatchPromise];this.rebuildWatchPromise=new Promise((function(e,n){S(r,void 0,void 0,(function(){var r,o,i,s;return E(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),this.watchStatus===f.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,e()]):[4,this.wsLogin(this.envId,t)];case 1:if(r=a.sent().envId,!this.sessionInfo)throw new Error("can not rebuildWatch without a successful initWatch (lack of sessionInfo)");return this.watchStatus===f.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,e()]):(this.watchStatus=f.REBUILDING,o={watchId:this.watchId,requestId:c(),msgType:"REBUILD_WATCH",msgData:{envId:r,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=f.ACTIVE,this.availableRetries.REBUILD_WATCH=2,e(),[3,4];case 3:return s=a.sent(),this.handleWatchEstablishmentError(s,{operationName:"REBUILD_WATCH",resolve:e,reject:n}),[3,4];case 4:return[2]}}))}))})),e=!1,n.label=1;case 1:return n.trys.push([1,,3,4]),[4,this.rebuildWatchPromise];case 2:return n.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,r){return S(e,void 0,void 0,(function(){var e,n,o,i=this;return E(this,(function(s){return e="INIT_WATCH"===r.operationName,n=function(){i.closeWithError(new b({errCode:e?w.SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:w.SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL,errMsg:t})),r.reject(t)},o=function(t){i.useRetryTicket(r.operationName)?e?(i.initWatchPromise=void 0,r.resolve(i.initWatch(t))):(i.rebuildWatchPromise=void 0,r.resolve(i.rebuildWatch(t))):n()},this.handleCommonError(t,{onSignError:function(){return o(!0)},onTimeoutError:function(){return o(!1)},onNotRetryableError:n,onCancelledError:r.reject,onUnknownError:function(){S(i,void 0,void 0,(function(){var t,e=this;return E(this,(function(n){switch(n.label){case 0:return n.trys.push([0,8,,9]),t=function(){return S(e,void 0,void 0,(function(){return E(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 n.sent(),[3,7];case 2:return[4,_(100)];case 3:return n.sent(),this.watchStatus!==f.PAUSED?[3,4]:(r.reject(new m("".concat(r.operationName," cancelled due to pause after unknownError"))),[3,7]);case 4:return this.isWSConnected()?[3,6]:[4,t()];case 5:return n.sent(),[3,7];case 6:o(!1),n.label=7;case 7:return[3,9];case 8:return n.sent(),o(!0),[3,9];case 9:return[2]}}))}))}}),[2]}))}))},this.closeWatch=function(){return S(e,void 0,void 0,(function(){var t,e,r;return E(this,(function(n){switch(n.label){case 0:if(t=this.sessionInfo?this.sessionInfo.queryID:"",this.watchStatus!==f.ACTIVE)return this.watchStatus=f.CLOSED,this.onWatchClose(this,t),[2];n.label=1;case 1:return n.trys.push([1,3,4,5]),this.watchStatus=f.CLOSING,e={watchId:this.watchId,requestId:c(),msgType:"CLOSE_WATCH",msgData:null},[4,this.send({msg:e})];case 2:return n.sent(),this.sessionInfo=void 0,this.watchStatus=f.CLOSED,[3,5];case 3:return r=n.sent(),this.closeWithError(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL,errMsg:r})),[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 S(e,void 0,void 0,(function(){var t,e,r;return E(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this.watchStatus!==f.ACTIVE?(this.scheduleSendACK(),[2]):this.sessionInfo?(t={watchId:this.watchId,requestId:c(),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 n.sent(),this.scheduleSendACK(),[3,3];case 2:if(e=n.sent(),v(e))switch((r=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 b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:r.msgData.code})),[2]}return this.availableRetries.CHECK_LAST&&this.availableRetries.CHECK_LAST>0?(this.availableRetries.CHECK_LAST-=1,this.scheduleSendACK()):this.closeWithError(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:e})),[3,3];case 3:return[2]}}))}))},this.handleCommonError=function(t,e){if(v(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:function(){e.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 f.PAUSED:if("ERROR"!==t.msgType)return;break;case f.LOGGINGIN:case f.INITING:case f.REBUILDING:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received while ".concat(this.watchStatus));case f.CLOSED:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received when the watch has closed");case f.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 b({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=f.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=f.PAUSED,console.log("[realtime] client paused (".concat(this.collectionName," ").concat(this.query,") (watchId ").concat(this.watchId,")"))},t.prototype.resume=function(){return S(this,void 0,void 0,(function(){var t;return E(this,(function(e){switch(e.label){case 0:this.watchStatus=f.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]-=1,console.log("[realtime] ".concat(t," use a retry ticket, now only ").concat(this.availableRetries[t]," retry left")),!0)},t.prototype.handleServerEvents=function(t){return S(this,void 0,void 0,(function(){var e;return E(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.scheduleSendACK(),[4,this.handleServerEventsInternel(t)];case 1:return r.sent(),this.postHandleServerEventsValidityCheck(t),[3,3];case 2:throw e=r.sent(),console.error("[realtime listener] internal non-fatal error: handle server events failed with error: ",e),e;case 3:return[2]}}))}))},t.prototype.handleServerEventsInternel=function(t){return S(this,void 0,void 0,(function(){var e,r,n,i,a,c,l,f,h,p,y,v;return E(this,(function(g){switch(g.label){case 0:if(e=t.requestId,r=t.msgData.events,n=t.msgType,!r.length||!this.sessionInfo)return[2];i=this.sessionInfo;try{a=r.map(T)}catch(t){return this.closeWithError(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA,errMsg:t})),[2]}c=I([],i.currentDocs,!0),l=!1,f=function(r,f){var p,y,v,g,m,_,S,O,T,R,A,P;return E(this,(function(E){switch(E.label){case 0:return p=a[r],i.currentEventId>=p.id?(!a[r-1]||p.id>a[r-1].id?console.warn("[realtime] duplicate event received, cur ".concat(i.currentEventId," but got ").concat(p.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!==p.id-1)return[3,2];switch(p.dataType){case"update":if(!p.doc)switch(p.queueType){case"update":case"dequeue":if(y=c.find((function(t){return t._id===p.docId})),y){if(v=u()(y),p.updatedFields&&Object.keys(p.updatedFields).forEach((function(t){o()(v,t,p.updatedFields[t])})),p.removedFields)for(g=0,m=p.removedFields;g<m.length;g++)_=m[g],s()(v,_);p.doc=v}else console.error("[realtime listener] internal non-fatal server error: unexpected update dataType event where no doc is associated.");break;case"enqueue":throw O=new b({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(O),O}break;case"replace":if(!p.doc)throw O=new b({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(O),O;break;case"remove":(S=c.find((function(t){return t._id===p.docId})))?p.doc=S:console.error("[realtime listener] internal non-fatal server error: unexpected remove event where no doc is associated.");break;case"limit":if(!p.doc)switch(p.queueType){case"dequeue":(S=c.find((function(t){return t._id===p.docId})))?p.doc=S:console.error("[realtime listener] internal non-fatal server error: unexpected limit dataType event where no doc is associated.");break;case"enqueue":throw O=new b({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(O),O}}switch(p.queueType){case"init":l?c.push(p.doc):(l=!0,c=[p.doc]);break;case"enqueue":c.push(p.doc);break;case"dequeue":T=c.findIndex((function(t){return t._id===p.docId})),T>-1?c.splice(T,1):console.error("[realtime listener] internal non-fatal server error: unexpected dequeue event where no doc is associated.");break;case"update":T=c.findIndex((function(t){return t._id===p.docId})),T>-1?c[T]=p.doc:console.error("[realtime listener] internal non-fatal server error: unexpected queueType update event where no doc is associated.")}return(r===f-1||a[r+1]&&a[r+1].id!==p.id)&&(R=I([],c,!0),A=a.slice(0,r+1).filter((function(t){return t.id===p.id})),h.sessionInfo.currentEventId=p.id,h.sessionInfo.currentDocs=c,P=new d({id:p.id,docChanges:A,docs:R,msgType:n}),h.listener.onChange(P)),[3,4];case 2:return console.warn("[realtime listener] event received is out of order, cur ".concat(h.sessionInfo.currentEventId," but got ").concat(p.id)),[4,h.rebuildWatch()];case 3:return E.sent(),[2,{value:void 0}];case 4:return[2]}}))},h=this,p=0,y=a.length,g.label=1;case 1:return p<y?[5,f(p,y)]:[3,4];case 2:if("object"==typeof(v=g.sent()))return[2,v.value];g.label=3;case 3:return p++,[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 T(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 R,A={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"}(R||(R={}));var P=function(t,e){var r=A[t],n=r?"".concat(r.name,", code ").concat(t,", reason ").concat(e||r.description):"code ".concat(t);return new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED,errMsg:n})},x=null,C="web";function N(){return x}function L(){return C}function j(t){C=t}var U=function(){return U=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},U.apply(this,arguments)},k=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},D=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},q=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 k(e,void 0,void 0,(function(){var e=this;return D(this,(function(r){return[2,new Promise((function(r,n){k(e,void 0,void 0,(function(){var e,o,i,s,a,u,c,l,f=this;return D(this,(function(h){switch(h.label){case 0:o=!1,i=!1,s=function(t){o=!0,e&&clearTimeout(e),r(t)},a=function(t){i=!0,e&&clearTimeout(e),n(t)},t.timeout&&(e=setTimeout((function(){k(f,void 0,void 0,(function(){return D(this,(function(t){switch(t.label){case 0:return o&&i?[3,2]:[4,_(0)];case 1:t.sent(),o&&i||a(new g("wsclient.send timedout")),t.label=2;case 2:return[2]}}))}))}),t.timeout)),h.label=1;case 1:return h.trys.push([1,8,,9]),void 0===this.wsInitPromise&&null===this.wsInitPromise?[3,3]:[4,this.wsInitPromise];case 2:h.sent(),h.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&&(u={resolve:s,reject:a,skipOnMessage:t.skipOnMessage},this.wsResponseWait.set(t.msg.requestId,u)),h.label=4;case 4:return h.trys.push([4,6,,7]),[4,this.ws.send(JSON.stringify(t.msg))];case 5:return h.sent(),t.waitResponse||s(void 0),[3,7];case 6:return(c=h.sent())&&(a(c),t.waitResponse&&this.wsResponseWait.delete(t.msg.requestId)),[3,7];case 7:return[3,9];case 8:return l=h.sent(),a(l),[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,r){return void 0===r&&(r=e.maxReconnect),k(e,void 0,void 0,(function(){var e=this;return D(this,(function(n){switch(n.label){case 0:if(t&&this.reconnectState)return[2];if(t&&(this.reconnectState=!0),void 0!==this.wsInitPromise&&null!==this.wsInitPromise)return[2,this.wsInitPromise];t&&this.pauseClients(),this.close(R.ReconnectWebSocket),this.wsInitPromise=new Promise((function(n,o){k(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 r=e.wsUrl||"wss://tcb-ws.tencentcloudapi.com",n=N();s.ws=n?new n(r):new WebSocket(r),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(),n(),t&&(this.resumeClients(),this.reconnectState=!1),[3,11];case 6:return i=a.sent(),console.error("[realtime] initWebSocketConnection connect fail",i),r>0?(this.wsInitPromise=void 0,[4,_(this.reconnectInterval)]):[3,9];case 7:a.sent(),t&&(this.reconnectState=!1),a.label=8;case 8:return n(this.initWebSocketConnection(t,r-1)),[3,10];case 9:o(i),t&&this.closeAllClients(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL,errMsg:i})),a.label=10;case 10:return[3,11];case 11:return[2]}}))}))})),n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,this.wsInitPromise];case 2:return n.sent(),this.wsReadySubsribers.forEach((function(t){return(0,t.resolve)()})),[3,5];case 3:return n.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,r){if(!e.ws)throw new Error("can not initWebSocketEvent, ws not exists");var n=!1;e.ws.onopen=function(e){console.warn("[realtime] ws event: open",e),n=!0,t()},e.ws.onerror=function(t){e.logins=new Map,n?(console.error("[realtime] ws event: error",t),e.clearHeartbeat(),e.virtualWSClient.forEach((function(e){return e.closeWithError(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR,errMsg:t}))}))):(console.error("[realtime] ws open failed with ws event: error",t),r(t))},e.ws.onclose=function(t){switch(console.warn("[realtime] ws event: close",t),e.logins=new Map,e.clearHeartbeat(),t.code){case R.ReconnectWebSocket:case R.NoRealtimeListeners:break;case R.HeartbeatPingError:case R.HeartbeatPongTimeoutError:case R.NormalClosure:case R.AbnormalClosure:e.maxReconnect>0?e.initWebSocketConnection(!0,e.maxReconnect):e.closeAllClients(P(t.code));break;case R.NoAuthentication:e.closeAllClients(P(t.code,t.reason));break;default:e.maxReconnect>0?e.initWebSocketConnection(!0,e.maxReconnect):e.closeAllClients(P(t.code))}},e.ws.onmessage=function(t){var r,n,o=(null===(r=t.data)||void 0===r?void 0:r.data)||t.data;e.heartbeat();try{n="string"==typeof o?JSON.parse(o):o}catch(t){throw new Error("[realtime] onMessage parse res.data error: ".concat(t))}if("ERROR"===n.msgType){var i=null;e.virtualWSClient.forEach((function(t){t.watchId===n.watchId&&(i=t)})),i&&i.listener.onError(n)}var s=e.wsResponseWait.get(n.requestId);if(s){try{"ERROR"===n.msgType?s.reject(new y(n)):s.resolve(n)}catch(t){console.error("ws onMessage responseWaitSpec.resolve(msg) errored:",t)}finally{e.wsResponseWait.delete(n.requestId)}if(s.skipOnMessage)return}if("PONG"!==n.msgType){var a=n.watchId&&e.watchIdClientMap.get(n.watchId);if(a)a.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":(a=e.queryIdClientMap.get(n.msgData.queryID))&&a.onMessage(n);break;default:for(var u=0,c=Array.from(e.watchIdClientMap.entries());u<c.length;u++){c[u][1].onMessage(n);break}}}else if(e.lastPingSendTS){var l=Date.now()-e.lastPingSendTS;if(l>1e4)return void console.warn("[realtime] untrusted rtt observed: ".concat(l));e.rttObserved.length>=3&&e.rttObserved.splice(0,e.rttObserved.length-3+1),e.rttObserved.push(l)}},e.heartbeat()}))},this.isWSConnected=function(){return Boolean(e.ws&&1===e.ws.readyState)},this.onceWSConnected=function(){return k(e,void 0,void 0,(function(){var t=this;return D(this,(function(e){return this.isWSConnected()?[2]:null!==this.wsInitPromise&&void 0!==this.wsInitPromise?[2,this.wsInitPromise]:[2,new Promise((function(e,r){t.wsReadySubsribers.push({resolve:e,reject:r})}))]}))}))},this.webLogin=function(t,r){return k(e,void 0,void 0,(function(){var e,n,o,i,s,a,u,l,f=this;return D(this,(function(h){switch(h.label){case 0:if(!r)if(t){if(e=this.logins.get(t)){if(e.loggedIn&&e.loginResult)return[2,e.loginResult];if(null!==e.loggingInPromise&&void 0!==e.loggingInPromise)return[2,e.loggingInPromise]}}else if(null!==(null==(n=this.logins.get(""))?void 0:n.loggingInPromise)&&void 0!==(null==n?void 0:n.loggingInPromise))return[2,n.loggingInPromise];o=new Promise((function(t,e){k(f,void 0,void 0,(function(){var r,n,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 r=a.sent(),n={envId:r.envId||"",accessToken:"",referrer:"web",sdkVersion:"",dataVersion:""},o={watchId:void 0,requestId:c(),msgType:"LOGIN",msgData:n,exMsgData:{runtime:L(),signStr:r.signStr,secretVersion:r.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:r.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(),(u=t&&this.logins.get(t))&&u===i&&u.loginStartTS===s)return i.loggedIn=!0,i.loggingInPromise=void 0,i.loginStartTS=void 0,i.loginResult=a,[2,a];if(u){if(u.loggedIn&&u.loginResult)return[2,u.loginResult];if(null!==u.loggingInPromise&&void 0!==u.loggingInPromise)return[2,u.loggingInPromise];throw new Error("ws unexpected login info")}throw new Error("ws login info reset");case 3:throw l=h.sent(),i.loggedIn=!1,i.loggingInPromise=void 0,i.loginStartTS=void 0,i.loginResult=void 0,l;case 4:return[2]}}))}))},this.getWsSign=function(){return k(e,void 0,void 0,(function(){var t,e,r,n,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:L()})]);case 1:if((e=a.sent()).code)throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败: ".concat(e.code));if(e.data)return r=e.data,n=r.signStr,o=r.wsUrl,i=r.secretVersion,s=r.envId,[2,{signStr:n,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 k(e,void 0,void 0,(function(){var t;return D(this,(function(e){switch(e.label){case 0:return t={watchId:void 0,requestId:c(),msgType:"PING",msgData:null},[4,this.send({msg:t})];case 1:return e.sent(),[2]}}))}))},this.onWatchStart=function(t,r){e.queryIdClientMap.set(r,t)},this.onWatchClose=function(t,r){r&&e.queryIdClientMap.delete(r),e.watchIdClientMap.delete(t.watchId),e.virtualWSClient.delete(t),e.virtualWSClient.size||e.close(R.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,A[t].name),this.ws=void 0)},t.prototype.watch=function(t){this.ws||void 0!==this.wsInitPromise&&null!==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(){k(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+=1,t.heartbeat(!0)):t.initWebSocketConnection(!0)}),this.context.appConfig.realtimePongWaitTimeout),[3,3];case 2:return e.sent(),this.pingFailed<2?(this.pingFailed+=1,this.heartbeat()):this.close(R.HeartbeatPingError),[3,3];case 3:return[2]}}))}))}),t?0:this.context.appConfig.realtimePingInterval)},t}(),M={target:"database",entity:function(){var t,e=this.platform,r=e.adapter,n=e.runtime;t=r.wsClass,x=t,j(n)}},B={name:"realtime",IIFE:!0,entity:function(){this.prototype.wsClientClass=q}};try{cloudbase.registerComponent(B),cloudbase.registerHook(M)}catch(t){}function W(t){try{t.registerComponent(B),t.registerHook(M)}catch(t){console.warn(t)}}},614:function(t,e,r){"use strict";r.r(e),r.d(e,{registerStorage:function(){return _}});var n,o=r(3616),i=function(){return i=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},i.apply(this,arguments)},s=function(t,e,r,n){var o,i=arguments.length,s=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s},a=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},u=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},c=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};!function(t){t.put="put",t.post="post"}(n||(n={}));var l=o._G.eX,f=o._G.Sg,h=o._G.vM,d=o.P6.isArray,p=o.P6.isString,y=o.P6.isPalinObject,v=o.P6.execCallback,g=o.BM.D,m="storage",b=new(function(){function t(){}return t.prototype.uploadFile=function(t,e){return u(this,void 0,void 0,(function(){var r,o,s,a,u,h,d,y,g,b,w,_,S,E,I,O,T,R,A,P,x,C,N,L,j;return c(this,(function(c){switch(c.label){case 0:if(r=t.cloudPath,o=t.filePath,s=t.onUploadProgress,a=t.method,u=void 0===a?"put":a,h=t.headers,d=void 0===h?{}:h,!p(r)||!o)throw new Error(JSON.stringify({code:f.INVALID_PARAMS,msg:"[".concat(m,".uploadFile] invalid params")}));return y={put:n.put,post:n.post}[u.toLocaleLowerCase()]||n.put,g=this.request,b={path:r,method:y},y===n.put&&(b.headers=d),[4,g.send("storage.getUploadMetadata",b)];case 1:return w=c.sent(),_=w.data,S=_.url,E=_.authorization,I=_.token,O=_.fileId,T=_.cosFileId,R=_.download_url,A=w.requestId,x=i(i({},P={url:S,file:o,name:r,onUploadProgress:s}),{method:n.put,headers:i(i({},d),{authorization:E,"x-cos-meta-fileid":T,"x-cos-security-token":I})}),C=i(i({},P),{method:n.post,data:{key:r,signature:E,"x-cos-meta-fileid":T,success_action_status:"201","x-cos-security-token":I}}),(j={})[n.put]={params:x,isSuccess:function(t){return t>=200&&t<300}},j[n.post]={params:C,isSuccess:function(t){return 201===t}},N=j,[4,g.upload(N[y].params)];case 2:return L=c.sent(),N[y].isSuccess(L.statusCode)?[2,v(e,null,{fileID:O,download_url:R,requestId:A})]:[2,v(e,new Error("[".concat(l(),"][").concat(f.OPERATION_FAIL,"][").concat(m,"]:").concat(L.data)))]}}))}))},t.prototype.getUploadMetadata=function(t,e){return u(this,void 0,void 0,(function(){var r,n,o,i,s;return c(this,(function(a){switch(a.label){case 0:if(r=t.cloudPath,!p(r))throw new Error(JSON.stringify({code:f.INVALID_PARAMS,msg:"[".concat(m,".getUploadMetadata] invalid cloudPath")}));n=this.request,o="storage.getUploadMetadata",a.label=1;case 1:return a.trys.push([1,3,,4]),[4,n.send(o,{path:r})];case 2:return i=a.sent(),[2,v(e,null,i)];case 3:return s=a.sent(),[2,v(e,s)];case 4:return[2]}}))}))},t.prototype.deleteFile=function(t,e){return u(this,void 0,void 0,(function(){var r,n,o,i,s,a;return c(this,(function(u){switch(u.label){case 0:if(!(r=t.fileList)||!d(r)||0===r.length)throw new Error(JSON.stringify({code:f.INVALID_PARAMS,msg:"[".concat(m,".deleteFile] fileList must not be empty")}));for(n=0,o=r;n<o.length;n++)if(!(i=o[n])||!p(i))throw new Error(JSON.stringify({code:f.INVALID_PARAMS,msg:"[".concat(m,".deleteFile] fileID must be string")}));return[4,this.request.send("storage.batchDeleteFile",{fileid_list:r})];case 1:return(s=u.sent()).code?[2,v(e,null,s)]:(a={fileList:s.data.delete_list,requestId:s.requestId},[2,v(e,null,a)])}}))}))},t.prototype.getTempFileURL=function(t,e){return u(this,void 0,void 0,(function(){var r,n,o,i,s,a;return c(this,(function(u){switch(u.label){case 0:if(!(r=t.fileList)||!d(r)||0===r.length)throw new Error(JSON.stringify({code:f.INVALID_PARAMS,msg:"[".concat(m,".getTempFileURL] fileList must not be empty")}));for(n=[],o=0,i=r;o<i.length;o++)if(s=i[o],y(s)){if(!Object.prototype.hasOwnProperty.call(s,"fileID")||!Object.prototype.hasOwnProperty.call(s,"maxAge"))throw new Error(JSON.stringify({code:f.INVALID_PARAMS,msg:"[".concat(m,".getTempFileURL] file info must include fileID and maxAge")}));n.push({fileid:s.fileID,max_age:s.maxAge})}else{if(!p(s))throw new Error(JSON.stringify({code:f.INVALID_PARAMS,msg:"[".concat(m,".getTempFileURL] invalid fileList")}));n.push({fileid:s})}return[4,this.request.send("storage.batchGetDownloadUrl",{file_list:n})];case 1:return(a=u.sent()).code?[2,v(e,null,a)]:[2,v(e,null,{fileList:a.data.download_list,requestId:a.requestId})]}}))}))},t.prototype.downloadFile=function(t,e){return u(this,void 0,void 0,(function(){var r,n,o,i,s,a;return c(this,(function(u){switch(u.label){case 0:if(r=t.fileID,!p(r))throw new Error(JSON.stringify({code:f.INVALID_PARAMS,msg:"[".concat(m,".getTempFileURL] fileID must be string")}));return[4,this.getTempFileURL.call(this,{fileList:[{fileID:r,maxAge:600}]})];case 1:return n=u.sent(),"SUCCESS"!==(o=n.fileList[0]).code?[2,v(e,o)]:(i=this.request,s=encodeURI(o.download_url),[4,i.download({url:s})]);case 2:return a=u.sent(),[2,v(e,null,a)]}}))}))},s([g({customInfo:{className:"Cloudbase",methodName:"uploadFile"},title:"上传文件失败",messages:["请确认以下各项:"," 1 - 调用 uploadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(h)]}),a("design:type",Function),a("design:paramtypes",[Object,Function]),a("design:returntype",Promise)],t.prototype,"uploadFile",null),s([g({customInfo:{className:"Cloudbase",methodName:"getUploadMetadata"},title:"获取上传元信息失败",messages:["请确认以下各项:"," 1 - 调用 getUploadMetadata() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(h)]}),a("design:type",Function),a("design:paramtypes",[Object,Function]),a("design:returntype",Promise)],t.prototype,"getUploadMetadata",null),s([g({customInfo:{className:"Cloudbase",methodName:"deleteFile"},title:"删除文件失败",messages:["请确认以下各项:"," 1 - 调用 deleteFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(h)]}),a("design:type",Function),a("design:paramtypes",[Object,Function]),a("design:returntype",Promise)],t.prototype,"deleteFile",null),s([g({customInfo:{className:"Cloudbase",methodName:"getTempFileURL"},title:"获取文件下载链接",messages:["请确认以下各项:"," 1 - 调用 getTempFileURL() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(h)]}),a("design:type",Function),a("design:paramtypes",[Object,Function]),a("design:returntype",Promise)],t.prototype,"getTempFileURL",null),s([g({customInfo:{className:"Cloudbase",methodName:"downloadFile"},title:"下载文件失败",messages:["请确认以下各项:"," 1 - 调用 downloadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(h)]}),a("design:type",Function),a("design:paramtypes",[Object,Function]),a("design:returntype",Promise)],t.prototype,"downloadFile",null),t}()),w={name:m,entity:{uploadFile:b.uploadFile,deleteFile:b.deleteFile,getTempFileURL:b.getTempFileURL,downloadFile:b.downloadFile,getUploadMetadata:b.getUploadMetadata}};try{cloudbase.registerComponent(w)}catch(t){}function _(t){try{t.registerComponent(w)}catch(t){console.warn(t)}}},8182:function(t,e,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},n.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&o(e,t,r);return i(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.useDefaultAdapter=e.useAdapters=e.RUNTIME=void 0;var a,u=s(r(4274)),c=r(5605);!function(t){t.WEB="web",t.WX_MP="wx_mp"}(a=e.RUNTIME||(e.RUNTIME={})),e.useAdapters=function(t,e){for(var r=0,o=(0,c.isArray)(t)?t:[t];r<o.length;r++){var i=o[r],s=i.isMatch,a=i.genAdapter,u=i.runtime;if(s())return{adapter:n({isMatch:s},a(e)),runtime:u}}},e.useDefaultAdapter=function(){return{adapter:u.genAdapter(),runtime:a.WEB}}},4274:function(t,e,r){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(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 r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__assign||function(){return i=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},i.apply(this,arguments)},s=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.WebRequest=e.genAdapter=void 0;var u=r(2829),c=r(5605),l=r(2946),f=function(t){function e(e){var r=t.call(this)||this,n=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=o||"请求超时",r.restrictedMethods=i||["get","post","upload","download"],r}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,r=t.file,n=t.name,o=t.method,s=t.headers,a=void 0===s?{}:s,u={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",c=new FormData;return"post"===u?(Object.keys(e).forEach((function(t){c.append(t,e[t])})),c.append("key",n),c.append("file",r),this.request(i(i({},t),{data:c,method:u}),this.restrictedMethods.includes("upload"))):this.request(i(i({},t),{method:"put",headers:a,body:r}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return s(this,void 0,void 0,(function(){var e,r,n,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,r=window.URL.createObjectURL(new Blob([e])),n=decodeURIComponent(new URL(t.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=r,o.setAttribute("download",n),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(r),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.fetch=function(t){var e;return s(this,void 0,void 0,(function(){var r,n,o,u,c,l,f,h,d,p,y,v=this;return a(this,(function(g){switch(g.label){case 0:return r=new AbortController,n=t.url,o=t.enableAbort,u=void 0!==o&&o,c=t.stream,l=void 0!==c&&c,f=t.signal,h=t.timeout,d=null!=h?h:this.timeout,f&&(f.aborted&&r.abort(),f.addEventListener("abort",(function(){return r.abort()}))),p=null,u&&d&&(p=setTimeout((function(){console.warn(v.timeoutMsg),r.abort(new Error(v.timeoutMsg))}),d)),[4,fetch(n,i(i({},t),{signal:r.signal})).then((function(t){return s(v,void 0,void 0,(function(){var e,r,n;return a(this,(function(o){switch(o.label){case 0:return clearTimeout(p),t.ok?(e=t,[3,3]):[3,1];case 1:return n=(r=Promise).reject,[4,t.json()];case 2:e=n.apply(r,[o.sent()]),o.label=3;case 3:return[2,e]}}))}))})).catch((function(t){return clearTimeout(p),Promise.reject(t)}))];case 1:return y=g.sent(),[2,{data:l?y.body:(null===(e=y.headers.get("content-type"))||void 0===e?void 0:e.includes("application/json"))?y.json():y.text(),statusCode:y.status,header:y.headers}]}}))}))},e.prototype.request=function(t,e){var r=this;void 0===e&&(e=!1);var n=String(t.method).toLowerCase()||"get";return new Promise((function(o){var i,s,a=t.url,u=t.headers,f=void 0===u?{}:u,h=t.data,d=t.responseType,p=t.withCredentials,y=t.body,v=t.onUploadProgress,g=(0,c.formatUrl)((0,l.getProtocol)(),a,"get"===n?h:{}),m=new XMLHttpRequest;m.open(n,g),d&&(m.responseType=d),Object.keys(f).forEach((function(t){m.setRequestHeader(t,f[t])})),v&&m.upload.addEventListener("progress",v),m.onreadystatechange=function(){var t={};if(4===m.readyState){var e=m.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};e.forEach((function(t){var e=t.split(": "),n=e.shift().toLowerCase(),o=e.join(": ");r[n]=o})),t.header=r,t.statusCode=m.status;try{t.data="blob"===d?m.response:JSON.parse(m.responseText)}catch(e){t.data="blob"===d?m.response:m.responseText}clearTimeout(i),o(t)}},e&&r.timeout&&(i=setTimeout((function(){console.warn(r.timeoutMsg),m.abort()}),r.timeout)),s=(0,c.isFormData)(h)?h:"application/x-www-form-urlencoded"===f["content-type"]?(0,c.toQueryString)(h):y||(h?JSON.stringify(h):void 0),p&&(m.withCredentials=!0),m.send(s)}))},e}(u.AbstractSDKRequest);e.WebRequest=f,e.genAdapter=function(){return{type:"default",root:window,reqClass:f,wsClass:WebSocket,localStorage:localStorage}}},2946: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 r="@cloudbase/js-sdk";e.setSdkName=function(t){r=t},e.getSdkName=function(){return r};var n="https:";e.setProtocol=function(t){n=t},e.getProtocol=function(){return n},e.IS_DEBUG_MODE=!1,e.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},6205: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,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.OATUH_LOGINTYPE=void 0,o(r(2946),e),o(r(6205),e),e.OATUH_LOGINTYPE="constants"},7718:function(t,e,r){"use strict";var n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.catchErrorsDecorator=void 0;var i=r(5605),s=r(794),a=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(a=-1!==navigator.userAgent.indexOf("Firefox"));var u=a?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,c=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function l(t){var e=t.err,r=t.className,n=t.methodName,o=t.sourceLink;if(!o)return null;var i,s=e.stack.split("\n"),u=a?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]\\s*\\(.*\\)$")),l=a?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]")),f=s.findIndex((function(t){return u.test(t)}));if(-1!==f){var h=s.filter((function(t,e){return e>f}));h.unshift(s[f].replace(l,"".concat(r,".").concat(n)).replace(c,o)),(i=new Error).stack="".concat(a?"@debugger":"Error","\n").concat(h.join("\n"))}return i}e.catchErrorsDecorator=function(t){var e=t.mode,r=void 0===e?"async":e,a=t.customInfo,f=void 0===a?{}:a,h=t.title,d=t.messages,p=void 0===d?[]:d;return function(t,e,a){if(s.IS_DEBUG_MODE){var d=f.className||t.constructor.name,y=f.methodName||e,v=a.value,g=function(){var t="",e=(new Error).stack.split("\n"),r=e.findIndex((function(t){return u.test(t)}));if(-1!==r){var n=c.exec(e[r+1]||"");t=n?n[0]:""}return t}();a.value="sync"===r?function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=l({err:new Error,className:d,methodName:y,sourceLink:g});try{return v.apply(this,t)}catch(t){var n=t,o=t.message,s=t.error,a=t.error_description,u={title:h||"".concat(d,".").concat(y," failed"),content:[{type:"error",body:t}]};if(o&&/^\{.*\}$/.test(o)){var c=JSON.parse(o);u.subtitle=o,c.code&&(r?(r.code=c.code,r.msg=c.msg):(t.code=c.code,t.message=c.msg),n=r||t,u.content=p.map((function(t){return{type:"info",body:t}})))}throw s&&a&&(u.subtitle=a,r?(r.code=s,r.msg=a):(t.code=s,t.message=a),n=r||t,u.content=p.map((function(t){return{type:"info",body:t}}))),(0,i.printGroupLog)(u),n}}:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n(this,void 0,void 0,(function(){var e,r,n,s,a,u,c,f;return o(this,(function(o){switch(o.label){case 0:e=l({err:new Error,className:d,methodName:y,sourceLink:g}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,v.apply(this,t)];case 2:return[2,o.sent()];case 3:throw r=o.sent(),n=r,s=r.message,a=r.error,u=r.error_description,c={title:h||"".concat(d,".").concat(y," failed"),content:[{type:"error",body:r}]},s&&/^\{.*\}$/.test(s)&&(f=JSON.parse(s),c.subtitle=f,f.code&&(e?(e.code=f.code,e.message=f.msg):(r.code=f.code,r.message=f.msg),n=e||r,c.content=p.map((function(t){return{type:"info",body:t}})))),a&&u&&(c.subtitle=u,e?(e.code=a,e.msg=u):(r.code=a,r.message=u),n=e||r,c.content=p.map((function(t){return{type:"info",body:t}}))),(0,i.printGroupLog)(c),n;case 4:return[2]}}))}))}}}}},141:function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),o(r(7718),e)},6197:function(t,e,r){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(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 r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},s=this&&this.__generator||function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.CloudbaseCache=void 0;var a=r(2829),u=r(5605),c=r(794),l=function(t){function e(e){var r=t.call(this)||this;return r.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),r}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),f=function(){function t(t){this.keys={};var e=t.persistence,r=t.platformInfo,n=void 0===r?{}:r,o=t.keys,i=void 0===o?{}:o;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||e,this.storage=function(t,e){switch(t){case"local":default:return e.localStorage?e.localStorage:((0,u.printWarn)(c.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new l(e.root));case"none":return new l(e.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(t.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),t.prototype.setStore=function(t,e,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(n))}catch(t){throw new Error(JSON.stringify({code:c.ERRORS.OPERATION_FAIL,msg:"[".concat((0,c.getSdkName)(),"][").concat(c.ERRORS.OPERATION_FAIL,"]setStore failed"),info:t}))}}else(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,r){return i(this,void 0,void 0,(function(){var n;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]),n={version:r||"localCachev1",content:e},[4,this.storage.setItem(t,JSON.stringify(n))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},t.prototype.getStore=function(t,e){var r;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!0})||void 0===r?void 0:r.tcb_token))return{IS_MP_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(t){return""}e=e||"localCachev1";var n=this.storage.getItem(t);return n&&n.indexOf(e)>=0?JSON.parse(n).content:""}(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){var r;return i(this,void 0,void 0,(function(){var n;return s(this,(function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!0})||void 0===r?void 0:r.tcb_token))return[2,{IS_MP_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(t){return[2,""]}return e=e||"localCachev1",[4,this.storage.getItem(t)];case 1:return(n=o.sent())&&n.indexOf(e)>=0?[2,JSON.parse(n).content]:[2,""]}}))}))},t.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):(0,u.printWarn)(c.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=f},9689:function(t,e,r){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(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 r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__spreadArray||function(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||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=r(5605),a=function(t,e){this.data=e||null,this.name=t};e.CloudbaseEvent=a;var u=function(t){function e(e,r){var n=t.call(this,"error",{error:e,data:r})||this;return n.error=e,n}return o(e,t),e}(a);e.IErrorEvent=u;var c=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){return function(t,e,r){r[t]=r[t]||[],r[t].push(e)}(t,e,this.listeners),this},t.prototype.off=function(t,e){return function(t,e,r){if(null==r?void 0:r[t]){var n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if((0,s.isInstanceOf)(t,u))return console.error(t.error),this;var r=(0,s.isString)(t)?new a(t,e||{}):t,n=r.name;if(this.listens(n)){r.target=this;for(var o=0,c=this.listeners[n]?i([],this.listeners[n],!0):[];o<c.length;o++)c[o].call(this,r)}return this},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}();e.CloudbaseEventEmitter=c;var l=new c;e.addEventListener=function(t,e){l.on(t,e)},e.activateEvent=function(t,e){void 0===e&&(e={}),l.fire(t,e)},e.removeEventListener=function(t,e){l.off(t,e)}},5605:function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.parseQueryString=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.formatUrl=e.generateRequestId=e.genSeqId=e.isFormData=e.isInstanceOf=e.isNull=e.isPalinObject=e.isUndefined=e.isString=e.isArray=void 0;var n=r(794);e.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},e.isString=function(t){return"string"==typeof t},e.isUndefined=function(t){return void 0===t},e.isPalinObject=function(t){return"[object Object]"===Object.prototype.toString.call(t)},e.isNull=function(t){return"[object Null]"===Object.prototype.toString.call(t)},e.isInstanceOf=function(t,e){return t instanceof e},e.isFormData=function(t){return"[object FormData]"===Object.prototype.toString.call(t)},e.genSeqId=function(){return Math.random().toString(16).slice(2)},e.generateRequestId=function(){var t=(new Date).getTime(),e=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(r){var n=16*Math.random();return t>0?(n=(t+n)%16|0,t=Math.floor(t/16)):(n=(e+n)%16|0,e=Math.floor(e/16)),("x"===r?n:7&n|8).toString(16)}))},e.formatUrl=function(t,e,r){void 0===r&&(r={});var n=/\?/.test(e),o="";return Object.keys(r).forEach((function(t){""===o?!n&&(e+="?"):o+="&",o+="".concat(t,"=").concat(encodeURIComponent(r[t]))})),/^http(s)?:\/\//.test(e+=o)?e:"".concat(t).concat(e)},e.toQueryString=function(t){void 0===t&&(t={});var e=[];return Object.keys(t).forEach((function(r){e.push("".concat(r,"=").concat(encodeURIComponent(t[r])))})),e.join("&")},e.getQuery=function(t,e){if("undefined"==typeof window)return!1;var r=e||window.location.search,n=new RegExp("(^|&)".concat(t,"=([^&]*)(&|$)")),o=r.substr(r.indexOf("?")+1).match(n);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 r=e.split("?")[0],n=[],o=-1!==e.indexOf("?")?e.split("?")[1]:"";if(""!==o){for(var i=(n=o.split("&")).length-1;i>=0;i-=1)n[i].split("=")[0]===t&&n.splice(i,1);r="".concat(r,"?").concat(n.join("&"))}return r},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 r=new Promise((function(e,r){t=function(t,n){return t?r(t):e(n)}}));return t.promise=r,t},e.execCallback=function(t,e,r){if(void 0===r&&(r=null),t&&"function"==typeof t)return t(e,r);if(e)throw e;return r},e.printWarn=function(t,e){console.warn("[".concat((0,n.getSdkName)(),"][").concat(t,"]:").concat(e))},e.printError=function(t,e){console.error({code:t,msg:"[".concat((0,n.getSdkName)(),"][").concat(t,"]:").concat(e)})},e.printInfo=function(t,e){console.log("[".concat((0,n.getSdkName)(),"][").concat(t,"]:").concat(e))},e.throwError=function(t,e){throw new Error(JSON.stringify({code:t,msg:"[".concat((0,n.getSdkName)(),"][").concat(t,"]:").concat(e)}))},e.printGroupLog=function(t){var e,r=t.title,n=t.subtitle,o=void 0===n?"":n,i=t.content,s=void 0===i?[]:i,a=t.printTrace,u=void 0!==a&&a,c=t.collapsed;void 0!==c&&c?(console.groupCollapsed||console.error)(r,o):(console.group||console.error)(r,o);for(var l=0,f=s;l<f.length;l++){var h=f[l],d=h.type,p=h.body;switch(d){case"info":console.log(p);break;case"warn":console.warn(p);break;case"error":console.error(p)}}u&&(console.trace||console.log)("stack trace:"),null===(e=console.groupEnd)||void 0===e||e.call(console)},e.sleep=function(t){return void 0===t&&(t=0),new Promise((function(e){return setTimeout(e,t)}))},e.transformPhone=function(t){return"+86".concat(t)},e.parseQueryString=function(t){t=t.replace(/^\?/,"");var e={};return t.split("&").forEach((function(t){var r=t.split("="),n=r[0],o=r[1];n=decodeURIComponent(n),o=decodeURIComponent(o),n&&(e[n]?Array.isArray(e[n])?e[n].push(o):e[n]=[e[n],o]:e[n]=o)})),e}},3616:function(t,e,r){"use strict";r.d(e,{j$:function(){return i},Fs:function(){return s},_G:function(){return n},U3:function(){return a},BM:function(){return c},RR:function(){return u},P6:function(){return o}});var n={};r.r(n),r.d(n,{vM:function(){return v},Sg:function(){return g},Fk:function(){return y},eX:function(){return h},pM:function(){return p},tC:function(){return f}});var o={};r.r(o),r.d(o,{createPromiseCallback:function(){return L},execCallback:function(){return j},formatUrl:function(){return A},genSeqId:function(){return T},generateRequestId:function(){return R},getHash:function(){return C},getQuery:function(){return x},isArray:function(){return b},isFormData:function(){return O},isInstanceOf:function(){return I},isNull:function(){return E},isPalinObject:function(){return S},isString:function(){return w},isUndefined:function(){return _},parseQueryString:function(){return H},printError:function(){return k},printGroupLog:function(){return M},printInfo:function(){return D},printWarn:function(){return U},removeParam:function(){return N},sleep:function(){return B},throwError:function(){return q},toQueryString:function(){return P},transformPhone:function(){return W}});var i={};r.r(i),r.d(i,{Fk:function(){return Q},xY:function(){return Z}});var s={};r.r(s),r.d(s,{q:function(){return nt}});var a={};r.r(a),r.d(a,{yE:function(){return at}});var u={};r.r(u),r.d(u,{P:function(){return ct},$:function(){return ut}});var c={};r.r(c),r.d(c,{D:function(){return yt}});var l="@cloudbase/js-sdk";function f(t){l=t}function h(){return l}var d="https:";function p(t){d=t}var y=!1,v="https://support.qq.com/products/148793",g={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"},m=r(2829);function b(t){return"[object Array]"===Object.prototype.toString.call(t)}function w(t){return"string"==typeof t}function _(t){return void 0===t}function S(t){return"[object Object]"===Object.prototype.toString.call(t)}function E(t){return"[object Null]"===Object.prototype.toString.call(t)}function I(t,e){return t instanceof e}function O(t){return"[object FormData]"===Object.prototype.toString.call(t)}function T(){return Math.random().toString(16).slice(2)}function R(){var t=(new Date).getTime(),e=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(r){var n=16*Math.random();return t>0?(n=(t+n)%16|0,t=Math.floor(t/16)):(n=(e+n)%16|0,e=Math.floor(e/16)),("x"===r?n:7&n|8).toString(16)}))}function A(t,e,r){void 0===r&&(r={});var n=/\?/.test(e),o="";return Object.keys(r).forEach((function(t){""===o?!n&&(e+="?"):o+="&",o+="".concat(t,"=").concat(encodeURIComponent(r[t]))})),/^http(s)?:\/\//.test(e+=o)?e:"".concat(t).concat(e)}function P(t){void 0===t&&(t={});var e=[];return Object.keys(t).forEach((function(r){e.push("".concat(r,"=").concat(encodeURIComponent(t[r])))})),e.join("&")}function x(t,e){if("undefined"==typeof window)return!1;var r=e||window.location.search,n=new RegExp("(^|&)".concat(t,"=([^&]*)(&|$)")),o=r.substr(r.indexOf("?")+1).match(n);return null!=o?o[2]:""}var C=function(t){if("undefined"==typeof window)return"";var e=window.location.hash.match(new RegExp("[#?&/]".concat(t,"=([^&#]*)")));return e?e[1]:""};function N(t,e){var r=e.split("?")[0],n=[],o=-1!==e.indexOf("?")?e.split("?")[1]:"";if(""!==o){for(var i=(n=o.split("&")).length-1;i>=0;i-=1)n[i].split("=")[0]===t&&n.splice(i,1);r="".concat(r,"?").concat(n.join("&"))}return r}function L(){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 r=new Promise((function(e,r){t=function(t,n){return t?r(t):e(n)}}));return t.promise=r,t}function j(t,e,r){if(void 0===r&&(r=null),t&&"function"==typeof t)return t(e,r);if(e)throw e;return r}function U(t,e){console.warn("[".concat(h(),"][").concat(t,"]:").concat(e))}function k(t,e){console.error({code:t,msg:"[".concat(h(),"][").concat(t,"]:").concat(e)})}function D(t,e){console.log("[".concat(h(),"][").concat(t,"]:").concat(e))}function q(t,e){throw new Error(JSON.stringify({code:t,msg:"[".concat(h(),"][").concat(t,"]:").concat(e)}))}function M(t){var e,r=t.title,n=t.subtitle,o=void 0===n?"":n,i=t.content,s=void 0===i?[]:i,a=t.printTrace,u=void 0!==a&&a,c=t.collapsed;void 0!==c&&c?(console.groupCollapsed||console.error)(r,o):(console.group||console.error)(r,o);for(var l=0,f=s;l<f.length;l++){var h=f[l],d=h.type,p=h.body;switch(d){case"info":console.log(p);break;case"warn":console.warn(p);break;case"error":console.error(p)}}u&&(console.trace||console.log)("stack trace:"),null===(e=console.groupEnd)||void 0===e||e.call(console)}var B=function(t){return void 0===t&&(t=0),new Promise((function(e){return setTimeout(e,t)}))};function W(t){return"+86".concat(t)}var F,V,H=function(t){t=t.replace(/^\?/,"");var e={};return t.split("&").forEach((function(t){var r=t.split("="),n=r[0],o=r[1];n=decodeURIComponent(n),o=decodeURIComponent(o),n&&(e[n]?Array.isArray(e[n])?e[n].push(o):e[n]=[e[n],o]:e[n]=o)})),e},G=(F=function(t,e){return F=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},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 r(){this.constructor=t}F(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),$=function(){return $=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},$.apply(this,arguments)},K=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},z=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},J=function(t){function e(e){var r=t.call(this)||this,n=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=o||"请求超时",r.restrictedMethods=i||["get","post","upload","download"],r}return G(e,t),e.prototype.get=function(t){return this.request($($({},t),{method:"get"}),this.restrictedMethods.includes("get"))},e.prototype.post=function(t){return this.request($($({},t),{method:"post"}),this.restrictedMethods.includes("post"))},e.prototype.put=function(t){return this.request($($({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,r=t.file,n=t.name,o=t.method,i=t.headers,s=void 0===i?{}:i,a={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",u=new FormData;return"post"===a?(Object.keys(e).forEach((function(t){u.append(t,e[t])})),u.append("key",n),u.append("file",r),this.request($($({},t),{data:u,method:a}),this.restrictedMethods.includes("upload"))):this.request($($({},t),{method:"put",headers:s,body:r}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return K(this,void 0,void 0,(function(){var e,r,n,o;return z(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.get($($({},t),{headers:{},responseType:"blob"}))];case 1:return e=i.sent().data,r=window.URL.createObjectURL(new Blob([e])),n=decodeURIComponent(new URL(t.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=r,o.setAttribute("download",n),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(r),document.body.removeChild(o),[3,3];case 2:return i.sent(),[3,3];case 3:return[2,new Promise((function(e){e({statusCode:200,tempFilePath:t.url})}))]}}))}))},e.prototype.fetch=function(t){var e;return K(this,void 0,void 0,(function(){var r,n,o,i,s,a,u,c,l,f,h,d=this;return z(this,(function(p){switch(p.label){case 0:return r=new AbortController,n=t.url,o=t.enableAbort,i=void 0!==o&&o,s=t.stream,a=void 0!==s&&s,u=t.signal,c=t.timeout,l=null!=c?c:this.timeout,u&&(u.aborted&&r.abort(),u.addEventListener("abort",(function(){return r.abort()}))),f=null,i&&l&&(f=setTimeout((function(){console.warn(d.timeoutMsg),r.abort(new Error(d.timeoutMsg))}),l)),[4,fetch(n,$($({},t),{signal:r.signal})).then((function(t){return K(d,void 0,void 0,(function(){var e,r,n;return z(this,(function(o){switch(o.label){case 0:return clearTimeout(f),t.ok?(e=t,[3,3]):[3,1];case 1:return n=(r=Promise).reject,[4,t.json()];case 2:e=n.apply(r,[o.sent()]),o.label=3;case 3:return[2,e]}}))}))})).catch((function(t){return clearTimeout(f),Promise.reject(t)}))];case 1:return h=p.sent(),[2,{data:a?h.body:(null===(e=h.headers.get("content-type"))||void 0===e?void 0:e.includes("application/json"))?h.json():h.text(),statusCode:h.status,header:h.headers}]}}))}))},e.prototype.request=function(t,e){var r=this;void 0===e&&(e=!1);var n=String(t.method).toLowerCase()||"get";return new Promise((function(o){var i,s,a=t.url,u=t.headers,c=void 0===u?{}:u,l=t.data,f=t.responseType,h=t.withCredentials,p=t.body,y=t.onUploadProgress,v=A(d,a,"get"===n?l:{}),g=new XMLHttpRequest;g.open(n,v),f&&(g.responseType=f),Object.keys(c).forEach((function(t){g.setRequestHeader(t,c[t])})),y&&g.upload.addEventListener("progress",y),g.onreadystatechange=function(){var t={};if(4===g.readyState){var e=g.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};e.forEach((function(t){var e=t.split(": "),n=e.shift().toLowerCase(),o=e.join(": ");r[n]=o})),t.header=r,t.statusCode=g.status;try{t.data="blob"===f?g.response:JSON.parse(g.responseText)}catch(e){t.data="blob"===f?g.response:g.responseText}clearTimeout(i),o(t)}},e&&r.timeout&&(i=setTimeout((function(){console.warn(r.timeoutMsg),g.abort()}),r.timeout)),s=O(l)?l:"application/x-www-form-urlencoded"===c["content-type"]?P(l):p||(l?JSON.stringify(l):void 0),h&&(g.withCredentials=!0),g.send(s)}))},e}(m.AbstractSDKRequest),Y=function(){return Y=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Y.apply(this,arguments)};function Q(t,e){for(var r=0,n=b(t)?t:[t];r<n.length;r++){var o=n[r],i=o.isMatch,s=o.genAdapter,a=o.runtime;if(i())return{adapter:Y({isMatch:i},s(e)),runtime:a}}}function Z(){return{adapter:{type:"default",root:window,reqClass:J,wsClass:WebSocket,localStorage:localStorage},runtime:V.WEB}}!function(t){t.WEB="web",t.WX_MP="wx_mp"}(V||(V={}));var X=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),tt=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},et=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},rt=function(t){function e(e){var r=t.call(this)||this;return r.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),r}return X(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}(m.AbstractStorage),nt=function(){function t(t){this.keys={};var e=t.persistence,r=t.platformInfo,n=void 0===r?{}:r,o=t.keys,i=void 0===o?{}:o;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||e,this.storage=function(t,e){switch(t){case"local":default:return e.localStorage?e.localStorage:(U(g.INVALID_PARAMS,"localStorage is not supported on current platform"),new rt(e.root));case"none":return new rt(e.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(t.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),t.prototype.setStore=function(t,e,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(n))}catch(t){throw new Error(JSON.stringify({code:g.OPERATION_FAIL,msg:"[".concat(h(),"][").concat(g.OPERATION_FAIL,"]setStore failed"),info:t}))}}else U(g.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,r){return tt(this,void 0,void 0,(function(){var n;return et(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]),n={version:r||"localCachev1",content:e},[4,this.storage.setItem(t,JSON.stringify(n))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},t.prototype.getStore=function(t,e){var r;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!0})||void 0===r?void 0:r.tcb_token))return{IS_MP_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(t){return""}e=e||"localCachev1";var n=this.storage.getItem(t);return n&&n.indexOf(e)>=0?JSON.parse(n).content:""}U(g.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){var r;return tt(this,void 0,void 0,(function(){var n;return et(this,(function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!0})||void 0===r?void 0:r.tcb_token))return[2,{IS_MP_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(t){return[2,""]}return e=e||"localCachev1",[4,this.storage.getItem(t)];case 1:return(n=o.sent())&&n.indexOf(e)>=0?[2,JSON.parse(n).content]:[2,""]}}))}))},t.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):U(g.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},t.prototype.removeStoreAsync=function(t){return tt(this,void 0,void 0,(function(){return et(this,(function(e){switch(e.label){case 0:return[4,this.storage.removeItem(t)];case 1:return e.sent(),[2]}}))}))},t}(),ot=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),it=function(t,e){this.data=e||null,this.name=t},st=function(t){function e(e,r){var n=t.call(this,"error",{error:e,data:r})||this;return n.error=e,n}return ot(e,t),e}(it),at=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){return function(t,e,r){r[t]=r[t]||[],r[t].push(e)}(t,e,this.listeners),this},t.prototype.off=function(t,e){return function(t,e,r){if(null==r?void 0:r[t]){var n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if(I(t,st))return console.error(t.error),this;var r=w(t)?new it(t,e||{}):t,n=r.name;if(this.listens(n)){r.target=this;for(var o=0,i=this.listeners[n]?function(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))}([],this.listeners[n],!0):[];o<i.length;o++)i[o].call(this,r)}return this},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}();new at;var ut=new at,ct="lang_change",lt=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},ft=function(t,e){var r,n,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(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},ht=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(ht=-1!==navigator.userAgent.indexOf("Firefox"));var dt=ht?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,pt=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function yt(t){var e=t.mode,r=void 0===e?"async":e,n=t.customInfo,o=void 0===n?{}:n,i=t.title,s=t.messages,a=void 0===s?[]:s;return function(t,e,n){if(y){var s=o.className||t.constructor.name,u=o.methodName||e,c=n.value,l=function(){var t="",e=(new Error).stack.split("\n"),r=e.findIndex((function(t){return dt.test(t)}));if(-1!==r){var n=pt.exec(e[r+1]||"");t=n?n[0]:""}return t}();n.value="sync"===r?function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=vt({err:new Error,className:s,methodName:u,sourceLink:l});try{return c.apply(this,t)}catch(t){var n=t,o=t.message,f=t.error,h=t.error_description,d={title:i||"".concat(s,".").concat(u," failed"),content:[{type:"error",body:t}]};if(o&&/^\{.*\}$/.test(o)){var p=JSON.parse(o);d.subtitle=o,p.code&&(r?(r.code=p.code,r.msg=p.msg):(t.code=p.code,t.message=p.msg),n=r||t,d.content=a.map((function(t){return{type:"info",body:t}})))}throw f&&h&&(d.subtitle=h,r?(r.code=f,r.msg=h):(t.code=f,t.message=h),n=r||t,d.content=a.map((function(t){return{type:"info",body:t}}))),M(d),n}}:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return lt(this,void 0,void 0,(function(){var e,r,n,o,f,h,d,p;return ft(this,(function(y){switch(y.label){case 0:e=vt({err:new Error,className:s,methodName:u,sourceLink:l}),y.label=1;case 1:return y.trys.push([1,3,,4]),[4,c.apply(this,t)];case 2:return[2,y.sent()];case 3:throw r=y.sent(),n=r,o=r.message,f=r.error,h=r.error_description,d={title:i||"".concat(s,".").concat(u," failed"),content:[{type:"error",body:r}]},o&&/^\{.*\}$/.test(o)&&(p=JSON.parse(o),d.subtitle=p,p.code&&(e?(e.code=p.code,e.message=p.msg):(r.code=p.code,r.message=p.msg),n=e||r,d.content=a.map((function(t){return{type:"info",body:t}})))),f&&h&&(d.subtitle=h,e?(e.code=f,e.msg=h):(r.code=f,r.message=h),n=e||r,d.content=a.map((function(t){return{type:"info",body:t}}))),M(d),n;case 4:return[2]}}))}))}}}}function vt(t){var e=t.err,r=t.className,n=t.methodName,o=t.sourceLink;if(!o)return null;var i,s=e.stack.split("\n"),a=ht?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]\\s*\\(.*\\)$")),u=ht?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]")),c=s.findIndex((function(t){return a.test(t)}));if(-1!==c){var l=s.filter((function(t,e){return e>c}));l.unshift(s[c].replace(u,"".concat(r,".").concat(n)).replace(pt,o)),(i=new Error).stack="".concat(ht?"@debugger":"Error","\n").concat(l.join("\n"))}return i}function gt(t){this.message=t}function mt(t){this.message=t}gt.prototype=new Error,gt.prototype.name="InvalidCharacterError","undefined"!=typeof window&&window.atob&&window.atob.bind(window),mt.prototype=new Error,mt.prototype.name="InvalidTokenError"},9515:function(t,e,r){var n=r(8761)(r(7772),"DataView");t.exports=n},9612:function(t,e,r){var n=r(2118),o=r(6909),i=r(8138),s=r(4174),a=r(7942);function u(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}u.prototype.clear=n,u.prototype.delete=o,u.prototype.get=i,u.prototype.has=s,u.prototype.set=a,t.exports=u},235:function(t,e,r){var n=r(3945),o=r(1846),i=r(8028),s=r(2344),a=r(4769);function u(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}u.prototype.clear=n,u.prototype.delete=o,u.prototype.get=i,u.prototype.has=s,u.prototype.set=a,t.exports=u},326:function(t,e,r){var n=r(8761)(r(7772),"Map");t.exports=n},6738:function(t,e,r){var n=r(2411),o=r(6417),i=r(6928),s=r(9493),a=r(4150);function u(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}u.prototype.clear=n,u.prototype.delete=o,u.prototype.get=i,u.prototype.has=s,u.prototype.set=a,t.exports=u},2760:function(t,e,r){var n=r(8761)(r(7772),"Promise");t.exports=n},2143:function(t,e,r){var n=r(8761)(r(7772),"Set");t.exports=n},6571:function(t,e,r){var n=r(235),o=r(5243),i=r(2858),s=r(4417),a=r(8605),u=r(1418);function c(t){var e=this.__data__=new n(t);this.size=e.size}c.prototype.clear=o,c.prototype.delete=i,c.prototype.get=s,c.prototype.has=a,c.prototype.set=u,t.exports=c},857:function(t,e,r){var n=r(7772).Symbol;t.exports=n},9162:function(t,e,r){var n=r(7772).Uint8Array;t.exports=n},3215:function(t,e,r){var n=r(8761)(r(7772),"WeakMap");t.exports=n},2517:function(t){t.exports=function(t,e){for(var r=-1,n=null==t?0:t.length;++r<n&&!1!==e(t[r],r,t););return t}},7552:function(t){t.exports=function(t,e){for(var r=-1,n=null==t?0:t.length,o=0,i=[];++r<n;){var s=t[r];e(s,r,t)&&(i[o++]=s)}return i}},1634:function(t,e,r){var n=r(6473),o=r(9631),i=r(6152),s=r(3226),a=r(9045),u=r(7598),c=Object.prototype.hasOwnProperty;t.exports=function(t,e){var r=i(t),l=!r&&o(t),f=!r&&!l&&s(t),h=!r&&!l&&!f&&u(t),d=r||l||f||h,p=d?n(t.length,String):[],y=p.length;for(var v in t)!e&&!c.call(t,v)||d&&("length"==v||f&&("offset"==v||"parent"==v)||h&&("buffer"==v||"byteLength"==v||"byteOffset"==v)||a(v,y))||p.push(v);return p}},343:function(t){t.exports=function(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r<n;)o[r]=e(t[r],r,t);return o}},5067:function(t){t.exports=function(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}},91:function(t,e,r){var n=r(3940),o=r(1225),i=Object.prototype.hasOwnProperty;t.exports=function(t,e,r){var s=t[e];i.call(t,e)&&o(s,r)&&(void 0!==r||e in t)||n(t,e,r)}},2218:function(t,e,r){var n=r(1225);t.exports=function(t,e){for(var r=t.length;r--;)if(n(t[r][0],e))return r;return-1}},7993:function(t,e,r){var n=r(752),o=r(249);t.exports=function(t,e){return t&&n(e,o(e),t)}},5906:function(t,e,r){var n=r(752),o=r(8582);t.exports=function(t,e){return t&&n(e,o(e),t)}},3940:function(t,e,r){var n=r(3043);t.exports=function(t,e,r){"__proto__"==e&&n?n(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}},8874:function(t,e,r){var n=r(6571),o=r(2517),i=r(91),s=r(7993),a=r(5906),u=r(2175),c=r(1522),l=r(7680),f=r(9987),h=r(3483),d=r(6939),p=r(940),y=r(9917),v=r(8222),g=r(8725),m=r(6152),b=r(3226),w=r(4714),_=r(9259),S=r(3679),E=r(249),I=r(8582),O="[object Arguments]",T="[object Function]",R="[object Object]",A={};A[O]=A["[object Array]"]=A["[object ArrayBuffer]"]=A["[object DataView]"]=A["[object Boolean]"]=A["[object Date]"]=A["[object Float32Array]"]=A["[object Float64Array]"]=A["[object Int8Array]"]=A["[object Int16Array]"]=A["[object Int32Array]"]=A["[object Map]"]=A["[object Number]"]=A[R]=A["[object RegExp]"]=A["[object Set]"]=A["[object String]"]=A["[object Symbol]"]=A["[object Uint8Array]"]=A["[object Uint8ClampedArray]"]=A["[object Uint16Array]"]=A["[object Uint32Array]"]=!0,A["[object Error]"]=A[T]=A["[object WeakMap]"]=!1,t.exports=function t(e,r,P,x,C,N){var L,j=1&r,U=2&r,k=4&r;if(P&&(L=C?P(e,x,C,N):P(e)),void 0!==L)return L;if(!_(e))return e;var D=m(e);if(D){if(L=y(e),!j)return c(e,L)}else{var q=p(e),M=q==T||"[object GeneratorFunction]"==q;if(b(e))return u(e,j);if(q==R||q==O||M&&!C){if(L=U||M?{}:g(e),!j)return U?f(e,a(L,e)):l(e,s(L,e))}else{if(!A[q])return C?e:{};L=v(e,q,j)}}N||(N=new n);var B=N.get(e);if(B)return B;N.set(e,L),S(e)?e.forEach((function(n){L.add(t(n,r,P,n,e,N))})):w(e)&&e.forEach((function(n,o){L.set(o,t(n,r,P,o,e,N))}));var W=D?void 0:(k?U?d:h:U?I:E)(e);return o(W||e,(function(n,o){W&&(n=e[o=n]),i(L,o,t(n,r,P,o,e,N))})),L}},9413:function(t,e,r){var n=r(9259),o=Object.create,i=function(){function t(){}return function(e){if(!n(e))return{};if(o)return o(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();t.exports=i},3324:function(t,e,r){var n=r(7297),o=r(3812);t.exports=function(t,e){for(var r=0,i=(e=n(e,t)).length;null!=t&&r<i;)t=t[o(e[r++])];return r&&r==i?t:void 0}},1897:function(t,e,r){var n=r(5067),o=r(6152);t.exports=function(t,e,r){var i=e(t);return o(t)?i:n(i,r(t))}},3366:function(t,e,r){var n=r(857),o=r(2107),i=r(7157),s=n?n.toStringTag:void 0;t.exports=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":s&&s in Object(t)?o(t):i(t)}},5183:function(t,e,r){var n=r(3366),o=r(5125);t.exports=function(t){return o(t)&&"[object Arguments]"==n(t)}},4511:function(t,e,r){var n=r(940),o=r(5125);t.exports=function(t){return o(t)&&"[object Map]"==n(t)}},6840:function(t,e,r){var n=r(1049),o=r(7394),i=r(9259),s=r(7035),a=/^\[object .+?Constructor\]$/,u=Function.prototype,c=Object.prototype,l=u.toString,f=c.hasOwnProperty,h=RegExp("^"+l.call(f).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");t.exports=function(t){return!(!i(t)||o(t))&&(n(t)?h:a).test(s(t))}},8436:function(t,e,r){var n=r(940),o=r(5125);t.exports=function(t){return o(t)&&"[object Set]"==n(t)}},5522:function(t,e,r){var n=r(3366),o=r(1158),i=r(5125),s={};s["[object Float32Array]"]=s["[object Float64Array]"]=s["[object Int8Array]"]=s["[object Int16Array]"]=s["[object Int32Array]"]=s["[object Uint8Array]"]=s["[object Uint8ClampedArray]"]=s["[object Uint16Array]"]=s["[object Uint32Array]"]=!0,s["[object Arguments]"]=s["[object Array]"]=s["[object ArrayBuffer]"]=s["[object Boolean]"]=s["[object DataView]"]=s["[object Date]"]=s["[object Error]"]=s["[object Function]"]=s["[object Map]"]=s["[object Number]"]=s["[object Object]"]=s["[object RegExp]"]=s["[object Set]"]=s["[object String]"]=s["[object WeakMap]"]=!1,t.exports=function(t){return i(t)&&o(t.length)&&!!s[n(t)]}},6411:function(t,e,r){var n=r(6001),o=r(4248),i=Object.prototype.hasOwnProperty;t.exports=function(t){if(!n(t))return o(t);var e=[];for(var r in Object(t))i.call(t,r)&&"constructor"!=r&&e.push(r);return e}},8390:function(t,e,r){var n=r(9259),o=r(6001),i=r(2966),s=Object.prototype.hasOwnProperty;t.exports=function(t){if(!n(t))return i(t);var e=o(t),r=[];for(var a in t)("constructor"!=a||!e&&s.call(t,a))&&r.push(a);return r}},2857:function(t,e,r){var n=r(91),o=r(7297),i=r(9045),s=r(9259),a=r(3812);t.exports=function(t,e,r,u){if(!s(t))return t;for(var c=-1,l=(e=o(e,t)).length,f=l-1,h=t;null!=h&&++c<l;){var d=a(e[c]),p=r;if("__proto__"===d||"constructor"===d||"prototype"===d)return t;if(c!=f){var y=h[d];void 0===(p=u?u(y,d,h):void 0)&&(p=s(y)?y:i(e[c+1])?[]:{})}n(h,d,p),h=h[d]}return t}},9872:function(t){t.exports=function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n<o;)i[n]=t[n+e];return i}},6473:function(t){t.exports=function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}},1054:function(t,e,r){var n=r(857),o=r(343),i=r(6152),s=r(4795),a=n?n.prototype:void 0,u=a?a.toString:void 0;t.exports=function t(e){if("string"==typeof e)return e;if(i(e))return o(e,t)+"";if(s(e))return u?u.call(e):"";var r=e+"";return"0"==r&&1/e==-1/0?"-0":r}},7826:function(t){t.exports=function(t){return function(e){return t(e)}}},9078:function(t,e,r){var n=r(7297),o=r(6974),i=r(2721),s=r(3812);t.exports=function(t,e){return e=n(e,t),null==(t=i(t,e))||delete t[s(o(e))]}},7297:function(t,e,r){var n=r(6152),o=r(1401),i=r(4452),s=r(6188);t.exports=function(t,e){return n(t)?t:o(t,e)?[t]:i(s(t))}},9882:function(t,e,r){var n=r(9162);t.exports=function(t){var e=new t.constructor(t.byteLength);return new n(e).set(new n(t)),e}},2175:function(t,e,r){t=r.nmd(t);var n=r(7772),o=e&&!e.nodeType&&e,i=o&&t&&!t.nodeType&&t,s=i&&i.exports===o?n.Buffer:void 0,a=s?s.allocUnsafe:void 0;t.exports=function(t,e){if(e)return t.slice();var r=t.length,n=a?a(r):new t.constructor(r);return t.copy(n),n}},4727:function(t,e,r){var n=r(9882);t.exports=function(t,e){var r=e?n(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}},6058:function(t){var e=/\w*$/;t.exports=function(t){var r=new t.constructor(t.source,e.exec(t));return r.lastIndex=t.lastIndex,r}},169:function(t,e,r){var n=r(857),o=n?n.prototype:void 0,i=o?o.valueOf:void 0;t.exports=function(t){return i?Object(i.call(t)):{}}},6190:function(t,e,r){var n=r(9882);t.exports=function(t,e){var r=e?n(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}},1522:function(t){t.exports=function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}},752:function(t,e,r){var n=r(91),o=r(3940);t.exports=function(t,e,r,i){var s=!r;r||(r={});for(var a=-1,u=e.length;++a<u;){var c=e[a],l=i?i(r[c],t[c],c,r,t):void 0;void 0===l&&(l=t[c]),s?o(r,c,l):n(r,c,l)}return r}},7680:function(t,e,r){var n=r(752),o=r(633);t.exports=function(t,e){return n(t,o(t),e)}},9987:function(t,e,r){var n=r(752),o=r(2680);t.exports=function(t,e){return n(t,o(t),e)}},4019:function(t,e,r){var n=r(7772)["__core-js_shared__"];t.exports=n},3043:function(t,e,r){var n=r(8761),o=function(){try{var t=n(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();t.exports=o},1242:function(t,e,r){var n="object"==typeof r.g&&r.g&&r.g.Object===Object&&r.g;t.exports=n},3483:function(t,e,r){var n=r(1897),o=r(633),i=r(249);t.exports=function(t){return n(t,i,o)}},6939:function(t,e,r){var n=r(1897),o=r(2680),i=r(8582);t.exports=function(t){return n(t,i,o)}},7937:function(t,e,r){var n=r(8304);t.exports=function(t,e){var r=t.__data__;return n(e)?r["string"==typeof e?"string":"hash"]:r.map}},8761:function(t,e,r){var n=r(6840),o=r(8109);t.exports=function(t,e){var r=o(t,e);return n(r)?r:void 0}},7353:function(t,e,r){var n=r(241)(Object.getPrototypeOf,Object);t.exports=n},2107:function(t,e,r){var n=r(857),o=Object.prototype,i=o.hasOwnProperty,s=o.toString,a=n?n.toStringTag:void 0;t.exports=function(t){var e=i.call(t,a),r=t[a];try{t[a]=void 0;var n=!0}catch(t){}var o=s.call(t);return n&&(e?t[a]=r:delete t[a]),o}},633:function(t,e,r){var n=r(7552),o=r(981),i=Object.prototype.propertyIsEnumerable,s=Object.getOwnPropertySymbols,a=s?function(t){return null==t?[]:(t=Object(t),n(s(t),(function(e){return i.call(t,e)})))}:o;t.exports=a},2680:function(t,e,r){var n=r(5067),o=r(7353),i=r(633),s=r(981),a=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)n(e,i(t)),t=o(t);return e}:s;t.exports=a},940:function(t,e,r){var n=r(9515),o=r(326),i=r(2760),s=r(2143),a=r(3215),u=r(3366),c=r(7035),l="[object Map]",f="[object Promise]",h="[object Set]",d="[object WeakMap]",p="[object DataView]",y=c(n),v=c(o),g=c(i),m=c(s),b=c(a),w=u;(n&&w(new n(new ArrayBuffer(1)))!=p||o&&w(new o)!=l||i&&w(i.resolve())!=f||s&&w(new s)!=h||a&&w(new a)!=d)&&(w=function(t){var e=u(t),r="[object Object]"==e?t.constructor:void 0,n=r?c(r):"";if(n)switch(n){case y:return p;case v:return l;case g:return f;case m:return h;case b:return d}return e}),t.exports=w},8109:function(t){t.exports=function(t,e){return null==t?void 0:t[e]}},2118:function(t,e,r){var n=r(9191);t.exports=function(){this.__data__=n?n(null):{},this.size=0}},6909:function(t){t.exports=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}},8138:function(t,e,r){var n=r(9191),o=Object.prototype.hasOwnProperty;t.exports=function(t){var e=this.__data__;if(n){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return o.call(e,t)?e[t]:void 0}},4174:function(t,e,r){var n=r(9191),o=Object.prototype.hasOwnProperty;t.exports=function(t){var e=this.__data__;return n?void 0!==e[t]:o.call(e,t)}},7942:function(t,e,r){var n=r(9191);t.exports=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=n&&void 0===e?"__lodash_hash_undefined__":e,this}},9917:function(t){var e=Object.prototype.hasOwnProperty;t.exports=function(t){var r=t.length,n=new t.constructor(r);return r&&"string"==typeof t[0]&&e.call(t,"index")&&(n.index=t.index,n.input=t.input),n}},8222:function(t,e,r){var n=r(9882),o=r(4727),i=r(6058),s=r(169),a=r(6190);t.exports=function(t,e,r){var u=t.constructor;switch(e){case"[object ArrayBuffer]":return n(t);case"[object Boolean]":case"[object Date]":return new u(+t);case"[object DataView]":return o(t,r);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return a(t,r);case"[object Map]":case"[object Set]":return new u;case"[object Number]":case"[object String]":return new u(t);case"[object RegExp]":return i(t);case"[object Symbol]":return s(t)}}},8725:function(t,e,r){var n=r(9413),o=r(7353),i=r(6001);t.exports=function(t){return"function"!=typeof t.constructor||i(t)?{}:n(o(t))}},9045:function(t){var e=/^(?:0|[1-9]\d*)$/;t.exports=function(t,r){var n=typeof t;return!!(r=null==r?9007199254740991:r)&&("number"==n||"symbol"!=n&&e.test(t))&&t>-1&&t%1==0&&t<r}},1401:function(t,e,r){var n=r(6152),o=r(4795),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;t.exports=function(t,e){if(n(t))return!1;var r=typeof t;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!o(t))||s.test(t)||!i.test(t)||null!=e&&t in Object(e)}},8304:function(t){t.exports=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}},7394:function(t,e,r){var n,o=r(4019),i=(n=/[^.]+$/.exec(o&&o.keys&&o.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"";t.exports=function(t){return!!i&&i in t}},6001:function(t){var e=Object.prototype;t.exports=function(t){var r=t&&t.constructor;return t===("function"==typeof r&&r.prototype||e)}},3945:function(t){t.exports=function(){this.__data__=[],this.size=0}},1846:function(t,e,r){var n=r(2218),o=Array.prototype.splice;t.exports=function(t){var e=this.__data__,r=n(e,t);return!(r<0||(r==e.length-1?e.pop():o.call(e,r,1),--this.size,0))}},8028:function(t,e,r){var n=r(2218);t.exports=function(t){var e=this.__data__,r=n(e,t);return r<0?void 0:e[r][1]}},2344:function(t,e,r){var n=r(2218);t.exports=function(t){return n(this.__data__,t)>-1}},4769:function(t,e,r){var n=r(2218);t.exports=function(t,e){var r=this.__data__,o=n(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}},2411:function(t,e,r){var n=r(9612),o=r(235),i=r(326);t.exports=function(){this.size=0,this.__data__={hash:new n,map:new(i||o),string:new n}}},6417:function(t,e,r){var n=r(7937);t.exports=function(t){var e=n(this,t).delete(t);return this.size-=e?1:0,e}},6928:function(t,e,r){var n=r(7937);t.exports=function(t){return n(this,t).get(t)}},9493:function(t,e,r){var n=r(7937);t.exports=function(t){return n(this,t).has(t)}},4150:function(t,e,r){var n=r(7937);t.exports=function(t,e){var r=n(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}},7777:function(t,e,r){var n=r(733);t.exports=function(t){var e=n(t,(function(t){return 500===r.size&&r.clear(),t})),r=e.cache;return e}},9191:function(t,e,r){var n=r(8761)(Object,"create");t.exports=n},4248:function(t,e,r){var n=r(241)(Object.keys,Object);t.exports=n},2966:function(t){t.exports=function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}},4146:function(t,e,r){t=r.nmd(t);var n=r(1242),o=e&&!e.nodeType&&e,i=o&&t&&!t.nodeType&&t,s=i&&i.exports===o&&n.process,a=function(){try{return i&&i.require&&i.require("util").types||s&&s.binding&&s.binding("util")}catch(t){}}();t.exports=a},7157:function(t){var e=Object.prototype.toString;t.exports=function(t){return e.call(t)}},241:function(t){t.exports=function(t,e){return function(r){return t(e(r))}}},2721:function(t,e,r){var n=r(3324),o=r(9872);t.exports=function(t,e){return e.length<2?t:n(t,o(e,0,-1))}},7772:function(t,e,r){var n=r(1242),o="object"==typeof self&&self&&self.Object===Object&&self,i=n||o||Function("return this")();t.exports=i},5243:function(t,e,r){var n=r(235);t.exports=function(){this.__data__=new n,this.size=0}},2858:function(t){t.exports=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}},4417:function(t){t.exports=function(t){return this.__data__.get(t)}},8605:function(t){t.exports=function(t){return this.__data__.has(t)}},1418:function(t,e,r){var n=r(235),o=r(326),i=r(6738);t.exports=function(t,e){var r=this.__data__;if(r instanceof n){var s=r.__data__;if(!o||s.length<199)return s.push([t,e]),this.size=++r.size,this;r=this.__data__=new i(s)}return r.set(t,e),this.size=r.size,this}},4452:function(t,e,r){var n=r(7777),o=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,i=/\\(\\)?/g,s=n((function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(o,(function(t,r,n,o){e.push(n?o.replace(i,"$1"):r||t)})),e}));t.exports=s},3812:function(t,e,r){var n=r(4795);t.exports=function(t){if("string"==typeof t||n(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}},7035:function(t){var e=Function.prototype.toString;t.exports=function(t){if(null!=t){try{return e.call(t)}catch(t){}try{return t+""}catch(t){}}return""}},9850:function(t,e,r){var n=r(8874);t.exports=function(t){return n(t,5)}},1225:function(t){t.exports=function(t,e){return t===e||t!=t&&e!=e}},9631:function(t,e,r){var n=r(5183),o=r(5125),i=Object.prototype,s=i.hasOwnProperty,a=i.propertyIsEnumerable,u=n(function(){return arguments}())?n:function(t){return o(t)&&s.call(t,"callee")&&!a.call(t,"callee")};t.exports=u},6152:function(t){var e=Array.isArray;t.exports=e},7878:function(t,e,r){var n=r(1049),o=r(1158);t.exports=function(t){return null!=t&&o(t.length)&&!n(t)}},3226:function(t,e,r){t=r.nmd(t);var n=r(7772),o=r(6330),i=e&&!e.nodeType&&e,s=i&&t&&!t.nodeType&&t,a=s&&s.exports===i?n.Buffer:void 0,u=(a?a.isBuffer:void 0)||o;t.exports=u},1049:function(t,e,r){var n=r(3366),o=r(9259);t.exports=function(t){if(!o(t))return!1;var e=n(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}},1158:function(t){t.exports=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}},4714:function(t,e,r){var n=r(4511),o=r(7826),i=r(4146),s=i&&i.isMap,a=s?o(s):n;t.exports=a},9259:function(t){t.exports=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}},5125:function(t){t.exports=function(t){return null!=t&&"object"==typeof t}},3679:function(t,e,r){var n=r(8436),o=r(7826),i=r(4146),s=i&&i.isSet,a=s?o(s):n;t.exports=a},4795:function(t,e,r){var n=r(3366),o=r(5125);t.exports=function(t){return"symbol"==typeof t||o(t)&&"[object Symbol]"==n(t)}},7598:function(t,e,r){var n=r(5522),o=r(7826),i=r(4146),s=i&&i.isTypedArray,a=s?o(s):n;t.exports=a},249:function(t,e,r){var n=r(1634),o=r(6411),i=r(7878);t.exports=function(t){return i(t)?n(t):o(t)}},8582:function(t,e,r){var n=r(1634),o=r(8390),i=r(7878);t.exports=function(t){return i(t)?n(t,!0):o(t)}},6974:function(t){t.exports=function(t){var e=null==t?0:t.length;return e?t[e-1]:void 0}},733:function(t,e,r){var n=r(6738);function o(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var r=function(){var n=arguments,o=e?e.apply(this,n):n[0],i=r.cache;if(i.has(o))return i.get(o);var s=t.apply(this,n);return r.cache=i.set(o,s)||i,s};return r.cache=new(o.Cache||n),r}o.Cache=n,t.exports=o},6765:function(t,e,r){var n=r(2857);t.exports=function(t,e,r){return null==t?t:n(t,e,r)}},981:function(t){t.exports=function(){return[]}},6330:function(t){t.exports=function(){return!1}},6188:function(t,e,r){var n=r(1054);t.exports=function(t){return null==t?"":n(t)}},7195:function(t,e,r){var n=r(9078);t.exports=function(t,e){return null==t||n(t,e)}},5047:function(t){var e=function(t){"use strict";var e,r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var i=e&&e.prototype instanceof g?e:g,s=Object.create(i.prototype),a=new x(n||[]);return o(s,"_invoke",{value:T(t,r,a)}),s}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function g(){}function m(){}function b(){}var w={};c(w,s,(function(){return this}));var _=Object.getPrototypeOf,S=_&&_(_(C([])));S&&S!==r&&n.call(S,s)&&(w=S);var E=b.prototype=g.prototype=Object.create(w);function I(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(o,i,s,a){var u=f(t[o],t,i);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,s,a)}),(function(t){r("throw",t,s,a)})):e.resolve(l).then((function(t){c.value=t,s(c)}),(function(t){return r("throw",t,s,a)}))}a(u.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function T(t,r,n){var o=h;return function(i,s){if(o===p)throw new Error("Generator is already running");if(o===y){if("throw"===i)throw s;return{value:e,done:!0}}for(n.method=i,n.arg=s;;){var a=n.delegate;if(a){var u=R(a,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=p;var c=f(t,r,n);if("normal"===c.type){if(o=n.done?y:d,c.arg===v)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(o=y,n.method="throw",n.arg=c.arg)}}}function R(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,R(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var i=f(o,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,v;var s=i.arg;return s?s.done?(r[t.resultName]=s.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,v):s:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function x(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function C(t){if(null!=t){var r=t[s];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}throw new TypeError(typeof t+" is not iterable")}return m.prototype=b,o(E,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:m,configurable:!0}),m.displayName=c(b,u,"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,b):(t.__proto__=b,c(t,u,"GeneratorFunction")),t.prototype=Object.create(E),t},t.awrap=function(t){return{__await:t}},I(O.prototype),c(O.prototype,a,(function(){return this})),t.AsyncIterator=O,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var s=new O(l(e,r,n,o),i);return t.isGeneratorFunction(r)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},I(E),c(E,u,"Generator"),c(E,s,(function(){return this})),c(E,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=C,x.prototype={constructor:x,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(P),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=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 r=this;function o(n,o){return a.type="throw",a.arg=t,r.next=n,o&&(r.method="next",r.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 u=n.call(s,"catchLoc"),c=n.call(s,"finallyLoc");if(u&&c){if(this.prev<s.catchLoc)return o(s.catchLoc,!0);if(this.prev<s.finallyLoc)return o(s.finallyLoc)}else if(u){if(this.prev<s.catchLoc)return o(s.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return o(s.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.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,v):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),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),P(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;P(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:C(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),v}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}},4410:function(t,e,r){var n,o;void 0===(o="function"==typeof(n=function(){"use strict";var t=void 0!==r.g?r.g:self;if(void 0!==t.TextEncoder&&void 0!==t.TextDecoder)return{TextEncoder:t.TextEncoder,TextDecoder:t.TextDecoder};var e=["utf8","utf-8","unicode-1-1-utf-8"];return{TextEncoder:function(t){if(e.indexOf(t)<0&&null!=t)throw new RangeError("Invalid encoding type. Only utf-8 is supported");this.encoding="utf-8",this.encode=function(t){if("string"!=typeof t)throw new TypeError("passed argument must be of type string");var e=unescape(encodeURIComponent(t)),r=new Uint8Array(e.length);return e.split("").forEach((function(t,e){r[e]=t.charCodeAt(0)})),r}},TextDecoder:function(t,r){if(e.indexOf(t)<0&&null!=t)throw new RangeError("Invalid encoding type. Only utf-8 is supported");if(this.encoding="utf-8",this.ignoreBOM=!1,this.fatal=void 0!==r&&"fatal"in r&&r.fatal,"boolean"!=typeof this.fatal)throw new TypeError("fatal flag must be boolean");this.decode=function(t,e){if(void 0===t)return"";if("boolean"!=typeof(void 0!==e&&"stream"in e&&e.stream))throw new TypeError("stream option must be boolean");if(ArrayBuffer.isView(t)){var r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength),n=new Array(r.length);return r.forEach((function(t,e){n[e]=String.fromCharCode(t)})),decodeURIComponent(escape(n.join("")))}throw new TypeError("passed argument must be an array buffer view")}}}})?n.apply(e,[]):n)||(t.exports=o)},5993:function(t,e,r){"use strict";function n(){}function o(t){return"object"==typeof t&&null!==t||"function"==typeof t}r.d(e,{GJ:function(){return rn},Pz:function(){return Lr}});const i=n;function s(t,e){try{Object.defineProperty(t,"name",{value:e,configurable:!0})}catch(t){}}const a=Promise,u=Promise.resolve.bind(a),c=Promise.prototype.then,l=Promise.reject.bind(a),f=u;function h(t){return new a(t)}function d(t){return h((e=>e(t)))}function p(t){return l(t)}function y(t,e,r){return c.call(t,e,r)}function v(t,e,r){y(y(t,e,r),void 0,i)}function g(t,e){v(t,e)}function m(t,e){v(t,void 0,e)}function b(t,e,r){return y(t,e,r)}function w(t){y(t,void 0,i)}let _=t=>{if("function"==typeof queueMicrotask)_=queueMicrotask;else{const t=d(void 0);_=e=>y(t,e)}return _(t)};function S(t,e,r){if("function"!=typeof t)throw new TypeError("Argument is not a function");return Function.prototype.apply.call(t,e,r)}function E(t,e,r){try{return d(S(t,e,r))}catch(t){return p(t)}}class I{constructor(){this._cursor=0,this._size=0,this._front={_elements:[],_next:void 0},this._back=this._front,this._cursor=0,this._size=0}get length(){return this._size}push(t){const e=this._back;let r=e;16383===e._elements.length&&(r={_elements:[],_next:void 0}),e._elements.push(t),r!==e&&(this._back=r,e._next=r),++this._size}shift(){const t=this._front;let e=t;const r=this._cursor;let n=r+1;const o=t._elements,i=o[r];return 16384===n&&(e=t._next,n=0),--this._size,this._cursor=n,t!==e&&(this._front=e),o[r]=void 0,i}forEach(t){let e=this._cursor,r=this._front,n=r._elements;for(;!(e===n.length&&void 0===r._next||e===n.length&&(r=r._next,n=r._elements,e=0,0===n.length));)t(n[e]),++e}peek(){const t=this._front,e=this._cursor;return t._elements[e]}}const O=Symbol("[[AbortSteps]]"),T=Symbol("[[ErrorSteps]]"),R=Symbol("[[CancelSteps]]"),A=Symbol("[[PullSteps]]"),P=Symbol("[[ReleaseSteps]]");function x(t,e){t._ownerReadableStream=e,e._reader=t,"readable"===e._state?j(t):"closed"===e._state?function(t){j(t),D(t)}(t):U(t,e._storedError)}function C(t,e){return Mr(t._ownerReadableStream,e)}function N(t){const e=t._ownerReadableStream;"readable"===e._state?k(t,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")):function(t){U(t,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness"))}(t),e._readableStreamController[P](),e._reader=void 0,t._ownerReadableStream=void 0}function L(t){return new TypeError("Cannot "+t+" a stream using a released reader")}function j(t){t._closedPromise=h(((e,r)=>{t._closedPromise_resolve=e,t._closedPromise_reject=r}))}function U(t,e){j(t),k(t,e)}function k(t,e){void 0!==t._closedPromise_reject&&(w(t._closedPromise),t._closedPromise_reject(e),t._closedPromise_resolve=void 0,t._closedPromise_reject=void 0)}function D(t){void 0!==t._closedPromise_resolve&&(t._closedPromise_resolve(void 0),t._closedPromise_resolve=void 0,t._closedPromise_reject=void 0)}const q=Number.isFinite||function(t){return"number"==typeof t&&isFinite(t)},M=Math.trunc||function(t){return t<0?Math.ceil(t):Math.floor(t)};function B(t,e){if(void 0!==t&&"object"!=typeof(r=t)&&"function"!=typeof r)throw new TypeError(`${e} is not an object.`);var r}function W(t,e){if("function"!=typeof t)throw new TypeError(`${e} is not a function.`)}function F(t,e){if(!function(t){return"object"==typeof t&&null!==t||"function"==typeof t}(t))throw new TypeError(`${e} is not an object.`)}function V(t,e,r){if(void 0===t)throw new TypeError(`Parameter ${e} is required in '${r}'.`)}function H(t,e,r){if(void 0===t)throw new TypeError(`${e} is required in '${r}'.`)}function G(t){return Number(t)}function $(t){return 0===t?0:t}function K(t,e){const r=Number.MAX_SAFE_INTEGER;let n=Number(t);if(n=$(n),!q(n))throw new TypeError(`${e} is not a finite number`);if(n=function(t){return $(M(t))}(n),n<0||n>r)throw new TypeError(`${e} is outside the accepted range of 0 to ${r}, inclusive`);return q(n)&&0!==n?n:0}function z(t,e){if(!Dr(t))throw new TypeError(`${e} is not a ReadableStream.`)}function J(t){return new tt(t)}function Y(t,e){t._reader._readRequests.push(e)}function Q(t,e,r){const n=t._reader._readRequests.shift();r?n._closeSteps():n._chunkSteps(e)}function Z(t){return t._reader._readRequests.length}function X(t){const e=t._reader;return void 0!==e&&!!et(e)}class tt{constructor(t){if(V(t,1,"ReadableStreamDefaultReader"),z(t,"First parameter"),qr(t))throw new TypeError("This stream has already been locked for exclusive reading by another reader");x(this,t),this._readRequests=new I}get closed(){return et(this)?this._closedPromise:p(ot("closed"))}cancel(t=void 0){return et(this)?void 0===this._ownerReadableStream?p(L("cancel")):C(this,t):p(ot("cancel"))}read(){if(!et(this))return p(ot("read"));if(void 0===this._ownerReadableStream)return p(L("read from"));let t,e;const r=h(((r,n)=>{t=r,e=n}));return rt(this,{_chunkSteps:e=>t({value:e,done:!1}),_closeSteps:()=>t({value:void 0,done:!0}),_errorSteps:t=>e(t)}),r}releaseLock(){if(!et(this))throw ot("releaseLock");void 0!==this._ownerReadableStream&&function(t){N(t),nt(t,new TypeError("Reader was released"))}(this)}}function et(t){return!!o(t)&&!!Object.prototype.hasOwnProperty.call(t,"_readRequests")&&t instanceof tt}function rt(t,e){const r=t._ownerReadableStream;r._disturbed=!0,"closed"===r._state?e._closeSteps():"errored"===r._state?e._errorSteps(r._storedError):r._readableStreamController[A](e)}function nt(t,e){const r=t._readRequests;t._readRequests=new I,r.forEach((t=>{t._errorSteps(e)}))}function ot(t){return new TypeError(`ReadableStreamDefaultReader.prototype.${t} can only be used on a ReadableStreamDefaultReader`)}var it,st,at;function ut(t){return t.slice()}function ct(t,e,r,n,o){new Uint8Array(t).set(new Uint8Array(r,n,o),e)}Object.defineProperties(tt.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),s(tt.prototype.cancel,"cancel"),s(tt.prototype.read,"read"),s(tt.prototype.releaseLock,"releaseLock"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(tt.prototype,Symbol.toStringTag,{value:"ReadableStreamDefaultReader",configurable:!0});let lt=t=>(lt="function"==typeof t.transfer?t=>t.transfer():"function"==typeof structuredClone?t=>structuredClone(t,{transfer:[t]}):t=>t,lt(t)),ft=t=>(ft="boolean"==typeof t.detached?t=>t.detached:t=>0===t.byteLength,ft(t));function ht(t,e,r){if(t.slice)return t.slice(e,r);const n=r-e,o=new ArrayBuffer(n);return ct(o,0,t,e,n),o}function dt(t,e){const r=t[e];if(null!=r){if("function"!=typeof r)throw new TypeError(`${String(e)} is not a function`);return r}}function pt(t){try{const e=t.done,r=t.value;return y(f(r),(t=>({done:e,value:t})))}catch(t){return p(t)}}const yt=null!==(at=null!==(it=Symbol.asyncIterator)&&void 0!==it?it:null===(st=Symbol.for)||void 0===st?void 0:st.call(Symbol,"Symbol.asyncIterator"))&&void 0!==at?at:"@@asyncIterator";function vt(t,e="sync",r){if(void 0===r)if("async"===e){if(void 0===(r=dt(t,yt)))return function(t){const e={next(){let e;try{e=gt(t)}catch(t){return p(t)}return pt(e)},return(e){let r;try{const n=dt(t.iterator,"return");if(void 0===n)return d({done:!0,value:e});r=S(n,t.iterator,[e])}catch(t){return p(t)}return o(r)?pt(r):p(new TypeError("The iterator.return() method must return an object"))}};return{iterator:e,nextMethod:e.next,done:!1}}(vt(t,"sync",dt(t,Symbol.iterator)))}else r=dt(t,Symbol.iterator);if(void 0===r)throw new TypeError("The object is not iterable");const n=S(r,t,[]);if(!o(n))throw new TypeError("The iterator method must return an object");return{iterator:n,nextMethod:n.next,done:!1}}function gt(t){const e=S(t.nextMethod,t.iterator,[]);if(!o(e))throw new TypeError("The iterator.next() method must return an object");return e}class mt{constructor(t,e){this._ongoingPromise=void 0,this._isFinished=!1,this._reader=t,this._preventCancel=e}next(){const t=()=>this._nextSteps();return this._ongoingPromise=this._ongoingPromise?b(this._ongoingPromise,t,t):t(),this._ongoingPromise}return(t){const e=()=>this._returnSteps(t);return this._ongoingPromise?b(this._ongoingPromise,e,e):e()}_nextSteps(){if(this._isFinished)return Promise.resolve({value:void 0,done:!0});const t=this._reader;let e,r;const n=h(((t,n)=>{e=t,r=n}));return rt(t,{_chunkSteps:t=>{this._ongoingPromise=void 0,_((()=>e({value:t,done:!1})))},_closeSteps:()=>{this._ongoingPromise=void 0,this._isFinished=!0,N(t),e({value:void 0,done:!0})},_errorSteps:e=>{this._ongoingPromise=void 0,this._isFinished=!0,N(t),r(e)}}),n}_returnSteps(t){if(this._isFinished)return Promise.resolve({value:t,done:!0});this._isFinished=!0;const e=this._reader;if(!this._preventCancel){const r=C(e,t);return N(e),b(r,(()=>({value:t,done:!0})))}return N(e),d({value:t,done:!0})}}const bt={next(){return wt(this)?this._asyncIteratorImpl.next():p(_t("next"))},return(t){return wt(this)?this._asyncIteratorImpl.return(t):p(_t("return"))},[yt](){return this}};function wt(t){if(!o(t))return!1;if(!Object.prototype.hasOwnProperty.call(t,"_asyncIteratorImpl"))return!1;try{return t._asyncIteratorImpl instanceof mt}catch(t){return!1}}function _t(t){return new TypeError(`ReadableStreamAsyncIterator.${t} can only be used on a ReadableSteamAsyncIterator`)}Object.defineProperty(bt,yt,{enumerable:!1});const St=Number.isNaN||function(t){return t!=t};function Et(t){const e=ht(t.buffer,t.byteOffset,t.byteOffset+t.byteLength);return new Uint8Array(e)}function It(t){const e=t._queue.shift();return t._queueTotalSize-=e.size,t._queueTotalSize<0&&(t._queueTotalSize=0),e.value}function Ot(t,e,r){if("number"!=typeof(n=r)||St(n)||n<0||r===1/0)throw new RangeError("Size must be a finite, non-NaN, non-negative number.");var n;t._queue.push({value:e,size:r}),t._queueTotalSize+=r}function Tt(t){t._queue=new I,t._queueTotalSize=0}function Rt(t){return t===DataView}class At{constructor(){throw new TypeError("Illegal constructor")}get view(){if(!Ct(this))throw re("view");return this._view}respond(t){if(!Ct(this))throw re("respond");if(V(t,1,"respond"),t=K(t,"First parameter"),void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");if(ft(this._view.buffer))throw new TypeError("The BYOB request's buffer has been detached and so cannot be used as a response");Xt(this._associatedReadableByteStreamController,t)}respondWithNewView(t){if(!Ct(this))throw re("respondWithNewView");if(V(t,1,"respondWithNewView"),!ArrayBuffer.isView(t))throw new TypeError("You can only respond with array buffer views");if(void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");if(ft(t.buffer))throw new TypeError("The given view's buffer has been detached and so cannot be used as a response");te(this._associatedReadableByteStreamController,t)}}Object.defineProperties(At.prototype,{respond:{enumerable:!0},respondWithNewView:{enumerable:!0},view:{enumerable:!0}}),s(At.prototype.respond,"respond"),s(At.prototype.respondWithNewView,"respondWithNewView"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(At.prototype,Symbol.toStringTag,{value:"ReadableStreamBYOBRequest",configurable:!0});class Pt{constructor(){throw new TypeError("Illegal constructor")}get byobRequest(){if(!xt(this))throw ne("byobRequest");return Qt(this)}get desiredSize(){if(!xt(this))throw ne("desiredSize");return Zt(this)}close(){if(!xt(this))throw ne("close");if(this._closeRequested)throw new TypeError("The stream has already been closed; do not close it again!");const t=this._controlledReadableByteStream._state;if("readable"!==t)throw new TypeError(`The stream (in ${t} state) is not in the readable state and cannot be closed`);Kt(this)}enqueue(t){if(!xt(this))throw ne("enqueue");if(V(t,1,"enqueue"),!ArrayBuffer.isView(t))throw new TypeError("chunk must be an array buffer view");if(0===t.byteLength)throw new TypeError("chunk must have non-zero byteLength");if(0===t.buffer.byteLength)throw new TypeError("chunk's buffer must have non-zero byteLength");if(this._closeRequested)throw new TypeError("stream is closed or draining");const e=this._controlledReadableByteStream._state;if("readable"!==e)throw new TypeError(`The stream (in ${e} state) is not in the readable state and cannot be enqueued to`);zt(this,t)}error(t=void 0){if(!xt(this))throw ne("error");Jt(this,t)}[R](t){Lt(this),Tt(this);const e=this._cancelAlgorithm(t);return $t(this),e}[A](t){const e=this._controlledReadableByteStream;if(this._queueTotalSize>0)return void Yt(this,t);const r=this._autoAllocateChunkSize;if(void 0!==r){let n;try{n=new ArrayBuffer(r)}catch(e){return void t._errorSteps(e)}const o={buffer:n,bufferByteLength:r,byteOffset:0,byteLength:r,bytesFilled:0,minimumFill:1,elementSize:1,viewConstructor:Uint8Array,readerType:"default"};this._pendingPullIntos.push(o)}Y(e,t),Nt(this)}[P](){if(this._pendingPullIntos.length>0){const t=this._pendingPullIntos.peek();t.readerType="none",this._pendingPullIntos=new I,this._pendingPullIntos.push(t)}}}function xt(t){return!!o(t)&&!!Object.prototype.hasOwnProperty.call(t,"_controlledReadableByteStream")&&t instanceof Pt}function Ct(t){return!!o(t)&&!!Object.prototype.hasOwnProperty.call(t,"_associatedReadableByteStreamController")&&t instanceof At}function Nt(t){const e=function(t){const e=t._controlledReadableByteStream;return"readable"===e._state&&(!t._closeRequested&&(!!t._started&&(!!(X(e)&&Z(e)>0)||(!!(ue(e)&&ae(e)>0)||Zt(t)>0))))}(t);e&&(t._pulling?t._pullAgain=!0:(t._pulling=!0,v(t._pullAlgorithm(),(()=>(t._pulling=!1,t._pullAgain&&(t._pullAgain=!1,Nt(t)),null)),(e=>(Jt(t,e),null)))))}function Lt(t){Ft(t),t._pendingPullIntos=new I}function jt(t,e){let r=!1;"closed"===t._state&&(r=!0);const n=Ut(e);"default"===e.readerType?Q(t,n,r):function(t,e,r){const n=t._reader._readIntoRequests.shift();r?n._closeSteps(e):n._chunkSteps(e)}(t,n,r)}function Ut(t){const e=t.bytesFilled,r=t.elementSize;return new t.viewConstructor(t.buffer,t.byteOffset,e/r)}function kt(t,e,r,n){t._queue.push({buffer:e,byteOffset:r,byteLength:n}),t._queueTotalSize+=n}function Dt(t,e,r,n){let o;try{o=ht(e,r,r+n)}catch(e){throw Jt(t,e),e}kt(t,o,0,n)}function qt(t,e){e.bytesFilled>0&&Dt(t,e.buffer,e.byteOffset,e.bytesFilled),Gt(t)}function Mt(t,e){const r=Math.min(t._queueTotalSize,e.byteLength-e.bytesFilled),n=e.bytesFilled+r;let o=r,i=!1;const s=n-n%e.elementSize;s>=e.minimumFill&&(o=s-e.bytesFilled,i=!0);const a=t._queue;for(;o>0;){const r=a.peek(),n=Math.min(o,r.byteLength),i=e.byteOffset+e.bytesFilled;ct(e.buffer,i,r.buffer,r.byteOffset,n),r.byteLength===n?a.shift():(r.byteOffset+=n,r.byteLength-=n),t._queueTotalSize-=n,Bt(0,n,e),o-=n}return i}function Bt(t,e,r){r.bytesFilled+=e}function Wt(t){0===t._queueTotalSize&&t._closeRequested?($t(t),Br(t._controlledReadableByteStream)):Nt(t)}function Ft(t){null!==t._byobRequest&&(t._byobRequest._associatedReadableByteStreamController=void 0,t._byobRequest._view=null,t._byobRequest=null)}function Vt(t){for(;t._pendingPullIntos.length>0;){if(0===t._queueTotalSize)return;const e=t._pendingPullIntos.peek();Mt(t,e)&&(Gt(t),jt(t._controlledReadableByteStream,e))}}function Ht(t,e){const r=t._pendingPullIntos.peek();Ft(t),"closed"===t._controlledReadableByteStream._state?function(t,e){"none"===e.readerType&&Gt(t);const r=t._controlledReadableByteStream;if(ue(r))for(;ae(r)>0;)jt(r,Gt(t))}(t,r):function(t,e,r){if(Bt(0,e,r),"none"===r.readerType)return qt(t,r),void Vt(t);if(r.bytesFilled<r.minimumFill)return;Gt(t);const n=r.bytesFilled%r.elementSize;if(n>0){const e=r.byteOffset+r.bytesFilled;Dt(t,r.buffer,e-n,n)}r.bytesFilled-=n,jt(t._controlledReadableByteStream,r),Vt(t)}(t,e,r),Nt(t)}function Gt(t){return t._pendingPullIntos.shift()}function $t(t){t._pullAlgorithm=void 0,t._cancelAlgorithm=void 0}function Kt(t){const e=t._controlledReadableByteStream;if(!t._closeRequested&&"readable"===e._state)if(t._queueTotalSize>0)t._closeRequested=!0;else{if(t._pendingPullIntos.length>0){const e=t._pendingPullIntos.peek();if(e.bytesFilled%e.elementSize!=0){const e=new TypeError("Insufficient bytes to fill elements in the given buffer");throw Jt(t,e),e}}$t(t),Br(e)}}function zt(t,e){const r=t._controlledReadableByteStream;if(t._closeRequested||"readable"!==r._state)return;const{buffer:n,byteOffset:o,byteLength:i}=e;if(ft(n))throw new TypeError("chunk's buffer is detached and so cannot be enqueued");const s=lt(n);if(t._pendingPullIntos.length>0){const e=t._pendingPullIntos.peek();if(ft(e.buffer))throw new TypeError("The BYOB request's buffer has been detached and so cannot be filled with an enqueued chunk");Ft(t),e.buffer=lt(e.buffer),"none"===e.readerType&&qt(t,e)}X(r)?(function(t){const e=t._controlledReadableByteStream._reader;for(;e._readRequests.length>0;){if(0===t._queueTotalSize)return;Yt(t,e._readRequests.shift())}}(t),0===Z(r)?kt(t,s,o,i):(t._pendingPullIntos.length>0&&Gt(t),Q(r,new Uint8Array(s,o,i),!1))):ue(r)?(kt(t,s,o,i),Vt(t)):kt(t,s,o,i),Nt(t)}function Jt(t,e){const r=t._controlledReadableByteStream;"readable"===r._state&&(Lt(t),Tt(t),$t(t),Wr(r,e))}function Yt(t,e){const r=t._queue.shift();t._queueTotalSize-=r.byteLength,Wt(t);const n=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);e._chunkSteps(n)}function Qt(t){if(null===t._byobRequest&&t._pendingPullIntos.length>0){const e=t._pendingPullIntos.peek(),r=new Uint8Array(e.buffer,e.byteOffset+e.bytesFilled,e.byteLength-e.bytesFilled),n=Object.create(At.prototype);!function(t,e,r){t._associatedReadableByteStreamController=e,t._view=r}(n,t,r),t._byobRequest=n}return t._byobRequest}function Zt(t){const e=t._controlledReadableByteStream._state;return"errored"===e?null:"closed"===e?0:t._strategyHWM-t._queueTotalSize}function Xt(t,e){const r=t._pendingPullIntos.peek();if("closed"===t._controlledReadableByteStream._state){if(0!==e)throw new TypeError("bytesWritten must be 0 when calling respond() on a closed stream")}else{if(0===e)throw new TypeError("bytesWritten must be greater than 0 when calling respond() on a readable stream");if(r.bytesFilled+e>r.byteLength)throw new RangeError("bytesWritten out of range")}r.buffer=lt(r.buffer),Ht(t,e)}function te(t,e){const r=t._pendingPullIntos.peek();if("closed"===t._controlledReadableByteStream._state){if(0!==e.byteLength)throw new TypeError("The view's length must be 0 when calling respondWithNewView() on a closed stream")}else if(0===e.byteLength)throw new TypeError("The view's length must be greater than 0 when calling respondWithNewView() on a readable stream");if(r.byteOffset+r.bytesFilled!==e.byteOffset)throw new RangeError("The region specified by view does not match byobRequest");if(r.bufferByteLength!==e.buffer.byteLength)throw new RangeError("The buffer of view has different capacity than byobRequest");if(r.bytesFilled+e.byteLength>r.byteLength)throw new RangeError("The region specified by view is larger than byobRequest");const n=e.byteLength;r.buffer=lt(e.buffer),Ht(t,n)}function ee(t,e,r,n,o,i,s){e._controlledReadableByteStream=t,e._pullAgain=!1,e._pulling=!1,e._byobRequest=null,e._queue=e._queueTotalSize=void 0,Tt(e),e._closeRequested=!1,e._started=!1,e._strategyHWM=i,e._pullAlgorithm=n,e._cancelAlgorithm=o,e._autoAllocateChunkSize=s,e._pendingPullIntos=new I,t._readableStreamController=e,v(d(r()),(()=>(e._started=!0,Nt(e),null)),(t=>(Jt(e,t),null)))}function re(t){return new TypeError(`ReadableStreamBYOBRequest.prototype.${t} can only be used on a ReadableStreamBYOBRequest`)}function ne(t){return new TypeError(`ReadableByteStreamController.prototype.${t} can only be used on a ReadableByteStreamController`)}function oe(t,e){if("byob"!=(t=`${t}`))throw new TypeError(`${e} '${t}' is not a valid enumeration value for ReadableStreamReaderMode`);return t}function ie(t){return new ce(t)}function se(t,e){t._reader._readIntoRequests.push(e)}function ae(t){return t._reader._readIntoRequests.length}function ue(t){const e=t._reader;return void 0!==e&&!!le(e)}Object.defineProperties(Pt.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},byobRequest:{enumerable:!0},desiredSize:{enumerable:!0}}),s(Pt.prototype.close,"close"),s(Pt.prototype.enqueue,"enqueue"),s(Pt.prototype.error,"error"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Pt.prototype,Symbol.toStringTag,{value:"ReadableByteStreamController",configurable:!0});class ce{constructor(t){if(V(t,1,"ReadableStreamBYOBReader"),z(t,"First parameter"),qr(t))throw new TypeError("This stream has already been locked for exclusive reading by another reader");if(!xt(t._readableStreamController))throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");x(this,t),this._readIntoRequests=new I}get closed(){return le(this)?this._closedPromise:p(de("closed"))}cancel(t=void 0){return le(this)?void 0===this._ownerReadableStream?p(L("cancel")):C(this,t):p(de("cancel"))}read(t,e={}){if(!le(this))return p(de("read"));if(!ArrayBuffer.isView(t))return p(new TypeError("view must be an array buffer view"));if(0===t.byteLength)return p(new TypeError("view must have non-zero byteLength"));if(0===t.buffer.byteLength)return p(new TypeError("view's buffer must have non-zero byteLength"));if(ft(t.buffer))return p(new TypeError("view's buffer has been detached"));let r;try{r=function(t,e){var r;return B(t,e),{min:K(null!==(r=null==t?void 0:t.min)&&void 0!==r?r:1,`${e} has member 'min' that`)}}(e,"options")}catch(t){return p(t)}const n=r.min;if(0===n)return p(new TypeError("options.min must be greater than 0"));if(function(t){return Rt(t.constructor)}(t)){if(n>t.byteLength)return p(new RangeError("options.min must be less than or equal to view's byteLength"))}else if(n>t.length)return p(new RangeError("options.min must be less than or equal to view's length"));if(void 0===this._ownerReadableStream)return p(L("read from"));let o,i;const s=h(((t,e)=>{o=t,i=e}));return fe(this,t,n,{_chunkSteps:t=>o({value:t,done:!1}),_closeSteps:t=>o({value:t,done:!0}),_errorSteps:t=>i(t)}),s}releaseLock(){if(!le(this))throw de("releaseLock");void 0!==this._ownerReadableStream&&function(t){N(t),he(t,new TypeError("Reader was released"))}(this)}}function le(t){return!!o(t)&&!!Object.prototype.hasOwnProperty.call(t,"_readIntoRequests")&&t instanceof ce}function fe(t,e,r,n){const o=t._ownerReadableStream;o._disturbed=!0,"errored"===o._state?n._errorSteps(o._storedError):function(t,e,r,n){const o=t._controlledReadableByteStream,i=e.constructor,s=function(t){return Rt(t)?1:t.BYTES_PER_ELEMENT}(i),{byteOffset:a,byteLength:u}=e,c=r*s;let l;try{l=lt(e.buffer)}catch(t){return void n._errorSteps(t)}const f={buffer:l,bufferByteLength:l.byteLength,byteOffset:a,byteLength:u,bytesFilled:0,minimumFill:c,elementSize:s,viewConstructor:i,readerType:"byob"};if(t._pendingPullIntos.length>0)return t._pendingPullIntos.push(f),void se(o,n);if("closed"!==o._state){if(t._queueTotalSize>0){if(Mt(t,f)){const e=Ut(f);return Wt(t),void n._chunkSteps(e)}if(t._closeRequested){const e=new TypeError("Insufficient bytes to fill elements in the given buffer");return Jt(t,e),void n._errorSteps(e)}}t._pendingPullIntos.push(f),se(o,n),Nt(t)}else{const t=new i(f.buffer,f.byteOffset,0);n._closeSteps(t)}}(o._readableStreamController,e,r,n)}function he(t,e){const r=t._readIntoRequests;t._readIntoRequests=new I,r.forEach((t=>{t._errorSteps(e)}))}function de(t){return new TypeError(`ReadableStreamBYOBReader.prototype.${t} can only be used on a ReadableStreamBYOBReader`)}function pe(t,e){const{highWaterMark:r}=t;if(void 0===r)return e;if(St(r)||r<0)throw new RangeError("Invalid highWaterMark");return r}function ye(t){const{size:e}=t;return e||(()=>1)}function ve(t,e){B(t,e);const r=null==t?void 0:t.highWaterMark,n=null==t?void 0:t.size;return{highWaterMark:void 0===r?void 0:G(r),size:void 0===n?void 0:ge(n,`${e} has member 'size' that`)}}function ge(t,e){return W(t,e),e=>G(t(e))}function me(t,e,r){return W(t,r),r=>E(t,e,[r])}function be(t,e,r){return W(t,r),()=>E(t,e,[])}function we(t,e,r){return W(t,r),r=>S(t,e,[r])}function _e(t,e,r){return W(t,r),(r,n)=>E(t,e,[r,n])}function Se(t,e){if(!Re(t))throw new TypeError(`${e} is not a WritableStream.`)}Object.defineProperties(ce.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),s(ce.prototype.cancel,"cancel"),s(ce.prototype.read,"read"),s(ce.prototype.releaseLock,"releaseLock"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(ce.prototype,Symbol.toStringTag,{value:"ReadableStreamBYOBReader",configurable:!0});const Ee="function"==typeof AbortController;class Ie{constructor(t={},e={}){void 0===t?t=null:F(t,"First parameter");const r=ve(e,"Second parameter"),n=function(t,e){B(t,e);const r=null==t?void 0:t.abort,n=null==t?void 0:t.close,o=null==t?void 0:t.start,i=null==t?void 0:t.type,s=null==t?void 0:t.write;return{abort:void 0===r?void 0:me(r,t,`${e} has member 'abort' that`),close:void 0===n?void 0:be(n,t,`${e} has member 'close' that`),start:void 0===o?void 0:we(o,t,`${e} has member 'start' that`),write:void 0===s?void 0:_e(s,t,`${e} has member 'write' that`),type:i}}(t,"First parameter");if(Te(this),void 0!==n.type)throw new RangeError("Invalid type is specified");const o=ye(r);!function(t,e,r,n){const o=Object.create(He.prototype);let i,s,a,u;i=void 0!==e.start?()=>e.start(o):()=>{},s=void 0!==e.write?t=>e.write(t,o):()=>d(void 0),a=void 0!==e.close?()=>e.close():()=>d(void 0),u=void 0!==e.abort?t=>e.abort(t):()=>d(void 0),$e(t,o,i,s,a,u,r,n)}(this,n,pe(r,1),o)}get locked(){if(!Re(this))throw Xe("locked");return Ae(this)}abort(t=void 0){return Re(this)?Ae(this)?p(new TypeError("Cannot abort a stream that already has a writer")):Pe(this,t):p(Xe("abort"))}close(){return Re(this)?Ae(this)?p(new TypeError("Cannot close a stream that already has a writer")):je(this)?p(new TypeError("Cannot close an already-closing stream")):xe(this):p(Xe("close"))}getWriter(){if(!Re(this))throw Xe("getWriter");return Oe(this)}}function Oe(t){return new De(t)}function Te(t){t._state="writable",t._storedError=void 0,t._writer=void 0,t._writableStreamController=void 0,t._writeRequests=new I,t._inFlightWriteRequest=void 0,t._closeRequest=void 0,t._inFlightCloseRequest=void 0,t._pendingAbortRequest=void 0,t._backpressure=!1}function Re(t){return!!o(t)&&!!Object.prototype.hasOwnProperty.call(t,"_writableStreamController")&&t instanceof Ie}function Ae(t){return void 0!==t._writer}function Pe(t,e){var r;if("closed"===t._state||"errored"===t._state)return d(void 0);t._writableStreamController._abortReason=e,null===(r=t._writableStreamController._abortController)||void 0===r||r.abort(e);const n=t._state;if("closed"===n||"errored"===n)return d(void 0);if(void 0!==t._pendingAbortRequest)return t._pendingAbortRequest._promise;let o=!1;"erroring"===n&&(o=!0,e=void 0);const i=h(((r,n)=>{t._pendingAbortRequest={_promise:void 0,_resolve:r,_reject:n,_reason:e,_wasAlreadyErroring:o}}));return t._pendingAbortRequest._promise=i,o||Ne(t,e),i}function xe(t){const e=t._state;if("closed"===e||"errored"===e)return p(new TypeError(`The stream (in ${e} state) is not in the writable state and cannot be closed`));const r=h(((e,r)=>{const n={_resolve:e,_reject:r};t._closeRequest=n})),n=t._writer;var o;return void 0!==n&&t._backpressure&&"writable"===e&&fr(n),Ot(o=t._writableStreamController,Ve,0),Je(o),r}function Ce(t,e){"writable"!==t._state?Le(t):Ne(t,e)}function Ne(t,e){const r=t._writableStreamController;t._state="erroring",t._storedError=e;const n=t._writer;void 0!==n&&Be(n,e),!function(t){return void 0!==t._inFlightWriteRequest||void 0!==t._inFlightCloseRequest}(t)&&r._started&&Le(t)}function Le(t){t._state="errored",t._writableStreamController[T]();const e=t._storedError;if(t._writeRequests.forEach((t=>{t._reject(e)})),t._writeRequests=new I,void 0===t._pendingAbortRequest)return void Ue(t);const r=t._pendingAbortRequest;if(t._pendingAbortRequest=void 0,r._wasAlreadyErroring)return r._reject(e),void Ue(t);v(t._writableStreamController[O](r._reason),(()=>(r._resolve(),Ue(t),null)),(e=>(r._reject(e),Ue(t),null)))}function je(t){return void 0!==t._closeRequest||void 0!==t._inFlightCloseRequest}function Ue(t){void 0!==t._closeRequest&&(t._closeRequest._reject(t._storedError),t._closeRequest=void 0);const e=t._writer;void 0!==e&&ir(e,t._storedError)}function ke(t,e){const r=t._writer;void 0!==r&&e!==t._backpressure&&(e?function(t){ar(t)}(r):fr(r)),t._backpressure=e}Object.defineProperties(Ie.prototype,{abort:{enumerable:!0},close:{enumerable:!0},getWriter:{enumerable:!0},locked:{enumerable:!0}}),s(Ie.prototype.abort,"abort"),s(Ie.prototype.close,"close"),s(Ie.prototype.getWriter,"getWriter"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Ie.prototype,Symbol.toStringTag,{value:"WritableStream",configurable:!0});class De{constructor(t){if(V(t,1,"WritableStreamDefaultWriter"),Se(t,"First parameter"),Ae(t))throw new TypeError("This stream has already been locked for exclusive writing by another writer");this._ownerWritableStream=t,t._writer=this;const e=t._state;if("writable"===e)!je(t)&&t._backpressure?ar(this):cr(this),nr(this);else if("erroring"===e)ur(this,t._storedError),nr(this);else if("closed"===e)cr(this),nr(this),sr(this);else{const e=t._storedError;ur(this,e),or(this,e)}}get closed(){return qe(this)?this._closedPromise:p(er("closed"))}get desiredSize(){if(!qe(this))throw er("desiredSize");if(void 0===this._ownerWritableStream)throw rr("desiredSize");return function(t){const e=t._ownerWritableStream,r=e._state;return"errored"===r||"erroring"===r?null:"closed"===r?0:ze(e._writableStreamController)}(this)}get ready(){return qe(this)?this._readyPromise:p(er("ready"))}abort(t=void 0){return qe(this)?void 0===this._ownerWritableStream?p(rr("abort")):function(t,e){return Pe(t._ownerWritableStream,e)}(this,t):p(er("abort"))}close(){if(!qe(this))return p(er("close"));const t=this._ownerWritableStream;return void 0===t?p(rr("close")):je(t)?p(new TypeError("Cannot close an already-closing stream")):Me(this)}releaseLock(){if(!qe(this))throw er("releaseLock");void 0!==this._ownerWritableStream&&We(this)}write(t=void 0){return qe(this)?void 0===this._ownerWritableStream?p(rr("write to")):Fe(this,t):p(er("write"))}}function qe(t){return!!o(t)&&!!Object.prototype.hasOwnProperty.call(t,"_ownerWritableStream")&&t instanceof De}function Me(t){return xe(t._ownerWritableStream)}function Be(t,e){"pending"===t._readyPromiseState?lr(t,e):function(t,e){ur(t,e)}(t,e)}function We(t){const e=t._ownerWritableStream,r=new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");Be(t,r),function(t,e){"pending"===t._closedPromiseState?ir(t,e):function(t,e){or(t,e)}(t,e)}(t,r),e._writer=void 0,t._ownerWritableStream=void 0}function Fe(t,e){const r=t._ownerWritableStream,n=r._writableStreamController,o=function(t,e){try{return t._strategySizeAlgorithm(e)}catch(e){return Ye(t,e),1}}(n,e);if(r!==t._ownerWritableStream)return p(rr("write to"));const i=r._state;if("errored"===i)return p(r._storedError);if(je(r)||"closed"===i)return p(new TypeError("The stream is closing or closed and cannot be written to"));if("erroring"===i)return p(r._storedError);const s=function(t){return h(((e,r)=>{const n={_resolve:e,_reject:r};t._writeRequests.push(n)}))}(r);return function(t,e,r){try{Ot(t,e,r)}catch(e){return void Ye(t,e)}const n=t._controlledWritableStream;je(n)||"writable"!==n._state||ke(n,Qe(t)),Je(t)}(n,e,o),s}Object.defineProperties(De.prototype,{abort:{enumerable:!0},close:{enumerable:!0},releaseLock:{enumerable:!0},write:{enumerable:!0},closed:{enumerable:!0},desiredSize:{enumerable:!0},ready:{enumerable:!0}}),s(De.prototype.abort,"abort"),s(De.prototype.close,"close"),s(De.prototype.releaseLock,"releaseLock"),s(De.prototype.write,"write"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(De.prototype,Symbol.toStringTag,{value:"WritableStreamDefaultWriter",configurable:!0});const Ve={};class He{constructor(){throw new TypeError("Illegal constructor")}get abortReason(){if(!Ge(this))throw tr("abortReason");return this._abortReason}get signal(){if(!Ge(this))throw tr("signal");if(void 0===this._abortController)throw new TypeError("WritableStreamDefaultController.prototype.signal is not supported");return this._abortController.signal}error(t=void 0){if(!Ge(this))throw tr("error");"writable"===this._controlledWritableStream._state&&Ze(this,t)}[O](t){const e=this._abortAlgorithm(t);return Ke(this),e}[T](){Tt(this)}}function Ge(t){return!!o(t)&&!!Object.prototype.hasOwnProperty.call(t,"_controlledWritableStream")&&t instanceof He}function $e(t,e,r,n,o,i,s,a){e._controlledWritableStream=t,t._writableStreamController=e,e._queue=void 0,e._queueTotalSize=void 0,Tt(e),e._abortReason=void 0,e._abortController=function(){if(Ee)return new AbortController}(),e._started=!1,e._strategySizeAlgorithm=a,e._strategyHWM=s,e._writeAlgorithm=n,e._closeAlgorithm=o,e._abortAlgorithm=i;const u=Qe(e);ke(t,u),v(d(r()),(()=>(e._started=!0,Je(e),null)),(r=>(e._started=!0,Ce(t,r),null)))}function Ke(t){t._writeAlgorithm=void 0,t._closeAlgorithm=void 0,t._abortAlgorithm=void 0,t._strategySizeAlgorithm=void 0}function ze(t){return t._strategyHWM-t._queueTotalSize}function Je(t){const e=t._controlledWritableStream;if(!t._started)return;if(void 0!==e._inFlightWriteRequest)return;if("erroring"===e._state)return void Le(e);if(0===t._queue.length)return;const r=t._queue.peek().value;r===Ve?function(t){const e=t._controlledWritableStream;(function(t){t._inFlightCloseRequest=t._closeRequest,t._closeRequest=void 0})(e),It(t);const r=t._closeAlgorithm();Ke(t),v(r,(()=>(function(t){t._inFlightCloseRequest._resolve(void 0),t._inFlightCloseRequest=void 0,"erroring"===t._state&&(t._storedError=void 0,void 0!==t._pendingAbortRequest&&(t._pendingAbortRequest._resolve(),t._pendingAbortRequest=void 0)),t._state="closed";const e=t._writer;void 0!==e&&sr(e)}(e),null)),(t=>(function(t,e){t._inFlightCloseRequest._reject(e),t._inFlightCloseRequest=void 0,void 0!==t._pendingAbortRequest&&(t._pendingAbortRequest._reject(e),t._pendingAbortRequest=void 0),Ce(t,e)}(e,t),null)))}(t):function(t,e){const r=t._controlledWritableStream;!function(t){t._inFlightWriteRequest=t._writeRequests.shift()}(r),v(t._writeAlgorithm(e),(()=>{!function(t){t._inFlightWriteRequest._resolve(void 0),t._inFlightWriteRequest=void 0}(r);const e=r._state;if(It(t),!je(r)&&"writable"===e){const e=Qe(t);ke(r,e)}return Je(t),null}),(e=>("writable"===r._state&&Ke(t),function(t,e){t._inFlightWriteRequest._reject(e),t._inFlightWriteRequest=void 0,Ce(t,e)}(r,e),null)))}(t,r)}function Ye(t,e){"writable"===t._controlledWritableStream._state&&Ze(t,e)}function Qe(t){return ze(t)<=0}function Ze(t,e){const r=t._controlledWritableStream;Ke(t),Ne(r,e)}function Xe(t){return new TypeError(`WritableStream.prototype.${t} can only be used on a WritableStream`)}function tr(t){return new TypeError(`WritableStreamDefaultController.prototype.${t} can only be used on a WritableStreamDefaultController`)}function er(t){return new TypeError(`WritableStreamDefaultWriter.prototype.${t} can only be used on a WritableStreamDefaultWriter`)}function rr(t){return new TypeError("Cannot "+t+" a stream using a released writer")}function nr(t){t._closedPromise=h(((e,r)=>{t._closedPromise_resolve=e,t._closedPromise_reject=r,t._closedPromiseState="pending"}))}function or(t,e){nr(t),ir(t,e)}function ir(t,e){void 0!==t._closedPromise_reject&&(w(t._closedPromise),t._closedPromise_reject(e),t._closedPromise_resolve=void 0,t._closedPromise_reject=void 0,t._closedPromiseState="rejected")}function sr(t){void 0!==t._closedPromise_resolve&&(t._closedPromise_resolve(void 0),t._closedPromise_resolve=void 0,t._closedPromise_reject=void 0,t._closedPromiseState="resolved")}function ar(t){t._readyPromise=h(((e,r)=>{t._readyPromise_resolve=e,t._readyPromise_reject=r})),t._readyPromiseState="pending"}function ur(t,e){ar(t),lr(t,e)}function cr(t){ar(t),fr(t)}function lr(t,e){void 0!==t._readyPromise_reject&&(w(t._readyPromise),t._readyPromise_reject(e),t._readyPromise_resolve=void 0,t._readyPromise_reject=void 0,t._readyPromiseState="rejected")}function fr(t){void 0!==t._readyPromise_resolve&&(t._readyPromise_resolve(void 0),t._readyPromise_resolve=void 0,t._readyPromise_reject=void 0,t._readyPromiseState="fulfilled")}Object.defineProperties(He.prototype,{abortReason:{enumerable:!0},signal:{enumerable:!0},error:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(He.prototype,Symbol.toStringTag,{value:"WritableStreamDefaultController",configurable:!0});const hr="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof global?global:void 0,dr=function(){const t=null==hr?void 0:hr.DOMException;return function(t){if("function"!=typeof t&&"object"!=typeof t)return!1;if("DOMException"!==t.name)return!1;try{return new t,!0}catch(t){return!1}}(t)?t:void 0}()||function(){const t=function(t,e){this.message=t||"",this.name=e||"Error",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)};return s(t,"DOMException"),t.prototype=Object.create(Error.prototype),Object.defineProperty(t.prototype,"constructor",{value:t,writable:!0,configurable:!0}),t}();function pr(t,e,r,o,i,s){const a=J(t),u=Oe(e);t._disturbed=!0;let c=!1,l=d(void 0);return h(((f,b)=>{let _;if(void 0!==s){if(_=()=>{const r=void 0!==s.reason?s.reason:new dr("Aborted","AbortError"),n=[];o||n.push((()=>"writable"===e._state?Pe(e,r):d(void 0))),i||n.push((()=>"readable"===t._state?Mr(t,r):d(void 0))),R((()=>Promise.all(n.map((t=>t())))),!0,r)},s.aborted)return void _();s.addEventListener("abort",_)}var S,E,I;if(T(t,a._closedPromise,(t=>(o?A(!0,t):R((()=>Pe(e,t)),!0,t),null))),T(e,u._closedPromise,(e=>(i?A(!0,e):R((()=>Mr(t,e)),!0,e),null))),S=t,E=a._closedPromise,I=()=>(r?A():R((()=>function(t){const e=t._ownerWritableStream,r=e._state;return je(e)||"closed"===r?d(void 0):"errored"===r?p(e._storedError):Me(t)}(u))),null),"closed"===S._state?I():g(E,I),je(e)||"closed"===e._state){const e=new TypeError("the destination writable stream closed before all data could be piped to it");i?A(!0,e):R((()=>Mr(t,e)),!0,e)}function O(){const t=l;return y(l,(()=>t!==l?O():void 0))}function T(t,e,r){"errored"===t._state?r(t._storedError):m(e,r)}function R(t,r,n){function o(){return v(t(),(()=>P(r,n)),(t=>P(!0,t))),null}c||(c=!0,"writable"!==e._state||je(e)?o():g(O(),o))}function A(t,r){c||(c=!0,"writable"!==e._state||je(e)?P(t,r):g(O(),(()=>P(t,r))))}function P(t,e){return We(u),N(a),void 0!==s&&s.removeEventListener("abort",_),t?b(e):f(void 0),null}w(h(((t,e)=>{!function r(o){o?t():y(c?d(!0):y(u._readyPromise,(()=>h(((t,e)=>{rt(a,{_chunkSteps:e=>{l=y(Fe(u,e),void 0,n),t(!1)},_closeSteps:()=>t(!0),_errorSteps:e})})))),r,e)}(!1)})))}))}class yr{constructor(){throw new TypeError("Illegal constructor")}get desiredSize(){if(!vr(this))throw Tr("desiredSize");return Er(this)}close(){if(!vr(this))throw Tr("close");if(!Ir(this))throw new TypeError("The stream is not in a state that permits close");wr(this)}enqueue(t=void 0){if(!vr(this))throw Tr("enqueue");if(!Ir(this))throw new TypeError("The stream is not in a state that permits enqueue");return _r(this,t)}error(t=void 0){if(!vr(this))throw Tr("error");Sr(this,t)}[R](t){Tt(this);const e=this._cancelAlgorithm(t);return br(this),e}[A](t){const e=this._controlledReadableStream;if(this._queue.length>0){const r=It(this);this._closeRequested&&0===this._queue.length?(br(this),Br(e)):gr(this),t._chunkSteps(r)}else Y(e,t),gr(this)}[P](){}}function vr(t){return!!o(t)&&!!Object.prototype.hasOwnProperty.call(t,"_controlledReadableStream")&&t instanceof yr}function gr(t){mr(t)&&(t._pulling?t._pullAgain=!0:(t._pulling=!0,v(t._pullAlgorithm(),(()=>(t._pulling=!1,t._pullAgain&&(t._pullAgain=!1,gr(t)),null)),(e=>(Sr(t,e),null)))))}function mr(t){const e=t._controlledReadableStream;return!!Ir(t)&&!!t._started&&(!!(qr(e)&&Z(e)>0)||Er(t)>0)}function br(t){t._pullAlgorithm=void 0,t._cancelAlgorithm=void 0,t._strategySizeAlgorithm=void 0}function wr(t){if(!Ir(t))return;const e=t._controlledReadableStream;t._closeRequested=!0,0===t._queue.length&&(br(t),Br(e))}function _r(t,e){if(!Ir(t))return;const r=t._controlledReadableStream;if(qr(r)&&Z(r)>0)Q(r,e,!1);else{let r;try{r=t._strategySizeAlgorithm(e)}catch(e){throw Sr(t,e),e}try{Ot(t,e,r)}catch(e){throw Sr(t,e),e}}gr(t)}function Sr(t,e){const r=t._controlledReadableStream;"readable"===r._state&&(Tt(t),br(t),Wr(r,e))}function Er(t){const e=t._controlledReadableStream._state;return"errored"===e?null:"closed"===e?0:t._strategyHWM-t._queueTotalSize}function Ir(t){const e=t._controlledReadableStream._state;return!t._closeRequested&&"readable"===e}function Or(t,e,r,n,o,i,s){e._controlledReadableStream=t,e._queue=void 0,e._queueTotalSize=void 0,Tt(e),e._started=!1,e._closeRequested=!1,e._pullAgain=!1,e._pulling=!1,e._strategySizeAlgorithm=s,e._strategyHWM=i,e._pullAlgorithm=n,e._cancelAlgorithm=o,t._readableStreamController=e,v(d(r()),(()=>(e._started=!0,gr(e),null)),(t=>(Sr(e,t),null)))}function Tr(t){return new TypeError(`ReadableStreamDefaultController.prototype.${t} can only be used on a ReadableStreamDefaultController`)}function Rr(t){return o(e=t)&&void 0!==e.getReader?function(t){let e;return e=jr(n,(function(){let r;try{r=t.read()}catch(r){return p(r)}return b(r,(t=>{if(!o(t))throw new TypeError("The promise returned by the reader.read() method must fulfill with an object");if(t.done)wr(e._readableStreamController);else{const r=t.value;_r(e._readableStreamController,r)}}))}),(function(e){try{return d(t.cancel(e))}catch(e){return p(e)}}),0),e}(t.getReader()):function(t){let e;const r=vt(t,"async");return e=jr(n,(function(){let t;try{t=gt(r)}catch(t){return p(t)}return b(d(t),(t=>{if(!o(t))throw new TypeError("The promise returned by the iterator.next() method must fulfill with an object");if(t.done)wr(e._readableStreamController);else{const r=t.value;_r(e._readableStreamController,r)}}))}),(function(t){const e=r.iterator;let n;try{n=dt(e,"return")}catch(t){return p(t)}return void 0===n?d(void 0):b(E(n,e,[t]),(t=>{if(!o(t))throw new TypeError("The promise returned by the iterator.return() method must fulfill with an object")}))}),0),e}(t);var e}function Ar(t,e,r){return W(t,r),r=>E(t,e,[r])}function Pr(t,e,r){return W(t,r),r=>E(t,e,[r])}function xr(t,e,r){return W(t,r),r=>S(t,e,[r])}function Cr(t,e){if("bytes"!=(t=`${t}`))throw new TypeError(`${e} '${t}' is not a valid enumeration value for ReadableStreamType`);return t}function Nr(t,e){B(t,e);const r=null==t?void 0:t.preventAbort,n=null==t?void 0:t.preventCancel,o=null==t?void 0:t.preventClose,i=null==t?void 0:t.signal;return void 0!==i&&function(t,e){if(!function(t){if("object"!=typeof t||null===t)return!1;try{return"boolean"==typeof t.aborted}catch(t){return!1}}(t))throw new TypeError(`${e} is not an AbortSignal.`)}(i,`${e} has member 'signal' that`),{preventAbort:Boolean(r),preventCancel:Boolean(n),preventClose:Boolean(o),signal:i}}Object.defineProperties(yr.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},desiredSize:{enumerable:!0}}),s(yr.prototype.close,"close"),s(yr.prototype.enqueue,"enqueue"),s(yr.prototype.error,"error"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(yr.prototype,Symbol.toStringTag,{value:"ReadableStreamDefaultController",configurable:!0});class Lr{constructor(t={},e={}){void 0===t?t=null:F(t,"First parameter");const r=ve(e,"Second parameter"),n=function(t,e){B(t,e);const r=t,n=null==r?void 0:r.autoAllocateChunkSize,o=null==r?void 0:r.cancel,i=null==r?void 0:r.pull,s=null==r?void 0:r.start,a=null==r?void 0:r.type;return{autoAllocateChunkSize:void 0===n?void 0:K(n,`${e} has member 'autoAllocateChunkSize' that`),cancel:void 0===o?void 0:Ar(o,r,`${e} has member 'cancel' that`),pull:void 0===i?void 0:Pr(i,r,`${e} has member 'pull' that`),start:void 0===s?void 0:xr(s,r,`${e} has member 'start' that`),type:void 0===a?void 0:Cr(a,`${e} has member 'type' that`)}}(t,"First parameter");if(kr(this),"bytes"===n.type){if(void 0!==r.size)throw new RangeError("The strategy for a byte stream cannot have a size function");!function(t,e,r){const n=Object.create(Pt.prototype);let o,i,s;o=void 0!==e.start?()=>e.start(n):()=>{},i=void 0!==e.pull?()=>e.pull(n):()=>d(void 0),s=void 0!==e.cancel?t=>e.cancel(t):()=>d(void 0);const a=e.autoAllocateChunkSize;if(0===a)throw new TypeError("autoAllocateChunkSize must be greater than 0");ee(t,n,o,i,s,r,a)}(this,n,pe(r,0))}else{const t=ye(r);!function(t,e,r,n){const o=Object.create(yr.prototype);let i,s,a;i=void 0!==e.start?()=>e.start(o):()=>{},s=void 0!==e.pull?()=>e.pull(o):()=>d(void 0),a=void 0!==e.cancel?t=>e.cancel(t):()=>d(void 0),Or(t,o,i,s,a,r,n)}(this,n,pe(r,1),t)}}get locked(){if(!Dr(this))throw Fr("locked");return qr(this)}cancel(t=void 0){return Dr(this)?qr(this)?p(new TypeError("Cannot cancel a stream that already has a reader")):Mr(this,t):p(Fr("cancel"))}getReader(t=void 0){if(!Dr(this))throw Fr("getReader");return void 0===function(t,e){B(t,e);const r=null==t?void 0:t.mode;return{mode:void 0===r?void 0:oe(r,`${e} has member 'mode' that`)}}(t,"First parameter").mode?J(this):ie(this)}pipeThrough(t,e={}){if(!Dr(this))throw Fr("pipeThrough");V(t,1,"pipeThrough");const r=function(t,e){B(t,e);const r=null==t?void 0:t.readable;H(r,"readable","ReadableWritablePair"),z(r,`${e} has member 'readable' that`);const n=null==t?void 0:t.writable;return H(n,"writable","ReadableWritablePair"),Se(n,`${e} has member 'writable' that`),{readable:r,writable:n}}(t,"First parameter"),n=Nr(e,"Second parameter");if(qr(this))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream");if(Ae(r.writable))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream");return w(pr(this,r.writable,n.preventClose,n.preventAbort,n.preventCancel,n.signal)),r.readable}pipeTo(t,e={}){if(!Dr(this))return p(Fr("pipeTo"));if(void 0===t)return p("Parameter 1 is required in 'pipeTo'.");if(!Re(t))return p(new TypeError("ReadableStream.prototype.pipeTo's first argument must be a WritableStream"));let r;try{r=Nr(e,"Second parameter")}catch(t){return p(t)}return qr(this)?p(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream")):Ae(t)?p(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream")):pr(this,t,r.preventClose,r.preventAbort,r.preventCancel,r.signal)}tee(){if(!Dr(this))throw Fr("tee");return ut(function(t){return xt(t._readableStreamController)?function(t){let e,r,n,o,i,s=J(t),a=!1,u=!1,c=!1,l=!1,f=!1;const p=h((t=>{i=t}));function y(t){m(t._closedPromise,(e=>(t!==s||(Jt(n._readableStreamController,e),Jt(o._readableStreamController,e),l&&f||i(void 0)),null)))}function v(){le(s)&&(N(s),s=J(t),y(s)),rt(s,{_chunkSteps:e=>{_((()=>{u=!1,c=!1;const r=e;let s=e;if(!l&&!f)try{s=Et(e)}catch(e){return Jt(n._readableStreamController,e),Jt(o._readableStreamController,e),void i(Mr(t,e))}l||zt(n._readableStreamController,r),f||zt(o._readableStreamController,s),a=!1,u?b():c&&w()}))},_closeSteps:()=>{a=!1,l||Kt(n._readableStreamController),f||Kt(o._readableStreamController),n._readableStreamController._pendingPullIntos.length>0&&Xt(n._readableStreamController,0),o._readableStreamController._pendingPullIntos.length>0&&Xt(o._readableStreamController,0),l&&f||i(void 0)},_errorSteps:()=>{a=!1}})}function g(e,r){et(s)&&(N(s),s=ie(t),y(s));const h=r?o:n,d=r?n:o;fe(s,e,1,{_chunkSteps:e=>{_((()=>{u=!1,c=!1;const n=r?f:l;if(r?l:f)n||te(h._readableStreamController,e);else{let r;try{r=Et(e)}catch(e){return Jt(h._readableStreamController,e),Jt(d._readableStreamController,e),void i(Mr(t,e))}n||te(h._readableStreamController,e),zt(d._readableStreamController,r)}a=!1,u?b():c&&w()}))},_closeSteps:t=>{a=!1;const e=r?f:l,n=r?l:f;e||Kt(h._readableStreamController),n||Kt(d._readableStreamController),void 0!==t&&(e||te(h._readableStreamController,t),!n&&d._readableStreamController._pendingPullIntos.length>0&&Xt(d._readableStreamController,0)),e&&n||i(void 0)},_errorSteps:()=>{a=!1}})}function b(){if(a)return u=!0,d(void 0);a=!0;const t=Qt(n._readableStreamController);return null===t?v():g(t._view,!1),d(void 0)}function w(){if(a)return c=!0,d(void 0);a=!0;const t=Qt(o._readableStreamController);return null===t?v():g(t._view,!0),d(void 0)}function S(){}return n=Ur(S,b,(function(n){if(l=!0,e=n,f){const n=ut([e,r]),o=Mr(t,n);i(o)}return p})),o=Ur(S,w,(function(n){if(f=!0,r=n,l){const n=ut([e,r]),o=Mr(t,n);i(o)}return p})),y(s),[n,o]}(t):function(t){const e=J(t);let r,n,o,i,s,a=!1,u=!1,c=!1,l=!1;const f=h((t=>{s=t}));function p(){return a?(u=!0,d(void 0)):(a=!0,rt(e,{_chunkSteps:t=>{_((()=>{u=!1;const e=t,r=t;c||_r(o._readableStreamController,e),l||_r(i._readableStreamController,r),a=!1,u&&p()}))},_closeSteps:()=>{a=!1,c||wr(o._readableStreamController),l||wr(i._readableStreamController),c&&l||s(void 0)},_errorSteps:()=>{a=!1}}),d(void 0))}function y(){}return o=jr(y,p,(function(e){if(c=!0,r=e,l){const e=ut([r,n]),o=Mr(t,e);s(o)}return f})),i=jr(y,p,(function(e){if(l=!0,n=e,c){const e=ut([r,n]),o=Mr(t,e);s(o)}return f})),m(e._closedPromise,(t=>(Sr(o._readableStreamController,t),Sr(i._readableStreamController,t),c&&l||s(void 0),null))),[o,i]}(t)}(this))}values(t=void 0){if(!Dr(this))throw Fr("values");return function(t,e){const r=J(t),n=new mt(r,e),o=Object.create(bt);return o._asyncIteratorImpl=n,o}(this,function(t){B(t,"First parameter");const e=null==t?void 0:t.preventCancel;return{preventCancel:Boolean(e)}}(t).preventCancel)}[yt](t){return this.values(t)}static from(t){return Rr(t)}}function jr(t,e,r,n=1,o=()=>1){const i=Object.create(Lr.prototype);return kr(i),Or(i,Object.create(yr.prototype),t,e,r,n,o),i}function Ur(t,e,r){const n=Object.create(Lr.prototype);return kr(n),ee(n,Object.create(Pt.prototype),t,e,r,0,void 0),n}function kr(t){t._state="readable",t._reader=void 0,t._storedError=void 0,t._disturbed=!1}function Dr(t){return!!o(t)&&!!Object.prototype.hasOwnProperty.call(t,"_readableStreamController")&&t instanceof Lr}function qr(t){return void 0!==t._reader}function Mr(t,e){if(t._disturbed=!0,"closed"===t._state)return d(void 0);if("errored"===t._state)return p(t._storedError);Br(t);const r=t._reader;if(void 0!==r&&le(r)){const t=r._readIntoRequests;r._readIntoRequests=new I,t.forEach((t=>{t._closeSteps(void 0)}))}return b(t._readableStreamController[R](e),n)}function Br(t){t._state="closed";const e=t._reader;if(void 0!==e&&(D(e),et(e))){const t=e._readRequests;e._readRequests=new I,t.forEach((t=>{t._closeSteps()}))}}function Wr(t,e){t._state="errored",t._storedError=e;const r=t._reader;void 0!==r&&(k(r,e),et(r)?nt(r,e):he(r,e))}function Fr(t){return new TypeError(`ReadableStream.prototype.${t} can only be used on a ReadableStream`)}function Vr(t,e){B(t,e);const r=null==t?void 0:t.highWaterMark;return H(r,"highWaterMark","QueuingStrategyInit"),{highWaterMark:G(r)}}Object.defineProperties(Lr,{from:{enumerable:!0}}),Object.defineProperties(Lr.prototype,{cancel:{enumerable:!0},getReader:{enumerable:!0},pipeThrough:{enumerable:!0},pipeTo:{enumerable:!0},tee:{enumerable:!0},values:{enumerable:!0},locked:{enumerable:!0}}),s(Lr.from,"from"),s(Lr.prototype.cancel,"cancel"),s(Lr.prototype.getReader,"getReader"),s(Lr.prototype.pipeThrough,"pipeThrough"),s(Lr.prototype.pipeTo,"pipeTo"),s(Lr.prototype.tee,"tee"),s(Lr.prototype.values,"values"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Lr.prototype,Symbol.toStringTag,{value:"ReadableStream",configurable:!0}),Object.defineProperty(Lr.prototype,yt,{value:Lr.prototype.values,writable:!0,configurable:!0});const Hr=t=>t.byteLength;s(Hr,"size");class Gr{constructor(t){V(t,1,"ByteLengthQueuingStrategy"),t=Vr(t,"First parameter"),this._byteLengthQueuingStrategyHighWaterMark=t.highWaterMark}get highWaterMark(){if(!Kr(this))throw $r("highWaterMark");return this._byteLengthQueuingStrategyHighWaterMark}get size(){if(!Kr(this))throw $r("size");return Hr}}function $r(t){return new TypeError(`ByteLengthQueuingStrategy.prototype.${t} can only be used on a ByteLengthQueuingStrategy`)}function Kr(t){return!!o(t)&&!!Object.prototype.hasOwnProperty.call(t,"_byteLengthQueuingStrategyHighWaterMark")&&t instanceof Gr}Object.defineProperties(Gr.prototype,{highWaterMark:{enumerable:!0},size:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Gr.prototype,Symbol.toStringTag,{value:"ByteLengthQueuingStrategy",configurable:!0});const zr=()=>1;s(zr,"size");class Jr{constructor(t){V(t,1,"CountQueuingStrategy"),t=Vr(t,"First parameter"),this._countQueuingStrategyHighWaterMark=t.highWaterMark}get highWaterMark(){if(!Qr(this))throw Yr("highWaterMark");return this._countQueuingStrategyHighWaterMark}get size(){if(!Qr(this))throw Yr("size");return zr}}function Yr(t){return new TypeError(`CountQueuingStrategy.prototype.${t} can only be used on a CountQueuingStrategy`)}function Qr(t){return!!o(t)&&!!Object.prototype.hasOwnProperty.call(t,"_countQueuingStrategyHighWaterMark")&&t instanceof Jr}function Zr(t,e,r){return W(t,r),r=>E(t,e,[r])}function Xr(t,e,r){return W(t,r),r=>S(t,e,[r])}function tn(t,e,r){return W(t,r),(r,n)=>E(t,e,[r,n])}function en(t,e,r){return W(t,r),r=>E(t,e,[r])}Object.defineProperties(Jr.prototype,{highWaterMark:{enumerable:!0},size:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Jr.prototype,Symbol.toStringTag,{value:"CountQueuingStrategy",configurable:!0});class rn{constructor(t={},e={},r={}){void 0===t&&(t=null);const n=ve(e,"Second parameter"),o=ve(r,"Third parameter"),i=function(t,e){B(t,e);const r=null==t?void 0:t.cancel,n=null==t?void 0:t.flush,o=null==t?void 0:t.readableType,i=null==t?void 0:t.start,s=null==t?void 0:t.transform,a=null==t?void 0:t.writableType;return{cancel:void 0===r?void 0:en(r,t,`${e} has member 'cancel' that`),flush:void 0===n?void 0:Zr(n,t,`${e} has member 'flush' that`),readableType:o,start:void 0===i?void 0:Xr(i,t,`${e} has member 'start' that`),transform:void 0===s?void 0:tn(s,t,`${e} has member 'transform' that`),writableType:a}}(t,"First parameter");if(void 0!==i.readableType)throw new RangeError("Invalid readableType specified");if(void 0!==i.writableType)throw new RangeError("Invalid writableType specified");const s=pe(o,0),a=ye(o),u=pe(n,1),c=ye(n);let l;!function(t,e,r,n,o,i){function s(){return e}t._writable=function(t,e,r,n,o=1,i=()=>1){const s=Object.create(Ie.prototype);return Te(s),$e(s,Object.create(He.prototype),t,e,r,n,o,i),s}(s,(function(e){return function(t,e){const r=t._transformStreamController;return t._backpressure?b(t._backpressureChangePromise,(()=>{const n=t._writable;if("erroring"===n._state)throw n._storedError;return dn(r,e)})):dn(r,e)}(t,e)}),(function(){return function(t){const e=t._transformStreamController;if(void 0!==e._finishPromise)return e._finishPromise;const r=t._readable;e._finishPromise=h(((t,r)=>{e._finishPromise_resolve=t,e._finishPromise_reject=r}));const n=e._flushAlgorithm();return fn(e),v(n,(()=>("errored"===r._state?vn(e,r._storedError):(wr(r._readableStreamController),yn(e)),null)),(t=>(Sr(r._readableStreamController,t),vn(e,t),null))),e._finishPromise}(t)}),(function(e){return function(t,e){const r=t._transformStreamController;if(void 0!==r._finishPromise)return r._finishPromise;const n=t._readable;r._finishPromise=h(((t,e)=>{r._finishPromise_resolve=t,r._finishPromise_reject=e}));const o=r._cancelAlgorithm(e);return fn(r),v(o,(()=>("errored"===n._state?vn(r,n._storedError):(Sr(n._readableStreamController,e),yn(r)),null)),(t=>(Sr(n._readableStreamController,t),vn(r,t),null))),r._finishPromise}(t,e)}),r,n),t._readable=jr(s,(function(){return function(t){return un(t,!1),t._backpressureChangePromise}(t)}),(function(e){return function(t,e){const r=t._transformStreamController;if(void 0!==r._finishPromise)return r._finishPromise;const n=t._writable;r._finishPromise=h(((t,e)=>{r._finishPromise_resolve=t,r._finishPromise_reject=e}));const o=r._cancelAlgorithm(e);return fn(r),v(o,(()=>("errored"===n._state?vn(r,n._storedError):(Ye(n._writableStreamController,e),an(t),yn(r)),null)),(e=>(Ye(n._writableStreamController,e),an(t),vn(r,e),null))),r._finishPromise}(t,e)}),o,i),t._backpressure=void 0,t._backpressureChangePromise=void 0,t._backpressureChangePromise_resolve=void 0,un(t,!0),t._transformStreamController=void 0}(this,h((t=>{l=t})),u,c,s,a),function(t,e){const r=Object.create(cn.prototype);let n,o,i;n=void 0!==e.transform?t=>e.transform(t,r):t=>{try{return hn(r,t),d(void 0)}catch(t){return p(t)}},o=void 0!==e.flush?()=>e.flush(r):()=>d(void 0),i=void 0!==e.cancel?t=>e.cancel(t):()=>d(void 0),function(t,e,r,n,o){e._controlledTransformStream=t,t._transformStreamController=e,e._transformAlgorithm=r,e._flushAlgorithm=n,e._cancelAlgorithm=o,e._finishPromise=void 0,e._finishPromise_resolve=void 0,e._finishPromise_reject=void 0}(t,r,n,o,i)}(this,i),void 0!==i.start?l(i.start(this._transformStreamController)):l(void 0)}get readable(){if(!nn(this))throw gn("readable");return this._readable}get writable(){if(!nn(this))throw gn("writable");return this._writable}}function nn(t){return!!o(t)&&!!Object.prototype.hasOwnProperty.call(t,"_transformStreamController")&&t instanceof rn}function on(t,e){Sr(t._readable._readableStreamController,e),sn(t,e)}function sn(t,e){fn(t._transformStreamController),Ye(t._writable._writableStreamController,e),an(t)}function an(t){t._backpressure&&un(t,!1)}function un(t,e){void 0!==t._backpressureChangePromise&&t._backpressureChangePromise_resolve(),t._backpressureChangePromise=h((e=>{t._backpressureChangePromise_resolve=e})),t._backpressure=e}Object.defineProperties(rn.prototype,{readable:{enumerable:!0},writable:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(rn.prototype,Symbol.toStringTag,{value:"TransformStream",configurable:!0});class cn{constructor(){throw new TypeError("Illegal constructor")}get desiredSize(){if(!ln(this))throw pn("desiredSize");return Er(this._controlledTransformStream._readable._readableStreamController)}enqueue(t=void 0){if(!ln(this))throw pn("enqueue");hn(this,t)}error(t=void 0){if(!ln(this))throw pn("error");var e;e=t,on(this._controlledTransformStream,e)}terminate(){if(!ln(this))throw pn("terminate");!function(t){const e=t._controlledTransformStream;wr(e._readable._readableStreamController),sn(e,new TypeError("TransformStream terminated"))}(this)}}function ln(t){return!!o(t)&&!!Object.prototype.hasOwnProperty.call(t,"_controlledTransformStream")&&t instanceof cn}function fn(t){t._transformAlgorithm=void 0,t._flushAlgorithm=void 0,t._cancelAlgorithm=void 0}function hn(t,e){const r=t._controlledTransformStream,n=r._readable._readableStreamController;if(!Ir(n))throw new TypeError("Readable side is not in a state that permits enqueue");try{_r(n,e)}catch(t){throw sn(r,t),r._readable._storedError}const o=function(t){return!mr(t)}(n);o!==r._backpressure&&un(r,!0)}function dn(t,e){return b(t._transformAlgorithm(e),void 0,(e=>{throw on(t._controlledTransformStream,e),e}))}function pn(t){return new TypeError(`TransformStreamDefaultController.prototype.${t} can only be used on a TransformStreamDefaultController`)}function yn(t){void 0!==t._finishPromise_resolve&&(t._finishPromise_resolve(),t._finishPromise_resolve=void 0,t._finishPromise_reject=void 0)}function vn(t,e){void 0!==t._finishPromise_reject&&(w(t._finishPromise),t._finishPromise_reject(e),t._finishPromise_resolve=void 0,t._finishPromise_reject=void 0)}function gn(t){return new TypeError(`TransformStream.prototype.${t} can only be used on a TransformStream`)}Object.defineProperties(cn.prototype,{enqueue:{enumerable:!0},error:{enumerable:!0},terminate:{enumerable:!0},desiredSize:{enumerable:!0}}),s(cn.prototype.enqueue,"enqueue"),s(cn.prototype.error,"error"),s(cn.prototype.terminate,"terminate"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(cn.prototype,Symbol.toStringTag,{value:"TransformStreamDefaultController",configurable:!0})},4536:function(t){"use strict";t.exports={version:"3.0.0"}}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={id:n,loaded:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.loaded=!0,i.exports}return r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,{a:e}),e},r.d=function(t,e){for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.nmd=function(t){return t.paths=[],t.children||(t.children=[]),t},r(5047),r(972)}()}));
|