@cloudbase/js-sdk 3.3.0 → 3.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/database/dist/index.esm.js +7 -7
- package/database/dist/index.js +8 -8
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/miniprogram_dist/app.js +1 -1
- package/miniprogram_dist/auth.js +1 -1
- package/miniprogram_dist/database.js +1 -1
- package/miniprogram_dist/index.js +1 -1
- package/package.json +15 -15
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see index.js.LICENSE.txt */
|
|
2
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("cloudbase",[],t):"object"==typeof exports?exports.cloudbase=t():e.cloudbase=t()}("undefined"!=typeof window?window:this,(function(){return function(){var e={2829:function(e,t,r){"use strict";var n;r.r(t),r.d(t,{AbstractSDKRequest:function(){return o},AbstractStorage:function(){return i},StorageType:function(){return n},formatUrl:function(){return s}}),function(e){e.local="local",e.none="none",e.session="session"}(n||(n={}));var o=function(){},i=function(){};function s(e,t,r){void 0===r&&(r={});var n=/\?/.test(t),o="";for(var i in r)""===o?!n&&(t+="?"):o+="&",o+=i+"="+encodeURIComponent(r[i]);return/^http(s)?\:\/\//.test(t+=o)?t:""+e+t}},190:function(e,t,r){"use strict";r.d(t,{ap:function(){return l},dD:function(){return d},ng:function(){return f},x5:function(){return c}});var n,o=r(2829),i=r(5993),s=(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},n(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},a.apply(this,arguments)},u="Error when aborting requestTask",c=function(e){function t(t){void 0===t&&(t={});var r=e.call(this)||this,n=t.timeout,o=t.timeoutMsg,i=t.restrictedMethods;return r._timeout=n||0,r._timeoutMsg=o||"请求超时",r._restrictedMethods=i||["get","post","upload","download"],r}return s(t,e),t.prototype.post=function(e){var t=this;return new Promise((function(r,n){var i=e.url,s=e.data,a=e.headers,u=wx.request({url:(0,o.formatUrl)("https:",i),data:s,timeout:t._timeout,method:"POST",header:a,success:function(e){e.statusCode>=200&&e.statusCode<300?r({statusCode:e.statusCode,status:e.statusCode,data:e.data}):n(e)},fail:function(e){n(e)},complete:function(e){if(e&&e.errMsg&&t._timeout&&-1!==t._restrictedMethods.indexOf("post")&&"request:fail timeout"===e.errMsg){console.warn(t._timeoutMsg);try{u.abort()}catch(e){}}}})}))},t.prototype.get=function(e){var t=this;return new Promise((function(r,n){var i=e.url,s=e.body,a=e.headers,c=(0,o.formatUrl)("https:",i),l=wx.request({url:c,data:s,timeout:t._timeout,method:"GET",header:a,success:function(e){e.statusCode>=200&&e.statusCode<300?r({statusCode:e.statusCode,status:e.statusCode,data:e.data}):n(e)},fail:function(e){n(e)},complete:function(e){if(e&&e.errMsg&&t._timeout&&-1!==t._restrictedMethods.indexOf("get")&&e.errMsg.includes("timeout")){console.warn(t._timeoutMsg);try{l.abort()}catch(e){console.warn(u,e)}}}})}))},t.prototype.upload=function(e){var t=this,r=this;return new Promise((function(n){return o=t,i=void 0,u=function(){var t,o,i,s,u,c;return function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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 t=e.url,o=e.file,i=e.data,s=e.headers,u=e.onUploadProgress,c=wx.uploadFile({url:t,filePath:o,name:"file",formData:a({},i),header:s,timeout:this._timeout,success:function(e){var t={statusCode:e.statusCode,data:e.data||{}};200===e.statusCode&&i.success_action_status&&(t.statusCode=parseInt(i.success_action_status,10)),n(t)},fail:function(e){n(e)},complete:function(e){if(e&&e.errMsg&&r._timeout&&-1!==r._restrictedMethods.indexOf("upload")&&"request:fail timeout"===e.errMsg){console.warn(r._timeoutMsg);try{c.abort()}catch(e){}}}}),u&&c.onProgressUpdate((function(e){u(e)})),[2]}))},new((s=void 0)||(s=Promise))((function(e,t){function r(e){try{a(u.next(e))}catch(e){t(e)}}function n(e){try{a(u.throw(e))}catch(e){t(e)}}function a(t){var o;t.done?e(t.value):(o=t.value,o instanceof s?o:new s((function(e){e(o)}))).then(r,n)}a((u=u.apply(o,i||[])).next())}));var o,i,s,u}))},t.prototype.download=function(e){var t=this,r=this;return new Promise((function(n,i){var s=e.url,a=e.headers,u=wx.downloadFile({url:(0,o.formatUrl)("https:",s),header:a,timeout:t._timeout,success:function(e){200===e.statusCode&&e.tempFilePath?n({statusCode:200,tempFilePath:e.tempFilePath}):n(e)},fail:function(e){i(e)},complete:function(e){if(e&&e.errMsg&&r._timeout&&-1!==r._restrictedMethods.indexOf("download")&&"request:fail timeout"===e.errMsg){console.warn(r._timeoutMsg);try{u.abort()}catch(e){}}}})}))},t.prototype.fetch=function(e){var t=e.url,r=e.body,n=e.enableAbort,s=e.headers,a=e.method,c=e.stream,l=void 0!==c&&c,f=e.signal,d=e.timeout,h=this,p=null!=d?d:this._timeout,v=null,y=new i.Pz({start:function(e){v=e},cancel:function(){v=null}});return new Promise((function(e,i){l&&e({data:y});var c=wx.request({url:(0,o.formatUrl)("https:",t),data:r,timeout:p,method:a.toUpperCase(),header:s,success:function(t){null==v||v.close(),!l&&e(t)},fail:function(e){if(null==v||v.close(),i(e),l)throw e},complete:function(e){if(e&&e.errMsg&&p&&-1!==h._restrictedMethods.indexOf("post")&&n&&"request:fail timeout"===e.errMsg){console.warn(h._timeoutMsg);try{c.abort()}catch(e){console.warn(u,e)}}},enableChunked:l});if(c.onChunkReceived((function(e){null==v||v.enqueue(new Uint8Array(e.data))})),f){var d=function(){try{c.abort()}catch(e){console.warn(u,e)}};f.aborted?d():f.addEventListener("abort",(function(){return d()}))}}))},t.prototype.patch=function(e){var t=e.method,r=e.headers,n=JSON.parse(JSON.stringify(r||{}));return"PATCH"===t.toUpperCase()&&(n["X-HTTP-Method-Override"]="PATCH",t="POST"),this.post(a(a({},e),{method:t,headers:n}))},t}(o.AbstractSDKRequest),l={setItem:function(e,t){wx.setStorageSync(e,t)},getItem:function(e){return wx.getStorageSync(e)},removeItem:function(e){wx.removeStorageSync(e)},clear:function(){wx.clearStorageSync()}},f=function(e,t){void 0===t&&(t={});var r=wx.connectSocket(a({url:e},t));return{set onopen(e){r.onOpen(e)},set onmessage(e){r.onMessage(e)},set onclose(e){r.onClose(e)},set onerror(e){r.onError(e)},send:function(e){return r.send({data:e})},close:function(e,t){return r.close({code:e,reason:t})},get readyState(){return r.readyState},CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3}};function d(e){var t={},r=e.replace(/^[?#]/,"");return r?(r.split("&").forEach((function(e){var r=e.split("="),n=r[0],o=r[1];n=decodeURIComponent(n),o=decodeURIComponent(o),n&&(t[n]?Array.isArray(t[n])?t[n].push(o):t[n]=[t[n],o]:t[n]=o)})),t):t}var h={genAdapter:function(e){return{root:{globalThis:{}},reqClass:c,wsClass:f,captchaOptions:{openURIWithCallback:function(t){var r=e.EventBus,n={},o=t;console.log("openURIWithCallback",t);var i=t.match(/^(data:.*?)(\?[^#\s]*)?$/);if(i){o=i[1],console.log("openURIWithCallback url",o);var s=i[2];s&&(n=d(s))}console.log("openURIWithCallback queryObj",n);var u=n.token,c=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(n,["token"]);return/^data:/.test(o)&&!u?Promise.reject({error:"invalid_argument",error_description:"invalie captcha data: "+t}):u?new Promise((function(e){console.log("wait for captcha..."),r.$emit("CAPTCHA_DATA_CHANGE",a(a({},c),{token:u,url:o})),r.$once("RESOLVE_CAPTCHA_DATA",(function(t){e(t)}))})):Promise.reject({error:"unimplemented",error_description:"need to impl captcha data"})}},localStorage:l,primaryStorage:o.StorageType.local,getAppSign:function(){var e=wx.getAccountInfoSync();return"undefined"!=typeof App||"undefined"!=typeof getApp||wx.onAppHide||wx.offAppHide||wx.onAppShow||wx.offAppShow?e&&e.miniProgram?e.miniProgram.appId:"":e&&e.plugin?e.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(e){return!1}return!0},runtime:"wx_mp"};t.ZP=h},5304:function(e,t){!function(e){"use strict";var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},t(e,r)};var r=function(){return r=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)};function n(e,t,r,n){return new(r||(r=Promise))((function(t,o){function i(e){try{a(n.next(e))}catch(e){o(e)}}function s(e){try{a(n.throw(e))}catch(e){o(e)}}function a(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r((function(e){e(n)}))).then(i,s)}a((n=n.apply(e,[])).next())}))}function o(e,t){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=t.call(e,s)}catch(e){i=[6,e],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(e){function r(t,r){var n=e.call(this,t)||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(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)}(r,e),r}(Error);function s(){return"undefined"!=typeof window&&window||"undefined"!=typeof globalThis&&globalThis}function a(){try{var e=s();if(!e)return;return"undefined"==typeof wx?s().location.href:e.__wxRoute}catch(e){}}var u=function(e){var t=e.dataSourceName,r=e.methodName,u=e.params,c=e.realMethodName,l=e.callFunction,f=e.envType,d=void 0===f?"prod":f,h=e.mode;return n(void 0,0,void 0,(function(){var e,n,f,p,v,y;return o(this,(function(o){switch(o.label){case 0:e={data:{},requestId:""},o.label=1;case 1:return o.trys.push([1,3,,4]),[4,l({name:"lowcode-datasource",data:{dataSourceName:t,methodName:r,params:u,userAgent:(g=s(),(null==g?void 0:g.navigator)?g.navigator.userAgent:"undefined"!=typeof wx&&wx.getSystemInfo?(wx.getSystemInfo({success:function(e){e&&(m=["brand","model","version","system","platform","SDKVersion","language"].map((function(t){return"".concat(t,": ").concat(e[t])})).join(", "))}}),m):void 0),referrer:a(),"x-sdk-version":"1.5.0",envType:d,mode:h}})];case 2:if(n=o.sent(),f=(null===(v=null==n?void 0:n.result)||void 0===v?void 0:v.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(t?"".concat(t,"."):"").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 e.data=(null===(y=null==n?void 0:n.result)||void 0===y?void 0:y.data)||{},e.requestId=f,[3,4];case 3:throw"WxCloudSDKError"===(p=o.sent()).name?p:(console.log(p),new i("【错误】".concat(p.message,"\n 【操作】调用 models.").concat(t?"".concat(t,"."):"").concat(c,"\n 【请求ID】N/A"),{code:"UnknownError",originError:p}));case 4:return[2,e]}var m,g}))}))},c=function(e){var t=e.sql,r=e.params,i=e.config,s=e.callFunction,a=e.unsafe,c=void 0!==a&&a;return n(void 0,0,void 0,(function(){return o(this,(function(e){return[2,u({realMethodName:"$runSQL",methodName:"callWedaApi",params:{action:"RunMysqlCommand",data:{sqlTemplate:t,config:i,parameter:c?"":Object.entries(r||{}).reduce((function(e,t){var r=t[0],n=t[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"}e.push({key:r,type:o,value:"STRING"===o?n:JSON.stringify(n)})}return e}),[])||[]}},callFunction:s,mode:"sdk"})]}))}))},l=function(e){return{$runSQL:function(t,i,s){return n(this,0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return[4,c({sql:t,params:i,config:r(r({},s),{preparedStatements:!0}),callFunction:e})];case 1:return[2,n.sent()]}}))}))},$runSQLRaw:function(t,i){return n(this,0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return[4,c({sql:t,params:[],config:r(r({},i),{preparedStatements:!1}),callFunction:e})];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}}}},d=function(e){var t=l(e);return new Proxy({},{get:function(s,a){if("string"==typeof a)return Object.prototype.hasOwnProperty.call(t,a)?t[a]:function(e,t){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,d;return o(this,(function(o){switch(o.label){case 0:return n=r(r({},c.defaultParams||{}),i||{}),[4,u({callFunction:t,dataSourceName:e,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===(d=null==s?void 0:s.data)||void 0===d?void 0:d[f]:null==s?void 0:s.data,[2,l]}}))}))}}})}(a,e)}})},h={filter:{where:{}},select:{$master:!0}};function p(e){return{getUrl:function(t){return"".concat(t,"/").concat(e)},method:"post"}}var v={get:r(r({},p("get")),{defaultParams:r({},h)}),list:r(r({},p("list")),{defaultParams:r({},h)}),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")},y="Unknown error occurred",m="NotSupported",g=function(e,t,r,n){var o=l(e);return new Proxy({},{get:function(e,i){if("string"==typeof i)return Object.prototype.hasOwnProperty.call(o,i)?o[i]:w(r,i,t,n)}})},b=function(e,t,r,n,o){return new i("【错误】".concat(e,"\n【操作】调用 models.").concat(t,".").concat(r,"\n【错误码】").concat(n,"\n【请求ID】").concat(o),{code:n,requestId:o})},w=function(e,t,s,a){return new Proxy({},{get:function(u,c){if("runSQLTemplate"!==c){var l=v[c];if(!l){var f=new Error("不支持的操作: ".concat(c));throw new i(f.message||y,{originError:f,code:m,requestId:"N/A"})}return function(r){return void 0===r&&(r={}),n(void 0,0,void 0,(function(){var n,a,u,f,d,h,p,v,m,g;return o(this,(function(o){switch(o.label){case 0:n=l.getUrl,a=l.method,u=l.defaultParams,f=void 0===u?{}:u,d=Object.assign({},f,r),h="pre"===d.envType?"pre":"prod",p=[e,h,n(t)].join("/"),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,s({url:p,body:JSON.stringify(d),method:a})];case 2:if((v=o.sent()).code)throw b(null==v?void 0:v.message,t,c,null==v?void 0:v.code,null==v?void 0:v.requestId);return"get"===c&&Object.assign(v,{data:null!==(g=v.data.record)&&void 0!==g?g:v.data}),[2,v];case 3:throw m=o.sent(),new i((null==m?void 0:m.message)||y,{originError:m});case 4:return[2]}}))}))}}if(!(null==a?void 0:a.sqlBaseUrl))throw f=new Error("不支持的操作: ".concat(c)),new i(f.message||y,{originError:f,code:m,requestId:"N/A"});return function(e){return n(void 0,0,void 0,(function(){var n,u,l,f,d,h,p,v,m,g,w,_,S,E,I,O;return o(this,(function(o){switch(o.label){case 0:n=e.params,u=e.templateName,l=e.envType,f="pre"===l?"pre":"prod",d=[a.sqlBaseUrl,f,u,"run"].join("/"),h=Object.entries(n||{}).reduce((function(e,t){var r=t[0],n=t[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"}e.push({key:r,type:o,value:"STRING"===o?n:JSON.stringify(n)})}return e}),[]),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,s({url:d,body:JSON.stringify({parameter:h}),method:"POST"})];case 2:if(p=o.sent(),null===(m=null==p?void 0:p.Response)||void 0===m?void 0:m.Error)throw b(null===(w=null===(g=null==p?void 0:p.Response)||void 0===g?void 0:g.Error)||void 0===w?void 0:w.Message,t,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 v=o.sent(),new i((null==v?void 0:v.message)||y,{originError:v});case 4:return[2]}}))}))}}})};function _(e){if(!e)throw new Error("cloud is required");if(!e.callFunction)throw new Error("cloud.callFunction is required");var t=d(e.callFunction.bind(e));return e.models=t,e}var S={init:_,generateHTTPClient:g};e.default=S,e.generateHTTPClient=g,e.init=_,Object.defineProperty(e,"__esModule",{value:!0})}(t)},972:function(e,t,r){"use strict";var n=(this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(r(9917)),o=r(6334),i=r(2363),s=r(534),a=r(9063),u=r(7505),c=r(9679),l=r(4982),f=r(7596),d=r(2840),h=r(41),p=r(5348);n.default.registerVersion("3.3.0");try{(0,o.registerAuth)(n.default),(0,i.registerFunctions)(n.default),(0,s.registerStorage)(n.default),(0,p.registerDatabase)(n.default),(0,a.registerRealtime)(n.default),(0,u.registerAnalytics)(n.default),(0,c.registerModel)(n.default),(0,l.registerAi)(n.default),(0,f.registerCloudrun)(n.default),(0,d.registerMySQL)(n.default),(0,h.registerApis)(n.default)}catch(e){}try{window.cloudbase=n.default}catch(e){}t.default=n.default,e.exports=n.default},4982:function(e,t,r){"use strict";r.r(t),r.d(t,{AI:function(){return ot},Bot:function(){return M},SimpleChatModel:function(){return it},createAI:function(){return lt},createAi:function(){return ft},models:function(){return ut},registerAi:function(){return ht},utils:function(){return n}});var n={};r.r(n),r.d(n,{ReadableStream:function(){return E},TextDecoderStream:function(){return A},TransformStream:function(){return I},createAsyncIterable:function(){return R},createEventSourceParserTransformStream:function(){return O},createPromise:function(){return x},functionToolToModelTool:function(){return U},intoStandardStream:function(){return P},intoTextStream:function(){return C},isToolCallAssistantMessage:function(){return L},readableStream2JsonObject:function(){return N},toPolyfillReadable:function(){return T}});var o={};r.r(o),r.d(o,{ArkSimpleModel:function(){return ae},DSSimpleModel:function(){return de},DefaultImageModel:function(){return Me},DefaultSimpleModel:function(){return qe},HunYuanBetaSimpleModel:function(){return Z},HunYuanExpSimpleModel:function(){return Te},HunYuanOpenSimpleModel:function(){return Ce},HunYuanSimpleModel:function(){return re},MODELS:function(){return Ze},MoonshotSimpleModel:function(){return Se},ReactModel:function(){return $e},YiSimpleModel:function(){return me},ZhiPuSimpleModel:function(){return $},toolMap:function(){return Ke}});var i=r(5993),s=function(e,t){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},s(e,t)};function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}s(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function u(e){if(!e)throw new TypeError("Assertion failed")}function c(){}function l(e){return!(t=e,("object"!=typeof t||null===t)&&"function"!=typeof t||"function"!=typeof e.getReader);var t}function f(e){try{return e.getReader({mode:"byob"}).releaseLock(),!0}catch(e){return!1}}function d(e,t){var r=(void 0===t?{}:t).type;return u(l(e)),u(!1===e.locked),"bytes"===(r=h(r))?new m(e):new v(e)}function h(e){var t=String(e);if("bytes"===t)return t;if(void 0===e)return e;throw new RangeError("Invalid type is specified")}var p=function(){function e(e){this._underlyingReader=void 0,this._readerMode=void 0,this._readableStreamController=void 0,this._pendingRead=void 0,this._underlyingStream=e,this._attachDefaultReader()}return e.prototype.start=function(e){this._readableStreamController=e},e.prototype.cancel=function(e){return u(void 0!==this._underlyingReader),this._underlyingReader.cancel(e)},e.prototype._attachDefaultReader=function(){if("default"!==this._readerMode){this._detachReader();var e=this._underlyingStream.getReader();this._readerMode="default",this._attachReader(e)}},e.prototype._attachReader=function(e){var t=this;u(void 0===this._underlyingReader),this._underlyingReader=e;var r=this._underlyingReader.closed;r&&r.then((function(){return t._finishPendingRead()})).then((function(){e===t._underlyingReader&&t._readableStreamController.close()}),(function(r){e===t._underlyingReader&&t._readableStreamController.error(r)})).catch(c)},e.prototype._detachReader=function(){void 0!==this._underlyingReader&&(this._underlyingReader.releaseLock(),this._underlyingReader=void 0,this._readerMode=void 0)},e.prototype._pullWithDefaultReader=function(){var e=this;this._attachDefaultReader();var t=this._underlyingReader.read().then((function(t){var r=e._readableStreamController;t.done?e._tryClose():r.enqueue(t.value)}));return this._setPendingRead(t),t},e.prototype._tryClose=function(){try{this._readableStreamController.close()}catch(e){}},e.prototype._setPendingRead=function(e){var t,r=this,n=function(){r._pendingRead===t&&(r._pendingRead=void 0)};this._pendingRead=t=e.then(n,n)},e.prototype._finishPendingRead=function(){var e=this;if(this._pendingRead){var t=function(){return e._finishPendingRead()};return this._pendingRead.then(t,t)}},e}(),v=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return a(t,e),t.prototype.pull=function(){return this._pullWithDefaultReader()},t}(p);function y(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var m=function(e){function t(t){var r=this,n=f(t);return(r=e.call(this,t)||this)._supportsByob=n,r}return a(t,e),Object.defineProperty(t.prototype,"type",{get:function(){return"bytes"},enumerable:!1,configurable:!0}),t.prototype._attachByobReader=function(){if("byob"!==this._readerMode){u(this._supportsByob),this._detachReader();var e=this._underlyingStream.getReader({mode:"byob"});this._readerMode="byob",this._attachReader(e)}},t.prototype.pull=function(){if(this._supportsByob){var e=this._readableStreamController.byobRequest;if(e)return this._pullWithByobRequest(e)}return this._pullWithDefaultReader()},t.prototype._pullWithByobRequest=function(e){var t=this;this._attachByobReader();var r=new Uint8Array(e.view.byteLength),n=this._underlyingReader.read(r).then((function(r){var n,o,i;t._readableStreamController,r.done?(t._tryClose(),e.respond(0)):(n=r.value,o=e.view,i=y(n),y(o).set(i,0),e.respond(r.value.byteLength))}));return this._setPendingRead(n),n},t}(p);!function(){function e(e){var t=this;this._writableStreamController=void 0,this._pendingWrite=void 0,this._state="writable",this._storedError=void 0,this._underlyingWriter=e,this._errorPromise=new Promise((function(e,r){t._errorPromiseReject=r})),this._errorPromise.catch(c)}e.prototype.start=function(e){var t=this;this._writableStreamController=e,this._underlyingWriter.closed.then((function(){t._state="closed"})).catch((function(e){return t._finishErroring(e)}))},e.prototype.write=function(e){var t=this,r=this._underlyingWriter;if(null===r.desiredSize)return r.ready;var n=r.write(e);n.catch((function(e){return t._finishErroring(e)})),r.ready.catch((function(e){return t._startErroring(e)}));var o=Promise.race([n,this._errorPromise]);return this._setPendingWrite(o),o},e.prototype.close=function(){var e=this;return void 0===this._pendingWrite?this._underlyingWriter.close():this._finishPendingWrite().then((function(){return e.close()}))},e.prototype.abort=function(e){if("errored"!==this._state)return this._underlyingWriter.abort(e)},e.prototype._setPendingWrite=function(e){var t,r=this,n=function(){r._pendingWrite===t&&(r._pendingWrite=void 0)};this._pendingWrite=t=e.then(n,n)},e.prototype._finishPendingWrite=function(){var e=this;if(void 0===this._pendingWrite)return Promise.resolve();var t=function(){return e._finishPendingWrite()};return this._pendingWrite.then(t,t)},e.prototype._startErroring=function(e){var t=this;if("writable"===this._state){this._state="erroring",this._storedError=e;var r=function(){return t._finishErroring(e)};void 0===this._pendingWrite?r():this._finishPendingWrite().then(r,r),this._writableStreamController.error(e)}},e.prototype._finishErroring=function(e){"writable"===this._state&&this._startErroring(e),"erroring"===this._state&&(this._state="errored",this._errorPromiseReject(this._storedError))}}(),function(){function e(e,t){var r=this;this._transformStreamController=void 0,this._onRead=function(e){if(!e.done)return r._transformStreamController.enqueue(e.value),r._reader.read().then(r._onRead)},this._onError=function(e){r._flushReject(e),r._transformStreamController.error(e),r._reader.cancel(e).catch(c),r._writer.abort(e).catch(c)},this._onTerminate=function(){r._flushResolve(),r._transformStreamController.terminate();var e=new TypeError("TransformStream terminated");r._writer.abort(e).catch(c)},this._reader=e,this._writer=t,this._flushPromise=new Promise((function(e,t){r._flushResolve=e,r._flushReject=t}))}e.prototype.start=function(e){this._transformStreamController=e,this._reader.read().then(this._onRead).then(this._onTerminate,this._onError);var t=this._reader.closed;t&&t.then(this._onTerminate,this._onError)},e.prototype.transform=function(e){return this._writer.write(e)},e.prototype.flush=function(){var e=this;return this._writer.close().then((function(){return e._flushPromise}))}}();var g=[239,187,191],b=r(4410),w=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},_=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,o){!function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)}(n,o,(t=e[r](t)).done,t.value)}))}}},E=i.Pz,I=i.GJ,O=function(){var e;return new I({start:function(t){e=function(e){var t,r,n,o,i,s,a;return u(),{feed:function(e){r=r?r+e:e,t&&function(e){return g.every((function(t,r){return e.charCodeAt(r)===t}))}(r)&&(r=r.slice(g.length)),t=!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,d=n;u<0&&d<i;d++)":"===(f=r[d])&&l<0?l=d-s:"\r"===f?(a=!0,u=d-s):"\n"===f&&(u=d-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(){t=!0,r="",n=0,o=-1,i=void 0,s=void 0,a=""}function c(t,r,n,o){if(0===o)return a.length>0&&(e({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=t.slice(r,r+(c?o:n)),f=r+(u=c?o:" "===t[r+n+1]?n+2:n+1),d=o-u,h=t.slice(f,f+d).toString();if("data"===l)a+=h?"".concat(h,"\n"):"\n";else if("event"===l)s=h;else if("id"!==l||h.includes("\0")){if("retry"===l){var p=parseInt(h,10);Number.isNaN(p)||e({type:"reconnect-interval",value:p})}}else i=h}}((function(e){"event"===e.type&&t.enqueue(e)}))},transform:function(t){e.feed(t)}})},T=function(e){u(function(e){return!!function(e){if("function"!=typeof e)return!1;var t=!1;try{new e({start:function(){t=!0}})}catch(e){}return t}(e)&&!!l(new e)}(e));var t=function(e){try{return new e({type:"bytes"}),!0}catch(e){return!1}}(e);return function(r,n){var o=(void 0===n?{}:n).type;if("bytes"!==(o=h(o))||t||(o=void 0),r.constructor===e&&("bytes"!==o||f(r)))return r;if("bytes"===o){var i=d(r,{type:o});return new e(i)}return i=d(r),new e(i)}}(E),A=function(){function e(e,t){void 0===e&&(e="utf-8"),void 0===t&&(t={});var r=this;this.transform=new I({transform:function(e,t){var n=r.handle.decode(new Uint8Array(e),{stream:!0});n&&t.enqueue(n)},flush:function(e){var t=r.handle.decode();t&&e.enqueue(t),e.terminate()}}),this.handle=new b.TextDecoder(e,t)}return Object.defineProperty(e.prototype,"encoding",{get:function(){return this.handle.encoding},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fatal",{get:function(){return this.handle.fatal},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ignoreBOM",{get:function(){return this.handle.ignoreBOM},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"readable",{get:function(){return this.transform.readable},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"writable",{get:function(){return this.transform.writable},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,Symbol.toStringTag,{get:function(){return"TextDecoderStream"},enumerable:!1,configurable:!0}),e}();function R(e){var t=e;return t[Symbol.asyncIterator]=function(){var t=e.getReader();return{next:function(){return w(this,void 0,void 0,(function(){var e,r,n;return _(this,(function(o){switch(o.label){case 0:return[4,t.read()];case 1:return e=o.sent(),r=e.done,n=e.value,[2,r?{done:!0,value:void 0}:{done:!1,value:n}]}}))}))}}},t}function P(e){return R(e.pipeThrough(new A).pipeThrough(O()).pipeThrough(new I({transform:function(e,t){try{var r=JSON.parse(e.data);t.enqueue(r)}catch(r){"[DONE]"!==e.data?console.warn("Error when transforming event source data to json",r,e):t.terminate()}}})))}function C(e){return R(T(e).pipeThrough(new A))}function N(e){var t,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=C(e),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(),t=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||t||!(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 x(){var e,t;return{promise:new Promise((function(r,n){e=r,t=n})),res:e,rej:t}}function L(e){var t;return"assistant"===e.role&&"tool_calls"in e&&null!=(null===(t=e.tool_calls)||void 0===t?void 0:t[0])}function U(e){return{type:"function",function:{description:e.description,name:e.name,parameters:e.parameters}}}var k=function(){return k=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},k.apply(this,arguments)},D=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},j=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r},M=function(){function e(e,t){this.baseUrl=t;var r=arguments[2];this.req="string"==typeof r?function(t){var n=t.headers,o=void 0===n?{}:n,i=q(t,["headers"]);return e(k(k({},i),{headers:k(k({},o),{Authorization:"Bearer ".concat(r)})}))}:e}return e.prototype.list=function(e,t){return this.req({method:"get",url:this.join("bots"),data:e,timeout:null==t?void 0:t.timeout})},e.prototype.create=function(e,t){var r=e.botInfo;return this.req({method:"post",url:this.join("bots"),data:r,timeout:null==t?void 0:t.timeout})},e.prototype.get=function(e,t){var r=e.botId;return this.req({method:"get",url:this.join("bots/".concat(r)),timeout:null==t?void 0:t.timeout})},e.prototype.update=function(e,t){var r=e.botId,n=e.botInfo;return this.req({method:"PATCH",url:this.join("bots/".concat(r)),data:n,timeout:null==t?void 0:t.timeout})},e.prototype.delete=function(e,t){var r=e.botId;return this.req({method:"delete",url:this.join("bots/".concat(r)),timeout:null==t?void 0:t.timeout})},e.prototype.getChatRecords=function(e,t){return this.req({method:"get",url:this.join("bots/".concat(e.botId,"/records")),data:e,timeout:null==t?void 0:t.timeout})},e.prototype.sendFeedback=function(e,t){var r=e.userFeedback;return this.req({method:"post",url:this.join("bots/".concat(r.botId,"/feedback")),data:r,timeout:null==t?void 0:t.timeout})},e.prototype.getFeedback=function(e,t){return this.req({method:"get",url:this.join("bots/".concat(e.botId,"/feedback")),data:e,timeout:null==t?void 0:t.timeout})},e.prototype.uploadFiles=function(e,t){return D(this,void 0,void 0,(function(){return j(this,(function(r){return[2,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/files")),data:e,timeout:null==t?void 0:t.timeout})]}))}))},e.prototype.createConversation=function(e,t){var r=e.botId,n=q(e,["botId"]);return D(this,void 0,void 0,(function(){return j(this,(function(e){return[2,this.req({method:"post",url:this.join("bots/".concat(r,"/conversation")),data:n,timeout:null==t?void 0:t.timeout})]}))}))},e.prototype.getConversation=function(e,t){var r=e.pageSize,n=void 0===r?10:r,o=e.pageNumber,i=void 0===o?1:o,s=e.botId,a=q(e,["pageSize","pageNumber","botId"]);return D(this,void 0,void 0,(function(){var e,r;return j(this,(function(o){if(i<1)throw new Error("pageNumber must be greater than 0");return e=n*(i-1),r=n,[2,this.req({method:"get",url:this.join("bots/".concat(s,"/conversation")),data:k(k({},a),{offset:e,limit:r}),timeout:null==t?void 0:t.timeout})]}))}))},e.prototype.deleteConversation=function(e,t){var r=e.botId,n=e.conversationId,o=q(e,["botId","conversationId"]);return D(this,void 0,void 0,(function(){return j(this,(function(e){return[2,this.req({method:"delete",url:this.join("bots/".concat(r,"/conversation/").concat(n)),data:o,timeout:null==t?void 0:t.timeout})]}))}))},e.prototype.speechToText=function(e,t){return D(this,void 0,void 0,(function(){return j(this,(function(r){return[2,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/speech-to-text")),data:e,timeout:null==t?void 0:t.timeout})]}))}))},e.prototype.textToSpeech=function(e,t){return D(this,void 0,void 0,(function(){return j(this,(function(r){return[2,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/text-to-speech")),data:e,timeout:null==t?void 0:t.timeout})]}))}))},e.prototype.getTextToSpeechResult=function(e,t){return D(this,void 0,void 0,(function(){return j(this,(function(r){return[2,this.req({method:"get",url:this.join("bots/".concat(e.botId,"/text-to-speech")),data:e,timeout:null==t?void 0:t.timeout})]}))}))},e.prototype.getRecommendQuestions=function(e,t){return D(this,void 0,void 0,(function(){var r;return j(this,(function(n){switch(n.label){case 0:return[4,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/recommend-questions")),data:e,stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return r=n.sent(),[2,new B(r)]}}))}))},e.prototype.generateBot=function(e,t){return D(this,void 0,void 0,(function(){var r;return j(this,(function(n){switch(n.label){case 0:return[4,this.req({method:"post",url:this.join("generate-bot"),data:e,stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return r=n.sent(),[2,new B(r)]}}))}))},e.prototype.getPreview=function(e,t){return D(this,void 0,void 0,(function(){var r;return j(this,(function(n){switch(n.label){case 0:return[4,this.req({method:"post",url:this.join("preview"),data:e,stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return r=n.sent(),[2,new B(r)]}}))}))},e.prototype.generateImage=function(e,t){return this.req({method:"post",url:this.join("generate-image"),data:e,timeout:null==t?void 0:t.timeout})},e.prototype.sendMessage=function(e,t){return D(this,void 0,void 0,(function(){var r;return j(this,(function(n){switch(n.label){case 0:return[4,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/send-message")),data:e,stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return r=n.sent(),[2,new B(r)]}}))}))},e.prototype.join=function(e){return"".concat(this.baseUrl,"/").concat(e)},e}(),B=function(){function e(e){var t=T(e);this._eventSourceStream=t.pipeThrough(new A).pipeThrough(O())}return Object.defineProperty(e.prototype,"teeedStream",{get:function(){var e=this._eventSourceStream.tee(),t=e[0],r=e[1];return this._eventSourceStream=r,t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"eventSourceStream",{get:function(){return R(this.teeedStream)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dataStream",{get:function(){return R(this.eventSourceStream.pipeThrough(new I({transform:function(e,t){try{var r=JSON.parse(e.data);t.enqueue(r)}catch(r){"[DONE]"!==e.data?console.warn("Error when transforming event source data to json",r,e):t.terminate()}}})))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"textStream",{get:function(){return R(this.dataStream.pipeThrough(new I({transform:function(e,t){var r;t.enqueue(null!==(r=null==e?void 0:e.content)&&void 0!==r?r:"")}})))},enumerable:!1,configurable:!0}),e}(),W=function(){return W=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},W.apply(this,arguments)},F=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},V=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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(e){var t=e.messages,r=e.model,n=e.temperature,o=e.tool_choice,i=e.tools,s=e.top_p;return W(W({},e),{messages:t,model:r,temperature:n,tool_choice:(o&&"auto"!==o&&console.warn("`tool_choice` is not 'auto'"),o),tools:i,top_p:s})}var $=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="zhipu/api/paas/v4/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return F(this,void 0,void 0,(function(){var r,n;return V(this,(function(o){switch(o.label){case 0:return r=H(e),[4,this.req({url:this.url,data:W(W({},r),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return n=o.sent(),[2,W(W({},n),{rawResponse:n})]}}))}))},e.prototype.doStream=function(e,t){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(e),n=null,[4,this.req({url:this.url,data:W(W({},r),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=s.sent(),i=T(o),[2,R(P(i).pipeThrough(new I({transform:function(e,t){var r=e.choices.map((function(e){var t=e.delta;return null==n&&(n=L(t)),n?W(W({},e),{finish_reason:"tool_calls",delta:t}):e})),o=W(W({},e),{choices:r});t.enqueue(W(W({},o),{rawResponse:e}))}})))]}}))}))},e}(),G=function(){return G=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},G.apply(this,arguments)};function z(e){var t=e.messages,r=e.model,n=e.temperature,o=e.tool_choice,i=e.tools,s=e.top_p;return G(G({},e),{messages:(t.forEach((function(e){"tool_calls"in e&&e.tool_calls.filter((function(e){return"function"!==e.type})).forEach((function(t){return console.warn("`type` in tool_call is not 'function'",t,e)}))})),t),model:r,tools:function(){if(i)return i.forEach((function(e){"function"!==e.type&&console.warn("`type` in tool is not 'function'",e)})),i}(),top_p:s,tool_choice:o,temperature:n})}function K(e){return"object"!=typeof e||null==e?e:Array.isArray(e)?e.map((function(e){return K(e)})):Object.entries(e).reduce((function(e,t){var r,n=t[0],o=t[1];return e["_"===(r=n.replace(/[A-Z]/g,(function(e){return"_".concat(e.toLowerCase())}))).charAt(0)?r.slice(1):r]="object"==typeof o?K(o):o,e}),{})}var J=function(){return J=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},J.apply(this,arguments)},Y=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},Q=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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 e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="hunyuan-beta/openapi/v1/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){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({},z(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return r=n.sent(),[2,J(J({},r),{rawResponse:r})]}}))}))},e.prototype.doStream=function(e,t){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({},z(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return n=i.sent(),o=T(n),[2,R(P(o).pipeThrough(new I({transform:function(e,t){var n=e.choices.map((function(e){var t=e.delta;return null==r&&(r=L(t)),r?J(J({},e),{finish_reason:"tool_calls",delta:t}):e})),o=J(J({},e),{choices:n});t.enqueue(J(J({},o),{rawResponse:e}))}})))]}}))}))},e}(),X=function(){return X=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},X.apply(this,arguments)},ee=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},te=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="hunyuan",null!=r&&(this.subUrl=r)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return ee(this,void 0,void 0,(function(){var r,n;return te(this,(function(o){switch(o.label){case 0:return[4,this.req({url:this.url,headers:{"X-Tc-Action":"ChatCompletions"},data:X(X({},z(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return r=o.sent(),n=K(r.Response),[2,X(X({},n),{rawResponse:r})]}}))}))},e.prototype.doStream=function(e,t){return ee(this,void 0,void 0,(function(){var r,n,o;return te(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({},e),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return n=i.sent(),o=T(n),[2,R(P(o).pipeThrough(new I({transform:function(e,t){var n=K(e),o=n.choices.map((function(e){var t=e.delta;return null==r&&(r=L(t)),r?X(X({},e),{finish_reason:"tool_calls",delta:t}):e})),i=X(X({},n),{choices:o});t.enqueue(X(X({},i),{rawResponse:e}))}})))]}}))}))},e}(),ne=function(){return ne=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},ne.apply(this,arguments)},oe=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},ie=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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 se(e){var t=e.messages,r=e.model,n=e.temperature,o=e.tools,i=e.top_p;return ne(ne({},e),{messages:t,model:r,tools:o,top_p:i,temperature:n})}var ae=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="ark/api/v3/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return oe(this,void 0,void 0,(function(){var r;return ie(this,(function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:ne(ne({},se(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return r=n.sent(),[2,ne(ne({},r),{rawResponse:r})]}}))}))},e.prototype.doStream=function(e,t){return oe(this,void 0,void 0,(function(){var r,n,o;return ie(this,(function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:ne(ne({},se(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return n=i.sent(),o=T(n),[2,R(P(o).pipeThrough(new I({transform:function(e,t){var n=e.choices.map((function(e){var t=e.delta;return null==r&&(r=L(t)),r?ne(ne({},e),{finish_reason:"tool_calls",delta:t}):e})),o=ne(ne({},e),{choices:n});t.enqueue(ne(ne({},o),{rawResponse:e}))}})))]}}))}))},e}(),ue=function(){return ue=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},ue.apply(this,arguments)},ce=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},le=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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 fe(e){var t=e.messages,r=e.model,n=e.temperature,o=e.tools,i=e.top_p;return ue(ue({},e),{messages:t,model:r,tools:o,top_p:i,temperature:n})}var de=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="dashscope/compatible-mode/v1/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return ce(this,void 0,void 0,(function(){var r;return le(this,(function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:ue(ue({},fe(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return r=n.sent(),[2,ue(ue({},r),{rawResponse:r})]}}))}))},e.prototype.doStream=function(e,t){return ce(this,void 0,void 0,(function(){var r,n,o;return le(this,(function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:ue(ue({},fe(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return n=i.sent(),o=T(n),[2,R(P(o).pipeThrough(new I({transform:function(e,t){var n=e.choices.map((function(e){var t=Object.assign(e.delta,{role:"assistant"});return null==r&&(r=L(t)),ue(ue({},e),r?{finish_reason:"tool_calls",delta:t}:{delta:t})})),o=ue(ue({},e),{choices:n});t.enqueue(ue(ue({},o),{rawResponse:e}))}})))]}}))}))},e}(),he=function(){return he=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},he.apply(this,arguments)},pe=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},ve=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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 ye(e){var t=e.messages,r=e.model,n=e.temperature,o=e.tools,i=e.top_p;return he(he({},e),{messages:t,model:r,tools:o,top_p:i,temperature:n})}var me=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="01-ai/v1/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return pe(this,void 0,void 0,(function(){var r;return ve(this,(function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:he(he({},ye(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return r=n.sent(),[2,he(he({},r),{rawResponse:r})]}}))}))},e.prototype.doStream=function(e,t){return pe(this,void 0,void 0,(function(){var r,n,o,i,s;return ve(this,(function(a){switch(a.label){case 0:return r=null,[4,this.req({url:this.url,data:he(he({},ye(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return n=a.sent(),o=T(n),i=P(o),s=i.pipeThrough(new I({transform:function(e,t){var n,o,i,s,a,u;if((null===(i=null===(o=null===(n=null==e?void 0:e.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==e?void 0:e.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=e.choices.map((function(e){var t=Object.assign(e.delta,{role:"assistant"});return null==r&&(r=L(t)),he(he({},e),r?{finish_reason:"tool_calls",delta:t}:{delta:t})})),l=he(he({},e),{choices:c});t.enqueue(he(he({},l),{rawResponse:e}))}}})),[2,R(s)]}}))}))},e}(),ge=function(){return ge=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},ge.apply(this,arguments)},be=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},we=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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 _e(e){var t=e.messages,r=e.model,n=e.temperature,o=e.tools,i=e.top_p;return ge(ge({},e),{messages:t,model:r,tools:o,top_p:i,temperature:n})}var Se=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="moonshot/v1/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return be(this,void 0,void 0,(function(){var r;return we(this,(function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:ge(ge({},_e(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return r=n.sent(),[2,ge(ge({},r),{rawResponse:r})]}}))}))},e.prototype.doStream=function(e,t){return be(this,void 0,void 0,(function(){var r,n,o;return we(this,(function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:ge(ge({},_e(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return n=i.sent(),o=T(n),[2,R(P(o).pipeThrough(new I({transform:function(e,t){var n=e.choices.map((function(e){var t=e.delta;return null==r&&(r=L(t)),r?ge(ge({},e),{finish_reason:"tool_calls",delta:t}):e})),o=ge(ge({},e),{choices:n});t.enqueue(ge(ge({},o),{rawResponse:e}))}})))]}}))}))},e}(),Ee=function(){return Ee=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Ee.apply(this,arguments)},Ie=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},Oe=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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])}}},Te=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="hunyuan-exp/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e){return Ie(this,void 0,void 0,(function(){var t;return Oe(this,(function(r){switch(r.label){case 0:return[4,this.req({url:this.url,data:Ee(Ee({},z(e)),{stream:!1}),stream:!1})];case 1:return t=r.sent(),[2,Ee(Ee({},t),{rawResponse:t})]}}))}))},e.prototype.doStream=function(e){return Ie(this,void 0,void 0,(function(){var t,r,n;return Oe(this,(function(o){switch(o.label){case 0:return t=null,[4,this.req({url:this.url,data:Ee(Ee({},z(e)),{stream:!0}),stream:!0})];case 1:return r=o.sent(),n=T(r),[2,R(P(n).pipeThrough(new I({transform:function(e,r){var n=e.choices.map((function(e){var r=e.delta;return null==t&&(t=L(r)),t?Ee(Ee({},e),{finish_reason:"tool_calls",delta:r}):e})),o=Ee(Ee({},e),{choices:n});r.enqueue(Ee(Ee({},o),{rawResponse:e}))}})))]}}))}))},e}(),Ae=function(){return Ae=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Ae.apply(this,arguments)},Re=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},Pe=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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])}}},Ce=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="hunyuan-open/v1/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return Re(this,void 0,void 0,(function(){var r;return Pe(this,(function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:Ae(Ae({},z(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return r=n.sent(),[2,Ae(Ae({},r),{rawResponse:r})]}}))}))},e.prototype.doStream=function(e,t){return Re(this,void 0,void 0,(function(){var r,n,o;return Pe(this,(function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:Ae(Ae({},z(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return n=i.sent(),o=T(n),[2,R(P(o).pipeThrough(new I({transform:function(e,t){var n=e.choices.map((function(e){var t=e.delta;return null==r&&(r=L(t)),r?Ae(Ae({},e),{finish_reason:"tool_calls",delta:t}):e})),o=Ae(Ae({},e),{choices:n});t.enqueue(Ae(Ae({},o),{rawResponse:e}))}})))]}}))}))},e}(),Ne=function(){return Ne=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Ne.apply(this,arguments)},xe=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},Le=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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])}}},Ue=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="deepseek/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return xe(this,void 0,void 0,(function(){var r;return Le(this,(function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:Ne(Ne({},e),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return r=n.sent(),[2,Ne(Ne({},r),{rawResponse:r})]}}))}))},e.prototype.doStream=function(e,t){return xe(this,void 0,void 0,(function(){var r,n,o;return Le(this,(function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:Ne(Ne({},e),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return n=i.sent(),o=T(n),[2,R(P(o).pipeThrough(new I({transform:function(e,t){var n=e.choices.map((function(e){var t=e.delta;return null==r&&(r=L(t)),r?Ne(Ne({},e),{finish_reason:"tool_calls",delta:t}):e})),o=Ne(Ne({},e),{choices:n});t.enqueue(Ne(Ne({},o),{rawResponse:e}))}})))]}}))}))},e}(),ke=function(){return ke=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},ke.apply(this,arguments)},De=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},je=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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])}}},qe=function(){function e(e,t,r){void 0===r&&(r=""),this.req=e,this.baseUrl=t,this.subUrl=r}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e){return De(this,void 0,void 0,(function(){var t;return je(this,(function(r){switch(r.label){case 0:return[4,this.req({url:this.url,data:ke(ke({},e),{stream:!1}),stream:!1})];case 1:return t=r.sent(),[2,ke(ke({},t),{rawResponse:t})]}}))}))},e.prototype.doStream=function(e){return De(this,void 0,void 0,(function(){var t,r,n;return je(this,(function(o){switch(o.label){case 0:return t=null,[4,this.req({url:this.url,data:ke(ke({},e),{stream:!0}),stream:!0})];case 1:return r=o.sent(),n=T(r),[2,R(P(n).pipeThrough(new I({transform:function(e,r){var n=e.choices.map((function(e){var r=e.delta;return null==t&&(t=L(r)),t?ke(ke({},e),{finish_reason:"tool_calls",delta:r}):e})),o=ke(ke({},e),{choices:n});r.enqueue(ke(ke({},o),{rawResponse:e}))}})))]}}))}))},e}(),Me=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.provider=r,this.defaultGenerateImageSubUrl="images/generations",this.generateImageSubUrlConfig={"hunyuan-image":{"hunyuan-image-v3.0-v1.0.4":"images/ar/generations","hunyuan-image-v3.0-v1.0.1":"images/ar/generations"}},this.generateImage=this.generateImageImpl.bind(this)}return e.prototype.generateImageImpl=function(e){var t,r,n,o,i;return r=this,n=void 0,i=function(){var r,n;return function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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){switch(o.label){case 0:return r=this.defaultGenerateImageSubUrl,"object"==typeof e&&e&&"model"in e&&"string"==typeof e.model&&(n=null===(t=this.generateImageSubUrlConfig[this.provider])||void 0===t?void 0:t[e.model])&&(r=n),[4,this.req({url:this.getGenerateUrl(r),data:e,stream:!1})];case 1:return[2,o.sent()]}}))},new((o=void 0)||(o=Promise))((function(e,t){function s(e){try{u(i.next(e))}catch(e){t(e)}}function a(e){try{u(i.throw(e))}catch(e){t(e)}}function u(t){var r;t.done?e(t.value):(r=t.value,r instanceof o?r:new o((function(e){e(r)}))).then(s,a)}u((i=i.apply(r,n||[])).next())}))},e.prototype.getGenerateUrl=function(e){return"".concat(this.baseUrl,"/").concat(this.provider,"/").concat(e)},e}(),Be=function(){return Be=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Be.apply(this,arguments)},We=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},Fe=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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])}}},Ve=function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};function He(e){var t,r=e.onStepFinish,n=e.abortSignal,o=e.maxSteps,i=e.topP,s=e.toolChoice,a=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(e,["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},Be(Be({},a),{tools:null===(t=a.tools)||void 0===t?void 0:t.map((function(e){return"fn"in e?U(e):e})),top_p:null!=i?i:a.top_p,tool_choice:null!=s?s:a.tool_choice})]}var $e=function(){function e(e){this.model=e}return e.prototype.generateText=function(e,t){var r,n;return We(this,void 0,void 0,(function(){var o,i,s,a,u,c,l,f,d,h,p,v,y,m,g,b,w,_,S,E,I,O=this;return Fe(this,(function(T){switch(T.label){case 0:return o=[],i={completion_tokens:0,prompt_tokens:0,total_tokens:0},s=He(e),a=s[0],u=a.onStepFinish,c=a.maxSteps,l=void 0===c?10:c,f=s[1],[4,(d=function(){return O.model.doGenerate(f,t)})()];case 1:h=T.sent(),p=1,h.rawResponse&&o.push(h.rawResponse),v=null,T.label=2;case 2:if(!(p<l&&null!=(v=Ge(h))))return[3,9];y=Ye(h.usage),Qe(i,y),T.label=3;case 3:return T.trys.push([3,7,,8]),[4,Je(v)];case 4:return m=T.sent(),g=h.choices[0],[4,null==u?void 0:u({finishReason:g.finish_reason,messages:f.messages.slice(),text:g.message.content,toolCall:v,toolResult:m,stepUsage:y,totalUsage:Object.assign({},i)})];case 5:return T.sent(),ze(f.messages,g.message,m),[4,d()];case 6:return(h=T.sent()).rawResponse&&o.push(h.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==h?void 0:h.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=_?Ve(Ve([],f.messages,!0),[_],!1):f.messages,I=Ye(h.usage),Qe(i,I),[4,null==u?void 0:u({finishReason:w.finish_reason,messages:E.slice(),text:S,toolCall:Ge(h),toolResult:null,stepUsage:I,totalUsage:Object.assign({},i)})];case 10:return T.sent(),[2,{text:S,messages:E,usage:i,rawResponses:o}]}}))}))},e.prototype.streamText=function(e,t){var r;return We(this,void 0,void 0,(function(){var n,o,i,s,a,u,c,l,f,d,h,p,v,y,m,g,b,w,_,S,E,O,T,A,P,C,N,L,U,k,D,j,q,M,B,W,F=this;return Fe(this,(function(V){switch(V.label){case 0:return n={completion_tokens:0,prompt_tokens:0,total_tokens:0},o=He(e),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,t)})()];case 1:f=V.sent(),d=1,h=null,p=function(){var e=f.tee(),t=e[0],r=e[1];return f=R(t),function(e){var t,r,n,o,i,s,a,u,c,l;return We(this,void 0,void 0,(function(){var f,d,h,p,v,y,m,g,b,w,_,S,E;return Fe(this,(function(I){switch(I.label){case 0:f={completion_tokens:0,prompt_tokens:0,total_tokens:0},d=R(e),p={role:"assistant",content:"",tool_calls:[h={id:"",function:{name:"",arguments:""},type:""}]},I.label=1;case 1:I.trys.push([1,6,7,12]),v=!0,y=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,o){!function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)}(n,o,(t=e[r](t)).done,t.value)}))}}}(d),I.label=2;case 2:return[4,y.next()];case 3:if(m=I.sent(),t=m.done)return[3,5];o=m.value,v=!1;try{if(!(b=null==(g=o)?void 0:g.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)&&(h.id=S.id),(null==S?void 0:S.type)&&(h.type=S.type),(null===(s=null==S?void 0:S.function)||void 0===s?void 0:s.name)&&(h.function.name=S.function.name),(null===(a=null==S?void 0:S.function)||void 0===a?void 0:a.arguments)&&(h.function.arguments+=S.function.arguments),(null===(u=null==g?void 0:g.usage)||void 0===u?void 0:u.completion_tokens)&&(f.completion_tokens=g.usage.completion_tokens),(null===(c=null==g?void 0:g.usage)||void 0===c?void 0:c.prompt_tokens)&&(f.prompt_tokens=g.usage.prompt_tokens),(null===(l=null==g?void 0:g.usage)||void 0===l?void 0:l.total_tokens)&&(f.total_tokens=g.usage.total_tokens)}finally{v=!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]),v||t||!(n=y.return)?[3,9]:[4,n.call(y)];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(v=d<u)?[4,p()]:[3,4];case 3:v=null!=(h=V.sent()),V.label=4;case 4:if(!v)return[3,11];y=h.message,m=h.usage,Qe(n,m),g=null===(r=y.tool_calls)||void 0===r?void 0:r[0],V.label=5;case 5:return V.trys.push([5,9,,10]),[4,Je(g)];case 6:return b=V.sent(),[4,null==s?void 0:s({finishReason:"tool_calls",messages:c.messages.slice(),text:y.content,toolCall:g,toolResult:b,stepUsage:m,totalUsage:Object.assign({},n)})];case 7:return V.sent(),ze(c.messages,y,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:R(S),textStream:R(E.pipeThrough(new I({transform:function(e,t){var r,n,o,i=null===(o=null===(n=null===(r=null==e?void 0:e.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&&t.enqueue(i)}}))),usage:Promise.resolve(n),error:w}];case 10:return[3,2];case 11:return[4,p()];case 12:return(h=V.sent())?(O=h.message,T=h.usage,Qe(n,T),A=Ve(Ve([],c.messages,!0),[O],!1),s({messages:A.slice(),finishReason:"tool_call",stepUsage:T,text:O.content,toolCall:O.tool_calls[0],totalUsage:Object.assign({},n)}),P=f.tee(),C=P[0],N=P[1],[2,{messages:Promise.resolve(Ve(Ve([],c.messages,!0),[O],!1)),dataStream:R(C),textStream:R(N.pipeThrough(new I({transform:function(e,t){var r,n,o,i=null===(o=null===(n=null===(r=null==e?void 0:e.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&&t.enqueue(i)}}))),usage:Promise.resolve(n)}]):(L=x(),U=x(),k={role:"assistant",content:""},D="",j={completion_tokens:0,prompt_tokens:0,total_tokens:0},q=f.pipeThrough(new I({transform:function(e,t){var r,n,o,i,s,a,u,c,l=null===(o=null===(n=null===(r=null==e?void 0:e.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&&(k.content+=l);var f=null===(s=null===(i=null==e?void 0:e.choices)||void 0===i?void 0:i[0])||void 0===s?void 0:s.finish_reason;f&&(D=f),(null===(a=null==e?void 0:e.usage)||void 0===a?void 0:a.completion_tokens)&&(j.completion_tokens=e.usage.completion_tokens),(null===(u=null==e?void 0:e.usage)||void 0===u?void 0:u.prompt_tokens)&&(j.prompt_tokens=e.usage.prompt_tokens),(null===(c=null==e?void 0:e.usage)||void 0===c?void 0:c.total_tokens)&&(j.total_tokens=e.usage.total_tokens),t.enqueue(e)},flush:function(){L.res(Ve(Ve([],c.messages,!0),[k],!1)),Qe(n,j),U.res(Object.assign({},n)),null==s||s({messages:Ve(Ve([],c.messages,!0),[k],!1),finishReason:D,text:k.content,stepUsage:j,totalUsage:Object.assign({},n)})}})),M=q.tee(),B=M[0],W=M[1],[2,{messages:L.promise,dataStream:R(B),textStream:R(W.pipeThrough(new I({transform:function(e,t){var r,n,o,i=null===(o=null===(n=null===(r=null==e?void 0:e.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&&t.enqueue(i)}}))),usage:U.promise}])}}))}))},e}();function Ge(e){var t,r=null===(t=null==e?void 0:e.choices)||void 0===t?void 0:t[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 ze(e,t,r){e.push(t,{role:"tool",tool_call_id:t.tool_calls[0].id,content:JSON.stringify(r)})}var Ke=new Map;function Je(e){return Ke.get(e.function.name)(JSON.parse(e.function.arguments))}function Ye(e){var t,r,n;return{completion_tokens:null!==(t=null==e?void 0:e.completion_tokens)&&void 0!==t?t:0,prompt_tokens:null!==(r=null==e?void 0:e.prompt_tokens)&&void 0!==r?r:0,total_tokens:null!==(n=null==e?void 0:e.total_tokens)&&void 0!==n?n:0}}function Qe(e,t){e.completion_tokens+=t.completion_tokens,e.prompt_tokens+=t.prompt_tokens,e.total_tokens+=t.total_tokens}var Ze={hunyuan:re,"hunyuan-beta":Z,ark:ae,dashscope:de,"01-ai":me,moonshot:Se,zhipu:$,"hunyuan-exp":Te,"hunyuan-open":Ce,deepseek:Ue},Xe=r(3616),et=function(){return et=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},et.apply(this,arguments)},tt=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},rt=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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])}}},nt=Ze,ot=function(){function e(e,t,r){var n=this;this.req=e,this.baseUrl=t,this.modelRequest=function(e){var t=e.url,r=e.data,o=e.headers,i=e.stream,s=e.timeout;return tt(n,void 0,void 0,(function(){var e,n,a,u,c,l,f;return rt(this,(function(d){switch(d.label){case 0:return e={"Content-Type":"application/json"},i&&Object.assign(e,{Accept:"text/event-stream"}),[4,this.req.fetch({method:"post",headers:et(et((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),e),o),body:JSON.stringify(r),url:t,stream:i,timeout:s})];case 1:return n=d.sent(),a=n.data,u=n.header,[2,this.handleResponseData(a,u)]}}))}))},this.botRequest=function(e){var t=e.method,r=e.url,o=e.data,i=void 0===o?{}:o,s=e.headers,a=e.stream,u=e.timeout;return tt(n,void 0,void 0,(function(){var e,n,o,c,l,f,d,h;return rt(this,(function(p){switch(p.label){case 0:return"get"!==t?[3,2]:(e=this.handleResponseData,[4,this.req.fetch({url:"".concat(r,"?").concat((v=i,Object.entries(v).map((function(e){var t=e[0],r=e[1];return"".concat(t,"=").concat(r)})).join("&"))),method:t,headers:s,stream:a,timeout:u})]);case 1:return[2,e.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:et(et((f={},f[null===(d=this.i18n)||void 0===d?void 0:d.LANG_HEADER_KEY]=null===(h=this.i18n)||void 0===h?void 0:h.lang,f),n),s),stream:a,method:t,timeout:u})];case 3:return o=p.sent(),c=o.data,l=o.header,[2,this.handleResponseData(c,l)]}var v}))}))},this.aiBaseUrl="".concat(t,"/ai"),this.aiBotBaseUrl="".concat(t,"/aibot"),this.bot=new M(this.botRequest,this.aiBotBaseUrl),this.i18n=r,Xe.RR.$.on(Xe.RR.P,(function(e){var t;n.i18n=(null===(t=e.data)||void 0===t?void 0:t.i18n)||n.i18n}))}return e.prototype.handleResponseData=function(e,t){var r,n;return tt(this,void 0,void 0,(function(){var o,i;return rt(this,(function(s){switch(s.label){case 0:return o="".concat(this.i18n.t("请检查调用方式,或前往云开发 AI+ 首页查看文档"),":https://tcb.cloud.tencent.com/dev#/ai"),"object"==typeof e&&e&&"then"in e?[4,e]:[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,e];case 2:return(null===(n=null===(r=null==t?void 0:t.get)||void 0===r?void 0:r.call(t,"content-type"))||void 0===n?void 0:n.includes("application/json"))?[4,N(e)]:[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,e]}}))}))},e.prototype.createModel=function(e,t){var r,n=nt[e];if(n)r=new n(this.modelRequest,this.aiBaseUrl);else{var o="string"==typeof(null==t?void 0:t.defaultModelSubUrl)?t.defaultModelSubUrl:"/chat/completions";r=new qe(this.modelRequest,this.aiBaseUrl,"".concat(e).concat(o))}return new $e(r)},e.prototype.registerModel=function(e,t){null==nt[e]?nt[e]=t:console.warn("AI model ".concat(e," already exists!"))},e.prototype.createImageModel=function(e){return new Me(this.modelRequest,this.aiBaseUrl,e)},e.prototype.registerFunctionTool=function(e){Ke.has(e.name)&&console.warn("AI function tool ".concat(e.name," already exists and will be overwritten!")),Ke.set(e.name,e.fn)},e}(),it=function(){},st=function(){return st=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},st.apply(this,arguments)},at=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r},ut=at(o,["MODELS"]),ct=function(e){var t=e.getAccessToken,r=e.req;return{download:r.download,post:r.post,upload:r.upload,fetch:function(e){return n=void 0,o=void 0,s=function(){var n,o,i,s,a;return function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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=e.token,o=e.headers,i=void 0===o?{}:o,s=at(e,["token","headers"]),null==n?[3,1]:(a=n,[3,3]);case 1:return[4,t()];case 2:a=u.sent().accessToken,u.label=3;case 3:return[2,r.fetch(st({headers:st({Authorization:"Bearer ".concat(a)},i)},s))]}}))},new((i=void 0)||(i=Promise))((function(e,t){function r(e){try{u(s.next(e))}catch(e){t(e)}}function a(e){try{u(s.throw(e))}catch(e){t(e)}}function u(t){var n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i((function(e){e(n)}))).then(r,a)}u((s=s.apply(n,o||[])).next())}));var n,o,i,s}}};function lt(e){var t=e.env,r=e.baseUrl,n=e.req,o=e.getAccessToken,i=e.handleReqInstance,s=e.i18n;return new ot(function(){if(null==i){if(null==o)throw new Error("`getAccessToken` is required when `handleReqInstance` is not provided!");return ct({req:n,getAccessToken:o})}return i({req:n})}(),function(){if(null!=r)return r;if(null==t)throw new Error("`env` is required when `baseUrl` is not provided!");return"https://".concat(t,".api.tcloudbasegateway.com/v1")}(),s)}var ft=lt,dt={name:"ai",entity:{ai:function(e){var t,r=this,n=this.request;if(null==n.fetch)throw new Error("cloudbase.request.fetch() unimplemented!");return lt({req:n,baseUrl:null!==(t=null==e?void 0:e.baseUrl)&&void 0!==t?t:function(){var e=r.getEndPointWithKey("GATEWAY"),t=e.BASE_URL,n=e.PROTOCOL;return"".concat(n).concat(t)}(),handleReqInstance:function(e){return e.req},i18n:this.config.i18n})}}};function ht(e){try{e.registerComponent(dt)}catch(e){console.warn(e)}}try{window.registerAi=ht}catch(e){}},7505:function(e,t,r){"use strict";r.r(t),r.d(t,{registerAnalytics:function(){return d}});var n=r(3616),o=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},i=n._G.Sg,s=n._G.vM,a=n.BM.D,u="analytics",c=["mall"],l=new(function(){function e(){}return e.prototype.analytics=function(e){return t=this,r=void 0,o=function(){var t,r,n;return function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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(e){if("Object"!==Object.prototype.toString.call(e).slice(8,-1))return!1;var t=e.report_data,r=e.report_type;return!1!==c.includes(r)&&"Object"===Object.prototype.toString.call(t).slice(8,-1)&&!(void 0!==t.action_time&&!Number.isInteger(t.action_time))&&"string"==typeof t.action_type}(e))throw new Error(JSON.stringify({code:i.INVALID_PARAMS,msg:"[".concat(u,".analytics] invalid report data")}));return t=void 0===e.report_data.action_time?Math.floor(Date.now()/1e3):e.report_data.action_time,r={analytics_scene:e.report_type,analytics_data:Object.assign({},e.report_data,{action_time:t})},n={requestData:r},this.request.send("analytics.report",n),[2]}))},new((n=void 0)||(n=Promise))((function(e,i){function s(e){try{u(o.next(e))}catch(e){i(e)}}function a(e){try{u(o.throw(e))}catch(e){i(e)}}function u(t){var r;t.done?e(t.value):(r=t.value,r instanceof n?r:new n((function(e){e(r)}))).then(s,a)}u((o=o.apply(t,r||[])).next())}));var t,r,n,o},function(e,t,r,n){var o,i=arguments.length,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);i>3&&s&&Object.defineProperty(t,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)],e.prototype,"analytics",null),e}()),f={name:u,entity:{analytics:l.analytics}};try{cloudbase.registerComponent(f)}catch(e){}function d(e){try{e.registerComponent(f)}catch(e){console.warn(e)}}},41:function(e,t,r){"use strict";r.r(t),r.d(t,{generateApis:function(){return l},registerApis:function(){return h}});var n=r(794),o=function(){return o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},o.apply(this,arguments)},i=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},s=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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 a(e,t){var r,a,u,c;return i(this,void 0,void 0,(function(){var i,l,f,d,h,p,v,y,m,g,b,w,_,S,E,I,O,T,A,R,P,C,N;return s(this,(function(s){switch(s.label){case 0:l=(i=e||{}).name,f=i.body,d=i.path,h=void 0===d?"":d,p=i.method,v=void 0===p?"POST":p,y=i.headers,m=void 0===y?{}:y,g=(e||{}).token,b={};try{b=JSON.parse(f)}catch(e){b=f||{}}if(!l)throw new Error(JSON.stringify({code:n.ERRORS.INVALID_PARAMS,msg:"[apis] invalid api name"}));return w="",S=(_=this).gatewayOrigin,E=_.getAccessToken,I=_.env,S?w="".concat(S,"/v1"):this.getEndPointWithKey?(O=this.getEndPointWithKey("GATEWAY"),T=O.BASE_URL,A=O.PROTOCOL,w="".concat(A).concat(T)):w="https://".concat(I,".api.tcloudbasegateway.com/v1"),R="".concat(w,"/apis/").concat(l),P=h.startsWith("/")?h:"/".concat(h),E?[4,E()]:[3,2];case 1:C=s.sent().accessToken,m.Authorization="Bearer ".concat(C),s.label=2;case 2:if(N=["GET","HEAD"].includes(null===(r=null==v?void 0:v.toUpperCase)||void 0===r?void 0:r.call(v)))try{P="".concat(P).concat(P.includes("?")?"&":"?").concat(Object.keys(b).map((function(e){return"".concat(e,"=").concat(b[e])})).join("&"))}catch(e){}return[4,this.request.fetch(o(o(o({url:"".concat(R).concat(P),method:v||"POST",headers:o({"Content-Type":"application/json; charset=utf-8"},m)},N?{}:{body:JSON.stringify(b)}),{token:(null===(a=null==g?void 0:g.trim)||void 0===a?void 0:a.call(g))||(null===(c=null===(u=m.Authorization)||void 0===u?void 0:u.replace)||void 0===c?void 0:c.call(u,/^Bearer /,""))||null}),t))];case 3:return[4,s.sent().data];case 4:return[2,s.sent()]}}))}))}var u=["GET","POST","PUT","DELETE","HEAD","OPTIONS","PATCH","REQUEST"];function c(e){var t=this;return new Proxy({},{get:function(r,n){if("string"!=typeof n)throw new Error("[apis] method must be string");var c=n.toLocaleUpperCase();if(!u.includes(c))throw new Error("[apis] invalid method: ".concat(n));return function(r,n){return i(t,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,a.call(this,o({name:e,method:("REQUEST"===c?r.method:c)||"POST"},r),n)];case 1:return[2,t.sent()]}}))}))}}})}function l(e){var t=this;return Object.keys(e||{}).forEach((function(r){void 0!==e[r]&&(t[r]=e[r])})),new Proxy({},{get:function(e,r){if("string"==typeof r)return c.call(t,r)}})}var f="apis",d={name:f,IIFE:!0,entity:function(){Object.defineProperty(this.prototype,f,{get:function(){return l.call(this)},configurable:!0,enumerable:!0})}};function h(e){try{e.registerComponent(d)}catch(e){console.warn(e)}}try{cloudbase.registerComponent(d)}catch(e){}try{window.registerApis=h}catch(e){}},9917:function(e,t,r){"use strict";r.r(t),r.d(t,{LANGS:function(){return $},cloudbase:function(){return le},default:function(){return fe},getBaseEndPoint:function(){return L}});var n=r(3616),o=function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))},i=n._G.Sg,s={};function a(e,t){var r=t.name,n=t.namespace,a=t.entity,c=t.injectEvents,l=t.IIFE,f=void 0!==l&&l;if(s[r]||n&&e[n])throw new Error(JSON.stringify({code:i.INVALID_OPERATION,msg:"Duplicate component ".concat(r)}));if(f){if(!a||"function"!=typeof a)throw new Error(JSON.stringify({code:i.INVALID_PARAMS,msg:"IIFE component's entity must be a function"}));a.call(e)}if(s[r]=t,n?e.prototype[n]=a:u(e.prototype,a),c){var d=c.bus,h=c.events;if(!d||!h||0===h.length)return;var p=e.prototype.fire||function(){};e.prototype.events||(e.prototype.events={}),(e.prototype.events||{})[r]?e.prototype.events[r].events=o(o([],e.prototype.events[r].events,!0),h,!0):e.prototype.events[r]={bus:d,events:h},e.prototype.fire=function(e,t){p(e,t);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(e)){s.fire(e,t);break}}}}}function u(e,t){if(!(t instanceof Object))return t;switch(t.constructor){case Date:return new Date(t.getTime());case Object:void 0===e&&(e={});break;case Array:e=[];break;default:return t}for(var r=0,n=Object.keys(t);r<n.length;r++){var o=n[r];Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=u(e[o],t[o]))}return e}var c=r(190),l=r(2829),f=function(){return f=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},f.apply(this,arguments)},d={},h=function(){return h=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},h.apply(this,arguments)},p=n.Fs.q,v={},y={};function m(e){var t=e.env,r=e.platformInfo,n={userInfoKey:"".concat("user_info","_").concat(t)};v[t]=v[t]||new p(h(h({},e),{keys:n,platformInfo:r})),y[t]=y[t]||new p(h(h({},e),{keys:n,platformInfo:r,persistence:"local"}))}function g(e){return y[e]}var b=function(){return b=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},b.apply(this,arguments)},w=["ap-shanghai","ap-guangzhou","ap-shenzhen-fsi","ap-shanghai-fsi","ap-nanjing","ap-beijing","ap-chengdu","ap-chongqing","ap-hongkong"],_=n._G.tC,S=n._G.pM,E="",I="@cloudbase/js-sdk";function O(){return E}var T,A=[],R=["env","endPointKey","region"],P="https:";function C(e){return A.find((function(t){return R.filter((function(t){return null!=e[t]})).every((function(r){return t[r]===e[r]}))}))}function N(e){var t,r;e.protocol&&!/:$/.test(e.protocol)&&(e.protocol="".concat(e.protocol,":"));var n=C(e);n?(null!=e.baseUrl&&(n.baseUrl=e.baseUrl),null!=e.protocol&&(n.protocol=e.protocol)):A.push(b(b({},e),{protocol:null!==(t=e.protocol)&&void 0!==t?t:P})),"CLOUD_API"===e.endPointKey&&S(null!==(r=e.protocol)&&void 0!==r?r:P)}function x(e,t,r){return C({env:e,endPointKey:t,region:r})}function L(e,t){void 0===t&&(t="CLOUD_API");var r=x(e,t||"CLOUD_API"),n=r.protocol,o=r.baseUrl;return"".concat(n).concat(o).match(/(http(s)?:)?\/\/([^/?#]*)/)[0]}!function(e){e.NULL="NULL",e.ANONYMOUS="ANONYMOUS",e.WECHAT="WECHAT",e.WECHAT_PUBLIC="WECHAT-PUBLIC",e.WECHAT_OPEN="WECHAT-OPEN",e.CUSTOM="CUSTOM",e.EMAIL="EMAIL",e.USERNAME="USERNAME",e.PHONE="PHONE"}(T||(T={}));var U=function(){return U=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},U.apply(this,arguments)},k=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},D=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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,q=n.P6.genSeqId,M=n.P6.isFormData,B=n.P6.formatUrl,W=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"];function F(e,t,r){var n=e[t];e[t]=function(t){var o={},i={};r.forEach((function(r){var n=r.call(e,t),s=n.data,a=n.headers;Object.assign(o,s),Object.assign(i,a)}));var s=t.data;return s&&(M(s)?Object.keys(o).forEach((function(e){s.append(e,o[e])})):t.data=U(U({},s),o)),t.headers=U(U({},t.headers||{}),i),n.call(e,t)}}function V(){var e=q();return{data:{seqId:e},headers:{"X-SDK-Version":"@cloudbase/js-sdk/".concat(O()),"x-seqid":e}}}var H,$,G=function(){function e(e){var t=this;this.throwWhenRequestFail=!1,this.config=e;var r={timeout:this.config.timeout,timeoutMsg:"[@cloudbase/js-sdk] 请求在".concat(this.config.timeout/1e3,"s内未完成,已中断"),restrictedMethods:["post","put"],auth:e.auth};this.reqClass=new d.adapter.reqClass(r),this.throwWhenRequestFail=e.throw||!1,this.localCache=g(this.config.env),"GATEWAY"!==this.config.endPointMode&&(F(this.reqClass,"post",[V]),F(this.reqClass,"upload",[V]),F(this.reqClass,"download",[V])),n.RR.$.on(n.RR.P,(function(e){var r;t.config.i18n=(null===(r=e.data)||void 0===r?void 0:r.i18n)||t.config.i18n}))}return e.prototype.getAccessToken=function(e){return void 0===e&&(e=null),k(this,void 0,void 0,(function(){var t,r,n;return D(this,(function(o){switch(o.label){case 0:if(null!=e)return[2,e];if(!(t=this.config._fromApp).oauthInstance)throw new Error("you can't request without auth");return r=t.oauthInstance,n=r.oauth2client,[4,this.getOauthAccessTokenV2(n)];case 1:return[2,o.sent().accessToken]}}))}))},e.prototype.getDefaultHeaders=function(){var e,t,r;return(e={})[null===(t=this.config.i18n)||void 0===t?void 0:t.LANG_HEADER_KEY]=null===(r=this.config.i18n)||void 0===r?void 0:r.lang,e["X-SDK-Version"]="@cloudbase/js-sdk/".concat(O()),e},e.prototype.post=function(e,t){return k(this,void 0,void 0,(function(){return D(this,(function(r){switch(r.label){case 0:return[4,this.reqClass.post(U(U({},e),{headers:U(U({},e.headers),this.getDefaultHeaders()),customReqOpts:t}))];case 1:return[2,r.sent()]}}))}))},e.prototype.upload=function(e){return k(this,void 0,void 0,(function(){return D(this,(function(t){switch(t.label){case 0:return[4,this.reqClass.upload(U(U({},e),{headers:U(U({},e.headers),this.getDefaultHeaders())}))];case 1:return[2,t.sent()]}}))}))},e.prototype.download=function(e){return k(this,void 0,void 0,(function(){return D(this,(function(t){switch(t.label){case 0:return[4,this.reqClass.download(U(U({},e),{headers:U(U({},e.headers),this.getDefaultHeaders())}))];case 1:return[2,t.sent()]}}))}))},e.prototype.getBaseEndPoint=function(e){return void 0===e&&(e="CLOUD_API"),L(this.config.env,e)},e.prototype.getOauthAccessTokenV2=function(e){return k(this,void 0,void 0,(function(){var t,r;return D(this,(function(n){switch(n.label){case 0:return[4,e.getAccessToken()];case 1:return t=n.sent(),[4,e.getCredentials()];case 2:return r=n.sent(),[2,{accessToken:t,accessTokenExpire:new Date(r.expires_at).getTime()}]}}))}))},e.prototype.request=function(e,t,r,n){var o,i;return k(this,void 0,void 0,(function(){var s,a,u,c,l,f,d,h,p,v,y,m,g,b,w,_,S,E,I,O,T,A,R;return D(this,(function(P){switch(P.label){case 0:if(P.trys.push([0,4,,5]),s="x-tcb-trace_".concat(this.config.env),a="application/x-www-form-urlencoded",u=U({action:e,dataVersion:"2020-01-10",env:this.config.env},t),-1!==W.indexOf(e))return[3,2];if(!(c=this.config._fromApp).oauthInstance)throw new Error("you can't request without auth");return l=c.oauthInstance,f=l.oauth2client,d=u,[4,this.getOauthAccessTokenV2(f)];case 1:d.access_token=P.sent().accessToken,P.label=2;case 2:return"storage.uploadFile"===e?(h=new FormData,Object.keys(h).forEach((function(e){Object.prototype.hasOwnProperty.call(h,e)&&void 0!==h[e]&&h.append(e,u[e])})),a="multipart/form-data"):(a="application/json;charset=UTF-8",h={},Object.keys(u).forEach((function(e){void 0!==u[e]&&(h[e]=u[e])}))),p={headers:U(U({"content-type":a},this.getDefaultHeaders()),null==r?void 0:r.headers)},(null==r?void 0:r.onUploadProgress)&&(p.onUploadProgress=r.onUploadProgress),this.config.region&&(p.headers["X-TCB-Region"]=this.config.region),(v=this.localCache.getStore(s))&&(p.headers["X-TCB-Trace"]=v),y=void 0!==(null==r?void 0:r.parse)?r.parse:t.parse,m=void 0!==(null==r?void 0:r.inQuery)?r.inQuery:t.inQuery,g=void 0!==(null==r?void 0:r.search)?r.search:t.search,b=U(U({},(null==r?void 0:r.defaultQuery)||{}),{env:this.config.env}),y&&(b.parse=!0),m&&(b=U(U({},m),b)),w=(null==r?void 0:r.endPointMode)||this.config.endPointMode||"CLOUD_API",_=x(this.config.env,w),S=_.baseUrl,E=_.protocol,"GATEWAY"===w&&/^((database)\.)|(auth\.wsWebSign)/.test(e)&&(I=x(this.config.env,"CLOUD_API"),S="".concat(I.baseUrl.match(/\/\/([^/?#]*)/)[0],"/web")),O=void 0,O=r.pathname?B(E,"".concat(null===(o=L(this.config.env,w))||void 0===o?void 0:o.replace(/^https?:/,""),"/").concat(r.pathname),b):B(E,S,b),g&&(O+=g),[4,this.post(U({url:O,data:h},p),n)];case 3:if(T=P.sent(),(A=null===(i=T.header)||void 0===i?void 0:i["x-tcb-trace"])&&this.localCache.setStore(s,A),200!==Number(T.status)&&200!==Number(T.statusCode)||!T.data)throw new Error("network request error");return[2,T];case 4:R=P.sent();try{R.requestId=R.requestId||(null==r?void 0:r.headers["x-request-id"])||(null==r?void 0:r.headers["X-Request-Id"])||""}catch(e){}throw R;case 5:return[2]}}))}))},e.prototype.fetch=function(e){var t,r,n,o,i,s,a,u;return k(this,void 0,void 0,(function(){var c,l,f,d,h,p,v=this;return D(this,(function(y){switch(y.label){case 0:c=e.token,l=e.headers,f=void 0===l?{}:l,d=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(e,["token","headers"]),h=function(){return k(v,void 0,void 0,(function(){var e,t,r,n,o;return D(this,(function(i){switch(i.label){case 0:return t=(e=this.reqClass).fetch,n={},o={"X-SDK-Version":"@cloudbase/js-sdk/".concat(O())},r="Bearer ".concat,[4,this.getAccessToken(c)];case 1:return[2,t.apply(e,[U.apply(void 0,[(n.headers=U.apply(void 0,[U.apply(void 0,[(o.Authorization=r.apply("Bearer ",[i.sent()]),o),this.getDefaultHeaders()]),f]),n),d])])]}}))}))},y.label=1;case 1:return y.trys.push([1,3,,6]),[4,h()];case 2:return[2,y.sent()];case 3:p=y.sent();try{p.requestId=p.requestId||f["x-request-id"]||f["X-Request-Id"]||""}catch(e){}if("ACCESS_TOKEN_EXPIRED"!==(null==p?void 0:p.code))return[3,5];if("function"!=typeof(null===(o=null===(n=null===(r=null===(t=this.config)||void 0===t?void 0:t._fromApp)||void 0===r?void 0:r.oauthInstance)||void 0===n?void 0:n.authApi)||void 0===o?void 0:o.refreshTokenForce))throw p;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 y.sent(),[2,h()];case 5:throw p;case 6:return[2]}}))}))},e.prototype.send=function(e,t,r,n){return void 0===t&&(t={}),void 0===r&&(r={}),k(this,void 0,void 0,(function(){var o;return D(this,(function(i){switch(i.label){case 0:return[4,this.request(e,t,U(U({},r),{onUploadProgress:t.onUploadProgress}),n)];case 1:if((o=i.sent()).data.code&&this.throwWhenRequestFail)throw new Error(JSON.stringify({code:j.OPERATION_FAIL,msg:"[".concat(o.data.code,"] ").concat(o.data.message)}));return[2,o.data]}}))}))},e.prototype.gateWay=function(e,t){var r;return k(this,void 0,void 0,(function(){var o,i,s,a,u,c,l,f,d,h,p,v,y,m,g,b,w,_,S;return D(this,(function(E){switch(E.label){case 0:if(o=e.url,i=e.name,s=e.data,a=e.path,u=void 0===a?"":a,c=e.method,l=e.header,f=void 0===l?{}:l,!(i&&u||o))throw new Error(JSON.stringify({code:j.INVALID_PARAMS,msg:"[gateWay] invalid function name or path or url"}));try{d=s?JSON.stringify(s):""}catch(e){throw new Error(JSON.stringify({code:j.INVALID_PARAMS,msg:"[gateWay] invalid data"}))}if(h=n.P6.generateRequestId(),p=x(this.config.env,"GATEWAY"),v=p.baseUrl,y=p.protocol,m="".concat(y).concat(v).concat(o||"/".concat(u,"/").concat(i)),g=["GET","HEAD"].includes(null===(r=null==c?void 0:c.toUpperCase)||void 0===r?void 0:r.call(c)))try{b={};try{b=JSON.parse(s)}catch(e){b=s||{}}m="".concat(m).concat(m.includes("?")?"&":"?").concat(Object.keys(b).map((function(e){return"".concat(e,"=").concat(b[e])})).join("&"))}catch(e){}return[4,this.fetch(U(U({method:c||"POST",headers:U({"Content-Type":"application/json; charset=utf-8","X-Request-Id":h},f)},g?{}:{body:d}),{url:m,customReqOpts:t}))];case 1:return w=E.sent(),_=[U({requestId:h},w)],S={},[4,w.data];case 2:return[2,U.apply(void 0,_.concat([(S.data=E.sent(),S)]))]}}))}))},e}(),z={};!function(e){e.ZH="zh-CN",e.EN="en-US"}($||($={}));var K=((H={})[$.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"},H),J=function(e,t){var r;return(null===(r=K[t])||void 0===r?void 0:r[e])||e},Y=function(e,t){var r,o,i=function(e){return"lang_".concat(e.clientId||e.env)}(t),s=(e.adapter||{}).localStorage,a=t.lang||(null===(r=null==s?void 0:s.getItem)||void 0===r?void 0:r.call(s,i))||$.ZH;return null===(o=null==s?void 0:s.setItem)||void 0===o||o.call(s,i,a),new Proxy({t:function(e){return J(e,a)},LANG_HEADER_KEY:"Accept-Language",lang:a},{get:function(e,t){var r;return"lang"===t&&(null===(r=null==s?void 0:s.getItem)||void 0===r?void 0:r.call(s,i))||e[t]},set:function(e,t,r){var o;return"lang"===t&&r!==e[t]&&(e[t]=r,e.t=function(e){return J(e,r)},null===(o=null==s?void 0:s.setItem)||void 0===o||o.call(s,i,r),n.RR.$.fire(n.RR.P,{i18n:e})),e[t]=r,!0}})},Q=function(){return Q=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Q.apply(this,arguments)},Z=function(e,t,r,n){var o,i=arguments.length,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s},X=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},ee=n.j$.Fk,te=n.j$.xY,re=n._G.Sg,ne=n._G.vM,oe=n.P6.printWarn,ie=n.BM.D,se={timeout:15e3,persistence:"local"},ae=6e5,ue={},ce=function(){function e(e){this.cloudbaseConfig=e||this.cloudbaseConfig,this.authInstance=null,this.oauthInstance=null,this.version=O()}return Object.defineProperty(e.prototype,"config",{get:function(){return this.cloudbaseConfig},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"platform",{get:function(){return d},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cache",{get:function(){return e=this.cloudbaseConfig.env,v[e];var e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"localCache",{get:function(){return g(this.cloudbaseConfig.env)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"request",{get:function(){return e=this.cloudbaseConfig.env,z[e];var e},enumerable:!1,configurable:!0}),e.prototype.init=function(t){var r,n,o;if(void 0===t&&(t={env:""}),t.endPointMode=t.endPointMode||"GATEWAY",d.adapter||this.useDefaultAdapter(),!(t=this.dealNodeAdapterConfig(t)).env)throw new Error(JSON.stringify({code:re.INVALID_PARAMS,msg:"env must not be specified"}));this.isInitialized(t);var i={timeout:t.timeout||15e3,timeoutMsg:"[".concat(I,"][REQUEST TIMEOUT] request had been abort since didn't finished within").concat(t.timeout/1e3,"s"),auth:t.auth};this.requestClient=new d.adapter.reqClass(i),this.cloudbaseConfig=Q(Q(Q({},se),t),{i18n:Y(d,t)}),delete this.cloudbaseConfig.lang,this.cloudbaseConfig.timeout=this.formatTimeout(this.cloudbaseConfig.timeout);var s=this.cloudbaseConfig,a=s.env,u=s.persistence,c=s.debug,l=s.timeout,f=s.oauthClient,h=s.i18n;m({env:a,persistence:u,debug:c,platformInfo:this.platform}),function(e,t){N({env:e,region:t,baseUrl:"//".concat(e,".").concat(t||"ap-shanghai",".tcb-api.tencentcloudapi.com/web"),protocol:void 0,endPointKey:"CLOUD_API"})}(a,t.region||""),function(e,t,r){void 0===r&&(r="ap-shanghai"),r=r||"ap-shanghai";var n="//".concat(e,".api.tcloudbasegateway.com/v1");w.includes(r)||(n="//".concat(e,".api.intl.tcloudbasegateway.com/v1")),N({endPointKey:"GATEWAY",env:e,baseUrl:n,protocol:t})}(a,P,t.region||"");var p=new e(this.cloudbaseConfig);return function(e){z[e.env]=new G(U(U({},e),{throw:!0}))}({env:a,region:t.region||"",timeout:l,oauthClient:f,_fromApp:p,i18n:h,endPointMode:t.endPointMode,auth:t.auth}),p.requestClient=this.requestClient,null===(r=null==this?void 0:this.fire)||void 0===r||r.call(this,"cloudbase_init",p),this.try2InitAuth(p),(null===(n=d.adapter)||void 0===n?void 0:n.nodeTool)&&(null===(o=d.adapter)||void 0===o||o.nodeTool(p,this.cloudbaseConfig)),p},e.prototype.updateConfig=function(e){var t=e.persistence,r=e.debug;this.cloudbaseConfig.persistence=t,this.cloudbaseConfig.debug=r,m({env:this.cloudbaseConfig.env,persistence:t,debug:r,platformInfo:this.platform})},e.prototype.updateLang=function(e){var t;e&&e!==(null===(t=this.cloudbaseConfig.i18n)||void 0===t?void 0:t.lang)&&(this.cloudbaseConfig.i18n.lang=e)},e.prototype.registerExtension=function(e){ue[e.name]=e},e.prototype.invokeExtension=function(e,t){return r=this,n=void 0,i=function(){var r;return function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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=ue[e]))throw new Error(JSON.stringify({code:re.INVALID_PARAMS,msg:"extension:".concat(e," must be registered before invoke")}));return[4,r.invoke(t,this)];case 1:return[2,n.sent()]}}))},new((o=void 0)||(o=Promise))((function(e,t){function s(e){try{u(i.next(e))}catch(e){t(e)}}function a(e){try{u(i.throw(e))}catch(e){t(e)}}function u(t){var r;t.done?e(t.value):(r=t.value,r instanceof o?r:new o((function(e){e(r)}))).then(s,a)}u((i=i.apply(r,n||[])).next())}));var r,n,o,i},e.prototype.useAdapters=function(e,t){var r=ee(e,t)||{},n=r.adapter,o=r.runtime;n&&(d.adapter=n),o&&(d.runtime=o)},e.prototype.registerHook=function(t){!function(e,t){var r=t.entity,n=t.target;if(Object.prototype.hasOwnProperty.call(e,n))throw new Error(JSON.stringify({code:i.INVALID_OPERATION,msg:"target:".concat(n," is not exist")}));var s=e.prototype[n];if("function"!=typeof s)throw new Error(JSON.stringify({code:i.INVALID_OPERATION,msg:"target:".concat(n," is not a function which is the only type supports hook")}));e.prototype[n]=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return r.call.apply(r,o([this],e,!1)),s.call.apply(s,o([this],e,!1))}}(e,t)},e.prototype.registerComponent=function(t){a(e,t)},e.prototype.registerVersion=function(e){!function(e){E=e}(e),this.version=e},e.prototype.registerSdkName=function(e){!function(e){I=e,_(e)}(e)},e.prototype.isInitialized=function(e){return void 0===e&&(e=this.cloudbaseConfig),["your-env-id","your-envid","your_env_id","xxx-yyy","xxxx-yyy","envId","env-id","your-environment-id","REPLACE_ME"].some((function(t){return e.env.toLowerCase()===t.toLowerCase()}))&&oe(re.INVALID_PARAMS,'[CloudBase] 检测到环境 ID "'.concat(e.env,'" 可能是占位符,请替换为真实的环境 ID。\n')+" 获取方式:登录腾讯云开发平台 → 环境管理 → 环境设置 → 环境 ID\n 建议通过环境变量配置:process.env.CLOUDBASE_ENV 或 import.meta.env.VITE_CLOUDBASE_ENV"),!!(null==e?void 0:e.env)},e.prototype.registerEndPoint=function(e,t){N({baseUrl:e,protocol:t,env:this.config.env,endPointKey:"CLOUD_API"})},e.prototype.registerEndPointWithKey=function(e){N({env:this.config.env,endPointKey:e.key,baseUrl:e.url,protocol:e.protocol})},e.prototype.getEndPointWithKey=function(e){var t=x(this.config.env,e);return{BASE_URL:t.baseUrl,PROTOCOL:t.protocol}},e.prototype.parseCaptcha=function(e){return n.P6.parseCaptcha(e)},e.prototype.useDefaultAdapter=function(){var e=te.bind(this)(),t=e.adapter,r=e.runtime;d.adapter=t,d.runtime=r},e.prototype.formatTimeout=function(e){switch(!0){case e>ae:return oe(re.INVALID_PARAMS,"timeout is greater than maximum value[10min]"),ae;case e<100:return oe(re.INVALID_PARAMS,"timeout is less than maximum value[100ms]"),100;default:return e}},e.prototype.try2InitAuth=function(e){try{e.auth()}catch(e){console.log("try2InitAuth error:",e)}},e.prototype.dealNodeAdapterConfig=function(e){return e},Z([ie({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(ne)]}),X("design:type",Function),X("design:paramtypes",[Object]),X("design:returntype",e)],e.prototype,"init",null),Z([ie({title:"调用扩展能力失败",messages:["请确认以下各项:"," 1 - 调用 invokeExtension() 的语法或参数是否正确"," 2 - 被调用的扩展能力是否已经安装并通过 registerExtension() 注册","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(ne)]}),X("design:type",Function),X("design:paramtypes",[String,Object]),X("design:returntype",Promise)],e.prototype,"invokeExtension",null),e}(),le=new ce;le.useAdapters((c.x5.prototype.upload=function(e){var t=this,r=this;return new Promise((function(n){var o=e.url,i=e.file,s=e.data,a=e.headers,u=wx.getFileSystemManager(),c=wx.request({url:o,method:e.method,header:f({"content-type":" "},a),data:u.readFileSync(i),timeout:t._timeout,success:function(e){var t={statusCode:e.statusCode,data:e.data||{}};200===e.statusCode&&(null==s?void 0:s.success_action_status)&&(t.statusCode=parseInt(s.success_action_status,10)),n(t)},fail:function(e){n(e)},complete:function(e){if((null==e?void 0:e.errMsg)&&r._timeout&&-1!==r._restrictedMethods.indexOf("upload")&&"request:fail timeout"===e.errMsg){console.warn(r._timeoutMsg);try{c.abort()}catch(e){}}}})}))},c.ZP.genAdapter=function(e){return{root:{globalThis:{}},reqClass:c.x5,wsClass:c.ng,captchaOptions:{openURIWithCallback:function(t){var r=e.EventBus,n={},o=t;console.log("openURIWithCallback",t);var i=t.match(/^(data:.*?)(\?[^#\s]*)?$/);if(i){o=i[1],console.log("openURIWithCallback url",o);var s=i[2];s&&(n=(0,c.dD)(s))}console.log("openURIWithCallback queryObj",n);var a=n.token,u=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(n,["token"]);return/^data:/.test(o)&&!a?Promise.reject({error:"invalid_argument",error_description:"invalie captcha data: ".concat(t)}):a?new Promise((function(e){console.log("wait for captcha..."),r.$emit("CAPTCHA_DATA_CHANGE",f(f({},u),{token:a,url:o})),r.$once("RESOLVE_CAPTCHA_DATA",(function(t){e(t)}))})):Promise.reject({error:"unimplemented",error_description:"need to impl captcha data"})}},localStorage:c.ap,primaryStorage:l.StorageType.local,getAppSign:function(){var e=wx.getAccountInfoSync();return"undefined"!=typeof App||"undefined"!=typeof getApp||wx.onAppHide||wx.offAppHide||wx.onAppShow||wx.offAppShow?e&&e.miniProgram?e.miniProgram.appId:"":e&&e.plugin?e.plugin.appId:""}}},c.ZP));var fe=le},6334:function(e,t,r){"use strict";r.r(t),r.d(t,{AnonymousAuthProvider:function(){return Fe},Auth:function(){return et},AuthError:function(){return ce},AuthErrorCategory:function(){return ie},CustomAuthProvider:function(){return We},LoginState:function(){return Xe},User:function(){return Ze},WeixinAuthProvider:function(){return Be},generateAuthInstance:function(){return tt},registerAuth:function(){return it}});var n,o,i,s,a,u="/auth";!function(e){e.AUTH_SIGN_UP_URL="/v1/signup",e.AUTH_TOKEN_URL="/v1/token",e.AUTH_REVOKE_URL="/v1/revoke",e.WEDA_USER_URL="/v1/plugin/weda/userinfo",e.AUTH_RESET_PASSWORD="/v1/reset",e.AUTH_GET_DEVICE_CODE="/v1/device/code",e.CHECK_USERNAME="/v1/checkUsername",e.CHECK_IF_USER_EXIST="/v1/checkIfUserExist",e.GET_PROVIDER_TYPE="/v1/mgr/provider/providerSubType",e.AUTH_SIGN_IN_URL="/v1/signin",e.AUTH_SIGN_IN_ANONYMOUSLY_URL="/v1/signin/anonymously",e.AUTH_SIGN_IN_WITH_PROVIDER_URL="/v1/signin/with/provider",e.AUTH_SIGN_IN_WITH_WECHAT_URL="/v1/signin/wechat/noauth",e.AUTH_SIGN_IN_CUSTOM="/v1/signin/custom",e.PROVIDER_TOKEN_URL="/v1/provider/token",e.PROVIDER_URI_URL="/v1/provider/uri",e.USER_ME_URL="/v1/user/me",e.AUTH_SIGNOUT_URL="/v1/user/signout",e.USER_QUERY_URL="/v1/user/query",e.USER_PRIFILE_URL="/v1/user/profile",e.USER_BASIC_EDIT_URL="/v1/user/basic/edit",e.USER_TRANS_BY_PROVIDER_URL="/v1/user/trans/by/provider",e.PROVIDER_LIST="/v1/user/provider",e.PROVIDER_BIND_URL="/v1/user/provider/bind",e.PROVIDER_UNBIND_URL="/v1/user/provider",e.CHECK_PWD_URL="/v1/user/sudo",e.SUDO_URL="/v1/user/sudo",e.BIND_CONTACT_URL="/v1/user/contact",e.AUTH_SET_PASSWORD="/v1/user/password",e.AUTHORIZE_DEVICE_URL="/v1/user/device/authorize",e.AUTHORIZE_URL="/v1/user/authorize",e.AUTHORIZE_INFO_URL="/v1/user/authorize/info",e.AUTHORIZED_DEVICES_DELETE_URL="/v1/user/authorized/devices/",e.AUTH_REVOKE_ALL_URL="/v1/user/revoke/all",e.GET_USER_BEHAVIOR_LOG="/v1/user/security/history",e.VERIFICATION_URL="/v1/verification",e.VERIFY_URL="/v1/verification/verify",e.CAPTCHA_DATA_URL="/v1/captcha/data",e.VERIFY_CAPTCHA_DATA_URL="/v1/captcha/data/verify",e.GET_CAPTCHA_URL="/v1/captcha/init",e.GET_MINIPROGRAM_QRCODE="/v1/qrcode/generate",e.GET_MINIPROGRAM_QRCODE_STATUS="/v1/qrcode/get/status"}(n||(n={})),function(e){e.AUTH_SIGN_IN_URL="/v2/signin/username",e.AUTH_TOKEN_URL="/v2/token",e.USER_ME_URL="/v2/user/me",e.VERIFY_URL="/v2/signin/verificationcode",e.AUTH_SIGN_IN_WITH_PROVIDER_URL="/v2/signin/with/provider",e.AUTH_PUBLIC_KEY="/v2/signin/publichkey",e.AUTH_RESET_PASSWORD="/v2/signin/password/update"}(o||(o={})),function(e){e.REGISTER="REGISTER",e.SIGN_IN="SIGN_IN",e.PASSWORD_RESET="PASSWORD_RESET",e.EMAIL_ADDRESS_CHANGE="EMAIL_ADDRESS_CHANGE",e.PHONE_NUMBER_CHANGE="PHONE_NUMBER_CHANGE"}(i||(i={})),(a=s||(s={})).UNREACHABLE="unreachable",a.LOCAL="local",a.CANCELLED="cancelled",a.UNKNOWN="unknown",a.UNAUTHENTICATED="unauthenticated",a.RESOURCE_EXHAUSTED="resource_exhausted",a.FAILED_PRECONDITION="failed_precondition",a.INVALID_ARGUMENT="invalid_argument",a.DEADLINE_EXCEEDED="deadline_exceeded",a.NOT_FOUND="not_found",a.ALREADY_EXISTS="already_exists",a.PERMISSION_DENIED="permission_denied",a.ABORTED="aborted",a.OUT_OF_RANGE="out_of_range",a.UNIMPLEMENTED="unimplemented",a.INTERNAL="internal",a.UNAVAILABLE="unavailable",a.DATA_LOSS="data_loss",a.INVALID_PASSWORD="invalid_password",a.PASSWORD_NOT_SET="password_not_set",a.INVALID_STATUS="invalid_status",a.USER_PENDING="user_pending",a.USER_BLOCKED="user_blocked",a.INVALID_VERIFICATION_CODE="invalid_verification_code",a.TWO_FACTOR_REQUIRED="two_factor_required",a.INVALID_TWO_FACTOR="invalid_two_factor",a.INVALID_TWO_FACTOR_RECOVERY="invalid_two_factor_recovery",a.UNDER_REVIEW="under_review",a.INVALID_REQUEST="invalid_request",a.UNAUTHORIZED_CLIENT="unauthorized_client",a.ACCESS_DENIED="access_denied",a.UNSUPPORTED_RESPONSE_TYPE="unsupported_response_type",a.INVALID_SCOPE="invalid_scope",a.INVALID_GRANT="invalid_grant",a.SERVER_ERROR="server_error",a.TEMPORARILY_UNAVAILABLE="temporarily_unavailable",a.INTERACTION_REQUIRED="interaction_required",a.LOGIN_REQUIRED="login_required",a.ACCOUNT_SELECTION_REQUIRED="account_selection_required",a.CONSENT_REQUIRED="consent_required",a.INVALID_REQUEST_URI="invalid_request_uri",a.INVALID_REQUEST_OBJECT="invalid_request_object",a.REQUEST_NOT_SUPPORTED="request_not_supported",a.REQUEST_URI_NOT_SUPPORTED="request_uri_not_supported",a.REGISTRATION_NOT_SUPPORTED="registration_not_supported",a.CAPTCHA_REQUIRED="captcha_required",a.CAPTCHA_INVALID="captcha_invalid",a.PROVIDER_NOT_ENABLED="provider_not_enabled",a.LOGIN_METHOD_DISABLED="login_method_disabled",a.INVALID_USERNAME_OR_PASSWORD="invalid_username_or_password",a.INVALID_CREDENTIALS="invalid_credentials",a.WRONG_PASSWORD="wrong_password",a.USER_NOT_FOUND="user_not_found";var c,l="credentials_error",f={SIGNED_OUT:"SIGNED_OUT",SIGNED_IN:"SIGNED_IN",INITIAL_SESSION:"INITIAL_SESSION",PASSWORD_RECOVERY:"PASSWORD_RECOVERY",TOKEN_REFRESHED:"TOKEN_REFRESHED",USER_UPDATED:"USER_UPDATED",BIND_IDENTITY:"BIND_IDENTITY"},d={LOGIN_STATE_CHANGED:"loginStateChanged",AUTH_STATE_CHANGED:"authStateChanged"},h={SIGN_IN:"sign_in",BIND_IDENTITY:"bind_identity"},p="node-sdk-scope";function v(){return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(e=>{var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}!function(e){e.CLIENT_ID="client_id",e.CLIENT_SECRET="client_secret",e.RESPONSE_TYPE="response_type",e.SCOPE="scope",e.STATE="state",e.REDIRECT_URI="redirect_uri",e.ERROR="error",e.ERROR_DESCRIPTION="error_description",e.ERROR_URI="error_uri",e.GRANT_TYPE="grant_type",e.CODE="code",e.ACCESS_TOKEN="access_token",e.TOKEN_TYPE="token_type",e.EXPIRES_IN="expires_in",e.USERNAME="username",e.PASSWORD="password",e.REFRESH_TOKEN="refresh_token"}(c||(c={}));var y=r(4655);function m(e,t,r,n,o,i,s){try{var a=e[i](s),u=a.value}catch(e){return void r(e)}a.done?t(u):Promise.resolve(u).then(n,o)}function g(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function s(e){m(i,n,o,s,a,"next",e)}function a(e){m(i,n,o,s,a,"throw",e)}s(void 0)}))}}var b=new Map;class w{constructor(e){this.clientId=(null==e?void 0:e.clientId)||"",b=b||new Map}run(e,t){var r=this;return g((function*(){e="".concat(r.clientId,"_").concat(e);var n=b.get(e);return n||(n=new Promise(((n,o)=>{g((function*(){try{yield r.runIdlePromise();var i=t();n(yield i)}catch(e){o(e)}finally{b.delete(e)}}))()})),b.set(e,n)),n}))()}runIdlePromise(){return Promise.resolve()}}var _="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",S=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/,E=function(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!S.test(e))throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");var t;e+="==".slice(2-(3&e.length));for(var r,n,o="",i=0;i<e.length;)t=_.indexOf(e.charAt(i++))<<18|_.indexOf(e.charAt(i++))<<12|(r=_.indexOf(e.charAt(i++)))<<6|(n=_.indexOf(e.charAt(i++))),o+=64===r?String.fromCharCode(t>>16&255):64===n?String.fromCharCode(t>>16&255,t>>8&255):String.fromCharCode(t>>16&255,t>>8&255,255&t);return o};function I(){if("undefined"==typeof globalThis)return!1;var{wx:e}=globalThis;if(void 0===e)return!1;if(void 0===globalThis.Page)return!1;if(!e.getDeviceInfo)return!1;if(!e.getStorageSync)return!1;if(!e.setStorageSync)return!1;if(!e.connectSocket)return!1;if(!e.request)return!1;try{if(!e.getDeviceInfo())return!1;if("qq"===e.getDeviceInfo().platform)return!1}catch(e){return!1}return!0}var O=!1;function T(){O=O||void 0!==typeof window&&"miniprogram"===window.__wxjs_environment}try{I()||(O=O||!!navigator.userAgent.match(/miniprogram/i)||"miniprogram"===window.__wxjs_environment,window&&window.WeixinJSBridge&&window.WeixinJSBridge.invoke?T():"undefined"!=typeof document&&document.addEventListener("WeixinJSBridgeReady",T,!1))}catch(e){}var A=r(3616);function R(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function P(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?R(Object(r),!0).forEach((function(t){C(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):R(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function C(e,t,r){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function N(e,t,r,n,o,i,s){try{var a=e[i](s),u=a.value}catch(e){return void r(e)}a.done?t(u):Promise.resolve(u).then(n,o)}function x(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function s(e){N(i,n,o,s,a,"next",e)}function a(e){N(i,n,o,s,a,"throw",e)}s(void 0)}))}}var L="x-request-id",U="x-device-id",k="device_id",D=function(){var e=x((function*(e,t){var r=null,n=null;try{var o=Object.assign({},t);o.method||(o.method="GET"),o.body&&"string"!=typeof o.body&&(o.body=JSON.stringify(o.body));var i=yield fetch(e,o),a=yield i.json();null!=a&&a.error?(n=a).error_uri=new URL(e).pathname:r=a}catch(t){n={error:s.UNREACHABLE,error_description:t.message,error_uri:new URL(e).pathname}}if(n)throw n;return r}));return function(t,r){return e.apply(this,arguments)}}(),j=new class{constructor(e){this._env=(null==e?void 0:e.env)||""}getItem(e){var t=this;return x((function*(){return window.localStorage.getItem("".concat(e).concat(t._env))}))()}removeItem(e){var t=this;return x((function*(){window.localStorage.removeItem("".concat(e).concat(t._env))}))()}setItem(e,t){var r=this;return x((function*(){window.localStorage.setItem("".concat(e).concat(r._env),t)}))()}getItemSync(e){return window.localStorage.getItem("".concat(e).concat(this._env))}removeItemSync(e){window.localStorage.removeItem("".concat(e).concat(this._env))}setItemSync(e,t){window.localStorage.setItem("".concat(e).concat(this._env),t)}};function q(e){var t=!0;return null!=e&&e.expires_at&&null!=e&&e.access_token&&(t=e.expires_at<new Date),t}class M{constructor(e){this.credentials=null,this.accessKeyCredentials=null,this.singlePromise=null,this.tokenSectionName=e.tokenSectionName,this.storage=e.storage,this.clientId=e.clientId,this.singlePromise=new w({clientId:this.clientId}),this.credentials=e.credentials||null}getStorageCredentialsSync(){var e=null,t=this.storage.getItemSync(this.tokenSectionName);if(null!=t)try{var r;null!==(r=e=JSON.parse(t))&&void 0!==r&&r.expires_at&&(e.expires_at=new Date(e.expires_at))}catch(t){this.storage.removeItem(this.tokenSectionName),e=null}return e}setCredentials(e){var t=this;return x((function*(){if(null!=e&&e.expires_in){if(null!=e&&e.expires_at||(e.expires_at=new Date(Date.now()+1e3*(e.expires_in-30))),t.storage){var r=JSON.stringify(e);yield t.storage.setItem(t.tokenSectionName,r)}t.credentials=e}else t.storage&&(yield t.storage.removeItem(t.tokenSectionName)),t.credentials=null}))()}setAccessKeyCredentials(e){this.accessKeyCredentials=e,e.scope===p&&(this.credentials=e)}getCredentials(){var e=this;return x((function*(){return e.singlePromise.run("getCredentials",x((function*(){if(q(e.credentials)){var{credentials:t,isAccessKeyCredentials:r}=yield e.getStorageCredentials();if(r)return t;e.credentials=t}return e.credentials})))}))()}getStorageCredentials(){var e=this;return x((function*(){return e.singlePromise.run("_getStorageCredentials",x((function*(){var t=null,r=!1,n=yield e.storage.getItem(e.tokenSectionName);if(n)try{var o;null!==(o=t=JSON.parse(n))&&void 0!==o&&o.expires_at&&(t.expires_at=new Date(t.expires_at))}catch(r){yield e.storage.removeItem(e.tokenSectionName),t=null}else t=e.accessKeyCredentials||null,r=!0;return{credentials:t,isAccessKeyCredentials:r}})))}))()}}class B{constructor(e){var t;this.initializePromise=null,this.lockAcquired=!1,this.pendingInLock=[],this.singlePromise=null,e.clientSecret||(e.clientSecret=""),!e.clientId&&e.env&&(e.clientId=e.env),this.apiOrigin=e.apiOrigin,this.apiPath=e.apiPath||u,this.clientId=e.clientId,this.i18n=e.i18n,this.eventBus=e.eventBus,this.singlePromise=new w({clientId:this.clientId}),this.retry=this.formatRetry(e.retry,B.defaultRetry),e.baseRequest?this.baseRequest=e.baseRequest:this.baseRequest=D,this.tokenInURL=e.tokenInURL,this.headers=e.headers,this.storage=e.storage||j,this.localCredentials=new M({tokenSectionName:"credentials_".concat(e.clientId),storage:this.storage,clientId:e.clientId}),this.clientSecret=e.clientSecret,e.clientId&&(this.basicAuth="Basic ".concat(function(e){for(var t,r,n,o,i="",s=0,a=(e=String(e)).length%3;s<e.length;){if((r=e.charCodeAt(s++))>255||(n=e.charCodeAt(s++))>255||(o=e.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+=_.charAt((t=r<<16|n<<8|o)>>18&63)+_.charAt(t>>12&63)+_.charAt(t>>6&63)+_.charAt(63&t)}return a?i.slice(0,a-3)+"===".substring(a):i}("".concat(e.clientId,":").concat(this.clientSecret)))),this.wxCloud=e.wxCloud;try{I()&&(this.useWxCloud=e.useWxCloud,void 0===this.wxCloud&&e.env&&(wx.cloud.init({env:e.env}),this.wxCloud=wx.cloud))}catch(e){}this.refreshTokenFunc=e.refreshTokenFunc||this.defaultRefreshTokenFunc,this.anonymousSignInFunc=e.anonymousSignInFunc,this.onCredentialsError=e.onCredentialsError,this.getInitialSession=e.getInitialSession,this.onInitialSessionObtained=e.onInitialSessionObtained,this.logDebugMessages=null!==(t=e.debug)&&void 0!==t&&t,A.RR.$.on(A.RR.P,(e=>{var t;this.i18n=(null===(t=e.data)||void 0===t?void 0:t.i18n)||this.i18n}))}setGetInitialSession(e){this.getInitialSession=e}setOnInitialSessionObtained(e){this.onInitialSessionObtained=e}initialize(e){var t=this;return x((function*(){return t.initializePromise?yield t.initializePromise:void 0!==e?(t.initializePromise=e,yield t.initializePromise):(t.initializePromise=x((function*(){return yield t._acquireLock(-1,x((function*(){return yield t._initialize()})))}))(),yield t.initializePromise)}))()}setCredentials(e){var t=this;return x((function*(){return yield t.initializePromise,t._acquireLock(-1,x((function*(){return t.localCredentials.setCredentials(e)})))}))()}setAccessKeyCredentials(e){return this.localCredentials.setAccessKeyCredentials(e)}getAccessToken(){var e=this;return x((function*(){yield e.initializePromise;var t=yield e.getCredentials();if((null==t?void 0:t.scope)===p)return Promise.resolve(t.access_token);if(null!=t&&t.access_token)return Promise.resolve(t.access_token);var r={error:s.UNAUTHENTICATED};return Promise.reject(r)}))()}request(e,t){var r=this;return x((function*(){var n,o,i,a;t||(t={});var u=r.formatRetry(t.retry,r.retry);if(t.headers=P(P({},t.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&&(t.headers=P(P({},r.headers),t.headers)),t.headers[L]||(t.headers[L]=v()),!t.headers[U]){var c=yield r.getDeviceId();t.headers[U]=c}if(null!==(i=t)&&void 0!==i&&i.withBasicAuth&&r.basicAuth&&(t.headers.Authorization=r.basicAuth),null!==(a=t)&&void 0!==a&&a.withCredentials){var l=t.getCredentials?yield t.getCredentials():yield r.getCredentials();l&&(r.tokenInURL?(e.indexOf("?")<0&&(e+="?"),e+="access_token=".concat(l.access_token)):t.headers.Authorization="".concat(l.token_type," ").concat(l.access_token))}else r.clientId&&e.indexOf("client_id")<0&&(e+=e.indexOf("?")<0?"?":"&",e+="client_id=".concat(r.clientId));e.startsWith("/")&&(e="".concat(r.apiOrigin).concat(r.apiPath).concat(e));for(var f=null,d=u+1,h=0;h<d;h++){try{var p;if(null!==(p=f=t.useWxCloud||r.useWxCloud?yield r.wxCloudCallFunction(e,t):yield r.baseRequest(e,t))&&void 0!==p&&p.code)throw{error:f.code,error_description:f.message,error_uri:new URL(e).pathname};break}catch(e){try{e.requestId=e.requestId||t.headers[L]||""}catch(e){}if(t.withCredentials&&e&&e.error===s.UNAUTHENTICATED)return yield r.setCredentials(null),Promise.reject(e);if(h===u||!e||"unreachable"!==e.error)return Promise.reject(e)}yield r.sleep(B.retryInterval)}return f}))()}wxCloudCallFunction(e,t){var r=this;return x((function*(){var n=null,o=null;try{var i,a="";try{a=yield wx.getRendererUserAgent()}catch(e){}var{result:u}=yield r.wxCloud.callFunction({name:"httpOverCallFunction",data:{url:e,method:t.method,headers:P({origin:"https://servicewechat.com","User-Agent":a},t.headers),body:t.body}});null!=u&&null!==(i=u.body)&&void 0!==i&&i.error_code?(o=null==u?void 0:u.body).error_uri=(0,y.y)(e):n=null==u?void 0:u.body}catch(t){o={error:s.UNREACHABLE,error_description:t.message,error_uri:(0,y.y)(e)}}if(o)throw o;return n}))()}getCredentials(){var e=this;return x((function*(){return yield e.initializePromise,e._acquireLock(-1,x((function*(){return e._getCredentials()})))}))()}getCredentialsSync(){return this.localCredentials.getStorageCredentialsSync()}getCredentialsAsync(){return this.getCredentials()}getScope(){var e=this;return x((function*(){var t=yield e.localCredentials.getCredentials();if(!t){var r,n="credentials not found";return null===(r=e.onCredentialsError)||void 0===r||r.call(e,{msg:n}),e.unAuthenticatedError(n)}return t.scope}))()}getGroups(){var e=this;return x((function*(){var t=yield e.localCredentials.getCredentials();if(!t){var r,n="credentials not found";return null===(r=e.onCredentialsError)||void 0===r||r.call(e,{msg:n}),e.unAuthenticatedError(n)}return t.groups}))()}refreshToken(e,t){var r=this;return x((function*(){return yield r.initializePromise,r._acquireLock(-1,x((function*(){return r._refreshToken(e,t)})))}))()}_refreshToken(e,t){var r=this;return x((function*(){return r.singlePromise.run("_refreshToken",x((function*(){if((null==e?void 0:e.scope)===p)return e;if(!e||!e.refresh_token){var n,o="no refresh token found in credentials";return null===(n=r.onCredentialsError)||void 0===n||n.call(r,{msg:o}),r.unAuthenticatedError(o)}try{var i,a=yield r.refreshTokenFunc(e.refresh_token,e);return yield r.localCredentials.setCredentials(a),null===(i=r.eventBus)||void 0===i||i.fire(d.AUTH_STATE_CHANGED,{event:f.TOKEN_REFRESHED}),a}catch(e){var u;if(null!=t&&t.throwError)throw e;if(e.error===s.INVALID_GRANT){var c;yield r.localCredentials.setCredentials(null);var l=e.error_description;return null===(c=r.onCredentialsError)||void 0===c||c.call(r,{msg:l}),r.unAuthenticatedError(l)}return null===(u=r.onCredentialsError)||void 0===u||u.call(r,{msg:e.error_description}),Promise.reject(e)}})))}))()}anonymousLogin(e){var t=this;return x((function*(){return t.singlePromise.run("_anonymousLogin",x((function*(){if(t.anonymousSignInFunc){var r=yield t.anonymousSignInFunc(e);e=r||(yield t.localCredentials.getCredentials())}else e=yield t.anonymousSignIn(e);return e})))}))()}checkRetry(e){var t=null;if(("number"!=typeof e||e<B.minRetry||e>B.maxRetry)&&(t={error:s.UNREACHABLE,error_description:"wrong options param: retry"}),t)throw t;return e}formatRetry(e,t){return void 0===e?t:this.checkRetry(e)}sleep(e){return x((function*(){return new Promise((t=>{setTimeout((()=>{t()}),e)}))}))()}anonymousSignIn(e){var t=this;return x((function*(){return t.singlePromise.run("_anonymous",x((function*(){if(!e||"anonymous"!==e.scope)return t.unAuthenticatedError("no anonymous in credentials");try{var r=yield t.request(n.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",withBasicAuth:!0,body:{}});return yield t.localCredentials.setCredentials(r),r}catch(e){return e.error===s.INVALID_GRANT?(yield t.localCredentials.setCredentials(null),t.unAuthenticatedError(e.error_description)):Promise.reject(e)}})))}))()}defaultRefreshTokenFunc(e,t){var r=this;return x((function*(){if(void 0===e||""===e){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==t?void 0:t.version)&&(a=o.AUTH_TOKEN_URL),P(P({},yield r.request(a,{method:"POST",body:{client_id:r.clientId,client_secret:r.clientSecret,grant_type:"refresh_token",refresh_token:e}})),{},{version:(null==t?void 0:t.version)||"v1"})}))()}getDeviceId(){var e=this;return x((function*(){if(e.deviceID)return e.deviceID;var t=yield e.storage.getItem(k);return"string"==typeof t&&t.length>=16&&t.length<=48||(t=v(),yield e.storage.setItem(k,t)),e.deviceID=t,t}))()}unAuthenticatedError(e){var t={error:s.UNAUTHENTICATED,error_description:e};return Promise.reject(t)}_debug(){if(this.logDebugMessages){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];console.log("[OAuth2Client]",...t)}}_initialize(){var e=this;return x((function*(){try{if(!e.getInitialSession)return e._debug("#_initialize()","no getInitialSession callback set, skipping"),{error:null};e._debug("#_initialize()","calling getInitialSession callback");try{var{data:t,error:r}=yield e.getInitialSession();if(null!=t&&t.session&&(e._debug("#_initialize()","session obtained from getInitialSession",t.session),yield e.localCredentials.setCredentials(null==t?void 0:t.session)),e.onInitialSessionObtained){e._debug("#_initialize()","calling onInitialSessionObtained callback");try{yield e.onInitialSessionObtained(t,r)}catch(t){e._debug("#_initialize()","error in onInitialSessionObtained",t)}}return r?(e._debug("#_initialize()","error from getInitialSession",r),{error:r}):{error:null}}catch(t){return e._debug("#_initialize()","exception during getInitialSession",t),{error:t instanceof Error?t:new Error(String(t))}}}catch(r){return e._debug("#_initialize()","unexpected error",r),{error:r instanceof Error?r:new Error(String(r))}}finally{e._debug("#_initialize()","end")}}))()}_acquireLock(e,t){var r=this;return x((function*(){r._debug("#_acquireLock","begin",e);try{if(r.lockAcquired){var n=r.pendingInLock.length?r.pendingInLock[r.pendingInLock.length-1]:Promise.resolve(),o=x((function*(){return yield n,yield t()}))();return r.pendingInLock.push(x((function*(){try{yield o}catch(e){}}))()),o}r._debug("#_acquireLock","acquiring lock for client",r.clientId);try{r.lockAcquired=!0;var i=t();for(r.pendingInLock.push(x((function*(){try{yield i}catch(e){}}))()),yield i;r.pendingInLock.length;){var s=[...r.pendingInLock];yield Promise.all(s),r.pendingInLock.splice(0,s.length)}return yield i}finally{r._debug("#_acquireLock","releasing lock for client",r.clientId),r.lockAcquired=!1}}finally{r._debug("#_acquireLock","end")}}))()}_getCredentials(){var e=this;return x((function*(){var t=yield e.localCredentials.getCredentials();if(t.scope===p)return t;if(!t){var r,n="credentials not found";return null===(r=e.onCredentialsError)||void 0===r||r.call(e,{msg:n}),e.unAuthenticatedError(n)}if(q(t))if(t.refresh_token)try{t=yield e._refreshToken(t)}catch(r){var o;if("anonymous"!==t.scope)return null===(o=e.onCredentialsError)||void 0===o||o.call(e,{msg:r.error_description}),Promise.reject(r);t=yield e.anonymousLogin(t)}else{if("anonymous"!==t.scope){var i,s="no refresh token found in credentials";return null===(i=e.onCredentialsError)||void 0===i||i.call(e,{msg:s}),e.unAuthenticatedError(s)}t=yield e.anonymousLogin(t)}return t}))()}}B.defaultRetry=2,B.minRetry=0,B.maxRetry=5,B.retryInterval=1e3;var W=r(9689),F=r(5605);function V(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function H(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?V(Object(r),!0).forEach((function(t){$(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):V(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function $(e,t,r){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function G(e,t,r,n,o,i,s){try{var a=e[i](s),u=a.value}catch(e){return void r(e)}a.done?t(u):Promise.resolve(u).then(n,o)}function z(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function s(e){G(i,n,o,s,a,"next",e)}function a(e){G(i,n,o,s,a,"throw",e)}s(void 0)}))}}var K=(e,t)=>{var r;return function(){for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];clearTimeout(r),r=setTimeout((()=>e.apply(null,o)),t)}},J=new W.CloudbaseEventEmitter,Y="resolveCaptchaData",Q="padding:10px 8px;background:#007bff;color:#fff;border:none;border-radius:4px;cursor:pointer;flex:1;white-space:nowrap;margin-left:10px",Z="width:100%;padding:10px;background:#007bff;color:#fff;border:none;border-radius:4px;cursor:pointer",X="background:#6c757d;cursor:not-allowed",ee=e=>{var{oauthInstance:t,captchaState:r}=e,n="captcha-image",o=function(){var e=z((function*(){try{var e=yield t.createCaptchaData({state:r.state});r=H(H({},r),{},{captchaData:e.data,token:e.token}),document.getElementById(n).src=e.data}catch(e){console.error("刷新图形验证码失败",e)}}));return function(){return e.apply(this,arguments)}}(),i=(e,t,r)=>{var n=document.createElement(e);return t&&(n.style.cssText=t),r&&(n.textContent=r),n},s=i("div","position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.5);z-index:999"),a=i("div","position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:320px;padding:20px;background:#fff;border-radius:8px;box-shadow:0 0 10px rgba(0,0,0,0.2);z-index:1000");a.appendChild(i("p","margin-bottom:15px","请输入你看到的字符:"));var u=i("div","display:flex;align-items:center;justify-content:space-between;margin-bottom:15px"),c=i("img","width:100%;height:auto;border:1px solid #eee");c.id=n,c.src=r.captchaData,u.appendChild(c);var l=i("button",Q,"刷新");l.onclick=K(z((function*(){l.textContent="加载中...",l.disabled=!0,l.style.cssText="".concat(Q,";").concat(X);try{yield o()}finally{l.textContent="刷新",l.disabled=!1,l.style.cssText=Q}})),500),u.appendChild(l),a.appendChild(u);var f=i("input","width:100%;padding:14px 16px;margin-bottom:15px;box-sizing:border-box;border:2px solid #e8ecf4;border-radius:10px;font-size:15px");f.type="text",f.placeholder="输入字符",f.maxLength=4,a.appendChild(f);var d=i("div","color:#dc3545;font-size:12px;margin-bottom:10px;display:none;padding:8px;background:#f8d7da;border:1px solid #f5c6cb;border-radius:4px");a.appendChild(d);var h=e=>{d.textContent=e,d.style.display="block"},p=i("button",Z,"确定");p.onclick=K(z((function*(){var e=f.value.trim();if(e){d.style.display="none",p.textContent="验证中...",p.disabled=!0,p.style.cssText="".concat(Z,";").concat(X);try{var n=yield t.verifyCaptchaData({token:r.token,key:e});J.fire(Y,n),console.log("图形验证码校验成功"),document.body.removeChild(s),document.body.removeChild(a)}catch(e){console.error("图形验证码校验失败",e);var i=e.error_description||"图形验证码校验失败";h(i),f.value="",f.focus(),yield o()}finally{p.textContent="确定",p.disabled=!1,p.style.cssText=Z}}else h("请输入字符")})),500),a.appendChild(p),document.body.appendChild(s),document.body.appendChild(a)},te=function(){var e=z((function*(e,t){var{captchaData:r,state:n,token:o}=(0,F.parseCaptcha)(e);return ee({oauthInstance:t,captchaState:{captchaData:r,state:n,token:o}}),new Promise((e=>{console.log("等待图形验证码校验结果..."),J.on(Y,(t=>{e(null==t?void 0:t.data)}))}))}));return function(t,r){return e.apply(this,arguments)}}();function re(e,t,r,n,o,i,s){try{var a=e[i](s),u=a.value}catch(e){return void r(e)}a.done?t(u):Promise.resolve(u).then(n,o)}function ne(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function s(e){re(i,n,o,s,a,"next",e)}function a(e){re(i,n,o,s,a,"throw",e)}s(void 0)}))}}class oe{constructor(e){e.openURIWithCallback||(e.openURIWithCallback=this.getDefaultOpenURIWithCallback()),e.storage||(e.storage=j),this.config=e,this.tokenSectionName="captcha_".concat(e.clientId||e.env)}isMatch(){var e,t;return(null===(e=this.config)||void 0===e||null===(e=e.adapter)||void 0===e||null===(t=e.isMatch)||void 0===t?void 0:t.call(e))||I()}request(e,t){var r=this;return ne((function*(){t||(t={}),t.method||(t.method="GET");var n,o="".concat(t.method,":").concat(e),i=e;t.withCaptcha&&(i=yield r.appendCaptchaTokenToURL(e,o,!1));try{n=yield r.config.request(i,t)}catch(n){return n.error===s.CAPTCHA_REQUIRED||n.error===s.CAPTCHA_INVALID?(e=yield r.appendCaptchaTokenToURL(e,o,n.error===s.CAPTCHA_INVALID),r.config.request(e,t)):Promise.reject(n)}return n}))()}getDefaultOpenURIWithCallback(){return e=>te(e,this.config.oauthInstance)}getCaptchaToken(e,t){var r=this;return ne((function*(){if(!e){var o=yield r.findCaptchaToken();if(o)return o}var i=yield r.config.request(n.CAPTCHA_DATA_URL,{method:"POST",body:{state:t,redirect_uri:""},withCredentials:!1}),s="".concat(i.data,"?state=").concat(encodeURIComponent(t),"&token=").concat(encodeURIComponent(i.token)),a=yield r.config.openURIWithCallback(s);return r.saveCaptchaToken(a),a.captcha_token}))()}appendCaptchaTokenToURL(e,t,r){var n=this;return ne((function*(){var o=yield n.getCaptchaToken(r,t);return e.indexOf("?")>0?e+="&captcha_token=".concat(o):e+="?captcha_token=".concat(o),e}))()}saveCaptchaToken(e){var t=this;return ne((function*(){e.expires_at=new Date(Date.now()+1e3*(e.expires_in-10));var r=JSON.stringify(e);yield t.config.storage.setItem(t.tokenSectionName,r)}))()}findCaptchaToken(){var e=this;return ne((function*(){var t=yield e.config.storage.getItem(e.tokenSectionName);if(null!=t)try{var r=JSON.parse(t);return null!=r&&r.expires_at&&(r.expires_at=new Date(r.expires_at)),r.expires_at<new Date?null:r.captcha_token}catch(t){return yield e.config.storage.removeItem(e.tokenSectionName),null}return null}))()}}var ie,se=class{constructor(e){if(this.params={},"string"==typeof e)this.parse(e);else if(e&&"object"==typeof e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&this.append(t,e[t])}parse(e){e.split("&").forEach((e=>{var[t,r]=e.split("=").map(decodeURIComponent);this.append(t,r)}))}append(e,t){this.params[e]?this.params[e]=this.params[e].concat([t]):this.params[e]=[t]}get(e){return this.params[e]?this.params[e][0]:null}getAll(e){return this.params[e]||[]}delete(e){delete this.params[e]}has(e){return Object.prototype.hasOwnProperty.call(this.params,e)}set(e,t){this.params[e]=[t]}toString(){var e=this,t=[],r=function(r){Object.prototype.hasOwnProperty.call(e.params,r)&&e.params[r].forEach((e=>{t.push("".concat(encodeURIComponent(r),"=").concat(encodeURIComponent(e)))}))};for(var n in this.params)r(n);return t.join("&")}};!function(e){e.PROVIDER_NOT_ENABLED="PROVIDER_NOT_ENABLED",e.INVALID_CREDENTIALS="INVALID_CREDENTIALS",e.USER_NOT_FOUND="USER_NOT_FOUND",e.USER_STATUS_ABNORMAL="USER_STATUS_ABNORMAL",e.SERVICE_ERROR="SERVICE_ERROR",e.INVALID_PARAMS="INVALID_PARAMS",e.AUTH_METHOD_MISMATCH="AUTH_METHOD_MISMATCH",e.UNKNOWN="UNKNOWN"}(ie||(ie={}));var ae="https://tcb.cloud.tencent.com/dev?envId=#/identity/login-manage",ue="https://docs.cloudbase.net/api-reference/webv3-next/initialization";class ce extends Error{constructor(e,t){var r,n=e.error_description||e.message;super(n),this.__isAuthError=!0,this.name="AuthError",this.status=e.error,this.code=e.error_code,this.requestId=e.requestId,this.category=function(e,t){if(!e&&!t)return ie.UNKNOWN;try{var r=(e||"").toLowerCase();return t===s.FAILED_PRECONDITION||t===s.PROVIDER_NOT_ENABLED||t===s.LOGIN_METHOD_DISABLED||r.includes("身份源")||r.includes("开启")||r.includes("identity provider")||r.includes("provider not enabled")||r.includes("login method")||r.includes("登录方式")||r.includes("not enabled")||r.includes("未开启")||r.includes("未启用")||r.includes("请联系开发者")||r.includes("anonymous login is not enabled")||r.includes("匿名登录未开启")?ie.PROVIDER_NOT_ENABLED:t===s.INVALID_PASSWORD||t===s.INVALID_GRANT||t===s.INVALID_VERIFICATION_CODE||t===s.INVALID_USERNAME_OR_PASSWORD||t===s.INVALID_CREDENTIALS||t===s.WRONG_PASSWORD||t===s.UNAUTHENTICATED||t===s.INVALID_TWO_FACTOR||t===s.INVALID_TWO_FACTOR_RECOVERY||t===s.PASSWORD_NOT_SET||r.includes("密码不正确")||r.includes("password")||r.includes("invalid_password")||r.includes("凭据")||r.includes("credentials")||r.includes("验证码")||r.includes("verification")||r.includes("invalid_verification_code")||r.includes("invalid_username_or_password")||r.includes("username or password")||r.includes("用户名或密码")||r.includes("wrong password")||r.includes("incorrect password")?ie.INVALID_CREDENTIALS:t===s.NOT_FOUND||t===s.USER_NOT_FOUND||r.includes("用户不存在")||r.includes("not found")||r.includes("user not found")||r.includes("不存在")||r.includes("no such user")||r.includes("user does not exist")?ie.USER_NOT_FOUND:t===s.USER_BLOCKED||t===s.USER_PENDING||t===s.UNDER_REVIEW||t===s.INVALID_STATUS||r.includes("被封禁")||r.includes("blocked")||r.includes("pending")||r.includes("审核")||r.includes("review")||r.includes("locked")||r.includes("已锁定")?ie.USER_STATUS_ABNORMAL:t===s.SERVER_ERROR||t===s.UNAVAILABLE||t===s.TEMPORARILY_UNAVAILABLE||t===s.INTERNAL||t===s.UNREACHABLE||t===s.DEADLINE_EXCEEDED||t===s.DATA_LOSS||r.includes("network")||r.includes("timeout")||r.includes("服务")||r.includes("timed out")||r.includes("超时")?ie.SERVICE_ERROR:t===s.INVALID_ARGUMENT||t===s.INVALID_REQUEST||t===s.INVALID_SCOPE||t===s.INVALID_REQUEST_URI||t===s.INVALID_REQUEST_OBJECT?ie.INVALID_PARAMS:t===s.PERMISSION_DENIED||t===s.ACCESS_DENIED||t===s.UNAUTHORIZED_CLIENT?ie.PROVIDER_NOT_ENABLED:ie.UNKNOWN}catch(e){return t}}(n,this.status),this.helpMessage=function(e,t){var r=(null==t?void 0:t.method)||"signIn",n={signInWithPassword:"「用户名密码登录」",signInAnonymously:"「匿名登录」",signInWithOtp:"「短信验证码登录」或「邮箱验证码登录」",signUp:"「短信验证码登录」或「邮箱验证码登录」",signInWithOAuth:"对应的第三方身份源",signInWithIdToken:"对应的第三方身份源",signInWithOpenId:"「微信小程序 OpenID 登录」",signInWithPhoneAuth:"「微信小程序手机号授权登录」",signInWithCustomTicket:"「自定义登录」"}[r]||"对应的登录方式";switch(e){case ie.PROVIDER_NOT_ENABLED:return"[CloudBase Auth] 登录方式未开启\n\n"+" 当前调用的 ".concat(r,"() 所需的登录方式尚未在云开发控制台启用。\n")+" 需要开启的登录方式:".concat(n,"\n")+"\n 请按以下步骤开启:\n"+" 1. 打开云开发控制台:".concat(ae,"\n")+" 2. 选择对应的云开发环境\n 3. 进入「登录授权」页面,在「登录方式」或「身份源列表」中开启所需的登录方式\n\n 各登录方法与所需登录方式的对应关系:\n - signInWithPassword → 「用户名密码登录」\n - signInAnonymously → 「匿名登录」\n - signInWithOtp/signUp → 「短信验证码登录」或「邮箱验证码登录」\n - signInWithOAuth/signInWithIdToken → 对应的第三方身份源\n\n 如使用 CLI/MCP 工具,可通过 auth 工具查询和配置身份源状态。\n"+" 更多帮助请参考文档:".concat(ue);case ie.INVALID_CREDENTIALS:return"[CloudBase Auth] 凭据验证失败\n\n"+" 调用 ".concat(r,"() 时凭据校验未通过。\n")+"\n 请按优先级逐项排查:\n 1. 确认用户名/邮箱/手机号是否拼写正确、格式完整\n 2. 确认密码是否正确(注意大小写、特殊字符、前后空格)\n 3. 确认用户账号确实存在(可通过 auth.isUsernameRegistered() 检查)\n 4. 确认凭据参数来源可靠(环境变量、配置文件中的值是否已正确设置)\n 5. 如使用加密登录(is_encrypt: true),请确认公钥版本正确\n\n 如忘记密码,可通过 auth.resetPasswordForEmail() 重置密码。\n\n 提示:如果是 AI agent / 自动化测试场景,请确认 ENV_ID、USERNAME、PASSWORD\n 等环境变量已正确传入,且对应用户已在目标环境中注册。";case ie.USER_NOT_FOUND:return"[CloudBase Auth] 用户不存在\n\n 请检查以下项目:\n 1. 确认用户名/邮箱/手机号是否正确\n 2. 确认是在正确的云开发环境(envId)下操作\n 3. 如果是新用户,请先通过 auth.signUp() 注册\n"+" 4. 也可在云开发控制台手动创建用户:".concat(ae,"\n")+"\n 提示:不同环境(开发/测试/生产)的用户库是隔离的,请确认 envId 正确。";case ie.USER_STATUS_ABNORMAL:return"[CloudBase Auth] 用户状态异常\n\n 当前用户账号可能处于以下状态之一:\n - 账号已被封禁\n - 账号正在审核中\n - 账号已被锁定(多次密码错误)\n\n"+" 请联系管理员在云开发控制台检查用户状态:".concat(ae);case ie.SERVICE_ERROR:return"[CloudBase Auth] 服务异常\n\n 请检查以下项目:\n 1. 网络连接是否正常\n 2. 云开发环境是否正常运行\n 3. 稍后重试,如持续失败请联系技术支持\n\n 提示:如果是超时错误,请检查网络环境和请求频率。";case ie.INVALID_PARAMS:return"[CloudBase Auth] 参数错误\n\n 请检查传入的参数是否符合要求,参考 API 文档确认各参数的格式和约束。\n"+" 文档地址:".concat(ue);case ie.AUTH_METHOD_MISMATCH:return"[CloudBase Auth] 登录方式不匹配\n\n"+" 调用 ".concat(r,"() 时遇到错误,可能原因:\n")+" - 匿名登录失败后尝试了用户名密码登录,但凭据不正确或用户不存在\n - 应使用匿名登录但传入了密码参数\n - 应使用密码登录但未传入正确的凭据\n\n 建议:\n 1. 明确当前场景需要的登录方式:\n - 无需用户注册 → auth.signInAnonymously()\n - 有用户名和密码 → auth.signInWithPassword({ username, password })\n - 第三方平台 → auth.signInWithOAuth({ provider })\n 2. 不要在同一流程中混合使用不同的登录方式\n 3. 每种登录方式需要在控制台开启对应的身份源\n"+" 4. 控制台地址:".concat(ae);default:return"[CloudBase Auth] 操作失败\n\n 如果问题持续存在,建议:\n"+" 1. 检查云开发控制台的认证配置:".concat(ae,"\n")+" 2. 到官方问答社区提问:https://cnb.cool/tencent/cloud/cloudbase/community/-/issues\n"+" 3. 查阅文档:".concat(ue)}}(this.category,t),this.loginMethodHint=(r=null==t?void 0:t.method)&&{signInWithPassword:"当前使用「用户名密码登录」,需确保:\n ✓ 控制台已开启「用户名密码登录」\n ✓ 用户已注册且凭据正确\n 如果不需要用户系统,建议改用 auth.signInAnonymously()",signInAnonymously:"当前使用「匿名登录」,需确保:\n ✓ 控制台已开启「匿名登录」\n 注意:匿名用户无需用户名密码,适用于快速体验或临时访问场景",signInWithOtp:"当前使用「OTP 验证码登录」,需确保:\n ✓ 控制台已开启「短信验证码登录」或「邮箱验证码登录」",signInWithOAuth:"当前使用「第三方 OAuth 登录」,需确保:\n ✓ 控制台已配置并开启对应的第三方身份源"}[r]||""}}var le=["provider_redirect_uri","other_params"];function fe(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function de(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?fe(Object(r),!0).forEach((function(t){he(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):fe(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function he(e,t,r){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function pe(e,t,r,n,o,i,s){try{var a=e[i](s),u=a.value}catch(e){return void r(e)}a.done?t(u):Promise.resolve(u).then(n,o)}function ve(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function s(e){pe(i,n,o,s,a,"next",e)}function a(e){pe(i,n,o,s,a,"throw",e)}s(void 0)}))}}function ye(e,t){return me.apply(this,arguments)}function me(){return me=ve((function*(e,t){var n=function(){var e=ve((function*(){try{return r(7171)}catch(e){try{return yield Promise.resolve().then(r.bind(r,7171))}catch(e){return}}}));return function(){return e.apply(this,arguments)}}();try{var o;if(((null==t||null===(o=t.root)||void 0===o?void 0:o.globalThis)||globalThis).IS_MP_BUILD)return}catch(t){if(e)return n()}})),me.apply(this,arguments)}class ge{static parseParamsToSearch(e){return Object.keys(e).forEach((t=>{e[t]||delete e[t]})),new se(e).toString()}constructor(e){var{request:t}=e,r=e.credentialsClient;if(!r){var n={apiOrigin:e.apiOrigin,apiPath:e.apiPath,clientId:e.clientId,storage:e.storage,env:e.env,baseRequest:e.baseRequest,anonymousSignInFunc:e.anonymousSignInFunc,wxCloud:e.wxCloud,onCredentialsError:e.onCredentialsError,headers:e.headers||{},i18n:e.i18n,debug:e.debug};r=new B(n)}if(!t){var o=r.request.bind(r),i=new oe(de({env:e.env,clientId:e.clientId,request:o,storage:e.storage,adapter:e.adapter,oauthInstance:this},e.captchaOptions));t=i.request.bind(i)}this.config={env:e.env,apiOrigin:e.apiOrigin,apiPath:e.apiPath,clientId:e.clientId,request:t,credentialsClient:r,storage:e.storage||j,adapter:e.adapter}}getParamsByVersion(e,t){var r,i=(0,y.I)(e),s=(null===(r={v2:o}[null==i?void 0:i.version])||void 0===r?void 0:r[t])||n[t];return i&&delete i.version,{params:i,url:s}}signIn(e){var t=this;return ve((function*(){var r=e.version||"v1",n=t.getParamsByVersion(e,"AUTH_SIGN_IN_URL");n.params.query&&delete n.params.query;var o=yield t.getEncryptParams(n.params),i=yield t.config.request(n.url,{method:"POST",body:o});return yield t.config.credentialsClient.setCredentials(de(de({},i),{},{version:r})),Promise.resolve(i)}))()}signInAnonymously(){var e=arguments,t=this;return ve((function*(){var r=e.length>0&&void 0!==e[0]?e[0]:{},o=e.length>1&&void 0!==e[1]&&e[1],i=yield t.config.request(n.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",body:r,useWxCloud:o});return yield t.config.credentialsClient.setCredentials(i),Promise.resolve(i)}))()}signUp(e){var t=this;return ve((function*(){var r=yield t.config.request(n.AUTH_SIGN_UP_URL,{method:"POST",body:e});return yield t.config.credentialsClient.setCredentials(r),Promise.resolve(r)}))()}signOut(e){var t=this;return ve((function*(){var r={};if(e){try{r=yield t.config.request(n.AUTH_SIGNOUT_URL,{method:"POST",withCredentials:!0,body:e})}catch(e){e.error!==s.UNAUTHENTICATED&&console.log("sign_out_error",e)}return yield t.config.credentialsClient.setCredentials(),r}var o=yield t.config.credentialsClient.getAccessToken(),i=yield t.config.request(n.AUTH_REVOKE_URL,{method:"POST",body:{token:o}});return yield t.config.credentialsClient.setCredentials(),Promise.resolve(i)}))()}revokeAllDevices(){var e=this;return ve((function*(){yield e.config.request(n.AUTH_REVOKE_ALL_URL,{method:"DELETE",withCredentials:!0})}))()}revokeDevice(e){var t=this;return ve((function*(){yield t.config.request(n.AUTHORIZED_DEVICES_DELETE_URL+e.device_id,{method:"DELETE",withCredentials:!0})}))()}getVerification(e,t){var r=this;return ve((function*(){var o=!1;("CUR_USER"===e.target||(yield r.hasLoginState()))&&(o=!0);var i=(0,y.I)(e);return i.phone_number&&!/^\+\d{1,3}\s+\d+/.test(i.phone_number)&&(i.phone_number="+86 ".concat(i.phone_number)),r.config.request(n.VERIFICATION_URL,{method:"POST",body:i,withCaptcha:(null==t?void 0:t.withCaptcha)||!1,withCredentials:o})}))()}verify(e){var t=this;return ve((function*(){var r=t.getParamsByVersion(e,"VERIFY_URL"),n=yield t.config.request(r.url,{method:"POST",body:r.params});return"v2"===(null==e?void 0:e.version)&&(yield t.config.credentialsClient.setCredentials(de(de({},n),{},{version:"v2"}))),n}))()}genProviderRedirectUri(e){var t=this;return ve((function*(){var{provider_redirect_uri:r,other_params:o={}}=e,i=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.includes(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.includes(r)||{}.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(e,le);r&&!i.redirect_uri&&(i.redirect_uri=r);var s="".concat(n.PROVIDER_URI_URL,"?").concat(ge.parseParamsToSearch(i));return Object.keys(o).forEach((e=>{var t=o[e];("sign_out_uri"!==e||(null==t?void 0:t.length)>0)&&(s+="&other_params[".concat(e,"]=").concat(encodeURIComponent(t)))})),t.config.request(s,{method:"GET"})}))()}grantProviderToken(e){var t=arguments,r=this;return ve((function*(){var o=t.length>1&&void 0!==t[1]&&t[1];return r.config.request(n.PROVIDER_TOKEN_URL,{method:"POST",body:e,useWxCloud:o})}))()}patchProviderToken(e){var t=this;return ve((function*(){return t.config.request(n.PROVIDER_TOKEN_URL,{method:"PATCH",body:e})}))()}signInWithProvider(e){var t=arguments,r=this;return ve((function*(){var n=t.length>1&&void 0!==t[1]&&t[1],o=r.getParamsByVersion(e,"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(de(de({},i),{},{version:(null==e?void 0:e.version)||"v1"})),Promise.resolve(i)}))()}toBindIdentity(e){var t=this;return ve((function*(){var r,n,o,i=e.credentials||(yield t.config.credentialsClient.localCredentials.getCredentials());try{yield t.bindWithProvider({provider_token:e.provider_token},i),r={data:{type:h.BIND_IDENTITY,provider:e.provider},error:null}}catch(e){r={data:{type:h.BIND_IDENTITY},error:new ce(e)}}return e.fireEvent&&(null===(n=t.config.eventBus)||void 0===n||null===(o=n.fire)||void 0===o||o.call(n,d.AUTH_STATE_CHANGED,{event:f.BIND_IDENTITY,info:r})),r}))()}getInitialSession(){var e=this;return ve((function*(){var t={};try{var r,n,o,i,s;if("undefined"==typeof window||"undefined"==typeof document)return{data:null,error:null};var a=new URLSearchParams(null===(r=location)||void 0===r?void 0:r.search),u=a.get("code"),c=a.get("state");if(!u||!c)return{data:null,error:null};var l=null;try{l=JSON.parse(sessionStorage.getItem(c)||"null")}catch(e){}t={type:null===(n=l)||void 0===n?void 0:n.type};var f=a.get("error"),d=a.get("error_description");if(f||d)return{data:t,error:new ce({message:d||f||"Unknown error from OAuth provider"})};var p=(null===(o=l)||void 0===o?void 0:o.provider)||a.get("provider");if(!p)return{data:t,error:new ce({message:"Provider is required for OAuth verification"})};var v,y,m=location.origin+location.pathname,{provider_token:g}=yield e.grantProviderToken({provider_id:p,provider_redirect_uri:m,provider_code:u}),b=null;if(l.type===h.BIND_IDENTITY)v=yield e.config.credentialsClient.localCredentials.getCredentials(),y=yield e.toBindIdentity({provider:p,provider_token:g,credentials:v});else if(l.type===h.SIGN_IN){y=e.getParamsByVersion({provider:p},"AUTH_SIGN_IN_WITH_PROVIDER_URL"),v=yield e.config.request(y.url,{method:"POST",body:{provider_token:g}});try{b=yield e.getUserInfo({credentials:v})}catch(e){console.error("get user info error",e)}y={data:de(de({},t),{},{session:v,user:b}),error:null}}a.delete("code"),a.delete("state"),a.delete("provider"),e.restoreUrlState(void 0===(null===(i=l)||void 0===i?void 0:i.search)?"?".concat(a.toString()):l.search,(null===(s=l)||void 0===s?void 0:s.hash)||location.hash);try{sessionStorage.removeItem(c)}catch(e){}return y}catch(e){return{data:t,error:new ce(e)}}}))()}signInCustom(e){var t=this;return ve((function*(){var r=yield t.config.request(n.AUTH_SIGN_IN_CUSTOM,{method:"POST",body:e});return yield t.config.credentialsClient.setCredentials(r),Promise.resolve(r)}))()}signInWithWechat(){var e=arguments,t=this;return ve((function*(){var r=e.length>0&&void 0!==e[0]?e[0]:{},o=yield t.config.request(n.AUTH_SIGN_IN_WITH_WECHAT_URL,{method:"POST",body:r});return yield t.config.credentialsClient.setCredentials(o),Promise.resolve(o)}))()}bindWithProvider(e,t){var r=this;return ve((function*(){return r.config.request(n.PROVIDER_BIND_URL,{method:"POST",body:e,withCredentials:!0,getCredentials:t?()=>t:void 0})}))()}getUserProfile(e){var t=this;return ve((function*(){return t.getUserInfo(e)}))()}getUserInfo(){var e=arguments,t=this;return ve((function*(){var r,n=e.length>0&&void 0!==e[0]?e[0]:{},o=t.getParamsByVersion(n,"USER_ME_URL");if(null!==(r=o.params)&&void 0!==r&&r.query){var i=new se(o.params.query);o.url+="?".concat(i.toString())}var s=yield t.config.request(o.url,{method:"GET",withCredentials:!0,getCredentials:n.credentials?()=>n.credentials:void 0});return s.sub&&(s.uid=s.sub),s}))()}getWedaUserInfo(){var e=this;return ve((function*(){return yield e.config.request(n.WEDA_USER_URL,{method:"GET",withCredentials:!0})}))()}deleteMe(e){var t=this;return ve((function*(){var r=t.getParamsByVersion(e,"USER_ME_URL"),n="".concat(r.url,"?").concat(ge.parseParamsToSearch(r.params));return t.config.request(n,{method:"DELETE",withCredentials:!0})}))()}hasLoginState(){var e=this;return ve((function*(){try{return yield e.config.credentialsClient.getAccessToken(),!0}catch(e){return!1}}))()}hasLoginStateSync(){return this.config.credentialsClient.getCredentialsSync()}getLoginState(){var e=this;return ve((function*(){return e.config.credentialsClient.getCredentialsAsync()}))()}transByProvider(e){var t=this;return ve((function*(){return t.config.request(n.USER_TRANS_BY_PROVIDER_URL,{method:"PATCH",body:e,withCredentials:!0})}))()}grantToken(e){var t=this;return ve((function*(){var r=t.getParamsByVersion(e,"AUTH_TOKEN_URL");return t.config.request(r.url,{method:"POST",body:r.params})}))()}getProviders(){var e=this;return ve((function*(){return e.config.request(n.PROVIDER_LIST,{method:"GET",withCredentials:!0})}))()}unbindProvider(e){var t=this;return ve((function*(){return t.config.request("".concat(n.PROVIDER_UNBIND_URL,"/").concat(e.provider_id),{method:"DELETE",withCredentials:!0})}))()}checkPassword(e){var t=this;return ve((function*(){return t.config.request("".concat(n.CHECK_PWD_URL),{method:"POST",withCredentials:!0,body:e})}))()}editContact(e){var t=this;return ve((function*(){return t.config.request("".concat(n.BIND_CONTACT_URL),{method:"PATCH",withCredentials:!0,body:e})}))()}setPassword(e){var t=this;return ve((function*(){return t.config.request("".concat(n.AUTH_SET_PASSWORD),{method:"PATCH",withCredentials:!0,body:e})}))()}updatePasswordByOld(e){var t=this;return ve((function*(){var r=yield t.sudo({password:e.old_password});return t.setPassword({sudo_token:r.sudo_token,new_password:e.new_password})}))()}sudo(e){var t=this;return ve((function*(){return t.config.request("".concat(n.SUDO_URL),{method:"POST",withCredentials:!0,body:e})}))()}sendVerificationCodeToCurrentUser(e){var t=this;return ve((function*(){return e.target="CUR_USER",t.config.request(n.VERIFICATION_URL,{method:"POST",body:e,withCredentials:!0,withCaptcha:!0})}))()}changeBoundProvider(e){var t=this;return ve((function*(){return t.config.request("".concat(n.PROVIDER_LIST,"/").concat(e.provider_id,"/trans"),{method:"POST",body:{provider_trans_token:e.trans_token},withCredentials:!0})}))()}setUserProfile(e){var t=this;return ve((function*(){return t.config.request(n.USER_PRIFILE_URL,{method:"PATCH",body:e,withCredentials:!0})}))()}updateUserBasicInfo(e){var t=this;return ve((function*(){return t.config.request(n.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:e})}))()}queryUserProfile(e){var t=this;return ve((function*(){var r=new se(e);return t.config.request("".concat(n.USER_QUERY_URL,"?").concat(r.toString()),{method:"GET",withCredentials:!0})}))()}setCustomSignFunc(e){this.getCustomSignTicketFn=e}signInWithCustomTicket(){var e=this;return ve((function*(){var t=e.getCustomSignTicketFn;if(!t)return Promise.reject({error:"failed_precondition",error_description:"please use setCustomSignFunc to set custom sign function"});var r=yield t();return e.signInCustom({provider_id:"custom",ticket:r})}))()}resetPassword(e){var t=this;return ve((function*(){return t.config.request(n.AUTH_RESET_PASSWORD,{method:"POST",body:e})}))()}authorize(e){var t=this;return ve((function*(){return t.config.request(n.AUTHORIZE_URL,{method:"POST",withCredentials:!0,body:e})}))()}authorizeDevice(e){var t=this;return ve((function*(){return t.config.request(n.AUTHORIZE_DEVICE_URL,{method:"POST",withCredentials:!0,body:e})}))()}deviceAuthorize(e){var t=this;return ve((function*(){return t.config.request(n.AUTH_GET_DEVICE_CODE,{method:"POST",body:e,withCredentials:!0})}))()}authorizeInfo(e){var t=this;return ve((function*(){var r="".concat(n.AUTHORIZE_INFO_URL,"?").concat(ge.parseParamsToSearch(e)),o=!0,i=!1;return(yield t.hasLoginState())&&(i=!0,o=!1),t.config.request(r,{method:"GET",withBasicAuth:o,withCredentials:i})}))()}checkUsername(e){var t=this;return ve((function*(){return t.config.request(n.CHECK_USERNAME,{method:"GET",body:e,withCredentials:!0})}))()}checkIfUserExist(e){var t=this;return ve((function*(){var r=new se(e);return t.config.request("".concat(n.CHECK_IF_USER_EXIST,"?").concat(r.toString()),{method:"GET"})}))()}loginScope(){var e=this;return ve((function*(){return e.config.credentialsClient.getScope()}))()}loginGroups(){var e=this;return ve((function*(){return e.config.credentialsClient.getGroups()}))()}refreshTokenForce(e){var t=this;return ve((function*(){var r=yield t.config.credentialsClient.getCredentials();return yield t.config.credentialsClient.refreshToken(de(de({},r),{},{version:(null==e?void 0:e.version)||"v1"}))}))()}getCredentials(){var e=this;return ve((function*(){return e.config.credentialsClient.getCredentials()}))()}getPublicKey(){var e=this;return ve((function*(){return e.config.request(o.AUTH_PUBLIC_KEY,{method:"POST",body:{}})}))()}getEncryptParams(e){var t=this;return ve((function*(){var{isEncrypt:r}=e;delete e.isEncrypt;var n=(0,y.I)(e),o=yield ye(r,t.config.adapter);if(!o)return e;var i="",s="";try{var a=yield t.getPublicKey();if(i=a.public_key,s=a.public_key_thumbprint,!i||!s)throw a}catch(e){throw e}return{params:o.getEncryptInfo({publicKey:i,payload:n}),public_key_thumbprint:s}}))()}getProviderSubType(){var e=this;return ve((function*(){return e.config.request(n.GET_PROVIDER_TYPE,{method:"POST",body:{provider_id:"weda"}})}))()}verifyCaptchaData(e){var t=this;return ve((function*(){var{token:r,key:o}=e;return t.config.request(n.VERIFY_CAPTCHA_DATA_URL,{method:"POST",body:{token:r,key:o},withCredentials:!1})}))()}createCaptchaData(e){var t=this;return ve((function*(){var{state:r,redirect_uri:o}=e;return t.config.request(n.CAPTCHA_DATA_URL,{method:"POST",body:{state:r,redirect_uri:o},withCredentials:!1})}))()}getMiniProgramCode(e){var t=this;return ve((function*(){return t.config.request(n.GET_MINIPROGRAM_QRCODE,{method:"POST",body:e})}))()}getMiniProgramQrCodeStatus(e){var t=this;return ve((function*(){return t.config.request(n.GET_MINIPROGRAM_QRCODE_STATUS,{method:"POST",body:e})}))()}getUserBehaviorLog(e){var t=this;return ve((function*(){var r="".concat(n.GET_USER_BEHAVIOR_LOG,"?").concat({LOGIN:"query[action]=USER_LOGIN",MODIFY:"ne_query[action]=USER_LOGIN"}[e.type],"&limit=").concat(e.limit).concat(e.page_token?"&page_token=".concat(e.page_token):"");return t.config.request(r,{method:"GET",withCredentials:!0})}))()}modifyPassword(e){var t=this;return ve((function*(){var r="",o="",i=yield ye(!0,t.config.adapter);if(!i)throw new Error("do not support encrypt, a encrypt util required.");try{var s=yield t.getPublicKey();if(r=s.public_key,o=s.public_key_thumbprint,!r||!o)throw s}catch(e){throw e}var a=e.password?i.getEncryptInfo({publicKey:r,payload:e.password}):"",u=i.getEncryptInfo({publicKey:r,payload:e.new_password});return t.config.request(n.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:{user_id:e.user_id,encrypt_password:a,encrypt_new_password:u,public_key_thumbprint:o}})}))()}modifyPasswordWithoutLogin(e){var t=this;return ve((function*(){var r="",n="",i=yield ye(!0,t.config.adapter);if(!i)throw new Error("do not support encrypt, a encrypt util required.");try{var s=yield t.getPublicKey();if(r=s.public_key,n=s.public_key_thumbprint,!r||!n)throw s}catch(e){throw e}var a=e.password?i.getEncryptInfo({publicKey:r,payload:e.password}):"",u=i.getEncryptInfo({publicKey:r,payload:e.new_password});return t.config.request(o.AUTH_RESET_PASSWORD,{method:"POST",body:{username:e.username,password:a,new_password:u,public_key_thumbprint:n}})}))()}restoreUrlState(e,t){if(void 0!==e)try{var r=new URL(window.location.href);r.search=e,r.hash=t||"",window.history.replaceState(null,"",r.toString()),window.location.replace(r.toString())}catch(e){}}}function be(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function we(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?be(Object(r),!0).forEach((function(t){_e(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):be(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _e(e,t,r){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class Se{constructor(e){var{apiOrigin:t,apiPath:r=u,clientId:n,env:o,storage:i,request:s,baseRequest:a,anonymousSignInFunc:c,wxCloud:l,adapter:f,onCredentialsError:d,headers:h,i18n:p,useWxCloud:v,eventBus:y,detectSessionInUrl:m,debug:g}=e;if(this.detectSessionInUrl=null!=m&&m,this.oauth2client=new B({apiOrigin:t,apiPath:r,clientId:n,env:o,storage:i,baseRequest:a||s,anonymousSignInFunc:c,wxCloud:l,onCredentialsError:d,headers:h||{},i18n:p,useWxCloud:v,eventBus:y,debug:g}),this.authApi=new ge(we(we({credentialsClient:this.oauth2client},e),{},{request:s?this.oauth2client.request.bind(this.oauth2client):void 0,adapter:f})),m)this.oauth2client.setGetInitialSession(this.authApi.getInitialSession.bind(this.authApi));else try{var b=new URL(window.location.href),w=b.searchParams.get("code"),_=b.searchParams.get("state"),S=JSON.parse(sessionStorage.getItem(_)||"null");w&&_&&null!=S&&S.hash&&(b.hash=S.hash,window.history.replaceState(null,"",b.toString()),window.location.replace(b.toString()))}catch(e){}}initializeSession(e){this.detectSessionInUrl?(this.oauth2client.setOnInitialSessionObtained(e),this.oauth2client.initialize()):this.oauth2client.initialize(Promise.resolve({error:null}))}}var Ee,Ie,Oe=r(794),Te=r(141),Ae=r(6197),Re=r(190),Pe=r(8182),Ce=function(){return Ce=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Ce.apply(this,arguments)},Ne=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},xe=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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])}}},Le=function(){function e(e){var t,r;try{this.localStorage=(null==e?void 0:e.localStorage)||((null===(r=null===(t=null==e?void 0:e.adapter)||void 0===t?void 0:t.root)||void 0===r?void 0:r.globalThis)||globalThis).localStorage}catch(t){this.localStorage=(null==e?void 0:e.localStorage)||{}}}return e.prototype.getItem=function(e){return Ne(this,void 0,void 0,(function(){return xe(this,(function(t){return[2,this.localStorage.getItem(e)]}))}))},e.prototype.removeItem=function(e){return Ne(this,void 0,void 0,(function(){return xe(this,(function(t){return this.localStorage.removeItem(e),[2]}))}))},e.prototype.setItem=function(e,t){return Ne(this,void 0,void 0,(function(){return xe(this,(function(r){return this.localStorage.setItem(e,t),[2]}))}))},e.prototype.getItemSync=function(e){return this.localStorage.getItem(e)},e.prototype.setItemSync=function(e,t){this.localStorage.setItem(e,t)},e.prototype.removeItemSync=function(e){this.localStorage.removeItem(e)},e}(),Ue=/^[^:]+:\/\/[^/]+(\/[^?#]+)/,ke=function(e,t){var r,n,o,i,s=null===(r=null==t?void 0:t.headers)||void 0===r?void 0:r["x-request-id"];return e||(e={}),((null==e?void 0:e.code)||(null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.error_code))&&(e={error:e.code||e.data.error,error_description:e.data.error_description||e.message||e.code||e.data.error_code,request_id:e.requestId,error_code:null===(o=e.data)||void 0===o?void 0:o.error_code}),(null==e?void 0:e.request_id)||(e.request_id=e.request_id||s),(null==e?void 0:e.error)?(e.error_uri=(i=null==t?void 0:t.url,Ue.test(i)?RegExp.$1:i),e):(null==e?void 0:e.data)||{}},De=function(e){return e.adapter&&"default"!==e.adapter.type?function(e,t){var r=Ce({},e);try{if(!(null==e?void 0:e.storage)&&(null==t?void 0:t.localStorage)&&(r.storage=new Le({localStorage:t.localStorage,adapter:t})),!e.captchaOptions&&(null==t?void 0:t.captchaOptions)&&(r.captchaOptions=t.captchaOptions),!e.baseRequest&&!e.request&&(null==t?void 0:t.reqClass)){var n={timeout:1e4,restrictedMethods:["get","post","upload","download","request"],auth:e.auth},o=new t.reqClass(n);r.baseRequest=function(e,t){var r,n,i,s,a;return Ne(this,void 0,void 0,(function(){var u,c,l,f;return xe(this,(function(d){switch(d.label){case 0:if(u={},c=(null===(r=t.method)||void 0===r?void 0:r.toLocaleLowerCase())||"post","function"!=typeof(l=null===(i=null===(n=null==o?void 0:o[c])||void 0===n?void 0:n.bind)||void 0===i?void 0:i.call(n,o)))throw new Error("invalid 【".concat(c,"】 request method"));d.label=1;case 1:return d.trys.push([1,3,,4]),(null===(s=t.headers)||void 0===s?void 0:s["content-type"])&&!(null===(a=t.headers)||void 0===a?void 0:a["content-type"].includes("application/json"))||["string","undefined"].includes(typeof t.body)||(t.data=t.data||t.body,t.body=JSON.stringify(t.body)),[4,l(Ce({url:e},t))];case 2:return u=d.sent(),u=ke(u,Ce(Ce({},t),{url:e})),[3,4];case 3:throw f=d.sent(),u=Ce(Ce({},null==f?void 0:f.data),f);case 4:if(null==u?void 0:u.error)throw u;return[2,u]}}))}))}}}catch(e){console.error("user adapter generate fail:",e)}return r}(e,e.adapter):function(e,t){var r=Ce({},e),n={};if((null==t?void 0:t.captchaOptions)&&(r.captchaOptions=t.captchaOptions),!Re.ZP.isMatch()||e.storage&&e.baseRequest)return r;try{var o=Re.ZP.genAdapter({}),i=o.localStorage,s=o.reqClass;if(i&&(n.storage=new Le({localStorage:i,adapter:t})),s){var a=new s({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});n.request=function(e){return function(t,r){return Ne(this,void 0,void 0,(function(){return xe(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:t,data:i.body,timeout:e._timeout,method:i.method||"GET",header:i.headers,success:function(e){(e=ke(e,Ce(Ce({},r),{url:t}))).error&&o(e),n(e)},fail:function(e){o({error:"unreachable",error_description:e.message})},complete:function(t){if(t&&t.errMsg&&e._timeout&&-1!==e._restrictedMethods.indexOf("request")&&"request:fail timeout"===t.errMsg){console.warn(e._timeoutMsg);try{s.abort()}catch(e){}}}})}))]}))}))}}(a)}return r.captchaOptions&&(n.baseRequest=n.request,n.request=void 0),Ce(Ce({},r),n)}catch(e){console.error("adapter generate fail:",e)}return r}(e,e.adapter)},je=function(){return je=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},je.apply(this,arguments)},qe=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},Me=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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])}}},Be=function(){function e(e){}return e.prototype.signInWithRedirect=function(){throw new Error("[v1 兼容] WeixinAuthProvider.signInWithRedirect() 在当前版本中无法实现。 建议使用 auth.signInWithOAuth({ provider: 'providerId' }) 替代。")},e.prototype.getRedirectResult=function(e){return qe(this,void 0,void 0,(function(){return Me(this,(function(e){throw new Error("[v1 兼容] WeixinAuthProvider.getRedirectResult() 在当前版本中无法实现。 建议使用 auth.verifyOAuth({ code, state, provider }) 替代。")}))}))},e.prototype.getLinkRedirectResult=function(e){return qe(this,void 0,void 0,(function(){return Me(this,(function(e){throw new Error("[v1 兼容] WeixinAuthProvider.getLinkRedirectResult() 在当前版本中无法实现。 建议使用 auth.linkIdentity({ provider: 'providerId' }) 替代。")}))}))},e}(),We=function(){function e(e){this.authInstance=e.authInstance}return e.prototype.signIn=function(e){return qe(this,void 0,void 0,(function(){return Me(this,(function(t){switch(t.label){case 0:return[4,this.authInstance.signInWithCustomTicket((function(){return Promise.resolve(e)}))];case 1:return t.sent(),[2]}}))}))},e}(),Fe=function(){function e(e){this.authInstance=e.authInstance}return e.prototype.signIn=function(){return qe(this,void 0,void 0,(function(){return Me(this,(function(e){switch(e.label){case 0:return[4,this.authInstance.signInAnonymously({})];case 1:return e.sent(),[2]}}))}))},e}(),Ve=function(){function e(){}return e.prototype.weixinAuthProvider=function(e){return new Be({authInstance:this,appid:e.appid,scope:e.scope})},e.prototype.customAuthProvider=function(){return new We({authInstance:this})},e.prototype.anonymousAuthProvider=function(){return new Fe({authInstance:this})},e.prototype.signUpWithEmailAndPassword=function(e,t){return qe(this,void 0,void 0,(function(){return Me(this,(function(r){switch(r.label){case 0:return"string"!=typeof e&&(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"email must be a string"),"string"!=typeof t&&(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signUp({email:e,password:t})];case 1:return[2,r.sent()]}}))}))},e.prototype.signInWithEmailAndPassword=function(e,t){return qe(this,void 0,void 0,(function(){return Me(this,(function(r){switch(r.label){case 0:return"string"!=typeof e&&(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"email must be a string"),"string"!=typeof t&&(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signIn({username:e,password:t})];case 1:return r.sent(),[2,this.createLoginState()]}}))}))},e.prototype.sendPasswordResetEmail=function(e){return qe(this,void 0,void 0,(function(){return Me(this,(function(t){switch(t.label){case 0:return"string"!=typeof e&&(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"email must be a string"),[4,this.getVerification({email:e})];case 1:return t.sent(),[2]}}))}))},e.prototype.signInWithUsernameAndPassword=function(e,t){return qe(this,void 0,void 0,(function(){return Me(this,(function(r){switch(r.label){case 0:return"string"!=typeof e&&(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"username must be a string"),"string"!=typeof t&&(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signIn({username:e,password:t})];case 1:return r.sent(),[2,this.createLoginState()]}}))}))},e.prototype.sendPhoneCode=function(e){return qe(this,void 0,void 0,(function(){var t;return Me(this,(function(r){switch(r.label){case 0:return"string"!=typeof e&&(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),t=this.formatPhone(e),[4,this.getVerification({phone_number:t})];case 1:return r.sent(),[2,!0]}}))}))},e.prototype.signUpWithPhoneCode=function(e,t,r){return qe(this,void 0,void 0,(function(){var n;return Me(this,(function(o){switch(o.label){case 0:return"string"!=typeof e&&(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),"string"!=typeof t&&(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"phoneCode must be a string"),n=this.formatPhone(e),[4,this.signUp(je({phone_number:n,verification_code:t},r?{password:r}:{}))];case 1:return o.sent(),[2,this.createLoginState()]}}))}))},e.prototype.signInWithPhoneCodeOrPassword=function(e){return qe(this,void 0,void 0,(function(){var t,r,n,o;return Me(this,(function(i){switch(i.label){case 0:return t=e.phoneNumber,r=e.phoneCode,n=e.password,"string"!=typeof t&&(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),o=this.formatPhone(t),n?[4,this.signIn({username:o,password:n})]:[3,2];case 1:return i.sent(),[3,5];case 2:return r?[4,this.signIn({username:o,verification_token:r})]:[3,4];case 3:return i.sent(),[3,5];case 4:(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"phoneCode or password must be provided"),i.label=5;case 5:return[2,this.createLoginState()]}}))}))},e.prototype.forceResetPwdByPhoneCode=function(e){return qe(this,void 0,void 0,(function(){var t,r,n,o;return Me(this,(function(i){switch(i.label){case 0:return t=e.phoneNumber,r=e.phoneCode,n=e.password,"string"!=typeof t&&(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),"string"!=typeof r&&(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"phoneCode must be a string"),"string"!=typeof n&&(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"password must be a string"),o=this.formatPhone(t),[4,this.resetPassword({phone_number:o,new_password:n,verification_token:r})];case 1:return i.sent(),[4,this.signIn({username:o,password:n})];case 2:return i.sent(),[2,this.createLoginState()]}}))}))},e.prototype.shouldRefreshAccessToken=function(e){throw new Error("[v1 兼容] shouldRefreshAccessToken() 在当前版本中无法实现。 建议使用 auth.onAuthStateChange(callback) 来监听 TOKEN_REFRESHED 事件替代。")},e.prototype.onLoginStateExpired=function(e){var t=this;this.onLoginStateChanged((function(r){(null==r?void 0:r.eventType)===l&&e.call(t)}))},e.prototype.onAccessTokenRefreshed=function(e){var t=this;this.onAuthStateChange((function(r){r===f.TOKEN_REFRESHED&&e.call(t)}))},e.prototype.onAnonymousConverted=function(e){var t=this;this.onAuthStateChange((function(r){r===f.SIGNED_IN&&e.call(t)}))},e.prototype.onLoginTypeChanged=function(e){var t=this;this.onAuthStateChange((function(r){r!==f.SIGNED_IN&&r!==f.SIGNED_OUT||e.call(t)}))},e}(),He=(Ee=function(e,t){return Ee=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},Ee(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}Ee(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),$e=function(){return $e=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},$e.apply(this,arguments)},Ge=function(e,t,r,n){var o,i=arguments.length,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s},ze=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Ke=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},Je=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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])}}},Ye=function(){return"undefined"!=typeof window&&"undefined"!=typeof document},Qe=function(e){return function(t){e.fire(d.LOGIN_STATE_CHANGED,$e($e({},t),{eventType:l}))}},Ze=function(){function e(e){var t=e.cache,r=e.oauthInstance;this.cache=t,this.oauthInstance=r,this.setUserInfo()}return e.prototype.checkLocalInfo=function(){return Ke(this,void 0,void 0,(function(){return Je(this,(function(e){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]}))}))},e.prototype.checkLocalInfoAsync=function(){return Ke(this,void 0,void 0,(function(){var e,t,r,n;return Je(this,(function(o){switch(o.label){case 0:return e=this,[4,this.getLocalUserInfoAsync("uid")];case 1:return e.uid=o.sent(),t=this,[4,this.getLocalUserInfoAsync("gender")];case 2:return t.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]}}))}))},e.prototype.update=function(e){return Ke(this,void 0,void 0,(function(){var t;return Je(this,(function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.setUserProfile($e({},e))];case 1:return t=r.sent(),this.setLocalUserInfo(t),[2]}}))}))},e.prototype.updateUserBasicInfo=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.updateUserBasicInfo($e({},e))];case 1:return t.sent(),[4,this.refresh()];case 2:return t.sent(),[2]}}))}))},e.prototype.updatePassword=function(e,t){return this.oauthInstance.authApi.updatePasswordByOld({old_password:t,new_password:e})},e.prototype.updateUsername=function(e){return"string"!=typeof e&&(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"username must be a string"),this.update({username:e})},e.prototype.refresh=function(e){return Ke(this,void 0,void 0,(function(){var t;return Je(this,(function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.getUserInfo(e)];case 1:if("INVALID_ACCESS_TOKEN"===(t=r.sent()).code)throw this.setLocalUserInfo({}),t;return this.setLocalUserInfo(t),[2,t]}}))}))},e.prototype.getLocalUserInfo=function(e){var t=this.cache.keys.userInfoKey,r=this.cache.getStore(t);return e?r[e]:r||{}},e.prototype.setLocalUserInfo=function(e){var t=this.cache.keys.userInfoKey;this.cache.setStore(t,e),this.setUserInfo()},e.prototype.getLocalUserInfoAsync=function(e){return Ke(this,void 0,void 0,(function(){var t;return Je(this,(function(r){switch(r.label){case 0:return t=this.cache.keys.userInfoKey,[4,this.cache.getStoreAsync(t)];case 1:return[2,r.sent()[e]]}}))}))},e.prototype.setUserInfo=function(){var e=this,t=this.cache.keys.userInfoKey,r=this.cache.getStore(t);["uid","email","name","gender","picture","email_verified","phone_number","birthdate","zoneinfo","locale","sub","created_from","providers","username","created_at"].forEach((function(t){e[t]=r[t]}))},Ge([(0,Te.catchErrorsDecorator)({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[Object]),ze("design:returntype",Promise)],e.prototype,"update",null),Ge([(0,Te.catchErrorsDecorator)({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[String,String]),ze("design:returntype",void 0)],e.prototype,"updatePassword",null),Ge([(0,Te.catchErrorsDecorator)({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[String]),ze("design:returntype",void 0)],e.prototype,"updateUsername",null),Ge([(0,Te.catchErrorsDecorator)({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[Object]),ze("design:returntype",Promise)],e.prototype,"refresh",null),e}();(Ie=Ze).prototype.linkWithTicket=function(e){return qe(this,void 0,void 0,(function(){return Me(this,(function(e){throw new Error("[v1 兼容] User.linkWithTicket() 在当前版本中无法实现。 建议使用 auth.signInWithCustomTicket(() => Promise.resolve(ticket)) 替代。")}))}))},Ie.prototype.linkWithRedirect=function(e){throw new Error("[v1 兼容] User.linkWithRedirect() 在当前版本中无法实现。 建议使用 auth.linkIdentity({ provider: 'providerId' }) 替代。")},Ie.prototype.updateEmail=function(e,t){return qe(this,void 0,void 0,(function(){return Me(this,(function(t){switch(t.label){case 0:return"string"!=typeof e&&(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"newEmail must be a string"),[4,this.updateUserBasicInfo({email:e})];case 1:return t.sent(),[2]}}))}))},Ie.prototype.linkWithPhoneNumber=function(e,t){return qe(this,void 0,void 0,(function(){return Me(this,(function(e){throw new Error("[v1 兼容] User.linkWithPhoneNumber() 在当前版本中无法实现。 建议使用 auth.bindPhoneNumber({ phone_number, verification_token, sudo_token }) 替代。")}))}))},Ie.prototype.updatePhoneNumber=function(e,t){return qe(this,void 0,void 0,(function(){return Me(this,(function(e){throw new Error("[v1 兼容] User.updatePhoneNumber() 在当前版本中无法实现。 建议使用 auth.updateUser({ phone: newPhoneNumber }) 替代。")}))}))},Ie.prototype.unlink=function(e){return qe(this,void 0,void 0,(function(){return Me(this,(function(e){throw new Error("[v1 兼容] User.unlink() 在当前版本中无法实现。 建议使用 auth.unlinkIdentity({ provider: loginType }) 替代。")}))}))};var Xe=function(){function e(e){var t=e.envId,r=e.cache,n=e.oauthInstance;t||(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"envId is not defined"),this.cache=r,this.oauthInstance=n,this.user=new Ze({cache:this.cache,oauthInstance:n})}return e.prototype.checkLocalState=function(){var e;this.oauthLoginState=null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.hasLoginStateSync(),this.user.checkLocalInfo()},e.prototype.checkLocalStateAsync=function(){var e;return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){switch(t.label){case 0:return[4,null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.getLoginState()];case 1:return t.sent(),[4,this.user.checkLocalInfoAsync()];case 2:return t.sent(),[2]}}))}))},e}(),et=function(e){function t(t){var r=e.call(this)||this;return r.listeners=new Map,r.hasListenerSetUp=!1,r.config=t,r.oauthInstance=t.oauthInstance,r.cache=t.cache,r.init(),r.setAccessKey(),r}return He(t,e),t.prototype.signInAnonymously=function(e){return Ke(this,void 0,void 0,(function(){var t,r,n,o,i;return Je(this,(function(s){switch(s.label){case 0:return s.trys.push([0,4,,5]),[4,this.oauthInstance.authApi.signInAnonymously(e)];case 1:return s.sent(),[4,this.createLoginState()];case 2:return t=s.sent(),[4,this.getSession()];case 3:return r=s.sent().data,n=(void 0===r?{}:r).session,[2,$e($e({},t),{data:{user:n.user,session:n},error:null})];case 4:return o=s.sent(),(i=new ce(o,{method:"signInAnonymously"})).category===ie.PROVIDER_NOT_ENABLED?(console.error(i.helpMessage),console.error("[CloudBase Auth] 提示:匿名登录需要在控制台开启「匿名登录」。\n 如果您需要使用用户名密码登录,请改用 auth.signInWithPassword({ username, password })。\n 不要在匿名登录失败后自动回退到密码登录,这两种方式的使用场景不同。")):(console.warn("[CloudBase Auth] signInAnonymously 失败 [".concat(i.category,"]: ").concat(i.message)),i.loginMethodHint&&console.warn(i.loginMethodHint)),[2,{data:{},error:i}];case 5:return[2]}}))}))},t.prototype.signUp=function(e){return Ke(this,void 0,void 0,(function(){var t,r,n=this;return Je(this,(function(o){switch(o.label){case 0:return e.phone_number||e.verification_code||e.verification_token||e.provider_token?(e.phone_number=this.formatPhone(e.phone_number),[4,this.oauthInstance.authApi.signUp(e)]):[3,2];case 1:return o.sent(),[2,this.createLoginState()];case 2:return o.trys.push([2,4,,5]),this.validateAtLeastOne(e,[["email"],["phone"]],"You must provide either an email or phone number"),[4,this.getVerification(e.email?{email:e.email}:{phone_number:this.formatPhone(e.phone)})];case 3:return t=o.sent(),[2,{data:{verifyOtp:function(r){var o=r.token,i=r.messageId,s=void 0===i?t.verification_id:i;return Ke(n,void 0,void 0,(function(){var r,n,i,a,u;return Je(this,(function(c){switch(c.label){case 0:return c.trys.push([0,8,,9]),[4,this.verify({verification_id:s||t.verification_id,verification_code:o})];case 1:return r=c.sent(),t.is_user?[4,this.signIn({username:e.email||this.formatPhone(e.phone),verification_token:r.verification_token})]:[3,3];case 2:return c.sent(),[3,6];case 3:return delete(n=JSON.parse(JSON.stringify(e))).email,delete n.phone,[4,this.oauthInstance.authApi.signUp($e($e($e({},n),e.email?{email:e.email}:{phone_number:this.formatPhone(e.phone)}),{verification_token:r.verification_token,verification_code:o}))];case 4:return c.sent(),[4,this.createLoginState()];case 5:c.sent(),c.label=6;case 6:return[4,this.getSession()];case 7:return i=c.sent().data,[2,{data:{user:(a=(void 0===i?{}:i).session).user,session:a},error:null}];case 8:return u=c.sent(),[2,{data:{},error:new ce(u,{method:"signUp"})}];case 9:return[2]}}))}))}},error:null}];case 4:return r=o.sent(),[2,{data:{},error:new ce(r,{method:"signUp"})}];case 5:return[2]}}))}))},t.prototype.signOut=function(e){var t,r;return Ke(this,void 0,void 0,(function(){var n,o,i;return Je(this,(function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),n=this.cache.keys.userInfoKey,[4,this.oauthInstance.authApi.signOut(e)];case 1:return o=s.sent(),[4,this.cache.removeStoreAsync(n)];case 2:return s.sent(),this.setAccessKey(),null===(t=this.config.eventBus)||void 0===t||t.fire(d.LOGIN_STATE_CHANGED,{eventType:"sign_out"}),null===(r=this.config.eventBus)||void 0===r||r.fire(d.AUTH_STATE_CHANGED,{event:f.SIGNED_OUT}),[2,$e($e({},o),{data:{},error:null})];case 3:return i=s.sent(),[2,{data:{},error:new ce(i,{method:"signOut"})}];case 4:return[2]}}))}))},t.prototype.onAuthStateChange=function(e){var t=this;this.hasListenerSetUp||(this.setupListeners(),this.hasListenerSetUp=!0);var r=Math.random().toString(36);return this.listeners.has(r)||this.listeners.set(r,new Set),this.listeners.get(r).add(e),{data:{subscription:{id:r,callback:e,unsubscribe:function(){var n=t.listeners.get(r);n&&(n.delete(e),0===n.size&&t.listeners.delete(r))}}}}},t.prototype.signInWithPassword=function(e){return Ke(this,void 0,void 0,(function(){var t,r,n,o;return Je(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),this.validateAtLeastOne(e,[["username"],["email"],["phone"]],"You must provide either username, email, or phone"),this.validateParams(e,{password:{required:!0,message:"Password is required"}}),[4,this.signIn($e({username:e.username||e.email||this.formatPhone(e.phone),password:e.password},e.is_encrypt?{isEncrypt:!0,version:"v2"}:{}))];case 1:return i.sent(),[4,this.getSession()];case 2:return t=i.sent().data,[2,{data:{user:(r=(void 0===t?{}:t).session).user,session:r},error:null}];case 3:return n=i.sent(),(o=new ce(n,{method:"signInWithPassword"})).category===ie.PROVIDER_NOT_ENABLED?console.error(o.helpMessage):o.category===ie.INVALID_CREDENTIALS||o.category===ie.USER_NOT_FOUND?console.warn(o.helpMessage):console.warn("[CloudBase Auth] signInWithPassword 失败 [".concat(o.category,"]: ").concat(o.message)),o.loginMethodHint&&console.info(o.loginMethodHint),[2,{data:{},error:o}];case 4:return[2]}}))}))},t.prototype.signInWithIdToken=function(e){return Ke(this,void 0,void 0,(function(){var t,r,n;return Je(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),this.validateParams(e,{token:{required:!0,message:"Token is required"}}),[4,this.signInWithProvider({provider_token:e.token})];case 1:return o.sent(),[4,this.getSession()];case 2:return t=o.sent().data,[2,{data:{user:(r=(void 0===t?{}:t).session).user,session:r},error:null}];case 3:return n=o.sent(),[2,{data:{},error:new ce(n,{method:"signInWithIdToken"})}];case 4:return[2]}}))}))},t.prototype.signInWithOtp=function(e){var t,r,n,o;return Ke(this,void 0,void 0,(function(){var i,s,a=this;return Je(this,(function(u){switch(u.label){case 0:if(!(null===(t=e.options)||void 0===t?void 0:t.emailRedirectTo)&&(void 0===(null===(r=e.options)||void 0===r?void 0:r.shouldCreateUser)||(null===(n=e.options)||void 0===n?void 0:n.shouldCreateUser)))return[2,this.signUp({email:e.email,phone:e.phone})];u.label=1;case 1:return u.trys.push([1,3,,4]),this.validateAtLeastOne(e,[["email"],["phone"]],"You must provide either an email or phone number"),[4,this.getVerification($e({email_redirect_to:null===(o=e.options)||void 0===o?void 0:o.emailRedirectTo},e.email?{email:e.email}:{phone_number:this.formatPhone(e.phone)}))];case 2:return i=u.sent(),[2,{data:{user:null,session:null,verifyOtp:function(t){var r=t.token,n=t.messageId,o=void 0===n?i.verification_id:n;return Ke(a,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.verifyOtp({email:e.email,phone:e.phone,token:r,messageId:o})]}))}))}},error:null}];case 3:return s=u.sent(),[2,{data:{},error:new ce(s,{method:"signInWithOtp"})}];case 4:return[2]}}))}))},t.prototype.verifyOAuth=function(e){return Ke(this,void 0,void 0,(function(){var t,r,n,o,i,s,a,u,c;return Je(this,(function(l){switch(l.label){case 0:t={},l.label=1;case 1:return l.trys.push([1,7,,8]),r=(null==e?void 0:e.code)||A.P6.getQuery("code"),n=(null==e?void 0:e.state)||A.P6.getQuery("state"),r?n?(o=function(e){try{return JSON.parse(sessionStorage.getItem(e))}catch(e){return console.error("Failed to get browser session:",e),null}}(n),t.type=null==o?void 0:o.type,(i=(null==e?void 0:e.provider)||(null==o?void 0:o.provider)||A.P6.getQuery("provider"))?[4,this.grantProviderToken({provider_id:i,provider_redirect_uri:location.origin+location.pathname,provider_code:r})]:[2,{data:t,error:new ce({message:"Provider is required"})}]):[2,{data:{},error:new ce({message:"State is required"})}]:[2,{data:{},error:new ce({message:"Code is required"})}];case 2:return s=l.sent().provider_token,a=void 0,o.type!==h.BIND_IDENTITY?[3,4]:[4,this.oauthInstance.authApi.toBindIdentity({provider_token:s,provider:i,fireEvent:!0})];case 3:return a=l.sent(),[3,6];case 4:return[4,this.signInWithIdToken({token:s})];case 5:(a=l.sent()).data=$e($e({},t),a.data),l.label=6;case 6:return(u=new URLSearchParams(null===location||void 0===location?void 0:location.search)).delete("code"),u.delete("state"),a.data.redirectUrl=function(e,t){if(void 0!==e){var r=new URL(window.location.href);return r.search=e,r.hash=t||r.hash,window.history.replaceState({},"",r.href),r.href}}(void 0===(null==o?void 0:o.search)?"?".concat(u.toString()):null==o?void 0:o.search,(null==o?void 0:o.hash)||location.hash),function(e){try{return sessionStorage.removeItem(e),!0}catch(e){return console.error("Failed to remove browser session:",e),null}}(n),[2,a];case 7:return c=l.sent(),[2,{data:t,error:new ce(c,{method:"verifyOAuth"})}];case 8:return[2]}}))}))},t.prototype.signInWithOAuth=function(e){var t,r,n,o,i;return Ke(this,void 0,void 0,(function(){var s,a,u,c,l,f,d,p,v;return Je(this,(function(y){switch(y.label){case 0:return y.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}}),s=(null===(t=e.options)||void 0===t?void 0:t.redirectTo)||location.href,a=new URL(s),u=a.origin+a.pathname,c=(null===(r=e.options)||void 0===r?void 0:r.state)||"prd-".concat(e.provider,"-").concat(Math.random().toString(36).slice(2)),[4,this.genProviderRedirectUri({provider_id:e.provider,provider_redirect_uri:u,state:c})];case 1:return l=y.sent().uri,f=decodeURIComponent(l),d=f,(null===(n=e.options)||void 0===n?void 0:n.queryParams)&&(p=new URL(f),Object.entries(e.options.queryParams).forEach((function(e){var t=e[0],r=e[1];p.searchParams.set(t,r)})),d=p.toString()),function(e,t){try{sessionStorage.setItem(e,JSON.stringify(t))}catch(e){console.error("Failed to save to browser session:",e)}}(c,{provider:e.provider,search:a.search,hash:a.hash,type:(null===(o=e.options)||void 0===o?void 0:o.type)||h.SIGN_IN}),Ye()&&!(null===(i=e.options)||void 0===i?void 0:i.skipBrowserRedirect)&&window.location.assign(d),[2,{data:{url:d,provider:e.provider},error:null}];case 2:return v=y.sent(),[2,{data:{},error:new ce(v,{method:"signInWithOAuth"})}];case 3:return[2]}}))}))},t.prototype.getClaims=function(){return Ke(this,void 0,void 0,(function(){var e;return Je(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.getAccessToken()];case 1:return[2,{data:function(e){if("string"!=typeof e)throw new Error("Invalid token specified");try{var t=e.split(".").map(((e,t)=>2===t?e:JSON.parse(function(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("Illegal base64url string!")}try{return function(e){return decodeURIComponent(E(e).replace(/(.)/g,(e=>{var t=e.charCodeAt(0).toString(16).toUpperCase();return t.length<2&&(t="0".concat(t)),"%".concat(t)})))}(t)}catch(e){return E(t)}}(e))));return{claims:t[1],header:t[0],signature:t[2]}}catch(e){throw new Error("Invalid token specified: ".concat(e)?e.message:0)}}(t.sent().accessToken),error:null}];case 2:return e=t.sent(),[2,{data:{},error:new ce(e,{method:"getClaims"})}];case 3:return[2]}}))}))},t.prototype.resetPasswordForEmail=function(e,t){return Ke(this,void 0,void 0,(function(){var r,n,o,i,s,a,u=this;return Je(this,(function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),this.validateParams({emailOrPhone:e},{emailOrPhone:{required:!0,message:"Email or phone is required"}}),r=(t||{}).redirectTo,n=e.includes("@"),o=void 0,n?o={email:e}:(i=this.formatPhone(e),o={phone_number:i}),[4,this.getVerification(o)];case 1:return s=c.sent(),[2,{data:{updateUser:function(t){return Ke(u,void 0,void 0,(function(){var o,i,a,u;return Je(this,(function(c){switch(c.label){case 0:this.validateParams(t,{nonce:{required:!0,message:"Nonce is required"},password:{required:!0,message:"Password is required"}}),c.label=1;case 1:return c.trys.push([1,5,,6]),[4,this.verify({verification_id:s.verification_id,verification_code:t.nonce})];case 2:return o=c.sent(),[4,this.oauthInstance.authApi.resetPassword({email:n?e:void 0,phone_number:n?void 0:e,new_password:t.password,verification_token:o.verification_token})];case 3:return c.sent(),null===(u=this.config.eventBus)||void 0===u||u.fire(d.AUTH_STATE_CHANGED,{event:f.PASSWORD_RECOVERY}),[4,this.signInWithPassword({email:n?e:void 0,phone:n?void 0:e,password:t.password})];case 4:return i=c.sent(),r&&Ye()&&window.location.assign(r),[2,i];case 5:return a=c.sent(),[2,{data:{},error:new ce(a,{method:"resetPasswordForEmail"})}];case 6:return[2]}}))}))}},error:null}];case 2:return a=c.sent(),[2,{data:{},error:new ce(a,{method:"resetPasswordForEmail"})}];case 3:return[2]}}))}))},t.prototype.resetPasswordForOld=function(e){return Ke(this,void 0,void 0,(function(){var t,r,n;return Je(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,this.oauthInstance.authApi.updatePasswordByOld({old_password:e.old_password,new_password:e.new_password})];case 1:return o.sent(),[4,this.getSession()];case 2:return t=o.sent().data,[2,{data:{user:(r=(void 0===t?{}:t).session).user,session:r},error:null}];case 3:return n=o.sent(),[2,{data:{},error:new ce(n,{method:"resetPasswordForOld"})}];case 4:return[2]}}))}))},t.prototype.verifyOtp=function(e){return Ke(this,void 0,void 0,(function(){var t,r,n,o;return Je(this,(function(i){switch(i.label){case 0:return i.trys.push([0,6,,7]),t=e.type,this.validateParams(e,{token:{required:!0,message:"Token is required"},messageId:{required:!0,message:"messageId is required"}}),["phone_change","email_change"].includes(t)?[4,this.verify({verification_id:e.messageId,verification_code:e.token})]:[3,2];case 1:return i.sent(),[3,4];case 2:return[4,this.signInWithUsername({verificationInfo:{verification_id:e.messageId,is_user:!0},verificationCode:e.token,username:e.email||this.formatPhone(e.phone)||"",loginType:e.email?"email":"phone"})];case 3:i.sent(),i.label=4;case 4:return[4,this.getSession()];case 5:return r=i.sent().data,[2,{data:{user:(n=(void 0===r?{}:r).session).user,session:n},error:null}];case 6:return o=i.sent(),[2,{data:{},error:new ce(o,{method:"verifyOtp"})}];case 7:return[2]}}))}))},t.prototype.getSession=function(){return Ke(this,void 0,void 0,(function(){var e,t,r,n;return Je(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,this.oauthInstance.oauth2client.getCredentials()];case 1:return(e=o.sent())&&"accessKey"!==e.scope?[4,this.getUser()]:[2,{data:{session:null},error:null}];case 2:return t=o.sent().data,r=(void 0===t?{}:t).user,[2,{data:{session:$e($e({},e),{user:r}),user:r},error:null}];case 3:return n=o.sent(),[2,{data:{},error:new ce(n,{method:"getSession"})}];case 4:return[2]}}))}))},t.prototype.refreshSession=function(e){return Ke(this,void 0,void 0,(function(){var t,r,n,o,i;return Je(this,(function(s){switch(s.label){case 0:return s.trys.push([0,4,,5]),[4,this.oauthInstance.oauth2client.localCredentials.getCredentials()];case 1:return(t=s.sent()).refresh_token=e||t.refresh_token,[4,this.oauthInstance.oauth2client.refreshToken(t)];case 2:return r=s.sent(),[4,this.getUser()];case 3:return n=s.sent().data,[2,{data:{user:o=(void 0===n?{}:n).user,session:$e($e({},r),{user:o})},error:null}];case 4:return i=s.sent(),[2,{data:{},error:new ce(i,{method:"refreshSession"})}];case 5:return[2]}}))}))},t.prototype.getUser=function(){return Ke(this,void 0,void 0,(function(){var e,t;return Je(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),e=this.convertToUser,[4,this.getCurrentUser()];case 1:return[2,{data:{user:e.apply(this,[r.sent()])},error:null}];case 2:return t=r.sent(),[2,{data:{},error:new ce(t,{method:"getUser"})}];case 3:return[2]}}))}))},t.prototype.refreshUser=function(){return Ke(this,void 0,void 0,(function(){var e,t,r;return Je(this,(function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),[4,this.currentUser.refresh()];case 1:return n.sent(),[4,this.getSession()];case 2:return e=n.sent().data,[2,{data:{user:(t=(void 0===e?{}:e).session).user,session:t},error:null}];case 3:return r=n.sent(),[2,{data:{},error:new ce(r,{method:"refreshUser"})}];case 4:return[2]}}))}))},t.prototype.updateUser=function(e){var t;return Ke(this,void 0,void 0,(function(){var r,n,o,i,s,a,u,c,l,h,p,v,y=this;return Je(this,(function(m){switch(m.label){case 0:if(m.trys.push([0,8,,9]),!Object.keys(e).some((function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]})))throw new ce({message:"At least one field must be provided for update"});return r=e.email,n=e.phone,o=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(e,["email","phone"]),s=void 0!==n,a={},(i=void 0!==r)||s?(u=void 0,i?(u={email:e.email},c="email_change"):(l=this.formatPhone(e.phone),u={phone_number:l},c="phone_change"),[4,this.getVerification(u)]):[3,4];case 1:return h=m.sent(),Object.keys(o).length>0?[4,this.updateUserBasicInfo(o)]:[3,3];case 2:m.sent(),m.label=3;case 3:return a={messageId:h.verification_id,verifyOtp:function(t){return Ke(y,void 0,void 0,(function(){var r,n,o;return Je(this,(function(s){switch(s.label){case 0:return s.trys.push([0,11,,12]),t.email&&e.email===t.email?[4,this.verifyOtp({type:"email_change",email:e.email,token:t.token,messageId:h.verification_id})]:[3,3];case 1:return s.sent(),[4,this.updateUserBasicInfo({email:e.email})];case 2:return s.sent(),[3,9];case 3:return t.phone&&e.phone===t.phone?[4,this.verifyOtp({type:"phone_change",phone:e.phone,token:t.token,messageId:h.verification_id})]:[3,6];case 4:return s.sent(),[4,this.updateUserBasicInfo({phone:this.formatPhone(e.phone)})];case 5:return s.sent(),[3,9];case 6:return[4,this.verifyOtp({type:c,email:i?e.email:void 0,phone:i?void 0:e.phone,token:t.token,messageId:h.verification_id})];case 7:return s.sent(),[4,this.updateUserBasicInfo(e)];case 8:s.sent(),s.label=9;case 9:return[4,this.getUser()];case 10:return r=s.sent().data.user,null===(o=this.config.eventBus)||void 0===o||o.fire(d.AUTH_STATE_CHANGED,{event:f.USER_UPDATED}),[2,{data:{user:r},error:null}];case 11:return n=s.sent(),[2,{data:{},error:new ce(n,{method:"updateUser"})}];case 12:return[2]}}))}))}},[3,6];case 4:return[4,this.updateUserBasicInfo(e)];case 5:m.sent(),m.label=6;case 6:return[4,this.getUser()];case 7:return p=m.sent().data.user,null===(t=this.config.eventBus)||void 0===t||t.fire(d.AUTH_STATE_CHANGED,{event:f.USER_UPDATED}),[2,{data:$e({user:p},a),error:null}];case 8:return v=m.sent(),[2,{data:{},error:new ce(v,{method:"updateUser"})}];case 9:return[2]}}))}))},t.prototype.getUserIdentities=function(){var e;return Ke(this,void 0,void 0,(function(){var t,r;return Je(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.oauthInstance.authApi.getProviders()];case 1:return t=n.sent(),[2,{data:{identities:null===(e=null==t?void 0:t.data)||void 0===e?void 0:e.filter((function(e){return!!e.bind}))},error:null}];case 2:return r=n.sent(),[2,{data:{},error:new ce(r,{method:"getUserIdentities"})}];case 3:return[2]}}))}))},t.prototype.linkIdentity=function(e){return Ke(this,void 0,void 0,(function(){var t;return Je(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}}),[4,this.signInWithOAuth({provider:e.provider,options:{type:h.BIND_IDENTITY}})];case 1:return r.sent(),[2,{data:{provider:e.provider},error:null}];case 2:return t=r.sent(),[2,{data:{},error:new ce(t,{method:"linkIdentity"})}];case 3:return[2]}}))}))},t.prototype.unlinkIdentity=function(e){return Ke(this,void 0,void 0,(function(){var t;return Je(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}}),[4,this.oauthInstance.authApi.unbindProvider({provider_id:e.provider})];case 1:return r.sent(),[2,{data:{},error:null}];case 2:return t=r.sent(),[2,{data:{},error:new ce(t,{method:"unlinkIdentity"})}];case 3:return[2]}}))}))},t.prototype.reauthenticate=function(){return Ke(this,void 0,void 0,(function(){var e,t,r,n,o=this;return Je(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,this.getUser()];case 1:return e=i.sent().data.user,this.validateAtLeastOne(e,[["email","phone"]],"You must provide either an email or phone number"),t=e.email?{email:e.email}:{phone_number:this.formatPhone(e.phone)},[4,this.getVerification(t)];case 2:return r=i.sent(),[2,{data:{updateUser:function(e){return Ke(o,void 0,void 0,(function(){var n,o,i,s,a;return Je(this,(function(u){switch(u.label){case 0:this.validateParams(e,{nonce:{required:!0,message:"Nonce is required"}}),u.label=1;case 1:return u.trys.push([1,9,,10]),e.password?[4,this.verify({verification_id:r.verification_id,verification_code:e.nonce})]:[3,5];case 2:return n=u.sent(),[4,this.oauthInstance.authApi.sudo({verification_token:n.verification_token})];case 3:return o=u.sent(),[4,this.oauthInstance.authApi.setPassword({new_password:e.password,sudo_token:o.sudo_token})];case 4:return u.sent(),[3,7];case 5:return[4,this.signInWithUsername($e($e({verificationInfo:r,verificationCode:e.nonce},t),{loginType:t.email?"email":"phone"}))];case 6:u.sent(),u.label=7;case 7:return[4,this.getSession()];case 8:return i=u.sent().data,[2,{data:{user:(s=(void 0===i?{}:i).session).user,session:s},error:null}];case 9:return a=u.sent(),[2,{data:{},error:new ce(a,{method:"reauthenticate"})}];case 10:return[2]}}))}))}},error:null}];case 3:return n=i.sent(),[2,{data:{},error:new ce(n,{method:"reauthenticate"})}];case 4:return[2]}}))}))},t.prototype.resend=function(e){return Ke(this,void 0,void 0,(function(){var t,r,n;return Je(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),this.validateAtLeastOne(e,[["email"],["phone"]],"You must provide either an email or phone number"),t="signup"===e.type?"ANY":"USER",r={target:t},"email"in e&&(r.email=e.email),"phone"in e&&(r.phone_number=this.formatPhone(e.phone)),[4,this.oauthInstance.authApi.getVerification(r)];case 1:return[2,{data:{messageId:o.sent().verification_id},error:null}];case 2:return n=o.sent(),[2,{data:{},error:new ce(n,{method:"resend"})}];case 3:return[2]}}))}))},t.prototype.setSession=function(e){var t;return Ke(this,void 0,void 0,(function(){var r,n,o;return Je(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),this.validateParams(e,{access_token:{required:!0,message:"Access token is required"},refresh_token:{required:!0,message:"Refresh token is required"}}),[4,this.oauthInstance.oauth2client.refreshToken(e,{throwError:!0})];case 1:return i.sent(),[4,this.getSession()];case 2:return r=i.sent().data,n=(void 0===r?{}:r).session,null===(t=this.config.eventBus)||void 0===t||t.fire(d.AUTH_STATE_CHANGED,{event:f.SIGNED_IN}),[2,{data:{user:n.user,session:n},error:null}];case 3:return o=i.sent(),[2,{data:{},error:new ce(o,{method:"setSession"})}];case 4:return[2]}}))}))},t.prototype.exchangeCodeForSession=function(){return Ke(this,void 0,void 0,(function(){return Je(this,(function(e){return[2]}))}))},t.prototype.deleteUser=function(e){return Ke(this,void 0,void 0,(function(){var t,r;return Je(this,(function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),this.validateParams(e,{password:{required:!0,message:"Password is required"}}),[4,this.oauthInstance.authApi.sudo(e)];case 1:return t=n.sent().sudo_token,[4,this.oauthInstance.authApi.deleteMe({sudo_token:t})];case 2:return n.sent(),[2,{data:{},error:null}];case 3:return r=n.sent(),[2,{data:{},error:new ce(r,{method:"deleteUser"})}];case 4:return[2]}}))}))},t.prototype.toDefaultLoginPage=function(e){return void 0===e&&(e={}),Ke(this,void 0,void 0,(function(){var t,r,n,o,i;return Je(this,(function(s){try{return t=e.config_version||"env",r=Object.keys(e.query||{}).map((function(t){return"".concat(t,"=").concat(e.query[t])})).join("&"),Re.ZP.isMatch()?wx.navigateTo({url:"/packages/$wd_system/pages/login/index".concat(r?"?".concat(r):"")}):(n=e.redirect_uri||window.location.href,o=new URL(n),i="".concat(o.origin,"/__auth/?app_id=").concat(e.app_id||"","&env_id=").concat(this.config.env,"&client_id=").concat(this.config.clientId||this.config.env,"&config_version=").concat(t,"&redirect_uri=").concat(encodeURIComponent(n)).concat(r?"&".concat(r):""),window.location.href=i),[2,{data:{},error:null}]}catch(e){return[2,{data:{},error:new ce(e,{method:"toDefaultLoginPage"})}]}return[2]}))}))},t.prototype.signInWithCustomTicket=function(e){return Ke(this,void 0,void 0,(function(){var t,r,n,o;return Je(this,(function(i){switch(i.label){case 0:e&&this.setCustomSignFunc(e),i.label=1;case 1:return i.trys.push([1,5,,6]),[4,this.oauthInstance.authApi.signInWithCustomTicket()];case 2:return i.sent(),[4,this.createLoginState()];case 3:return t=i.sent(),[4,this.getSession()];case 4:return r=i.sent().data,n=(void 0===r?{}:r).session,[2,$e($e({},t),{data:{user:n.user,session:n},error:null})];case 5:return o=i.sent(),[2,{data:{},error:new ce(o,{method:"signInWithCustomTicket"})}];case 6:return[2]}}))}))},t.prototype.signInWithOpenId=function(e){var t=(void 0===e?{}:e).useWxCloud,r=void 0===t||t;return Ke(this,void 0,void 0,(function(){var e,t,n,o,i,s,a=this;return Je(this,(function(u){switch(u.label){case 0:if(!Re.ZP.isMatch())throw Error("wx api undefined");e=wx.getAccountInfoSync().miniProgram,t=function(t){return Ke(a,void 0,void 0,(function(){var n,o;return Je(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==e?void 0:e.appId,provider_code:t,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.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]}}))}))},u.label=1;case 1:return u.trys.push([1,5,,6]),[4,new Promise((function(e,r){wx.login({success:function(n){return Ke(a,void 0,void 0,(function(){var o;return Je(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,t(n.code)];case 1:return i.sent(),e(!0),[3,3];case 2:return o=i.sent(),r(o),[3,3];case 3:return[2]}}))}))},fail:function(e){var t=new Error(null==e?void 0:e.errMsg);t.code=null==e?void 0:e.errno,r(t)}})}))];case 2:return u.sent(),[4,this.createLoginState()];case 3:return n=u.sent(),[4,this.getSession()];case 4:return o=u.sent().data,i=(void 0===o?{}:o).session,[2,$e($e({},n),{data:{user:i.user,session:i},error:null})];case 5:return s=u.sent(),[2,{data:{},error:new ce(s,{method:"signInWithOpenId"})}];case 6:return[2]}}))}))},t.prototype.signInWithPhoneAuth=function(e){var t=e.phoneCode,r=void 0===t?"":t,n=e.useWxCloud,o=void 0!==n&&n;return Ke(this,void 0,void 0,(function(){var e,t,n,i,s,a,u,c,l;return Je(this,(function(f){switch(f.label){case 0:return Re.ZP.isMatch()?(e=wx.getAccountInfoSync().miniProgram,t={provider_params:{provider_code_type:"phone",code:r,appid:e.appId},provider_id:e.appId},[4,wx.login()]):[2,{data:{},error:new ce({message:"wx api undefined"})}];case 1:n=f.sent().code,t.provider_code=n,f.label=2;case 2:return f.trys.push([2,5,,6]),[4,this.oauthInstance.authApi.grantProviderToken(t,o)];case 3:if((i=f.sent()).error_code)throw i;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:i.provider_token},o)];case 4:if(null==(s=f.sent())?void 0:s.error_code)throw s;return[3,6];case 5:return a=f.sent(),[2,{data:{},error:new ce(a,{method:"signInWithPhoneAuth"})}];case 6:return[4,this.createLoginState()];case 7:return u=f.sent(),[4,this.getSession()];case 8:return c=f.sent().data,l=(void 0===c?{}:c).session,[2,$e($e({},u),{data:{user:l.user,session:l},error:null})]}}))}))},t.prototype.bindPhoneNumber=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.editContact(e)]}))}))},t.prototype.unbindProvider=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.unbindProvider(e)]}))}))},t.prototype.bindEmail=function(e){return this.oauthInstance.authApi.editContact(e)},t.prototype.verify=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.verify(e)]}))}))},t.prototype.getVerification=function(e,t){return Ke(this,void 0,void 0,(function(){return Je(this,(function(r){return e.phone_number&&(e.phone_number=this.formatPhone(e.phone_number)),[2,this.oauthInstance.authApi.getVerification(e,t)]}))}))},Object.defineProperty(t.prototype,"currentUser",{get:function(){if("async"!==this.cache.mode){var e=this.hasLoginState();return e&&e.user||null}(0,F.printWarn)(Oe.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrentUser instead")},enumerable:!1,configurable:!0}),t.prototype.getCurrentUser=function(){return Ke(this,void 0,void 0,(function(){var e,t;return Je(this,(function(r){switch(r.label){case 0:return[4,this.getLoginState()];case 1:return(e=r.sent())?(t=e.user.getLocalUserInfo(),[4,e.user.checkLocalInfoAsync()]):[3,3];case 2:return r.sent(),[2,$e($e({},e.user),t)];case 3:return[2,null]}}))}))},t.prototype.signInAnonymouslyInWx=function(e){var t=(void 0===e?{}:e).useWxCloud;return Ke(this,void 0,void 0,(function(){var e,r,n=this;return Je(this,(function(o){switch(o.label){case 0:if(!Re.ZP.isMatch())throw Error("wx api undefined");return e=wx.getAccountInfoSync().miniProgram,r=function(r){return Ke(n,void 0,void 0,(function(){var n,o;return Je(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==e?void 0:e.appId,provider_code:r,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.appId}},t)];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},t)];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(e,t){wx.login({success:function(o){return Ke(n,void 0,void 0,(function(){var n;return Je(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,r(o.code)];case 1:return i.sent(),e(!0),[3,3];case 2:return n=i.sent(),t(n),[3,3];case 3:return[2]}}))}))},fail:function(e){var r=new Error(null==e?void 0:e.errMsg);r.code=null==e?void 0:e.errno,t(r)}})}))];case 1:return o.sent(),[2,this.createLoginState(void 0,{asyncRefreshUser:!0})]}}))}))},t.prototype.bindOpenId=function(){return Ke(this,void 0,void 0,(function(){var e,t,r=this;return Je(this,(function(n){switch(n.label){case 0:if(!Re.ZP.isMatch())throw Error("wx api undefined");return e=wx.getAccountInfoSync().miniProgram,t=function(t){return Ke(r,void 0,void 0,(function(){var r;return Je(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==e?void 0:e.appId,provider_code:t,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.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(e,n){wx.login({success:function(o){return Ke(r,void 0,void 0,(function(){var r;return Je(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,t(o.code)];case 1:return i.sent(),e(!0),[3,3];case 2:return r=i.sent(),n(r),[3,3];case 3:return[2]}}))}))},fail:function(e){var t=new Error(null==e?void 0:e.errMsg);t.code=null==e?void 0:e.errno,n(t)}})}))];case 1:return n.sent(),[2]}}))}))},t.prototype.signInWithUnionId=function(){return Ke(this,void 0,void 0,(function(){var e=this;return Je(this,(function(t){switch(t.label){case 0:if(!Re.ZP.isMatch())throw Error("wx api undefined");t.label=1;case 1:return t.trys.push([1,3,,4]),[4,new Promise((function(t,r){var n=wx.getAccountInfoSync().miniProgram;wx.login({success:function(o){return Ke(e,void 0,void 0,(function(){var e,i,s,a,u;return Je(this,(function(c){switch(c.label){case 0:e=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:e,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:e,provider_token:s})]:(r(i),[2]);case 3:return(null==(a=c.sent())?void 0:a.error_code)?(r(a),[2]):(t(!0),[3,5]);case 4:return u=c.sent(),r(u),[3,5];case 5:return[2]}}))}))},fail:function(e){var t=new Error(null==e?void 0:e.errMsg);t.code=null==e?void 0:e.errno,r(t)}})}))];case 2:return t.sent(),[3,4];case 3:throw t.sent();case 4:return[2,this.createLoginState()]}}))}))},t.prototype.signInWithSms=function(e){var t=e.verificationInfo,r=void 0===t?{verification_id:"",is_user:!1}:t,n=e.verificationCode,o=void 0===n?"":n,i=e.phoneNum,s=void 0===i?"":i,a=e.bindInfo,u=void 0===a?void 0:a;return Ke(this,void 0,void 0,(function(){return Je(this,(function(e){try{return[2,this.signInWithUsername({verificationInfo:r,verificationCode:o,bindInfo:u,username:s,loginType:"sms"})]}catch(e){throw e}return[2]}))}))},t.prototype.signInWithEmail=function(e){var t=e.verificationInfo,r=void 0===t?{verification_id:"",is_user:!1}:t,n=e.verificationCode,o=void 0===n?"":n,i=e.bindInfo,s=void 0===i?void 0:i,a=e.email,u=void 0===a?"":a;return Ke(this,void 0,void 0,(function(){return Je(this,(function(e){try{return[2,this.signInWithUsername({verificationInfo:r,verificationCode:o,bindInfo:s,username:u,loginType:"email"})]}catch(e){throw e}return[2]}))}))},t.prototype.setCustomSignFunc=function(e){this.oauthInstance.authApi.setCustomSignFunc(e)},t.prototype.signIn=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signIn(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}}))}))},t.prototype.setPassword=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.setPassword(e)]}))}))},t.prototype.isUsernameRegistered=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){switch(t.label){case 0:return"string"!=typeof e&&(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"username must be a string"),[4,this.oauthInstance.authApi.checkIfUserExist({username:e})];case 1:return[2,t.sent().exist]}}))}))},t.prototype.hasLoginState=function(){var e;if("async"!==this.cache.mode)return(null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.hasLoginStateSync())?new Xe({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance}):null;(0,F.printWarn)(Oe.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState instead")},t.prototype.getLoginState=function(){return Ke(this,void 0,void 0,(function(){var e;return Je(this,(function(t){switch(t.label){case 0:e=null,t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.oauthInstance.authApi.getLoginState()];case 2:return e=t.sent(),[3,4];case 3:return t.sent(),[2,null];case 4:return e?[2,new Xe({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})]:[2,null]}}))}))},t.prototype.getUserInfo=function(){return Ke(this,void 0,void 0,(function(){return Je(this,(function(e){return[2,this.getCurrentUser()]}))}))},t.prototype.getWedaUserInfo=function(){return Ke(this,void 0,void 0,(function(){return Je(this,(function(e){return[2,this.oauthInstance.authApi.getWedaUserInfo()]}))}))},t.prototype.updateUserBasicInfo=function(e){return Ke(this,void 0,void 0,(function(){var t;return Je(this,(function(r){switch(r.label){case 0:return[4,this.getLoginState()];case 1:return(t=r.sent())?[4,t.user.updateUserBasicInfo(e)]:[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(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.bindWithProvider(e)]}))}))},t.prototype.queryUser=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.queryUserProfile(e)]}))}))},t.prototype.getAccessToken=function(){return Ke(this,void 0,void 0,(function(){return Je(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.oauth2client.getAccessToken()];case 1:return[2,{accessToken:e.sent(),env:this.config.env}]}}))}))},t.prototype.grantProviderToken=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.grantProviderToken(e)]}))}))},t.prototype.patchProviderToken=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.patchProviderToken(e)]}))}))},t.prototype.signInWithProvider=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signInWithProvider(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}}))}))},t.prototype.signInWithWechat=function(e){return void 0===e&&(e={}),Ke(this,void 0,void 0,(function(){return Je(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signInWithWechat(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}}))}))},t.prototype.grantToken=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.grantToken(e)];case 1:return t.sent(),[2,this.createLoginState()]}}))}))},t.prototype.genProviderRedirectUri=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.genProviderRedirectUri(e)]}))}))},t.prototype.resetPassword=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.resetPassword(e)]}))}))},t.prototype.deviceAuthorize=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.deviceAuthorize(e)]}))}))},t.prototype.sudo=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.sudo(e)]}))}))},t.prototype.deleteMe=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.deleteMe(e)]}))}))},t.prototype.getProviders=function(){return Ke(this,void 0,void 0,(function(){return Je(this,(function(e){return[2,this.oauthInstance.authApi.getProviders()]}))}))},t.prototype.loginScope=function(){return Ke(this,void 0,void 0,(function(){return Je(this,(function(e){return[2,this.oauthInstance.authApi.loginScope()]}))}))},t.prototype.loginGroups=function(){return Ke(this,void 0,void 0,(function(){return Je(this,(function(e){return[2,this.oauthInstance.authApi.loginGroups()]}))}))},t.prototype.onLoginStateChanged=function(e){var t;return Ke(this,void 0,void 0,(function(){var r,n=this;return Je(this,(function(o){switch(o.label){case 0:return null===(t=this.config.eventBus)||void 0===t||t.on(d.LOGIN_STATE_CHANGED,(function(t){return Ke(n,void 0,void 0,(function(){var r,n,o;return Je(this,(function(i){switch(i.label){case 0:return(null===(o=null==t?void 0:t.data)||void 0===o?void 0:o.eventType)===l?[3,2]:[4,this.getLoginState()];case 1:return n=i.sent(),[3,3];case 2:n={},i.label=3;case 3:return r=n,e.call(this,$e($e({},t),r)),[2]}}))}))})),[4,this.getLoginState()];case 1:return r=o.sent(),e.call(this,r),[2]}}))}))},t.prototype.refreshTokenForce=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.refreshTokenForce(e)]}))}))},t.prototype.getCredentials=function(){return Ke(this,void 0,void 0,(function(){return Je(this,(function(e){return[2,this.oauthInstance.authApi.getCredentials()]}))}))},t.prototype.setCredentials=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.oauth2client.setCredentials(e)];case 1:return t.sent(),[2]}}))}))},t.prototype.getProviderSubType=function(){return Ke(this,void 0,void 0,(function(){return Je(this,(function(e){return[2,this.oauthInstance.authApi.getProviderSubType()]}))}))},t.prototype.createCaptchaData=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.createCaptchaData(e)]}))}))},t.prototype.verifyCaptchaData=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.verifyCaptchaData(e)]}))}))},t.prototype.getMiniProgramQrCode=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.getMiniProgramCode(e)]}))}))},t.prototype.getMiniProgramQrCodeStatus=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.getMiniProgramQrCodeStatus(e)]}))}))},t.prototype.modifyPassword=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.modifyPassword(e)]}))}))},t.prototype.modifyPasswordWithoutLogin=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.modifyPasswordWithoutLogin(e)]}))}))},t.prototype.getUserBehaviorLog=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.getUserBehaviorLog(e)]}))}))},t.prototype.signInWithUsername=function(e){var t=e.verificationInfo,r=void 0===t?{verification_id:"",is_user:!1}:t,n=e.verificationCode,o=void 0===n?"":n,i=e.username,s=void 0===i?"":i,a=e.bindInfo,u=void 0===a?void 0:a,c=e.loginType,l=void 0===c?"":c;return Ke(this,void 0,void 0,(function(){var e,t,n,i,a,c,f;return Je(this,(function(d){switch(d.label){case 0:return d.trys.push([0,8,,9]),[4,this.oauthInstance.authApi.verify({verification_id:r.verification_id,verification_code:o})];case 1:if(null==(e=d.sent())?void 0:e.error_code)throw e;return t=e.verification_token,n=this.formatPhone(s),i={phone_number:n},"email"===l&&(i={email:n=s}),r.is_user?[4,this.oauthInstance.authApi.signIn({username:n,verification_token:t})]:[3,5];case 2:if(null==(a=d.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=d.sent())?void 0:c.error_code)throw c;d.label=4;case 4:return[3,7];case 5:return[4,this.oauthInstance.authApi.signUp($e($e({},i),{verification_token:t,provider_token:null==u?void 0:u.providerId}))];case 6:if(null==(f=d.sent())?void 0:f.error_code)throw f;d.label=7;case 7:return[2,this.createLoginState()];case 8:throw d.sent();case 9:return[2]}}))}))},t.prototype.createLoginState=function(e,t){var r,n;return Ke(this,void 0,void 0,(function(){var o;return Je(this,(function(i){switch(i.label){case 0:return[4,(o=new Xe({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})).checkLocalStateAsync()];case 1:return i.sent(),(null==t?void 0:t.userInfo)?(o.user.setLocalUserInfo(t.userInfo),[3,5]):[3,2];case 2:return(null==t?void 0:t.asyncRefreshUser)?(o.user.refresh(e),[3,5]):[3,3];case 3:return[4,o.user.refresh(e)];case 4:i.sent(),i.label=5;case 5:return null===(r=this.config.eventBus)||void 0===r||r.fire(d.LOGIN_STATE_CHANGED,{eventType:"sign_in"}),null===(n=this.config.eventBus)||void 0===n||n.fire(d.AUTH_STATE_CHANGED,{event:f.SIGNED_IN}),[2,o]}}))}))},t.prototype.setAccessKey=function(){var e,t;return Ke(this,void 0,void 0,(function(){var r,n;return Je(this,(function(o){if(r="",n="",this.config.accessKey?(r=this.config.accessKey,n="accessKey"):(null===(e=this.config.auth)||void 0===e?void 0:e.secretId)&&(null===(t=this.config.auth)||void 0===t?void 0:t.secretKey)&&(r="",n=p),!n)return[2];try{this.oauthInstance.oauth2client.setAccessKeyCredentials({access_token:r,token_type:"Bearer",scope:n,expires_at:new Date(+new Date+ +new Date),expires_in:+new Date+ +new Date})}catch(e){console.warn("accessKey error: ",e)}return[2]}))}))},t.prototype.formatPhone=function(e){return!/\s+/.test(e)&&/^\+\d{1,3}\d+/.test(e)?e.replace(/^(\+\d{1,2})(\d+)$/,"$1 $2"):/^\+\d{1,3}\s+/.test(e)?e:"+86 ".concat(e)},t.prototype.notifyListeners=function(e,t,r){this.listeners.forEach((function(n){n.forEach((function(n){try{n(e,t,r)}catch(e){console.error("Error in auth state change callback:",e)}}))}))},t.prototype.setupListeners=function(){var e,t=this;null===(e=this.config.eventBus)||void 0===e||e.on(d.AUTH_STATE_CHANGED,(function(e){return Ke(t,void 0,void 0,(function(){var t,r,n,o,i;return Je(this,(function(s){switch(s.label){case 0:return t=null===(o=null==e?void 0:e.data)||void 0===o?void 0:o.event,r=null===(i=null==e?void 0:e.data)||void 0===i?void 0:i.info,[4,this.getSession()];case 1:return n=s.sent().data.session,this.notifyListeners(t,n,r),[2]}}))}))}))},t.prototype.convertToUser=function(e){var t,r,n,o,i;if(!e)return null;var s=(null==e?void 0:e.email)||"",a=(null==e?void 0:e.phone_number)||"",u=(null==e?void 0:e.sub)||(null==e?void 0:e.uid)||"";return{id:u,aud:"authenticated",role:null===(r=null===(t=e.groups)||void 0===t?void 0:t.map)||void 0===r?void 0:r.call(t,(function(e){return"string"==typeof e?e:e.id})),email:s||"",email_confirmed_at:(null==e||e.email_verified,e.created_at),phone:a,phone_confirmed_at:a?e.created_at:void 0,confirmed_at:e.created_at,last_sign_in_at:e.last_sign_in_at,app_metadata:{provider:(null===(n=e.loginType)||void 0===n?void 0:n.toLowerCase())||"cloudbase",providers:[(null===(o=e.loginType)||void 0===o?void 0:o.toLowerCase())||"cloudbase"]},user_metadata:{name:null==e?void 0:e.name,picture:null==e?void 0:e.picture,username:null==e?void 0:e.username,gender:null==e?void 0:e.gender,locale:null==e?void 0:e.locale,uid:e.uid,nickName:e.nickName||(null==e?void 0:e.name),avatarUrl:e.avatarUrl||e.picture,location:e.location,hasPassword:e.hasPassword},identities:(null===(i=null==e?void 0:e.providers)||void 0===i?void 0:i.map((function(t){return{id:t.id||"",identity_id:t.id||"",user_id:u,identity_data:{provider_id:t.id,provider_user_id:t.provider_user_id,name:t.name},provider:t.id||"cloudbase",created_at:e.created_at,updated_at:e.updated_at,last_sign_in_at:e.last_sign_in_at}})))||[],created_at:e.created_at,updated_at:e.updated_at,is_anonymous:"anonymous"===e.name}},t.prototype.validateParams=function(e,t){for(var r=0,n=Object.entries(t);r<n.length;r++){var o=n[r],i=o[0],s=o[1];if(s.required&&(void 0===(null==e?void 0:e[i])||null===(null==e?void 0:e[i])||""===(null==e?void 0:e[i])))throw new ce({message:s.message})}},t.prototype.validateAtLeastOne=function(e,t,r){if(!t.some((function(t){return t.some((function(t){return void 0!==(null==e?void 0:e[t])&&null!==(null==e?void 0:e[t])&&""!==(null==e?void 0:e[t])}))})))throw new ce({message:r})},t.prototype.init=function(){var e;return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.oauthInstance.oauth2client.localCredentials.getCredentials()];case 1:return t.sent()&&(null===(e=this.config.eventBus)||void 0===e||e.fire(d.AUTH_STATE_CHANGED,{event:f.INITIAL_SESSION})),[3,3];case 2:return t.sent(),[3,3];case 3:return[2,{error:null}]}}))}))},Ge([(0,Te.catchErrorsDecorator)({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[Object]),ze("design:returntype",Promise)],t.prototype,"bindPhoneNumber",null),Ge([(0,Te.catchErrorsDecorator)({title:"解除三方绑定失败",messages:["请确认以下各项:"," 1 - 调用 auth().unbindProvider() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[Object]),ze("design:returntype",Promise)],t.prototype,"unbindProvider",null),Ge([(0,Te.catchErrorsDecorator)({title:"绑定邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[Object]),ze("design:returntype",void 0)],t.prototype,"bindEmail",null),Ge([(0,Te.catchErrorsDecorator)({title:"验证码验证失败",messages:["请确认以下各项:"," 1 - 调用 auth().verify() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[Object]),ze("design:returntype",Promise)],t.prototype,"verify",null),Ge([(0,Te.catchErrorsDecorator)({title:"获取验证码失败",messages:["请确认以下各项:"," 1 - 调用 auth().getVerification() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[Object,Object]),ze("design:returntype",Promise)],t.prototype,"getVerification",null),Ge([(0,Te.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrentUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[]),ze("design:returntype",Promise)],t.prototype,"getCurrentUser",null),Ge([(0,Te.catchErrorsDecorator)({title:"小程序匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymouslyInWx() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[Object]),ze("design:returntype",Promise)],t.prototype,"signInAnonymouslyInWx",null),Ge([(0,Te.catchErrorsDecorator)({title:"小程序绑定OpenID失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序openId静默登录"," 2 - 调用 auth().bindOpenId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[]),ze("design:returntype",Promise)],t.prototype,"bindOpenId",null),Ge([(0,Te.catchErrorsDecorator)({title:"小程序unionId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序unionId静默登录"," 2 - 调用 auth().signInWithUnionId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[]),ze("design:returntype",Promise)],t.prototype,"signInWithUnionId",null),Ge([(0,Te.catchErrorsDecorator)({title:"短信验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序短信验证码登陆"," 2 - 调用 auth().signInWithSms() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[Object]),ze("design:returntype",Promise)],t.prototype,"signInWithSms",null),Ge([(0,Te.catchErrorsDecorator)({title:"邮箱验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了邮箱登陆"," 2 - 调用 auth().signInWithEmail() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[Object]),ze("design:returntype",Promise)],t.prototype,"signInWithEmail",null),Ge([(0,Te.catchErrorsDecorator)({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[String]),ze("design:returntype",Promise)],t.prototype,"isUsernameRegistered",null),Ge([(0,Te.catchErrorsDecorator)({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[]),ze("design:returntype",Promise)],t.prototype,"getLoginState",null),Ge([(0,Te.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[]),ze("design:returntype",Promise)],t.prototype,"getUserInfo",null),Ge([(0,Te.catchErrorsDecorator)({title:"获取微搭插件用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getWedaUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[]),ze("design:returntype",Promise)],t.prototype,"getWedaUserInfo",null),Ge([(0,Te.catchErrorsDecorator)({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindWithProvider() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[Object]),ze("design:returntype",Promise)],t.prototype,"bindWithProvider",null),Ge([(0,Te.catchErrorsDecorator)({title:"获取身份源类型",messages:["请确认以下各项:"," 1 - 调用 auth().getProviderSubType() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[]),ze("design:returntype",Promise)],t.prototype,"getProviderSubType",null),t}(Ve);function tt(e,t){var r,n,o,i,s=this,a=e.region,c=void 0===a?"ap-shanghai":a,l=e.i18n,p=e.accessKey,v=e.useWxCloud,y=(null==t?void 0:t.platform)||Pe.useDefaultAdapter.bind(t)(),m=y.runtime,g=y.adapter,b=t||{},w=b.env,_=b.clientId,S=b.debug,E=b.cache,I=b.app,O=(t||{}).apiOrigin;O||(O="https://".concat(w,".").concat(c,".tcb-api.tencentcloudapi.com"));var T={env:w,clientId:_,i18n:l,accessKey:p,useWxCloud:v,eventBus:new W.CloudbaseEventEmitter},A=new Se(De($e($e({},T),{apiOrigin:O,apiPath:(null==e?void 0:e.apiPath)||u,storage:null==e?void 0:e.storage,baseRequest:null==e?void 0:e.baseRequest,request:null==e?void 0:e.request,anonymousSignInFunc:null==e?void 0:e.anonymousSignInFunc,captchaOptions:null==e?void 0:e.captchaOptions,wxCloud:null==e?void 0:e.wxCloud,adapter:g,onCredentialsError:Qe(T.eventBus),headers:$e({"X-SDK-Version":"@cloudbase/js-sdk/".concat(e.sdkVersion)},e.headers||{}),detectSessionInUrl:e.detectSessionInUrl,debug:S,auth:null===(n=null===(r=t.app)||void 0===r?void 0:r.config)||void 0===n?void 0:n.auth}))),R=new et($e($e({},T),{region:c,persistence:e.persistence,debug:S,cache:E||new Ae.CloudbaseCache({persistence:e.persistence,keys:{userInfoKey:"user_info_".concat(w)},platformInfo:y}),runtime:m||"web",_fromApp:I,oauthInstance:A,auth:null===(i=null===(o=t.app)||void 0===o?void 0:o.config)||void 0===i?void 0:i.auth}));return A.initializeSession((function(e,t){return Ke(s,void 0,void 0,(function(){return Je(this,(function(r){return e?(e.type===h.SIGN_IN?t?T.eventBus.fire(d.AUTH_STATE_CHANGED,{event:f.SIGNED_IN,info:$e($e({},e),{error:t})}):e.user&&R.createLoginState({},{userInfo:e.user}):e.type===h.BIND_IDENTITY&&T.eventBus.fire(d.AUTH_STATE_CHANGED,{event:f.BIND_IDENTITY,info:$e($e({},e),{error:t})}),[2]):[2]}))}))})),{authInstance:R,oauthInstance:A}}var rt="auth";function nt(e,t){for(var r=[],n=0;n<=e.length;n++)r[n]=[n];for(var o=0;o<=t.length;o++)r[0][o]=o;for(n=1;n<=e.length;n++)for(o=1;o<=t.length;o++){var i=e[n-1].toLowerCase()===t[o-1].toLowerCase()?0:1;r[n][o]=Math.min(r[n-1][o]+1,r[n][o-1]+1,r[n-1][o-1]+i)}return r[e.length][t.length]}var ot={name:"auth",namespace:rt,entity:function(e){var t=function(e){var t;if(this.authInstance&&!e)return this.authInstance;e=e||{region:"",persistence:"local",apiPath:u};var r=this.platform.adapter,n=e.persistence||r.primaryStorage;n&&n!==this.config.persistence&&this.updateConfig({persistence:n});var o=tt($e($e({wxCloud:this.config.wxCloud,storage:this.config.storage},e),{persistence:this.config.persistence,i18n:this.config.i18n,accessKey:this.config.accessKey,useWxCloud:this.config.useWxCloud,sdkVersion:this.version,detectSessionInUrl:null===(t=this.config.auth)||void 0===t?void 0:t.detectSessionInUrl}),{env:this.config.env,clientId:this.config.clientId,apiOrigin:this.request.getBaseEndPoint(this.config.endPointMode||"CLOUD_API"),platform:this.platform,cache:this.cache,app:this,debug:this.config.debug}),i=o.authInstance,s=o.oauthInstance;return this.oauthInstance=s,this.authInstance=i,this.authInstance},r=t.call(this,e);Object.assign(t,r),Object.setPrototypeOf(t,Object.getPrototypeOf(r));var n="undefined"!=typeof Proxy?new Proxy(t,{get:function(e,t,r){var n=Reflect.get(e,t,r);if(void 0!==n||"string"!=typeof t)return n;var o=function(e,t){for(var r=null,n=1/0,o=0,i=t;o<i.length;o++){var s=i[o];if(!s.startsWith("_")&&"constructor"!==s){var a=nt(e,s);a<n&&(n=a,r=s)}}return r}(t,Object.getOwnPropertyNames(Object.getPrototypeOf(e)).concat(Object.keys(e)).filter((function(t){return"function"==typeof e[t]})));return o&&console.warn("[CloudBase Auth] auth.".concat(t," is not a function. Did you mean: auth.").concat(o,"() ?")),n}}):t;return this[rt]=n,n}};try{cloudbase.registerComponent(ot)}catch(e){}function it(e){try{e.registerComponent(ot)}catch(e){console.warn(e)}}},5348:function(e,t,r){"use strict";r.r(t),r.d(t,{registerDatabase:function(){return Yr}});var n,o,i={};r.r(i),r.d(i,{LineString:function(){return H},MultiLineString:function(){return J},MultiPoint:function(){return z},MultiPolygon:function(){return Q},Point:function(){return oe},Polygon:function(){return G}}),function(e){e.DocIDError="文档ID不合法",e.CollNameError="集合名称不合法",e.OpStrError="操作符不合法",e.DirectionError="排序字符不合法",e.IntergerError="must be integer",e.QueryParamTypeError="查询参数必须为对象",e.QueryParamValueError="查询参数对象值不能均为undefined"}(o||(o={}));var s,a,u="Object",c="GeoPoint",l="GeoLineString",f="GeoPolygon",d="GeoMultiPoint",h="GeoMultiLineString",p="GeoMultiPolygon",v="Date",y="ServerDate",m=["desc","asc"],g=["<","<=","==",">=",">"];!function(e){e.lt="<",e.gt=">",e.lte="<=",e.gte=">=",e.eq="=="}(s||(s={})),(n={})[s.eq]="$eq",n[s.lt]="$lt",n[s.lte]="$lte",n[s.gt]="$gt",n[s.gte]="$gte",function(e){e.WHERE="WHERE",e.DOC="DOC"}(a||(a={}));var b,w=(b=function(e,t){return b=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},b(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}b(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),_=[],S={},E=function(e){function t(t,r){if(r!==S)throw new TypeError("InternalSymbol cannot be constructed with new operator");return e.call(this,t)||this}return w(t,e),t.for=function(e){for(var r=0,n=_.length;r<n;r++)if(_[r].target===e)return _[r].instance;var o=new t(e,S);return _.push({target:e,instance:o}),o},t}((function(e){Object.defineProperties(this,{target:{enumerable:!1,writable:!1,configurable:!1,value:e}})})),I=E,O=I.for("UNSET_FIELD_NAME"),T=I.for("UPDATE_COMMAND"),A=I.for("QUERY_COMMAND"),R=I.for("LOGIC_COMMAND"),P=I.for("GEO_POINT"),C=I.for("SYMBOL_GEO_LINE_STRING"),N=I.for("SYMBOL_GEO_POLYGON"),x=I.for("SYMBOL_GEO_MULTI_POINT"),L=I.for("SYMBOL_GEO_MULTI_LINE_STRING"),U=I.for("SYMBOL_GEO_MULTI_POLYGON"),k=I.for("SERVER_DATE"),D=I.for("REGEXP"),j=function(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()},q=function(e){return"object"===j(e)},M=function(e){return"number"===j(e)},B=function(e){return Array.isArray(e)},W=function(e){return"date"===j(e)},F=function(e){return"regexp"===j(e)},V=function(e){return e&&e._internalType instanceof E},H=function(){function e(e){if(!B(e))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof e));if(e.length<2)throw new Error('"points" must contain 2 points at least');e.forEach((function(e){if(!(e instanceof oe))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof e,"[]"))})),this.points=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"LineString",coordinates:this.points.map((function(e){return e.toJSON().coordinates}))},t},e.prototype.toJSON=function(){return{type:"LineString",coordinates:this.points.map((function(e){return e.toJSON().coordinates}))}},e.validate=function(e){var t,r;if("LineString"!==e.type||!B(e.coordinates))return!1;try{for(var n=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(e.coordinates),o=n.next();!o.done;o=n.next()){var i=o.value;if(!M(i[0])||!M(i[1]))return!1}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}return!0},e.isClosed=function(e){var t=e.points[0],r=e.points[e.points.length-1];if(t.latitude===r.latitude&&t.longitude===r.longitude)return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return C},enumerable:!1,configurable:!0}),e}(),$=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},G=function(){function e(e){if(!B(e))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof e));if(0===e.length)throw new Error("Polygon must contain 1 linestring at least");e.forEach((function(e){if(!(e instanceof H))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof e,"[]"));if(!H.isClosed(e))throw new Error("LineString ".concat(e.points.map((function(e){return e.toReadableString()}))," is not a closed cycle"))})),this.lines=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"Polygon",coordinates:this.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))},t},e.prototype.toJSON=function(){return{type:"Polygon",coordinates:this.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))}},e.validate=function(e){var t,r,n,o;if("Polygon"!==e.type||!B(e.coordinates))return!1;try{for(var i=$(e.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,$(a)),c=u.next();!c.done;c=u.next()){var l=c.value;if(!M(l[0])||!M(l[1]))return!1}}catch(e){n={error:e}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}finally{if(n)throw n.error}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}return!0},e.isCloseLineString=function(e){var t=e[0],r=e[e.length-1];return t[0]===r[0]&&t[1]===r[1]},Object.defineProperty(e.prototype,"_internalType",{get:function(){return U},enumerable:!1,configurable:!0}),e}(),z=function(){function e(e){if(!B(e))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof e));if(0===e.length)throw new Error('"points" must contain 1 point at least');e.forEach((function(e){if(!(e instanceof oe))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof e,"[]"))})),this.points=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"MultiPoint",coordinates:this.points.map((function(e){return e.toJSON().coordinates}))},t},e.prototype.toJSON=function(){return{type:"MultiPoint",coordinates:this.points.map((function(e){return e.toJSON().coordinates}))}},e.validate=function(e){var t,r;if("MultiPoint"!==e.type||!B(e.coordinates))return!1;try{for(var n=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(e.coordinates),o=n.next();!o.done;o=n.next()){var i=o.value;if(!M(i[0])||!M(i[1]))return!1}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return x},enumerable:!1,configurable:!0}),e}(),K=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},J=function(){function e(e){if(!B(e))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof e));if(0===e.length)throw new Error("Polygon must contain 1 linestring at least");e.forEach((function(e){if(!(e instanceof H))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof e,"[]"))})),this.lines=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"MultiLineString",coordinates:this.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))},t},e.prototype.toJSON=function(){return{type:"MultiLineString",coordinates:this.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))}},e.validate=function(e){var t,r,n,o;if("MultiLineString"!==e.type||!B(e.coordinates))return!1;try{for(var i=K(e.coordinates),s=i.next();!s.done;s=i.next()){var a=s.value;try{for(var u=(n=void 0,K(a)),c=u.next();!c.done;c=u.next()){var l=c.value;if(!M(l[0])||!M(l[1]))return!1}}catch(e){n={error:e}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}finally{if(n)throw n.error}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return L},enumerable:!1,configurable:!0}),e}(),Y=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Q=function(){function e(e){var t,r;if(!B(e))throw new TypeError('"polygons" must be of type Polygon[]. Received type '.concat(typeof e));if(0===e.length)throw new Error("MultiPolygon must contain 1 polygon at least");try{for(var n=Y(e),o=n.next();!o.done;o=n.next()){var i=o.value;if(!(i instanceof G))throw new TypeError('"polygon" must be of type Polygon[]. Received type '.concat(typeof i,"[]"))}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}this.polygons=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"MultiPolygon",coordinates:this.polygons.map((function(e){return e.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))}))},t},e.prototype.toJSON=function(){return{type:"MultiPolygon",coordinates:this.polygons.map((function(e){return e.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))}))}},e.validate=function(e){var t,r,n,o,i,s;if("MultiPolygon"!==e.type||!B(e.coordinates))return!1;try{for(var a=Y(e.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 d=f.value;try{for(var h=(i=void 0,Y(d)),p=h.next();!p.done;p=h.next()){var v=p.value;if(!M(v[0])||!M(v[1]))return!1}}catch(e){i={error:e}}finally{try{p&&!p.done&&(s=h.return)&&s.call(h)}finally{if(i)throw i.error}}}}catch(e){n={error:e}}finally{try{f&&!f.done&&(o=l.return)&&o.call(l)}finally{if(n)throw n.error}}}}catch(e){t={error:e}}finally{try{u&&!u.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return N},enumerable:!1,configurable:!0}),e}(),Z=function(){function e(e){var t=(void 0===e?{}:e).offset,r=void 0===t?0:t;this.offset=r}return Object.defineProperty(e.prototype,"_internalType",{get:function(){return k},enumerable:!1,configurable:!0}),e.prototype.parse=function(){return{$date:{offset:this.offset}}},e}();function X(e){return new Z(e)}var ee,te=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s},re=function(){function e(){}return e.formatResDocumentData=function(t){return t.map((function(t){return e.formatField(t)}))},e.formatField=function(t){var r=Object.keys(t),n={};return Array.isArray(t)&&(n=[]),r.forEach((function(r){var o,i=t[r];switch(e.whichType(i)){case c:o=new oe(i.coordinates[0],i.coordinates[1]);break;case l:o=new H(i.coordinates.map((function(e){return new oe(e[0],e[1])})));break;case f:o=new G(i.coordinates.map((function(e){return new H(e.map((function(e){var t=te(e,2),r=t[0],n=t[1];return new oe(r,n)})))})));break;case d:o=new z(i.coordinates.map((function(e){return new oe(e[0],e[1])})));break;case h:o=new J(i.coordinates.map((function(e){return new H(e.map((function(e){var t=te(e,2),r=t[0],n=t[1];return new oe(r,n)})))})));break;case p:o=new Q(i.coordinates.map((function(e){return new G(e.map((function(e){return new H(e.map((function(e){var t=te(e,2),r=t[0],n=t[1];return new oe(r,n)})))})))})));break;case v:o=new Date(1e3*i.$timestamp);break;case u:case"Array":o=e.formatField(i);break;case y:o=new Date(i.$date);break;default:o=i}Array.isArray(n)?n.push(o):n[r]=o})),n},e.whichType=function(e){var t=Object.prototype.toString.call(e).slice(8,-1);if(t===v)return"BsonDate";if(t===u){if(e instanceof oe)return c;if(e instanceof Date)return v;if(e instanceof Z)return y;e.$timestamp?t=v:e.$date?t=y:oe.validate(e)?t=c:H.validate(e)?t=l:G.validate(e)?t=f:z.validate(e)?t=d:J.validate(e)?t=h:Q.validate(e)&&(t=p)}return t},e.generateDocId=function(){for(var e="",t=0;t<24;t++)e+="ABCDEFabcdef0123456789".charAt(Math.floor(22*Math.random()));return e},e}(),ne=function(){function e(){}return e.isGeopoint=function(e,t){if("Number"!==re.whichType(t))throw new Error("Geo Point must be number type");var r=Math.abs(t);if("latitude"===e&&r>90)throw new Error("latitude should be a number ranges from -90 to 90");if("longitude"===e&&r>180)throw new Error("longitude should be a number ranges from -180 to 180");return!0},e.isInteger=function(e,t){if(!Number.isInteger(t))throw new Error(e+o.IntergerError);return!0},e.isFieldOrder=function(e){if(-1===m.indexOf(e))throw new Error(o.DirectionError);return!0},e.isFieldPath=function(e){if(!/^[a-zA-Z0-9-_\.]/.test(e))throw new Error;return!0},e.isOperator=function(e){if(-1===g.indexOf(e))throw new Error(o.OpStrError);return!0},e.isCollName=function(e){if(!/^[a-zA-Z0-9]([a-zA-Z0-9-_]){1,32}$/.test(e))throw new Error(o.CollNameError);return!0},e.isDocID=function(e){if(!/^([a-fA-F0-9]){24}$/.test(e))throw new Error(o.DocIDError);return!0},e}(),oe=function(){function e(e,t){ne.isGeopoint("longitude",e),ne.isGeopoint("latitude",t),this.longitude=e,this.latitude=t}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"Point",coordinates:[this.longitude,this.latitude]},t},e.prototype.toJSON=function(){return{type:"Point",coordinates:[this.longitude,this.latitude]}},e.prototype.toReadableString=function(){return"[".concat(this.longitude,",").concat(this.latitude,"]")},e.validate=function(e){return"Point"===e.type&&B(e.coordinates)&&ne.isGeopoint("longitude",e.coordinates[0])&&ne.isGeopoint("latitude",e.coordinates[1])},Object.defineProperty(e.prototype,"_internalType",{get:function(){return P},enumerable:!1,configurable:!0}),e}(),ie=function(){var e=function(){};if(!Promise){e.promise={};var t=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}var r=new Promise((function(t,r){e=function(e,n){return e?r(e):t(n)}}));return e.promise=r,e};!function(e){e.SET="set",e.REMOVE="remove",e.INC="inc",e.MUL="mul",e.PUSH="push",e.PULL="pull",e.PULL_ALL="pullAll",e.POP="pop",e.SHIFT="shift",e.UNSHIFT="unshift",e.ADD_TO_SET="addToSet",e.BIT="bit",e.RENAME="rename",e.MAX="max",e.MIN="min"}(ee||(ee={}));var se,ae=function(){function e(e,t,r){this._internalType=T,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=e,this.operands=t,this.fieldName=r||O}return e.prototype._setFieldName=function(t){return new e(this.operator,this.operands,t)},e}();function ue(e){return e&&e instanceof ae&&e._internalType===T}!function(e){e.AND="and",e.OR="or",e.NOT="not",e.NOR="nor"}(se||(se={}));var ce=function(){function e(e,t,r){if(this._internalType=R,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=e,this.operands=t,this.fieldName=r||O,this.fieldName!==O)if(Array.isArray(t)){t=t.slice(),this.operands=t;for(var n=0,o=t.length;n<o;n++)(le(i=t[n])||pe(i))&&(t[n]=i._setFieldName(this.fieldName))}else{var i;(le(i=t)||pe(i))&&(t=i._setFieldName(this.fieldName))}}return e.prototype._setFieldName=function(t){var r=this.operands.map((function(r){return r instanceof e?r._setFieldName(t):r}));return new e(this.operator,r,t)},e.prototype.and=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return n.unshift(this),new e(se.AND,n,this.fieldName)},e.prototype.or=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return n.unshift(this),new e(se.OR,n,this.fieldName)},e}();function le(e){return e&&e instanceof ce&&e._internalType===R}var fe,de=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};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)}}();!function(e){e.EQ="eq",e.NEQ="neq",e.GT="gt",e.GTE="gte",e.LT="lt",e.LTE="lte",e.IN="in",e.NIN="nin",e.ALL="all",e.ELEM_MATCH="elemMatch",e.EXISTS="exists",e.SIZE="size",e.MOD="mod",e.GEO_NEAR="geoNear",e.GEO_WITHIN="geoWithin",e.GEO_INTERSECTS="geoIntersects"}(fe||(fe={}));var he=function(e){function t(t,r,n){var o=e.call(this,t,r,n)||this;return o.operator=t,o._internalType=A,o}return de(t,e),t.prototype.toJSON=function(){var e,t;switch(this.operator){case fe.IN:case fe.NIN:return(e={})["$"+this.operator]=this.operands,e;default:return(t={})["$"+this.operator]=this.operands[0],t}},t.prototype._setFieldName=function(e){return new t(this.operator,this.operands,e)},t.prototype.eq=function(e){var r=new t(fe.EQ,[e],this.fieldName);return this.and(r)},t.prototype.neq=function(e){var r=new t(fe.NEQ,[e],this.fieldName);return this.and(r)},t.prototype.gt=function(e){var r=new t(fe.GT,[e],this.fieldName);return this.and(r)},t.prototype.gte=function(e){var r=new t(fe.GTE,[e],this.fieldName);return this.and(r)},t.prototype.lt=function(e){var r=new t(fe.LT,[e],this.fieldName);return this.and(r)},t.prototype.lte=function(e){var r=new t(fe.LTE,[e],this.fieldName);return this.and(r)},t.prototype.in=function(e){var r=new t(fe.IN,e,this.fieldName);return this.and(r)},t.prototype.nin=function(e){var r=new t(fe.NIN,e,this.fieldName);return this.and(r)},t.prototype.geoNear=function(e){if(!(e.geometry instanceof oe))throw new TypeError('"geometry" must be of type Point. Received type '.concat(typeof e.geometry));if(void 0!==e.maxDistance&&!M(e.maxDistance))throw new TypeError('"maxDistance" must be of type Number. Received type '.concat(typeof e.maxDistance));if(void 0!==e.minDistance&&!M(e.minDistance))throw new TypeError('"minDistance" must be of type Number. Received type '.concat(typeof e.minDistance));var r=new t(fe.GEO_NEAR,[e],this.fieldName);return this.and(r)},t.prototype.geoWithin=function(e){if(!(e.geometry instanceof Q||e.geometry instanceof G))throw new TypeError('"geometry" must be of type Polygon or MultiPolygon. Received type '.concat(typeof e.geometry));var r=new t(fe.GEO_WITHIN,[e],this.fieldName);return this.and(r)},t.prototype.geoIntersects=function(e){if(!(e.geometry instanceof oe||e.geometry instanceof H||e.geometry instanceof G||e.geometry instanceof z||e.geometry instanceof J||e.geometry instanceof Q))throw new TypeError('"geometry" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type '.concat(typeof e.geometry));var r=new t(fe.GEO_INTERSECTS,[e],this.fieldName);return this.and(r)},t}(ce);function pe(e){return e&&e instanceof he&&e._internalType===A}function ve(e){return pe(e)}var ye={};for(var me in fe)ye[me]="$"+me;for(var me in se)ye[me]="$"+me;for(var me in ee)ye[me]="$"+me;function ge(e){return ye[e]||"$"+e}ye[fe.NEQ]="$ne",ye[ee.REMOVE]="$unset",ye[ee.SHIFT]="$pop",ye[ee.UNSHIFT]="$push";var be=function(){return be=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},be.apply(this,arguments)},we=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s},_e=function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};function Se(e){return Ee(e,[e])}function Ee(e,t){if(!V(e)){if(W(e))return{$date:+e};if(F(e))return{$regex:e.source,$options:e.flags};if(B(e))return e.map((function(e){if(t.indexOf(e)>-1)throw new Error("Cannot convert circular structure to JSON");return Ee(e,_e(_e([],we(t),!1),[e],!1))}));if(q(e)){var r=be({},e);for(var n in r){if(t.indexOf(r[n])>-1)throw new Error("Cannot convert circular structure to JSON");r[n]=Ee(r[n],_e(_e([],we(t),!1),[r[n]],!1))}return r}return e}switch(e._internalType){case P:return e.toJSON();case k:case D:return e.parse();default:return e.toJSON?e.toJSON():e}}var Ie=function(){return Ie=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Ie.apply(this,arguments)},Oe=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s},Te=function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};function Ae(e,t,r,n){var o=Ie({},e);for(var i in e)if(!/^\$/.test(i)){var s=e[i];if(s&&q(s)&&!t(s)){if(n.indexOf(s)>-1)throw new Error("Cannot convert circular structure to JSON");var a=Ae(s,t,Te(Te([],Oe(r),!1),[i],!1),Te(Te([],Oe(n),!1),[s],!1));o[i]=a;var u=!1;for(var c in a)/^\$/.test(c)?u=!0:(o["".concat(i,".").concat(c)]=a[c],delete o[i][c]);u||delete o[i]}}return o}function Re(e){return Ae(e,Ce,[],[e])}function Pe(e,t,r){for(var n in t[r]||delete e[r],t)e[n]?B(e[n])?e[n].push(t[n]):q(e[n])?q(t[n])?Object.assign(e[n],t[n]):(console.warn("unmergable condition, query is object but condition is ".concat(j(t),", can only overwrite"),t,r),e[n]=t[n]):(console.warn("to-merge query is of type ".concat(j(e),", can only overwrite"),e,t,r),e[n]=t[n]):e[n]=t[n]}function Ce(e){return V(e)||W(e)||F(e)}function Ne(e){return Se(e)}var xe=function(){function e(){}return e.encode=function(t){return(new e).encodeUpdate(t)},e.prototype.encodeUpdate=function(e){return ue(e)?this.encodeUpdateCommand(e):"object"===j(e)?this.encodeUpdateObject(e):e},e.prototype.encodeUpdateCommand=function(e){if(e.fieldName===O)throw new Error("Cannot encode a comparison command with unset field name");switch(e.operator){case ee.PUSH:case ee.PULL:case ee.PULL_ALL:case ee.POP:case ee.SHIFT:case ee.UNSHIFT:case ee.ADD_TO_SET:return this.encodeArrayUpdateCommand(e);default:return this.encodeFieldUpdateCommand(e)}},e.prototype.encodeFieldUpdateCommand=function(e){var t,r,n,o,i=ge(e.operator);return e.operator===ee.REMOVE?((t={})[i]=((r={})[e.fieldName]="",r),t):((n={})[i]=((o={})[e.fieldName]=e.operands[0],o),n)},e.prototype.encodeArrayUpdateCommand=function(e){var t,r,n,o,i,s,a,u,c,l,f=ge(e.operator);switch(e.operator){case ee.PUSH:var d=void 0;return d=B(e.operands)?{$each:e.operands.map(Ne)}:e.operands,(t={})[f]=((r={})[e.fieldName]=d,r),t;case ee.UNSHIFT:return d={$each:e.operands.map(Ne),$position:0},(n={})[f]=((o={})[e.fieldName]=d,o),n;case ee.POP:return(i={})[f]=((s={})[e.fieldName]=1,s),i;case ee.SHIFT:return(a={})[f]=((u={})[e.fieldName]=-1,u),a;default:return(c={})[f]=((l={})[e.fieldName]=Ne(e.operands),l),c}},e.prototype.encodeUpdateObject=function(e){var t=Re(e);for(var r in t)if(!/^\$/.test(r)){var n=t[r];if(ue(n))t[r]=n._setFieldName(r),Pe(t,this.encodeUpdateCommand(t[r]),r);else{t[r]=n=Ne(n);var o=new ae(ee.SET,[n],r);Pe(t,this.encodeUpdateCommand(o),r)}}return t},e}(),Le={};function Ue(e){if(!Vr.wsClientClass)throw new Error("to use realtime you must import realtime module first");var t=e.config.env;return Le[t]||(Le[t]=new Vr.wsClientClass({context:{appConfig:{docSizeLimit:1e3,realtimePingInterval:1e4,realtimePongWaitTimeout:5e3,request:Vr.createRequest(e.config)}}})),Le[t]}var ke=function(){return ke=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},ke.apply(this,arguments)},De=function(){function e(e,t,r,n){void 0===n&&(n={});var o=this;this.watch=function(e){return Ue(o._db).watch(ke(ke({},e),{envId:o._db.config.env,collectionName:o._coll,query:JSON.stringify({_id:o.id})}))},this._db=e,this._coll=t,this.id=r,this.request=Vr.createRequest(this._db.config),this.projection=n}return e.prototype.create=function(e,t){t=t||ie();var r={collectionName:this._coll,data:Se(e)};return this.id&&(r._id=this.id),this.request.send("database.addDocument",r).then((function(e){e.code?t(0,e):t(0,{id:e.data._id,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},e.prototype.set=function(e,t){if(t=t||ie(),!this.id)return Promise.resolve({code:"INVALID_PARAM",message:"docId不能为空"});if(!e||"object"!=typeof e)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(e.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var r=!1,n=function(e){if("object"==typeof e)for(var t in e)e[t]instanceof ae?r=!0:"object"==typeof e[t]&&n(e[t])};if(n(e),r)return Promise.resolve({code:"DATABASE_REQUEST_FAILED",message:"update operator complicit"});var o={collectionName:this._coll,queryType:a.DOC,data:Se(e),multi:!1,merge:!1,upsert:!0};return this.id&&(o.query={_id:this.id}),this.request.send("database.updateDocument",o).then((function(e){e.code?t(0,e):t(0,{updated:e.data.updated,upsertedId:e.data.upserted_id,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},e.prototype.update=function(e,t){if(t=t||ie(),!e||"object"!=typeof e)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(e.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var r={_id:this.id},n={collectionName:this._coll,data:xe.encode(e),query:r,queryType:a.DOC,multi:!1,merge:!0,upsert:!1};return this.request.send("database.updateDocument",n).then((function(e){e.code?t(0,e):t(0,{updated:e.data.updated,upsertedId:e.data.upserted_id,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},e.prototype.remove=function(e){e=e||ie();var t={_id:this.id},r={collectionName:this._coll,query:t,queryType:a.DOC,multi:!1};return this.request.send("database.deleteDocument",r).then((function(t){t.code?e(0,t):e(0,{deleted:t.data.deleted,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},e.prototype.get=function(e){e=e||ie();var t={_id:this.id},r={collectionName:this._coll,query:t,queryType:a.DOC,multi:!1,projection:this.projection};return this.request.send("database.queryDocument",r).then((function(t){if(t.code)e(0,t);else{var r=re.formatResDocumentData(t.data.list);e(0,{data:r,requestId:t.requestId})}})).catch((function(t){e(t)})),e.promise},e.prototype.field=function(t){for(var r in t)t[r]?t[r]=1:t[r]=0;return new e(this._db,this._coll,this.id,t)},e}(),je=function(){function e(){}return e.encode=function(e){return(new qe).encodeQuery(e)},e}(),qe=function(){function e(){}return e.prototype.encodeQuery=function(e,t){var r;return Ce(e)?le(e)?this.encodeLogicCommand(e):pe(e)?this.encodeQueryCommand(e):((r={})[t]=this.encodeQueryObject(e),r):q(e)?this.encodeQueryObject(e):e},e.prototype.encodeRegExp=function(e){return{$regex:e.source,$options:e.flags}},e.prototype.encodeLogicCommand=function(e){var t,r,n,o,i,s,a,u=this;switch(e.operator){case se.NOR:case se.AND:case se.OR:var c=ge(e.operator),l=e.operands.map((function(t){return u.encodeQuery(t,e.fieldName)}));return(t={})[c]=l,t;case se.NOT:c=ge(e.operator);var f=e.operands[0];return F(f)?((r={})[e.fieldName]=((n={})[c]=this.encodeRegExp(f),n),r):(l=this.encodeQuery(f)[e.fieldName],(o={})[e.fieldName]=((i={})[c]=l,i),o);default:if(c=ge(e.operator),1===e.operands.length){var d=this.encodeQuery(e.operands[0]);return(s={})[c]=d,s}return l=e.operands.map(this.encodeQuery.bind(this)),(a={})[c]=l,a}},e.prototype.encodeQueryCommand=function(e){return ve(e),this.encodeComparisonCommand(e)},e.prototype.encodeComparisonCommand=function(e){var t,r,n,o,i,s,a,u,c;if(e.fieldName===O)throw new Error("Cannot encode a comparison command with unset field name");var l=ge(e.operator);switch(e.operator){case fe.EQ:case fe.NEQ:case fe.LT:case fe.LTE:case fe.GT:case fe.GTE:case fe.ELEM_MATCH:case fe.EXISTS:case fe.SIZE:case fe.MOD:return(t={})[e.fieldName]=((r={})[l]=Ne(e.operands[0]),r),t;case fe.IN:case fe.NIN:case fe.ALL:return(n={})[e.fieldName]=((o={})[l]=Ne(e.operands),o),n;case fe.GEO_NEAR:var f=e.operands[0];return(i={})[e.fieldName]={$nearSphere:{$geometry:f.geometry.toJSON(),$maxDistance:f.maxDistance,$minDistance:f.minDistance}},i;case fe.GEO_WITHIN:return f=e.operands[0],(s={})[e.fieldName]={$geoWithin:{$geometry:f.geometry.toJSON()}},s;case fe.GEO_INTERSECTS:return f=e.operands[0],(a={})[e.fieldName]={$geoIntersects:{$geometry:f.geometry.toJSON()}},a;default:return(u={})[e.fieldName]=((c={})[l]=Ne(e.operands[0]),c),u}},e.prototype.encodeQueryObject=function(e){var t=Re(e);for(var r in t){var n=t[r];if(le(n)){t[r]=n._setFieldName(r);var o=this.encodeLogicCommand(t[r]);this.mergeConditionAfterEncode(t,o,r)}else ve(n)?(t[r]=n._setFieldName(r),o=this.encodeComparisonCommand(t[r]),this.mergeConditionAfterEncode(t,o,r)):Ce(n)&&(t[r]=Ne(n))}return t},e.prototype.mergeConditionAfterEncode=function(e,t,r){for(var n in t[r]||delete e[r],t)e[n]?B(e[n])?e[n]=e[n].concat(t[n]):q(e[n])?q(t[n])?Object.assign(e,t):(console.warn("unmergable condition, query is object but condition is ".concat(j(t),", can only overwrite"),t,r),e[n]=t[n]):(console.warn("to-merge query is of type ".concat(j(e),", can only overwrite"),e,t,r),e[n]=t[n]):e[n]=t[n]},e}(),Me=function(){return Me=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Me.apply(this,arguments)},Be=function(){function e(e,t,r,n,o){var i=this;this.watch=function(e){return Ue(i._db).watch(Me(Me({},e),{envId:i._db.config.env,collectionName:i._coll,query:JSON.stringify(i._fieldFilters||{}),limit:i._queryOptions.limit,orderBy:i._fieldOrders?i._fieldOrders.reduce((function(e,t){return e[t.field]=t.direction,e}),{}):void 0}))},this._db=e,this._coll=t,this._fieldFilters=r,this._fieldOrders=n||[],this._queryOptions=o||{},this._request=Vr.createRequest(this._db.config)}return e.prototype.get=function(e){e=e||ie();var t=[];this._fieldOrders&&this._fieldOrders.forEach((function(e){t.push(e)}));var r={collectionName:this._coll,queryType:a.WHERE};return this._fieldFilters&&(r.query=this._fieldFilters),t.length>0&&(r.order=t),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(t){if(t.code)e(0,t);else{var r={data:re.formatResDocumentData(t.data.list),requestId:t.requestId};void 0!==t.total&&(r.total=t.total),void 0!==t.limit&&(r.limit=t.limit),void 0!==t.offset&&(r.offset=t.offset),e(0,r)}})).catch((function(t){e(t)})),e.promise},e.prototype.count=function(e){e=e||ie();var t={collectionName:this._coll,queryType:a.WHERE};return this._fieldFilters&&(t.query=this._fieldFilters),this._request.send("database.countDocument",t).then((function(t){t.code?e(0,t):e(0,{requestId:t.requestId,total:t.data.total})})).catch((function(t){e(t)})),e.promise},e.prototype.where=function(t){if("Object"!==Object.prototype.toString.call(t).slice(8,-1))throw Error(o.QueryParamTypeError);var r=Object.keys(t),n=r.some((function(e){return void 0!==t[e]}));if(r.length&&!n)throw Error(o.QueryParamValueError);return new e(this._db,this._coll,je.encode(t),this._fieldOrders,this._queryOptions)},e.prototype.orderBy=function(t,r){ne.isFieldPath(t),ne.isFieldOrder(r);var n={field:t,direction:r},o=this._fieldOrders.concat(n);return new e(this._db,this._coll,this._fieldFilters,o,this._queryOptions)},e.prototype.limit=function(t){ne.isInteger("limit",t);var r=Me({},this._queryOptions);return r.limit=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,r)},e.prototype.skip=function(t){ne.isInteger("offset",t);var r=Me({},this._queryOptions);return r.offset=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,r)},e.prototype.update=function(e,t){if(t=t||ie(),!e||"object"!=typeof e)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(e.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:xe.encode(e)};return this._request.send("database.updateDocument",r).then((function(e){e.code?t(0,e):t(0,{requestId:e.requestId,updated:e.data.updated,upsertId:e.data.upsert_id})})).catch((function(e){t(e)})),t.promise},e.prototype.field=function(t){for(var r in t)t[r]?"object"!=typeof t[r]&&(t[r]=1):t[r]=0;var n=Me({},this._queryOptions);return n.projection=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},e.prototype.remove=function(e){e=e||ie(),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 t={collectionName:this._coll,query:je.encode(this._fieldFilters),queryType:a.WHERE,multi:!0};return this._request.send("database.deleteDocument",t).then((function(t){t.code?e(0,t):e(0,{requestId:t.requestId,deleted:t.data.deleted})})).catch((function(t){e(t)})),e.promise},e}();const We=(()=>{const e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype),Symbol.toStringTag).get;return t=>e.call(t)})();function Fe(e){return"Uint8Array"===We(e)}function Ve(e){return"object"==typeof e&&null!=e&&Symbol.toStringTag in e&&"Map"===e[Symbol.toStringTag]}function He(e,t){return JSON.stringify(e,((e,t)=>"bigint"==typeof t?{$numberLong:`${t}`}:Ve(t)?Object.fromEntries(t):t))}const $e=7,Ge=Symbol.for("@@mdb.bson.version"),ze=2147483647,Ke=-2147483648,Je=Math.pow(2,63)-1,Ye=-Math.pow(2,63),Qe=Math.pow(2,53),Ze=-Math.pow(2,53);Object.freeze({double:1,string:2,object:3,array:4,binData:5,undefined:6,objectId:7,bool:8,date:9,null:10,regex:11,dbPointer:12,javascript:13,symbol:14,javascriptWithScope:15,int:16,timestamp:17,long:18,decimal:19,minKey:-1,maxKey:127});class Xe extends Error{get bsonError(){return!0}get name(){return"BSONError"}constructor(e,t){super(e,t)}static isBSONError(e){return null!=e&&"object"==typeof e&&"bsonError"in e&&!0===e.bsonError&&"name"in e&&"message"in e&&"stack"in e}}class et extends Xe{get name(){return"BSONVersionError"}constructor(){super(`Unsupported BSON version, bson types must be from bson ${$e}.x.x`)}}class tt extends Xe{get name(){return"BSONRuntimeError"}constructor(e){super(e)}}class rt extends Xe{get name(){return"BSONOffsetError"}offset;constructor(e,t,r){super(`${e}. offset: ${t}`,r),this.offset=t}}let nt,ot;function it(e,t,r,n){if(n){nt??=new TextDecoder("utf8",{fatal:!0});try{return nt.decode(e.subarray(t,r))}catch(e){throw new Xe("Invalid UTF-8 string in BSON document",{cause:e})}}return ot??=new TextDecoder("utf8",{fatal:!1}),ot.decode(e.subarray(t,r))}function st(e,t,r){if(0===e.length)return"";const n=r-t;if(0===n)return"";if(n>20)return null;if(1===n&&e[t]<128)return String.fromCharCode(e[t]);if(2===n&&e[t]<128&&e[t+1]<128)return String.fromCharCode(e[t])+String.fromCharCode(e[t+1]);if(3===n&&e[t]<128&&e[t+1]<128&&e[t+2]<128)return String.fromCharCode(e[t])+String.fromCharCode(e[t+1])+String.fromCharCode(e[t+2]);const o=[];for(let n=t;n<r;n++){const t=e[n];if(t>127)return null;o.push(t)}return String.fromCharCode(...o)}function at(e){return lt.fromNumberArray(Array.from({length:e},(()=>Math.floor(256*Math.random()))))}function ut(e){return crypto.getRandomValues(lt.allocate(e))}const ct=(()=>{const{crypto:e}=globalThis;return null!=e&&"function"==typeof e.getRandomValues?ut:at})(),lt={isUint8Array:Fe,toLocalBufferType(e){if(Buffer.isBuffer(e))return e;if(ArrayBuffer.isView(e))return Buffer.from(e.buffer,e.byteOffset,e.byteLength);const t=e?.[Symbol.toStringTag]??Object.prototype.toString.call(e);if("ArrayBuffer"===t||"SharedArrayBuffer"===t||"[object ArrayBuffer]"===t||"[object SharedArrayBuffer]"===t)return Buffer.from(e);throw new Xe("Cannot create Buffer from the passed potentialBuffer.")},allocate(e){return Buffer.alloc(e)},allocateUnsafe(e){return Buffer.allocUnsafe(e)},compare(e,t){return lt.toLocalBufferType(e).compare(t)},concat(e){return Buffer.concat(e)},equals(e,t){return lt.toLocalBufferType(e).equals(t)},fromNumberArray(e){return Buffer.from(e)},fromBase64(e){return Buffer.from(e,"base64")},fromUTF8(e){return Buffer.from(e,"utf8")},toBase64(e){return lt.toLocalBufferType(e).toString("base64")},fromISO88591(e){return Buffer.from(e,"binary")},toISO88591(e){return lt.toLocalBufferType(e).toString("binary")},fromHex(e){return Buffer.from(e,"hex")},toHex(e){return lt.toLocalBufferType(e).toString("hex")},toUTF8(e,t,r,n){const o=r-t<=20?st(e,t,r):null;if(null!=o)return o;const i=lt.toLocalBufferType(e).toString("utf8",t,r);if(n)for(let n=0;n<i.length;n++)if(65533===i.charCodeAt(n)){it(e,t,r,!0);break}return i},utf8ByteLength(e){return Buffer.byteLength(e,"utf8")},encodeUTF8Into(e,t,r){const n=function(e,t,r){if(0===t.length)return 0;if(t.length>25)return null;if(e.length-r<t.length)return null;for(let n=0,o=r;n<t.length;n++,o++){const r=t.charCodeAt(n);if(r>127)return null;e[o]=r}return t.length}(e,t,r);return null!=n?n:lt.toLocalBufferType(e).write(t,r,void 0,"utf8")},randomBytes:ct,swap32(e){return lt.toLocalBufferType(e).swap32()}};function ft(e){if(e<0)throw new RangeError(`The argument 'byteLength' is invalid. Received ${e}`);return pt.fromNumberArray(Array.from({length:e},(()=>Math.floor(256*Math.random()))))}const dt=(()=>{const{crypto:e}=globalThis;if(null!=e&&"function"==typeof e.getRandomValues)return t=>e.getRandomValues(pt.allocate(t));if(function(){const{navigator:e}=globalThis;return"object"==typeof e&&"ReactNative"===e.product}()){const{console:e}=globalThis;e?.warn?.("BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.")}return ft})(),ht=/(\d|[a-f])/i,pt={isUint8Array:Fe,toLocalBufferType(e){const t=e?.[Symbol.toStringTag]??Object.prototype.toString.call(e);if("Uint8Array"===t)return e;if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength));if("ArrayBuffer"===t||"SharedArrayBuffer"===t||"[object ArrayBuffer]"===t||"[object SharedArrayBuffer]"===t)return new Uint8Array(e);throw new Xe("Cannot make a Uint8Array from passed potentialBuffer.")},allocate(e){if("number"!=typeof e)throw new TypeError(`The "size" argument must be of type number. Received ${String(e)}`);return new Uint8Array(e)},allocateUnsafe(e){return pt.allocate(e)},compare(e,t){if(e===t)return 0;const r=Math.min(e.length,t.length);for(let n=0;n<r;n++){if(e[n]<t[n])return-1;if(e[n]>t[n])return 1}return e.length<t.length?-1:e.length>t.length?1:0},concat(e){if(0===e.length)return pt.allocate(0);let t=0;for(const r of e)t+=r.length;const r=pt.allocate(t);let n=0;for(const t of e)r.set(t,n),n+=t.length;return r},equals(e,t){if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0},fromNumberArray(e){return Uint8Array.from(e)},fromBase64(e){return Uint8Array.from(atob(e),(e=>e.charCodeAt(0)))},fromUTF8(e){return(new TextEncoder).encode(e)},toBase64(e){return btoa(pt.toISO88591(e))},fromISO88591(e){return Uint8Array.from(e,(e=>255&e.charCodeAt(0)))},toISO88591(e){return Array.from(Uint16Array.from(e),(e=>String.fromCharCode(e))).join("")},fromHex(e){const t=e.length%2==0?e:e.slice(0,e.length-1),r=[];for(let e=0;e<t.length;e+=2){const n=t[e],o=t[e+1];if(!ht.test(n))break;if(!ht.test(o))break;const i=Number.parseInt(`${n}${o}`,16);r.push(i)}return Uint8Array.from(r)},toHex(e){return Array.from(e,(e=>e.toString(16).padStart(2,"0"))).join("")},toUTF8(e,t,r,n){const o=r-t<=20?st(e,t,r):null;return null!=o?o:it(e,t,r,n)},utf8ByteLength(e){return(new TextEncoder).encode(e).byteLength},encodeUTF8Into(e,t,r){const n=(new TextEncoder).encode(t);return e.set(n,r),n.byteLength},randomBytes:dt,swap32(e){if(e.length%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e.length;t+=4){const r=e[t],n=e[t+1],o=e[t+2],i=e[t+3];e[t]=i,e[t+1]=o,e[t+2]=n,e[t+3]=r}return e}},vt="function"==typeof Buffer&&!0!==Buffer.prototype?._isBuffer?lt:pt,yt=Symbol.for("@@mdb.bson.type");class mt{get[yt](){return this._bsontype}get[Ge](){return $e}[Symbol.for("nodejs.util.inspect.custom")](e,t,r){return this.inspect(e,t,r)}}const gt=new Float64Array(1),bt=new Uint8Array(gt.buffer,0,8);gt[0]=-1;const wt=0===bt[7],_t={isBigEndian:wt,getNonnegativeInt32LE(e,t){if(e[t+3]>127)throw new RangeError(`Size cannot be negative at offset: ${t}`);return e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24},getInt32LE(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24},getUint32LE(e,t){return e[t]+256*e[t+1]+65536*e[t+2]+16777216*e[t+3]},getUint32BE(e,t){return e[t+3]+256*e[t+2]+65536*e[t+1]+16777216*e[t]},getBigInt64LE(e,t){return(BigInt(e[t+4]+256*e[t+5]+65536*e[t+6]+(e[t+7]<<24))<<32n)+BigInt(e[t]+256*e[t+1]+65536*e[t+2]+16777216*e[t+3])},getFloat64LE:wt?(e,t)=>(bt[7]=e[t],bt[6]=e[t+1],bt[5]=e[t+2],bt[4]=e[t+3],bt[3]=e[t+4],bt[2]=e[t+5],bt[1]=e[t+6],bt[0]=e[t+7],gt[0]):(e,t)=>(bt[0]=e[t],bt[1]=e[t+1],bt[2]=e[t+2],bt[3]=e[t+3],bt[4]=e[t+4],bt[5]=e[t+5],bt[6]=e[t+6],bt[7]=e[t+7],gt[0]),setInt32BE(e,t,r){return e[t+3]=r,r>>>=8,e[t+2]=r,r>>>=8,e[t+1]=r,r>>>=8,e[t]=r,4},setInt32LE(e,t,r){return e[t]=r,r>>>=8,e[t+1]=r,r>>>=8,e[t+2]=r,r>>>=8,e[t+3]=r,4},setBigInt64LE(e,t,r){const n=0xffffffffn;let o=Number(r&n);e[t]=o,o>>=8,e[t+1]=o,o>>=8,e[t+2]=o,o>>=8,e[t+3]=o;let i=Number(r>>32n&n);return e[t+4]=i,i>>=8,e[t+5]=i,i>>=8,e[t+6]=i,i>>=8,e[t+7]=i,8},setFloat64LE:wt?(e,t,r)=>(gt[0]=r,e[t]=bt[7],e[t+1]=bt[6],e[t+2]=bt[5],e[t+3]=bt[4],e[t+4]=bt[3],e[t+5]=bt[2],e[t+6]=bt[1],e[t+7]=bt[0],8):(e,t,r)=>(gt[0]=r,e[t]=bt[0],e[t+1]=bt[1],e[t+2]=bt[2],e[t+3]=bt[3],e[t+4]=bt[4],e[t+5]=bt[5],e[t+6]=bt[6],e[t+7]=bt[7],8)};class St extends mt{get _bsontype(){return"Binary"}static BSON_BINARY_SUBTYPE_DEFAULT=0;static BUFFER_SIZE=256;static SUBTYPE_DEFAULT=0;static SUBTYPE_FUNCTION=1;static SUBTYPE_BYTE_ARRAY=2;static SUBTYPE_UUID_OLD=3;static SUBTYPE_UUID=4;static SUBTYPE_MD5=5;static SUBTYPE_ENCRYPTED=6;static SUBTYPE_COLUMN=7;static SUBTYPE_SENSITIVE=8;static SUBTYPE_VECTOR=9;static SUBTYPE_USER_DEFINED=128;static VECTOR_TYPE=Object.freeze({Int8:3,Float32:39,PackedBit:16});buffer;sub_type;position;constructor(e,t){if(super(),null!=e&&"string"==typeof e&&!ArrayBuffer.isView(e)&&("object"!=typeof(r=e)||null==r||!(Symbol.toStringTag in r)||"ArrayBuffer"!==r[Symbol.toStringTag]&&"SharedArrayBuffer"!==r[Symbol.toStringTag])&&!Array.isArray(e))throw new Xe("Binary can only be constructed from Uint8Array or number[]");var r;this.sub_type=t??St.BSON_BINARY_SUBTYPE_DEFAULT,null==e?(this.buffer=vt.allocate(St.BUFFER_SIZE),this.position=0):(this.buffer=Array.isArray(e)?vt.fromNumberArray(e):vt.toLocalBufferType(e),this.position=this.buffer.byteLength)}put(e){if("string"==typeof e&&1!==e.length)throw new Xe("only accepts single character String");if("number"!=typeof e&&1!==e.length)throw new Xe("only accepts single character Uint8Array or Array");let t;if(t="string"==typeof e?e.charCodeAt(0):"number"==typeof e?e:e[0],t<0||t>255)throw new Xe("only accepts number in a valid unsigned byte range 0-255");if(this.buffer.byteLength>this.position)this.buffer[this.position++]=t;else{const e=vt.allocate(St.BUFFER_SIZE+this.buffer.length);e.set(this.buffer,0),this.buffer=e,this.buffer[this.position++]=t}}write(e,t){if(t="number"==typeof t?t:this.position,this.buffer.byteLength<t+e.length){const t=vt.allocate(this.buffer.byteLength+e.length);t.set(this.buffer,0),this.buffer=t}if(ArrayBuffer.isView(e))this.buffer.set(vt.toLocalBufferType(e),t),this.position=t+e.byteLength>this.position?t+e.length:this.position;else if("string"==typeof e)throw new Xe("input cannot be string")}read(e,t){const r=e+(t=t&&t>0?t:this.position);return this.buffer.subarray(e,r>this.position?this.position:r)}value(){return this.buffer.length===this.position?this.buffer:this.buffer.subarray(0,this.position)}length(){return this.position}toJSON(){return vt.toBase64(this.buffer.subarray(0,this.position))}toString(e){return"hex"===e?vt.toHex(this.buffer.subarray(0,this.position)):"base64"===e?vt.toBase64(this.buffer.subarray(0,this.position)):vt.toUTF8(this.buffer,0,this.position,!1)}toExtendedJSON(e){e=e||{},this.sub_type===St.SUBTYPE_VECTOR&&Et(this);const t=vt.toBase64(this.buffer),r=Number(this.sub_type).toString(16);return e.legacy?{$binary:t,$type:1===r.length?"0"+r:r}:{$binary:{base64:t,subType:1===r.length?"0"+r:r}}}toUUID(){if(this.sub_type===St.SUBTYPE_UUID)return new Tt(this.buffer.subarray(0,this.position));throw new Xe(`Binary sub_type "${this.sub_type}" is not supported for converting to UUID. Only "${St.SUBTYPE_UUID}" is currently supported.`)}static createFromHexString(e,t){return new St(vt.fromHex(e),t)}static createFromBase64(e,t){return new St(vt.fromBase64(e),t)}static fromExtendedJSON(e,t){let r,n;if(t=t||{},"$binary"in e?t.legacy&&"string"==typeof e.$binary&&"$type"in e?(n=e.$type?parseInt(e.$type,16):0,r=vt.fromBase64(e.$binary)):"string"!=typeof e.$binary&&(n=e.$binary.subType?parseInt(e.$binary.subType,16):0,r=vt.fromBase64(e.$binary.base64)):"$uuid"in e&&(n=4,r=Tt.bytesFromString(e.$uuid)),!r)throw new Xe(`Unexpected Binary Extended JSON format ${JSON.stringify(e)}`);return 4===n?new Tt(r):new St(r,n)}inspect(e,t,r){return r??=He,`Binary.createFromBase64(${r(vt.toBase64(this.buffer.subarray(0,this.position)),t)}, ${r(this.sub_type,t)})`}toInt8Array(){if(this.sub_type!==St.SUBTYPE_VECTOR)throw new Xe("Binary sub_type is not Vector");if(this.buffer[0]!==St.VECTOR_TYPE.Int8)throw new Xe("Binary datatype field is not Int8");return Et(this),new Int8Array(this.buffer.buffer.slice(this.buffer.byteOffset+2,this.buffer.byteOffset+this.position))}toFloat32Array(){if(this.sub_type!==St.SUBTYPE_VECTOR)throw new Xe("Binary sub_type is not Vector");if(this.buffer[0]!==St.VECTOR_TYPE.Float32)throw new Xe("Binary datatype field is not Float32");Et(this);const e=new Uint8Array(this.buffer.buffer.slice(this.buffer.byteOffset+2,this.buffer.byteOffset+this.position));return _t.isBigEndian&&vt.swap32(e),new Float32Array(e.buffer)}toPackedBits(){if(this.sub_type!==St.SUBTYPE_VECTOR)throw new Xe("Binary sub_type is not Vector");if(this.buffer[0]!==St.VECTOR_TYPE.PackedBit)throw new Xe("Binary datatype field is not packed bit");return Et(this),new Uint8Array(this.buffer.buffer.slice(this.buffer.byteOffset+2,this.buffer.byteOffset+this.position))}toBits(){if(this.sub_type!==St.SUBTYPE_VECTOR)throw new Xe("Binary sub_type is not Vector");if(this.buffer[0]!==St.VECTOR_TYPE.PackedBit)throw new Xe("Binary datatype field is not packed bit");Et(this);const e=8*(this.length()-2)-this.buffer[1],t=new Int8Array(e);for(let e=0;e<t.length;e++){const r=e/8|0,n=this.buffer[r+2]>>7-e%8&1;t[e]=n}return t}static fromInt8Array(e){const t=vt.allocate(e.byteLength+2);t[0]=St.VECTOR_TYPE.Int8,t[1]=0;const r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);t.set(r,2);const n=new this(t,this.SUBTYPE_VECTOR);return Et(n),n}static fromFloat32Array(e){const t=vt.allocate(e.byteLength+2);t[0]=St.VECTOR_TYPE.Float32,t[1]=0;const r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);t.set(r,2),_t.isBigEndian&&vt.swap32(new Uint8Array(t.buffer,2));const n=new this(t,this.SUBTYPE_VECTOR);return Et(n),n}static fromPackedBits(e,t=0){const r=vt.allocate(e.byteLength+2);r[0]=St.VECTOR_TYPE.PackedBit,r[1]=t,r.set(e,2);const n=new this(r,this.SUBTYPE_VECTOR);return Et(n),n}static fromBits(e){const t=e.length+7>>>3,r=new Uint8Array(t+2);r[0]=St.VECTOR_TYPE.PackedBit;const n=e.length%8;r[1]=0===n?0:8-n;for(let t=0;t<e.length;t++){const n=t>>>3,o=e[t];if(0!==o&&1!==o)throw new Xe(`Invalid bit value at ${t}: must be 0 or 1, found ${e[t]}`);if(0===o)continue;const i=7-t%8;r[n+2]|=o<<i}return new this(r,St.SUBTYPE_VECTOR)}}function Et(e){if(e.sub_type!==St.SUBTYPE_VECTOR)return;const t=e.position,r=e.buffer[0],n=e.buffer[1];if((r===St.VECTOR_TYPE.Float32||r===St.VECTOR_TYPE.Int8)&&0!==n)throw new Xe("Invalid Vector: padding must be zero for int8 and float32 vectors");if(r===St.VECTOR_TYPE.Float32&&0!==t&&t-2!=0&&(t-2)%4!=0)throw new Xe("Invalid Vector: Float32 vector must contain a multiple of 4 bytes");if(r===St.VECTOR_TYPE.PackedBit&&0!==n&&2===t)throw new Xe("Invalid Vector: padding must be zero for packed bit vectors that are empty");if(r===St.VECTOR_TYPE.PackedBit&&n>7)throw new Xe(`Invalid Vector: padding must be a value between 0 and 7. found: ${n}`)}const It=/^[0-9A-F]{32}$/i,Ot=/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i;class Tt extends St{constructor(e){let t;if(null==e)t=Tt.generate();else if(e instanceof Tt)t=vt.toLocalBufferType(new Uint8Array(e.buffer));else if(ArrayBuffer.isView(e)&&16===e.byteLength)t=vt.toLocalBufferType(e);else{if("string"!=typeof e)throw new Xe("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).");t=Tt.bytesFromString(e)}super(t,4)}get id(){return this.buffer}set id(e){this.buffer=e}toHexString(e=!0){return e?[vt.toHex(this.buffer.subarray(0,4)),vt.toHex(this.buffer.subarray(4,6)),vt.toHex(this.buffer.subarray(6,8)),vt.toHex(this.buffer.subarray(8,10)),vt.toHex(this.buffer.subarray(10,16))].join("-"):vt.toHex(this.buffer)}toString(e){return"hex"===e?vt.toHex(this.id):"base64"===e?vt.toBase64(this.id):this.toHexString()}toJSON(){return this.toHexString()}equals(e){if(!e)return!1;if(e instanceof Tt)return vt.equals(e.id,this.id);try{return vt.equals(new Tt(e).id,this.id)}catch{return!1}}toBinary(){return new St(this.id,St.SUBTYPE_UUID)}static generate(){const e=vt.randomBytes(16);return e[6]=15&e[6]|64,e[8]=63&e[8]|128,e}static isValid(e){return!!e&&("string"==typeof e?Tt.isValidUUIDString(e):Fe(e)?16===e.byteLength:"Binary"===e._bsontype&&e.sub_type===this.SUBTYPE_UUID&&16===e.buffer.byteLength)}static createFromHexString(e){const t=Tt.bytesFromString(e);return new Tt(t)}static createFromBase64(e){return new Tt(vt.fromBase64(e))}static bytesFromString(e){if(!Tt.isValidUUIDString(e))throw new Xe("UUID string representation must be 32 hex digits or canonical hyphenated representation");return vt.fromHex(e.replace(/-/g,""))}static isValidUUIDString(e){return It.test(e)||Ot.test(e)}inspect(e,t,r){return r??=He,`new UUID(${r(this.toHexString(),t)})`}}class At extends mt{get _bsontype(){return"Code"}code;scope;constructor(e,t){super(),this.code=e.toString(),this.scope=t??null}toJSON(){return null!=this.scope?{code:this.code,scope:this.scope}:{code:this.code}}toExtendedJSON(){return this.scope?{$code:this.code,$scope:this.scope}:{$code:this.code}}static fromExtendedJSON(e){return new At(e.$code,e.$scope)}inspect(e,t,r){r??=He;let n=r(this.code,t);const o=n.includes("\n");return null!=this.scope&&(n+=`,${o?"\n":" "}${r(this.scope,t)}`),`new Code(${o?"\n":""}${n}${o&&null===this.scope?"\n":""})`}}class Rt extends mt{get _bsontype(){return"DBRef"}collection;oid;db;fields;constructor(e,t,r,n){super();const o=e.split(".");2===o.length&&(r=o.shift(),e=o.shift()),this.collection=e,this.oid=t,this.db=r,this.fields=n||{}}get namespace(){return this.collection}set namespace(e){this.collection=e}toJSON(){const e=Object.assign({$ref:this.collection,$id:this.oid},this.fields);return null!=this.db&&(e.$db=this.db),e}toExtendedJSON(e){e=e||{};let t={$ref:this.collection,$id:this.oid};return e.legacy||(this.db&&(t.$db=this.db),t=Object.assign(t,this.fields)),t}static fromExtendedJSON(e){const t=Object.assign({},e);return delete t.$ref,delete t.$id,delete t.$db,new Rt(e.$ref,e.$id,e.$db,t)}inspect(e,t,r){r??=He;const n=[r(this.namespace,t),r(this.oid,t),...this.db?[r(this.db,t)]:[],...Object.keys(this.fields).length>0?[r(this.fields,t)]:[]];return n[1]=r===He?`new ObjectId(${n[1]})`:n[1],`new DBRef(${n.join(", ")})`}}function Pt(e){if(""===e)return e;let t=0;const r="-"===e[t],n="+"===e[t];(n||r)&&(t+=1);let o=!1;for(;t<e.length&&"0"===e[t];++t)o=!0;return o?`${r?"-":""}${e.length===t?"0":e.slice(t)}`:n?e.slice(1):e}let Ct;try{Ct=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{}const Nt=4294967296,xt=0x10000000000000000,Lt=xt/2,Ut={},kt={},Dt=/^(\+?0|(\+|-)?[1-9][0-9]*)$/;class jt extends mt{get _bsontype(){return"Long"}get __isLong__(){return!0}high;low;unsigned;constructor(e=0,t,r){super();const n="boolean"==typeof t?t:Boolean(r),o="number"==typeof t?t:0,i="string"==typeof e?jt.fromString(e,n):"bigint"==typeof e?jt.fromBigInt(e,n):{low:0|e,high:0|o,unsigned:n};this.low=i.low,this.high=i.high,this.unsigned=i.unsigned}static TWO_PWR_24=jt.fromInt(16777216);static MAX_UNSIGNED_VALUE=jt.fromBits(-1,-1,!0);static ZERO=jt.fromInt(0);static UZERO=jt.fromInt(0,!0);static ONE=jt.fromInt(1);static UONE=jt.fromInt(1,!0);static NEG_ONE=jt.fromInt(-1);static MAX_VALUE=jt.fromBits(-1,2147483647,!1);static MIN_VALUE=jt.fromBits(0,-2147483648,!1);static fromBits(e,t,r){return new jt(e,t,r)}static fromInt(e,t){let r,n,o;return t?(o=0<=(e>>>=0)&&e<256)&&(n=kt[e],n)?n:(r=jt.fromBits(e,(0|e)<0?-1:0,!0),o&&(kt[e]=r),r):(o=-128<=(e|=0)&&e<128)&&(n=Ut[e],n)?n:(r=jt.fromBits(e,e<0?-1:0,!1),o&&(Ut[e]=r),r)}static fromNumber(e,t){if(isNaN(e))return t?jt.UZERO:jt.ZERO;if(t){if(e<0)return jt.UZERO;if(e>=xt)return jt.MAX_UNSIGNED_VALUE}else{if(e<=-Lt)return jt.MIN_VALUE;if(e+1>=Lt)return jt.MAX_VALUE}return e<0?jt.fromNumber(-e,t).neg():jt.fromBits(e%Nt|0,e/Nt|0,t)}static fromBigInt(e,t){const r=0xffffffffn;return new jt(Number(e&r),Number(e>>32n&r),t)}static _fromString(e,t,r){if(0===e.length)throw new Xe("empty string");if(r<2||36<r)throw new Xe("radix");let n;if((n=e.indexOf("-"))>0)throw new Xe("interior hyphen");if(0===n)return jt._fromString(e.substring(1),t,r).neg();const o=jt.fromNumber(Math.pow(r,8));let i=jt.ZERO;for(let t=0;t<e.length;t+=8){const n=Math.min(8,e.length-t),s=parseInt(e.substring(t,t+n),r);if(n<8){const e=jt.fromNumber(Math.pow(r,n));i=i.mul(e).add(jt.fromNumber(s))}else i=i.mul(o),i=i.add(jt.fromNumber(s))}return i.unsigned=t,i}static fromStringStrict(e,t,r){let n=!1;if("number"==typeof t?(r=t,t=!1):n=!!t,r??=10,e.trim()!==e)throw new Xe(`Input: '${e}' contains leading and/or trailing whitespace`);if(!function(e,t){const r="0123456789abcdefghijklmnopqrstuvwxyz".slice(0,t=t??10);return!new RegExp(`[^-+${r}]`,"i").test(e)&&e}(e,r))throw new Xe(`Input: '${e}' contains invalid characters for radix: ${r}`);const o=Pt(e),i=jt._fromString(o,n,r);if(i.toString(r).toLowerCase()!==o.toLowerCase())throw new Xe(`Input: ${e} is not representable as ${i.unsigned?"an unsigned":"a signed"} 64-bit Long ${null!=r?`with radix: ${r}`:""}`);return i}static fromString(e,t,r){let n=!1;return"number"==typeof t?(r=t,t=!1):n=!!t,r??=10,"NaN"===e&&r<24||("Infinity"===e||"+Infinity"===e||"-Infinity"===e)&&r<35?jt.ZERO:jt._fromString(e,n,r)}static fromBytes(e,t,r){return r?jt.fromBytesLE(e,t):jt.fromBytesBE(e,t)}static fromBytesLE(e,t){return new jt(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)}static fromBytesBE(e,t){return new jt(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)}static isLong(e){return null!=e&&"object"==typeof e&&"__isLong__"in e&&!0===e.__isLong__}static fromValue(e,t){return"number"==typeof e?jt.fromNumber(e,t):"string"==typeof e?jt.fromString(e,t):jt.fromBits(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}add(e){jt.isLong(e)||(e=jt.fromValue(e));const t=this.high>>>16,r=65535&this.high,n=this.low>>>16,o=65535&this.low,i=e.high>>>16,s=65535&e.high,a=e.low>>>16;let u=0,c=0,l=0,f=0;return f+=o+(65535&e.low),l+=f>>>16,f&=65535,l+=n+a,c+=l>>>16,l&=65535,c+=r+s,u+=c>>>16,c&=65535,u+=t+i,u&=65535,jt.fromBits(l<<16|f,u<<16|c,this.unsigned)}and(e){return jt.isLong(e)||(e=jt.fromValue(e)),jt.fromBits(this.low&e.low,this.high&e.high,this.unsigned)}compare(e){if(jt.isLong(e)||(e=jt.fromValue(e)),this.eq(e))return 0;const t=this.isNegative(),r=e.isNegative();return t&&!r?-1:!t&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1}comp(e){return this.compare(e)}divide(e){if(jt.isLong(e)||(e=jt.fromValue(e)),e.isZero())throw new Xe("division by zero");if(Ct){if(!this.unsigned&&-2147483648===this.high&&-1===e.low&&-1===e.high)return this;const t=(this.unsigned?Ct.div_u:Ct.div_s)(this.low,this.high,e.low,e.high);return jt.fromBits(t,Ct.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?jt.UZERO:jt.ZERO;let t,r,n;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return jt.UZERO;if(e.gt(this.shru(1)))return jt.UONE;n=jt.UZERO}else{if(this.eq(jt.MIN_VALUE))return e.eq(jt.ONE)||e.eq(jt.NEG_ONE)?jt.MIN_VALUE:e.eq(jt.MIN_VALUE)?jt.ONE:(t=this.shr(1).div(e).shl(1),t.eq(jt.ZERO)?e.isNegative()?jt.ONE:jt.NEG_ONE:(r=this.sub(e.mul(t)),n=t.add(r.div(e)),n));if(e.eq(jt.MIN_VALUE))return this.unsigned?jt.UZERO:jt.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();n=jt.ZERO}for(r=this;r.gte(e);){t=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));const o=Math.ceil(Math.log(t)/Math.LN2),i=o<=48?1:Math.pow(2,o-48);let s=jt.fromNumber(t),a=s.mul(e);for(;a.isNegative()||a.gt(r);)t-=i,s=jt.fromNumber(t,this.unsigned),a=s.mul(e);s.isZero()&&(s=jt.ONE),n=n.add(s),r=r.sub(a)}return n}div(e){return this.divide(e)}equals(e){return jt.isLong(e)||(e=jt.fromValue(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&this.high===e.high&&this.low===e.low}eq(e){return this.equals(e)}getHighBits(){return this.high}getHighBitsUnsigned(){return this.high>>>0}getLowBits(){return this.low}getLowBitsUnsigned(){return this.low>>>0}getNumBitsAbs(){if(this.isNegative())return this.eq(jt.MIN_VALUE)?64:this.neg().getNumBitsAbs();const e=0!==this.high?this.high:this.low;let t;for(t=31;t>0&&!(e&1<<t);t--);return 0!==this.high?t+33:t+1}greaterThan(e){return this.comp(e)>0}gt(e){return this.greaterThan(e)}greaterThanOrEqual(e){return this.comp(e)>=0}gte(e){return this.greaterThanOrEqual(e)}ge(e){return this.greaterThanOrEqual(e)}isEven(){return!(1&this.low)}isNegative(){return!this.unsigned&&this.high<0}isOdd(){return!(1&~this.low)}isPositive(){return this.unsigned||this.high>=0}isZero(){return 0===this.high&&0===this.low}lessThan(e){return this.comp(e)<0}lt(e){return this.lessThan(e)}lessThanOrEqual(e){return this.comp(e)<=0}lte(e){return this.lessThanOrEqual(e)}modulo(e){if(jt.isLong(e)||(e=jt.fromValue(e)),Ct){const t=(this.unsigned?Ct.rem_u:Ct.rem_s)(this.low,this.high,e.low,e.high);return jt.fromBits(t,Ct.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))}mod(e){return this.modulo(e)}rem(e){return this.modulo(e)}multiply(e){if(this.isZero())return jt.ZERO;if(jt.isLong(e)||(e=jt.fromValue(e)),Ct){const t=Ct.mul(this.low,this.high,e.low,e.high);return jt.fromBits(t,Ct.get_high(),this.unsigned)}if(e.isZero())return jt.ZERO;if(this.eq(jt.MIN_VALUE))return e.isOdd()?jt.MIN_VALUE:jt.ZERO;if(e.eq(jt.MIN_VALUE))return this.isOdd()?jt.MIN_VALUE:jt.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(jt.TWO_PWR_24)&&e.lt(jt.TWO_PWR_24))return jt.fromNumber(this.toNumber()*e.toNumber(),this.unsigned);const t=this.high>>>16,r=65535&this.high,n=this.low>>>16,o=65535&this.low,i=e.high>>>16,s=65535&e.high,a=e.low>>>16,u=65535&e.low;let c=0,l=0,f=0,d=0;return d+=o*u,f+=d>>>16,d&=65535,f+=n*u,l+=f>>>16,f&=65535,f+=o*a,l+=f>>>16,f&=65535,l+=r*u,c+=l>>>16,l&=65535,l+=n*a,c+=l>>>16,l&=65535,l+=o*s,c+=l>>>16,l&=65535,c+=t*u+r*a+n*s+o*i,c&=65535,jt.fromBits(f<<16|d,c<<16|l,this.unsigned)}mul(e){return this.multiply(e)}negate(){return!this.unsigned&&this.eq(jt.MIN_VALUE)?jt.MIN_VALUE:this.not().add(jt.ONE)}neg(){return this.negate()}not(){return jt.fromBits(~this.low,~this.high,this.unsigned)}notEquals(e){return!this.equals(e)}neq(e){return this.notEquals(e)}ne(e){return this.notEquals(e)}or(e){return jt.isLong(e)||(e=jt.fromValue(e)),jt.fromBits(this.low|e.low,this.high|e.high,this.unsigned)}shiftLeft(e){return jt.isLong(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?jt.fromBits(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):jt.fromBits(0,this.low<<e-32,this.unsigned)}shl(e){return this.shiftLeft(e)}shiftRight(e){return jt.isLong(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?jt.fromBits(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):jt.fromBits(this.high>>e-32,this.high>=0?0:-1,this.unsigned)}shr(e){return this.shiftRight(e)}shiftRightUnsigned(e){if(jt.isLong(e)&&(e=e.toInt()),0==(e&=63))return this;{const t=this.high;if(e<32){const r=this.low;return jt.fromBits(r>>>e|t<<32-e,t>>>e,this.unsigned)}return 32===e?jt.fromBits(t,0,this.unsigned):jt.fromBits(t>>>e-32,0,this.unsigned)}}shr_u(e){return this.shiftRightUnsigned(e)}shru(e){return this.shiftRightUnsigned(e)}subtract(e){return jt.isLong(e)||(e=jt.fromValue(e)),this.add(e.neg())}sub(e){return this.subtract(e)}toInt(){return this.unsigned?this.low>>>0:this.low}toNumber(){return this.unsigned?(this.high>>>0)*Nt+(this.low>>>0):this.high*Nt+(this.low>>>0)}toBigInt(){return BigInt(this.toString())}toBytes(e){return e?this.toBytesLE():this.toBytesBE()}toBytesLE(){const e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]}toBytesBE(){const e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]}toSigned(){return this.unsigned?jt.fromBits(this.low,this.high,!1):this}toString(e){if((e=e||10)<2||36<e)throw new Xe("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(jt.MIN_VALUE)){const t=jt.fromNumber(e),r=this.div(t),n=r.mul(t).sub(this);return r.toString(e)+n.toInt().toString(e)}return"-"+this.neg().toString(e)}const t=jt.fromNumber(Math.pow(e,6),this.unsigned);let r=this,n="";for(;;){const o=r.div(t);let i=(r.sub(o.mul(t)).toInt()>>>0).toString(e);if(r=o,r.isZero())return i+n;for(;i.length<6;)i="0"+i;n=""+i+n}}toUnsigned(){return this.unsigned?this:jt.fromBits(this.low,this.high,!0)}xor(e){return jt.isLong(e)||(e=jt.fromValue(e)),jt.fromBits(this.low^e.low,this.high^e.high,this.unsigned)}eqz(){return this.isZero()}le(e){return this.lessThanOrEqual(e)}toExtendedJSON(e){return e&&e.relaxed?this.toNumber():{$numberLong:this.toString()}}static fromExtendedJSON(e,t){const{useBigInt64:r=!1,relaxed:n=!0}={...t};if(e.$numberLong.length>20)throw new Xe("$numberLong string is too long");if(!Dt.test(e.$numberLong))throw new Xe(`$numberLong string "${e.$numberLong}" is in an invalid format`);if(r){const t=BigInt(e.$numberLong);return BigInt.asIntN(64,t)}const o=jt.fromString(e.$numberLong);return n?o.toNumber():o}inspect(e,t,r){return r??=He,`new Long(${r(this.toString(),t)}${this.unsigned?`, ${r(this.unsigned,t)}`:""})`}}const qt=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,Mt=/^(\+|-)?(Infinity|inf)$/i,Bt=/^(\+|-)?NaN$/i,Wt=6111,Ft=-6176,Vt=vt.fromNumberArray([124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),Ht=vt.fromNumberArray([248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),$t=vt.fromNumberArray([120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),Gt=/^([-+])?(\d+)?$/;function zt(e){return!isNaN(parseInt(e,10))}function Kt(e){const t=jt.fromNumber(1e9);let r=jt.fromNumber(0);if(!(e.parts[0]||e.parts[1]||e.parts[2]||e.parts[3]))return{quotient:e,rem:r};for(let n=0;n<=3;n++)r=r.shiftLeft(32),r=r.add(new jt(e.parts[n],0)),e.parts[n]=r.div(t).low,r=r.modulo(t);return{quotient:e,rem:r}}function Jt(e,t){throw new Xe(`"${e}" is not a valid Decimal128 string - ${t}`)}class Yt extends mt{get _bsontype(){return"Decimal128"}bytes;constructor(e){if(super(),"string"==typeof e)this.bytes=Yt.fromString(e).bytes;else{if(!(e instanceof Uint8Array||Fe(e)))throw new Xe("Decimal128 must take a Buffer or string");if(16!==e.byteLength)throw new Xe("Decimal128 must take a Buffer of 16 bytes");this.bytes=e}}static fromString(e){return Yt._fromString(e,{allowRounding:!1})}static fromStringWithRounding(e){return Yt._fromString(e,{allowRounding:!0})}static _fromString(e,t){let r=!1,n=!1,o=!1,i=!1,s=0,a=0,u=0,c=0,l=0;const f=[0];let d=0,h=0,p=0,v=0,y=new jt(0,0),m=new jt(0,0),g=0,b=0;if(e.length>=7e3)throw new Xe(e+" not a valid Decimal128 string");const w=e.match(qt),_=e.match(Mt),S=e.match(Bt);if(!w&&!_&&!S||0===e.length)throw new Xe(e+" not a valid Decimal128 string");if(w){const t=w[2],r=w[4],n=w[5],o=w[6];r&&void 0===o&&Jt(e,"missing exponent power"),r&&void 0===t&&Jt(e,"missing exponent base"),void 0===r&&(n||o)&&Jt(e,"missing e before exponent")}if("+"!==e[b]&&"-"!==e[b]||(n=!0,r="-"===e[b++]),!zt(e[b])&&"."!==e[b]){if("i"===e[b]||"I"===e[b])return new Yt(r?Ht:$t);if("N"===e[b])return new Yt(Vt)}for(;zt(e[b])||"."===e[b];)"."!==e[b]?(d<34&&("0"!==e[b]||i)&&(i||(l=a),i=!0,f[h++]=parseInt(e[b],10),d+=1),i&&(u+=1),o&&(c+=1),a+=1,b+=1):(o&&Jt(e,"contains multiple periods"),o=!0,b+=1);if(o&&!a)throw new Xe(e+" not a valid Decimal128 string");if("e"===e[b]||"E"===e[b]){const t=e.substr(++b).match(Gt);if(!t||!t[2])return new Yt(Vt);v=parseInt(t[0],10),b+=t[0].length}if(e[b])return new Yt(Vt);if(d){if(p=d-1,s=u,1!==s)for(;"0"===e[l+s-1+Number(n)+Number(o)];)s-=1}else f[0]=0,u=1,d=1,s=0;for(v<=c&&c>v+16384?v=Ft:v-=c;v>Wt;){if(p+=1,p>=34){if(0===s){v=Wt;break}Jt(e,"overflow")}v-=1}if(t.allowRounding){for(;v<Ft||d<u;){if(0===p&&s<d){v=Ft,s=0;break}if(d<u?u-=1:p-=1,v<Wt)v+=1;else{if(f.join("").match(/^0+$/)){v=Wt;break}Jt(e,"overflow")}}if(p+1<s){let t=a;o&&(l+=1,t+=1),n&&(l+=1,t+=1);const i=parseInt(e[l+p+1],10);let s=0;if(i>=5&&(s=1,5===i)){s=f[p]%2==1?1:0;for(let r=l+p+2;r<t;r++)if(parseInt(e[r],10)){s=1;break}}if(s){let e=p;for(;e>=0&&++f[e]>9;e--)if(f[e]=0,0===e){if(!(v<Wt))return new Yt(r?Ht:$t);v+=1,f[e]=1}}}}else{for(;v<Ft||d<u;){if(0===p){if(0===s){v=Ft;break}Jt(e,"exponent underflow")}d<u?("0"!==e[u-1+Number(n)+Number(o)]&&0!==s&&Jt(e,"inexact rounding"),u-=1):(0!==f[p]&&Jt(e,"inexact rounding"),p-=1),v<Wt?v+=1:Jt(e,"overflow")}p+1<s&&(o&&(l+=1),n&&(l+=1),0!==parseInt(e[l+p+1],10)&&Jt(e,"inexact rounding"))}if(y=jt.fromNumber(0),m=jt.fromNumber(0),0===s)y=jt.fromNumber(0),m=jt.fromNumber(0);else if(p<17){let e=0;for(m=jt.fromNumber(f[e++]),y=new jt(0,0);e<=p;e++)m=m.multiply(jt.fromNumber(10)),m=m.add(jt.fromNumber(f[e]))}else{let e=0;for(y=jt.fromNumber(f[e++]);e<=p-17;e++)y=y.multiply(jt.fromNumber(10)),y=y.add(jt.fromNumber(f[e]));for(m=jt.fromNumber(f[e++]);e<=p;e++)m=m.multiply(jt.fromNumber(10)),m=m.add(jt.fromNumber(f[e]))}const E=function(e,t){if(!e&&!t)return{high:jt.fromNumber(0),low:jt.fromNumber(0)};const r=e.shiftRightUnsigned(32),n=new jt(e.getLowBits(),0),o=t.shiftRightUnsigned(32),i=new jt(t.getLowBits(),0);let s=r.multiply(o),a=r.multiply(i);const u=n.multiply(o);let c=n.multiply(i);return s=s.add(a.shiftRightUnsigned(32)),a=new jt(a.getLowBits(),0).add(u).add(c.shiftRightUnsigned(32)),s=s.add(a.shiftRightUnsigned(32)),c=a.shiftLeft(32).add(new jt(c.getLowBits(),0)),{high:s,low:c}}(y,jt.fromString("100000000000000000"));E.low=E.low.add(m),function(e,t){const r=e.high>>>0,n=t.high>>>0;return r<n||r===n&&e.low>>>0<t.low>>>0}(E.low,m)&&(E.high=E.high.add(jt.fromNumber(1))),g=v+6176;const I={low:jt.fromNumber(0),high:jt.fromNumber(0)};E.high.shiftRightUnsigned(49).and(jt.fromNumber(1)).equals(jt.fromNumber(1))?(I.high=I.high.or(jt.fromNumber(3).shiftLeft(61)),I.high=I.high.or(jt.fromNumber(g).and(jt.fromNumber(16383).shiftLeft(47))),I.high=I.high.or(E.high.and(jt.fromNumber(0x7fffffffffff)))):(I.high=I.high.or(jt.fromNumber(16383&g).shiftLeft(49)),I.high=I.high.or(E.high.and(jt.fromNumber(562949953421311)))),I.low=E.low,r&&(I.high=I.high.or(jt.fromString("9223372036854775808")));const O=vt.allocateUnsafe(16);return b=0,O[b++]=255&I.low.low,O[b++]=I.low.low>>8&255,O[b++]=I.low.low>>16&255,O[b++]=I.low.low>>24&255,O[b++]=255&I.low.high,O[b++]=I.low.high>>8&255,O[b++]=I.low.high>>16&255,O[b++]=I.low.high>>24&255,O[b++]=255&I.high.low,O[b++]=I.high.low>>8&255,O[b++]=I.high.low>>16&255,O[b++]=I.high.low>>24&255,O[b++]=255&I.high.high,O[b++]=I.high.high>>8&255,O[b++]=I.high.high>>16&255,O[b++]=I.high.high>>24&255,new Yt(O)}toString(){let e,t=0;const r=new Array(36);for(let e=0;e<r.length;e++)r[e]=0;let n,o,i,s=0,a=!1,u={parts:[0,0,0,0]};const c=[];s=0;const l=this.bytes,f=l[s++]|l[s++]<<8|l[s++]<<16|l[s++]<<24,d=l[s++]|l[s++]<<8|l[s++]<<16|l[s++]<<24,h=l[s++]|l[s++]<<8|l[s++]<<16|l[s++]<<24,p=l[s++]|l[s++]<<8|l[s++]<<16|l[s++]<<24;s=0,(new jt(f,d),new jt(h,p)).lessThan(jt.ZERO)&&c.push("-");const v=p>>26&31;if(v>>3==3){if(30===v)return c.join("")+"Infinity";if(31===v)return"NaN";e=p>>15&16383,n=8+(p>>14&1)}else n=p>>14&7,e=p>>17&16383;const y=e-6176;if(u.parts[0]=(16383&p)+((15&n)<<14),u.parts[1]=h,u.parts[2]=d,u.parts[3]=f,0===u.parts[0]&&0===u.parts[1]&&0===u.parts[2]&&0===u.parts[3])a=!0;else for(i=3;i>=0;i--){let e=0;const t=Kt(u);if(u=t.quotient,e=t.rem.low,e)for(o=8;o>=0;o--)r[9*i+o]=e%10,e=Math.floor(e/10)}if(a)t=1,r[s]=0;else for(t=36;!r[s];)t-=1,s+=1;const m=t-1+y;if(m>=34||m<=-7||y>0){if(t>34)return c.push("0"),y>0?c.push(`E+${y}`):y<0&&c.push(`E${y}`),c.join("");c.push(`${r[s++]}`),t-=1,t&&c.push(".");for(let e=0;e<t;e++)c.push(`${r[s++]}`);c.push("E"),m>0?c.push(`+${m}`):c.push(`${m}`)}else if(y>=0)for(let e=0;e<t;e++)c.push(`${r[s++]}`);else{let e=t+y;if(e>0)for(let t=0;t<e;t++)c.push(`${r[s++]}`);else c.push("0");for(c.push(".");e++<0;)c.push("0");for(let n=0;n<t-Math.max(e-1,0);n++)c.push(`${r[s++]}`)}return c.join("")}toJSON(){return{$numberDecimal:this.toString()}}toExtendedJSON(){return{$numberDecimal:this.toString()}}static fromExtendedJSON(e){return Yt.fromString(e.$numberDecimal)}inspect(e,t,r){return r??=He,`new Decimal128(${r(this.toString(),t)})`}}class Qt extends mt{get _bsontype(){return"Double"}value;constructor(e){super(),e instanceof Number&&(e=e.valueOf()),this.value=+e}static fromString(e){const t=Number(e);if("NaN"===e)return new Qt(NaN);if("Infinity"===e)return new Qt(1/0);if("-Infinity"===e)return new Qt(-1/0);if(!Number.isFinite(t))throw new Xe(`Input: ${e} is not representable as a Double`);if(e.trim()!==e)throw new Xe(`Input: '${e}' contains whitespace`);if(""===e)throw new Xe("Input is an empty string");if(/[^-0-9.+eE]/.test(e))throw new Xe(`Input: '${e}' is not in decimal or exponential notation`);return new Qt(t)}valueOf(){return this.value}toJSON(){return this.value}toString(e){return this.value.toString(e)}toExtendedJSON(e){return e&&(e.legacy||e.relaxed&&isFinite(this.value))?this.value:Object.is(Math.sign(this.value),-0)?{$numberDouble:"-0.0"}:{$numberDouble:Number.isInteger(this.value)?this.value.toFixed(1):this.value.toString()}}static fromExtendedJSON(e,t){const r=parseFloat(e.$numberDouble);return t&&t.relaxed?r:new Qt(r)}inspect(e,t,r){return r??=He,`new Double(${r(this.value,t)})`}}class Zt extends mt{get _bsontype(){return"Int32"}value;constructor(e){super(),e instanceof Number&&(e=e.valueOf()),this.value=0|+e}static fromString(e){const t=Pt(e),r=Number(e);if(ze<r)throw new Xe(`Input: '${e}' is larger than the maximum value for Int32`);if(Ke>r)throw new Xe(`Input: '${e}' is smaller than the minimum value for Int32`);if(!Number.isSafeInteger(r))throw new Xe(`Input: '${e}' is not a safe integer`);if(r.toString()!==t)throw new Xe(`Input: '${e}' is not a valid Int32 string`);return new Zt(r)}valueOf(){return this.value}toString(e){return this.value.toString(e)}toJSON(){return this.value}toExtendedJSON(e){return e&&(e.relaxed||e.legacy)?this.value:{$numberInt:this.value.toString()}}static fromExtendedJSON(e,t){return t&&t.relaxed?parseInt(e.$numberInt,10):new Zt(e.$numberInt)}inspect(e,t,r){return r??=He,`new Int32(${r(this.value,t)})`}}class Xt extends mt{get _bsontype(){return"MaxKey"}toExtendedJSON(){return{$maxKey:1}}static fromExtendedJSON(){return new Xt}inspect(){return"new MaxKey()"}}class er extends mt{get _bsontype(){return"MinKey"}toExtendedJSON(){return{$minKey:1}}static fromExtendedJSON(){return new er}inspect(){return"new MinKey()"}}let tr=null;const rr=new WeakMap;class nr extends mt{get _bsontype(){return"ObjectId"}static index=Math.floor(16777215*Math.random());static cacheHexString;buffer;constructor(e){let t;if(super(),"object"==typeof e&&e&&"id"in e){if("string"!=typeof e.id&&!ArrayBuffer.isView(e.id))throw new Xe("Argument passed in must have an id that is of type string or Buffer");t="toHexString"in e&&"function"==typeof e.toHexString?vt.fromHex(e.toHexString()):e.id}else t=e;if(null==t)this.buffer=nr.generate();else if(ArrayBuffer.isView(t)&&12===t.byteLength)this.buffer=vt.toLocalBufferType(t);else{if("string"!=typeof t)throw new Xe("Argument passed in does not match the accepted types");if(!nr.validateHexString(t))throw new Xe("input must be a 24 character hex string, 12 byte Uint8Array, or an integer");this.buffer=vt.fromHex(t),nr.cacheHexString&&rr.set(this,t)}}get id(){return this.buffer}set id(e){this.buffer=e,nr.cacheHexString&&rr.set(this,vt.toHex(e))}static validateHexString(e){if(24!==e?.length)return!1;for(let t=0;t<24;t++){const r=e.charCodeAt(t);if(!(r>=48&&r<=57||r>=97&&r<=102||r>=65&&r<=70))return!1}return!0}toHexString(){if(nr.cacheHexString){const e=rr.get(this);if(e)return e}const e=vt.toHex(this.id);return nr.cacheHexString&&rr.set(this,e),e}static getInc(){return nr.index=(nr.index+1)%16777215}static generate(e){"number"!=typeof e&&(e=Math.floor(Date.now()/1e3));const t=nr.getInc(),r=vt.allocateUnsafe(12);return _t.setInt32BE(r,0,e),null===tr&&(tr=vt.randomBytes(5)),r[4]=tr[0],r[5]=tr[1],r[6]=tr[2],r[7]=tr[3],r[8]=tr[4],r[11]=255&t,r[10]=t>>8&255,r[9]=t>>16&255,r}toString(e){return"base64"===e?vt.toBase64(this.id):this.toHexString()}toJSON(){return this.toHexString()}static is(e){return null!=e&&"object"==typeof e&&"_bsontype"in e&&"ObjectId"===e._bsontype}equals(e){if(null==e)return!1;if(nr.is(e))return this.buffer[11]===e.buffer[11]&&vt.equals(this.buffer,e.buffer);if("string"==typeof e)return e.toLowerCase()===this.toHexString();if("object"==typeof e&&"function"==typeof e.toHexString){const t=e.toHexString(),r=this.toHexString();return"string"==typeof t&&t.toLowerCase()===r}return!1}getTimestamp(){const e=new Date,t=_t.getUint32BE(this.buffer,0);return e.setTime(1e3*Math.floor(t)),e}static createPk(){return new nr}serializeInto(e,t){return e[t]=this.buffer[0],e[t+1]=this.buffer[1],e[t+2]=this.buffer[2],e[t+3]=this.buffer[3],e[t+4]=this.buffer[4],e[t+5]=this.buffer[5],e[t+6]=this.buffer[6],e[t+7]=this.buffer[7],e[t+8]=this.buffer[8],e[t+9]=this.buffer[9],e[t+10]=this.buffer[10],e[t+11]=this.buffer[11],12}static createFromTime(e){const t=vt.allocate(12);for(let e=11;e>=4;e--)t[e]=0;return _t.setInt32BE(t,0,e),new nr(t)}static createFromHexString(e){if(24!==e?.length)throw new Xe("hex string must be 24 characters");return new nr(vt.fromHex(e))}static createFromBase64(e){if(16!==e?.length)throw new Xe("base64 string must be 16 characters");return new nr(vt.fromBase64(e))}static isValid(e){if(null==e)return!1;if("string"==typeof e)return nr.validateHexString(e);try{return new nr(e),!0}catch{return!1}}toExtendedJSON(){return this.toHexString?{$oid:this.toHexString()}:{$oid:this.toString("hex")}}static fromExtendedJSON(e){return new nr(e.$oid)}isCached(){return nr.cacheHexString&&rr.has(this)}inspect(e,t,r){return r??=He,`new ObjectId(${r(this.toHexString(),t)})`}}class or extends mt{get _bsontype(){return"BSONRegExp"}pattern;options;constructor(e,t){if(super(),this.pattern=e,this.options=(t??"").split("").sort().join(""),-1!==this.pattern.indexOf("\0"))throw new Xe(`BSON Regex patterns cannot contain null bytes, found: ${JSON.stringify(this.pattern)}`);if(-1!==this.options.indexOf("\0"))throw new Xe(`BSON Regex options cannot contain null bytes, found: ${JSON.stringify(this.options)}`);for(let e=0;e<this.options.length;e++)if("i"!==this.options[e]&&"m"!==this.options[e]&&"x"!==this.options[e]&&"l"!==this.options[e]&&"s"!==this.options[e]&&"u"!==this.options[e])throw new Xe(`The regular expression option [${this.options[e]}] is not supported`)}static parseOptions(e){return e?e.split("").sort().join(""):""}toExtendedJSON(e){return(e=e||{}).legacy?{$regex:this.pattern,$options:this.options}:{$regularExpression:{pattern:this.pattern,options:this.options}}}static fromExtendedJSON(e){if("$regex"in e){if("string"==typeof e.$regex)return new or(e.$regex,or.parseOptions(e.$options));if("BSONRegExp"===e.$regex._bsontype)return e}if("$regularExpression"in e)return new or(e.$regularExpression.pattern,or.parseOptions(e.$regularExpression.options));throw new Xe(`Unexpected BSONRegExp EJSON object form: ${JSON.stringify(e)}`)}inspect(e,t,r){const n=function(e){if(null!=e&&"object"==typeof e&&"stylize"in e&&"function"==typeof e.stylize)return e.stylize}(t)??(e=>e);return r??=He,`new BSONRegExp(${n(r(this.pattern),"regexp")}, ${n(r(this.options),"regexp")})`}}class ir extends mt{get _bsontype(){return"BSONSymbol"}value;constructor(e){super(),this.value=e}valueOf(){return this.value}toString(){return this.value}toJSON(){return this.value}toExtendedJSON(){return{$symbol:this.value}}static fromExtendedJSON(e){return new ir(e.$symbol)}inspect(e,t,r){return r??=He,`new BSONSymbol(${r(this.value,t)})`}}const sr=jt;class ar extends sr{get _bsontype(){return"Timestamp"}get[yt](){return"Timestamp"}static MAX_VALUE=jt.MAX_UNSIGNED_VALUE;get i(){return this.low>>>0}get t(){return this.high>>>0}constructor(e){if(null==e)super(0,0,!0);else if("bigint"==typeof e)super(e,!0);else if(jt.isLong(e))super(e.low,e.high,!0);else{if("object"!=typeof e||!("t"in e)||!("i"in e))throw new Xe("A Timestamp can only be constructed with: bigint, Long, or { t: number; i: number }");{if("number"!=typeof e.t&&("object"!=typeof e.t||"Int32"!==e.t._bsontype))throw new Xe("Timestamp constructed from { t, i } must provide t as a number");if("number"!=typeof e.i&&("object"!=typeof e.i||"Int32"!==e.i._bsontype))throw new Xe("Timestamp constructed from { t, i } must provide i as a number");const t=Number(e.t),r=Number(e.i);if(t<0||Number.isNaN(t))throw new Xe("Timestamp constructed from { t, i } must provide a positive t");if(r<0||Number.isNaN(r))throw new Xe("Timestamp constructed from { t, i } must provide a positive i");if(t>4294967295)throw new Xe("Timestamp constructed from { t, i } must provide t equal or less than uint32 max");if(r>4294967295)throw new Xe("Timestamp constructed from { t, i } must provide i equal or less than uint32 max");super(r,t,!0)}}}toJSON(){return{$timestamp:this.toString()}}static fromInt(e){return new ar(jt.fromInt(e,!0))}static fromNumber(e){return new ar(jt.fromNumber(e,!0))}static fromBits(e,t){return new ar({i:e,t:t})}static fromString(e,t){return new ar(jt.fromString(e,!0,t))}toExtendedJSON(){return{$timestamp:{t:this.t,i:this.i}}}static fromExtendedJSON(e){const t=jt.isLong(e.$timestamp.i)?e.$timestamp.i.getLowBitsUnsigned():e.$timestamp.i,r=jt.isLong(e.$timestamp.t)?e.$timestamp.t.getLowBitsUnsigned():e.$timestamp.t;return new ar({t:r,i:t})}inspect(e,t,r){return r??=He,`new Timestamp({ t: ${r(this.t,t)}, i: ${r(this.i,t)} })`}}jt.fromNumber(Qe),jt.fromNumber(Ze),new Set(["$db","$ref","$id","$clusterTime"]);const ur={$oid:nr,$binary:St,$uuid:St,$symbol:ir,$numberInt:Zt,$numberDecimal:Yt,$numberDouble:Qt,$numberLong:jt,$minKey:er,$maxKey:Xt,$regex:or,$regularExpression:or,$timestamp:ar};function cr(e,t={}){if("number"==typeof e){const r=e<=ze&&e>=Ke,n=e<=Je&&e>=Ye;if(t.relaxed||t.legacy)return e;if(Number.isInteger(e)&&!Object.is(e,-0)){if(r)return new Zt(e);if(n)return t.useBigInt64?BigInt(e):jt.fromNumber(e)}return new Qt(e)}if(null==e||"object"!=typeof e)return e;if(e.$undefined)return null;const r=Object.keys(e).filter((t=>t.startsWith("$")&&null!=e[t]));for(let n=0;n<r.length;n++){const o=ur[r[n]];if(o)return o.fromExtendedJSON(e,t)}if(null!=e.$date){const r=e.$date,n=new Date;if(t.legacy)if("number"==typeof r)n.setTime(r);else if("string"==typeof r)n.setTime(Date.parse(r));else{if("bigint"!=typeof r)throw new tt("Unrecognized type for EJSON date: "+typeof r);n.setTime(Number(r))}else if("string"==typeof r)n.setTime(Date.parse(r));else if(jt.isLong(r))n.setTime(r.toNumber());else if("number"==typeof r&&t.relaxed)n.setTime(r);else{if("bigint"!=typeof r)throw new tt("Unrecognized type for EJSON date: "+typeof r);n.setTime(Number(r))}return n}if(null!=e.$code){const t=Object.assign({},e);return e.$scope&&(t.$scope=cr(e.$scope)),At.fromExtendedJSON(e)}if(function(e){return null!=e&&"object"==typeof e&&"$id"in e&&null!=e.$id&&"$ref"in e&&"string"==typeof e.$ref&&(!("$db"in e)||"$db"in e&&"string"==typeof e.$db)}(e)||e.$dbPointer){const t=e.$ref?e:e.$dbPointer;if(t instanceof Rt)return t;const r=Object.keys(t).filter((e=>e.startsWith("$")));let n=!0;if(r.forEach((e=>{-1===["$ref","$id","$db"].indexOf(e)&&(n=!1)})),n)return Rt.fromExtendedJSON(t)}return e}function lr(e){const t=e.toISOString();return 0!==e.getUTCMilliseconds()?t:t.slice(0,-5)+"Z"}function fr(e,t){if(e instanceof Map||Ve(e)){const r=Object.create(null);for(const[t,n]of e){if("string"!=typeof t)throw new Xe("Can only serialize maps with string keys");r[t]=n}return fr(r,t)}if(("object"==typeof e||"function"==typeof e)&&null!==e){const r=t.seenObjects.findIndex((t=>t.obj===e));if(-1!==r){const e=t.seenObjects.map((e=>e.propertyName)),n=e.slice(0,r).map((e=>`${e} -> `)).join(""),o=e[r],i=" -> "+e.slice(r+1,e.length-1).map((e=>`${e} -> `)).join(""),s=e[e.length-1],a=" ".repeat(n.length+o.length/2),u="-".repeat(i.length+(o.length+s.length)/2-1);throw new Xe(`Converting circular structure to EJSON:\n ${n}${o}${i}${s}\n ${a}\\${u}/`)}t.seenObjects[t.seenObjects.length-1].obj=e}if(Array.isArray(e))return function(e,t){return e.map(((e,r)=>{t.seenObjects.push({propertyName:`index ${r}`,obj:null});try{return fr(e,t)}finally{t.seenObjects.pop()}}))}(e,t);if(void 0===e)return null;if(e instanceof Date||((r=e)instanceof Date||"[object Date]"===Object.prototype.toString.call(r))){const r=e.getTime(),n=r>-1&&r<2534023188e5;return t.legacy?t.relaxed&&n?{$date:e.getTime()}:{$date:lr(e)}:t.relaxed&&n?{$date:lr(e)}:{$date:{$numberLong:e.getTime().toString()}}}var r,n;if(!("number"!=typeof e||t.relaxed&&isFinite(e))){if(Number.isInteger(e)&&!Object.is(e,-0)){if(e>=Ke&&e<=ze)return{$numberInt:e.toString()};if(e>=Ye&&e<=Je)return{$numberLong:e.toString()}}return{$numberDouble:Object.is(e,-0)?"-0.0":e.toString()}}if("bigint"==typeof e)return t.relaxed?Number(BigInt.asIntN(64,e)):{$numberLong:BigInt.asIntN(64,e).toString()};if(e instanceof RegExp||((n=e)instanceof RegExp||"[object RegExp]"===Object.prototype.toString.call(n))){let r=e.flags;if(void 0===r){const t=e.toString().match(/[gimuy]*$/);t&&(r=t[0])}return new or(e.source,r).toExtendedJSON(t)}return null!=e&&"object"==typeof e?function(e,t){if(null==e||"object"!=typeof e)throw new Xe("not an object instance");const r=e._bsontype;if(void 0===r){const r={};for(const n of Object.keys(e)){t.seenObjects.push({propertyName:n,obj:null});try{const o=fr(e[n],t);"__proto__"===n?Object.defineProperty(r,n,{value:o,writable:!0,enumerable:!0,configurable:!0}):r[n]=o}finally{t.seenObjects.pop()}}return r}if(null!=e&&"object"==typeof e&&"string"==typeof e._bsontype&&e[Ge]!==$e)throw new et;if(function(e){return null!=e&&"object"==typeof e&&"_bsontype"in e&&"string"==typeof e._bsontype}(e)){let n=e;if("function"!=typeof n.toExtendedJSON){const t=dr[e._bsontype];if(!t)throw new Xe("Unrecognized or invalid _bsontype: "+e._bsontype);n=t(n)}return"Code"===r&&n.scope?n=new At(n.code,fr(n.scope,t)):"DBRef"===r&&n.oid&&(n=new Rt(fr(n.collection,t),fr(n.oid,t),fr(n.db,t),fr(n.fields,t))),n.toExtendedJSON(t)}throw new Xe("_bsontype must be a string, but was: "+typeof r)}(e,t):e}const dr={Binary:e=>new St(e.value(),e.sub_type),Code:e=>new At(e.code,e.scope),DBRef:e=>new Rt(e.collection||e.namespace,e.oid,e.db,e.fields),Decimal128:e=>new Yt(e.bytes),Double:e=>new Qt(e.value),Int32:e=>new Zt(e.value),Long:e=>jt.fromBits(null!=e.low?e.low:e.low_,null!=e.low?e.high:e.high_,null!=e.low?e.unsigned:e.unsigned_),MaxKey:()=>new Xt,MinKey:()=>new er,ObjectId:e=>new nr(e),BSONRegExp:e=>new or(e.pattern,e.options),BSONSymbol:e=>new ir(e.value),Timestamp:e=>ar.fromBits(e.low,e.high)};function hr(e,t){const r={useBigInt64:t?.useBigInt64??!1,relaxed:t?.relaxed??!0,legacy:t?.legacy??!1};return JSON.parse(e,((e,t)=>{if(-1!==e.indexOf("\0"))throw new Xe(`BSON Document field names cannot contain null bytes, found: ${JSON.stringify(e)}`);return cr(t,r)}))}function pr(e,t,r,n){null!=r&&"object"==typeof r&&(n=r,r=0),null==t||"object"!=typeof t||Array.isArray(t)||(n=t,t=void 0,r=0);const o=fr(e,Object.assign({relaxed:!0,legacy:!1},n,{seenObjects:[{propertyName:"(root)",obj:null}]}));return JSON.stringify(o,t,r)}const vr=Object.create(null);vr.parse=hr,vr.stringify=pr,vr.serialize=function(e,t){return t=t||{},JSON.parse(pr(e,t))},vr.deserialize=function(e,t){return t=t||{},hr(JSON.stringify(e),t)},Object.freeze(vr);function yr(e,t){try{return _t.getNonnegativeInt32LE(e,t)}catch(e){throw new rt("BSON size cannot be negative",t,{cause:e})}}function mr(e,t){let r=t;for(;0!==e[r];r++);if(r===e.length-1)throw new rt("Null terminator not found",t);return r}const gr=Object.create(null);gr.parseToElements=function(e,t=0){if(t??=0,e.length<5)throw new rt(`Input must be at least 5 bytes, got ${e.length} bytes`,t);const r=yr(e,t);if(r>e.length-t)throw new rt(`Parsed documentSize (${r} bytes) does not match input length (${e.length} bytes)`,t);if(0!==e[t+r-1])throw new rt("BSON documents must end in 0x00",t+r);const n=[];let o=t+4;for(;o<=r+t;){const i=e[o];if(o+=1,0===i){if(o-t!==r)throw new rt("Invalid 0x00 type byte",o);break}const s=o,a=mr(e,o)-s;let u;if(o+=a+1,1===i||18===i||9===i||17===i)u=8;else if(16===i)u=4;else if(7===i)u=12;else if(19===i)u=16;else if(8===i)u=1;else if(10===i||6===i||127===i||255===i)u=0;else if(11===i)u=mr(e,mr(e,o)+1)+1-o;else if(3===i||4===i||15===i)u=yr(e,o);else{if(2!==i&&5!==i&&12!==i&&13!==i&&14!==i)throw new rt(`Invalid 0x${i.toString(16).padStart(2,"0")} type byte`,o);u=yr(e,o)+4,5===i&&(u+=1),12===i&&(u+=12)}if(u>r)throw new rt("value reports length larger than document",o);n.push([i,s,a,o,u]),o+=u}return n},gr.ByteUtils=vt,gr.NumberUtils=_t,Object.freeze(gr);vt.allocate(17825792);var br=function(){function e(e,t){this._stages=[],e&&t&&(this._db=e,this._request=Vr.createRequest(this._db.config),this._collectionName=t)}return e.prototype.end=function(){return e=this,t=void 0,n=function(){var e;return function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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(t){switch(t.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(e=t.sent())&&e.data&&e.data.list?[2,{requestId:e.requestId,data:JSON.parse(e.data.list).map(vr.parse)}]:[2,e]}}))},new((r=void 0)||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}));var e,t,r,n},e.prototype.unwrap=function(){return this._stages},e.prototype.done=function(){return this._stages.map((function(e){var t,r=e.stageKey,n=e.stageValue;return(t={})[r]=JSON.parse(n),t}))},e.prototype._pipe=function(e,t){return this._stages.push({stageKey:"$".concat(e),stageValue:JSON.stringify(t)}),this},e.prototype.addFields=function(e){return this._pipe("addFields",e)},e.prototype.bucket=function(e){return this._pipe("bucket",e)},e.prototype.bucketAuto=function(e){return this._pipe("bucketAuto",e)},e.prototype.count=function(e){return this._pipe("count",e)},e.prototype.geoNear=function(e){return e.query&&(e.query=je.encode(e.query)),e.distanceMultiplier&&"number"==typeof e.distanceMultiplier&&(e.distanceMultiplier=e.distanceMultiplier),e.near&&(e.near=new oe(e.near.longitude,e.near.latitude).toJSON()),this._pipe("geoNear",e)},e.prototype.group=function(e){return this._pipe("group",e)},e.prototype.limit=function(e){return this._pipe("limit",e)},e.prototype.match=function(e){return this._pipe("match",je.encode(e))},e.prototype.project=function(e){return this._pipe("project",e)},e.prototype.lookup=function(e){return this._pipe("lookup",e)},e.prototype.replaceRoot=function(e){return this._pipe("replaceRoot",e)},e.prototype.sample=function(e){return this._pipe("sample",e)},e.prototype.skip=function(e){return this._pipe("skip",e)},e.prototype.sort=function(e){return this._pipe("sort",e)},e.prototype.sortByCount=function(e){return this._pipe("sortByCount",e)},e.prototype.unwind=function(e){return this._pipe("unwind",e)},e}(),wr=br,_r=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};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)}}(),Sr=function(e){function t(t,r){return e.call(this,t,r)||this}return _r(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return this._coll},enumerable:!1,configurable:!0}),t.prototype.doc=function(e){if("string"!=typeof e&&"number"!=typeof e)throw new Error("docId必须为字符串或数字");return new De(this._db,this._coll,e)},t.prototype.add=function(e,t){return new De(this._db,this._coll,void 0).create(e,t)},t.prototype.aggregate=function(){return new wr(this._db,this._coll)},t}(Be),Er={eq:function(e){return new he(fe.EQ,[e])},neq:function(e){return new he(fe.NEQ,[e])},lt:function(e){return new he(fe.LT,[e])},lte:function(e){return new he(fe.LTE,[e])},gt:function(e){return new he(fe.GT,[e])},gte:function(e){return new he(fe.GTE,[e])},in:function(e){return new he(fe.IN,e)},nin:function(e){return new he(fe.NIN,e)},all:function(e){return new he(fe.ALL,e)},elemMatch:function(e){return new he(fe.ELEM_MATCH,[e])},exists:function(e){return new he(fe.EXISTS,[e])},size:function(e){return new he(fe.SIZE,[e])},mod:function(e){return new he(fe.MOD,[e])},geoNear:function(e){return new he(fe.GEO_NEAR,[e])},geoWithin:function(e){return new he(fe.GEO_WITHIN,[e])},geoIntersects:function(e){return new he(fe.GEO_INTERSECTS,[e])},and:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=B(arguments[0])?arguments[0]:Array.from(arguments);return new ce(se.AND,r)},nor:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=B(arguments[0])?arguments[0]:Array.from(arguments);return new ce(se.NOR,r)},or:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=B(arguments[0])?arguments[0]:Array.from(arguments);return new ce(se.OR,r)},not:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=B(arguments[0])?arguments[0]:Array.from(arguments);return new ce(se.NOT,r)},set:function(e){return new ae(ee.SET,[e])},remove:function(){return new ae(ee.REMOVE,[])},inc:function(e){return new ae(ee.INC,[e])},mul:function(e){return new ae(ee.MUL,[e])},push:function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];if(q(t[0])&&t[0].hasOwnProperty("each")){var n=t[0];e={$each:n.each,$position:n.position,$sort:n.sort,$slice:n.slice}}else e=B(t[0])?t[0]:Array.from(t);return new ae(ee.PUSH,e)},pull:function(e){return new ae(ee.PULL,e)},pullAll:function(e){return new ae(ee.PULL_ALL,e)},pop:function(){return new ae(ee.POP,[])},shift:function(){return new ae(ee.SHIFT,[])},unshift:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=B(arguments[0])?arguments[0]:Array.from(arguments);return new ae(ee.UNSHIFT,r)},addToSet:function(e){return new ae(ee.ADD_TO_SET,e)},rename:function(e){return new ae(ee.RENAME,[e])},bit:function(e){return new ae(ee.BIT,[e])},max:function(e){return new ae(ee.MAX,[e])},min:function(e){return new ae(ee.MIN,[e])},expr:function(e){return{$expr:e}},jsonSchema:function(e){return{$jsonSchema:e}},text:function(e){return"string"===j(e)?{$search:e.search}:{$search:e.search,$language:e.language,$caseSensitive:e.caseSensitive,$diacriticSensitive:e.diacriticSensitive}},aggregate:{pipeline:function(){return new wr},abs:function(e){return new Ir("abs",e)},add:function(e){return new Ir("add",e)},ceil:function(e){return new Ir("ceil",e)},divide:function(e){return new Ir("divide",e)},exp:function(e){return new Ir("exp",e)},floor:function(e){return new Ir("floor",e)},ln:function(e){return new Ir("ln",e)},log:function(e){return new Ir("log",e)},log10:function(e){return new Ir("log10",e)},mod:function(e){return new Ir("mod",e)},multiply:function(e){return new Ir("multiply",e)},pow:function(e){return new Ir("pow",e)},sqrt:function(e){return new Ir("sqrt",e)},subtract:function(e){return new Ir("subtract",e)},trunc:function(e){return new Ir("trunc",e)},arrayElemAt:function(e){return new Ir("arrayElemAt",e)},arrayToObject:function(e){return new Ir("arrayToObject",e)},concatArrays:function(e){return new Ir("concatArrays",e)},filter:function(e){return new Ir("filter",e)},in:function(e){return new Ir("in",e)},indexOfArray:function(e){return new Ir("indexOfArray",e)},isArray:function(e){return new Ir("isArray",e)},map:function(e){return new Ir("map",e)},range:function(e){return new Ir("range",e)},reduce:function(e){return new Ir("reduce",e)},reverseArray:function(e){return new Ir("reverseArray",e)},size:function(e){return new Ir("size",e)},slice:function(e){return new Ir("slice",e)},zip:function(e){return new Ir("zip",e)},and:function(e){return new Ir("and",e)},not:function(e){return new Ir("not",e)},or:function(e){return new Ir("or",e)},cmp:function(e){return new Ir("cmp",e)},eq:function(e){return new Ir("eq",e)},gt:function(e){return new Ir("gt",e)},gte:function(e){return new Ir("gte",e)},lt:function(e){return new Ir("lt",e)},lte:function(e){return new Ir("lte",e)},neq:function(e){return new Ir("ne",e)},cond:function(e){return new Ir("cond",e)},ifNull:function(e){return new Ir("ifNull",e)},switch:function(e){return new Ir("switch",e)},dateFromParts:function(e){return new Ir("dateFromParts",e)},dateFromString:function(e){return new Ir("dateFromString",e)},dayOfMonth:function(e){return new Ir("dayOfMonth",e)},dayOfWeek:function(e){return new Ir("dayOfWeek",e)},dayOfYear:function(e){return new Ir("dayOfYear",e)},isoDayOfWeek:function(e){return new Ir("isoDayOfWeek",e)},isoWeek:function(e){return new Ir("isoWeek",e)},isoWeekYear:function(e){return new Ir("isoWeekYear",e)},millisecond:function(e){return new Ir("millisecond",e)},minute:function(e){return new Ir("minute",e)},month:function(e){return new Ir("month",e)},second:function(e){return new Ir("second",e)},hour:function(e){return new Ir("hour",e)},week:function(e){return new Ir("week",e)},year:function(e){return new Ir("year",e)},literal:function(e){return new Ir("literal",e)},mergeObjects:function(e){return new Ir("mergeObjects",e)},objectToArray:function(e){return new Ir("objectToArray",e)},allElementsTrue:function(e){return new Ir("allElementsTrue",e)},anyElementTrue:function(e){return new Ir("anyElementTrue",e)},setDifference:function(e){return new Ir("setDifference",e)},setEquals:function(e){return new Ir("setEquals",e)},setIntersection:function(e){return new Ir("setIntersection",e)},setIsSubset:function(e){return new Ir("setIsSubset",e)},setUnion:function(e){return new Ir("setUnion",e)},concat:function(e){return new Ir("concat",e)},dateToString:function(e){return new Ir("dateToString",e)},indexOfBytes:function(e){return new Ir("indexOfBytes",e)},indexOfCP:function(e){return new Ir("indexOfCP",e)},split:function(e){return new Ir("split",e)},strLenBytes:function(e){return new Ir("strLenBytes",e)},strLenCP:function(e){return new Ir("strLenCP",e)},strcasecmp:function(e){return new Ir("strcasecmp",e)},substr:function(e){return new Ir("substr",e)},substrBytes:function(e){return new Ir("substrBytes",e)},substrCP:function(e){return new Ir("substrCP",e)},toLower:function(e){return new Ir("toLower",e)},toUpper:function(e){return new Ir("toUpper",e)},meta:function(e){return new Ir("meta",e)},addToSet:function(e){return new Ir("addToSet",e)},avg:function(e){return new Ir("avg",e)},first:function(e){return new Ir("first",e)},last:function(e){return new Ir("last",e)},max:function(e){return new Ir("max",e)},min:function(e){return new Ir("min",e)},push:function(e){return new Ir("push",e)},stdDevPop:function(e){return new Ir("stdDevPop",e)},stdDevSamp:function(e){return new Ir("stdDevSamp",e)},sum:function(e){return new Ir("sum",e)},let:function(e){return new Ir("let",e)}},project:{slice:function(e){return new Or("slice",e)},elemMatch:function(e){return new Or("elemMatch",e)}}},Ir=function(e,t){this["$"+e]=t},Or=function(e,t){this["$"+e]=t},Tr=function(){function e(e){var t=e.regexp,r=e.options;if(!t)throw new TypeError("regexp must be a string");this.$regex=t,this.$options=r}return e.prototype.parse=function(){return{$regex:this.$regex,$options:this.$options}},Object.defineProperty(e.prototype,"_internalType",{get:function(){return D},enumerable:!1,configurable:!0}),e}();function Ar(e){return new Tr(e)}var Rr="insert document failed",Pr="DATABASE_TRANSACTION_CONFLICT",Cr=function(){return Cr=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Cr.apply(this,arguments)},Nr=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},xr=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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])}}},Lr="database.updateDocInTransaction",Ur=function(){function e(e,t,r){this._coll=t,this.id=r,this._transaction=e,this._request=this._transaction.getRequestMethod(),this._transactionId=this._transaction.getTransactionId()}return e.prototype.create=function(e){return Nr(this,void 0,void 0,(function(){var t,r,n,o;return xr(this,(function(i){switch(i.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,data:vr.stringify(Se(e),{relaxed:!1})},this.id&&(t._id=this.id),[4,this._request.send("database.insertDocInTransaction",t)];case 1:if((r=i.sent()).code)throw r;if(n=vr.parse(r.inserted),1==(o=vr.parse(r.ok))&&1==n)return[2,Cr(Cr({},r),{ok:o,inserted:n})];throw new Error(Rr)}}))}))},e.prototype.get=function(){return Nr(this,void 0,void 0,(function(){var e,t;return xr(this,(function(r){switch(r.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.getInTransaction",e)];case 1:if((t=r.sent()).code)throw t;return[2,{data:"null"!==t.data?re.formatField(vr.parse(t.data)):vr.parse(t.data),requestId:t.requestId}]}}))}))},e.prototype.set=function(e){return Nr(this,void 0,void 0,(function(){var t,r;return xr(this,(function(n){switch(n.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:vr.stringify(Se(e),{relaxed:!1}),upsert:!0},[4,this._request.send(Lr,t)];case 1:if((r=n.sent()).code)throw r;return[2,Cr(Cr({},r),{updated:vr.parse(r.updated),upserted:r.upserted?JSON.parse(r.upserted):null})]}}))}))},e.prototype.update=function(e){return Nr(this,void 0,void 0,(function(){var t,r;return xr(this,(function(n){switch(n.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:vr.stringify(xe.encode(e),{relaxed:!1})},[4,this._request.send(Lr,t)];case 1:if((r=n.sent()).code)throw r;return[2,Cr(Cr({},r),{updated:vr.parse(r.updated)})]}}))}))},e.prototype.delete=function(){return Nr(this,void 0,void 0,(function(){var e,t;return xr(this,(function(r){switch(r.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.deleteDocInTransaction",e)];case 1:if((t=r.sent()).code)throw t;return[2,Cr(Cr({},t),{deleted:vr.parse(t.deleted)})]}}))}))},e}(),kr=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};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)}}(),Dr=function(e){function t(t,r){return e.call(this,t,r)||this}return kr(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return this._coll},enumerable:!1,configurable:!0}),t.prototype.doc=function(e){if("string"!=typeof e&&"number"!=typeof e)throw new Error("docId必须为字符串或数字");return new Ur(this._transaction,this._coll,e)},t.prototype.add=function(e){var t;return void 0!==e._id&&(t=e._id),new Ur(this._transaction,this._coll,t).create(e)},t}((function(e,t){this._coll=t,this._transaction=e})),jr=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},qr=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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])}}},Mr=function(){function e(e){this._db=e,this._request=Vr.createRequest(this._db.config),this.aborted=!1,this.commited=!1,this.inited=!1}return e.prototype.init=function(){return jr(this,void 0,void 0,(function(){var e;return qr(this,(function(t){switch(t.label){case 0:return[4,this._request.send("database.startTransaction")];case 1:if((e=t.sent()).code)throw e;return this.inited=!0,this._id=e.transactionId,[2]}}))}))},e.prototype.collection=function(e){if(!e)throw new Error("Collection name is required");return new Dr(this,e)},e.prototype.getTransactionId=function(){return this._id},e.prototype.getRequestMethod=function(){return this._request},e.prototype.commit=function(){return jr(this,void 0,void 0,(function(){var e,t;return qr(this,(function(r){switch(r.label){case 0:return e={transactionId:this._id},[4,this._request.send("database.commitTransaction",e)];case 1:if((t=r.sent()).code)throw t;return this.commited=!0,[2,t]}}))}))},e.prototype.rollback=function(e){return jr(this,void 0,void 0,(function(){var t,r;return qr(this,(function(n){switch(n.label){case 0:return t={transactionId:this._id},[4,this._request.send("database.abortTransaction",t)];case 1:if((r=n.sent()).code)throw r;return this.aborted=!0,this.abortReason=e,[2,r]}}))}))},e}();function Br(){return jr(this,void 0,void 0,(function(){var e;return qr(this,(function(t){switch(t.label){case 0:return[4,(e=new Mr(this)).init()];case 1:return t.sent(),[2,e]}}))}))}function Wr(e,t){return void 0===t&&(t=3),jr(this,void 0,void 0,(function(){var r,n,o,i,s=this;return qr(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,10]),[4,(r=new Mr(this)).init()];case 1:return a.sent(),[4,e(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(e){return jr(s,void 0,void 0,(function(){return qr(this,(function(t){switch(t.label){case 0:if(r.aborted||r.commited)return[3,5];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,r.rollback()];case 2:case 3:return t.sent(),[3,4];case 4:throw e;case 5:if(!0===r.aborted)throw r.abortReason;throw e}}))}))},t<=0?[4,i(o)]:[3,6];case 5:a.sent(),a.label=6;case 6:return o&&o.code===Pr?[4,Wr.bind(this)(e,--t)]:[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 Fr,Vr=function(){function e(e){this.config=e,this.Geo=i,this.serverDate=X,this.command=Er,this.RegExp=Ar,this.startTransaction=Br,this.runTransaction=Wr,this.logicCommand=ce,this.updateCommand=ae,this.queryCommand=he}return e.createRequest=function(t){var r=new e.reqClass(t),n=r.send;return r.send=function(e,r){return t.instance&&(r.instance=t.instance),t.database&&(r.database=t.database),n.call(this,e,r)},r},e.prototype.collection=function(e){if(!e)throw new Error("Collection name is required");return new Sr(this,e)},e.prototype.createCollection=function(t){var r={collectionName:t};return e.createRequest(this.config).send("database.addCollection",r)},e}(),Hr=(Fr=function(e,t){return Fr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},Fr(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}Fr(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),$r=function(){return $r=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},$r.apply(this,arguments)},Gr=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},zr=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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])}}},Kr={filterRes:function(e){return delete e.header,delete e.statusCode,e},flattenResData:function(e){if("object"==typeof e.data&&null!==e.data){var t=$r($r({},e),e.data);return delete t.data,t}return e},safeParseEJSON:function(e){if("string"!=typeof e)return e;try{return vr.parse(e)}catch(t){return e}},buildQueryParams:function(e){return Object.entries(e).filter((function(e){e[0];var t=e[1];return null!=t&&""!==t})).map((function(e){var t=e[0],r=e[1],n="object"==typeof r?JSON.stringify(r):String(r);return"".concat(encodeURIComponent(t),"=").concat(encodeURIComponent(n))})).join("&")},getUrlPrefix:function(e){var t=(null==e?void 0:e.instance)||"(default)",r=(null==e?void 0:e.database)||"(default)";return"/database/instances/".concat(t,"/databases/").concat(r)},"database.queryDocument":function(e){var t,r,n,o;return Gr(this,void 0,void 0,(function(){var i,s,a,u;return zr(this,(function(c){switch(c.label){case 0:return i=!!(null===(t=e.query)||void 0===t?void 0:t._id),s=Kr.buildQueryParams($r({projection:e.projection,transactionId:e.transactionId},i?{}:{offset:null!==(r=e.offset)&&void 0!==r?r:0,limit:null!==(n=e.limit)&&void 0!==n?n:100,order:e.order,query:e.query?vr.stringify(e.query,{relaxed:!1}):void 0})),a="".concat(Kr.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents?").concat(s),i&&(a="".concat(Kr.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents/").concat(e.query._id,"?").concat(s)),[4,this.gateWay({url:a,method:"GET"})];case 1:return(u=c.sent()).data=Kr.safeParseEJSON(JSON.stringify(u.data)),!i||u.code||(null===(o=u.data)||void 0===o?void 0:o.code)?[2,Kr.filterRes(u)]:[2,$r($r({},u),{data:{list:[u.data]}})]}}))}))},"database.addDocument":function(e){var t,r;return Gr(this,void 0,void 0,(function(){var n;return zr(this,(function(o){switch(o.label){case 0:return[4,this.gateWay({url:"".concat(Kr.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents"),method:"POST",data:$r({data:Array.isArray(e.data)?e.data:[e.data]},e.transactionId&&{transactionId:e.transactionId})})];case 1:return n=o.sent(),!Array.isArray(e.data)&&(null===(r=null===(t=n.data)||void 0===t?void 0:t.insertedIds)||void 0===r?void 0:r[0])&&(n=$r($r({},n),{data:$r({_id:n.data.insertedIds[0]},n.data)})),[2,Kr.filterRes(n)]}}))}))},"database.updateDocument":function(e){return Gr(this,void 0,void 0,(function(){var t;return zr(this,(function(r){switch(r.label){case 0:return[4,this.gateWay({url:"".concat(Kr.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents"),method:"PATCH",data:$r({query:e.query,data:e.data,multi:!!e.multi,upsert:!!e.upsert,replaceMode:!!e.replaceMode},e.transactionId&&{transactionId:e.transactionId})})];case 1:return t=r.sent(),[2,Kr.filterRes(t)]}}))}))},"database.deleteDocument":function(e){return Gr(this,void 0,void 0,(function(){var t;return zr(this,(function(r){switch(r.label){case 0:return[4,this.gateWay({url:"".concat(Kr.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents/remove"),method:"POST",data:$r({query:e.query,multi:!!e.multi},e.transactionId&&{transactionId:e.transactionId})})];case 1:return t=r.sent(),[2,Kr.filterRes(t)]}}))}))},"database.countDocument":function(e){return Gr(this,void 0,void 0,(function(){var t,r;return zr(this,(function(n){switch(n.label){case 0:return t=Kr.buildQueryParams({count:!0,query:e.query?vr.stringify(e.query,{relaxed:!1}):void 0}),[4,this.gateWay({url:"".concat(Kr.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents?").concat(t),method:"GET"})];case 1:return r=n.sent(),[2,Kr.filterRes(r)]}}))}))},"database.addCollection":function(e){return Gr(this,void 0,void 0,(function(){var t;return zr(this,(function(r){switch(r.label){case 0:return[4,this.gateWay({url:"".concat(Kr.getUrlPrefix(e),"/collections"),method:"POST",data:{collectionName:e.collectionName}})];case 1:return t=r.sent(),[2,Kr.filterRes(t)]}}))}))},"database.aggregate":function(e){var t;return Gr(this,void 0,void 0,(function(){var r,n;return zr(this,(function(o){switch(o.label){case 0:return r=e.stages.map((function(e){var t,r;try{var n="string"==typeof e.stageValue?JSON.parse(e.stageValue):e.stageValue;return(t={})[e.stageKey]=vr.serialize(n),t}catch(t){return(r={})[e.stageKey]=e.stageValue,r}})),[4,this.gateWay({url:"".concat(Kr.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents/aggregations"),method:"POST",data:{pipeline:r}})];case 1:return n=o.sent(),Array.isArray(null===(t=n.data)||void 0===t?void 0:t.list)&&(n.data.list=JSON.stringify(n.data.list.map((function(e){return JSON.stringify(e)})))),[2,Kr.filterRes(n)]}}))}))},"database.startTransaction":function(e){return Gr(this,void 0,void 0,(function(){var t;return zr(this,(function(r){switch(r.label){case 0:return[4,this.gateWay({url:"".concat(Kr.getUrlPrefix(e),"/transactions"),method:"POST"})];case 1:return t=r.sent(),[2,Kr.filterRes(Kr.flattenResData(t))]}}))}))},"database.commitTransaction":function(e){return Gr(this,void 0,void 0,(function(){var t;return zr(this,(function(r){switch(r.label){case 0:return[4,this.gateWay({url:"".concat(Kr.getUrlPrefix(e),"/transactions/").concat(e.transactionId,"/commit"),method:"POST"})];case 1:return t=r.sent(),[2,Kr.filterRes(t)]}}))}))},"database.abortTransaction":function(e){return Gr(this,void 0,void 0,(function(){var t;return zr(this,(function(r){switch(r.label){case 0:return[4,this.gateWay({url:"".concat(Kr.getUrlPrefix(e),"/transactions/").concat(e.transactionId,"/rollback"),method:"POST"})];case 1:return t=r.sent(),[2,Kr.filterRes(t)]}}))}))},"database.getInTransaction":function(e){var t;return Gr(this,void 0,void 0,(function(){var r;return zr(this,(function(n){switch(n.label){case 0:return[4,Kr["database.queryDocument"].call(this,e)];case 1:return"object"==typeof(r=n.sent()).data&&null!==r.data?(null===(t=r.data)||void 0===t?void 0:t.code)?[2,Kr.flattenResData(r)]:[2,$r($r({},r),{data:JSON.stringify(r.data)})]:[2,r]}}))}))},"database.updateDocInTransaction":function(e){return Gr(this,void 0,void 0,(function(){var t;return zr(this,(function(r){switch(r.label){case 0:return e.data=Kr.safeParseEJSON(e.data),[4,Kr["database.updateDocument"].call(this,e)];case 1:return t=r.sent(),[2,Kr.flattenResData(t)]}}))}))},"database.deleteDocInTransaction":function(e){return Gr(this,void 0,void 0,(function(){var t;return zr(this,(function(r){switch(r.label){case 0:return[4,Kr["database.deleteDocument"].call(this,e)];case 1:return t=r.sent(),[2,Kr.flattenResData(t)]}}))}))},"database.insertDocInTransaction":function(e){var t;return Gr(this,void 0,void 0,(function(){var r,n;return zr(this,(function(o){switch(o.label){case 0:return e.data=Kr.safeParseEJSON(e.data),[4,Kr["database.addDocument"].call(this,e)];case 1:return"object"==typeof(r=o.sent()).data&&null!==r.data?(n=!!(null===(t=r.data)||void 0===t?void 0:t._id),r=$r($r($r({},r),{inserted:n?1:0,ok:n?1:0}),r.data)):r=$r({inserted:0,ok:0},r),delete r.data,[2,r]}}))}))},"database.runCommands":function(e){return Gr(this,void 0,void 0,(function(){var t;return zr(this,(function(r){switch(r.label){case 0:return[4,this.gateWay({url:"".concat(Kr.getUrlPrefix(e),"/commands"),method:"POST",data:$r({commands:vr.serialize(e.commands)},e.transactionId&&{transactionId:e.transactionId})})];case 1:"object"==typeof(t=r.sent()).data&&null!==t.data&&(delete(t=$r($r({},t),t.data)).data,delete t.request_id);try{t=vr.deserialize(t)}catch(e){}return[2,Kr.filterRes(t)]}}))}))}},Jr={name:"database",entity:{database:function(e){var t=this.platform,r=t.adapter,n=t.runtime,o=function(e){function t(t){return e.call(this,t)||this}return Hr(t,e),t.prototype.send=function(t,r){return Gr(this,void 0,void 0,(function(){var n;return zr(this,(function(o){switch(o.label){case 0:return n=null,"GATEWAY"===this.config.endPointMode&&Kr[t]?[4,Kr[t].call(this,r)]:[3,2];case 1:return n=o.sent(),[3,4];case 2:return[4,e.prototype.send.call(this,t,r)];case 3:n=o.sent(),o.label=4;case 4:return[2,n]}}))}))},t}(this.request.constructor);return Vr.reqClass=o,Vr.getAccessToken=this.authInstance?this.authInstance.getAccessToken.bind(this.authInstance):function(){return""},Vr.runtime=n,this.wsClientClass&&(Vr.wsClass=r.wsClass,Vr.wsClientClass=this.wsClientClass),Vr.ws||(Vr.ws=null),new(function(e){function t(t){return e.call(this,t)||this}return Hr(t,e),t.prototype.runCommands=function(e){return Gr(this,void 0,void 0,(function(){return zr(this,(function(t){return[2,Vr.createRequest(this.config).send("database.runCommands",e)]}))}))},t}(Vr))($r($r($r({},this.config),{_fromApp:this}),e))}}};try{cloudbase.registerComponent(Jr)}catch(e){}function Yr(e){try{e.registerComponent(Jr)}catch(e){console.warn(e)}}try{window.registerDatabase=Yr}catch(e){}},7596:function(e,t,r){"use strict";r.r(t),r.d(t,{registerCloudrun:function(){return d},requestContainer:function(){return c}});var n=r(3616),o=function(){return o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},o.apply(this,arguments)},i=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},s=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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(e,t){var r;return i(this,void 0,void 0,(function(){var n,i,a,u,c,l,f,d,h,p,v,y,m,g,b;return s(this,(function(s){switch(s.label){case 0:if(n=e.name,i=e.data,a=e.path,u=void 0===a?"":a,c=e.method,l=e.header,f=void 0===l?{}:l,d=this.getEndPointWithKey("GATEWAY"),h=d.BASE_URL,p=d.PROTOCOL,v="".concat(p).concat(h,"/cloudrun/").concat(n),y=u.startsWith("/")?u:"/".concat(u),m=["GET","HEAD"].includes(null===(r=null==c?void 0:c.toUpperCase)||void 0===r?void 0:r.call(c)))try{g={};try{g=JSON.parse(i)}catch(e){g=i||{}}y="".concat(y).concat(y.includes("?")?"&":"?").concat(Object.keys(g).map((function(e){return"".concat(e,"=").concat(g[e])})).join("&"))}catch(e){}return[4,this.request.fetch(o(o({method:c||"POST",headers:Object.assign({},{"Content-Type":"application/json; charset=utf-8"},f)},m?{}:{body:i}),{url:"".concat(v).concat(y),customReqOpts:t}))];case 1:return b=s.sent(),"node-sdk"===(null==t?void 0:t.from)?[2,b]:[4,b.data];case 2:return[2,s.sent()]}}))}))}var l=new(function(){function e(){}return e.prototype.callContainer=function(e,t){return i(this,void 0,void 0,(function(){var r,n,i;return s(this,(function(s){switch(s.label){case 0:if(r=e.name,n=e.data,!r)throw new Error(JSON.stringify({code:a.INVALID_PARAMS,msg:"[".concat(u,".callContainer] invalid name")}));try{i=n?JSON.stringify(n):""}catch(e){throw new Error(JSON.stringify({code:a.INVALID_PARAMS,msg:"[".concat(u,".callContainer] invalid data")}))}return[4,c.call(this,o(o({},e),{data:i}),t)];case 1:return[2,s.sent()]}}))}))},e}()),f={name:u,entity:{callContainer:l.callContainer}};try{cloudbase.registerComponent(f)}catch(e){}function d(e){try{e.registerComponent(f)}catch(e){console.warn(e)}}try{window.registerCloudrun=d}catch(e){}},2363:function(e,t,r){"use strict";r.r(t),r.d(t,{registerFunctions:function(){return v}});var n=r(3616),o=r(7596),i=function(){return i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)},s=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},a=n._G.eX,u=n._G.Sg,c=n._G.vM,l=n.P6.execCallback,f=n.BM.D,d="functions",h=new(function(){function e(){}return e.prototype.callFunction=function(e,t,r){var s,c,f,h,p,v,y;return h=this,p=void 0,y=function(){var h,p,v,y,m,g,b,w,_,S,E,I,O,T,A,R,P,C,N,x,L,U;return function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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(k){switch(k.label){case 0:if(h=e.name,p=e.data,v=e.query,y=e.parse,m=e.search,g=e.type,b=e.path,w=void 0===b?"":b,_=e.method,S=e.header,E=void 0===S?{}:S,!h)throw new Error(JSON.stringify({code:u.INVALID_PARAMS,msg:"[".concat(d,".callFunction] invalid function name")}));try{I=p?JSON.stringify(p):""}catch(e){throw new Error(JSON.stringify({code:u.INVALID_PARAMS,msg:"[".concat(d,".callFunction] invalid data")}))}return"cloudrun"!==g?[3,2]:(O=n.P6.generateRequestId(),[4,o.requestContainer.call(this,{name:h,data:I,path:w,method:_,header:i(i({},E),{"X-Request-Id":O})})]);case 1:return[2,{result:L=k.sent(),requestId:O}];case 2:A=(T=this).request,R=T.config,P="functions.invokeFunction",C={inQuery:v,parse:y,search:m,function_name:h,request_data:I},N={},k.label=3;case 3:return k.trys.push([3,8,,9]),"GATEWAY"!==R.endPointMode?[3,5]:[4,A.gateWay(i(i({},e),{path:"functions"}),r)];case 4:return x=k.sent(),N=i({requestId:x.requestId},(null===(s=x.data)||void 0===s?void 0:s.code)?x.data:{data:{response_data:x.data}}),[3,7];case 5:return[4,A.send(P,C,{defaultQuery:(null===(c=null==p?void 0:p.params)||void 0===c?void 0:c.action)?{action:null===(f=null==p?void 0:p.params)||void 0===f?void 0:f.action}:{}},r)];case 6:N=k.sent(),k.label=7;case 7:if(N.code)return[2,l(t,null,N)];if(L=N.data.response_data,y||"GATEWAY"===R.endPointMode)return[2,l(t,null,{result:L,requestId:N.requestId})];try{return L=JSON.parse(N.data.response_data),[2,l(t,null,{result:L,requestId:N.requestId})]}catch(e){l(t,new Error("[".concat(a(),"][").concat(u.INVALID_PARAMS,"][").concat(d,".callFunction] response data must be json")))}return[3,9];case 8:return U=k.sent(),l(t,U),[3,9];case 9:return[2]}}))},new((v=void 0)||(v=Promise))((function(e,t){function r(e){try{o(y.next(e))}catch(e){t(e)}}function n(e){try{o(y.throw(e))}catch(e){t(e)}}function o(t){var o;t.done?e(t.value):(o=t.value,o instanceof v?o:new v((function(e){e(o)}))).then(r,n)}o((y=y.apply(h,p||[])).next())}))},function(e,t,r,n){var o,i=arguments.length,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);i>3&&s&&Object.defineProperty(t,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,Object]),s("design:returntype",Promise)],e.prototype,"callFunction",null),e}()),p={name:d,entity:{callFunction:h.callFunction}};try{cloudbase.registerComponent(p)}catch(e){}function v(e){try{e.registerComponent(p)}catch(e){console.warn(e)}}},9679:function(e,t,r){"use strict";r.r(t),r.d(t,{lazyGetEntity:function(){return h},registerModel:function(){return m}});var n=r(5304),o=r(3616),i={};for(var s in n)["default","lazyGetEntity","registerModel"].indexOf(s)<0&&(i[s]=function(e){return n[e]}.bind(0,s));r.d(t,i);var a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},a.apply(this,arguments)},u=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},c=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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",d=new WeakMap;function h(e){return new Proxy({},{get:function(t,r){var o=e.getEndPointWithKey("GATEWAY"),i=o.BASE_URL,s=o.PROTOCOL,l=a(a({},e),{BASE_URL:i,PROTOCOL:s}),f=d.get(l);return f||(f=function(e){var t=this,r=e.callFunction.bind(e),o=e.request.fetch.bind(e.request),i=e.getEndPointWithKey("GATEWAY"),s=i.BASE_URL,l=i.PROTOCOL,f="".concat(l).concat(s,"/model"),d="".concat(l).concat(s,"/sql"),h=(0,n.generateHTTPClient)(r,(function(e){return u(t,void 0,void 0,(function(){return c(this,(function(t){switch(t.label){case 0:return[4,o(a(a({},e),{headers:a({"Content-Type":"application/json"},e.headers)}))];case 1:return[4,t.sent().data];case 2:return[2,t.sent()]}}))}))}),f,{sqlBaseUrl:d});return h}(e),d.set(l,f)),f[r]}})}var p="cloudbase_init",v=new l;v.on(p,(function(e){var t=e.data;Object.assign(t,{models:h(t)})}));var y={name:f,namespace:f,entity:new Proxy({},{get:function(e,t){console.warn("【deprecated】Accessing Cloudbase.prototype.models.".concat(t,"."))}}),injectEvents:{bus:v,events:[p]}};try{cloudbase.registerComponent(y)}catch(e){}function m(e){try{e.registerComponent(y)}catch(e){console.warn(e)}}try{window.registerModel=m}catch(e){}},2840:function(e,t,r){"use strict";r.r(t),r.d(t,{registerMySQL:function(){return l}});var n=r(5090),o={};for(var i in n)["default","registerMySQL"].indexOf(i)<0&&(o[i]=function(e){return n[e]}.bind(0,i));r.d(t,o);var s=function(){return s=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},s.apply(this,arguments)};function a(e,t){var r=this,o=e.request.fetch.bind(e.request),i=t||{},a=i.instance,u=void 0===a?"default":a,c=i.database,l=void 0===c?e.config.env:c,f=e.getEndPointWithKey("GATEWAY"),d=f.BASE_URL,h=f.PROTOCOL,p="".concat(h).concat(d,"/rdb/rest"),v=(0,n.generateMySQLClient)(e,{mysqlBaseUrl:p,fetch:function(e,t){return n=r,i=void 0,c=function(){var r,n,i,a;return function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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(c){switch(c.label){case 0:return r={},t.headers instanceof Headers?t.headers.forEach((function(e,t){r[t]=e})):r=t.headers||{},[4,o(s(s({url:e.toString()},t),{headers:s({"Content-Type":"application/json","X-Db-Instance":u,"Accept-Profile":l,"Content-Profile":l},r),shouldThrowOnError:!1}))];case 1:n=c.sent(),i={},c.label=2;case 2:return c.trys.push([2,4,,5]),[4,n.data];case 3:return i=c.sent(),[3,5];case 4:if(!(a=c.sent()).message.includes("Unexpected end of JSON input"))throw a;return[3,5];case 5:return[2,{ok:(null==n?void 0:n.statusCode)>=200&&(null==n?void 0:n.statusCode)<300,status:(null==n?void 0:n.statusCode)||200,statusText:(null==n?void 0:n.statusMessage)||"OK",json:function(){return Promise.resolve(i||{})},text:function(){return Promise.resolve("string"==typeof i?i:JSON.stringify(i||{}))},headers:null==n?void 0:n.header}]}}))},new((a=void 0)||(a=Promise))((function(e,t){function r(e){try{s(c.next(e))}catch(e){t(e)}}function o(e){try{s(c.throw(e))}catch(e){t(e)}}function s(t){var n;t.done?e(t.value):(n=t.value,n instanceof a?n:new a((function(e){e(n)}))).then(r,o)}s((c=c.apply(n,i||[])).next())}));var n,i,a,c}});return v}var u={name:"mysql",entity:{mysql:function(e){return a(this,e)(e)}}},c={name:"rdb",entity:{rdb:function(e){return a(this,e)(e)}}};try{cloudbase.registerComponent(u),cloudbase.registerComponent(c)}catch(e){}function l(e){try{e.registerComponent(u),e.registerComponent(c)}catch(e){console.warn(e)}}try{window.registerMySQL=l}catch(e){}},7171:function(e,t,r){"use strict";var n;if(r.r(t),r.d(t,{getEncryptInfo:function(){return M}}),!globalThis.IS_MP_BUILD){var o="undefined"!=typeof globalThis?globalThis.navigator:window.globalThis,i="0123456789abcdefghijklmnopqrstuvwxyz";function B(e){return i.charAt(e)}function W(e,t){return e&t}function F(e,t){return e|t}function V(e,t){return e^t}function H(e,t){return e&~t}function $(e){if(0==e)return-1;var t=0;return 65535&e||(e>>=16,t+=16),255&e||(e>>=8,t+=8),15&e||(e>>=4,t+=4),3&e||(e>>=2,t+=2),1&e||++t,t}function G(e){for(var t=0;0!=e;)e&=e-1,++t;return t}var s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function z(e){var t,r,n="";for(t=0;t+3<=e.length;t+=3)r=parseInt(e.substring(t,t+3),16),n+=s.charAt(r>>6)+s.charAt(63&r);for(t+1==e.length?(r=parseInt(e.substring(t,t+1),16),n+=s.charAt(r<<2)):t+2==e.length&&(r=parseInt(e.substring(t,t+2),16),n+=s.charAt(r>>2)+s.charAt((3&r)<<4));(3&n.length)>0;)n+="=";return n}function K(e){var t,r="",n=0,o=0;for(t=0;t<e.length&&"="!=e.charAt(t);++t){var i=s.indexOf(e.charAt(t));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(e){var t;if(void 0===a){var r="0123456789ABCDEF";for(a={},t=0;t<16;++t)a[r.charAt(t)]=t;for(r=r.toLowerCase(),t=10;t<16;++t)a[r.charAt(t)]=t;for(t=0;t<8;++t)a[" \f\n\r\t \u2028\u2029".charAt(t)]=-1}var n=[],o=0,i=0;for(t=0;t<e.length;++t){var s=e.charAt(t);if("="==s)break;if(-1!=(s=a[s])){if(void 0===s)throw new Error("Illegal character at offset "+t);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(e){var t;if(void 0===u){for(u=Object.create(null),t=0;t<64;++t)u["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(t)]=t;for(t=0;t<9;++t)u["= \f\n\r\t \u2028\u2029".charAt(t)]=-1}var r=[],n=0,o=0;for(t=0;t<e.length;++t){var i=e.charAt(t);if("="==i)break;if(-1!=(i=u[i])){if(void 0===i)throw new Error("Illegal character at offset "+t);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(e){var t=l.re.exec(e);if(t)if(t[1])e=t[1];else{if(!t[2])throw new Error("RegExp out of sync");e=t[2]}return l.decode(e)}},f=1e13;class J{constructor(e){this.buf=[+e||0]}mulAdd(e,t){var r,n,o=this.buf,i=o.length;for(r=0;r<i;++r)(n=o[r]*e+t)<f?t=0:n-=(t=0|n/f)*f,o[r]=n;t>0&&(o[r]=t)}sub(e){var t,r,n=this.buf,o=n.length;for(t=0;t<o;++t)(r=n[t]-e)<0?(r+=f,e=1):e=0,n[t]=r;for(;0===n[n.length-1];)n.pop()}toString(e){if(10!=(e||10))throw new Error("only base 10 is supported");for(var t=this.buf,r=t[t.length-1].toString(),n=t.length-2;n>=0;--n)r+=(f+t[n]).toString().substring(1);return r}valueOf(){for(var e=this.buf,t=0,r=e.length-1;r>=0;--r)t=t*f+e[r];return t}simplify(){var e=this.buf;return 1==e.length?e[0]:this}}var d,h=/^(\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(e,t){return e.length>t&&(e=e.substring(0,t)+"…"),e}class Q{constructor(e,t){this.hexDigits="0123456789ABCDEF",e instanceof Q?(this.enc=e.enc,this.pos=e.pos):(this.enc=e,this.pos=t)}get(e){if(void 0===e&&(e=this.pos++),e>=this.enc.length)throw new Error("Requesting byte offset "+e+" on a stream of length "+this.enc.length);return"string"==typeof this.enc?this.enc.charCodeAt(e):this.enc[e]}hexByte(e){return this.hexDigits.charAt(e>>4&15)+this.hexDigits.charAt(15&e)}hexDump(e,t,r){for(var n="",o=e;o<t;++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(e,t){for(var r=e;r<t;++r){var n=this.get(r);if(n<32||n>176)return!1}return!0}parseStringISO(e,t){for(var r="",n=e;n<t;++n)r+=String.fromCharCode(this.get(n));return r}parseStringUTF(e,t){for(var r="",n=e;n<t;){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(e,t){for(var r,n,o="",i=e;i<t;)r=this.get(i++),n=this.get(i++),o+=String.fromCharCode(r<<8|n);return o}parseTime(e,t,r){var n=this.parseStringISO(e,t),o=(r?h: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(e,t){for(var r,n=this.get(e),o=n>127,i=o?255:0,s="";n==i&&++e<t;)n=this.get(e);if(0==(r=t-e))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=e+1;u<t;++u)a.mulAdd(256,this.get(u));return s+a.toString()}parseBitString(e,t,r){for(var n=this.get(e),o="("+((t-e-1<<3)-n)+" bit)\n",i="",s=e+1;s<t;++s){for(var a=this.get(s),u=s==t-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(e,t,r){if(this.isASCII(e,t))return Y(this.parseStringISO(e,t),r);var n=t-e,o="("+n+" byte)\n";n>(r/=2)&&(t=e+r);for(var i=e;i<t;++i)o+=this.hexByte(this.get(i));return n>r&&(o+="…"),o}parseOID(e,t,r){for(var n="",o=new J,i=0,s=e;s<t;++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(e,t,r,n,o){if(!(n instanceof X))throw new Error("Invalid tag value.");this.stream=e,this.header=t,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(e){if(void 0===this.tag)return null;void 0===e&&(e=1/0);var t=this.posContent(),r=Math.abs(this.length);if(!this.tag.isUniversal())return null!==this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(t,t+r,e);switch(this.tag.tagNumber){case 1:return 0===this.stream.get(t)?"false":"true";case 2:return this.stream.parseInteger(t,t+r);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(t,t+r,e);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(t,t+r,e);case 6:return this.stream.parseOID(t,t+r,e);case 16:case 17:return null!==this.sub?"("+this.sub.length+" elem)":"(no elem)";case 12:return Y(this.stream.parseStringUTF(t,t+r),e);case 18:case 19:case 20:case 21:case 22:case 26:return Y(this.stream.parseStringISO(t,t+r),e);case 30:return Y(this.stream.parseStringBMP(t,t+r),e);case 23:case 24:return this.stream.parseTime(t,t+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(e){void 0===e&&(e="");var t=e+this.typeName()+" @"+this.stream.pos;if(this.length>=0&&(t+="+"),t+=this.length,this.tag.tagConstructed?t+=" (constructed)":!this.tag.isUniversal()||3!=this.tag.tagNumber&&4!=this.tag.tagNumber||null===this.sub||(t+=" (encapsulates)"),t+="\n",null!==this.sub){e+=" ";for(var r=0,n=this.sub.length;r<n;++r)t+=this.sub[r].toPrettyString(e)}return t}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(e){var t=e.get(),r=127&t;if(r==t)return r;if(r>6)throw new Error("Length over 48 bits not supported at position "+(e.pos-1));if(0===r)return null;t=0;for(var n=0;n<r;++n)t=256*t+e.get();return t}getHexStringValue(){var e=this.toHexString(),t=2*this.header,r=2*this.length;return e.substr(t,r)}static decode(e){var t;t=e instanceof Q?e:new Q(e,0);var r=new Q(t),n=new X(t),o=Z.decodeLength(t),i=t.pos,s=i-r.pos,a=null,u=function(){var e=[];if(null!==o){for(var r=i+o;t.pos<r;)e[e.length]=Z.decode(t);if(t.pos!=r)throw new Error("Content size is not correct for container starting at offset "+i)}else try{for(;;){var n=Z.decode(t);if(n.tag.isEOC())break;e[e.length]=n}o=i-t.pos}catch(e){throw new Error("Exception while decoding undefined length content: "+e)}return e};if(n.tagConstructed)a=u();else if(n.isUniversal()&&(3==n.tagNumber||4==n.tagNumber))try{if(3==n.tagNumber&&0!=t.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(e){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);t.pos=i+Math.abs(o)}return new Z(r,s,o,n,a)}}class X{constructor(e){var t=e.get();if(this.tagClass=t>>6,this.tagConstructed=!!(32&t),this.tagNumber=31&t,31==this.tagNumber){var r=new J;do{t=e.get(),r.mulAdd(128,127&t)}while(128&t);this.tagNumber=r.simplify()}}isUniversal(){return 0===this.tagClass}isEOC(){return 0===this.tagClass&&0===this.tagNumber}}var v=[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],y=(1<<26)/v[v.length-1];class ee{constructor(e,t,r){null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}toString(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,n=(1<<t)-1,o=!1,i="",s=this.t,a=this.DB-s*this.DB%t;if(s-- >0)for(a<this.DB&&(r=this[s]>>a)>0&&(o=!0,i=B(r));s>=0;)a<t?(r=(this[s]&(1<<a)-1)<<t-a,r|=this[--s]>>(a+=this.DB-t)):(r=this[s]>>(a-=t)&n,a<=0&&(a+=this.DB,--s)),r>0&&(o=!0),o&&(i+=B(r));return o?i:"0"}negate(){var e=te();return ee.ZERO.subTo(this,e),e}abs(){return this.s<0?this.negate():this}compareTo(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this[r]-e[r]))return t;return 0}bitLength(){return this.t<=0?0:this.DB*(this.t-1)+ue(this[this.t-1]^this.s&this.DM)}mod(e){var t=te();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(ee.ZERO)>0&&e.subTo(t,t),t}modPowInt(e,t){var r;return r=e<256||t.isEven()?new g(t):new b(t),this.exp(e,r)}clone(){var e=te();return this.copyTo(e),e}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 e=this.t,t=[];t[0]=this.s;var r,n=this.DB-e*this.DB%8,o=0;if(e-- >0)for(n<this.DB&&(r=this[e]>>n)!=(this.s&this.DM)>>n&&(t[o++]=r|this.s<<this.DB-n);e>=0;)n<8?(r=(this[e]&(1<<n)-1)<<8-n,r|=this[--e]>>(n+=this.DB-8)):(r=this[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),128&r&&(r|=-256),0==o&&(128&this.s)!=(128&r)&&++o,(o>0||r!=this.s)&&(t[o++]=r);return t}equals(e){return 0==this.compareTo(e)}min(e){return this.compareTo(e)<0?this:e}max(e){return this.compareTo(e)>0?this:e}and(e){var t=te();return this.bitwiseTo(e,W,t),t}or(e){var t=te();return this.bitwiseTo(e,F,t),t}xor(e){var t=te();return this.bitwiseTo(e,V,t),t}andNot(e){var t=te();return this.bitwiseTo(e,H,t),t}not(){for(var e=te(),t=0;t<this.t;++t)e[t]=this.DM&~this[t];return e.t=this.t,e.s=~this.s,e}shiftLeft(e){var t=te();return e<0?this.rShiftTo(-e,t):this.lShiftTo(e,t),t}shiftRight(e){var t=te();return e<0?this.lShiftTo(-e,t):this.rShiftTo(e,t),t}getLowestSetBit(){for(var e=0;e<this.t;++e)if(0!=this[e])return e*this.DB+$(this[e]);return this.s<0?this.t*this.DB:-1}bitCount(){for(var e=0,t=this.s&this.DM,r=0;r<this.t;++r)e+=G(this[r]^t);return e}testBit(e){var t=Math.floor(e/this.DB);return t>=this.t?0!=this.s:!!(this[t]&1<<e%this.DB)}setBit(e){return this.changeBit(e,F)}clearBit(e){return this.changeBit(e,H)}flipBit(e){return this.changeBit(e,V)}add(e){var t=te();return this.addTo(e,t),t}subtract(e){var t=te();return this.subTo(e,t),t}multiply(e){var t=te();return this.multiplyTo(e,t),t}divide(e){var t=te();return this.divRemTo(e,t,null),t}remainder(e){var t=te();return this.divRemTo(e,null,t),t}divideAndRemainder(e){var t=te(),r=te();return this.divRemTo(e,t,r),[t,r]}modPow(e,t){var r,n,o=e.bitLength(),i=ae(1);if(o<=0)return i;r=o<18?1:o<48?3:o<144?4:o<768?5:6,n=o<8?new g(t):t.isEven()?new w(t):new b(t);var s=[],a=3,u=r-1,c=(1<<r)-1;if(s[1]=n.convert(this),r>1){var l=te();for(n.sqrTo(s[1],l);a<=c;)s[a]=te(),n.mulTo(l,s[a-2],s[a]),a+=2}var f,d,h=e.t-1,p=!0,v=te();for(o=ue(e[h])-1;h>=0;){for(o>=u?f=e[h]>>o-u&c:(f=(e[h]&(1<<o+1)-1)<<u-o,h>0&&(f|=e[h-1]>>this.DB+o-u)),a=r;!(1&f);)f>>=1,--a;if((o-=a)<0&&(o+=this.DB,--h),p)s[f].copyTo(i),p=!1;else{for(;a>1;)n.sqrTo(i,v),n.sqrTo(v,i),a-=2;a>0?n.sqrTo(i,v):(d=i,i=v,v=d),n.mulTo(v,s[f],i)}for(;h>=0&&!(e[h]&1<<o);)n.sqrTo(i,v),d=i,i=v,v=d,--o<0&&(o=this.DB-1,--h)}return n.revert(i)}modInverse(e){var t=e.isEven();if(this.isEven()&&t||0==e.signum())return ee.ZERO;for(var r=e.clone(),n=this.clone(),o=ae(1),i=ae(0),s=ae(0),a=ae(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),t?(o.isEven()&&i.isEven()||(o.addTo(this,o),i.subTo(e,i)),o.rShiftTo(1,o)):i.isEven()||i.subTo(e,i),i.rShiftTo(1,i);for(;n.isEven();)n.rShiftTo(1,n),t?(s.isEven()&&a.isEven()||(s.addTo(this,s),a.subTo(e,a)),s.rShiftTo(1,s)):a.isEven()||a.subTo(e,a),a.rShiftTo(1,a);r.compareTo(n)>=0?(r.subTo(n,r),t&&o.subTo(s,o),i.subTo(a,i)):(n.subTo(r,n),t&&s.subTo(o,s),a.subTo(i,a))}return 0!=n.compareTo(ee.ONE)?ee.ZERO:a.compareTo(e)>=0?a.subtract(e):a.signum()<0?(a.addTo(e,a),a.signum()<0?a.add(e):a):a}pow(e){return this.exp(e,new m)}gcd(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var n=t;t=r,r=n}var o=t.getLowestSetBit(),i=r.getLowestSetBit();if(i<0)return t;for(o<i&&(i=o),i>0&&(t.rShiftTo(i,t),r.rShiftTo(i,r));t.signum()>0;)(o=t.getLowestSetBit())>0&&t.rShiftTo(o,t),(o=r.getLowestSetBit())>0&&r.rShiftTo(o,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return i>0&&r.lShiftTo(i,r),r}isProbablePrime(e){var t,r=this.abs();if(1==r.t&&r[0]<=v[v.length-1]){for(t=0;t<v.length;++t)if(r[0]==v[t])return!0;return!1}if(r.isEven())return!1;for(t=1;t<v.length;){for(var n=v[t],o=t+1;o<v.length&&n<y;)n*=v[o++];for(n=r.modInt(n);t<o;)if(n%v[t++]==0)return!1}return r.millerRabin(e)}copyTo(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s}fromInt(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+this.DV:this.t=0}fromString(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return void this.fromRadix(e,t);r=2}this.t=0,this.s=0;for(var n=e.length,o=!1,i=0;--n>=0;){var s=8==r?255&+e[n]:se(e,n);s<0?"-"==e.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&+e[0]&&(this.s=-1,i>0&&(this[this.t-1]|=(1<<this.DB-i)-1<<i)),this.clamp(),o&&ee.ZERO.subTo(this,this)}clamp(){for(var e=this.s&this.DM;this.t>0&&this[this.t-1]==e;)--this.t}dlShiftTo(e,t){var r;for(r=this.t-1;r>=0;--r)t[r+e]=this[r];for(r=e-1;r>=0;--r)t[r]=0;t.t=this.t+e,t.s=this.s}drShiftTo(e,t){for(var r=e;r<this.t;++r)t[r-e]=this[r];t.t=Math.max(this.t-e,0),t.s=this.s}lShiftTo(e,t){for(var r=e%this.DB,n=this.DB-r,o=(1<<n)-1,i=Math.floor(e/this.DB),s=this.s<<r&this.DM,a=this.t-1;a>=0;--a)t[a+i+1]=this[a]>>n|s,s=(this[a]&o)<<r;for(a=i-1;a>=0;--a)t[a]=0;t[i]=s,t.t=this.t+i+1,t.s=this.s,t.clamp()}rShiftTo(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var n=e%this.DB,o=this.DB-n,i=(1<<n)-1;t[0]=this[r]>>n;for(var s=r+1;s<this.t;++s)t[s-r-1]|=(this[s]&i)<<o,t[s-r]=this[s]>>n;n>0&&(t[this.t-r-1]|=(this.s&i)<<o),t.t=this.t-r,t.clamp()}}subTo(e,t){for(var r=0,n=0,o=Math.min(e.t,this.t);r<o;)n+=this[r]-e[r],t[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n-=e.s;r<this.t;)n+=this[r],t[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n-=e[r],t[r++]=n&this.DM,n>>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t[r++]=this.DV+n:n>0&&(t[r++]=n),t.t=r,t.clamp()}multiplyTo(e,t){var r=this.abs(),n=e.abs(),o=r.t;for(t.t=o+n.t;--o>=0;)t[o]=0;for(o=0;o<n.t;++o)t[o+r.t]=r.am(0,n[o],t,o,0,r.t);t.s=0,t.clamp(),this.s!=e.s&&ee.ZERO.subTo(t,t)}squareTo(e){for(var t=this.abs(),r=e.t=2*t.t;--r>=0;)e[r]=0;for(r=0;r<t.t-1;++r){var n=t.am(r,t[r],e,2*r,0,1);(e[r+t.t]+=t.am(r+1,2*t[r],e,2*r+1,n,t.t-r-1))>=t.DV&&(e[r+t.t]-=t.DV,e[r+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(r,t[r],e,2*r,0,1)),e.s=0,e.clamp()}divRemTo(e,t,r){var n=e.abs();if(!(n.t<=0)){var o=this.abs();if(o.t<n.t)return null!=t&&t.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=te());var i=te(),s=this.s,a=e.s,u=this.DB-ue(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),d=this.FV/f,h=(1<<this.F1)/f,p=1<<this.F2,v=r.t,y=v-c,m=null==t?te():t;for(i.dlShiftTo(y,m),r.compareTo(m)>=0&&(r[r.t++]=1,r.subTo(m,r)),ee.ONE.dlShiftTo(c,m),m.subTo(i,i);i.t<c;)i[i.t++]=0;for(;--y>=0;){var g=r[--v]==l?this.DM:Math.floor(r[v]*d+(r[v-1]+p)*h);if((r[v]+=i.am(0,g,r,y,0,c))<g)for(i.dlShiftTo(y,m),r.subTo(m,r);r[v]<--g;)r.subTo(m,r)}null!=t&&(r.drShiftTo(c,t),s!=a&&ee.ZERO.subTo(t,t)),r.t=c,r.clamp(),u>0&&r.rShiftTo(u,r),s<0&&ee.ZERO.subTo(r,r)}}}invDigit(){if(this.t<1)return 0;var e=this[0];if(!(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t}isEven(){return 0==(this.t>0?1&this[0]:this.s)}exp(e,t){if(e>4294967295||e<1)return ee.ONE;var r=te(),n=te(),o=t.convert(this),i=ue(e)-1;for(o.copyTo(r);--i>=0;)if(t.sqrTo(r,n),(e&1<<i)>0)t.mulTo(n,o,r);else{var s=r;r=n,n=s}return t.revert(r)}chunkSize(e){return Math.floor(Math.LN2*this.DB/Math.log(e))}toRadix(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),n=ae(r),o=te(),i=te(),s="";for(this.divRemTo(n,o,i);o.signum()>0;)s=(r+i.intValue()).toString(e).substr(1)+s,o.divRemTo(n,o,i);return i.intValue().toString(e)+s}fromRadix(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),o=!1,i=0,s=0,a=0;a<e.length;++a){var u=se(e,a);u<0?"-"==e.charAt(a)&&0==this.signum()&&(o=!0):(s=t*s+u,++i>=r&&(this.dMultiply(n),this.dAddOffset(s,0),i=0,s=0))}i>0&&(this.dMultiply(Math.pow(t,i)),this.dAddOffset(s,0)),o&&ee.ZERO.subTo(this,this)}fromNumber(e,t,r){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(ee.ONE.shiftLeft(e-1),F,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(ee.ONE.shiftLeft(e-1),this);else{var n=[],o=7&e;n.length=1+(e>>3),t.nextBytes(n),o>0?n[0]&=(1<<o)-1:n[0]=0,this.fromString(n,256)}}bitwiseTo(e,t,r){var n,o,i=Math.min(e.t,this.t);for(n=0;n<i;++n)r[n]=t(this[n],e[n]);if(e.t<this.t){for(o=e.s&this.DM,n=i;n<this.t;++n)r[n]=t(this[n],o);r.t=this.t}else{for(o=this.s&this.DM,n=i;n<e.t;++n)r[n]=t(o,e[n]);r.t=e.t}r.s=t(this.s,e.s),r.clamp()}changeBit(e,t){var r=ee.ONE.shiftLeft(e);return this.bitwiseTo(r,t,r),r}addTo(e,t){for(var r=0,n=0,o=Math.min(e.t,this.t);r<o;)n+=this[r]+e[r],t[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n+=e.s;r<this.t;)n+=this[r],t[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n+=e[r],t[r++]=n&this.DM,n>>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t[r++]=n:n<-1&&(t[r++]=this.DV+n),t.t=r,t.clamp()}dMultiply(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()}dAddOffset(e,t){if(0!=e){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=e;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}}multiplyLowerTo(e,t,r){var n=Math.min(this.t+e.t,t);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,e[n],r,n,0,this.t);for(o=Math.min(e.t,t);n<o;++n)this.am(0,e[n],r,n,0,t-n);r.clamp()}multiplyUpperTo(e,t,r){--t;var n=r.t=this.t+e.t-t;for(r.s=0;--n>=0;)r[n]=0;for(n=Math.max(t-this.t,0);n<e.t;++n)r[this.t+n-t]=this.am(t-n,e[n],r,0,0,this.t+n-t);r.clamp(),r.drShiftTo(1,r)}modInt(e){if(e<=0)return 0;var t=this.DV%e,r=this.s<0?e-1:0;if(this.t>0)if(0==t)r=this[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this[n])%e;return r}millerRabin(e){var t=this.subtract(ee.ONE),r=t.getLowestSetBit();if(r<=0)return!1;var n=t.shiftRight(r);(e=e+1>>1)>v.length&&(e=v.length);for(var o=te(),i=0;i<e;++i){o.fromInt(v[Math.floor(Math.random()*v.length)]);var s=o.modPow(n,this);if(0!=s.compareTo(ee.ONE)&&0!=s.compareTo(t)){for(var a=1;a++<r&&0!=s.compareTo(t);)if(0==(s=s.modPowInt(2,this)).compareTo(ee.ONE))return!1;if(0!=s.compareTo(t))return!1}}return!0}square(){var e=te();return this.squareTo(e),e}gcda(e,t){var r=this.s<0?this.negate():this.clone(),n=e.s<0?e.negate():e.clone();if(r.compareTo(n)<0){var o=r;r=n,n=o}var i=r.getLowestSetBit(),s=n.getLowestSetBit();if(s<0)t(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(){t(n)}),0))};setTimeout(a,10)}}fromNumberAsync(e,t,r,n){if("number"==typeof t)if(e<2)this.fromInt(1);else{this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(ee.ONE.shiftLeft(e-1),F,this),this.isEven()&&this.dAddOffset(1,0);var o=this,i=function(){o.dAddOffset(2,0),o.bitLength()>e&&o.subTo(ee.ONE.shiftLeft(e-1),o),o.isProbablePrime(t)?setTimeout((function(){n()}),0):setTimeout(i,0)};setTimeout(i,0)}else{var s=[],a=7&e;s.length=1+(e>>3),t.nextBytes(s),a>0?s[0]&=(1<<a)-1:s[0]=0,this.fromString(s,256)}}}var m=function(){function e(){}return e.prototype.convert=function(e){return e},e.prototype.revert=function(e){return e},e.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},e.prototype.sqrTo=function(e,t){e.squareTo(t)},e}(),g=function(){function e(e){this.m=e}return e.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},e.prototype.revert=function(e){return e},e.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},e.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},e.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},e}(),b=function(){function e(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}return e.prototype.convert=function(e){var t=te();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(ee.ZERO)>0&&this.m.subTo(t,t),t},e.prototype.revert=function(e){var t=te();return e.copyTo(t),this.reduce(t),t},e.prototype.reduce=function(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t<this.m.t;++t){var r=32767&e[t],n=r*this.mpl+((r*this.mph+(e[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(e[r=t+this.m.t]+=this.m.am(0,n,e,t,0,this.m.t);e[r]>=e.DV;)e[r]-=e.DV,e[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},e.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},e.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},e}(),w=function(){function e(e){this.m=e,this.r2=te(),this.q3=te(),ee.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e)}return e.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=te();return e.copyTo(t),this.reduce(t),t},e.prototype.revert=function(e){return e},e.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},e.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},e.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},e}();function te(){return new ee(null)}function re(e,t){return new ee(e,t)}function ne(e,t,r,n,o,i){for(;--i>=0;){var s=t*this[e++]+r[n]+o;o=Math.floor(s/67108864),r[n++]=67108863&s}return o}function oe(e,t,r,n,o,i){for(var s=32767&t,a=t>>15;--i>=0;){var u=32767&this[e],c=this[e++]>>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 ie(e,t,r,n,o,i){for(var s=16383&t,a=t>>14;--i>=0;){var u=16383&this[e],c=this[e++]>>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)?(ee.prototype.am=oe,d=30):"Netscape"!=(null==o?void 0:o.appName)?(ee.prototype.am=ne,d=26):(ee.prototype.am=ie,d=28),ee.prototype.DB=d,ee.prototype.DM=(1<<d)-1,ee.prototype.DV=1<<d,ee.prototype.FV=Math.pow(2,52),ee.prototype.F1=52-d,ee.prototype.F2=2*d-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 se(e,t){var r=E[e.charCodeAt(t)];return null==r?-1:r}function ae(e){var t=te();return t.fromInt(e),t}function ue(e){var t,r=1;return 0!=(t=e>>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}ee.ZERO=ae(0),ee.ONE=ae(1);class ce{constructor(){this.i=0,this.j=0,this.S=[]}init(e){var t,r,n;for(t=0;t<256;++t)this.S[t]=t;for(r=0,t=0;t<256;++t)r=r+this.S[t]+e[t%e.length]&255,n=this.S[t],this.S[t]=this.S[r],this.S[r]=n;this.i=0,this.j=0}next(){var e;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,e=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=e,this.S[e+this.S[this.i]&255]}}var I,O,T=null;if(null==T){T=[],O=0;var A,R,P=void 0;if("undefined"!=typeof window&&null!==(A=window)&&void 0!==A&&A.crypto&&null!==(R=window)&&void 0!==R&&R.crypto.getRandomValues){var C,N=new Uint32Array(256);for(null===(C=window)||void 0===C||C.crypto.getRandomValues(N),P=0;P<N.length;++P)T[O++]=255&N[P]}var x,L,U,k=function(e){var t,r,n;if(this.count=this.count||0,this.count>=256||O>=256){if("undefined"!=typeof window)if(null!==(t=window)&&void 0!==t&&t.removeEventListener)null===(n=window)||void 0===n||n.removeEventListener("mousemove",k,!1);else if(null!==(r=window)&&void 0!==r&&r.detachEvent){var o;null===(o=window)||void 0===o||o.detachEvent("onmousemove",k)}}else try{var i=e.x+e.y;T[O++]=255&i,this.count+=1}catch(e){}};if("undefined"!=typeof window)if(null!==(x=window)&&void 0!==x&&x.addEventListener)null===(U=window)||void 0===U||U.addEventListener("mousemove",k,!1);else if(null!==(L=window)&&void 0!==L&&L.attachEvent){var D;null===(D=window)||void 0===D||D.attachEvent("onmousemove",k)}}function le(){if(null==I){for(I=new ce;O<256;){var e=Math.floor(65536*Math.random());T[O++]=255&e}for(I.init(T),O=0;O<T.length;++O)T[O]=0;O=0}return I.next()}class fe{constructor(){}nextBytes(e){for(var t=0;t<e.length;++t)e[t]=le()}}function de(e,t){if(t<e.length+11)return console.error("Message too long for RSA"),null;for(var r=[],n=e.length-1;n>=0&&t>0;){var o=e.charCodeAt(n--);o<128?r[--t]=o:o>127&&o<2048?(r[--t]=63&o|128,r[--t]=o>>6|192):(r[--t]=63&o|128,r[--t]=o>>6&63|128,r[--t]=o>>12|224)}r[--t]=0;for(var i=new fe,s=[];t>2;){for(s[0]=0;0==s[0];)i.nextBytes(s);r[--t]=s[0]}return r[--t]=2,r[--t]=0,new ee(r)}class he{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(e){return e.modPowInt(this.e,this.n)}doPrivate(e){if(null==this.p||null==this.q)return e.modPow(this.d,this.n);for(var t=e.mod(this.p).modPow(this.dmp1,this.p),r=e.mod(this.q).modPow(this.dmq1,this.q);t.compareTo(r)<0;)t=t.add(this.p);return t.subtract(r).multiply(this.coeff).mod(this.p).multiply(this.q).add(r)}setPublic(e,t){null!=e&&null!=t&&e.length>0&&t.length>0?(this.n=re(e,16),this.e=parseInt(t,16)):console.error("Invalid RSA public key")}encrypt(e){var t=de(e,this.n.bitLength()+7>>3);if(null==t)return null;var r=this.doPublic(t);if(null==r)return null;var n=r.toString(16);return 1&n.length?"0"+n:n}encryptLong(e){var t=this,r=(this.n.bitLength()+7>>3)-11;try{var n="";return e.length>r?(e.match(/.{1,117}/g).forEach((function(e){var r=t.encrypt(e);n+=r})),z(n)):z(this.encrypt(e))}catch(e){return!1}}decryptLong(e){var t=this,r=this.n.bitLength()+7>>3;e=K(e);try{if(e.length>r){var n="";return e.match(/.{1,256}/g).forEach((function(e){var r=t.decrypt(e);n+=r})),n}return this.decrypt(e)}catch(e){return!1}}setPrivate(e,t,r){null!=e&&null!=t&&e.length>0&&t.length>0?(this.n=re(e,16),this.e=parseInt(t,16),this.d=re(r,16)):console.error("Invalid RSA private key")}setPrivateEx(e,t,r,n,o,i,s,a){null!=e&&null!=t&&e.length>0&&t.length>0?(this.n=re(e,16),this.e=parseInt(t,16),this.d=re(r,16),this.p=re(n,16),this.q=re(o,16),this.dmp1=re(i,16),this.dmq1=re(s,16),this.coeff=re(a,16)):console.error("Invalid RSA private key")}generate(e,t){var r=new fe,n=e>>1;this.e=parseInt(t,16);for(var o=new ee(t,16);;){for(;this.p=new ee(e-n,1,r),0!=this.p.subtract(ee.ONE).gcd(o).compareTo(ee.ONE)||!this.p.isProbablePrime(10););for(;this.q=new ee(n,1,r),0!=this.q.subtract(ee.ONE).gcd(o).compareTo(ee.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(ee.ONE),a=this.q.subtract(ee.ONE),u=s.multiply(a);if(0==u.gcd(o).compareTo(ee.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(e){var t=re(e,16),r=this.doPrivate(t);return null==r?null:pe(r,this.n.bitLength()+7>>3)}generateAsync(e,t,r){var n=new fe,o=e>>1;this.e=parseInt(t,16);var i=new ee(t,16),s=this,a=()=>{var t=()=>{if(s.p.compareTo(s.q)<=0){var e=s.p;s.p=s.q,s.q=e}var t=s.p.subtract(ee.ONE),n=s.q.subtract(ee.ONE),o=t.multiply(n);0==o.gcd(i).compareTo(ee.ONE)?(s.n=s.p.multiply(s.q),s.d=i.modInverse(o),s.dmp1=s.d.mod(t),s.dmq1=s.d.mod(n),s.coeff=s.q.modInverse(s.p),setTimeout((function(){r()}),0)):setTimeout(a,0)},u=()=>{s.q=te(),s.q.fromNumberAsync(o,1,n,(function(){s.q.subtract(ee.ONE).gcda(i,(function(e){0==e.compareTo(ee.ONE)&&s.q.isProbablePrime(10)?setTimeout(t,0):setTimeout(u,0)}))}))},c=()=>{s.p=te(),s.p.fromNumberAsync(e-o,1,n,(function(){s.p.subtract(ee.ONE).gcda(i,(function(e){0==e.compareTo(ee.ONE)&&s.p.isProbablePrime(10)?setTimeout(u,0):setTimeout(c,0)}))}))};setTimeout(c,0)};setTimeout(a,0)}}function pe(e,t){for(var r=e.toByteArray(),n=0;n<r.length&&0==r[n];)++n;if(r.length-n!=t-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 ve extends he{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";super(),e&&("string"==typeof e?this.parseKey(e):(this.hasPrivateKeyProperty(e)||this.hasPublicKeyProperty(e))&&this.parsePropertiesFrom(e))}parseKey(e){try{var t=0,r=0,n=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(e)?c.decode(e):l.unarmor(e),o=Z.decode(n);if(3===o.sub.length&&(o=o.sub[2].sub[0]),9===o.sub.length){t=o.sub[1].getHexStringValue(),this.n=re(t,16),r=o.sub[2].getHexStringValue(),this.e=parseInt(r,16);var i=o.sub[3].getHexStringValue();this.d=re(i,16);var s=o.sub[4].getHexStringValue();this.p=re(s,16);var a=o.sub[5].getHexStringValue();this.q=re(a,16);var u=o.sub[6].getHexStringValue();this.dmp1=re(u,16);var f=o.sub[7].getHexStringValue();this.dmq1=re(f,16);var d=o.sub[8].getHexStringValue();this.coeff=re(d,16)}else{if(2!==o.sub.length)return!1;var h=o.sub[1].sub[0];t=h.sub[0].getHexStringValue(),this.n=re(t,16),r=h.sub[1].getHexStringValue(),this.e=parseInt(r,16)}return!0}catch(e){return!1}}hasPublicKeyProperty(e){return(e=e||{}).hasOwnProperty("n")&&e.hasOwnProperty("e")}hasPrivateKeyProperty(e){return(e=e||{}).hasOwnProperty("n")&&e.hasOwnProperty("e")&&e.hasOwnProperty("d")&&e.hasOwnProperty("p")&&e.hasOwnProperty("q")&&e.hasOwnProperty("dmp1")&&e.hasOwnProperty("dmq1")&&e.hasOwnProperty("coeff")}parsePropertiesFrom(e){this.n=e.n,this.e=e.e,e.hasOwnProperty("d")&&(this.d=e.d,this.p=e.p,this.q=e.q,this.dmp1=e.dmp1,this.dmq1=e.dmq1,this.coeff=e.coeff)}}(n=function(e){e=e||{},this.default_key_size=parseInt(e.default_key_size,10)||1024,this.default_public_exponent=e.default_public_exponent||"010001",this.log=e.log||!1,this.key=null}).prototype.setKey=function(e){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new ve(e)},n.prototype.setPrivateKey=function(e){this.setKey(e)},n.prototype.setPublicKey=function(e){this.setKey(e)},n.prototype.decrypt=function(e){try{return this.getKey().decrypt(K(e))}catch(e){return!1}},n.prototype.encrypt=function(e){try{return z(this.getKey().encrypt(e))}catch(e){return!1}},n.prototype.encryptLong=function(e){try{for(var t=this.getKey().encryptLong(e)||"",r=this.getKey().decryptLong(t)||"",n=0,o=/null$/g;o.test(r)&&(n++,t=this.getKey().encryptLong(e)||"",r=this.getKey().decryptLong(t)||"",!(n>10)););return t}catch(e){return!1}},n.prototype.getKey=function(e){if(!this.key){if(this.key=new ve,e&&"[object Function]"==={}.toString.call(e))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,e);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},n.version="3.1.4"}var j=n,q=r(4655),M=function(){var{publicKey:e="",payload:t={}}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!e)return"";try{var r=(0,q.I)(t),n=new j;return n.setPublicKey(e),n.encryptLong("object"==typeof r?JSON.stringify(r):r)}catch(e){console.error("encrypt error:",e)}return""}},4655:function(e,t,r){"use strict";r.d(t,{I:function(){return n},y:function(){return o}});var n=e=>{var t=t=>{for(var r in e)e.hasOwnProperty(r)&&(t[r]=n(e[r]));return t},r=null==e?"NullOrUndefined":Object.prototype.toString.call(e).slice(8,-1);if(["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"].includes(r))return e.slice();switch(r){case"Object":return t(Object.create(Object.getPrototypeOf(e)));case"Array":return t([]);case"Date":return new Date(e.valueOf());case"RegExp":return new RegExp(e.source,(e.global?"g":"")+(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.sticky?"y":"")+(e.unicode?"u":""));default:return e}},o=e=>{var t=e.match(/^(?:http(s)?:\/\/[^\/]+)?(\/[^\?#]*)/);return t&&t[2]||""}},9063:function(e,t,r){"use strict";r.r(t),r.d(t,{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(e){return void 0===e&&(e=""),"".concat(e?"".concat(e,"_"):"").concat(+new Date,"_").concat(Math.random())}var l,f,d=function(e){this.close=e.close,this.onChange=e.onChange,this.onError=e.onError,e.debug&&Object.defineProperty(this,"virtualClient",{get:function(){return e.virtualClient}})},h=function(e){var t,r,n=e.id,o=e.docChanges,i=e.docs,s=e.msgType,a=e.type;Object.defineProperties(this,{id:{get:function(){return n},enumerable:!0},docChanges:{get:function(){return t||(t=JSON.parse(JSON.stringify(o))),t},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(e,t){return l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},l(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}l(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),v=function(e){function t(t){var r=e.call(this,"Watch Error ".concat(JSON.stringify(t.msgData)," (requestid: ").concat(t.requestId,")"))||this;return r.isRealtimeErrorMessageError=!0,r.payload=t,r}return p(t,e),t}(Error),y=function(e){return null==e?void 0:e.isRealtimeErrorMessageError},m=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type="timeout",t.payload=null,t.generic=!0,t}return p(t,e),t}(Error),g=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type="cancelled",t.payload=null,t.generic=!0,t}return p(t,e),t}(Error),b=function(e){function t(t){var r=e.call(this,t.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(e){this.errMsg=e}}}),r.errCode=t.errCode||"UNKNOWN_ERROR",r.errMsg=t.errMsg,r}return p(t,e),Object.defineProperty(t.prototype,"message",{get:function(){return"errCode: ".concat(this.errCode," | errMsg: ").concat(this.errMsg)},set:function(e){this.errMsg=e},enumerable:!1,configurable:!0}),t}(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(e){return void 0===e&&(e=0),new Promise((function(t){return setTimeout(t,e)}))},S=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},E=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};!function(e){e.LOGGINGIN="LOGGINGIN",e.INITING="INITING",e.REBUILDING="REBUILDING",e.ACTIVE="ACTIVE",e.ERRORED="ERRORED",e.CLOSING="CLOSING",e.CLOSED="CLOSED",e.PAUSED="PAUSED",e.RESUMING="RESUMING"}(f||(f={}));var O=function(){function e(e){var t=this;this.watchStatus=f.INITING,this.wsLogin=function(e,r){return S(t,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return this.watchStatus=f.LOGGINGIN,[4,this.login(e,r)];case 1:return t=n.sent(),this.envId||(this.envId=t.envId),[2,t]}}))}))},this.initWatch=function(e){return S(t,void 0,void 0,(function(){var t,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(t,n){S(r,void 0,void 0,(function(){var r,o,i,s,a,u,l,d,p,v;return E(this,(function(y){switch(y.label){case 0:return y.trys.push([0,3,,4]),this.watchStatus===f.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,t()]):[4,this.wsLogin(this.envId,e)];case 1:return r=y.sent().envId,this.watchStatus===f.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,t()]):(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=y.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,d=a;l<d.length;l++)d[l].ID=u;this.handleServerEvents(i)}else this.sessionInfo.currentEventId=u,p=new h({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,t(),[3,4];case 3:return v=y.sent(),this.handleWatchEstablishmentError(v,{operationName:"INIT_WATCH",resolve:t,reject:n}),[3,4];case 4:return[2]}}))}))})),t=!1,n.label=1;case 1:return n.trys.push([1,,3,4]),[4,this.initWatchPromise];case 2:return n.sent(),t=!0,[3,4];case 3:return this.initWatchPromise=void 0,[7];case 4:return console.log("[realtime] initWatch ".concat(t?"success":"fail")),[2]}}))}))},this.rebuildWatch=function(e){return S(t,void 0,void 0,(function(){var t,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(t,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,t()]):[4,this.wsLogin(this.envId,e)];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,t()]):(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,t(),[3,4];case 3:return s=a.sent(),this.handleWatchEstablishmentError(s,{operationName:"REBUILD_WATCH",resolve:t,reject:n}),[3,4];case 4:return[2]}}))}))})),t=!1,n.label=1;case 1:return n.trys.push([1,,3,4]),[4,this.rebuildWatchPromise];case 2:return n.sent(),t=!0,[3,4];case 3:return this.rebuildWatchPromise=void 0,[7];case 4:return console.log("[realtime] rebuildWatch ".concat(t?"success":"fail")),[2]}}))}))},this.handleWatchEstablishmentError=function(e,r){return S(t,void 0,void 0,(function(){var t,n,o,i=this;return E(this,(function(s){return t="INIT_WATCH"===r.operationName,n=function(){i.closeWithError(new b({errCode:t?w.SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:w.SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL,errMsg:e})),r.reject(e)},o=function(e){i.useRetryTicket(r.operationName)?t?(i.initWatchPromise=void 0,r.resolve(i.initWatch(e))):(i.rebuildWatchPromise=void 0,r.resolve(i.rebuildWatch(e))):n()},this.handleCommonError(e,{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 e,t=this;return E(this,(function(n){switch(n.label){case 0:return n.trys.push([0,8,,9]),e=function(){return S(t,void 0,void 0,(function(){return E(this,(function(e){switch(e.label){case 0:return this.pause(),[4,this.onceWSConnected()];case 1:return e.sent(),o(!0),[2]}}))}))},this.isWSConnected()?[3,2]:[4,e()];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 g("".concat(r.operationName," cancelled due to pause after unknownError"))),[3,7]);case 4:return this.isWSConnected()?[3,6]:[4,e()];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(t,void 0,void 0,(function(){var e,t,r;return E(this,(function(n){switch(n.label){case 0:if(e=this.sessionInfo?this.sessionInfo.queryID:"",this.watchStatus!==f.ACTIVE)return this.watchStatus=f.CLOSED,this.onWatchClose(this,e),[2];n.label=1;case 1:return n.trys.push([1,3,4,5]),this.watchStatus=f.CLOSING,t={watchId:this.watchId,requestId:c(),msgType:"CLOSE_WATCH",msgData:null},[4,this.send({msg:t})];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,e),[7];case 5:return[2]}}))}))},this.scheduleSendACK=function(){t.clearACKSchedule(),t.ackTimeoutId=setTimeout((function(){t.waitExpectedTimeoutId?t.scheduleSendACK():t.sendACK()}),1e4)},this.clearACKSchedule=function(){t.ackTimeoutId&&clearTimeout(t.ackTimeoutId)},this.sendACK=function(){return S(t,void 0,void 0,(function(){var e,t,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?(e={watchId:this.watchId,requestId:c(),msgType:"CHECK_LAST",msgData:{queryID:this.sessionInfo.queryID,eventID:this.sessionInfo.currentEventId}},[4,this.send({msg:e})]):(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(t=n.sent(),y(t))switch((r=t.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:t})),[3,3];case 3:return[2]}}))}))},this.handleCommonError=function(e,t){if(y(e))switch(e.payload.msgData.code){case"CHECK_LOGIN_FAILED":case"SIGN_EXPIRED_ERROR":case"SIGN_INVALID_ERROR":case"SIGN_PARAM_INVALID":return void t.onSignError(e);default:return void t.onNotRetryableError(e)}else{if(function(e){return"timeout"===e.type}(e))return void t.onTimeoutError(e);if(function(e){return"cancelled"===e.type}(e))return void t.onCancelledError(e)}t.onUnknownError(e)},this.watchId="watchid_".concat(+new Date,"_").concat(Math.random()),this.envId=e.envId,this.collectionName=e.collectionName,this.query=e.query,this.limit=e.limit,this.orderBy=e.orderBy,this.send=e.send,this.login=e.login,this.isWSConnected=e.isWSConnected,this.onceWSConnected=e.onceWSConnected,this.getWaitExpectedTimeoutLength=e.getWaitExpectedTimeoutLength,this.onWatchStart=e.onWatchStart,this.onWatchClose=e.onWatchClose,this.debug=e.debug,this.availableRetries={INIT_WATCH:2,REBUILD_WATCH:2,CHECK_LAST:2},this.listener=new d({close:function(){t.closeWatch()},onChange:e.onChange,onError:e.onError,debug:this.debug,virtualClient:this}),this.initWatch()}return e.prototype.onMessage=function(e){var t=this;switch(this.watchStatus){case f.PAUSED:if("ERROR"!==e.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(),e.msgType){case"NEXT_EVENT":console.warn("nextevent ".concat(e.msgData.currEvent," ignored"),e),this.handleServerEvents(e);break;case"CHECK_EVENT":this.sessionInfo.currentEventId<e.msgData.currEvent&&(this.sessionInfo.expectEventId=e.msgData.currEvent,this.clearWaitExpectedEvent(),this.waitExpectedTimeoutId=setTimeout((function(){t.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(e.msgData.code," - ").concat(e.msgData.message)}));break;default:console.warn("[realtime listener] virtual client receive unexpected msg ".concat(e.msgType,": "),e)}else console.warn("[realtime listener] internal non-fatal error: sessionInfo not found while message is received.")},e.prototype.closeWithError=function(e){var t;this.watchStatus=f.ERRORED,this.clearACKSchedule(),this.listener.onError(e),this.onWatchClose(this,(null===(t=this.sessionInfo)||void 0===t?void 0:t.queryID)||""),console.log("[realtime] client closed (".concat(this.collectionName," ").concat(this.query,") (watchId ").concat(this.watchId,")"))},e.prototype.pause=function(){this.watchStatus=f.PAUSED,console.log("[realtime] client paused (".concat(this.collectionName," ").concat(this.query,") (watchId ").concat(this.watchId,")"))},e.prototype.resume=function(){return S(this,void 0,void 0,(function(){var e;return E(this,(function(t){switch(t.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,")")),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.sessionInfo?this.rebuildWatch():this.initWatch()];case 2:return t.sent(),console.log("[realtime] client successfully resumed (".concat(this.collectionName," ").concat(this.query,") (").concat(this.watchId,")")),[3,4];case 3:return e=t.sent(),console.error("[realtime] client resume failed (".concat(this.collectionName," ").concat(this.query,") (").concat(this.watchId,")"),e),[3,4];case 4:return[2]}}))}))},e.prototype.useRetryTicket=function(e){return!!(this.availableRetries[e]&&this.availableRetries[e]>0)&&(this.availableRetries[e]-=1,console.log("[realtime] ".concat(e," use a retry ticket, now only ").concat(this.availableRetries[e]," retry left")),!0)},e.prototype.handleServerEvents=function(e){return S(this,void 0,void 0,(function(){var t;return E(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.scheduleSendACK(),[4,this.handleServerEventsInternel(e)];case 1:return r.sent(),this.postHandleServerEventsValidityCheck(e),[3,3];case 2:throw t=r.sent(),console.error("[realtime listener] internal non-fatal error: handle server events failed with error: ",t),t;case 3:return[2]}}))}))},e.prototype.handleServerEventsInternel=function(e){return S(this,void 0,void 0,(function(){var t,r,n,i,a,c,l,f,d,p,v,y;return E(this,(function(m){switch(m.label){case 0:if(t=e.requestId,r=e.msgData.events,n=e.msgType,!r.length||!this.sessionInfo)return[2];i=this.sessionInfo;try{a=r.map(T)}catch(e){return this.closeWithError(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA,errMsg:e})),[2]}c=I([],i.currentDocs,!0),l=!1,f=function(r,f){var p,v,y,m,g,_,S,O,T,A,R,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(t,")")),[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(v=c.find((function(e){return e._id===p.docId})),v){if(y=u()(v),p.updatedFields&&Object.keys(p.updatedFields).forEach((function(e){o()(y,e,p.updatedFields[e])})),p.removedFields)for(m=0,g=p.removedFields;m<g.length;m++)_=g[m],s()(y,_);p.doc=y}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(e.requestId,")")}),d.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(e.requestId,")")}),d.closeWithError(O),O;break;case"remove":(S=c.find((function(e){return e._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(e){return e._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(e.requestId,")")}),d.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(e){return e._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(e){return e._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)&&(A=I([],c,!0),R=a.slice(0,r+1).filter((function(e){return e.id===p.id})),d.sessionInfo.currentEventId=p.id,d.sessionInfo.currentDocs=c,P=new h({id:p.id,docChanges:R,docs:A,msgType:n}),d.listener.onChange(P)),[3,4];case 2:return console.warn("[realtime listener] event received is out of order, cur ".concat(d.sessionInfo.currentEventId," but got ").concat(p.id)),[4,d.rebuildWatch()];case 3:return E.sent(),[2,{value:void 0}];case 4:return[2]}}))},d=this,p=0,v=a.length,m.label=1;case 1:return p<v?[5,f(p,v)]:[3,4];case 2:if("object"==typeof(y=m.sent()))return[2,y.value];m.label=3;case 3:return p++,[3,1];case 4:return[2]}}))}))},e.prototype.postHandleServerEventsValidityCheck=function(e){this.sessionInfo?(this.sessionInfo.expectEventId&&this.sessionInfo.currentEventId>=this.sessionInfo.expectEventId&&this.clearWaitExpectedEvent(),this.sessionInfo.currentEventId<e.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")},e.prototype.clearWaitExpectedEvent=function(){this.waitExpectedTimeoutId&&(clearTimeout(this.waitExpectedTimeoutId),this.waitExpectedTimeoutId=void 0)},e}();function T(e){var t={id:e.ID,dataType:e.DataType,queueType:e.QueueType,docId:e.DocID,doc:e.Doc&&"{}"!==e.Doc?JSON.parse(e.Doc):void 0};return"update"===e.DataType&&(e.UpdatedFields&&(t.updatedFields=JSON.parse(e.UpdatedFields)),(e.removedFields||e.RemovedFields)&&(t.removedFields=JSON.parse(e.removedFields))),t}var A,R={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(e){e[e.NormalClosure=1e3]="NormalClosure",e[e.GoingAway=1001]="GoingAway",e[e.ProtocolError=1002]="ProtocolError",e[e.UnsupportedData=1003]="UnsupportedData",e[e.NoStatusReceived=1005]="NoStatusReceived",e[e.AbnormalClosure=1006]="AbnormalClosure",e[e.InvalidFramePayloadData=1007]="InvalidFramePayloadData",e[e.PolicyViolation=1008]="PolicyViolation",e[e.MessageTooBig=1009]="MessageTooBig",e[e.MissingExtension=1010]="MissingExtension",e[e.InternalError=1011]="InternalError",e[e.ServiceRestart=1012]="ServiceRestart",e[e.TryAgainLater=1013]="TryAgainLater",e[e.BadGateway=1014]="BadGateway",e[e.TLSHandshake=1015]="TLSHandshake",e[e.ReconnectWebSocket=3e3]="ReconnectWebSocket",e[e.NoRealtimeListeners=3001]="NoRealtimeListeners",e[e.HeartbeatPingError=3002]="HeartbeatPingError",e[e.HeartbeatPongTimeoutError=3003]="HeartbeatPongTimeoutError",e[e.NoAuthentication=3050]="NoAuthentication"}(A||(A={}));var P=function(e,t){var r=R[e],n=r?"".concat(r.name,", code ").concat(e,", reason ").concat(t||r.description):"code ".concat(e);return new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED,errMsg:n})},C=null,N="web";function x(){return C}function L(){return N}function U(e){N=e}var k=function(){return k=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},k.apply(this,arguments)},D=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},j=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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 e(e){var t=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(e){return D(t,void 0,void 0,(function(){var t=this;return j(this,(function(r){return[2,new Promise((function(r,n){D(t,void 0,void 0,(function(){var t,o,i,s,a,u,c,l,f=this;return j(this,(function(d){switch(d.label){case 0:o=!1,i=!1,s=function(e){o=!0,t&&clearTimeout(t),r(e)},a=function(e){i=!0,t&&clearTimeout(t),n(e)},e.timeout&&(t=setTimeout((function(){D(f,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return o&&i?[3,2]:[4,_(0)];case 1:e.sent(),o&&i||a(new m("wsclient.send timedout")),e.label=2;case 2:return[2]}}))}))}),e.timeout)),d.label=1;case 1:return d.trys.push([1,8,,9]),void 0===this.wsInitPromise&&null===this.wsInitPromise?[3,3]:[4,this.wsInitPromise];case 2:d.sent(),d.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];e.waitResponse&&(u={resolve:s,reject:a,skipOnMessage:e.skipOnMessage},this.wsResponseWait.set(e.msg.requestId,u)),d.label=4;case 4:return d.trys.push([4,6,,7]),[4,this.ws.send(JSON.stringify(e.msg))];case 5:return d.sent(),e.waitResponse||s(void 0),[3,7];case 6:return(c=d.sent())&&(a(c),e.waitResponse&&this.wsResponseWait.delete(e.msg.requestId)),[3,7];case 7:return[3,9];case 8:return l=d.sent(),a(l),[3,9];case 9:return[2]}}))}))}))]}))}))},this.closeAllClients=function(e){t.virtualWSClient.forEach((function(t){t.closeWithError(e)}))},this.pauseClients=function(e){(e||t.virtualWSClient).forEach((function(e){e.pause()}))},this.resumeClients=function(e){(e||t.virtualWSClient).forEach((function(e){e.resume()}))},this.initWebSocketConnection=function(e,r){return void 0===r&&(r=t.maxReconnect),D(t,void 0,void 0,(function(){var t=this;return j(this,(function(n){switch(n.label){case 0:if(e&&this.reconnectState)return[2];if(e&&(this.reconnectState=!0),void 0!==this.wsInitPromise&&null!==this.wsInitPromise)return[2,this.wsInitPromise];e&&this.pauseClients(),this.close(A.ReconnectWebSocket),this.wsInitPromise=new Promise((function(n,o){D(t,void 0,void 0,(function(){var t,i,s=this;return j(this,(function(a){switch(a.label){case 0:return a.trys.push([0,6,,11]),[4,this.getWsSign()];case 1:return t=a.sent(),[4,new Promise((function(e){var r=t.wsUrl||"wss://tcb-ws.tencentcloudapi.com",n=x();s.ws=n?new n(r):new WebSocket(r),e(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(),e&&(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(),e&&(this.reconnectState=!1),a.label=8;case 8:return n(this.initWebSocketConnection(e,r-1)),[3,10];case 9:o(i),e&&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(e){return(0,e.resolve)()})),[3,5];case 3:return n.sent(),this.wsReadySubsribers.forEach((function(e){return(0,e.reject)()})),[3,5];case 4:return this.wsInitPromise=void 0,this.wsReadySubsribers=[],[7];case 5:return[2]}}))}))},this.initWebSocketEvent=function(){return new Promise((function(e,r){if(!t.ws)throw new Error("can not initWebSocketEvent, ws not exists");var n=!1;t.ws.onopen=function(t){console.warn("[realtime] ws event: open",t),n=!0,e()},t.ws.onerror=function(e){t.logins=new Map,n?(console.error("[realtime] ws event: error",e),t.clearHeartbeat(),t.virtualWSClient.forEach((function(t){return t.closeWithError(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR,errMsg:e}))}))):(console.error("[realtime] ws open failed with ws event: error",e),r(e))},t.ws.onclose=function(e){switch(console.warn("[realtime] ws event: close",e),t.logins=new Map,t.clearHeartbeat(),e.code){case A.ReconnectWebSocket:case A.NoRealtimeListeners:break;case A.HeartbeatPingError:case A.HeartbeatPongTimeoutError:case A.NormalClosure:case A.AbnormalClosure:t.maxReconnect>0?t.initWebSocketConnection(!0,t.maxReconnect):t.closeAllClients(P(e.code));break;case A.NoAuthentication:t.closeAllClients(P(e.code,e.reason));break;default:t.maxReconnect>0?t.initWebSocketConnection(!0,t.maxReconnect):t.closeAllClients(P(e.code))}},t.ws.onmessage=function(e){var r,n,o=(null===(r=e.data)||void 0===r?void 0:r.data)||e.data;t.heartbeat();try{n="string"==typeof o?JSON.parse(o):o}catch(e){throw new Error("[realtime] onMessage parse res.data error: ".concat(e))}if("ERROR"===n.msgType){var i=null;t.virtualWSClient.forEach((function(e){e.watchId===n.watchId&&(i=e)})),i&&i.listener.onError(n)}var s=t.wsResponseWait.get(n.requestId);if(s){try{"ERROR"===n.msgType?s.reject(new v(n)):s.resolve(n)}catch(e){console.error("ws onMessage responseWaitSpec.resolve(msg) errored:",e)}finally{t.wsResponseWait.delete(n.requestId)}if(s.skipOnMessage)return}if("PONG"!==n.msgType){var a=n.watchId&&t.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=t.queryIdClientMap.get(n.msgData.queryID))&&a.onMessage(n);break;default:for(var u=0,c=Array.from(t.watchIdClientMap.entries());u<c.length;u++){c[u][1].onMessage(n);break}}}else if(t.lastPingSendTS){var l=Date.now()-t.lastPingSendTS;if(l>1e4)return void console.warn("[realtime] untrusted rtt observed: ".concat(l));t.rttObserved.length>=3&&t.rttObserved.splice(0,t.rttObserved.length-3+1),t.rttObserved.push(l)}},t.heartbeat()}))},this.isWSConnected=function(){return Boolean(t.ws&&1===t.ws.readyState)},this.onceWSConnected=function(){return D(t,void 0,void 0,(function(){var e=this;return j(this,(function(t){return this.isWSConnected()?[2]:null!==this.wsInitPromise&&void 0!==this.wsInitPromise?[2,this.wsInitPromise]:[2,new Promise((function(t,r){e.wsReadySubsribers.push({resolve:t,reject:r})}))]}))}))},this.webLogin=function(e,r){return D(t,void 0,void 0,(function(){var t,n,o,i,s,a,u,l,f=this;return j(this,(function(d){switch(d.label){case 0:if(!r)if(e){if(t=this.logins.get(e)){if(t.loggedIn&&t.loginResult)return[2,t.loginResult];if(null!==t.loggingInPromise&&void 0!==t.loggingInPromise)return[2,t.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(e,t){D(f,void 0,void 0,(function(){var r,n,o,i,s;return j(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?t(new Error("".concat(i.msgData.code," ").concat(i.msgData.message))):e({envId:r.envId}),[3,4];case 3:return s=a.sent(),t(s),[3,4];case 4:return[2]}}))}))})),i=e&&this.logins.get(e),s=Date.now(),i?(i.loggedIn=!1,i.loggingInPromise=o,i.loginStartTS=s):(i={loggedIn:!1,loggingInPromise:o,loginStartTS:s},this.logins.set(e||"",i)),d.label=1;case 1:return d.trys.push([1,3,,4]),[4,o];case 2:if(a=d.sent(),(u=e&&this.logins.get(e))&&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=d.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 D(t,void 0,void 0,(function(){var e,t,r,n,o,i,s;return j(this,(function(a){switch(a.label){case 0:return this.wsSign&&this.wsSign.expiredTs>Date.now()?[2,this.wsSign]:(e=Date.now()+6e4,[4,this.context.appConfig.request.send("auth.wsWebSign",{runtime:L()})]);case 1:if((t=a.sent()).code)throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败: ".concat(t.code));if(t.data)return r=t.data,n=r.signStr,o=r.wsUrl,i=r.secretVersion,s=r.envId,[2,{signStr:n,wsUrl:o,secretVersion:i,envId:s,expiredTs:e}];throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败")}}))}))},this.getWaitExpectedTimeoutLength=function(){return t.rttObserved.length?t.rttObserved.reduce((function(e,t){return e+t}))/t.rttObserved.length*1.5:5e3},this.ping=function(){return D(t,void 0,void 0,(function(){var e;return j(this,(function(t){switch(t.label){case 0:return e={watchId:void 0,requestId:c(),msgType:"PING",msgData:null},[4,this.send({msg:e})];case 1:return t.sent(),[2]}}))}))},this.onWatchStart=function(e,r){t.queryIdClientMap.set(r,e)},this.onWatchClose=function(e,r){r&&t.queryIdClientMap.delete(r),t.watchIdClientMap.delete(e.watchId),t.virtualWSClient.delete(e),t.virtualWSClient.size||t.close(A.NoRealtimeListeners)},this.maxReconnect=e.maxReconnect||5,this.reconnectInterval=e.reconnectInterval||1e4,this.context=e.context}return e.prototype.clearHeartbeat=function(){this.pingTimeoutId&&clearTimeout(this.pingTimeoutId),this.pongTimeoutId&&clearTimeout(this.pongTimeoutId)},e.prototype.close=function(e){this.clearHeartbeat(),this.ws&&(this.ws.close(e,R[e].name),this.ws=void 0)},e.prototype.watch=function(e){this.ws||void 0!==this.wsInitPromise&&null!==this.wsInitPromise||this.initWebSocketConnection(!1);var t=new O(k(k({},e),{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(t),this.watchIdClientMap.set(t.watchId,t),t.listener},e.prototype.heartbeat=function(e){var t=this;this.clearHeartbeat(),this.pingTimeoutId=setTimeout((function(){D(t,void 0,void 0,(function(){var e=this;return j(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),this.ws&&1===this.ws.readyState?(this.lastPingSendTS=Date.now(),[4,this.ping()]):[2];case 1:return t.sent(),this.pingFailed=0,this.pongTimeoutId=setTimeout((function(){console.error("pong timed out"),e.pongMissed<2?(e.pongMissed+=1,e.heartbeat(!0)):e.initWebSocketConnection(!0)}),this.context.appConfig.realtimePongWaitTimeout),[3,3];case 2:return t.sent(),this.pingFailed<2?(this.pingFailed+=1,this.heartbeat()):this.close(A.HeartbeatPingError),[3,3];case 3:return[2]}}))}))}),e?0:this.context.appConfig.realtimePingInterval)},e}(),M={target:"database",entity:function(){var e,t=this.platform,r=t.adapter,n=t.runtime;e=r.wsClass,C=e,U(n)}},B={name:"realtime",IIFE:!0,entity:function(){this.prototype.wsClientClass=q}};try{cloudbase.registerComponent(B),cloudbase.registerHook(M)}catch(e){}function W(e){try{e.registerComponent(B),e.registerHook(M)}catch(e){console.warn(e)}}},534:function(e,t,r){"use strict";r.r(t),r.d(t,{COMPONENT_NAME:function(){return I},CloudbaseStorage:function(){return P},SupabaseFileAPILikeStorage:function(){return x},registerStorage:function(){return U}});var n,o,i=(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),s=function(e){function t(t){var r=e.call(this,t)||this;return r.__isStorageError=!0,r.name="StorageError",r}return i(t,e),t}(Error);function a(e){return"object"==typeof e&&null!==e&&"__isStorageError"in e}(function(e){function t(t,r,n){var o=e.call(this,t)||this;return o.name="StorageApiError",o.status=r,o.statusCode=n,o}i(t,e),t.prototype.toJSON=function(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}})(s),i((function(e,t){var r=o.call(this,e)||this;return r.name="StorageUnknownError",r.originalError=t,r}),o=s);var u,c=r(3616),l=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};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)}}(),f=function(){return f=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},f.apply(this,arguments)},d=function(e,t,r,n){var o,i=arguments.length,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s},h=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},p=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},v=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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(e){e.put="put",e.post="post"}(u||(u={}));var y=c._G.eX,m=c._G.Sg,g=c._G.vM,b=c.P6.isArray,w=c.P6.isString,_=c.P6.isPalinObject,S=c.P6.execCallback,E=c.BM.D,I="storage",O=function(e,t,r){return p(void 0,void 0,void 0,(function(){var n,o,i;return v(this,(function(s){switch(s.label){case 0:return[4,e.gateWay({path:"storages",name:"get-objects-upload-info",data:[f({objectId:t.path},t.headers?{signedHeader:Object.keys(t.headers).reduce((function(e,r){var n;return f(f({},e),((n={})[r]=[t.headers[r]],n))}),{})}:{})]},r)];case 1:return n=s.sent(),o=(null===(i=n.data)||void 0===i?void 0:i[0])||{},[2,n=f(f({},n),{data:f(f({},o.code?f({},o):{}),{authorization:o.authorization,token:o.token,url:o.uploadUrl,fileId:o.cloudObjectId,cosFileId:o.cloudObjectMeta,download_url:o.downloadUrl})})]}}))}))},T=function(e,t,r){return p(void 0,void 0,void 0,(function(){var n,o;return v(this,(function(i){switch(i.label){case 0:return[4,e.gateWay({path:"storages",name:"get-objects-download-info",data:t.convertedFileList.map((function(e){return{cloudObjectId:e.fileid}}))},r)];case 1:return n=i.sent(),[2,n=f(f({},n),{data:{download_list:null===(o=n.data)||void 0===o?void 0:o.map((function(e){return{code:e.code||"SUCCESS",message:e.message,fileid:e.cloudObjectId,download_url:e.downloadUrl,fileID:e.cloudObjectId,tempFileURL:e.downloadUrl}}))}})]}}))}))},A=function(e,t,r){return p(void 0,void 0,void 0,(function(){var n,o;return v(this,(function(i){switch(i.label){case 0:return[4,e.gateWay({path:"storages",name:"delete-objects",data:t.fileList.map((function(e){return{cloudObjectId:e}}))},r)];case 1:return n=i.sent(),[2,n=f(f({},n),{data:{delete_list:null===(o=n.data)||void 0===o?void 0:o.map((function(e){return{code:e.code||"SUCCESS",fileID:e.cloudObjectId,message:e.message}}))}})]}}))}))},R=function(e,t,r){return p(void 0,void 0,void 0,(function(){var n,o;return v(this,(function(i){switch(i.label){case 0:return[4,e.gateWay({path:"storages",name:"copy-objects",data:t.convertedFileList.map((function(e){return{srcPath:e.src_path,dstPath:e.dst_path,overwrite:e.overwrite,removeOriginal:e.remove_original}}))},r)];case 1:return n=i.sent(),[2,n=f(f({},n),{data:{copy_list:null===(o=n.data)||void 0===o?void 0:o.map((function(e){return{code:e.code||"SUCCESS",fileID:e.cloudObjectId,message:e.message}}))}})]}}))}))},P=function(){function e(){}return e.prototype.isGateWay=function(){return"GATEWAY"===(this.config.endPointMode||"CLOUD_API")},e.prototype.uploadFile=function(e,t){return p(this,void 0,void 0,(function(){var r,n,o,i,s,a,c,l,d,h,p,g,b,_,E,O,T,A,R,P,C,N,x,L;return v(this,(function(v){switch(v.label){case 0:if(r=e.cloudPath,n=e.filePath,o=e.onUploadProgress,N=e.method,i=void 0===N?"put":N,x=e.headers,s=void 0===x?{}:x,a=e.fileContent,!w(r)||!n&&!a)throw new Error(JSON.stringify({code:m.INVALID_PARAMS,msg:"[".concat(I,".uploadFile] invalid params")}));return c={put:u.put,post:u.post}[i.toLocaleLowerCase()]||u.put,[4,this.getUploadMetadata({cloudPath:r,method:c,headers:c===u.put?s:void 0,customReqOpts:e.customReqOpts})];case 1:return l=v.sent(),d=l.data,h=l.requestId,p=d.url,g=d.authorization,b=d.token,_=d.fileId,E=d.cosFileId,O=d.download_url,A=f(f({},T={url:p,file:n,name:r,onUploadProgress:o,fileContent:a,fileId:_,requestId:h}),{method:u.put,headers:f(f({},s),{authorization:g,"x-cos-meta-fileid":E,"x-cos-security-token":b})}),R=f(f({},T),{method:u.post,data:{key:r,signature:g,"x-cos-meta-fileid":E,success_action_status:"201","x-cos-security-token":b}}),(L={})[u.put]={params:A,isSuccess:function(e){return e>=200&&e<300}},L[u.post]={params:R,isSuccess:function(e){return 201===e}},P=L,[4,this.request.upload(P[c].params)];case 2:return C=v.sent(),P[c].isSuccess(C.statusCode)?[2,S(t,null,{fileID:_,download_url:O,requestId:h})]:[2,S(t,new Error("[".concat(y(),"][").concat(m.OPERATION_FAIL,"][").concat(I,"]:").concat(C.data)))]}}))}))},e.prototype.getUploadMetadata=function(e,t){return p(this,void 0,void 0,(function(){var r,n,o,i,s,a,c,l;return v(this,(function(f){switch(f.label){case 0:if(r=e.cloudPath,n=e.method,o=e.headers,!w(r))throw new Error(JSON.stringify({code:m.INVALID_PARAMS,msg:"[".concat(I,".getUploadMetadata] invalid cloudPath")}));i=this.request,s="storage.getUploadMetadata",f.label=1;case 1:return f.trys.push([1,6,,7]),a=void 0,c={path:r},n&&(c.method=n),n===u.put&&o&&(c.headers=o),this.isGateWay()?[4,O(i,c,e.customReqOpts)]:[3,3];case 2:return a=f.sent(),[3,5];case 3:return[4,i.send(s,c,e.customReqOpts)];case 4:a=f.sent(),f.label=5;case 5:return[2,S(t,null,a)];case 6:return l=f.sent(),[2,S(t,l)];case 7:return[2]}}))}))},e.prototype.deleteFile=function(e,t){return p(this,void 0,void 0,(function(){var r,n,o,i,s,a,u,c;return v(this,(function(l){switch(l.label){case 0:if(!(r=e.fileList)||!b(r)||0===r.length)throw new Error(JSON.stringify({code:m.INVALID_PARAMS,msg:"[".concat(I,".deleteFile] fileList must not be empty")}));for(n=0,o=r;n<o.length;n++)if(!(i=o[n])||!w(i))throw new Error(JSON.stringify({code:m.INVALID_PARAMS,msg:"[".concat(I,".deleteFile] fileID must be string")}));return s="storage.batchDeleteFile",a=this.request,u={},this.isGateWay()?[4,A(a,{fileList:r},e.customReqOpts)]:[3,2];case 1:return u=l.sent(),[3,4];case 2:return[4,a.send(s,{fileid_list:r},e.customReqOpts)];case 3:u=l.sent(),l.label=4;case 4:return u.code?[2,S(t,null,u)]:(c={fileList:u.data.delete_list,requestId:u.requestId},[2,S(t,null,c)])}}))}))},e.prototype.getTempFileURL=function(e,t){return p(this,void 0,void 0,(function(){var r,n,o,i,s,a,u,c;return v(this,(function(l){switch(l.label){case 0:if(!(r=e.fileList)||!b(r)||0===r.length)throw new Error(JSON.stringify({code:m.INVALID_PARAMS,msg:"[".concat(I,".getTempFileURL] fileList must not be empty")}));for(n=[],o=0,i=r;o<i.length;o++)if(s=i[o],_(s)){if(!Object.prototype.hasOwnProperty.call(s,"fileID"))throw new Error(JSON.stringify({code:m.INVALID_PARAMS,msg:"[".concat(I,".getTempFileURL] file info must include fileID")}));n.push({fileid:s.fileID,max_age:s.maxAge||7200})}else{if(!w(s))throw new Error(JSON.stringify({code:m.INVALID_PARAMS,msg:"[".concat(I,".getTempFileURL] invalid fileList")}));n.push({fileid:s})}return a="storage.batchGetDownloadUrl",u=this.request,c={},this.isGateWay()?[4,T(u,{convertedFileList:n},e.customReqOpts)]:[3,2];case 1:return c=l.sent(),[3,4];case 2:return[4,u.send(a,{file_list:n},e.customReqOpts)];case 3:c=l.sent(),l.label=4;case 4:return c.code?[2,S(t,null,c)]:[2,S(t,null,{fileList:c.data.download_list,requestId:c.requestId})]}}))}))},e.prototype.downloadFile=function(e,t){return p(this,void 0,void 0,(function(){var r,n,o,i,s,a;return v(this,(function(u){switch(u.label){case 0:if(r=e.fileID,!w(r))throw new Error(JSON.stringify({code:m.INVALID_PARAMS,msg:"[".concat(I,".getTempFileURL] fileID must be string")}));return[4,this.getTempFileURL.call(this,{fileList:[{fileID:r,maxAge:600}],customReqOpts:e.customReqOpts})];case 1:return n=u.sent(),"SUCCESS"!==(o=n.fileList[0]).code?[2,S(t,o)]:(i=this.request,s=encodeURI(o.download_url),[4,i.download({url:s,tempFilePath:e.tempFilePath})]);case 2:return a=u.sent(),[2,S(t,null,a)]}}))}))},e.prototype.copyFile=function(e,t){return p(this,void 0,void 0,(function(){var r,n,o,i,s,a,u,c,l;return v(this,(function(f){switch(f.label){case 0:if(!(r=e.fileList)||!b(r)||0===r.length)throw new Error(JSON.stringify({code:m.INVALID_PARAMS,msg:"[".concat(I,".copyFile] fileList must not be empty")}));for(n=[],o=0,i=r;o<i.length;o++){if(s=i[o],a=s.srcPath,u=s.dstPath,!a||!u||"string"!=typeof a||"string"!=typeof u)throw new Error(JSON.stringify({code:m.INVALID_PARAMS,msg:"[".concat(I,".copyFile] srcPath and dstPath may not be empty")}));if(a===u)throw new Error(JSON.stringify({code:m.INVALID_PARAMS,msg:"[".concat(I,".copyFile] srcPath and dstPath can not be the same")}));n.push({src_path:a,dst_path:u,overwrite:s.overwrite,remove_original:s.removeOriginal})}return c=this.request,l={},this.isGateWay()?[4,R(c,{convertedFileList:n},e.customReqOpts)]:[3,2];case 1:return l=f.sent(),[3,4];case 2:return[4,c.send("storage.batchCopyFile",{file_list:n},e.customReqOpts)];case 3:l=f.sent(),f.label=4;case 4:return l.code?[2,S(t,null,l)]:[2,S(t,null,{fileList:l.data.copy_list,requestId:l.requestId})]}}))}))},e.prototype.getFileInfo=function(e){var t;return p(this,void 0,void 0,(function(){var r,n=this;return v(this,(function(o){switch(o.label){case 0:return[4,this.getTempFileURL(e)];case 1:return(null==(r=o.sent())?void 0:r.fileList)&&(null===(t=null==r?void 0:r.fileList)||void 0===t?void 0:t.length)>0?[4,Promise.all(r.fileList.map((function(e){return p(n,void 0,void 0,(function(){var t,r,n,o,i;return v(this,(function(s){switch(s.label){case 0:if("SUCCESS"!==e.code)return[2,{code:e.code,fileID:e.fileID,tempFileURL:e.tempFileURL,message:e.message}];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.request.fetch({url:e.tempFileURL,method:"HEAD"})];case 2:return t=s.sent(),r=t.header,Headers&&r instanceof Headers&&(r=Object.fromEntries(t.header.entries())),n=parseInt(r["content-length"])||0,o=r["content-type"]||"",[400,404].includes(Number(t.statusCode))?[2,{code:"FILE_NOT_FOUND",fileID:e.fileID,tempFileURL:e.tempFileURL,message:"file not found"}]:[2,{code:e.code,fileID:e.fileID,tempFileURL:e.tempFileURL,cloudId:e.fileID,fileName:e.fileID.split("/").pop(),contentType:o,mime:o.split(";")[0].trim(),size:n,etag:r.etag||"",lastModified:r["last-modified"]||"",cacheControl:r["cache-control"]||""}];case 3:return i=s.sent(),[2,{code:"FETCH_FILE_INFO_ERROR",fileID:e.fileID,tempFileURL:e.tempFileURL,message:i.message}];case 4:return[2]}}))}))})))]:[3,3];case 2:return[2,{fileList:o.sent(),requestId:r.requestId}];case 3:return[2,{fileList:[],requestId:r.requestId}]}}))}))},d([E({customInfo:{className:"Cloudbase",methodName:"uploadFile"},title:"上传文件失败",messages:["请确认以下各项:"," 1 - 调用 uploadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(g)]}),h("design:type",Function),h("design:paramtypes",[Object,Function]),h("design:returntype",Promise)],e.prototype,"uploadFile",null),d([E({customInfo:{className:"Cloudbase",methodName:"getUploadMetadata"},title:"获取上传元信息失败",messages:["请确认以下各项:"," 1 - 调用 getUploadMetadata() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(g)]}),h("design:type",Function),h("design:paramtypes",[Object,Function]),h("design:returntype",Promise)],e.prototype,"getUploadMetadata",null),d([E({customInfo:{className:"Cloudbase",methodName:"deleteFile"},title:"删除文件失败",messages:["请确认以下各项:"," 1 - 调用 deleteFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(g)]}),h("design:type",Function),h("design:paramtypes",[Object,Function]),h("design:returntype",Promise)],e.prototype,"deleteFile",null),d([E({customInfo:{className:"Cloudbase",methodName:"getTempFileURL"},title:"获取文件下载链接",messages:["请确认以下各项:"," 1 - 调用 getTempFileURL() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(g)]}),h("design:type",Function),h("design:paramtypes",[Object,Function]),h("design:returntype",Promise)],e.prototype,"getTempFileURL",null),d([E({customInfo:{className:"Cloudbase",methodName:"downloadFile"},title:"下载文件失败",messages:["请确认以下各项:"," 1 - 调用 downloadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(g)]}),h("design:type",Function),h("design:paramtypes",[Object,Function]),h("design:returntype",Promise)],e.prototype,"downloadFile",null),d([E({customInfo:{className:"Cloudbase",methodName:"copyFile"},title:"批量复制文件",messages:["请确认以下各项:"," 1 - 调用 copyFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(g)]}),h("design:type",Function),h("design:paramtypes",[Object,Function]),h("design:returntype",Promise)],e.prototype,"copyFile",null),e}(),C=new P,N={name:I,entity:{uploadFile:C.uploadFile,deleteFile:C.deleteFile,getTempFileURL:C.getTempFileURL,downloadFile:C.downloadFile,getUploadMetadata:C.getUploadMetadata,copyFile:C.copyFile,getFileInfo:C.getFileInfo,isGateWay:C.isGateWay}},x=function(e){function t(t){var r=e.call(this)||this;return r.shouldThrowOnError=!1,r.bucketId="",r.context=t,r}return l(t,e),Object.defineProperty(t.prototype,"config",{get:function(){var e;return null===(e=this.context)||void 0===e?void 0:e.config},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"request",{get:function(){var e;return null===(e=this.context)||void 0===e?void 0:e.request},enumerable:!1,configurable:!0}),t.prototype.throwOnError=function(){return this.shouldThrowOnError=!0,this},t.prototype.from=function(e){return this.bucketId=e||"",this},t.prototype.upload=function(e,t,r){return p(this,void 0,void 0,(function(){var n,o,i,s,u,c,l,d,h;return v(this,(function(p){switch(p.label){case 0:n=f({upsert:!0},r),o=n.cacheControl,i=n.contentType,s=n.metadata,p.label=1;case 1:return p.trys.push([1,3,,4]),u=this._getCloudPath(e),c={cloudPath:u,filePath:t},(o||i||s)&&(l={},o&&(l["cache-control"]=o),i&&(l["content-type"]=i),s&&(l["x-cos-metadata-metadata"]=this.toBase64(JSON.stringify(s))),c.headers=l),[4,this.uploadFile(c)];case 2:if(!(d=p.sent()).fileID)throw new Error(JSON.stringify({code:m.OPERATION_FAIL,msg:"[".concat(I,".update] no fileID returned")}));return[2,{data:{id:d.fileID,path:e,fullPath:e},error:null}];case 3:if(h=p.sent(),this.shouldThrowOnError)throw h;if(a(h))return[2,{data:null,error:h}];throw h;case 4:return[2]}}))}))},t.prototype.uploadToSignedUrl=function(e,t,r,n){return p(this,void 0,void 0,(function(){return v(this,(function(t){return[2,this.upload(e,r,n)]}))}))},t.prototype.createSignedUploadUrl=function(e){return p(this,void 0,void 0,(function(){var t,r,n;return v(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),t=this._getCloudPath(e),[4,this.getUploadMetadata({cloudPath:t})];case 1:return[2,{data:{signedUrl:(r=o.sent().data).url,token:r.token,path:e,authorization:r.authorization,id:r.fileId,cosFileId:r.cosFileId,downloadUrl:r.download_url},error:null}];case 2:if(n=o.sent(),this.shouldThrowOnError)throw n;return[2,{data:null,error:n instanceof s?n:new s(n.message)}];case 3:return[2]}}))}))},t.prototype.update=function(e,t,r){return p(this,void 0,void 0,(function(){return v(this,(function(n){return[2,this.upload(e,t,f(f({},r),{upsert:!0}))]}))}))},t.prototype.move=function(e,t){return p(this,void 0,void 0,(function(){var r,n;return v(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.copyFile({fileList:[{srcPath:this._getCloudPath(e),dstPath:this._getCloudPath(t),overwrite:!0,removeOriginal:!0}]})];case 1:if((r=o.sent()).fileList[0].code&&"SUCCESS"!==r.fileList[0].code)throw new s(r.fileList[0].message||"Move failed");return[2,{data:{message:"File moved from ".concat(e," to ").concat(t)},error:null}];case 2:if(n=o.sent(),this.shouldThrowOnError)throw n;if(a(n))return[2,{data:null,error:n}];throw n;case 3:return[2]}}))}))},t.prototype.copy=function(e,t){return p(this,void 0,void 0,(function(){var r,n;return v(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.copyFile({fileList:[{srcPath:this._getCloudPath(e),dstPath:this._getCloudPath(t),overwrite:!0,removeOriginal:!1}]})];case 1:if((r=o.sent()).fileList[0].code&&"SUCCESS"!==r.fileList[0].code)throw new s(r.fileList[0].message||"Copy failed");return[2,{data:{path:this._getCloudPath(t)},error:null}];case 2:if(n=o.sent(),this.shouldThrowOnError)throw n;if(a(n))return[2,{data:null,error:n}];throw n;case 3:return[2]}}))}))},t.prototype.createSignedUrl=function(e,t,r){return p(this,void 0,void 0,(function(){var n,o,i,u,c,l,f;return v(this,(function(d){switch(d.label){case 0:return d.trys.push([0,2,,3]),n=this._normalizeCloudId(e),[4,this.getTempFileURL({fileList:[{fileID:n,maxAge:t}]})];case 1:if("SUCCESS"!==(o=d.sent()).fileList[0].code)throw new s("Failed to create signed URL: [".concat(o.fileList[0].code,"] ").concat(o.fileList[0].fileID));return i=o.fileList[0].download_url,u=[],void 0!==(null==r?void 0:r.download)&&("string"==typeof r.download?u.push("download=".concat(encodeURIComponent(r.download))):!0===r.download&&u.push("download=true")),(null==r?void 0:r.transform)&&(c=this._transformOptsToQueryString(r.transform))&&u.push(c),u.length>0&&(l=i.includes("?")?"&":"?",i="".concat(i).concat(l).concat(u.join("&"))),[2,{data:{signedUrl:i},error:null}];case 2:if(f=d.sent(),this.shouldThrowOnError)throw f;if(a(f))return[2,{data:null,error:f}];throw f;case 3:return[2]}}))}))},t.prototype.createSignedUrls=function(e,t){return p(this,void 0,void 0,(function(){var r,n,o=this;return v(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),r=e.map((function(e){return{fileID:o._normalizeCloudId(e),maxAge:t}})),[4,this.getTempFileURL({fileList:r})];case 1:return[2,{data:i.sent().fileList.map((function(t,r){return{path:e[r],signedUrl:t.tempFileURL||"",error:"SUCCESS"===t.code?null:t.message}})),error:null}];case 2:if(n=i.sent(),this.shouldThrowOnError)throw n;if(a(n))return[2,{data:null,error:n}];throw n;case 3:return[2]}}))}))},t.prototype.download=function(e,t){return p(this,void 0,void 0,(function(){var r,n,o=this;return v(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),n={},[4,p(o,void 0,void 0,(function(){var r,n,o,i;return v(this,(function(a){switch(a.label){case 0:return[4,this.createSignedUrl(e,600,{transform:t})];case 1:if((r=a.sent()).error)throw r.error;return n=encodeURI(null===(i=r.data)||void 0===i?void 0:i.signedUrl),[4,this.request.reqClass.get({url:n,headers:{},responseType:"blob"})];case 2:if(!(o=a.sent().data))throw new s("Download failed: no file content");return[2,new Blob([o])]}}))}))];case 1:return[2,(n.data=i.sent(),n.error=null,n)];case 2:if(r=i.sent(),this.shouldThrowOnError)throw r;if(a(r))return[2,{data:null,error:r}];throw r;case 3:return[2]}}))}))},t.prototype.info=function(e){return p(this,void 0,void 0,(function(){var t,r,n,o,i,a,u,c;return v(this,(function(l){switch(l.label){case 0:return l.trys.push([0,2,,3]),t=e.startsWith("cloud://"),r=t?this._extractPathFromFileId(e):e,n=t?this._extractBucketFromFileId(e):this.bucketId,[4,this.getFileInfo({fileList:[this._normalizeCloudId(e)]})];case 1:if(o=l.sent(),"SUCCESS"!==(i=o.fileList[0]).code)throw new s(i.message);return a=(new Date).toISOString(),u=(i.lastModified?new Date(i.lastModified):new Date).toISOString(),[2,{data:{id:i.fileID,version:"1",name:r,bucketId:n,updatedAt:u,createdAt:u,lastAccessedAt:a,size:i.size,cacheControl:i.cacheControl,contentType:i.contentType,etag:i.etag,lastModified:u,metadata:{}},error:null}];case 2:if(c=l.sent(),this.shouldThrowOnError)throw c;return[2,{data:null,error:c instanceof s?c:new s(c.message)}];case 3:return[2]}}))}))},t.prototype.exists=function(e){return p(this,void 0,void 0,(function(){var t,r,n;return v(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.getFileInfo({fileList:[this._normalizeCloudId(e)]})];case 1:if(t=o.sent(),"FILE_NOT_FOUND"===(r=t.fileList[0]).code)return[2,{data:!1,error:null}];if("SUCCESS"!==r.code)throw new s(r.message);return[2,{data:!0,error:null}];case 2:if(n=o.sent(),this.shouldThrowOnError)throw n;if(a(n))return[2,{data:null,error:n}];throw n;case 3:return[2]}}))}))},t.prototype.getPublicUrl=function(e,t){return p(this,void 0,void 0,(function(){var r;return v(this,(function(n){switch(n.label){case 0:return[4,this.createSignedUrl(e,600,t)];case 1:return(r=n.sent()).data?[2,{data:{publicUrl:r.data.signedUrl}}]:[2,{data:null,error:r.error}]}}))}))},t.prototype.remove=function(e){return p(this,void 0,void 0,(function(){var t,r,n,o,i,u,c,l,f,d,h=this;return v(this,(function(p){switch(p.label){case 0:for(p.trys.push([0,3,,4]),t=10,r=[],n=0;n<e.length;n+=t)r.push(e.slice(n,n+t));return[4,Promise.all(r.map((function(e){return Promise.all(e.map((function(e){return h.info(e)})))})))];case 1:return o=p.sent(),i=new Map,o.flat().forEach((function(r,n){r.data&&i.set(e[Math.floor(n/t)*t+n%t],r.data)})),u=e.map((function(e){return h._normalizeCloudId(e)})),[4,this.deleteFile({fileList:u})];case 2:if(c=p.sent(),(l=c.fileList.filter((function(e){return"SUCCESS"!==e.code}))).length>0)throw new s("Delete failed for ".concat(l.length," file(s)"));return f=(new Date).toISOString(),[2,{data:e.map((function(e){var t=i.get(e);return{name:null==t?void 0:t.name,id:null==t?void 0:t.id,bucket_id:null==t?void 0:t.bucketId,owner:void 0,updated_at:(null==t?void 0:t.updatedAt)||f,created_at:null==t?void 0:t.createdAt,last_accessed_at:(null==t?void 0:t.lastAccessedAt)||f,metadata:(null==t?void 0:t.metadata)||{},buckets:{id:null==t?void 0:t.bucketId,name:null==t?void 0:t.bucketId,owner:void 0,public:!1,created_at:"",updated_at:f}}})),error:null}];case 3:if(d=p.sent(),this.shouldThrowOnError)throw d;if(a(d))return[2,{data:null,error:d}];throw d;case 4:return[2]}}))}))},t.prototype.list=function(){return p(this,void 0,void 0,(function(){return v(this,(function(e){throw new s("Not implemented")}))}))},t.prototype._getCloudPath=function(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")},t.prototype._normalizeCloudId=function(e){var t;if(/^cloud:\/\//.test(e))return e;var r=this._getCloudPath(e);if(!this.bucketId)throw new s("bucketId is not set");var n=(null===(t=this.config)||void 0===t?void 0:t.env)||"";return n?"cloud://".concat(n,".").concat(this.bucketId,"/").concat(r):void 0},t.prototype.toBase64=function(e){return"undefined"!=typeof Buffer?Buffer.from(e).toString("base64"):btoa(e)},t.prototype._transformOptsToQueryString=function(e){var t=["imageMogr2"];if(e.width||e.height){var r=e.width||"",n=e.height||"";"fill"===e.resize?t.push("thumbnail/".concat(r,"x").concat(n,"!")):"contain"===e.resize?t.push("thumbnail/".concat(r,"x").concat(n)):t.push("thumbnail/".concat(r,"x").concat(n,"^"))}if(e.format&&"origin"!==e.format&&t.push("format/".concat(e.format)),void 0!==e.quality){var o=Math.max(1,Math.min(100,e.quality));t.push("quality/".concat(o))}return t.join("/")},t.prototype._extractPathFromFileId=function(e){var t=e.replace(/^cloud:\/\//,"").split("/");return t.length<2?e:t.slice(1).join("/")},t.prototype._extractBucketFromFileId=function(e){var t=e.replace(/^cloud:\/\//,"").split("/");if(t.length<1)return"";var r=t[0],n=r.indexOf(".");return-1===n?r:r.substring(n+1)},t}(P),L={name:"".concat(I,"/supabase"),IIFE:!0,entity:function(){var e=new WeakMap;Object.defineProperty(this.prototype,"storage",{get:function(){if(e.has(this))return e.get(this);var t=this,r=new Proxy({},{get:function(e,r){return"config"===r?t.config:"request"===r?t.request:void 0}}),n=new x(r);return e.set(this,n),n},configurable:!0,enumerable:!0})}};try{cloudbase.registerComponent(N),cloudbase.registerComponent(L)}catch(e){}function U(e){try{e.registerComponent(N),e.registerComponent(L)}catch(e){console.warn(e)}}try{window.registerStorage=U}catch(e){}},8182:function(e,t,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.useDefaultAdapter=t.useAdapters=t.RUNTIME=void 0;var a,u=s(r(4274)),c=r(5605);!function(e){e.WEB="web",e.WX_MP="wx_mp"}(a=t.RUNTIME||(t.RUNTIME={})),t.useAdapters=function(e,t){for(var r=0,o=(0,c.isArray)(e)?e:[e];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(t)),runtime:u}}},t.useDefaultAdapter=function(){return{adapter:n({},u.genAdapter()),runtime:a.WEB}}},4274:function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)},s=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},a=this&&this.__generator||function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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(t,"__esModule",{value:!0}),t.WebRequest=t.genAdapter=void 0;var u=r(2829),c=r(5605),l=r(2946),f=function(e){function t(t){var r=e.call(this)||this,n=t.timeout,o=t.timeoutMsg,i=t.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=o||"请求超时",r.restrictedMethods=i||["get","post","upload","download"],r}return o(t,e),t.prototype.get=function(e){return this.request(i(i({},e),{method:"get"}),this.restrictedMethods.includes("get"))},t.prototype.post=function(e){return this.request(i(i({},e),{method:"post"}),this.restrictedMethods.includes("post"))},t.prototype.put=function(e){return this.request(i(i({},e),{method:"put"}))},t.prototype.upload=function(e){var t=e.data,r=e.file,n=e.name,o=e.method,s=e.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(t).forEach((function(e){c.append(e,t[e])})),c.append("key",n),c.append("file",r),this.request(i(i({},e),{data:c,method:u}),this.restrictedMethods.includes("upload"))):this.request(i(i({},e),{method:"put",headers:a,body:r}),this.restrictedMethods.includes("upload"))},t.prototype.download=function(e){return s(this,void 0,void 0,(function(){var t,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({},e),{headers:{},responseType:"blob"}))];case 1:return t=s.sent().data,r=window.URL.createObjectURL(new Blob([t])),n=decodeURIComponent(new URL(e.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(t){t({statusCode:200,tempFilePath:e.url})}))]}}))}))},t.prototype.fetch=function(e){var t;return s(this,void 0,void 0,(function(){var r,n,o,u,c,l,f,d,h,p,v,y,m,g=this;return a(this,(function(b){switch(b.label){case 0:return r=new AbortController,n=e.url,o=e.enableAbort,u=void 0!==o&&o,c=e.stream,l=void 0!==c&&c,f=e.signal,d=e.timeout,h=e.shouldThrowOnError,p=void 0===h||h,v=null!=d?d:this.timeout,f&&(f.aborted&&r.abort(),f.addEventListener("abort",(function(){return r.abort()}))),y=null,u&&v&&(y=setTimeout((function(){console.warn(g.timeoutMsg),r.abort(new Error(g.timeoutMsg))}),v)),[4,fetch(n,i(i({},e),{signal:r.signal})).then((function(e){return s(g,void 0,void 0,(function(){var t,r,n;return a(this,(function(o){switch(o.label){case 0:return clearTimeout(y),p?e.ok?(t=e,[3,3]):[3,1]:[3,4];case 1:return n=(r=Promise).reject,[4,e.json()];case 2:t=n.apply(r,[o.sent()]),o.label=3;case 3:return[2,t];case 4:return[2,e]}}))}))})).catch((function(e){if(clearTimeout(y),p)return Promise.reject(e)}))];case 1:return m=b.sent(),[2,{data:l?m.body:(null===(t=m.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))?m.json():m.text(),statusCode:m.status,header:m.headers}]}}))}))},t.prototype.request=function(e,t){var r=this;void 0===t&&(t=!1);var n=String(e.method).toLowerCase()||"get";return new Promise((function(o){var i,s,a=e.url,u=e.headers,f=void 0===u?{}:u,d=e.data,h=e.responseType,p=e.withCredentials,v=e.body,y=e.onUploadProgress,m=(0,c.formatUrl)((0,l.getProtocol)(),a,"get"===n?d:{}),g=new XMLHttpRequest;g.open(n,m),h&&(g.responseType=h),Object.keys(f).forEach((function(e){g.setRequestHeader(e,f[e])})),y&&g.upload.addEventListener("progress",y),g.onreadystatechange=function(){var e={};if(4===g.readyState){var t=g.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};t.forEach((function(e){var t=e.split(": "),n=t.shift().toLowerCase(),o=t.join(": ");r[n]=o})),e.header=r,e.statusCode=g.status;try{e.data="blob"===h?g.response:JSON.parse(g.responseText)}catch(t){e.data="blob"===h?g.response:g.responseText}clearTimeout(i),o(e)}},t&&r.timeout&&(i=setTimeout((function(){console.warn(r.timeoutMsg),g.abort()}),r.timeout)),s=(0,c.isFormData)(d)?d:"application/x-www-form-urlencoded"===f["content-type"]?(0,c.toQueryString)(d):v||(d?JSON.stringify(d):void 0),p&&(g.withCredentials=!0),g.send(s)}))},t}(u.AbstractSDKRequest);t.WebRequest=f,t.genAdapter=function(){return{type:"default",root:window,reqClass:f,wsClass:WebSocket,localStorage:localStorage}}},2946:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.COMMUNITY_SITE_URL=t.IS_DEBUG_MODE=t.getProtocol=t.setProtocol=t.getSdkName=t.setSdkName=void 0;var r="@cloudbase/js-sdk";t.setSdkName=function(e){r=e},t.getSdkName=function(){return r};var n="https:";t.setProtocol=function(e){n=e},t.getProtocol=function(){return n},t.IS_DEBUG_MODE=!1,t.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},6205:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ERRORS=void 0,t.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(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.OATUH_LOGINTYPE=void 0,o(r(2946),t),o(r(6205),t),t.OATUH_LOGINTYPE="constants"},7718:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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(t,"__esModule",{value:!0}),t.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(e){var t=e.err,r=e.className,n=e.methodName,o=e.sourceLink;if(!o)return null;var i,s=t.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(e){return u.test(e)}));if(-1!==f){var d=s.filter((function(e,t){return t>f}));d.unshift(s[f].replace(l,"".concat(r,".").concat(n)).replace(c,o)),(i=new Error).stack="".concat(a?"@debugger":"Error","\n").concat(d.join("\n"))}return i}t.catchErrorsDecorator=function(e){var t=e.mode,r=void 0===t?"async":t,a=e.customInfo,f=void 0===a?{}:a,d=e.title,h=e.messages,p=void 0===h?[]:h;return function(e,t,a){if(s.IS_DEBUG_MODE){var h=f.className||e.constructor.name,v=f.methodName||t,y=a.value,m=function(){var e="",t=(new Error).stack.split("\n"),r=t.findIndex((function(e){return u.test(e)}));if(-1!==r){var n=c.exec(t[r+1]||"");e=n?n[0]:""}return e}();a.value="sync"===r?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=l({err:new Error,className:h,methodName:v,sourceLink:m});try{return y.apply(this,e)}catch(e){var n=e,o=e.message,s=e.error,a=e.error_description,u={title:d||"".concat(h,".").concat(v," failed"),content:[{type:"error",body:e}]};if(o&&/^\{.*\}$/.test(o)){var c=JSON.parse(o);u.subtitle=o,c.code&&(r?(r.code=c.code,r.msg=c.msg):(e.code=c.code,e.message=c.msg),n=r||e,u.content=p.map((function(e){return{type:"info",body:e}})))}throw s&&a&&(u.subtitle=a,r?(r.code=s,r.msg=a):(e.code=s,e.message=a),n=r||e,u.content=p.map((function(e){return{type:"info",body:e}}))),(0,i.printGroupLog)(u),n}}:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n(this,void 0,void 0,(function(){var t,r,n,s,a,u,c,f;return o(this,(function(o){switch(o.label){case 0:t=l({err:new Error,className:h,methodName:v,sourceLink:m}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,y.apply(this,e)];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:d||"".concat(h,".").concat(v," failed"),content:[{type:"error",body:r}]},s&&/^\{.*\}$/.test(s)&&(f=JSON.parse(s),c.subtitle=f,f.code&&(t?(t.code=f.code,t.message=f.msg):(r.code=f.code,r.message=f.msg),n=t||r,c.content=p.map((function(e){return{type:"info",body:e}})))),a&&u&&(c.subtitle=u,t?(t.code=a,t.msg=u):(r.code=a,r.message=u),n=t||r,c.content=p.map((function(e){return{type:"info",body:e}}))),(0,i.printGroupLog)(c),n;case 4:return[2]}}))}))}}}}},141:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(7718),t)},6197:function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},s=this&&this.__generator||function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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(t,"__esModule",{value:!0}),t.CloudbaseCache=void 0;var a=r(2829),u=r(5605),c=r(794),l=function(e){function t(t){var r=e.call(this)||this;return r.root=t,t.tcbCacheObject||(t.tcbCacheObject={}),r}return o(t,e),t.prototype.setItem=function(e,t){this.root.tcbCacheObject[e]=t},t.prototype.getItem=function(e){return this.root.tcbCacheObject[e]},t.prototype.removeItem=function(e){delete this.root.tcbCacheObject[e]},t.prototype.clear=function(){delete this.root.tcbCacheObject},t}(a.AbstractStorage),f=function(){function e(e){this.keys={};var t=e.persistence,r=e.platformInfo,n=void 0===r?{}:r,o=e.keys,i=void 0===o?{}:o;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||t,this.storage=function(e,t){switch(e){case"local":default:return t.localStorage?t.localStorage:((0,u.printWarn)(c.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new l(t.root));case"none":return new l(t.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(e.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),e.prototype.setStore=function(e,t,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:t};this.storage.setItem(e,JSON.stringify(n))}catch(e){throw new Error(JSON.stringify({code:c.ERRORS.OPERATION_FAIL,msg:"[".concat((0,c.getSdkName)(),"][").concat(c.ERRORS.OPERATION_FAIL,"]setStore failed"),info:e}))}}else(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(e,t,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:t},[4,this.storage.setItem(e,JSON.stringify(n))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},e.prototype.getStore=function(e,t){var r;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return{IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(e){return""}t=t||"localCachev1";var n=this.storage.getItem(e);return n&&n.indexOf(t)>=0?JSON.parse(n).content:""}(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,t){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,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return[2,{IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(e){return[2,""]}return t=t||"localCachev1",[4,this.storage.getItem(e)];case 1:return(n=o.sent())&&n.indexOf(t)>=0?[2,JSON.parse(n).content]:[2,""]}}))}))},e.prototype.removeStore=function(e){"async"!==this.mode?this.storage.removeItem(e):(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.storage.removeItem(e)];case 1:return t.sent(),[2]}}))}))},e}();t.CloudbaseCache=f},9689:function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.removeEventListener=t.activateEvent=t.addEventListener=t.CloudbaseEventEmitter=t.IErrorEvent=t.CloudbaseEvent=void 0;var s=r(5605),a=function(e,t){this.data=t||null,this.name=e};t.CloudbaseEvent=a;var u=function(e){function t(t,r){var n=e.call(this,"error",{error:t,data:r})||this;return n.error=t,n}return o(t,e),t}(a);t.IErrorEvent=u;var c=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){return function(e,t,r){r[e]=r[e]||[],r[e].push(t)}(e,t,this.listeners),this},e.prototype.off=function(e,t){return function(e,t,r){if(null==r?void 0:r[e]){var n=r[e].indexOf(t);-1!==n&&r[e].splice(n,1)}}(e,t,this.listeners),this},e.prototype.fire=function(e,t){if((0,s.isInstanceOf)(e,u))return console.error(e.error),this;var r=(0,s.isString)(e)?new a(e,t||{}):e,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},e.prototype.listens=function(e){return this.listeners[e]&&this.listeners[e].length>0},e}();t.CloudbaseEventEmitter=c;var l=new c;t.addEventListener=function(e,t){l.on(e,t)},t.activateEvent=function(e,t){void 0===t&&(t={}),l.fire(e,t)},t.removeEventListener=function(e,t){l.off(e,t)}},5605:function(e,t,r){"use strict";var n=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.parseCaptcha=t.parseQueryString=t.transformPhone=t.sleep=t.printGroupLog=t.throwError=t.printInfo=t.printError=t.printWarn=t.execCallback=t.createPromiseCallback=t.removeParam=t.getHash=t.getQuery=t.toQueryString=t.formatUrl=t.generateRequestId=t.genSeqId=t.isFormData=t.isInstanceOf=t.isNull=t.isPalinObject=t.isUndefined=t.isString=t.isArray=void 0;var o=r(794);t.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isString=function(e){return"string"==typeof e},t.isUndefined=function(e){return void 0===e},t.isPalinObject=function(e){return"[object Object]"===Object.prototype.toString.call(e)},t.isNull=function(e){return"[object Null]"===Object.prototype.toString.call(e)},t.isInstanceOf=function(e,t){return e instanceof t},t.isFormData=function(e){return"[object FormData]"===Object.prototype.toString.call(e)},t.genSeqId=function(){return Math.random().toString(16).slice(2)},t.generateRequestId=function(){var e=(new Date).getTime(),t=(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 e>0?(n=(e+n)%16|0,e=Math.floor(e/16)):(n=(t+n)%16|0,t=Math.floor(t/16)),("x"===r?n:7&n|8).toString(16)}))},t.formatUrl=function(e,t,r){void 0===r&&(r={});var n=/\?/.test(t),o="";return Object.keys(r).forEach((function(e){""===o?!n&&(t+="?"):o+="&",o+="".concat(e,"=").concat(encodeURIComponent(r[e]))})),/^http(s)?:\/\//.test(t+=o)?t:"".concat(e).concat(t)},t.toQueryString=function(e){void 0===e&&(e={});var t=[];return Object.keys(e).forEach((function(r){t.push("".concat(r,"=").concat(encodeURIComponent(e[r])))})),t.join("&")},t.getQuery=function(e,t){if("undefined"==typeof window)return!1;var r=t||decodeURIComponent(window.location.search),n=new RegExp("(^|&)".concat(e,"=([^&]*)(&|$)")),o=r.substr(r.indexOf("?")+1).match(n);return null!=o?o[2]:""},t.getHash=function(e){if("undefined"==typeof window)return"";var t=window.location.hash.match(new RegExp("[#?&/]".concat(e,"=([^&#]*)")));return t?t[1]:""},t.removeParam=function(e,t){var r=t.split("?")[0],n=[],o=-1!==t.indexOf("?")?t.split("?")[1]:"";if(""!==o){for(var i=(n=o.split("&")).length-1;i>=0;i-=1)n[i].split("=")[0]===e&&n.splice(i,1);r="".concat(r,"?").concat(n.join("&"))}return r},t.createPromiseCallback=function(){var e={};if(!Promise){(e=function(){}).promise={};var t=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}var r=new Promise((function(t,r){e=function(e,n){return e?r(e):t(n)}}));return e.promise=r,e},t.execCallback=function(e,t,r){if(void 0===r&&(r=null),e&&"function"==typeof e)return e(t,r);if(t)throw t;return r},t.printWarn=function(e,t){console.warn("[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t))},t.printError=function(e,t){console.error({code:e,msg:"[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t)})},t.printInfo=function(e,t){console.log("[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t))},t.throwError=function(e,t){throw new Error(JSON.stringify({code:e,msg:"[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t)}))},t.printGroupLog=function(e){var t,r=e.title,n=e.subtitle,o=void 0===n?"":n,i=e.content,s=void 0===i?[]:i,a=e.printTrace,u=void 0!==a&&a,c=e.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 d=f[l],h=d.type,p=d.body;switch(h){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===(t=console.groupEnd)||void 0===t||t.call(console)},t.sleep=function(e){return void 0===e&&(e=0),new Promise((function(t){return setTimeout(t,e)}))},t.transformPhone=function(e){return"+86".concat(e)},t.parseQueryString=function(e){e=e.replace(/^\?/,"");var t={};return e.split("&").forEach((function(e){var r=e.split("="),n=r[0],o=r[1];n=decodeURIComponent(n),o=decodeURIComponent(o),n&&(t[n]?Array.isArray(t[n])?t[n].push(o):t[n]=[t[n],o]:t[n]=o)})),t},t.parseCaptcha=function(e){var r={},o=e.match(/^(data:.*?)(\?[^#\s]*)?$/);if(o){e=o[1];var i=o[2];i&&(r=(0,t.parseQueryString)(i))}var s=r.token,a=n(r,["token"]);return/^data:/.test(e)&&!s?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(e)}:s?{state:a.state,token:s,captchaData:e}:{error:"unimplemented",error_description:"need to impl captcha data"}}},3616:function(e,t,r){"use strict";r.d(t,{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 y},Sg:function(){return m},Fk:function(){return v},eX:function(){return d},pM:function(){return p},tC:function(){return f}});var o={};r.r(o),r.d(o,{createPromiseCallback:function(){return U},execCallback:function(){return k},formatUrl:function(){return P},genSeqId:function(){return A},generateRequestId:function(){return R},getHash:function(){return x},getQuery:function(){return N},isArray:function(){return w},isFormData:function(){return T},isInstanceOf:function(){return O},isNull:function(){return I},isPalinObject:function(){return E},isString:function(){return _},isUndefined:function(){return S},parseCaptcha:function(){return H},parseQueryString:function(){return V},printError:function(){return j},printGroupLog:function(){return B},printInfo:function(){return q},printWarn:function(){return D},removeParam:function(){return L},sleep:function(){return W},throwError:function(){return M},toQueryString:function(){return C},transformPhone:function(){return F}});var i={};r.r(i),r.d(i,{Fk:function(){return X},xY:function(){return ee}});var s={};r.r(s),r.d(s,{q:function(){return ie}});var a={};r.r(a),r.d(a,{yE:function(){return ce}});var u={};r.r(u),r.d(u,{P:function(){return fe},$:function(){return le}});var c={};r.r(c),r.d(c,{D:function(){return me}});var l="@cloudbase/js-sdk";function f(e){l=e}function d(){return l}var h="https:";function p(e){h=e}var v=!1,y="https://support.qq.com/products/148793",m={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"},g=r(2829),b=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r};function w(e){return"[object Array]"===Object.prototype.toString.call(e)}function _(e){return"string"==typeof e}function S(e){return void 0===e}function E(e){return"[object Object]"===Object.prototype.toString.call(e)}function I(e){return"[object Null]"===Object.prototype.toString.call(e)}function O(e,t){return e instanceof t}function T(e){return"[object FormData]"===Object.prototype.toString.call(e)}function A(){return Math.random().toString(16).slice(2)}function R(){var e=(new Date).getTime(),t=(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 e>0?(n=(e+n)%16|0,e=Math.floor(e/16)):(n=(t+n)%16|0,t=Math.floor(t/16)),("x"===r?n:7&n|8).toString(16)}))}function P(e,t,r){void 0===r&&(r={});var n=/\?/.test(t),o="";return Object.keys(r).forEach((function(e){""===o?!n&&(t+="?"):o+="&",o+="".concat(e,"=").concat(encodeURIComponent(r[e]))})),/^http(s)?:\/\//.test(t+=o)?t:"".concat(e).concat(t)}function C(e){void 0===e&&(e={});var t=[];return Object.keys(e).forEach((function(r){t.push("".concat(r,"=").concat(encodeURIComponent(e[r])))})),t.join("&")}function N(e,t){if("undefined"==typeof window)return!1;var r=t||decodeURIComponent(window.location.search),n=new RegExp("(^|&)".concat(e,"=([^&]*)(&|$)")),o=r.substr(r.indexOf("?")+1).match(n);return null!=o?o[2]:""}var x=function(e){if("undefined"==typeof window)return"";var t=window.location.hash.match(new RegExp("[#?&/]".concat(e,"=([^&#]*)")));return t?t[1]:""};function L(e,t){var r=t.split("?")[0],n=[],o=-1!==t.indexOf("?")?t.split("?")[1]:"";if(""!==o){for(var i=(n=o.split("&")).length-1;i>=0;i-=1)n[i].split("=")[0]===e&&n.splice(i,1);r="".concat(r,"?").concat(n.join("&"))}return r}function U(){var e={};if(!Promise){(e=function(){}).promise={};var t=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}var r=new Promise((function(t,r){e=function(e,n){return e?r(e):t(n)}}));return e.promise=r,e}function k(e,t,r){if(void 0===r&&(r=null),e&&"function"==typeof e)return e(t,r);if(t)throw t;return r}function D(e,t){console.warn("[".concat(d(),"][").concat(e,"]:").concat(t))}function j(e,t){console.error({code:e,msg:"[".concat(d(),"][").concat(e,"]:").concat(t)})}function q(e,t){console.log("[".concat(d(),"][").concat(e,"]:").concat(t))}function M(e,t){throw new Error(JSON.stringify({code:e,msg:"[".concat(d(),"][").concat(e,"]:").concat(t)}))}function B(e){var t,r=e.title,n=e.subtitle,o=void 0===n?"":n,i=e.content,s=void 0===i?[]:i,a=e.printTrace,u=void 0!==a&&a,c=e.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 d=f[l],h=d.type,p=d.body;switch(h){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===(t=console.groupEnd)||void 0===t||t.call(console)}var W=function(e){return void 0===e&&(e=0),new Promise((function(t){return setTimeout(t,e)}))};function F(e){return"+86".concat(e)}var V=function(e){e=e.replace(/^\?/,"");var t={};return e.split("&").forEach((function(e){var r=e.split("="),n=r[0],o=r[1];n=decodeURIComponent(n),o=decodeURIComponent(o),n&&(t[n]?Array.isArray(t[n])?t[n].push(o):t[n]=[t[n],o]:t[n]=o)})),t};function H(e){var t={},r=e.match(/^(data:.*?)(\?[^#\s]*)?$/);if(r){e=r[1];var n=r[2];n&&(t=V(n))}var o=t.token,i=b(t,["token"]);return/^data:/.test(e)&&!o?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(e)}:o?{state:i.state,token:o,captchaData:e}:{error:"unimplemented",error_description:"need to impl captcha data"}}var $,G,z=($=function(e,t){return $=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},$(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}$(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),K=function(){return K=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},K.apply(this,arguments)},J=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},Y=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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(e){function t(t){var r=e.call(this)||this,n=t.timeout,o=t.timeoutMsg,i=t.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=o||"请求超时",r.restrictedMethods=i||["get","post","upload","download"],r}return z(t,e),t.prototype.get=function(e){return this.request(K(K({},e),{method:"get"}),this.restrictedMethods.includes("get"))},t.prototype.post=function(e){return this.request(K(K({},e),{method:"post"}),this.restrictedMethods.includes("post"))},t.prototype.put=function(e){return this.request(K(K({},e),{method:"put"}))},t.prototype.upload=function(e){var t=e.data,r=e.file,n=e.name,o=e.method,i=e.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(t).forEach((function(e){u.append(e,t[e])})),u.append("key",n),u.append("file",r),this.request(K(K({},e),{data:u,method:a}),this.restrictedMethods.includes("upload"))):this.request(K(K({},e),{method:"put",headers:s,body:r}),this.restrictedMethods.includes("upload"))},t.prototype.download=function(e){return J(this,void 0,void 0,(function(){var t,r,n,o;return Y(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.get(K(K({},e),{headers:{},responseType:"blob"}))];case 1:return t=i.sent().data,r=window.URL.createObjectURL(new Blob([t])),n=decodeURIComponent(new URL(e.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(t){t({statusCode:200,tempFilePath:e.url})}))]}}))}))},t.prototype.fetch=function(e){var t;return J(this,void 0,void 0,(function(){var r,n,o,i,s,a,u,c,l,f,d,h,p,v=this;return Y(this,(function(y){switch(y.label){case 0:return r=new AbortController,n=e.url,o=e.enableAbort,i=void 0!==o&&o,s=e.stream,a=void 0!==s&&s,u=e.signal,c=e.timeout,l=e.shouldThrowOnError,f=void 0===l||l,d=null!=c?c:this.timeout,u&&(u.aborted&&r.abort(),u.addEventListener("abort",(function(){return r.abort()}))),h=null,i&&d&&(h=setTimeout((function(){console.warn(v.timeoutMsg),r.abort(new Error(v.timeoutMsg))}),d)),[4,fetch(n,K(K({},e),{signal:r.signal})).then((function(e){return J(v,void 0,void 0,(function(){var t,r,n;return Y(this,(function(o){switch(o.label){case 0:return clearTimeout(h),f?e.ok?(t=e,[3,3]):[3,1]:[3,4];case 1:return n=(r=Promise).reject,[4,e.json()];case 2:t=n.apply(r,[o.sent()]),o.label=3;case 3:return[2,t];case 4:return[2,e]}}))}))})).catch((function(e){if(clearTimeout(h),f)return Promise.reject(e)}))];case 1:return p=y.sent(),[2,{data:a?p.body:(null===(t=p.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))?p.json():p.text(),statusCode:p.status,header:p.headers}]}}))}))},t.prototype.request=function(e,t){var r=this;void 0===t&&(t=!1);var n=String(e.method).toLowerCase()||"get";return new Promise((function(o){var i,s,a=e.url,u=e.headers,c=void 0===u?{}:u,l=e.data,f=e.responseType,d=e.withCredentials,p=e.body,v=e.onUploadProgress,y=P(h,a,"get"===n?l:{}),m=new XMLHttpRequest;m.open(n,y),f&&(m.responseType=f),Object.keys(c).forEach((function(e){m.setRequestHeader(e,c[e])})),v&&m.upload.addEventListener("progress",v),m.onreadystatechange=function(){var e={};if(4===m.readyState){var t=m.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};t.forEach((function(e){var t=e.split(": "),n=t.shift().toLowerCase(),o=t.join(": ");r[n]=o})),e.header=r,e.statusCode=m.status;try{e.data="blob"===f?m.response:JSON.parse(m.responseText)}catch(t){e.data="blob"===f?m.response:m.responseText}clearTimeout(i),o(e)}},t&&r.timeout&&(i=setTimeout((function(){console.warn(r.timeoutMsg),m.abort()}),r.timeout)),s=T(l)?l:"application/x-www-form-urlencoded"===c["content-type"]?C(l):p||(l?JSON.stringify(l):void 0),d&&(m.withCredentials=!0),m.send(s)}))},t}(g.AbstractSDKRequest),Z=function(){return Z=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Z.apply(this,arguments)};function X(e,t){for(var r=0,n=w(e)?e:[e];r<n.length;r++){var o=n[r],i=o.isMatch,s=o.genAdapter,a=o.runtime;if(i())return{adapter:Z({isMatch:i},s(t)),runtime:a}}}function ee(){return{adapter:Z({},{type:"default",root:window,reqClass:Q,wsClass:WebSocket,localStorage:localStorage}),runtime:G.WEB}}!function(e){e.WEB="web",e.WX_MP="wx_mp"}(G||(G={}));var te=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};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)}}(),re=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},ne=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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])}}},oe=function(e){function t(t){var r=e.call(this)||this;return r.root=t,t.tcbCacheObject||(t.tcbCacheObject={}),r}return te(t,e),t.prototype.setItem=function(e,t){this.root.tcbCacheObject[e]=t},t.prototype.getItem=function(e){return this.root.tcbCacheObject[e]},t.prototype.removeItem=function(e){delete this.root.tcbCacheObject[e]},t.prototype.clear=function(){delete this.root.tcbCacheObject},t}(g.AbstractStorage),ie=function(){function e(e){this.keys={};var t=e.persistence,r=e.platformInfo,n=void 0===r?{}:r,o=e.keys,i=void 0===o?{}:o;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||t,this.storage=function(e,t){switch(e){case"local":default:return t.localStorage?t.localStorage:(D(m.INVALID_PARAMS,"localStorage is not supported on current platform"),new oe(t.root));case"none":return new oe(t.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(e.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),e.prototype.setStore=function(e,t,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:t};this.storage.setItem(e,JSON.stringify(n))}catch(e){throw new Error(JSON.stringify({code:m.OPERATION_FAIL,msg:"[".concat(d(),"][").concat(m.OPERATION_FAIL,"]setStore failed"),info:e}))}}else D(m.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(e,t,r){return re(this,void 0,void 0,(function(){var n;return ne(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:t},[4,this.storage.setItem(e,JSON.stringify(n))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},e.prototype.getStore=function(e,t){var r;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return{IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(e){return""}t=t||"localCachev1";var n=this.storage.getItem(e);return n&&n.indexOf(t)>=0?JSON.parse(n).content:""}D(m.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,t){var r;return re(this,void 0,void 0,(function(){var n;return ne(this,(function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return[2,{IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(e){return[2,""]}return t=t||"localCachev1",[4,this.storage.getItem(e)];case 1:return(n=o.sent())&&n.indexOf(t)>=0?[2,JSON.parse(n).content]:[2,""]}}))}))},e.prototype.removeStore=function(e){"async"!==this.mode?this.storage.removeItem(e):D(m.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(e){return re(this,void 0,void 0,(function(){return ne(this,(function(t){switch(t.label){case 0:return[4,this.storage.removeItem(e)];case 1:return t.sent(),[2]}}))}))},e}(),se=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};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)}}(),ae=function(e,t){this.data=t||null,this.name=e},ue=function(e){function t(t,r){var n=e.call(this,"error",{error:t,data:r})||this;return n.error=t,n}return se(t,e),t}(ae),ce=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){return function(e,t,r){r[e]=r[e]||[],r[e].push(t)}(e,t,this.listeners),this},e.prototype.off=function(e,t){return function(e,t,r){if(null==r?void 0:r[e]){var n=r[e].indexOf(t);-1!==n&&r[e].splice(n,1)}}(e,t,this.listeners),this},e.prototype.fire=function(e,t){if(O(e,ue))return console.error(e.error),this;var r=_(e)?new ae(e,t||{}):e,n=r.name;if(this.listens(n)){r.target=this;for(var o=0,i=this.listeners[n]?function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}([],this.listeners[n],!0):[];o<i.length;o++)i[o].call(this,r)}return this},e.prototype.listens=function(e){return this.listeners[e]&&this.listeners[e].length>0},e}();new ce;var le=new ce,fe="lang_change",de=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},he=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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])}}},pe=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(pe=-1!==navigator.userAgent.indexOf("Firefox"));var ve=pe?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,ye=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function me(e){var t=e.mode,r=void 0===t?"async":t,n=e.customInfo,o=void 0===n?{}:n,i=e.title,s=e.messages,a=void 0===s?[]:s;return function(e,t,n){if(v){var s=o.className||e.constructor.name,u=o.methodName||t,c=n.value,l=function(){var e="",t=(new Error).stack.split("\n"),r=t.findIndex((function(e){return ve.test(e)}));if(-1!==r){var n=ye.exec(t[r+1]||"");e=n?n[0]:""}return e}();n.value="sync"===r?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=ge({err:new Error,className:s,methodName:u,sourceLink:l});try{return c.apply(this,e)}catch(e){var n=e,o=e.message,f=e.error,d=e.error_description,h={title:i||"".concat(s,".").concat(u," failed"),content:[{type:"error",body:e}]};if(o&&/^\{.*\}$/.test(o)){var p=JSON.parse(o);h.subtitle=o,p.code&&(r?(r.code=p.code,r.msg=p.msg):(e.code=p.code,e.message=p.msg),n=r||e,h.content=a.map((function(e){return{type:"info",body:e}})))}throw f&&d&&(h.subtitle=d,r?(r.code=f,r.msg=d):(e.code=f,e.message=d),n=r||e,h.content=a.map((function(e){return{type:"info",body:e}}))),B(h),n}}:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return de(this,void 0,void 0,(function(){var t,r,n,o,f,d,h,p;return he(this,(function(v){switch(v.label){case 0:t=ge({err:new Error,className:s,methodName:u,sourceLink:l}),v.label=1;case 1:return v.trys.push([1,3,,4]),[4,c.apply(this,e)];case 2:return[2,v.sent()];case 3:throw r=v.sent(),n=r,o=r.message,f=r.error,d=r.error_description,h={title:i||"".concat(s,".").concat(u," failed"),content:[{type:"error",body:r}]},o&&/^\{.*\}$/.test(o)&&(p=JSON.parse(o),h.subtitle=p,p.code&&(t?(t.code=p.code,t.message=p.msg):(r.code=p.code,r.message=p.msg),n=t||r,h.content=a.map((function(e){return{type:"info",body:e}})))),f&&d&&(h.subtitle=d,t?(t.code=f,t.msg=d):(r.code=f,r.message=d),n=t||r,h.content=a.map((function(e){return{type:"info",body:e}}))),B(h),n;case 4:return[2]}}))}))}}}}function ge(e){var t=e.err,r=e.className,n=e.methodName,o=e.sourceLink;if(!o)return null;var i,s=t.stack.split("\n"),a=pe?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]\\s*\\(.*\\)$")),u=pe?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]")),c=s.findIndex((function(e){return a.test(e)}));if(-1!==c){var l=s.filter((function(e,t){return t>c}));l.unshift(s[c].replace(u,"".concat(r,".").concat(n)).replace(ye,o)),(i=new Error).stack="".concat(pe?"@debugger":"Error","\n").concat(l.join("\n"))}return i}function be(e){this.message=e}function we(e){this.message=e}be.prototype=new Error,be.prototype.name="InvalidCharacterError","undefined"!=typeof window&&window.atob&&window.atob.bind(window),we.prototype=new Error,we.prototype.name="InvalidTokenError"},9515:function(e,t,r){var n=r(8761)(r(7772),"DataView");e.exports=n},9612:function(e,t,r){var n=r(2118),o=r(6909),i=r(8138),s=r(4174),a=r(7942);function u(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];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,e.exports=u},235:function(e,t,r){var n=r(3945),o=r(1846),i=r(8028),s=r(2344),a=r(4769);function u(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];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,e.exports=u},326:function(e,t,r){var n=r(8761)(r(7772),"Map");e.exports=n},6738:function(e,t,r){var n=r(2411),o=r(6417),i=r(6928),s=r(9493),a=r(4150);function u(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];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,e.exports=u},2760:function(e,t,r){var n=r(8761)(r(7772),"Promise");e.exports=n},2143:function(e,t,r){var n=r(8761)(r(7772),"Set");e.exports=n},6571:function(e,t,r){var n=r(235),o=r(5243),i=r(2858),s=r(4417),a=r(8605),u=r(1418);function c(e){var t=this.__data__=new n(e);this.size=t.size}c.prototype.clear=o,c.prototype.delete=i,c.prototype.get=s,c.prototype.has=a,c.prototype.set=u,e.exports=c},857:function(e,t,r){var n=r(7772).Symbol;e.exports=n},9162:function(e,t,r){var n=r(7772).Uint8Array;e.exports=n},3215:function(e,t,r){var n=r(8761)(r(7772),"WeakMap");e.exports=n},2517:function(e){e.exports=function(e,t){for(var r=-1,n=null==e?0:e.length;++r<n&&!1!==t(e[r],r,e););return e}},7552:function(e){e.exports=function(e,t){for(var r=-1,n=null==e?0:e.length,o=0,i=[];++r<n;){var s=e[r];t(s,r,e)&&(i[o++]=s)}return i}},1634:function(e,t,r){var n=r(6473),o=r(9631),i=r(6152),s=r(3226),a=r(9045),u=r(7598),c=Object.prototype.hasOwnProperty;e.exports=function(e,t){var r=i(e),l=!r&&o(e),f=!r&&!l&&s(e),d=!r&&!l&&!f&&u(e),h=r||l||f||d,p=h?n(e.length,String):[],v=p.length;for(var y in e)!t&&!c.call(e,y)||h&&("length"==y||f&&("offset"==y||"parent"==y)||d&&("buffer"==y||"byteLength"==y||"byteOffset"==y)||a(y,v))||p.push(y);return p}},343:function(e){e.exports=function(e,t){for(var r=-1,n=null==e?0:e.length,o=Array(n);++r<n;)o[r]=t(e[r],r,e);return o}},5067:function(e){e.exports=function(e,t){for(var r=-1,n=t.length,o=e.length;++r<n;)e[o+r]=t[r];return e}},91:function(e,t,r){var n=r(3940),o=r(1225),i=Object.prototype.hasOwnProperty;e.exports=function(e,t,r){var s=e[t];i.call(e,t)&&o(s,r)&&(void 0!==r||t in e)||n(e,t,r)}},2218:function(e,t,r){var n=r(1225);e.exports=function(e,t){for(var r=e.length;r--;)if(n(e[r][0],t))return r;return-1}},7993:function(e,t,r){var n=r(752),o=r(249);e.exports=function(e,t){return e&&n(t,o(t),e)}},5906:function(e,t,r){var n=r(752),o=r(8582);e.exports=function(e,t){return e&&n(t,o(t),e)}},3940:function(e,t,r){var n=r(3043);e.exports=function(e,t,r){"__proto__"==t&&n?n(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}},8874:function(e,t,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),d=r(3483),h=r(6939),p=r(940),v=r(9854),y=r(8222),m=r(8725),g=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]",A="[object Object]",R={};R[O]=R["[object Array]"]=R["[object ArrayBuffer]"]=R["[object DataView]"]=R["[object Boolean]"]=R["[object Date]"]=R["[object Float32Array]"]=R["[object Float64Array]"]=R["[object Int8Array]"]=R["[object Int16Array]"]=R["[object Int32Array]"]=R["[object Map]"]=R["[object Number]"]=R[A]=R["[object RegExp]"]=R["[object Set]"]=R["[object String]"]=R["[object Symbol]"]=R["[object Uint8Array]"]=R["[object Uint8ClampedArray]"]=R["[object Uint16Array]"]=R["[object Uint32Array]"]=!0,R["[object Error]"]=R[T]=R["[object WeakMap]"]=!1,e.exports=function e(t,r,P,C,N,x){var L,U=1&r,k=2&r,D=4&r;if(P&&(L=N?P(t,C,N,x):P(t)),void 0!==L)return L;if(!_(t))return t;var j=g(t);if(j){if(L=v(t),!U)return c(t,L)}else{var q=p(t),M=q==T||"[object GeneratorFunction]"==q;if(b(t))return u(t,U);if(q==A||q==O||M&&!N){if(L=k||M?{}:m(t),!U)return k?f(t,a(L,t)):l(t,s(L,t))}else{if(!R[q])return N?t:{};L=y(t,q,U)}}x||(x=new n);var B=x.get(t);if(B)return B;x.set(t,L),S(t)?t.forEach((function(n){L.add(e(n,r,P,n,t,x))})):w(t)&&t.forEach((function(n,o){L.set(o,e(n,r,P,o,t,x))}));var W=j?void 0:(D?k?h:d:k?I:E)(t);return o(W||t,(function(n,o){W&&(n=t[o=n]),i(L,o,e(n,r,P,o,t,x))})),L}},9413:function(e,t,r){var n=r(9259),o=Object.create,i=function(){function e(){}return function(t){if(!n(t))return{};if(o)return o(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}}();e.exports=i},3324:function(e,t,r){var n=r(7297),o=r(3812);e.exports=function(e,t){for(var r=0,i=(t=n(t,e)).length;null!=e&&r<i;)e=e[o(t[r++])];return r&&r==i?e:void 0}},1897:function(e,t,r){var n=r(5067),o=r(6152);e.exports=function(e,t,r){var i=t(e);return o(e)?i:n(i,r(e))}},3366:function(e,t,r){var n=r(857),o=r(2107),i=r(7157),s=n?n.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":s&&s in Object(e)?o(e):i(e)}},5183:function(e,t,r){var n=r(3366),o=r(5125);e.exports=function(e){return o(e)&&"[object Arguments]"==n(e)}},4511:function(e,t,r){var n=r(940),o=r(5125);e.exports=function(e){return o(e)&&"[object Map]"==n(e)}},6840:function(e,t,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,d=RegExp("^"+l.call(f).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");e.exports=function(e){return!(!i(e)||o(e))&&(n(e)?d:a).test(s(e))}},8436:function(e,t,r){var n=r(940),o=r(5125);e.exports=function(e){return o(e)&&"[object Set]"==n(e)}},5522:function(e,t,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,e.exports=function(e){return i(e)&&o(e.length)&&!!s[n(e)]}},6411:function(e,t,r){var n=r(6001),o=r(4248),i=Object.prototype.hasOwnProperty;e.exports=function(e){if(!n(e))return o(e);var t=[];for(var r in Object(e))i.call(e,r)&&"constructor"!=r&&t.push(r);return t}},8390:function(e,t,r){var n=r(9259),o=r(6001),i=r(2966),s=Object.prototype.hasOwnProperty;e.exports=function(e){if(!n(e))return i(e);var t=o(e),r=[];for(var a in e)("constructor"!=a||!t&&s.call(e,a))&&r.push(a);return r}},2857:function(e,t,r){var n=r(91),o=r(7297),i=r(9045),s=r(9259),a=r(3812);e.exports=function(e,t,r,u){if(!s(e))return e;for(var c=-1,l=(t=o(t,e)).length,f=l-1,d=e;null!=d&&++c<l;){var h=a(t[c]),p=r;if("__proto__"===h||"constructor"===h||"prototype"===h)return e;if(c!=f){var v=d[h];void 0===(p=u?u(v,h,d):void 0)&&(p=s(v)?v:i(t[c+1])?[]:{})}n(d,h,p),d=d[h]}return e}},9872:function(e){e.exports=function(e,t,r){var n=-1,o=e.length;t<0&&(t=-t>o?0:o+t),(r=r>o?o:r)<0&&(r+=o),o=t>r?0:r-t>>>0,t>>>=0;for(var i=Array(o);++n<o;)i[n]=e[n+t];return i}},6473:function(e){e.exports=function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}},1054:function(e,t,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;e.exports=function e(t){if("string"==typeof t)return t;if(i(t))return o(t,e)+"";if(s(t))return u?u.call(t):"";var r=t+"";return"0"==r&&1/t==-1/0?"-0":r}},7826:function(e){e.exports=function(e){return function(t){return e(t)}}},9078:function(e,t,r){var n=r(7297),o=r(6974),i=r(2721),s=r(3812);e.exports=function(e,t){return t=n(t,e),null==(e=i(e,t))||delete e[s(o(t))]}},7297:function(e,t,r){var n=r(6152),o=r(1401),i=r(4452),s=r(6188);e.exports=function(e,t){return n(e)?e:o(e,t)?[e]:i(s(e))}},9882:function(e,t,r){var n=r(9162);e.exports=function(e){var t=new e.constructor(e.byteLength);return new n(t).set(new n(e)),t}},2175:function(e,t,r){e=r.nmd(e);var n=r(7772),o=t&&!t.nodeType&&t,i=o&&e&&!e.nodeType&&e,s=i&&i.exports===o?n.Buffer:void 0,a=s?s.allocUnsafe:void 0;e.exports=function(e,t){if(t)return e.slice();var r=e.length,n=a?a(r):new e.constructor(r);return e.copy(n),n}},4727:function(e,t,r){var n=r(9882);e.exports=function(e,t){var r=t?n(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}},6058:function(e){var t=/\w*$/;e.exports=function(e){var r=new e.constructor(e.source,t.exec(e));return r.lastIndex=e.lastIndex,r}},169:function(e,t,r){var n=r(857),o=n?n.prototype:void 0,i=o?o.valueOf:void 0;e.exports=function(e){return i?Object(i.call(e)):{}}},6190:function(e,t,r){var n=r(9882);e.exports=function(e,t){var r=t?n(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}},1522:function(e){e.exports=function(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}},752:function(e,t,r){var n=r(91),o=r(3940);e.exports=function(e,t,r,i){var s=!r;r||(r={});for(var a=-1,u=t.length;++a<u;){var c=t[a],l=i?i(r[c],e[c],c,r,e):void 0;void 0===l&&(l=e[c]),s?o(r,c,l):n(r,c,l)}return r}},7680:function(e,t,r){var n=r(752),o=r(633);e.exports=function(e,t){return n(e,o(e),t)}},9987:function(e,t,r){var n=r(752),o=r(2680);e.exports=function(e,t){return n(e,o(e),t)}},4019:function(e,t,r){var n=r(7772)["__core-js_shared__"];e.exports=n},3043:function(e,t,r){var n=r(8761),o=function(){try{var e=n(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();e.exports=o},1242:function(e,t,r){var n="object"==typeof r.g&&r.g&&r.g.Object===Object&&r.g;e.exports=n},3483:function(e,t,r){var n=r(1897),o=r(633),i=r(249);e.exports=function(e){return n(e,i,o)}},6939:function(e,t,r){var n=r(1897),o=r(2680),i=r(8582);e.exports=function(e){return n(e,i,o)}},7937:function(e,t,r){var n=r(8304);e.exports=function(e,t){var r=e.__data__;return n(t)?r["string"==typeof t?"string":"hash"]:r.map}},8761:function(e,t,r){var n=r(6840),o=r(8109);e.exports=function(e,t){var r=o(e,t);return n(r)?r:void 0}},7353:function(e,t,r){var n=r(241)(Object.getPrototypeOf,Object);e.exports=n},2107:function(e,t,r){var n=r(857),o=Object.prototype,i=o.hasOwnProperty,s=o.toString,a=n?n.toStringTag:void 0;e.exports=function(e){var t=i.call(e,a),r=e[a];try{e[a]=void 0;var n=!0}catch(e){}var o=s.call(e);return n&&(t?e[a]=r:delete e[a]),o}},633:function(e,t,r){var n=r(7552),o=r(981),i=Object.prototype.propertyIsEnumerable,s=Object.getOwnPropertySymbols,a=s?function(e){return null==e?[]:(e=Object(e),n(s(e),(function(t){return i.call(e,t)})))}:o;e.exports=a},2680:function(e,t,r){var n=r(5067),o=r(7353),i=r(633),s=r(981),a=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)n(t,i(e)),e=o(e);return t}:s;e.exports=a},940:function(e,t,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]",d="[object Set]",h="[object WeakMap]",p="[object DataView]",v=c(n),y=c(o),m=c(i),g=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)!=d||a&&w(new a)!=h)&&(w=function(e){var t=u(e),r="[object Object]"==t?e.constructor:void 0,n=r?c(r):"";if(n)switch(n){case v:return p;case y:return l;case m:return f;case g:return d;case b:return h}return t}),e.exports=w},8109:function(e){e.exports=function(e,t){return null==e?void 0:e[t]}},2118:function(e,t,r){var n=r(9191);e.exports=function(){this.__data__=n?n(null):{},this.size=0}},6909:function(e){e.exports=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}},8138:function(e,t,r){var n=r(9191),o=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;if(n){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return o.call(t,e)?t[e]:void 0}},4174:function(e,t,r){var n=r(9191),o=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;return n?void 0!==t[e]:o.call(t,e)}},7942:function(e,t,r){var n=r(9191);e.exports=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=n&&void 0===t?"__lodash_hash_undefined__":t,this}},9854:function(e){var t=Object.prototype.hasOwnProperty;e.exports=function(e){var r=e.length,n=new e.constructor(r);return r&&"string"==typeof e[0]&&t.call(e,"index")&&(n.index=e.index,n.input=e.input),n}},8222:function(e,t,r){var n=r(9882),o=r(4727),i=r(6058),s=r(169),a=r(6190);e.exports=function(e,t,r){var u=e.constructor;switch(t){case"[object ArrayBuffer]":return n(e);case"[object Boolean]":case"[object Date]":return new u(+e);case"[object DataView]":return o(e,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(e,r);case"[object Map]":case"[object Set]":return new u;case"[object Number]":case"[object String]":return new u(e);case"[object RegExp]":return i(e);case"[object Symbol]":return s(e)}}},8725:function(e,t,r){var n=r(9413),o=r(7353),i=r(6001);e.exports=function(e){return"function"!=typeof e.constructor||i(e)?{}:n(o(e))}},9045:function(e){var t=/^(?:0|[1-9]\d*)$/;e.exports=function(e,r){var n=typeof e;return!!(r=null==r?9007199254740991:r)&&("number"==n||"symbol"!=n&&t.test(e))&&e>-1&&e%1==0&&e<r}},1401:function(e,t,r){var n=r(6152),o=r(4795),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;e.exports=function(e,t){if(n(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!o(e))||s.test(e)||!i.test(e)||null!=t&&e in Object(t)}},8304:function(e){e.exports=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}},7394:function(e,t,r){var n,o=r(4019),i=(n=/[^.]+$/.exec(o&&o.keys&&o.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"";e.exports=function(e){return!!i&&i in e}},6001:function(e){var t=Object.prototype;e.exports=function(e){var r=e&&e.constructor;return e===("function"==typeof r&&r.prototype||t)}},3945:function(e){e.exports=function(){this.__data__=[],this.size=0}},1846:function(e,t,r){var n=r(2218),o=Array.prototype.splice;e.exports=function(e){var t=this.__data__,r=n(t,e);return!(r<0||(r==t.length-1?t.pop():o.call(t,r,1),--this.size,0))}},8028:function(e,t,r){var n=r(2218);e.exports=function(e){var t=this.__data__,r=n(t,e);return r<0?void 0:t[r][1]}},2344:function(e,t,r){var n=r(2218);e.exports=function(e){return n(this.__data__,e)>-1}},4769:function(e,t,r){var n=r(2218);e.exports=function(e,t){var r=this.__data__,o=n(r,e);return o<0?(++this.size,r.push([e,t])):r[o][1]=t,this}},2411:function(e,t,r){var n=r(9612),o=r(235),i=r(326);e.exports=function(){this.size=0,this.__data__={hash:new n,map:new(i||o),string:new n}}},6417:function(e,t,r){var n=r(7937);e.exports=function(e){var t=n(this,e).delete(e);return this.size-=t?1:0,t}},6928:function(e,t,r){var n=r(7937);e.exports=function(e){return n(this,e).get(e)}},9493:function(e,t,r){var n=r(7937);e.exports=function(e){return n(this,e).has(e)}},4150:function(e,t,r){var n=r(7937);e.exports=function(e,t){var r=n(this,e),o=r.size;return r.set(e,t),this.size+=r.size==o?0:1,this}},7777:function(e,t,r){var n=r(733);e.exports=function(e){var t=n(e,(function(e){return 500===r.size&&r.clear(),e})),r=t.cache;return t}},9191:function(e,t,r){var n=r(8761)(Object,"create");e.exports=n},4248:function(e,t,r){var n=r(241)(Object.keys,Object);e.exports=n},2966:function(e){e.exports=function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}},4146:function(e,t,r){e=r.nmd(e);var n=r(1242),o=t&&!t.nodeType&&t,i=o&&e&&!e.nodeType&&e,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(e){}}();e.exports=a},7157:function(e){var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},241:function(e){e.exports=function(e,t){return function(r){return e(t(r))}}},2721:function(e,t,r){var n=r(3324),o=r(9872);e.exports=function(e,t){return t.length<2?e:n(e,o(t,0,-1))}},7772:function(e,t,r){var n=r(1242),o="object"==typeof self&&self&&self.Object===Object&&self,i=n||o||Function("return this")();e.exports=i},5243:function(e,t,r){var n=r(235);e.exports=function(){this.__data__=new n,this.size=0}},2858:function(e){e.exports=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}},4417:function(e){e.exports=function(e){return this.__data__.get(e)}},8605:function(e){e.exports=function(e){return this.__data__.has(e)}},1418:function(e,t,r){var n=r(235),o=r(326),i=r(6738);e.exports=function(e,t){var r=this.__data__;if(r instanceof n){var s=r.__data__;if(!o||s.length<199)return s.push([e,t]),this.size=++r.size,this;r=this.__data__=new i(s)}return r.set(e,t),this.size=r.size,this}},4452:function(e,t,r){var n=r(7777),o=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,i=/\\(\\)?/g,s=n((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(o,(function(e,r,n,o){t.push(n?o.replace(i,"$1"):r||e)})),t}));e.exports=s},3812:function(e,t,r){var n=r(4795);e.exports=function(e){if("string"==typeof e||n(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}},7035:function(e){var t=Function.prototype.toString;e.exports=function(e){if(null!=e){try{return t.call(e)}catch(e){}try{return e+""}catch(e){}}return""}},9850:function(e,t,r){var n=r(8874);e.exports=function(e){return n(e,5)}},1225:function(e){e.exports=function(e,t){return e===t||e!=e&&t!=t}},9631:function(e,t,r){var n=r(5183),o=r(5125),i=Object.prototype,s=i.hasOwnProperty,a=i.propertyIsEnumerable,u=n(function(){return arguments}())?n:function(e){return o(e)&&s.call(e,"callee")&&!a.call(e,"callee")};e.exports=u},6152:function(e){var t=Array.isArray;e.exports=t},7878:function(e,t,r){var n=r(1049),o=r(1158);e.exports=function(e){return null!=e&&o(e.length)&&!n(e)}},3226:function(e,t,r){e=r.nmd(e);var n=r(7772),o=r(6330),i=t&&!t.nodeType&&t,s=i&&e&&!e.nodeType&&e,a=s&&s.exports===i?n.Buffer:void 0,u=(a?a.isBuffer:void 0)||o;e.exports=u},1049:function(e,t,r){var n=r(3366),o=r(9259);e.exports=function(e){if(!o(e))return!1;var t=n(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}},1158:function(e){e.exports=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}},4714:function(e,t,r){var n=r(4511),o=r(7826),i=r(4146),s=i&&i.isMap,a=s?o(s):n;e.exports=a},9259:function(e){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},5125:function(e){e.exports=function(e){return null!=e&&"object"==typeof e}},3679:function(e,t,r){var n=r(8436),o=r(7826),i=r(4146),s=i&&i.isSet,a=s?o(s):n;e.exports=a},4795:function(e,t,r){var n=r(3366),o=r(5125);e.exports=function(e){return"symbol"==typeof e||o(e)&&"[object Symbol]"==n(e)}},7598:function(e,t,r){var n=r(5522),o=r(7826),i=r(4146),s=i&&i.isTypedArray,a=s?o(s):n;e.exports=a},249:function(e,t,r){var n=r(1634),o=r(6411),i=r(7878);e.exports=function(e){return i(e)?n(e):o(e)}},8582:function(e,t,r){var n=r(1634),o=r(8390),i=r(7878);e.exports=function(e){return i(e)?n(e,!0):o(e)}},6974:function(e){e.exports=function(e){var t=null==e?0:e.length;return t?e[t-1]:void 0}},733:function(e,t,r){var n=r(6738);function o(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var r=function(){var n=arguments,o=t?t.apply(this,n):n[0],i=r.cache;if(i.has(o))return i.get(o);var s=e.apply(this,n);return r.cache=i.set(o,s)||i,s};return r.cache=new(o.Cache||n),r}o.Cache=n,e.exports=o},6765:function(e,t,r){var n=r(2857);e.exports=function(e,t,r){return null==e?e:n(e,t,r)}},981:function(e){e.exports=function(){return[]}},6330:function(e){e.exports=function(){return!1}},6188:function(e,t,r){var n=r(1054);e.exports=function(e){return null==e?"":n(e)}},7195:function(e,t,r){var n=r(9078);e.exports=function(e,t){return null==e||n(e,t)}},5047:function(e){var t=function(e){"use strict";var t,r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var i=t&&t.prototype instanceof m?t:m,s=Object.create(i.prototype),a=new C(n||[]);return o(s,"_invoke",{value:T(e,r,a)}),s}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var d="suspendedStart",h="suspendedYield",p="executing",v="completed",y={};function m(){}function g(){}function b(){}var w={};c(w,s,(function(){return this}));var _=Object.getPrototypeOf,S=_&&_(_(N([])));S&&S!==r&&n.call(S,s)&&(w=S);var E=b.prototype=m.prototype=Object.create(w);function I(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function O(e,t){function r(o,i,s,a){var u=f(e[o],e,i);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,s,a)}),(function(e){r("throw",e,s,a)})):t.resolve(l).then((function(e){c.value=e,s(c)}),(function(e){return r("throw",e,s,a)}))}a(u.arg)}var i;o(this,"_invoke",{value:function(e,n){function o(){return new t((function(t,o){r(e,n,t,o)}))}return i=i?i.then(o,o):o()}})}function T(e,r,n){var o=d;return function(i,s){if(o===p)throw new Error("Generator is already running");if(o===v){if("throw"===i)throw s;return{value:t,done:!0}}for(n.method=i,n.arg=s;;){var a=n.delegate;if(a){var u=A(a,n);if(u){if(u===y)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===d)throw o=v,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=p;var c=f(e,r,n);if("normal"===c.type){if(o=n.done?v:h,c.arg===y)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(o=v,n.method="throw",n.arg=c.arg)}}}function A(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,A(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var i=f(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,y;var s=i.arg;return s?s.done?(r[e.resultName]=s.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,y):s:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function R(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function P(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function C(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(R,this),this.reset(!0)}function N(e){if(null!=e){var r=e[s];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}throw new TypeError(typeof e+" is not iterable")}return g.prototype=b,o(E,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:g,configurable:!0}),g.displayName=c(b,u,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,c(e,u,"GeneratorFunction")),e.prototype=Object.create(E),e},e.awrap=function(e){return{__await:e}},I(O.prototype),c(O.prototype,a,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var s=new O(l(t,r,n,o),i);return e.isGeneratorFunction(r)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},I(E),c(E,u,"Generator"),c(E,s,(function(){return this})),c(E,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=N,C.prototype={constructor:C,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(P),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return a.type="throw",a.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!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(e,t){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"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=e,s.arg=t,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),P(r),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;P(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:N(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),y}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}},4410:function(e,t,r){var n,o;void 0===(o="function"==typeof(n=function(){"use strict";var e=void 0!==r.g?r.g:self;if(void 0!==e.TextEncoder&&void 0!==e.TextDecoder)return{TextEncoder:e.TextEncoder,TextDecoder:e.TextDecoder};var t=["utf8","utf-8","unicode-1-1-utf-8"];return{TextEncoder:function(e){if(t.indexOf(e)<0&&null!=e)throw new RangeError("Invalid encoding type. Only utf-8 is supported");this.encoding="utf-8",this.encode=function(e){if("string"!=typeof e)throw new TypeError("passed argument must be of type string");var t=unescape(encodeURIComponent(e)),r=new Uint8Array(t.length);return t.split("").forEach((function(e,t){r[t]=e.charCodeAt(0)})),r}},TextDecoder:function(e,r){if(t.indexOf(e)<0&&null!=e)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(e,t){if(void 0===e)return"";if("boolean"!=typeof(void 0!==t&&"stream"in t&&t.stream))throw new TypeError("stream option must be boolean");if(ArrayBuffer.isView(e)){var r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n=new Array(r.length);return r.forEach((function(e,t){n[t]=String.fromCharCode(e)})),decodeURIComponent(escape(n.join("")))}throw new TypeError("passed argument must be an array buffer view")}}}})?n.apply(t,[]):n)||(e.exports=o)},5090:function(e,t,r){!function(e){"use strict";var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},t(e,r)};function n(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)}var o=function(){return o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},o.apply(this,arguments)};function i(e,t,r,n){return new(r||(r=Promise))((function(t,o){function i(e){try{a(n.next(e))}catch(e){o(e)}}function s(e){try{a(n.throw(e))}catch(e){o(e)}}function a(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r((function(e){e(n)}))).then(i,s)}a((n=n.apply(e,[])).next())}))}function s(e,t){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=t.call(e,s)}catch(e){i=[6,e],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 a=function(e){function t(t,r){var n=e.call(this,t)||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 n(t,e),t}(Error);function u(){return"undefined"!=typeof window&&window||"undefined"!=typeof globalThis&&globalThis}function c(){try{var e=u();if(!e)return;return"undefined"==typeof wx?u().location.href:e.__wxRoute}catch(e){}}var l=function(e){var t=e.dataSourceName,r=e.methodName,n=e.params,o=e.realMethodName,l=e.callFunction,f=e.envType,d=void 0===f?"prod":f,h=e.mode;return i(void 0,0,void 0,(function(){var e,i,f,p,v,y;return s(this,(function(s){switch(s.label){case 0:e={data:{},requestId:""},s.label=1;case 1:return s.trys.push([1,3,,4]),[4,l({name:"lowcode-datasource",data:{dataSourceName:t,methodName:r,params:n,userAgent:(g=u(),(null==g?void 0:g.navigator)?g.navigator.userAgent:"undefined"!=typeof wx&&wx.getSystemInfo?(wx.getSystemInfo({success:function(e){e&&(m=["brand","model","version","system","platform","SDKVersion","language"].map((function(t){return"".concat(t,": ").concat(e[t])})).join(", "))}}),m):void 0),referrer:c(),"x-sdk-version":"1.7.1",envType:d,mode:h}})];case 2:if(i=s.sent(),f=(null===(v=null==i?void 0:i.result)||void 0===v?void 0:v.requestId)||(null==i?void 0:i.requestId)||(null==i?void 0:i.requestID),null==i?void 0:i.result.code)throw new a("【错误】".concat(null==i?void 0:i.result.message,"\n【操作】调用 models.").concat(t?"".concat(t,"."):"").concat(o,"\n【错误码】").concat(null==i?void 0:i.result.code,"\n【请求ID】").concat(f||"N/A"),{code:null==i?void 0:i.result.code,requestId:f});return e.data=(null===(y=null==i?void 0:i.result)||void 0===y?void 0:y.data)||{},e.requestId=f,[3,4];case 3:throw"WxCloudSDKError"===(p=s.sent()).name?p:(console.log(p),new a("【错误】".concat(p.message,"\n 【操作】调用 models.").concat(t?"".concat(t,"."):"").concat(o,"\n 【请求ID】N/A"),{code:"UnknownError",originError:p}));case 4:return[2,e]}var m,g}))}))},f=function(e){var t=e.sql,r=e.params,n=e.config,o=e.callFunction,a=e.unsafe,u=void 0!==a&&a;return i(void 0,0,void 0,(function(){return s(this,(function(e){return[2,l({realMethodName:"$runSQL",methodName:"callWedaApi",params:{action:"RunMysqlCommand",data:{sqlTemplate:t,config:n,parameter:u?"":Object.entries(r||{}).reduce((function(e,t){var r=t[0],n=t[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"}e.push({key:r,type:o,value:"STRING"===o?n:JSON.stringify(n)})}return e}),[])||[]}},callFunction:o,mode:"sdk"})]}))}))},d=function(e){return{$runSQL:function(t,r,n){return i(this,0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,f({sql:t,params:r,config:o(o({},n),{preparedStatements:!0}),callFunction:e})];case 1:return[2,i.sent()]}}))}))},$runSQLRaw:function(t,r){return i(this,0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,f({sql:t,params:[],config:o(o({},r),{preparedStatements:!1}),callFunction:e})];case 1:return[2,n.sent()]}}))}))}}},h={filter:{where:{}},select:{$master:!0}};function p(e){return{getUrl:function(t){return"".concat(t,"/").concat(e)},method:"post"}}var v={get:o(o({},p("get")),{defaultParams:o({},h)}),list:o(o({},p("list")),{defaultParams:o({},h)}),create:p("create"),createMany:p("createMany"),update:o(o({},p("update")),{method:"put"}),updateMany:o(o({},p("updateMany")),{method:"put"}),upsert:p("upsert"),delete:p("delete"),deleteMany:p("deleteMany")},y="Unknown error occurred",m="NotSupported",g=function(e,t,r,n){var o=d(e);return new Proxy({},{get:function(e,i){if("string"==typeof i)return Object.prototype.hasOwnProperty.call(o,i)?o[i]:w(r,i,t,n)}})},b=function(e,t,r,n,o){return new a("【错误】".concat(e,"\n【操作】调用 models.").concat(t,".").concat(r,"\n【错误码】").concat(n,"\n【请求ID】").concat(o),{code:n,requestId:o})},w=function(e,t,r,n){return new Proxy({},{get:function(u,c){if("runSQLTemplate"!==c){var l=v[c];if(!l){var f=new Error("不支持的操作: ".concat(c));throw new a(f.message||y,{originError:f,code:m,requestId:"N/A"})}return function(n){return void 0===n&&(n={}),i(void 0,0,void 0,(function(){var o,i,u,f,d,h,p,v,m,g;return s(this,(function(s){switch(s.label){case 0:o=l.getUrl,i=l.method,u=l.defaultParams,f=void 0===u?{}:u,d=Object.assign({},f,n),h="pre"===d.envType?"pre":"prod",p=[e,h,o(t)].join("/"),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,r({url:p,body:JSON.stringify(d),method:i})];case 2:if((v=s.sent()).code)throw b(null==v?void 0:v.message,t,c,null==v?void 0:v.code,null==v?void 0:v.requestId);return"get"===c&&Object.assign(v,{data:null!==(g=v.data.record)&&void 0!==g?g:v.data}),[2,v];case 3:throw m=s.sent(),new a((null==m?void 0:m.message)||y,{originError:m});case 4:return[2]}}))}))}}if(!(null==n?void 0:n.sqlBaseUrl))throw f=new Error("不支持的操作: ".concat(c)),new a(f.message||y,{originError:f,code:m,requestId:"N/A"});return function(e){return i(void 0,0,void 0,(function(){var i,u,l,f,d,h,p,v,m,g,w,_,S,E,I,O;return s(this,(function(s){switch(s.label){case 0:i=e.params,u=e.templateName,l=e.envType,f="pre"===l?"pre":"prod",d=[n.sqlBaseUrl,f,u,"run"].join("/"),h=Object.entries(i||{}).reduce((function(e,t){var r=t[0],n=t[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"}e.push({key:r,type:o,value:"STRING"===o?n:JSON.stringify(n)})}return e}),[]),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,r({url:d,body:JSON.stringify({parameter:h}),method:"POST"})];case 2:if(p=s.sent(),null===(m=null==p?void 0:p.Response)||void 0===m?void 0:m.Error)throw b(null===(w=null===(g=null==p?void 0:p.Response)||void 0===g?void 0:g.Error)||void 0===w?void 0:w.Message,t,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,o(o({},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 v=s.sent(),new a((null==v?void 0:v.message)||y,{originError:v});case 4:return[2]}}))}))}}})},_={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}}}},S=function(e){var t=d(e);return new Proxy({},{get:function(r,n){if("string"==typeof n)return Object.prototype.hasOwnProperty.call(t,n)?t[n]:function(e,t){return new Proxy({},{get:function(r,n){var u=_[n];if(!u){var c=new Error("不支持的操作: ".concat(n));throw new a(c.message||"Unknown error occurred",{originError:c,code:"NotSupported",requestId:"N/A"})}return function(r){return i(void 0,0,void 0,(function(){var i,a,c,f,d;return s(this,(function(s){switch(s.label){case 0:return i=o(o({},u.defaultParams||{}),r||{}),[4,l({callFunction:t,dataSourceName:e,methodName:u.methodName,realMethodName:n,params:i,envType:null==r?void 0:r.envType})];case 1:return a=s.sent(),c={data:{}},f=u.responseKey,c.data=f?null===(d=null==a?void 0:a.data)||void 0===d?void 0:d[f]:null==a?void 0:a.data,[2,c]}}))}))}}})}(n,e)}})},E=function(){function e(e){var t=this;this.map=new Map,e&&(e instanceof Headers?e.forEach((function(e,r){t.append(r,e)})):Array.isArray(e)?e.forEach((function(e){var r=e[0],n=e[1];t.append(r,n)})):"object"==typeof e&&Object.keys(e).forEach((function(r){t.append(r,e[r])})))}return e.prototype.append=function(e,t){var r=e.toLowerCase(),n=this.map.get(r);n?this.map.set(r,"".concat(n,", ").concat(t)):this.map.set(r,String(t))},e.prototype.delete=function(e){this.map.delete(e.toLowerCase())},e.prototype.forEach=function(e,t){var r=this;this.map.forEach((function(n,o){e.call(t,n,o,r)}))},e.prototype.get=function(e){return this.map.get(e.toLowerCase())||null},e.prototype.has=function(e){return this.map.has(e.toLowerCase())},e.prototype.set=function(e,t){this.map.set(e.toLowerCase(),String(t))},e.prototype.entries=function(){return this.map.entries()},e.prototype.keys=function(){return this.map.keys()},e.prototype.values=function(){return this.map.values()},e.prototype.getSetCookie=function(){var e=[];return this.map.forEach((function(t,r){"set-cookie"===r&&e.push(t)})),e},e.prototype.toJSON=function(){var e={};return this.map.forEach((function(t,r){e[r]=t})),e},e.prototype[Symbol.iterator]=function(){return this.entries()},e}();"object"!=typeof globalThis||globalThis.Headers||(globalThis.Headers=E);var I="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==r.g?r.g:"undefined"!=typeof self?self:{};function O(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var T,A,R=function(e){try{return!!e()}catch(e){return!0}},P=!R((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),C=P,N=Function.prototype,x=N.call,L=C&&N.bind.bind(x,x),U=C?L:function(e){return function(){return x.apply(e,arguments)}},k=U,D=k({}.toString),j=k("".slice),q=function(e){return j(D(e),8,-1)},M=R,B=q,W=Object,F=U("".split),V=M((function(){return!W("z").propertyIsEnumerable(0)}))?function(e){return"String"===B(e)?F(e,""):W(e)}:W,H=function(e){return null==e},$=H,G=TypeError,z=function(e){if($(e))throw new G("Can't call method on "+e);return e},K=V,J=z,Y=function(e){return K(J(e))},Q={},Z=function(e){return e&&e.Math===Math&&e},X=Z("object"==typeof globalThis&&globalThis)||Z("object"==typeof window&&window)||Z("object"==typeof self&&self)||Z("object"==typeof I&&I)||Z("object"==typeof I&&I)||function(){return this}()||Function("return this")(),ee="object"==typeof document&&document.all,te=void 0===ee&&void 0!==ee?function(e){return"function"==typeof e||e===ee}:function(e){return"function"==typeof e},re=te,ne=X.WeakMap,oe=re(ne)&&/native code/.test(String(ne)),ie=te,se=function(e){return"object"==typeof e?null!==e:ie(e)},ae=!R((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]})),ue={},ce=se,le=X.document,fe=ce(le)&&ce(le.createElement),de=function(e){return fe?le.createElement(e):{}},he=de,pe=!ae&&!R((function(){return 7!==Object.defineProperty(he("div"),"a",{get:function(){return 7}}).a})),ve=ae&&R((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),ye=se,me=String,ge=TypeError,be=function(e){if(ye(e))return e;throw new ge(me(e)+" is not an object")},we=P,_e=Function.prototype.call,Se=we?_e.bind(_e):function(){return _e.apply(_e,arguments)},Ee={},Ie=Ee,Oe=X,Te=te,Ae=function(e){return Te(e)?e:void 0},Re=function(e,t){return arguments.length<2?Ae(Ie[e])||Ae(Oe[e]):Ie[e]&&Ie[e][t]||Oe[e]&&Oe[e][t]},Pe=U({}.isPrototypeOf),Ce=X.navigator,Ne=Ce&&Ce.userAgent,xe=X,Le=Ne?String(Ne):"",Ue=xe.process,ke=xe.Deno,De=Ue&&Ue.versions||ke&&ke.version,je=De&&De.v8;je&&(A=(T=je.split("."))[0]>0&&T[0]<4?1:+(T[0]+T[1])),!A&&Le&&(!(T=Le.match(/Edge\/(\d+)/))||T[1]>=74)&&(T=Le.match(/Chrome\/(\d+)/))&&(A=+T[1]);var qe=A,Me=R,Be=X.String,We=!!Object.getOwnPropertySymbols&&!Me((function(){var e=Symbol("symbol detection");return!Be(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&qe&&qe<41})),Fe=We&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,Ve=Re,He=te,$e=Pe,Ge=Object,ze=Fe?function(e){return"symbol"==typeof e}:function(e){var t=Ve("Symbol");return He(t)&&$e(t.prototype,Ge(e))},Ke=String,Je=function(e){try{return Ke(e)}catch(e){return"Object"}},Ye=te,Qe=Je,Ze=TypeError,Xe=function(e){if(Ye(e))return e;throw new Ze(Qe(e)+" is not a function")},et=Xe,tt=H,rt=function(e,t){var r=e[t];return tt(r)?void 0:et(r)},nt=Se,ot=te,it=se,st=TypeError,at={exports:{}},ut=X,ct=Object.defineProperty,lt=X,ft="__core-js_shared__",dt=at.exports=lt[ft]||function(e,t){try{ct(ut,e,{value:t,configurable:!0,writable:!0})}catch(r){ut[e]=t}return t}(ft,{});(dt.versions||(dt.versions=[])).push({version:"3.45.0",mode:"pure",copyright:"© 2014-2025 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.45.0/LICENSE",source:"https://github.com/zloirock/core-js"});var ht=at.exports,pt=ht,vt=function(e,t){return pt[e]||(pt[e]=t||{})},yt=z,mt=Object,gt=function(e){return mt(yt(e))},bt=gt,wt=U({}.hasOwnProperty),_t=Object.hasOwn||function(e,t){return wt(bt(e),t)},St=U,Et=0,It=Math.random(),Ot=St(1.1.toString),Tt=function(e){return"Symbol("+(void 0===e?"":e)+")_"+Ot(++Et+It,36)},At=vt,Rt=_t,Pt=Tt,Ct=We,Nt=Fe,xt=X.Symbol,Lt=At("wks"),Ut=Nt?xt.for||xt:xt&&xt.withoutSetter||Pt,kt=function(e){return Rt(Lt,e)||(Lt[e]=Ct&&Rt(xt,e)?xt[e]:Ut("Symbol."+e)),Lt[e]},Dt=Se,jt=se,qt=ze,Mt=rt,Bt=function(e,t){var r,n;if("string"===t&&ot(r=e.toString)&&!it(n=nt(r,e)))return n;if(ot(r=e.valueOf)&&!it(n=nt(r,e)))return n;if("string"!==t&&ot(r=e.toString)&&!it(n=nt(r,e)))return n;throw new st("Can't convert object to primitive value")},Wt=TypeError,Ft=kt("toPrimitive"),Vt=ze,Ht=function(e){var t=function(e,t){if(!jt(e)||qt(e))return e;var r,n=Mt(e,Ft);if(n){if(void 0===t&&(t="default"),r=Dt(n,e,t),!jt(r)||qt(r))return r;throw new Wt("Can't convert object to primitive value")}return void 0===t&&(t="number"),Bt(e,t)}(e,"string");return Vt(t)?t:t+""},$t=ae,Gt=pe,zt=ve,Kt=be,Jt=Ht,Yt=TypeError,Qt=Object.defineProperty,Zt=Object.getOwnPropertyDescriptor,Xt="enumerable",er="configurable",tr="writable";ue.f=$t?zt?function(e,t,r){if(Kt(e),t=Jt(t),Kt(r),"function"==typeof e&&"prototype"===t&&"value"in r&&tr in r&&!r[tr]){var n=Zt(e,t);n&&n[tr]&&(e[t]=r.value,r={configurable:er in r?r[er]:n[er],enumerable:Xt in r?r[Xt]:n[Xt],writable:!1})}return Qt(e,t,r)}:Qt:function(e,t,r){if(Kt(e),t=Jt(t),Kt(r),Gt)try{return Qt(e,t,r)}catch(e){}if("get"in r||"set"in r)throw new Yt("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var rr,nr,or,ir=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},sr=ue,ar=ir,ur=ae?function(e,t,r){return sr.f(e,t,ar(1,r))}:function(e,t,r){return e[t]=r,e},cr=Tt,lr=vt("keys"),fr=function(e){return lr[e]||(lr[e]=cr(e))},dr={},hr=oe,pr=X,vr=se,yr=ur,mr=_t,gr=ht,br=fr,wr=dr,_r="Object already initialized",Sr=pr.TypeError,Er=pr.WeakMap;if(hr||gr.state){var Ir=gr.state||(gr.state=new Er);Ir.get=Ir.get,Ir.has=Ir.has,Ir.set=Ir.set,rr=function(e,t){if(Ir.has(e))throw new Sr(_r);return t.facade=e,Ir.set(e,t),t},nr=function(e){return Ir.get(e)||{}},or=function(e){return Ir.has(e)}}else{var Or=br("state");wr[Or]=!0,rr=function(e,t){if(mr(e,Or))throw new Sr(_r);return t.facade=e,yr(e,Or,t),t},nr=function(e){return mr(e,Or)?e[Or]:{}},or=function(e){return mr(e,Or)}}var Tr={set:rr,get:nr,has:or,enforce:function(e){return or(e)?nr(e):rr(e,{})},getterFor:function(e){return function(t){var r;if(!vr(t)||(r=nr(t)).type!==e)throw new Sr("Incompatible receiver, "+e+" required");return r}}},Ar=P,Rr=Function.prototype,Pr=Rr.apply,Cr=Rr.call,Nr="object"==typeof Reflect&&Reflect.apply||(Ar?Cr.bind(Pr):function(){return Cr.apply(Pr,arguments)}),xr=q,Lr=U,Ur=function(e){if("Function"===xr(e))return Lr(e)},kr={},Dr={},jr={}.propertyIsEnumerable,qr=Object.getOwnPropertyDescriptor,Mr=qr&&!jr.call({1:2},1);Dr.f=Mr?function(e){var t=qr(this,e);return!!t&&t.enumerable}:jr;var Br=ae,Wr=Se,Fr=Dr,Vr=ir,Hr=Y,$r=Ht,Gr=_t,zr=pe,Kr=Object.getOwnPropertyDescriptor;kr.f=Br?Kr:function(e,t){if(e=Hr(e),t=$r(t),zr)try{return Kr(e,t)}catch(e){}if(Gr(e,t))return Vr(!Wr(Fr.f,e,t),e[t])};var Jr=R,Yr=te,Qr=/#|\.prototype\./,Zr=function(e,t){var r=en[Xr(e)];return r===rn||r!==tn&&(Yr(t)?Jr(t):!!t)},Xr=Zr.normalize=function(e){return String(e).replace(Qr,".").toLowerCase()},en=Zr.data={},tn=Zr.NATIVE="N",rn=Zr.POLYFILL="P",nn=Zr,on=Xe,sn=P,an=Ur(Ur.bind),un=function(e,t){return on(e),void 0===t?e:sn?an(e,t):function(){return e.apply(t,arguments)}},cn=X,ln=Nr,fn=Ur,dn=te,hn=kr.f,pn=nn,vn=Ee,yn=un,mn=ur,gn=_t,bn=function(e){var t=function(r,n,o){if(this instanceof t){switch(arguments.length){case 0:return new e;case 1:return new e(r);case 2:return new e(r,n)}return new e(r,n,o)}return ln(e,this,arguments)};return t.prototype=e.prototype,t},wn=function(e,t){var r,n,o,i,s,a,u,c,l,f=e.target,d=e.global,h=e.stat,p=e.proto,v=d?cn:h?cn[f]:cn[f]&&cn[f].prototype,y=d?vn:vn[f]||mn(vn,f,{})[f],m=y.prototype;for(i in t)n=!(r=pn(d?i:f+(h?".":"#")+i,e.forced))&&v&&gn(v,i),a=y[i],n&&(u=e.dontCallGetSet?(l=hn(v,i))&&l.value:v[i]),s=n&&u?u:t[i],(r||p||typeof a!=typeof s)&&(c=e.bind&&n?yn(s,cn):e.wrap&&n?bn(s):p&&dn(s)?fn(s):s,(e.sham||s&&s.sham||a&&a.sham)&&mn(c,"sham",!0),mn(y,i,c),p&&(gn(vn,o=f+"Prototype")||mn(vn,o,{}),mn(vn[o],i,s),e.real&&m&&(r||!m[i])&&mn(m,i,s)))},_n=ae,Sn=_t,En=Function.prototype,In=_n&&Object.getOwnPropertyDescriptor,On=Sn(En,"name"),Tn={EXISTS:On,PROPER:On&&"something"===function(){}.name,CONFIGURABLE:On&&(!_n||_n&&In(En,"name").configurable)},An={},Rn=Math.ceil,Pn=Math.floor,Cn=Math.trunc||function(e){var t=+e;return(t>0?Pn:Rn)(t)},Nn=function(e){var t=+e;return t!=t||0===t?0:Cn(t)},xn=Nn,Ln=Math.max,Un=Math.min,kn=function(e,t){var r=xn(e);return r<0?Ln(r+t,0):Un(r,t)},Dn=Nn,jn=Math.min,qn=function(e){return t=e.length,(r=Dn(t))>0?jn(r,9007199254740991):0;var t,r},Mn=Y,Bn=kn,Wn=qn,Fn=function(e){return function(t,r,n){var o=Mn(t),i=Wn(o);if(0===i)return!e&&-1;var s,a=Bn(n,i);if(e&&r!=r){for(;i>a;)if((s=o[a++])!=s)return!0}else for(;i>a;a++)if((e||a in o)&&o[a]===r)return e||a||0;return!e&&-1}},Vn={includes:Fn(!0),indexOf:Fn(!1)},Hn=_t,$n=Y,Gn=Vn.indexOf,zn=dr,Kn=U([].push),Jn=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Yn=Jn,Qn=Object.keys||function(e){return function(e,t){var r,n=$n(e),o=0,i=[];for(r in n)!Hn(zn,r)&&Hn(n,r)&&Kn(i,r);for(;t.length>o;)Hn(n,r=t[o++])&&(~Gn(i,r)||Kn(i,r));return i}(e,Yn)},Zn=ae,Xn=ve,eo=ue,to=be,ro=Y,no=Qn;An.f=Zn&&!Xn?Object.defineProperties:function(e,t){to(e);for(var r,n=ro(t),o=no(t),i=o.length,s=0;i>s;)eo.f(e,r=o[s++],n[r]);return e};var oo,io=Re("document","documentElement"),so=be,ao=An,uo=Jn,co=dr,lo=io,fo=de,ho="prototype",po="script",vo=fr("IE_PROTO"),yo=function(){},mo=function(e){return"<"+po+">"+e+"</"+po+">"},go=function(e){e.write(mo("")),e.close();var t=e.parentWindow.Object;return e=null,t},bo=function(){try{oo=new ActiveXObject("htmlfile")}catch(e){}var e,t,r;bo="undefined"!=typeof document?document.domain&&oo?go(oo):(t=fo("iframe"),r="java"+po+":",t.style.display="none",lo.appendChild(t),t.src=String(r),(e=t.contentWindow.document).open(),e.write(mo("document.F=Object")),e.close(),e.F):go(oo);for(var n=uo.length;n--;)delete bo[ho][uo[n]];return bo()};co[vo]=!0;var wo,_o,So,Eo=Object.create||function(e,t){var r;return null!==e?(yo[ho]=so(e),r=new yo,yo[ho]=null,r[vo]=e):r=bo(),void 0===t?r:ao.f(r,t)},Io=!R((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),Oo=_t,To=te,Ao=gt,Ro=Io,Po=fr("IE_PROTO"),Co=Object,No=Co.prototype,xo=Ro?Co.getPrototypeOf:function(e){var t=Ao(e);if(Oo(t,Po))return t[Po];var r=t.constructor;return To(r)&&t instanceof r?r.prototype:t instanceof Co?No:null},Lo=ur,Uo=function(e,t,r,n){return n&&n.enumerable?e[t]=r:Lo(e,t,r),e},ko=R,Do=te,jo=se,qo=Eo,Mo=xo,Bo=Uo,Wo=kt("iterator"),Fo=!1;[].keys&&("next"in(So=[].keys())?(_o=Mo(Mo(So)))!==Object.prototype&&(wo=_o):Fo=!0),wo=!jo(wo)||ko((function(){var e={};return wo[Wo].call(e)!==e}))?{}:qo(wo),Do(wo[Wo])||Bo(wo,Wo,(function(){return this}));var Vo={IteratorPrototype:wo,BUGGY_SAFARI_ITERATORS:Fo},Ho={};Ho[kt("toStringTag")]="z";var $o="[object z]"===String(Ho),Go=$o,zo=te,Ko=q,Jo=kt("toStringTag"),Yo=Object,Qo="Arguments"===Ko(function(){return arguments}()),Zo=Go?Ko:function(e){var t,r,n;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=function(e,t){try{return e[t]}catch(e){}}(t=Yo(e),Jo))?r:Qo?Ko(t):"Object"===(n=Ko(t))&&zo(t.callee)?"Arguments":n},Xo=Zo,ei=$o?{}.toString:function(){return"[object "+Xo(this)+"]"},ti=$o,ri=ue.f,ni=ur,oi=_t,ii=ei,si=kt("toStringTag"),ai=function(e,t,r,n){var o=r?e:e&&e.prototype;o&&(oi(o,si)||ri(o,si,{configurable:!0,value:t}),n&&!ti&&ni(o,"toString",ii))},ui=Vo.IteratorPrototype,ci=Eo,li=ir,fi=ai,di=Q,hi=function(){return this},pi=function(e,t,r,n){var o=t+" Iterator";return e.prototype=ci(ui,{next:li(+!n,r)}),fi(e,o,!1,!0),di[o]=hi,e},vi=wn,yi=Se,mi=Tn,gi=pi,bi=xo,wi=ai,_i=Uo,Si=Q,Ei=Vo,Ii=mi.PROPER,Oi=Ei.BUGGY_SAFARI_ITERATORS,Ti=kt("iterator"),Ai="keys",Ri="values",Pi="entries",Ci=function(){return this},Ni=function(e,t,r,n,o,i,s){gi(r,t,n);var a,u,c,l=function(e){if(e===o&&v)return v;if(!Oi&&e&&e in h)return h[e];switch(e){case Ai:case Ri:case Pi:return function(){return new r(this,e)}}return function(){return new r(this)}},f=t+" Iterator",d=!1,h=e.prototype,p=h[Ti]||h["@@iterator"]||o&&h[o],v=!Oi&&p||l(o),y="Array"===t&&h.entries||p;if(y&&(a=bi(y.call(new e)))!==Object.prototype&&a.next&&(wi(a,f,!0,!0),Si[f]=Ci),Ii&&o===Ri&&p&&p.name!==Ri&&(d=!0,v=function(){return yi(p,this)}),o)if(u={values:l(Ri),keys:i?v:l(Ai),entries:l(Pi)},s)for(c in u)(Oi||d||!(c in h))&&_i(h,c,u[c]);else vi({target:t,proto:!0,forced:Oi||d},u);return s&&h[Ti]!==v&&_i(h,Ti,v,{name:o}),Si[t]=v,u},xi=function(e,t){return{value:e,done:t}},Li=Y,Ui=Q,ki=Tr;ue.f;var Di=Ni,ji=xi,qi="Array Iterator",Mi=ki.set,Bi=ki.getterFor(qi);Di(Array,"Array",(function(e,t){Mi(this,{type:qi,target:Li(e),index:0,kind:t})}),(function(){var e=Bi(this),t=e.target,r=e.index++;if(!t||r>=t.length)return e.target=null,ji(void 0,!0);switch(e.kind){case"keys":return ji(r,!1);case"values":return ji(t[r],!1)}return ji([r,t[r]],!1)}),"values"),Ui.Arguments=Ui.Array;var Wi=wn,Fi=U,Vi=kn,Hi=RangeError,$i=String.fromCharCode,Gi=String.fromCodePoint,zi=Fi([].join);Wi({target:"String",stat:!0,arity:1,forced:!!Gi&&1!==Gi.length},{fromCodePoint:function(e){for(var t,r=[],n=arguments.length,o=0;n>o;){if(t=+arguments[o++],Vi(t,1114111)!==t)throw new Hi(t+" is not a valid code point");r[o]=t<65536?$i(t):$i(55296+((t-=65536)>>10),t%1024+56320)}return zi(r,"")}});var Ki=X,Ji=ae,Yi=Object.getOwnPropertyDescriptor,Qi=R,Zi=!0,Xi=kt("iterator"),es=!Qi((function(){var e=new URL("b?a=1&b=2&c=3","https://a"),t=e.searchParams,r=new URLSearchParams("a=1&a=2&b=3"),n="";return e.pathname="c%20d",t.forEach((function(e,r){t.delete("b"),n+=r+e})),r.delete("a",2),r.delete("b",void 0),!e.toJSON||!r.has("a",1)||r.has("a",2)||!r.has("a",void 0)||r.has("b")||!t.size&&Zi||!t.sort||"https://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[Xi]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("https://тест").host||"#%D0%B1"!==new URL("https://a#б").hash||"a1c3"!==n||"x"!==new URL("https://x",void 0).host})),ts=ue,rs=function(e,t,r){return ts.f(e,t,r)},ns=Uo,os=Pe,is=TypeError,ss=function(e,t){if(os(t,e))return e;throw new is("Incorrect invocation")},as=Zo,us=String,cs=function(e){if("Symbol"===as(e))throw new TypeError("Cannot convert a Symbol value to a string");return us(e)},ls=Zo,fs=rt,ds=H,hs=Q,ps=kt("iterator"),vs=function(e){if(!ds(e))return fs(e,ps)||fs(e,"@@iterator")||hs[ls(e)]},ys=Se,ms=Xe,gs=be,bs=Je,ws=vs,_s=TypeError,Ss=function(e,t){var r=arguments.length<2?ws(e):t;if(ms(r))return gs(ys(r,e));throw new _s(bs(e)+" is not iterable")},Es=TypeError,Is=function(e,t){if(e<t)throw new Es("Not enough arguments");return e},Os=U([].slice),Ts=Os,As=Math.floor,Rs=function(e,t){var r=e.length;if(r<8)for(var n,o,i=1;i<r;){for(o=i,n=e[i];o&&t(e[o-1],n)>0;)e[o]=e[--o];o!==i++&&(e[o]=n)}else for(var s=As(r/2),a=Rs(Ts(e,0,s),t),u=Rs(Ts(e,s),t),c=a.length,l=u.length,f=0,d=0;f<c||d<l;)e[f+d]=f<c&&d<l?t(a[f],u[d])<=0?a[f++]:u[d++]:f<c?a[f++]:u[d++];return e},Ps=wn,Cs=X,Ns=function(e){if(!Ji)return Ki[e];var t=Yi(Ki,e);return t&&t.value},xs=Re,Ls=Se,Us=U,ks=ae,Ds=es,js=Uo,qs=rs,Ms=function(e,t,r){for(var n in t)r&&r.unsafe&&e[n]?e[n]=t[n]:ns(e,n,t[n],r);return e},Bs=ai,Ws=pi,Fs=Tr,Vs=ss,Hs=te,$s=_t,Gs=un,zs=Zo,Ks=be,Js=se,Ys=cs,Qs=Eo,Zs=ir,Xs=Ss,ea=vs,ta=xi,ra=Is,na=Rs,oa=kt("iterator"),ia="URLSearchParams",sa=ia+"Iterator",aa=Fs.set,ua=Fs.getterFor(ia),ca=Fs.getterFor(sa),la=Ns("fetch"),fa=Ns("Request"),da=Ns("Headers"),ha=fa&&fa.prototype,pa=da&&da.prototype,va=Cs.TypeError,ya=Cs.encodeURIComponent,ma=String.fromCharCode,ga=xs("String","fromCodePoint"),ba=parseInt,wa=Us("".charAt),_a=Us([].join),Sa=Us([].push),Ea=Us("".replace),Ia=Us([].shift),Oa=Us([].splice),Ta=Us("".split),Aa=Us("".slice),Ra=Us(/./.exec),Pa=/\+/g,Ca=/^[0-9a-f]+$/i,Na=function(e,t){var r=Aa(e,t,t+2);return Ra(Ca,r)?ba(r,16):NaN},xa=function(e){for(var t=0,r=128;r>0&&e&r;r>>=1)t++;return t},La=function(e){var t=null;switch(e.length){case 1:t=e[0];break;case 2:t=(31&e[0])<<6|63&e[1];break;case 3:t=(15&e[0])<<12|(63&e[1])<<6|63&e[2];break;case 4:t=(7&e[0])<<18|(63&e[1])<<12|(63&e[2])<<6|63&e[3]}return t>1114111?null:t},Ua=function(e){for(var t=(e=Ea(e,Pa," ")).length,r="",n=0;n<t;){var o=wa(e,n);if("%"===o){if("%"===wa(e,n+1)||n+3>t){r+="%",n++;continue}var i=Na(e,n+1);if(i!=i){r+=o,n++;continue}n+=2;var s=xa(i);if(0===s)o=ma(i);else{if(1===s||s>4){r+="�",n++;continue}for(var a=[i],u=1;u<s&&!(3+ ++n>t||"%"!==wa(e,n));){var c=Na(e,n+1);if(c!=c){n+=3;break}if(c>191||c<128)break;Sa(a,c),n+=2,u++}if(a.length!==s){r+="�";continue}var l=La(a);null===l?r+="�":o=ga(l)}}r+=o,n++}return r},ka=/[!'()~]|%20/g,Da={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},ja=function(e){return Da[e]},qa=function(e){return Ea(ya(e),ka,ja)},Ma=Ws((function(e,t){aa(this,{type:sa,target:ua(e).entries,index:0,kind:t})}),ia,(function(){var e=ca(this),t=e.target,r=e.index++;if(!t||r>=t.length)return e.target=null,ta(void 0,!0);var n=t[r];switch(e.kind){case"keys":return ta(n.key,!1);case"values":return ta(n.value,!1)}return ta([n.key,n.value],!1)}),!0),Ba=function(e){this.entries=[],this.url=null,void 0!==e&&(Js(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===wa(e,0)?Aa(e,1):e:Ys(e)))};Ba.prototype={type:ia,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,n,o,i,s,a,u=this.entries,c=ea(e);if(c)for(r=(t=Xs(e,c)).next;!(n=Ls(r,t)).done;){if(i=(o=Xs(Ks(n.value))).next,(s=Ls(i,o)).done||(a=Ls(i,o)).done||!Ls(i,o).done)throw new va("Expected sequence with length 2");Sa(u,{key:Ys(s.value),value:Ys(a.value)})}else for(var l in e)$s(e,l)&&Sa(u,{key:l,value:Ys(e[l])})},parseQuery:function(e){if(e)for(var t,r,n=this.entries,o=Ta(e,"&"),i=0;i<o.length;)(t=o[i++]).length&&(r=Ta(t,"="),Sa(n,{key:Ua(Ia(r)),value:Ua(_a(r,"="))}))},serialize:function(){for(var e,t=this.entries,r=[],n=0;n<t.length;)e=t[n++],Sa(r,qa(e.key)+"="+qa(e.value));return _a(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var Wa=function(){Vs(this,Fa);var e=aa(this,new Ba(arguments.length>0?arguments[0]:void 0));ks||(this.size=e.entries.length)},Fa=Wa.prototype;if(Ms(Fa,{append:function(e,t){var r=ua(this);ra(arguments.length,2),Sa(r.entries,{key:Ys(e),value:Ys(t)}),ks||this.length++,r.updateURL()},delete:function(e){for(var t=ua(this),r=ra(arguments.length,1),n=t.entries,o=Ys(e),i=r<2?void 0:arguments[1],s=void 0===i?i:Ys(i),a=0;a<n.length;){var u=n[a];if(u.key!==o||void 0!==s&&u.value!==s)a++;else if(Oa(n,a,1),void 0!==s)break}ks||(this.size=n.length),t.updateURL()},get:function(e){var t=ua(this).entries;ra(arguments.length,1);for(var r=Ys(e),n=0;n<t.length;n++)if(t[n].key===r)return t[n].value;return null},getAll:function(e){var t=ua(this).entries;ra(arguments.length,1);for(var r=Ys(e),n=[],o=0;o<t.length;o++)t[o].key===r&&Sa(n,t[o].value);return n},has:function(e){for(var t=ua(this).entries,r=ra(arguments.length,1),n=Ys(e),o=r<2?void 0:arguments[1],i=void 0===o?o:Ys(o),s=0;s<t.length;){var a=t[s++];if(a.key===n&&(void 0===i||a.value===i))return!0}return!1},set:function(e,t){var r=ua(this);ra(arguments.length,1);for(var n,o=r.entries,i=!1,s=Ys(e),a=Ys(t),u=0;u<o.length;u++)(n=o[u]).key===s&&(i?Oa(o,u--,1):(i=!0,n.value=a));i||Sa(o,{key:s,value:a}),ks||(this.size=o.length),r.updateURL()},sort:function(){var e=ua(this);na(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,r=ua(this).entries,n=Gs(e,arguments.length>1?arguments[1]:void 0),o=0;o<r.length;)n((t=r[o++]).value,t.key,this)},keys:function(){return new Ma(this,"keys")},values:function(){return new Ma(this,"values")},entries:function(){return new Ma(this,"entries")}},{enumerable:!0}),js(Fa,oa,Fa.entries,{name:"entries"}),js(Fa,"toString",(function(){return ua(this).serialize()}),{enumerable:!0}),ks&&qs(Fa,"size",{get:function(){return ua(this).entries.length},configurable:!0,enumerable:!0}),Bs(Wa,ia),Ps({global:!0,constructor:!0,forced:!Ds},{URLSearchParams:Wa}),!Ds&&Hs(da)){var Va=Us(pa.has),Ha=Us(pa.set),$a=function(e){if(Js(e)){var t,r=e.body;if(zs(r)===ia)return t=e.headers?new da(e.headers):new da,Va(t,"content-type")||Ha(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),Qs(e,{body:Zs(0,Ys(r)),headers:Zs(0,t)})}return e};if(Hs(la)&&Ps({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return la(e,arguments.length>1?$a(arguments[1]):{})}}),Hs(fa)){var Ga=function(e){return Vs(this,ha),new fa(e,arguments.length>1?$a(arguments[1]):{})};ha.constructor=Ga,Ga.prototype=ha,Ps({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:Ga})}}var za={URLSearchParams:Wa,getState:ua},Ka=U,Ja=Nn,Ya=cs,Qa=z,Za=Ka("".charAt),Xa=Ka("".charCodeAt),eu=Ka("".slice),tu=function(e){return function(t,r){var n,o,i=Ya(Qa(t)),s=Ja(r),a=i.length;return s<0||s>=a?e?"":void 0:(n=Xa(i,s))<55296||n>56319||s+1===a||(o=Xa(i,s+1))<56320||o>57343?e?Za(i,s):n:e?eu(i,s,s+2):o-56320+(n-55296<<10)+65536}},ru={codeAt:tu(!1),charAt:tu(!0)},nu=ru.charAt,ou=cs,iu=Tr,su=Ni,au=xi,uu="String Iterator",cu=iu.set,lu=iu.getterFor(uu);su(String,"String",(function(e){cu(this,{type:uu,string:ou(e),index:0})}),(function(){var e,t=lu(this),r=t.string,n=t.index;return n>=r.length?au(void 0,!0):(e=nu(r,n),t.index+=e.length,au(e,!1))}));var fu={};fu.f=Object.getOwnPropertySymbols;var du=ae,hu=U,pu=Se,vu=R,yu=Qn,mu=fu,gu=Dr,bu=gt,wu=V,_u=Object.assign,Su=Object.defineProperty,Eu=hu([].concat),Iu=!_u||vu((function(){if(du&&1!==_u({b:1},_u(Su({},"a",{enumerable:!0,get:function(){Su(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},r=Symbol("assign detection"),n="abcdefghijklmnopqrst";return e[r]=7,n.split("").forEach((function(e){t[e]=e})),7!==_u({},e)[r]||yu(_u({},t)).join("")!==n}))?function(e,t){for(var r=bu(e),n=arguments.length,o=1,i=mu.f,s=gu.f;n>o;)for(var a,u=wu(arguments[o++]),c=i?Eu(yu(u),i(u)):yu(u),l=c.length,f=0;l>f;)a=c[f++],du&&!pu(s,u,a)||(r[a]=u[a]);return r}:_u,Ou=Se,Tu=be,Au=rt,Ru=be,Pu=Q,Cu=kt("iterator"),Nu=Array.prototype,xu=te,Lu=ht,Uu=U(Function.toString);xu(Lu.inspectSource)||(Lu.inspectSource=function(e){return Uu(e)});var ku=Lu.inspectSource,Du=U,ju=R,qu=te,Mu=Zo,Bu=ku,Wu=function(){},Fu=Re("Reflect","construct"),Vu=/^\s*(?:class|function)\b/,Hu=Du(Vu.exec),$u=!Vu.test(Wu),Gu=function(e){if(!qu(e))return!1;try{return Fu(Wu,[],e),!0}catch(e){return!1}},zu=function(e){if(!qu(e))return!1;switch(Mu(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return $u||!!Hu(Vu,Bu(e))}catch(e){return!0}};zu.sham=!0;var Ku,Ju=!Fu||ju((function(){var e;return Gu(Gu.call)||!Gu(Object)||!Gu((function(){e=!0}))||e}))?zu:Gu,Yu=ae,Qu=ue,Zu=ir,Xu=un,ec=Se,tc=gt,rc=function(e,t,r,n){try{return n?t(Ru(r)[0],r[1]):t(r)}catch(t){!function(e,t,r){var n,o;Tu(e);try{if(!(n=Au(e,"return"))){if("throw"===t)throw r;return r}n=Ou(n,e)}catch(e){o=!0,n=e}if("throw"===t)throw r;if(o)throw n;Tu(n)}(e,"throw",t)}},nc=function(e){return void 0!==e&&(Pu.Array===e||Nu[Cu]===e)},oc=Ju,ic=qn,sc=function(e,t,r){Yu?Qu.f(e,t,Zu(0,r)):e[t]=r},ac=Ss,uc=vs,cc=Array,lc=U,fc=2147483647,dc=/[^\0-\u007E]/,hc=/[.\u3002\uFF0E\uFF61]/g,pc="Overflow: input needs wider integers to process",vc=RangeError,yc=lc(hc.exec),mc=Math.floor,gc=String.fromCharCode,bc=lc("".charCodeAt),wc=lc([].join),_c=lc([].push),Sc=lc("".replace),Ec=lc("".split),Ic=lc("".toLowerCase),Oc=function(e){return e+22+75*(e<26)},Tc=function(e,t,r){var n=0;for(e=r?mc(e/700):e>>1,e+=mc(e/t);e>455;)e=mc(e/35),n+=36;return mc(n+36*e/(e+38))},Ac=function(e){var t,r,n=[],o=(e=function(e){for(var t=[],r=0,n=e.length;r<n;){var o=bc(e,r++);if(o>=55296&&o<=56319&&r<n){var i=bc(e,r++);56320==(64512&i)?_c(t,((1023&o)<<10)+(1023&i)+65536):(_c(t,o),r--)}else _c(t,o)}return t}(e)).length,i=128,s=0,a=72;for(t=0;t<e.length;t++)(r=e[t])<128&&_c(n,gc(r));var u=n.length,c=u;for(u&&_c(n,"-");c<o;){var l=fc;for(t=0;t<e.length;t++)(r=e[t])>=i&&r<l&&(l=r);var f=c+1;if(l-i>mc((fc-s)/f))throw new vc(pc);for(s+=(l-i)*f,i=l,t=0;t<e.length;t++){if((r=e[t])<i&&++s>fc)throw new vc(pc);if(r===i){for(var d=s,h=36;;){var p=h<=a?1:h>=a+26?26:h-a;if(d<p)break;var v=d-p,y=36-p;_c(n,gc(Oc(p+v%y))),d=mc(v/y),h+=36}_c(n,gc(Oc(d))),a=Tc(s,f,c===u),s=0,c++}}s++,i++}return wc(n,"")},Rc=wn,Pc=ae,Cc=es,Nc=X,xc=un,Lc=U,Uc=Uo,kc=rs,Dc=ss,jc=_t,qc=Iu,Mc=function(e){var t=tc(e),r=oc(this),n=arguments.length,o=n>1?arguments[1]:void 0,i=void 0!==o;i&&(o=Xu(o,n>2?arguments[2]:void 0));var s,a,u,c,l,f,d=uc(t),h=0;if(!d||this===cc&&nc(d))for(s=ic(t),a=r?new this(s):cc(s);s>h;h++)f=i?o(t[h],h):t[h],sc(a,h,f);else for(a=r?new this:[],l=(c=ac(t,d)).next;!(u=ec(l,c)).done;h++)f=i?rc(c,o,[u.value,h],!0):u.value,sc(a,h,f);return a.length=h,a},Bc=Os,Wc=ru.codeAt,Fc=function(e){var t,r,n=[],o=Ec(Sc(Ic(e),hc,"."),".");for(t=0;t<o.length;t++)r=o[t],_c(n,yc(dc,r)?"xn--"+Ac(r):r);return wc(n,".")},Vc=cs,Hc=ai,$c=Is,Gc=za,zc=Tr,Kc=zc.set,Jc=zc.getterFor("URL"),Yc=Gc.URLSearchParams,Qc=Gc.getState,Zc=Nc.URL,Xc=Nc.TypeError,el=Nc.parseInt,tl=Math.floor,rl=Math.pow,nl=Lc("".charAt),ol=Lc(/./.exec),il=Lc([].join),sl=Lc(1.1.toString),al=Lc([].pop),ul=Lc([].push),cl=Lc("".replace),ll=Lc([].shift),fl=Lc("".split),dl=Lc("".slice),hl=Lc("".toLowerCase),pl=Lc([].unshift),vl="Invalid scheme",yl="Invalid host",ml="Invalid port",gl=/[a-z]/i,bl=/[\d+-.a-z]/i,wl=/\d/,_l=/^0x/i,Sl=/^[0-7]+$/,El=/^\d+$/,Il=/^[\da-f]+$/i,Ol=/[\0\t\n\r #%/:<>?@[\\\]^|]/,Tl=/[\0\t\n\r #/:<>?@[\\\]^|]/,Al=/^[\u0000-\u0020]+/,Rl=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,Pl=/[\t\n\r]/g,Cl=function(e){var t,r,n,o;if("number"==typeof e){for(t=[],r=0;r<4;r++)pl(t,e%256),e=tl(e/256);return il(t,".")}if("object"==typeof e){for(t="",n=function(e){for(var t=null,r=1,n=null,o=0,i=0;i<8;i++)0!==e[i]?(o>r&&(t=n,r=o),n=null,o=0):(null===n&&(n=i),++o);return o>r?n:t}(e),r=0;r<8;r++)o&&0===e[r]||(o&&(o=!1),n===r?(t+=r?":":"::",o=!0):(t+=sl(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},Nl={},xl=qc({},Nl,{" ":1,'"':1,"<":1,">":1,"`":1}),Ll=qc({},xl,{"#":1,"?":1,"{":1,"}":1}),Ul=qc({},Ll,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),kl=function(e,t){var r=Wc(e,0);return r>32&&r<127&&!jc(t,e)?e:encodeURIComponent(e)},Dl={ftp:21,file:null,http:80,https:443,ws:80,wss:443},jl=function(e,t){var r;return 2===e.length&&ol(gl,nl(e,0))&&(":"===(r=nl(e,1))||!t&&"|"===r)},ql=function(e){var t;return e.length>1&&jl(dl(e,0,2))&&(2===e.length||"/"===(t=nl(e,2))||"\\"===t||"?"===t||"#"===t)},Ml=function(e){return"."===e||"%2e"===hl(e)},Bl={},Wl={},Fl={},Vl={},Hl={},$l={},Gl={},zl={},Kl={},Jl={},Yl={},Ql={},Zl={},Xl={},ef={},tf={},rf={},nf={},of={},sf={},af={},uf=function(e,t,r){var n,o,i,s=Vc(e);if(t){if(o=this.parse(s))throw new Xc(o);this.searchParams=null}else{if(void 0!==r&&(n=new uf(r,!0)),o=this.parse(s,null,n))throw new Xc(o);(i=Qc(new Yc)).bindURL(this),this.searchParams=i}};uf.prototype={type:"URL",parse:function(e,t,r){var n,o,i,s,a,u=this,c=t||Bl,l=0,f="",d=!1,h=!1,p=!1;for(e=Vc(e),t||(u.scheme="",u.username="",u.password="",u.host=null,u.port=null,u.path=[],u.query=null,u.fragment=null,u.cannotBeABaseURL=!1,e=cl(e,Al,""),e=cl(e,Rl,"$1")),e=cl(e,Pl,""),n=Mc(e);l<=n.length;){switch(o=n[l],c){case Bl:if(!o||!ol(gl,o)){if(t)return vl;c=Fl;continue}f+=hl(o),c=Wl;break;case Wl:if(o&&(ol(bl,o)||"+"===o||"-"===o||"."===o))f+=hl(o);else{if(":"!==o){if(t)return vl;f="",c=Fl,l=0;continue}if(t&&(u.isSpecial()!==jc(Dl,f)||"file"===f&&(u.includesCredentials()||null!==u.port)||"file"===u.scheme&&!u.host))return;if(u.scheme=f,t)return void(u.isSpecial()&&Dl[u.scheme]===u.port&&(u.port=null));f="","file"===u.scheme?c=Xl:u.isSpecial()&&r&&r.scheme===u.scheme?c=Vl:u.isSpecial()?c=zl:"/"===n[l+1]?(c=Hl,l++):(u.cannotBeABaseURL=!0,ul(u.path,""),c=of)}break;case Fl:if(!r||r.cannotBeABaseURL&&"#"!==o)return vl;if(r.cannotBeABaseURL&&"#"===o){u.scheme=r.scheme,u.path=Bc(r.path),u.query=r.query,u.fragment="",u.cannotBeABaseURL=!0,c=af;break}c="file"===r.scheme?Xl:$l;continue;case Vl:if("/"!==o||"/"!==n[l+1]){c=$l;continue}c=Kl,l++;break;case Hl:if("/"===o){c=Jl;break}c=nf;continue;case $l:if(u.scheme=r.scheme,o===Ku)u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=Bc(r.path),u.query=r.query;else if("/"===o||"\\"===o&&u.isSpecial())c=Gl;else if("?"===o)u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=Bc(r.path),u.query="",c=sf;else{if("#"!==o){u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=Bc(r.path),u.path.length--,c=nf;continue}u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=Bc(r.path),u.query=r.query,u.fragment="",c=af}break;case Gl:if(!u.isSpecial()||"/"!==o&&"\\"!==o){if("/"!==o){u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,c=nf;continue}c=Jl}else c=Kl;break;case zl:if(c=Kl,"/"!==o||"/"!==nl(f,l+1))continue;l++;break;case Kl:if("/"!==o&&"\\"!==o){c=Jl;continue}break;case Jl:if("@"===o){d&&(f="%40"+f),d=!0,i=Mc(f);for(var v=0;v<i.length;v++){var y=i[v];if(":"!==y||p){var m=kl(y,Ul);p?u.password+=m:u.username+=m}else p=!0}f=""}else if(o===Ku||"/"===o||"?"===o||"#"===o||"\\"===o&&u.isSpecial()){if(d&&""===f)return"Invalid authority";l-=Mc(f).length+1,f="",c=Yl}else f+=o;break;case Yl:case Ql:if(t&&"file"===u.scheme){c=tf;continue}if(":"!==o||h){if(o===Ku||"/"===o||"?"===o||"#"===o||"\\"===o&&u.isSpecial()){if(u.isSpecial()&&""===f)return yl;if(t&&""===f&&(u.includesCredentials()||null!==u.port))return;if(s=u.parseHost(f))return s;if(f="",c=rf,t)return;continue}"["===o?h=!0:"]"===o&&(h=!1),f+=o}else{if(""===f)return yl;if(s=u.parseHost(f))return s;if(f="",c=Zl,t===Ql)return}break;case Zl:if(!ol(wl,o)){if(o===Ku||"/"===o||"?"===o||"#"===o||"\\"===o&&u.isSpecial()||t){if(""!==f){var g=el(f,10);if(g>65535)return ml;u.port=u.isSpecial()&&g===Dl[u.scheme]?null:g,f=""}if(t)return;c=rf;continue}return ml}f+=o;break;case Xl:if(u.scheme="file","/"===o||"\\"===o)c=ef;else{if(!r||"file"!==r.scheme){c=nf;continue}switch(o){case Ku:u.host=r.host,u.path=Bc(r.path),u.query=r.query;break;case"?":u.host=r.host,u.path=Bc(r.path),u.query="",c=sf;break;case"#":u.host=r.host,u.path=Bc(r.path),u.query=r.query,u.fragment="",c=af;break;default:ql(il(Bc(n,l),""))||(u.host=r.host,u.path=Bc(r.path),u.shortenPath()),c=nf;continue}}break;case ef:if("/"===o||"\\"===o){c=tf;break}r&&"file"===r.scheme&&!ql(il(Bc(n,l),""))&&(jl(r.path[0],!0)?ul(u.path,r.path[0]):u.host=r.host),c=nf;continue;case tf:if(o===Ku||"/"===o||"\\"===o||"?"===o||"#"===o){if(!t&&jl(f))c=nf;else if(""===f){if(u.host="",t)return;c=rf}else{if(s=u.parseHost(f))return s;if("localhost"===u.host&&(u.host=""),t)return;f="",c=rf}continue}f+=o;break;case rf:if(u.isSpecial()){if(c=nf,"/"!==o&&"\\"!==o)continue}else if(t||"?"!==o)if(t||"#"!==o){if(o!==Ku&&(c=nf,"/"!==o))continue}else u.fragment="",c=af;else u.query="",c=sf;break;case nf:if(o===Ku||"/"===o||"\\"===o&&u.isSpecial()||!t&&("?"===o||"#"===o)){if(".."===(a=hl(a=f))||"%2e."===a||".%2e"===a||"%2e%2e"===a?(u.shortenPath(),"/"===o||"\\"===o&&u.isSpecial()||ul(u.path,"")):Ml(f)?"/"===o||"\\"===o&&u.isSpecial()||ul(u.path,""):("file"===u.scheme&&!u.path.length&&jl(f)&&(u.host&&(u.host=""),f=nl(f,0)+":"),ul(u.path,f)),f="","file"===u.scheme&&(o===Ku||"?"===o||"#"===o))for(;u.path.length>1&&""===u.path[0];)ll(u.path);"?"===o?(u.query="",c=sf):"#"===o&&(u.fragment="",c=af)}else f+=kl(o,Ll);break;case of:"?"===o?(u.query="",c=sf):"#"===o?(u.fragment="",c=af):o!==Ku&&(u.path[0]+=kl(o,Nl));break;case sf:t||"#"!==o?o!==Ku&&("'"===o&&u.isSpecial()?u.query+="%27":u.query+="#"===o?"%23":kl(o,Nl)):(u.fragment="",c=af);break;case af:o!==Ku&&(u.fragment+=kl(o,xl))}l++}},parseHost:function(e){var t,r,n;if("["===nl(e,0)){if("]"!==nl(e,e.length-1))return yl;if(!(t=function(e){var t,r,n,o,i,s,a,u=[0,0,0,0,0,0,0,0],c=0,l=null,f=0,d=function(){return nl(e,f)};if(":"===d()){if(":"!==nl(e,1))return;f+=2,l=++c}for(;d();){if(8===c)return;if(":"!==d()){for(t=r=0;r<4&&ol(Il,d());)t=16*t+el(d(),16),f++,r++;if("."===d()){if(0===r)return;if(f-=r,c>6)return;for(n=0;d();){if(o=null,n>0){if(!("."===d()&&n<4))return;f++}if(!ol(wl,d()))return;for(;ol(wl,d());){if(i=el(d(),10),null===o)o=i;else{if(0===o)return;o=10*o+i}if(o>255)return;f++}u[c]=256*u[c]+o,2!=++n&&4!==n||c++}if(4!==n)return;break}if(":"===d()){if(f++,!d())return}else if(d())return;u[c++]=t}else{if(null!==l)return;f++,l=++c}}if(null!==l)for(s=c-l,c=7;0!==c&&s>0;)a=u[c],u[c--]=u[l+s-1],u[l+--s]=a;else if(8!==c)return;return u}(dl(e,1,-1))))return yl;this.host=t}else if(this.isSpecial()){if(e=Fc(e),ol(Ol,e))return yl;if(null===(t=function(e){var t,r,n,o,i,s,a,u=fl(e,".");if(u.length&&""===u[u.length-1]&&u.length--,(t=u.length)>4)return e;for(r=[],n=0;n<t;n++){if(""===(o=u[n]))return e;if(i=10,o.length>1&&"0"===nl(o,0)&&(i=ol(_l,o)?16:8,o=dl(o,8===i?1:2)),""===o)s=0;else{if(!ol(10===i?El:8===i?Sl:Il,o))return e;s=el(o,i)}ul(r,s)}for(n=0;n<t;n++)if(s=r[n],n===t-1){if(s>=rl(256,5-t))return null}else if(s>255)return null;for(a=al(r),n=0;n<r.length;n++)a+=r[n]*rl(256,3-n);return a}(e)))return yl;this.host=t}else{if(ol(Tl,e))return yl;for(t="",r=Mc(e),n=0;n<r.length;n++)t+=kl(r[n],Nl);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"===this.scheme},includesCredentials:function(){return""!==this.username||""!==this.password},isSpecial:function(){return jc(Dl,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"===this.scheme&&1===t&&jl(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,r=e.username,n=e.password,o=e.host,i=e.port,s=e.path,a=e.query,u=e.fragment,c=t+":";return null!==o?(c+="//",e.includesCredentials()&&(c+=r+(n?":"+n:"")+"@"),c+=Cl(o),null!==i&&(c+=":"+i)):"file"===t&&(c+="//"),c+=e.cannotBeABaseURL?s[0]:s.length?"/"+il(s,"/"):"",null!==a&&(c+="?"+a),null!==u&&(c+="#"+u),c},setHref:function(e){var t=this.parse(e);if(t)throw new Xc(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"===e)try{return new cf(e.path[0]).origin}catch(e){return"null"}return"file"!==e&&this.isSpecial()?e+"://"+Cl(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(Vc(e)+":",Bl)},getUsername:function(){return this.username},setUsername:function(e){var t=Mc(Vc(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<t.length;r++)this.username+=kl(t[r],Ul)}},getPassword:function(){return this.password},setPassword:function(e){var t=Mc(Vc(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<t.length;r++)this.password+=kl(t[r],Ul)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?Cl(e):Cl(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,Yl)},getHostname:function(){var e=this.host;return null===e?"":Cl(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,Ql)},getPort:function(){var e=this.port;return null===e?"":Vc(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""===(e=Vc(e))?this.port=null:this.parse(e,Zl))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+il(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,rf))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""===(e=Vc(e))?this.query=null:("?"===nl(e,0)&&(e=dl(e,1)),this.query="",this.parse(e,sf)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!==(e=Vc(e))?("#"===nl(e,0)&&(e=dl(e,1)),this.fragment="",this.parse(e,af)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var cf=function(e){var t=Dc(this,lf),r=$c(arguments.length,1)>1?arguments[1]:void 0,n=Kc(t,new uf(e,!1,r));Pc||(t.href=n.serialize(),t.origin=n.getOrigin(),t.protocol=n.getProtocol(),t.username=n.getUsername(),t.password=n.getPassword(),t.host=n.getHost(),t.hostname=n.getHostname(),t.port=n.getPort(),t.pathname=n.getPathname(),t.search=n.getSearch(),t.searchParams=n.getSearchParams(),t.hash=n.getHash())},lf=cf.prototype,ff=function(e,t){return{get:function(){return Jc(this)[e]()},set:t&&function(e){return Jc(this)[t](e)},configurable:!0,enumerable:!0}};if(Pc&&(kc(lf,"href",ff("serialize","setHref")),kc(lf,"origin",ff("getOrigin")),kc(lf,"protocol",ff("getProtocol","setProtocol")),kc(lf,"username",ff("getUsername","setUsername")),kc(lf,"password",ff("getPassword","setPassword")),kc(lf,"host",ff("getHost","setHost")),kc(lf,"hostname",ff("getHostname","setHostname")),kc(lf,"port",ff("getPort","setPort")),kc(lf,"pathname",ff("getPathname","setPathname")),kc(lf,"search",ff("getSearch","setSearch")),kc(lf,"searchParams",ff("getSearchParams")),kc(lf,"hash",ff("getHash","setHash"))),Uc(lf,"toJSON",(function(){return Jc(this).serialize()}),{enumerable:!0}),Uc(lf,"toString",(function(){return Jc(this).serialize()}),{enumerable:!0}),Zc){var df=Zc.createObjectURL,hf=Zc.revokeObjectURL;df&&Uc(cf,"createObjectURL",xc(df,Zc)),hf&&Uc(cf,"revokeObjectURL",xc(hf,Zc))}Hc(cf,"URL"),Rc({global:!0,constructor:!0,forced:!Cc,sham:!Pc},{URL:cf});var pf=wn,vf=R,yf=Is,mf=cs,gf=es,bf=Re("URL"),wf=gf&&vf((function(){bf.canParse()})),_f=vf((function(){return 1!==bf.canParse.length}));pf({target:"URL",stat:!0,forced:!wf||_f},{canParse:function(e){var t=yf(arguments.length,1),r=mf(e),n=t<2||void 0===arguments[1]?void 0:mf(arguments[1]);try{return!!new bf(r,n)}catch(e){return!1}}});var Sf=wn,Ef=Is,If=cs,Of=es,Tf=Re("URL");Sf({target:"URL",stat:!0,forced:!Of},{parse:function(e){var t=Ef(arguments.length,1),r=If(e),n=t<2||void 0===arguments[1]?void 0:If(arguments[1]);try{return new Tf(r,n)}catch(e){return null}}});var Af=O(Ee.URL),Rf=function(e){function t(t){var r=e.call(this,t.message)||this;return r.name="PostgrestError",r.details=t.details,r.hint=t.hint,r.code=t.code,r}return n(t,e),t}(Error),Pf=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.select=function(e){var t=!1,r=(null!=e?e:"*").split("").map((function(e){return/\s/.test(e)&&!t?"":('"'===e&&(t=!t),e)})).join("");return this.url.searchParams.set("select",r),this.headers.append("Prefer","return=representation"),this},t.prototype.order=function(e,t){var r=void 0===t?{}:t,n=r.ascending,o=void 0===n||n,i=r.nullsFirst,s=r.foreignTable,a=r.referencedTable,u=void 0===a?s:a,c=u?"".concat(u,".order"):"order",l=this.url.searchParams.get(c);return this.url.searchParams.set(c,"".concat(l?"".concat(l,","):"").concat(e,".").concat(o?"asc":"desc").concat(void 0===i?"":i?".nullsfirst":".nullslast")),this},t.prototype.limit=function(e,t){var r=void 0===t?{}:t,n=r.foreignTable,o=r.referencedTable,i=void 0===o?n:o,s=void 0===i?"limit":"".concat(i,".limit");return this.url.searchParams.set(s,"".concat(e)),this},t.prototype.range=function(e,t,r){var n=void 0===r?{}:r,o=n.foreignTable,i=n.referencedTable,s=void 0===i?o:i,a=void 0===s?"offset":"".concat(s,".offset"),u=void 0===s?"limit":"".concat(s,".limit");return this.url.searchParams.set(a,"".concat(e)),this.url.searchParams.set(u,"".concat(t-e+1)),this},t.prototype.abortSignal=function(e){return this.signal=e,this},t.prototype.single=function(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this},t.prototype.maybeSingle=function(){return"GET"===this.method?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this},t.prototype.csv=function(){return this.headers.set("Accept","text/csv"),this},t.prototype.geojson=function(){return this.headers.set("Accept","application/geo+json"),this},t.prototype.explain=function(e){var t,r=void 0===e?{}:e,n=r.analyze,o=void 0!==n&&n,i=r.verbose,s=void 0!==i&&i,a=r.settings,u=void 0!==a&&a,c=r.buffers,l=void 0!==c&&c,f=r.wal,d=void 0!==f&&f,h=r.format,p=void 0===h?"text":h,v=[o?"analyze":null,s?"verbose":null,u?"settings":null,l?"buffers":null,d?"wal":null].filter(Boolean).join("|"),y=null!==(t=this.headers.get("Accept"))&&void 0!==t?t:"application/json";return this.headers.set("Accept","application/vnd.pgrst.plan+".concat(p,'; for="').concat(y,'"; options=').concat(v,";")),this},t.prototype.rollback=function(){return this.headers.append("Prefer","tx=rollback"),this},t.prototype.returns=function(){return this},t.prototype.maxAffected=function(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer","max-affected=".concat(e)),this},t}(function(){function e(e){var t,r;this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=null!==(t=e.shouldThrowOnError)&&void 0!==t&&t,this.signal=e.signal,this.isMaybeSingle=null!==(r=e.isMaybeSingle)&&void 0!==r&&r,e.fetch?this.fetch=e.fetch:this.fetch=fetch}return e.prototype.throwOnError=function(){return this.shouldThrowOnError=!0,this},e.prototype.setHeader=function(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this},e.prototype.then=function(e,t){var r=this;void 0===this.schema||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),"GET"!==this.method&&"HEAD"!==this.method&&this.headers.set("Content-Type","application/json");var n=(0,this.fetch)(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then((function(e){return i(r,0,void 0,(function(){var t,r,n,o,i,a,u,c,l,f,d,h;return s(this,(function(s){switch(s.label){case 0:return t=null,r=null,n=null,o=e.status,i=e.statusText,e.ok?"HEAD"===this.method?[3,2]:[4,e.text()]:[3,3];case 1:""===(c=s.sent())||(r="text/csv"===this.headers.get("Accept")||this.headers.get("Accept")&&(null===(l=this.headers.get("Accept"))||void 0===l?void 0:l.includes("application/vnd.pgrst.plan+text"))?c:JSON.parse(c)),s.label=2;case 2:return a=null===(f=this.headers.get("Prefer"))||void 0===f?void 0:f.match(/count=(exact|planned|estimated)/),u=null===(d=e.headers.get("content-range"))||void 0===d?void 0:d.split("/"),a&&u&&u.length>1&&(n=parseInt(u[1])),this.isMaybeSingle&&"GET"===this.method&&Array.isArray(r)&&(r.length>1?(t={code:"PGRST116",details:"Results contain ".concat(r.length," rows, application/vnd.pgrst.object+json requires 1 row"),hint:null,message:"JSON object requested, multiple (or no) rows returned"},r=null,n=null,o=406,i="Not Acceptable"):r=1===r.length?r[0]:null),[3,5];case 3:return[4,e.text()];case 4:c=s.sent();try{t=JSON.parse(c),Array.isArray(t)&&404===e.status&&(r=[],t=null,o=200,i="OK")}catch(r){404===e.status&&""===c?(o=204,i="No Content"):t={message:c}}if(t&&this.isMaybeSingle&&(null===(h=null==t?void 0:t.details)||void 0===h?void 0:h.includes("0 rows"))&&(t=null,o=200,i="OK"),t&&this.shouldThrowOnError)throw new Rf(t);s.label=5;case 5:return[2,{error:t,data:r,count:n,status:o,statusText:i}]}}))}))}));return this.shouldThrowOnError||(n=n.catch((function(e){var t,r,n;return{error:{message:"".concat(null!==(t=null==e?void 0:e.name)&&void 0!==t?t:"FetchError",": ").concat(null==e?void 0:e.message),details:"".concat(null!==(r=null==e?void 0:e.stack)&&void 0!==r?r:""),hint:"",code:"".concat(null!==(n=null==e?void 0:e.code)&&void 0!==n?n:"")},data:null,count:null,status:0,statusText:""}}))),n.then(e,t)},e.prototype.returns=function(){return this},e.prototype.overrideTypes=function(){return this},e}()),Cf=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.eq=function(e,t){return this.url.searchParams.append(e,"eq.".concat(t)),this},t.prototype.neq=function(e,t){return this.url.searchParams.append(e,"neq.".concat(t)),this},t.prototype.gt=function(e,t){return this.url.searchParams.append(e,"gt.".concat(t)),this},t.prototype.gte=function(e,t){return this.url.searchParams.append(e,"gte.".concat(t)),this},t.prototype.lt=function(e,t){return this.url.searchParams.append(e,"lt.".concat(t)),this},t.prototype.lte=function(e,t){return this.url.searchParams.append(e,"lte.".concat(t)),this},t.prototype.like=function(e,t){return this.url.searchParams.append(e,"like.".concat(t)),this},t.prototype.likeAllOf=function(e,t){return this.url.searchParams.append(e,"like(all).{".concat(t.join(","),"}")),this},t.prototype.likeAnyOf=function(e,t){return this.url.searchParams.append(e,"like(any).{".concat(t.join(","),"}")),this},t.prototype.ilike=function(e,t){return this.url.searchParams.append(e,"ilike.".concat(t)),this},t.prototype.ilikeAllOf=function(e,t){return this.url.searchParams.append(e,"ilike(all).{".concat(t.join(","),"}")),this},t.prototype.ilikeAnyOf=function(e,t){return this.url.searchParams.append(e,"ilike(any).{".concat(t.join(","),"}")),this},t.prototype.is=function(e,t){return this.url.searchParams.append(e,"is.".concat(t)),this},t.prototype.in=function(e,t){var r=Array.from(new Set(t)).map((function(e){return"string"==typeof e&&new RegExp("[,()]").test(e)?'"'.concat(e,'"'):"".concat(e)})).join(",");return this.url.searchParams.append(e,"in.(".concat(r,")")),this},t.prototype.contains=function(e,t){return"string"==typeof t?this.url.searchParams.append(e,"cs.".concat(t)):Array.isArray(t)?this.url.searchParams.append(e,"cs.{".concat(t.join(","),"}")):this.url.searchParams.append(e,"cs.".concat(JSON.stringify(t))),this},t.prototype.containedBy=function(e,t){return"string"==typeof t?this.url.searchParams.append(e,"cd.".concat(t)):Array.isArray(t)?this.url.searchParams.append(e,"cd.{".concat(t.join(","),"}")):this.url.searchParams.append(e,"cd.".concat(JSON.stringify(t))),this},t.prototype.rangeGt=function(e,t){return this.url.searchParams.append(e,"sr.".concat(t)),this},t.prototype.rangeGte=function(e,t){return this.url.searchParams.append(e,"nxl.".concat(t)),this},t.prototype.rangeLt=function(e,t){return this.url.searchParams.append(e,"sl.".concat(t)),this},t.prototype.rangeLte=function(e,t){return this.url.searchParams.append(e,"nxr.".concat(t)),this},t.prototype.rangeAdjacent=function(e,t){return this.url.searchParams.append(e,"adj.".concat(t)),this},t.prototype.overlaps=function(e,t){return"string"==typeof t?this.url.searchParams.append(e,"ov.".concat(t)):this.url.searchParams.append(e,"ov.{".concat(t.join(","),"}")),this},t.prototype.textSearch=function(e,t,r){var n=void 0===r?{}:r,o=n.config,i=n.type,s="";"plain"===i?s="pl":"phrase"===i?s="ph":"websearch"===i&&(s="w");var a=void 0===o?"":"(".concat(o,")");return this.url.searchParams.append(e,"".concat(s,"fts").concat(a,".").concat(t)),this},t.prototype.match=function(e){var t=this;return Object.entries(e).forEach((function(e){var r=e[0],n=e[1];t.url.searchParams.append(r,"eq.".concat(n))})),this},t.prototype.not=function(e,t,r){return this.url.searchParams.append(e,"not.".concat(t,".").concat(r)),this},t.prototype.or=function(e,t){var r=void 0===t?{}:t,n=r.foreignTable,o=r.referencedTable,i=void 0===o?n:o,s=i?"".concat(i,".or"):"or";return this.url.searchParams.append(s,"(".concat(e,")")),this},t.prototype.filter=function(e,t,r){return this.url.searchParams.append(e,"".concat(t,".").concat(r)),this},t}(Pf),Nf=function(e){function t(t,r){var n=r.headers,o=void 0===n?{}:n,i=r.fetch;return e.call(this,t,{headers:o,schema:void 0,fetch:i})||this}return n(t,e),t}(function(){function e(e,t){var r=t.headers,n=void 0===r?{}:r,o=t.schema,i=t.fetch;this.url=e,this.headers=new Headers(n),this.schema=o,this.fetch=i}return e.prototype.select=function(e,t){var r=void 0===t?{}:t,n=r.head,o=void 0!==n&&n,i=r.count,s=o?"HEAD":"GET",a=!1,u=(null!=e?e:"*").split("").map((function(e){return/\s/.test(e)&&!a?"":('"'===e&&(a=!a),e)})).join("");return this.url.searchParams.set("select",u),i&&this.headers.append("Prefer","count=".concat(i)),new Cf({method:s,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})},e.prototype.insert=function(e,t){var r,n=void 0===t?{}:t,o=n.count,i=n.defaultToNull,s=void 0===i||i;if(o&&this.headers.append("Prefer","count=".concat(o)),s||this.headers.append("Prefer","missing=default"),Array.isArray(e)){var a=e.reduce((function(e,t){return e.concat(Object.keys(t))}),[]);if(a.length>0){var u=Array.from(new Set(a)).map((function(e){return'"'.concat(e,'"')}));this.url.searchParams.set("columns",u.join(","))}}return new Cf({method:"POST",url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:null!==(r=this.fetch)&&void 0!==r?r:fetch})},e.prototype.upsert=function(e,t){var r,n=void 0===t?{}:t,o=n.onConflict,i=n.ignoreDuplicates,s=void 0!==i&&i,a=n.count,u=n.defaultToNull,c=void 0===u||u;if(this.headers.append("Prefer","resolution=".concat(s?"ignore":"merge","-duplicates")),void 0!==o&&this.url.searchParams.set("on_conflict",o),a&&this.headers.append("Prefer","count=".concat(a)),c||this.headers.append("Prefer","missing=default"),Array.isArray(e)){var l=e.reduce((function(e,t){return e.concat(Object.keys(t))}),[]);if(l.length>0){var f=Array.from(new Set(l)).map((function(e){return'"'.concat(e,'"')}));this.url.searchParams.set("columns",f.join(","))}}return new Cf({method:"POST",url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:null!==(r=this.fetch)&&void 0!==r?r:fetch})},e.prototype.update=function(e,t){var r,n=(void 0===t?{}:t).count;return n&&this.headers.append("Prefer","count=".concat(n)),new Cf({method:"PATCH",url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:null!==(r=this.fetch)&&void 0!==r?r:fetch})},e.prototype.delete=function(e){var t,r=(void 0===e?{}:e).count;return r&&this.headers.append("Prefer","count=".concat(r)),new Cf({method:"DELETE",url:this.url,headers:this.headers,schema:this.schema,fetch:null!==(t=this.fetch)&&void 0!==t?t:fetch})},e}()),xf=function(){function e(e,t){var r=void 0===t?{}:t,n=r.headers,o=void 0===n?{}:n,i=r.fetch;this.url=e,this.headers=new Headers(o),this.fetch=i}return e.prototype.from=function(e){var t=new Af("".concat(this.url,"/").concat(e));return new Nf(t,{headers:this.headers,fetch:this.fetch})},e}();function Lf(e,t){if(!e)throw new Error("cloud is required");if(!e.callFunction)throw new Error("cloud.callFunction is required");var r=e.callFunction.bind(e);return e.models=S(r),e.mysql=Uf(e,{envId:null==t?void 0:t.envId}),e}function Uf(e,t){var r=null==t?void 0:t.envId,n=(null==t?void 0:t.mysqlBaseUrl)||kf(e,null==t?void 0:t.envId).mysql,a=null==t?void 0:t.fetch;return function(t){var u=this;return new xf(n,{fetch:a||function(n,a){return i(u,0,void 0,(function(){var i,u,c;return s(this,(function(s){return i=(null==t?void 0:t.instance)||"default",u=(null==t?void 0:t.database)||r,c={},(null==a?void 0:a.headers)instanceof Headers?a.headers.forEach((function(e,t){c[t]=e})):c=(null==a?void 0:a.headers)||{},[2,e.callFunction({name:"httpOverCallFunction",data:{url:n.toString(),method:(null==a?void 0:a.method)||"GET",headers:o(o({},c||{}),{"Content-Type":"application/json","X-Db-Instance":i,"Accept-Profile":u,"Content-Profile":u}),body:null==a?void 0:a.body}}).then((function(e){var t=null==e?void 0:e.result;return{ok:(null==t?void 0:t.statusCode)>=200&&(null==t?void 0:t.statusCode)<300,status:(null==t?void 0:t.statusCode)||200,statusText:(null==t?void 0:t.statusMessage)||"OK",json:function(){return Promise.resolve((null==t?void 0:t.body)||{})},text:function(){return Promise.resolve("string"==typeof(null==t?void 0:t.body)?t.body:JSON.stringify((null==t?void 0:t.body)||{}))},headers:new Headers((null==t?void 0:t.headers)||{})}}))]}))}))}})}}function kf(e,t){var r,n,o,i,s=t||(null===(n=null===(r=null==e?void 0:e.extend)||void 0===r?void 0:r.AI)||void 0===n?void 0:n.env);if("string"==typeof s&&s.trim()||(s=null===(o=null==e?void 0:e.config)||void 0===o?void 0:o.env),"string"==typeof s&&s.trim()||(s=null===(i=null==e?void 0:e.config)||void 0===i?void 0:i.envName),"string"!=typeof s||!s.trim())throw new Error("Generating default gateway base url failed: env not found");return s=s.trim(),{model:"https://".concat(s,".api.tcloudbasegateway.com/v1/model"),sql:"https://".concat(s,".api.tcloudbasegateway.com/v1/sql"),mysql:"https://".concat(s,".api.tcloudbasegateway.com/v1/rdb/rest")}}var Df={init:Lf,generateHTTPClient:g,generateMySQLClient:Uf};e.default=Df,e.generateHTTPClient=g,e.generateMySQLClient=Uf,e.init=Lf,e.initHTTPOverCallFunction=function(e,t){var r=this;if(!e)throw new Error("cloud is required");if(!e.callFunction)throw new Error("cloud.callFunction is required");var n,a=e.callFunction.bind(e);try{var u=(null==t?void 0:t.baseUrl)||kf(e,null==t?void 0:t.envId).model,c=(null==t?void 0:t.sqlBaseUrl)||kf(e,null==t?void 0:t.envId).sql;n=g(a,(function(e){var t=e.url,n=e.body,u=e.method,c=e.headers;return i(r,0,void 0,(function(){var e,r;return s(this,(function(i){switch(i.label){case 0:return[4,a({name:"httpOverCallFunction",data:{url:t,method:null==u?void 0:u.toUpperCase(),headers:o(o({},c||{}),{"Content-Type":"application/json"}),body:n}})];case 1:return e=i.sent(),[2,null===(r=null==e?void 0:e.result)||void 0===r?void 0:r.body]}}))}))}),u,{sqlBaseUrl:c})}catch(e){console.error("init http orm client failed, try call function orm",e),n=S(a)}return e.models=n,e.mysql=Uf(e,{envId:null==t?void 0:t.envId,mysqlBaseUrl:null==t?void 0:t.mysqlBaseUrl}),e},Object.defineProperty(e,"__esModule",{value:!0})}(t)},5993:function(e,t,r){"use strict";function n(){}function o(e){return"object"==typeof e&&null!==e||"function"==typeof e}r.d(t,{GJ:function(){return rn},Pz:function(){return Lr}});const i=n;function s(e,t){try{Object.defineProperty(e,"name",{value:t,configurable:!0})}catch(e){}}const a=Promise,u=Promise.resolve.bind(a),c=Promise.prototype.then,l=Promise.reject.bind(a),f=u;function d(e){return new a(e)}function h(e){return d((t=>t(e)))}function p(e){return l(e)}function v(e,t,r){return c.call(e,t,r)}function y(e,t,r){v(v(e,t,r),void 0,i)}function m(e,t){y(e,t)}function g(e,t){y(e,void 0,t)}function b(e,t,r){return v(e,t,r)}function w(e){v(e,void 0,i)}let _=e=>{if("function"==typeof queueMicrotask)_=queueMicrotask;else{const e=h(void 0);_=t=>v(e,t)}return _(e)};function S(e,t,r){if("function"!=typeof e)throw new TypeError("Argument is not a function");return Function.prototype.apply.call(e,t,r)}function E(e,t,r){try{return h(S(e,t,r))}catch(e){return p(e)}}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(e){const t=this._back;let r=t;16383===t._elements.length&&(r={_elements:[],_next:void 0}),t._elements.push(e),r!==t&&(this._back=r,t._next=r),++this._size}shift(){const e=this._front;let t=e;const r=this._cursor;let n=r+1;const o=e._elements,i=o[r];return 16384===n&&(t=e._next,n=0),--this._size,this._cursor=n,e!==t&&(this._front=t),o[r]=void 0,i}forEach(e){let t=this._cursor,r=this._front,n=r._elements;for(;!(t===n.length&&void 0===r._next||t===n.length&&(r=r._next,n=r._elements,t=0,0===n.length));)e(n[t]),++t}peek(){const e=this._front,t=this._cursor;return e._elements[t]}}const O=Symbol("[[AbortSteps]]"),T=Symbol("[[ErrorSteps]]"),A=Symbol("[[CancelSteps]]"),R=Symbol("[[PullSteps]]"),P=Symbol("[[ReleaseSteps]]");function C(e,t){e._ownerReadableStream=t,t._reader=e,"readable"===t._state?U(e):"closed"===t._state?function(e){U(e),j(e)}(e):k(e,t._storedError)}function N(e,t){return Mr(e._ownerReadableStream,t)}function x(e){const t=e._ownerReadableStream;"readable"===t._state?D(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")):function(e){k(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness"))}(e),t._readableStreamController[P](),t._reader=void 0,e._ownerReadableStream=void 0}function L(e){return new TypeError("Cannot "+e+" a stream using a released reader")}function U(e){e._closedPromise=d(((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r}))}function k(e,t){U(e),D(e,t)}function D(e,t){void 0!==e._closedPromise_reject&&(w(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}function j(e){void 0!==e._closedPromise_resolve&&(e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}const q=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},M=Math.trunc||function(e){return e<0?Math.ceil(e):Math.floor(e)};function B(e,t){if(void 0!==e&&"object"!=typeof(r=e)&&"function"!=typeof r)throw new TypeError(`${t} is not an object.`);var r}function W(e,t){if("function"!=typeof e)throw new TypeError(`${t} is not a function.`)}function F(e,t){if(!function(e){return"object"==typeof e&&null!==e||"function"==typeof e}(e))throw new TypeError(`${t} is not an object.`)}function V(e,t,r){if(void 0===e)throw new TypeError(`Parameter ${t} is required in '${r}'.`)}function H(e,t,r){if(void 0===e)throw new TypeError(`${t} is required in '${r}'.`)}function $(e){return Number(e)}function G(e){return 0===e?0:e}function z(e,t){const r=Number.MAX_SAFE_INTEGER;let n=Number(e);if(n=G(n),!q(n))throw new TypeError(`${t} is not a finite number`);if(n=function(e){return G(M(e))}(n),n<0||n>r)throw new TypeError(`${t} is outside the accepted range of 0 to ${r}, inclusive`);return q(n)&&0!==n?n:0}function K(e,t){if(!jr(e))throw new TypeError(`${t} is not a ReadableStream.`)}function J(e){return new ee(e)}function Y(e,t){e._reader._readRequests.push(t)}function Q(e,t,r){const n=e._reader._readRequests.shift();r?n._closeSteps():n._chunkSteps(t)}function Z(e){return e._reader._readRequests.length}function X(e){const t=e._reader;return void 0!==t&&!!te(t)}class ee{constructor(e){if(V(e,1,"ReadableStreamDefaultReader"),K(e,"First parameter"),qr(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");C(this,e),this._readRequests=new I}get closed(){return te(this)?this._closedPromise:p(oe("closed"))}cancel(e=void 0){return te(this)?void 0===this._ownerReadableStream?p(L("cancel")):N(this,e):p(oe("cancel"))}read(){if(!te(this))return p(oe("read"));if(void 0===this._ownerReadableStream)return p(L("read from"));let e,t;const r=d(((r,n)=>{e=r,t=n}));return re(this,{_chunkSteps:t=>e({value:t,done:!1}),_closeSteps:()=>e({value:void 0,done:!0}),_errorSteps:e=>t(e)}),r}releaseLock(){if(!te(this))throw oe("releaseLock");void 0!==this._ownerReadableStream&&function(e){x(e),ne(e,new TypeError("Reader was released"))}(this)}}function te(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readRequests")&&e instanceof ee}function re(e,t){const r=e._ownerReadableStream;r._disturbed=!0,"closed"===r._state?t._closeSteps():"errored"===r._state?t._errorSteps(r._storedError):r._readableStreamController[R](t)}function ne(e,t){const r=e._readRequests;e._readRequests=new I,r.forEach((e=>{e._errorSteps(t)}))}function oe(e){return new TypeError(`ReadableStreamDefaultReader.prototype.${e} can only be used on a ReadableStreamDefaultReader`)}var ie,se,ae;function ue(e){return e.slice()}function ce(e,t,r,n,o){new Uint8Array(e).set(new Uint8Array(r,n,o),t)}Object.defineProperties(ee.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),s(ee.prototype.cancel,"cancel"),s(ee.prototype.read,"read"),s(ee.prototype.releaseLock,"releaseLock"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(ee.prototype,Symbol.toStringTag,{value:"ReadableStreamDefaultReader",configurable:!0});let le=e=>(le="function"==typeof e.transfer?e=>e.transfer():"function"==typeof structuredClone?e=>structuredClone(e,{transfer:[e]}):e=>e,le(e)),fe=e=>(fe="boolean"==typeof e.detached?e=>e.detached:e=>0===e.byteLength,fe(e));function de(e,t,r){if(e.slice)return e.slice(t,r);const n=r-t,o=new ArrayBuffer(n);return ce(o,0,e,t,n),o}function he(e,t){const r=e[t];if(null!=r){if("function"!=typeof r)throw new TypeError(`${String(t)} is not a function`);return r}}function pe(e){try{const t=e.done,r=e.value;return v(f(r),(e=>({done:t,value:e})))}catch(e){return p(e)}}const ve=null!==(ae=null!==(ie=Symbol.asyncIterator)&&void 0!==ie?ie:null===(se=Symbol.for)||void 0===se?void 0:se.call(Symbol,"Symbol.asyncIterator"))&&void 0!==ae?ae:"@@asyncIterator";function ye(e,t="sync",r){if(void 0===r)if("async"===t){if(void 0===(r=he(e,ve)))return function(e){const t={next(){let t;try{t=me(e)}catch(e){return p(e)}return pe(t)},return(t){let r;try{const n=he(e.iterator,"return");if(void 0===n)return h({done:!0,value:t});r=S(n,e.iterator,[t])}catch(e){return p(e)}return o(r)?pe(r):p(new TypeError("The iterator.return() method must return an object"))}};return{iterator:t,nextMethod:t.next,done:!1}}(ye(e,"sync",he(e,Symbol.iterator)))}else r=he(e,Symbol.iterator);if(void 0===r)throw new TypeError("The object is not iterable");const n=S(r,e,[]);if(!o(n))throw new TypeError("The iterator method must return an object");return{iterator:n,nextMethod:n.next,done:!1}}function me(e){const t=S(e.nextMethod,e.iterator,[]);if(!o(t))throw new TypeError("The iterator.next() method must return an object");return t}class ge{constructor(e,t){this._ongoingPromise=void 0,this._isFinished=!1,this._reader=e,this._preventCancel=t}next(){const e=()=>this._nextSteps();return this._ongoingPromise=this._ongoingPromise?b(this._ongoingPromise,e,e):e(),this._ongoingPromise}return(e){const t=()=>this._returnSteps(e);return this._ongoingPromise?b(this._ongoingPromise,t,t):t()}_nextSteps(){if(this._isFinished)return Promise.resolve({value:void 0,done:!0});const e=this._reader;let t,r;const n=d(((e,n)=>{t=e,r=n}));return re(e,{_chunkSteps:e=>{this._ongoingPromise=void 0,_((()=>t({value:e,done:!1})))},_closeSteps:()=>{this._ongoingPromise=void 0,this._isFinished=!0,x(e),t({value:void 0,done:!0})},_errorSteps:t=>{this._ongoingPromise=void 0,this._isFinished=!0,x(e),r(t)}}),n}_returnSteps(e){if(this._isFinished)return Promise.resolve({value:e,done:!0});this._isFinished=!0;const t=this._reader;if(!this._preventCancel){const r=N(t,e);return x(t),b(r,(()=>({value:e,done:!0})))}return x(t),h({value:e,done:!0})}}const be={next(){return we(this)?this._asyncIteratorImpl.next():p(_e("next"))},return(e){return we(this)?this._asyncIteratorImpl.return(e):p(_e("return"))},[ve](){return this}};function we(e){if(!o(e))return!1;if(!Object.prototype.hasOwnProperty.call(e,"_asyncIteratorImpl"))return!1;try{return e._asyncIteratorImpl instanceof ge}catch(e){return!1}}function _e(e){return new TypeError(`ReadableStreamAsyncIterator.${e} can only be used on a ReadableSteamAsyncIterator`)}Object.defineProperty(be,ve,{enumerable:!1});const Se=Number.isNaN||function(e){return e!=e};function Ee(e){const t=de(e.buffer,e.byteOffset,e.byteOffset+e.byteLength);return new Uint8Array(t)}function Ie(e){const t=e._queue.shift();return e._queueTotalSize-=t.size,e._queueTotalSize<0&&(e._queueTotalSize=0),t.value}function Oe(e,t,r){if("number"!=typeof(n=r)||Se(n)||n<0||r===1/0)throw new RangeError("Size must be a finite, non-NaN, non-negative number.");var n;e._queue.push({value:t,size:r}),e._queueTotalSize+=r}function Te(e){e._queue=new I,e._queueTotalSize=0}function Ae(e){return e===DataView}class Re{constructor(){throw new TypeError("Illegal constructor")}get view(){if(!Ne(this))throw rt("view");return this._view}respond(e){if(!Ne(this))throw rt("respond");if(V(e,1,"respond"),e=z(e,"First parameter"),void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");if(fe(this._view.buffer))throw new TypeError("The BYOB request's buffer has been detached and so cannot be used as a response");Xe(this._associatedReadableByteStreamController,e)}respondWithNewView(e){if(!Ne(this))throw rt("respondWithNewView");if(V(e,1,"respondWithNewView"),!ArrayBuffer.isView(e))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(fe(e.buffer))throw new TypeError("The given view's buffer has been detached and so cannot be used as a response");et(this._associatedReadableByteStreamController,e)}}Object.defineProperties(Re.prototype,{respond:{enumerable:!0},respondWithNewView:{enumerable:!0},view:{enumerable:!0}}),s(Re.prototype.respond,"respond"),s(Re.prototype.respondWithNewView,"respondWithNewView"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Re.prototype,Symbol.toStringTag,{value:"ReadableStreamBYOBRequest",configurable:!0});class Pe{constructor(){throw new TypeError("Illegal constructor")}get byobRequest(){if(!Ce(this))throw nt("byobRequest");return Qe(this)}get desiredSize(){if(!Ce(this))throw nt("desiredSize");return Ze(this)}close(){if(!Ce(this))throw nt("close");if(this._closeRequested)throw new TypeError("The stream has already been closed; do not close it again!");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 closed`);ze(this)}enqueue(e){if(!Ce(this))throw nt("enqueue");if(V(e,1,"enqueue"),!ArrayBuffer.isView(e))throw new TypeError("chunk must be an array buffer view");if(0===e.byteLength)throw new TypeError("chunk must have non-zero byteLength");if(0===e.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 t=this._controlledReadableByteStream._state;if("readable"!==t)throw new TypeError(`The stream (in ${t} state) is not in the readable state and cannot be enqueued to`);Ke(this,e)}error(e=void 0){if(!Ce(this))throw nt("error");Je(this,e)}[A](e){Le(this),Te(this);const t=this._cancelAlgorithm(e);return Ge(this),t}[R](e){const t=this._controlledReadableByteStream;if(this._queueTotalSize>0)return void Ye(this,e);const r=this._autoAllocateChunkSize;if(void 0!==r){let n;try{n=new ArrayBuffer(r)}catch(t){return void e._errorSteps(t)}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(t,e),xe(this)}[P](){if(this._pendingPullIntos.length>0){const e=this._pendingPullIntos.peek();e.readerType="none",this._pendingPullIntos=new I,this._pendingPullIntos.push(e)}}}function Ce(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableByteStream")&&e instanceof Pe}function Ne(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_associatedReadableByteStreamController")&&e instanceof Re}function xe(e){const t=function(e){const t=e._controlledReadableByteStream;return"readable"===t._state&&(!e._closeRequested&&(!!e._started&&(!!(X(t)&&Z(t)>0)||(!!(ut(t)&&at(t)>0)||Ze(e)>0))))}(e);t&&(e._pulling?e._pullAgain=!0:(e._pulling=!0,y(e._pullAlgorithm(),(()=>(e._pulling=!1,e._pullAgain&&(e._pullAgain=!1,xe(e)),null)),(t=>(Je(e,t),null)))))}function Le(e){Fe(e),e._pendingPullIntos=new I}function Ue(e,t){let r=!1;"closed"===e._state&&(r=!0);const n=ke(t);"default"===t.readerType?Q(e,n,r):function(e,t,r){const n=e._reader._readIntoRequests.shift();r?n._closeSteps(t):n._chunkSteps(t)}(e,n,r)}function ke(e){const t=e.bytesFilled,r=e.elementSize;return new e.viewConstructor(e.buffer,e.byteOffset,t/r)}function De(e,t,r,n){e._queue.push({buffer:t,byteOffset:r,byteLength:n}),e._queueTotalSize+=n}function je(e,t,r,n){let o;try{o=de(t,r,r+n)}catch(t){throw Je(e,t),t}De(e,o,0,n)}function qe(e,t){t.bytesFilled>0&&je(e,t.buffer,t.byteOffset,t.bytesFilled),$e(e)}function Me(e,t){const r=Math.min(e._queueTotalSize,t.byteLength-t.bytesFilled),n=t.bytesFilled+r;let o=r,i=!1;const s=n-n%t.elementSize;s>=t.minimumFill&&(o=s-t.bytesFilled,i=!0);const a=e._queue;for(;o>0;){const r=a.peek(),n=Math.min(o,r.byteLength),i=t.byteOffset+t.bytesFilled;ce(t.buffer,i,r.buffer,r.byteOffset,n),r.byteLength===n?a.shift():(r.byteOffset+=n,r.byteLength-=n),e._queueTotalSize-=n,Be(0,n,t),o-=n}return i}function Be(e,t,r){r.bytesFilled+=t}function We(e){0===e._queueTotalSize&&e._closeRequested?(Ge(e),Br(e._controlledReadableByteStream)):xe(e)}function Fe(e){null!==e._byobRequest&&(e._byobRequest._associatedReadableByteStreamController=void 0,e._byobRequest._view=null,e._byobRequest=null)}function Ve(e){for(;e._pendingPullIntos.length>0;){if(0===e._queueTotalSize)return;const t=e._pendingPullIntos.peek();Me(e,t)&&($e(e),Ue(e._controlledReadableByteStream,t))}}function He(e,t){const r=e._pendingPullIntos.peek();Fe(e),"closed"===e._controlledReadableByteStream._state?function(e,t){"none"===t.readerType&&$e(e);const r=e._controlledReadableByteStream;if(ut(r))for(;at(r)>0;)Ue(r,$e(e))}(e,r):function(e,t,r){if(Be(0,t,r),"none"===r.readerType)return qe(e,r),void Ve(e);if(r.bytesFilled<r.minimumFill)return;$e(e);const n=r.bytesFilled%r.elementSize;if(n>0){const t=r.byteOffset+r.bytesFilled;je(e,r.buffer,t-n,n)}r.bytesFilled-=n,Ue(e._controlledReadableByteStream,r),Ve(e)}(e,t,r),xe(e)}function $e(e){return e._pendingPullIntos.shift()}function Ge(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0}function ze(e){const t=e._controlledReadableByteStream;if(!e._closeRequested&&"readable"===t._state)if(e._queueTotalSize>0)e._closeRequested=!0;else{if(e._pendingPullIntos.length>0){const t=e._pendingPullIntos.peek();if(t.bytesFilled%t.elementSize!=0){const t=new TypeError("Insufficient bytes to fill elements in the given buffer");throw Je(e,t),t}}Ge(e),Br(t)}}function Ke(e,t){const r=e._controlledReadableByteStream;if(e._closeRequested||"readable"!==r._state)return;const{buffer:n,byteOffset:o,byteLength:i}=t;if(fe(n))throw new TypeError("chunk's buffer is detached and so cannot be enqueued");const s=le(n);if(e._pendingPullIntos.length>0){const t=e._pendingPullIntos.peek();if(fe(t.buffer))throw new TypeError("The BYOB request's buffer has been detached and so cannot be filled with an enqueued chunk");Fe(e),t.buffer=le(t.buffer),"none"===t.readerType&&qe(e,t)}X(r)?(function(e){const t=e._controlledReadableByteStream._reader;for(;t._readRequests.length>0;){if(0===e._queueTotalSize)return;Ye(e,t._readRequests.shift())}}(e),0===Z(r)?De(e,s,o,i):(e._pendingPullIntos.length>0&&$e(e),Q(r,new Uint8Array(s,o,i),!1))):ut(r)?(De(e,s,o,i),Ve(e)):De(e,s,o,i),xe(e)}function Je(e,t){const r=e._controlledReadableByteStream;"readable"===r._state&&(Le(e),Te(e),Ge(e),Wr(r,t))}function Ye(e,t){const r=e._queue.shift();e._queueTotalSize-=r.byteLength,We(e);const n=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);t._chunkSteps(n)}function Qe(e){if(null===e._byobRequest&&e._pendingPullIntos.length>0){const t=e._pendingPullIntos.peek(),r=new Uint8Array(t.buffer,t.byteOffset+t.bytesFilled,t.byteLength-t.bytesFilled),n=Object.create(Re.prototype);!function(e,t,r){e._associatedReadableByteStreamController=t,e._view=r}(n,e,r),e._byobRequest=n}return e._byobRequest}function Ze(e){const t=e._controlledReadableByteStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function Xe(e,t){const r=e._pendingPullIntos.peek();if("closed"===e._controlledReadableByteStream._state){if(0!==t)throw new TypeError("bytesWritten must be 0 when calling respond() on a closed stream")}else{if(0===t)throw new TypeError("bytesWritten must be greater than 0 when calling respond() on a readable stream");if(r.bytesFilled+t>r.byteLength)throw new RangeError("bytesWritten out of range")}r.buffer=le(r.buffer),He(e,t)}function et(e,t){const r=e._pendingPullIntos.peek();if("closed"===e._controlledReadableByteStream._state){if(0!==t.byteLength)throw new TypeError("The view's length must be 0 when calling respondWithNewView() on a closed stream")}else if(0===t.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!==t.byteOffset)throw new RangeError("The region specified by view does not match byobRequest");if(r.bufferByteLength!==t.buffer.byteLength)throw new RangeError("The buffer of view has different capacity than byobRequest");if(r.bytesFilled+t.byteLength>r.byteLength)throw new RangeError("The region specified by view is larger than byobRequest");const n=t.byteLength;r.buffer=le(t.buffer),He(e,n)}function tt(e,t,r,n,o,i,s){t._controlledReadableByteStream=e,t._pullAgain=!1,t._pulling=!1,t._byobRequest=null,t._queue=t._queueTotalSize=void 0,Te(t),t._closeRequested=!1,t._started=!1,t._strategyHWM=i,t._pullAlgorithm=n,t._cancelAlgorithm=o,t._autoAllocateChunkSize=s,t._pendingPullIntos=new I,e._readableStreamController=t,y(h(r()),(()=>(t._started=!0,xe(t),null)),(e=>(Je(t,e),null)))}function rt(e){return new TypeError(`ReadableStreamBYOBRequest.prototype.${e} can only be used on a ReadableStreamBYOBRequest`)}function nt(e){return new TypeError(`ReadableByteStreamController.prototype.${e} can only be used on a ReadableByteStreamController`)}function ot(e,t){if("byob"!=(e=`${e}`))throw new TypeError(`${t} '${e}' is not a valid enumeration value for ReadableStreamReaderMode`);return e}function it(e){return new ct(e)}function st(e,t){e._reader._readIntoRequests.push(t)}function at(e){return e._reader._readIntoRequests.length}function ut(e){const t=e._reader;return void 0!==t&&!!lt(t)}Object.defineProperties(Pe.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},byobRequest:{enumerable:!0},desiredSize:{enumerable:!0}}),s(Pe.prototype.close,"close"),s(Pe.prototype.enqueue,"enqueue"),s(Pe.prototype.error,"error"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Pe.prototype,Symbol.toStringTag,{value:"ReadableByteStreamController",configurable:!0});class ct{constructor(e){if(V(e,1,"ReadableStreamBYOBReader"),K(e,"First parameter"),qr(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");if(!Ce(e._readableStreamController))throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");C(this,e),this._readIntoRequests=new I}get closed(){return lt(this)?this._closedPromise:p(ht("closed"))}cancel(e=void 0){return lt(this)?void 0===this._ownerReadableStream?p(L("cancel")):N(this,e):p(ht("cancel"))}read(e,t={}){if(!lt(this))return p(ht("read"));if(!ArrayBuffer.isView(e))return p(new TypeError("view must be an array buffer view"));if(0===e.byteLength)return p(new TypeError("view must have non-zero byteLength"));if(0===e.buffer.byteLength)return p(new TypeError("view's buffer must have non-zero byteLength"));if(fe(e.buffer))return p(new TypeError("view's buffer has been detached"));let r;try{r=function(e,t){var r;return B(e,t),{min:z(null!==(r=null==e?void 0:e.min)&&void 0!==r?r:1,`${t} has member 'min' that`)}}(t,"options")}catch(e){return p(e)}const n=r.min;if(0===n)return p(new TypeError("options.min must be greater than 0"));if(function(e){return Ae(e.constructor)}(e)){if(n>e.byteLength)return p(new RangeError("options.min must be less than or equal to view's byteLength"))}else if(n>e.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=d(((e,t)=>{o=e,i=t}));return ft(this,e,n,{_chunkSteps:e=>o({value:e,done:!1}),_closeSteps:e=>o({value:e,done:!0}),_errorSteps:e=>i(e)}),s}releaseLock(){if(!lt(this))throw ht("releaseLock");void 0!==this._ownerReadableStream&&function(e){x(e),dt(e,new TypeError("Reader was released"))}(this)}}function lt(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readIntoRequests")&&e instanceof ct}function ft(e,t,r,n){const o=e._ownerReadableStream;o._disturbed=!0,"errored"===o._state?n._errorSteps(o._storedError):function(e,t,r,n){const o=e._controlledReadableByteStream,i=t.constructor,s=function(e){return Ae(e)?1:e.BYTES_PER_ELEMENT}(i),{byteOffset:a,byteLength:u}=t,c=r*s;let l;try{l=le(t.buffer)}catch(e){return void n._errorSteps(e)}const f={buffer:l,bufferByteLength:l.byteLength,byteOffset:a,byteLength:u,bytesFilled:0,minimumFill:c,elementSize:s,viewConstructor:i,readerType:"byob"};if(e._pendingPullIntos.length>0)return e._pendingPullIntos.push(f),void st(o,n);if("closed"!==o._state){if(e._queueTotalSize>0){if(Me(e,f)){const t=ke(f);return We(e),void n._chunkSteps(t)}if(e._closeRequested){const t=new TypeError("Insufficient bytes to fill elements in the given buffer");return Je(e,t),void n._errorSteps(t)}}e._pendingPullIntos.push(f),st(o,n),xe(e)}else{const e=new i(f.buffer,f.byteOffset,0);n._closeSteps(e)}}(o._readableStreamController,t,r,n)}function dt(e,t){const r=e._readIntoRequests;e._readIntoRequests=new I,r.forEach((e=>{e._errorSteps(t)}))}function ht(e){return new TypeError(`ReadableStreamBYOBReader.prototype.${e} can only be used on a ReadableStreamBYOBReader`)}function pt(e,t){const{highWaterMark:r}=e;if(void 0===r)return t;if(Se(r)||r<0)throw new RangeError("Invalid highWaterMark");return r}function vt(e){const{size:t}=e;return t||(()=>1)}function yt(e,t){B(e,t);const r=null==e?void 0:e.highWaterMark,n=null==e?void 0:e.size;return{highWaterMark:void 0===r?void 0:$(r),size:void 0===n?void 0:mt(n,`${t} has member 'size' that`)}}function mt(e,t){return W(e,t),t=>$(e(t))}function gt(e,t,r){return W(e,r),r=>E(e,t,[r])}function bt(e,t,r){return W(e,r),()=>E(e,t,[])}function wt(e,t,r){return W(e,r),r=>S(e,t,[r])}function _t(e,t,r){return W(e,r),(r,n)=>E(e,t,[r,n])}function St(e,t){if(!At(e))throw new TypeError(`${t} is not a WritableStream.`)}Object.defineProperties(ct.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),s(ct.prototype.cancel,"cancel"),s(ct.prototype.read,"read"),s(ct.prototype.releaseLock,"releaseLock"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(ct.prototype,Symbol.toStringTag,{value:"ReadableStreamBYOBReader",configurable:!0});const Et="function"==typeof AbortController;class It{constructor(e={},t={}){void 0===e?e=null:F(e,"First parameter");const r=yt(t,"Second parameter"),n=function(e,t){B(e,t);const r=null==e?void 0:e.abort,n=null==e?void 0:e.close,o=null==e?void 0:e.start,i=null==e?void 0:e.type,s=null==e?void 0:e.write;return{abort:void 0===r?void 0:gt(r,e,`${t} has member 'abort' that`),close:void 0===n?void 0:bt(n,e,`${t} has member 'close' that`),start:void 0===o?void 0:wt(o,e,`${t} has member 'start' that`),write:void 0===s?void 0:_t(s,e,`${t} has member 'write' that`),type:i}}(e,"First parameter");if(Tt(this),void 0!==n.type)throw new RangeError("Invalid type is specified");const o=vt(r);!function(e,t,r,n){const o=Object.create(Ht.prototype);let i,s,a,u;i=void 0!==t.start?()=>t.start(o):()=>{},s=void 0!==t.write?e=>t.write(e,o):()=>h(void 0),a=void 0!==t.close?()=>t.close():()=>h(void 0),u=void 0!==t.abort?e=>t.abort(e):()=>h(void 0),Gt(e,o,i,s,a,u,r,n)}(this,n,pt(r,1),o)}get locked(){if(!At(this))throw Xt("locked");return Rt(this)}abort(e=void 0){return At(this)?Rt(this)?p(new TypeError("Cannot abort a stream that already has a writer")):Pt(this,e):p(Xt("abort"))}close(){return At(this)?Rt(this)?p(new TypeError("Cannot close a stream that already has a writer")):Ut(this)?p(new TypeError("Cannot close an already-closing stream")):Ct(this):p(Xt("close"))}getWriter(){if(!At(this))throw Xt("getWriter");return Ot(this)}}function Ot(e){return new jt(e)}function Tt(e){e._state="writable",e._storedError=void 0,e._writer=void 0,e._writableStreamController=void 0,e._writeRequests=new I,e._inFlightWriteRequest=void 0,e._closeRequest=void 0,e._inFlightCloseRequest=void 0,e._pendingAbortRequest=void 0,e._backpressure=!1}function At(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_writableStreamController")&&e instanceof It}function Rt(e){return void 0!==e._writer}function Pt(e,t){var r;if("closed"===e._state||"errored"===e._state)return h(void 0);e._writableStreamController._abortReason=t,null===(r=e._writableStreamController._abortController)||void 0===r||r.abort(t);const n=e._state;if("closed"===n||"errored"===n)return h(void 0);if(void 0!==e._pendingAbortRequest)return e._pendingAbortRequest._promise;let o=!1;"erroring"===n&&(o=!0,t=void 0);const i=d(((r,n)=>{e._pendingAbortRequest={_promise:void 0,_resolve:r,_reject:n,_reason:t,_wasAlreadyErroring:o}}));return e._pendingAbortRequest._promise=i,o||xt(e,t),i}function Ct(e){const t=e._state;if("closed"===t||"errored"===t)return p(new TypeError(`The stream (in ${t} state) is not in the writable state and cannot be closed`));const r=d(((t,r)=>{const n={_resolve:t,_reject:r};e._closeRequest=n})),n=e._writer;var o;return void 0!==n&&e._backpressure&&"writable"===t&&fr(n),Oe(o=e._writableStreamController,Vt,0),Jt(o),r}function Nt(e,t){"writable"!==e._state?Lt(e):xt(e,t)}function xt(e,t){const r=e._writableStreamController;e._state="erroring",e._storedError=t;const n=e._writer;void 0!==n&&Bt(n,t),!function(e){return void 0!==e._inFlightWriteRequest||void 0!==e._inFlightCloseRequest}(e)&&r._started&&Lt(e)}function Lt(e){e._state="errored",e._writableStreamController[T]();const t=e._storedError;if(e._writeRequests.forEach((e=>{e._reject(t)})),e._writeRequests=new I,void 0===e._pendingAbortRequest)return void kt(e);const r=e._pendingAbortRequest;if(e._pendingAbortRequest=void 0,r._wasAlreadyErroring)return r._reject(t),void kt(e);y(e._writableStreamController[O](r._reason),(()=>(r._resolve(),kt(e),null)),(t=>(r._reject(t),kt(e),null)))}function Ut(e){return void 0!==e._closeRequest||void 0!==e._inFlightCloseRequest}function kt(e){void 0!==e._closeRequest&&(e._closeRequest._reject(e._storedError),e._closeRequest=void 0);const t=e._writer;void 0!==t&&ir(t,e._storedError)}function Dt(e,t){const r=e._writer;void 0!==r&&t!==e._backpressure&&(t?function(e){ar(e)}(r):fr(r)),e._backpressure=t}Object.defineProperties(It.prototype,{abort:{enumerable:!0},close:{enumerable:!0},getWriter:{enumerable:!0},locked:{enumerable:!0}}),s(It.prototype.abort,"abort"),s(It.prototype.close,"close"),s(It.prototype.getWriter,"getWriter"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(It.prototype,Symbol.toStringTag,{value:"WritableStream",configurable:!0});class jt{constructor(e){if(V(e,1,"WritableStreamDefaultWriter"),St(e,"First parameter"),Rt(e))throw new TypeError("This stream has already been locked for exclusive writing by another writer");this._ownerWritableStream=e,e._writer=this;const t=e._state;if("writable"===t)!Ut(e)&&e._backpressure?ar(this):cr(this),nr(this);else if("erroring"===t)ur(this,e._storedError),nr(this);else if("closed"===t)cr(this),nr(this),sr(this);else{const t=e._storedError;ur(this,t),or(this,t)}}get closed(){return qt(this)?this._closedPromise:p(tr("closed"))}get desiredSize(){if(!qt(this))throw tr("desiredSize");if(void 0===this._ownerWritableStream)throw rr("desiredSize");return function(e){const t=e._ownerWritableStream,r=t._state;return"errored"===r||"erroring"===r?null:"closed"===r?0:Kt(t._writableStreamController)}(this)}get ready(){return qt(this)?this._readyPromise:p(tr("ready"))}abort(e=void 0){return qt(this)?void 0===this._ownerWritableStream?p(rr("abort")):function(e,t){return Pt(e._ownerWritableStream,t)}(this,e):p(tr("abort"))}close(){if(!qt(this))return p(tr("close"));const e=this._ownerWritableStream;return void 0===e?p(rr("close")):Ut(e)?p(new TypeError("Cannot close an already-closing stream")):Mt(this)}releaseLock(){if(!qt(this))throw tr("releaseLock");void 0!==this._ownerWritableStream&&Wt(this)}write(e=void 0){return qt(this)?void 0===this._ownerWritableStream?p(rr("write to")):Ft(this,e):p(tr("write"))}}function qt(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_ownerWritableStream")&&e instanceof jt}function Mt(e){return Ct(e._ownerWritableStream)}function Bt(e,t){"pending"===e._readyPromiseState?lr(e,t):function(e,t){ur(e,t)}(e,t)}function Wt(e){const t=e._ownerWritableStream,r=new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");Bt(e,r),function(e,t){"pending"===e._closedPromiseState?ir(e,t):function(e,t){or(e,t)}(e,t)}(e,r),t._writer=void 0,e._ownerWritableStream=void 0}function Ft(e,t){const r=e._ownerWritableStream,n=r._writableStreamController,o=function(e,t){try{return e._strategySizeAlgorithm(t)}catch(t){return Yt(e,t),1}}(n,t);if(r!==e._ownerWritableStream)return p(rr("write to"));const i=r._state;if("errored"===i)return p(r._storedError);if(Ut(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(e){return d(((t,r)=>{const n={_resolve:t,_reject:r};e._writeRequests.push(n)}))}(r);return function(e,t,r){try{Oe(e,t,r)}catch(t){return void Yt(e,t)}const n=e._controlledWritableStream;Ut(n)||"writable"!==n._state||Dt(n,Qt(e)),Jt(e)}(n,t,o),s}Object.defineProperties(jt.prototype,{abort:{enumerable:!0},close:{enumerable:!0},releaseLock:{enumerable:!0},write:{enumerable:!0},closed:{enumerable:!0},desiredSize:{enumerable:!0},ready:{enumerable:!0}}),s(jt.prototype.abort,"abort"),s(jt.prototype.close,"close"),s(jt.prototype.releaseLock,"releaseLock"),s(jt.prototype.write,"write"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(jt.prototype,Symbol.toStringTag,{value:"WritableStreamDefaultWriter",configurable:!0});const Vt={};class Ht{constructor(){throw new TypeError("Illegal constructor")}get abortReason(){if(!$t(this))throw er("abortReason");return this._abortReason}get signal(){if(!$t(this))throw er("signal");if(void 0===this._abortController)throw new TypeError("WritableStreamDefaultController.prototype.signal is not supported");return this._abortController.signal}error(e=void 0){if(!$t(this))throw er("error");"writable"===this._controlledWritableStream._state&&Zt(this,e)}[O](e){const t=this._abortAlgorithm(e);return zt(this),t}[T](){Te(this)}}function $t(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledWritableStream")&&e instanceof Ht}function Gt(e,t,r,n,o,i,s,a){t._controlledWritableStream=e,e._writableStreamController=t,t._queue=void 0,t._queueTotalSize=void 0,Te(t),t._abortReason=void 0,t._abortController=function(){if(Et)return new AbortController}(),t._started=!1,t._strategySizeAlgorithm=a,t._strategyHWM=s,t._writeAlgorithm=n,t._closeAlgorithm=o,t._abortAlgorithm=i;const u=Qt(t);Dt(e,u),y(h(r()),(()=>(t._started=!0,Jt(t),null)),(r=>(t._started=!0,Nt(e,r),null)))}function zt(e){e._writeAlgorithm=void 0,e._closeAlgorithm=void 0,e._abortAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function Kt(e){return e._strategyHWM-e._queueTotalSize}function Jt(e){const t=e._controlledWritableStream;if(!e._started)return;if(void 0!==t._inFlightWriteRequest)return;if("erroring"===t._state)return void Lt(t);if(0===e._queue.length)return;const r=e._queue.peek().value;r===Vt?function(e){const t=e._controlledWritableStream;(function(e){e._inFlightCloseRequest=e._closeRequest,e._closeRequest=void 0})(t),Ie(e);const r=e._closeAlgorithm();zt(e),y(r,(()=>(function(e){e._inFlightCloseRequest._resolve(void 0),e._inFlightCloseRequest=void 0,"erroring"===e._state&&(e._storedError=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._resolve(),e._pendingAbortRequest=void 0)),e._state="closed";const t=e._writer;void 0!==t&&sr(t)}(t),null)),(e=>(function(e,t){e._inFlightCloseRequest._reject(t),e._inFlightCloseRequest=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._reject(t),e._pendingAbortRequest=void 0),Nt(e,t)}(t,e),null)))}(e):function(e,t){const r=e._controlledWritableStream;!function(e){e._inFlightWriteRequest=e._writeRequests.shift()}(r),y(e._writeAlgorithm(t),(()=>{!function(e){e._inFlightWriteRequest._resolve(void 0),e._inFlightWriteRequest=void 0}(r);const t=r._state;if(Ie(e),!Ut(r)&&"writable"===t){const t=Qt(e);Dt(r,t)}return Jt(e),null}),(t=>("writable"===r._state&&zt(e),function(e,t){e._inFlightWriteRequest._reject(t),e._inFlightWriteRequest=void 0,Nt(e,t)}(r,t),null)))}(e,r)}function Yt(e,t){"writable"===e._controlledWritableStream._state&&Zt(e,t)}function Qt(e){return Kt(e)<=0}function Zt(e,t){const r=e._controlledWritableStream;zt(e),xt(r,t)}function Xt(e){return new TypeError(`WritableStream.prototype.${e} can only be used on a WritableStream`)}function er(e){return new TypeError(`WritableStreamDefaultController.prototype.${e} can only be used on a WritableStreamDefaultController`)}function tr(e){return new TypeError(`WritableStreamDefaultWriter.prototype.${e} can only be used on a WritableStreamDefaultWriter`)}function rr(e){return new TypeError("Cannot "+e+" a stream using a released writer")}function nr(e){e._closedPromise=d(((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r,e._closedPromiseState="pending"}))}function or(e,t){nr(e),ir(e,t)}function ir(e,t){void 0!==e._closedPromise_reject&&(w(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="rejected")}function sr(e){void 0!==e._closedPromise_resolve&&(e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="resolved")}function ar(e){e._readyPromise=d(((t,r)=>{e._readyPromise_resolve=t,e._readyPromise_reject=r})),e._readyPromiseState="pending"}function ur(e,t){ar(e),lr(e,t)}function cr(e){ar(e),fr(e)}function lr(e,t){void 0!==e._readyPromise_reject&&(w(e._readyPromise),e._readyPromise_reject(t),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="rejected")}function fr(e){void 0!==e._readyPromise_resolve&&(e._readyPromise_resolve(void 0),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="fulfilled")}Object.defineProperties(Ht.prototype,{abortReason:{enumerable:!0},signal:{enumerable:!0},error:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Ht.prototype,Symbol.toStringTag,{value:"WritableStreamDefaultController",configurable:!0});const dr="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof global?global:void 0,hr=function(){const e=null==dr?void 0:dr.DOMException;return function(e){if("function"!=typeof e&&"object"!=typeof e)return!1;if("DOMException"!==e.name)return!1;try{return new e,!0}catch(e){return!1}}(e)?e:void 0}()||function(){const e=function(e,t){this.message=e||"",this.name=t||"Error",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)};return s(e,"DOMException"),e.prototype=Object.create(Error.prototype),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,configurable:!0}),e}();function pr(e,t,r,o,i,s){const a=J(e),u=Ot(t);e._disturbed=!0;let c=!1,l=h(void 0);return d(((f,b)=>{let _;if(void 0!==s){if(_=()=>{const r=void 0!==s.reason?s.reason:new hr("Aborted","AbortError"),n=[];o||n.push((()=>"writable"===t._state?Pt(t,r):h(void 0))),i||n.push((()=>"readable"===e._state?Mr(e,r):h(void 0))),A((()=>Promise.all(n.map((e=>e())))),!0,r)},s.aborted)return void _();s.addEventListener("abort",_)}var S,E,I;if(T(e,a._closedPromise,(e=>(o?R(!0,e):A((()=>Pt(t,e)),!0,e),null))),T(t,u._closedPromise,(t=>(i?R(!0,t):A((()=>Mr(e,t)),!0,t),null))),S=e,E=a._closedPromise,I=()=>(r?R():A((()=>function(e){const t=e._ownerWritableStream,r=t._state;return Ut(t)||"closed"===r?h(void 0):"errored"===r?p(t._storedError):Mt(e)}(u))),null),"closed"===S._state?I():m(E,I),Ut(t)||"closed"===t._state){const t=new TypeError("the destination writable stream closed before all data could be piped to it");i?R(!0,t):A((()=>Mr(e,t)),!0,t)}function O(){const e=l;return v(l,(()=>e!==l?O():void 0))}function T(e,t,r){"errored"===e._state?r(e._storedError):g(t,r)}function A(e,r,n){function o(){return y(e(),(()=>P(r,n)),(e=>P(!0,e))),null}c||(c=!0,"writable"!==t._state||Ut(t)?o():m(O(),o))}function R(e,r){c||(c=!0,"writable"!==t._state||Ut(t)?P(e,r):m(O(),(()=>P(e,r))))}function P(e,t){return Wt(u),x(a),void 0!==s&&s.removeEventListener("abort",_),e?b(t):f(void 0),null}w(d(((e,t)=>{!function r(o){o?e():v(c?h(!0):v(u._readyPromise,(()=>d(((e,t)=>{re(a,{_chunkSteps:t=>{l=v(Ft(u,t),void 0,n),e(!1)},_closeSteps:()=>e(!0),_errorSteps:t})})))),r,t)}(!1)})))}))}class vr{constructor(){throw new TypeError("Illegal constructor")}get desiredSize(){if(!yr(this))throw Tr("desiredSize");return Er(this)}close(){if(!yr(this))throw Tr("close");if(!Ir(this))throw new TypeError("The stream is not in a state that permits close");wr(this)}enqueue(e=void 0){if(!yr(this))throw Tr("enqueue");if(!Ir(this))throw new TypeError("The stream is not in a state that permits enqueue");return _r(this,e)}error(e=void 0){if(!yr(this))throw Tr("error");Sr(this,e)}[A](e){Te(this);const t=this._cancelAlgorithm(e);return br(this),t}[R](e){const t=this._controlledReadableStream;if(this._queue.length>0){const r=Ie(this);this._closeRequested&&0===this._queue.length?(br(this),Br(t)):mr(this),e._chunkSteps(r)}else Y(t,e),mr(this)}[P](){}}function yr(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableStream")&&e instanceof vr}function mr(e){gr(e)&&(e._pulling?e._pullAgain=!0:(e._pulling=!0,y(e._pullAlgorithm(),(()=>(e._pulling=!1,e._pullAgain&&(e._pullAgain=!1,mr(e)),null)),(t=>(Sr(e,t),null)))))}function gr(e){const t=e._controlledReadableStream;return!!Ir(e)&&!!e._started&&(!!(qr(t)&&Z(t)>0)||Er(e)>0)}function br(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function wr(e){if(!Ir(e))return;const t=e._controlledReadableStream;e._closeRequested=!0,0===e._queue.length&&(br(e),Br(t))}function _r(e,t){if(!Ir(e))return;const r=e._controlledReadableStream;if(qr(r)&&Z(r)>0)Q(r,t,!1);else{let r;try{r=e._strategySizeAlgorithm(t)}catch(t){throw Sr(e,t),t}try{Oe(e,t,r)}catch(t){throw Sr(e,t),t}}mr(e)}function Sr(e,t){const r=e._controlledReadableStream;"readable"===r._state&&(Te(e),br(e),Wr(r,t))}function Er(e){const t=e._controlledReadableStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function Ir(e){const t=e._controlledReadableStream._state;return!e._closeRequested&&"readable"===t}function Or(e,t,r,n,o,i,s){t._controlledReadableStream=e,t._queue=void 0,t._queueTotalSize=void 0,Te(t),t._started=!1,t._closeRequested=!1,t._pullAgain=!1,t._pulling=!1,t._strategySizeAlgorithm=s,t._strategyHWM=i,t._pullAlgorithm=n,t._cancelAlgorithm=o,e._readableStreamController=t,y(h(r()),(()=>(t._started=!0,mr(t),null)),(e=>(Sr(t,e),null)))}function Tr(e){return new TypeError(`ReadableStreamDefaultController.prototype.${e} can only be used on a ReadableStreamDefaultController`)}function Ar(e){return o(t=e)&&void 0!==t.getReader?function(e){let t;return t=Ur(n,(function(){let r;try{r=e.read()}catch(r){return p(r)}return b(r,(e=>{if(!o(e))throw new TypeError("The promise returned by the reader.read() method must fulfill with an object");if(e.done)wr(t._readableStreamController);else{const r=e.value;_r(t._readableStreamController,r)}}))}),(function(t){try{return h(e.cancel(t))}catch(t){return p(t)}}),0),t}(e.getReader()):function(e){let t;const r=ye(e,"async");return t=Ur(n,(function(){let e;try{e=me(r)}catch(e){return p(e)}return b(h(e),(e=>{if(!o(e))throw new TypeError("The promise returned by the iterator.next() method must fulfill with an object");if(e.done)wr(t._readableStreamController);else{const r=e.value;_r(t._readableStreamController,r)}}))}),(function(e){const t=r.iterator;let n;try{n=he(t,"return")}catch(e){return p(e)}return void 0===n?h(void 0):b(E(n,t,[e]),(e=>{if(!o(e))throw new TypeError("The promise returned by the iterator.return() method must fulfill with an object")}))}),0),t}(e);var t}function Rr(e,t,r){return W(e,r),r=>E(e,t,[r])}function Pr(e,t,r){return W(e,r),r=>E(e,t,[r])}function Cr(e,t,r){return W(e,r),r=>S(e,t,[r])}function Nr(e,t){if("bytes"!=(e=`${e}`))throw new TypeError(`${t} '${e}' is not a valid enumeration value for ReadableStreamType`);return e}function xr(e,t){B(e,t);const r=null==e?void 0:e.preventAbort,n=null==e?void 0:e.preventCancel,o=null==e?void 0:e.preventClose,i=null==e?void 0:e.signal;return void 0!==i&&function(e,t){if(!function(e){if("object"!=typeof e||null===e)return!1;try{return"boolean"==typeof e.aborted}catch(e){return!1}}(e))throw new TypeError(`${t} is not an AbortSignal.`)}(i,`${t} has member 'signal' that`),{preventAbort:Boolean(r),preventCancel:Boolean(n),preventClose:Boolean(o),signal:i}}Object.defineProperties(vr.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},desiredSize:{enumerable:!0}}),s(vr.prototype.close,"close"),s(vr.prototype.enqueue,"enqueue"),s(vr.prototype.error,"error"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(vr.prototype,Symbol.toStringTag,{value:"ReadableStreamDefaultController",configurable:!0});class Lr{constructor(e={},t={}){void 0===e?e=null:F(e,"First parameter");const r=yt(t,"Second parameter"),n=function(e,t){B(e,t);const r=e,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:z(n,`${t} has member 'autoAllocateChunkSize' that`),cancel:void 0===o?void 0:Rr(o,r,`${t} has member 'cancel' that`),pull:void 0===i?void 0:Pr(i,r,`${t} has member 'pull' that`),start:void 0===s?void 0:Cr(s,r,`${t} has member 'start' that`),type:void 0===a?void 0:Nr(a,`${t} has member 'type' that`)}}(e,"First parameter");if(Dr(this),"bytes"===n.type){if(void 0!==r.size)throw new RangeError("The strategy for a byte stream cannot have a size function");!function(e,t,r){const n=Object.create(Pe.prototype);let o,i,s;o=void 0!==t.start?()=>t.start(n):()=>{},i=void 0!==t.pull?()=>t.pull(n):()=>h(void 0),s=void 0!==t.cancel?e=>t.cancel(e):()=>h(void 0);const a=t.autoAllocateChunkSize;if(0===a)throw new TypeError("autoAllocateChunkSize must be greater than 0");tt(e,n,o,i,s,r,a)}(this,n,pt(r,0))}else{const e=vt(r);!function(e,t,r,n){const o=Object.create(vr.prototype);let i,s,a;i=void 0!==t.start?()=>t.start(o):()=>{},s=void 0!==t.pull?()=>t.pull(o):()=>h(void 0),a=void 0!==t.cancel?e=>t.cancel(e):()=>h(void 0),Or(e,o,i,s,a,r,n)}(this,n,pt(r,1),e)}}get locked(){if(!jr(this))throw Fr("locked");return qr(this)}cancel(e=void 0){return jr(this)?qr(this)?p(new TypeError("Cannot cancel a stream that already has a reader")):Mr(this,e):p(Fr("cancel"))}getReader(e=void 0){if(!jr(this))throw Fr("getReader");return void 0===function(e,t){B(e,t);const r=null==e?void 0:e.mode;return{mode:void 0===r?void 0:ot(r,`${t} has member 'mode' that`)}}(e,"First parameter").mode?J(this):it(this)}pipeThrough(e,t={}){if(!jr(this))throw Fr("pipeThrough");V(e,1,"pipeThrough");const r=function(e,t){B(e,t);const r=null==e?void 0:e.readable;H(r,"readable","ReadableWritablePair"),K(r,`${t} has member 'readable' that`);const n=null==e?void 0:e.writable;return H(n,"writable","ReadableWritablePair"),St(n,`${t} has member 'writable' that`),{readable:r,writable:n}}(e,"First parameter"),n=xr(t,"Second parameter");if(qr(this))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream");if(Rt(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(e,t={}){if(!jr(this))return p(Fr("pipeTo"));if(void 0===e)return p("Parameter 1 is required in 'pipeTo'.");if(!At(e))return p(new TypeError("ReadableStream.prototype.pipeTo's first argument must be a WritableStream"));let r;try{r=xr(t,"Second parameter")}catch(e){return p(e)}return qr(this)?p(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream")):Rt(e)?p(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream")):pr(this,e,r.preventClose,r.preventAbort,r.preventCancel,r.signal)}tee(){if(!jr(this))throw Fr("tee");return ue(function(e){return Ce(e._readableStreamController)?function(e){let t,r,n,o,i,s=J(e),a=!1,u=!1,c=!1,l=!1,f=!1;const p=d((e=>{i=e}));function v(e){g(e._closedPromise,(t=>(e!==s||(Je(n._readableStreamController,t),Je(o._readableStreamController,t),l&&f||i(void 0)),null)))}function y(){lt(s)&&(x(s),s=J(e),v(s)),re(s,{_chunkSteps:t=>{_((()=>{u=!1,c=!1;const r=t;let s=t;if(!l&&!f)try{s=Ee(t)}catch(t){return Je(n._readableStreamController,t),Je(o._readableStreamController,t),void i(Mr(e,t))}l||Ke(n._readableStreamController,r),f||Ke(o._readableStreamController,s),a=!1,u?b():c&&w()}))},_closeSteps:()=>{a=!1,l||ze(n._readableStreamController),f||ze(o._readableStreamController),n._readableStreamController._pendingPullIntos.length>0&&Xe(n._readableStreamController,0),o._readableStreamController._pendingPullIntos.length>0&&Xe(o._readableStreamController,0),l&&f||i(void 0)},_errorSteps:()=>{a=!1}})}function m(t,r){te(s)&&(x(s),s=it(e),v(s));const d=r?o:n,h=r?n:o;ft(s,t,1,{_chunkSteps:t=>{_((()=>{u=!1,c=!1;const n=r?f:l;if(r?l:f)n||et(d._readableStreamController,t);else{let r;try{r=Ee(t)}catch(t){return Je(d._readableStreamController,t),Je(h._readableStreamController,t),void i(Mr(e,t))}n||et(d._readableStreamController,t),Ke(h._readableStreamController,r)}a=!1,u?b():c&&w()}))},_closeSteps:e=>{a=!1;const t=r?f:l,n=r?l:f;t||ze(d._readableStreamController),n||ze(h._readableStreamController),void 0!==e&&(t||et(d._readableStreamController,e),!n&&h._readableStreamController._pendingPullIntos.length>0&&Xe(h._readableStreamController,0)),t&&n||i(void 0)},_errorSteps:()=>{a=!1}})}function b(){if(a)return u=!0,h(void 0);a=!0;const e=Qe(n._readableStreamController);return null===e?y():m(e._view,!1),h(void 0)}function w(){if(a)return c=!0,h(void 0);a=!0;const e=Qe(o._readableStreamController);return null===e?y():m(e._view,!0),h(void 0)}function S(){}return n=kr(S,b,(function(n){if(l=!0,t=n,f){const n=ue([t,r]),o=Mr(e,n);i(o)}return p})),o=kr(S,w,(function(n){if(f=!0,r=n,l){const n=ue([t,r]),o=Mr(e,n);i(o)}return p})),v(s),[n,o]}(e):function(e){const t=J(e);let r,n,o,i,s,a=!1,u=!1,c=!1,l=!1;const f=d((e=>{s=e}));function p(){return a?(u=!0,h(void 0)):(a=!0,re(t,{_chunkSteps:e=>{_((()=>{u=!1;const t=e,r=e;c||_r(o._readableStreamController,t),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}}),h(void 0))}function v(){}return o=Ur(v,p,(function(t){if(c=!0,r=t,l){const t=ue([r,n]),o=Mr(e,t);s(o)}return f})),i=Ur(v,p,(function(t){if(l=!0,n=t,c){const t=ue([r,n]),o=Mr(e,t);s(o)}return f})),g(t._closedPromise,(e=>(Sr(o._readableStreamController,e),Sr(i._readableStreamController,e),c&&l||s(void 0),null))),[o,i]}(e)}(this))}values(e=void 0){if(!jr(this))throw Fr("values");return function(e,t){const r=J(e),n=new ge(r,t),o=Object.create(be);return o._asyncIteratorImpl=n,o}(this,function(e){B(e,"First parameter");const t=null==e?void 0:e.preventCancel;return{preventCancel:Boolean(t)}}(e).preventCancel)}[ve](e){return this.values(e)}static from(e){return Ar(e)}}function Ur(e,t,r,n=1,o=()=>1){const i=Object.create(Lr.prototype);return Dr(i),Or(i,Object.create(vr.prototype),e,t,r,n,o),i}function kr(e,t,r){const n=Object.create(Lr.prototype);return Dr(n),tt(n,Object.create(Pe.prototype),e,t,r,0,void 0),n}function Dr(e){e._state="readable",e._reader=void 0,e._storedError=void 0,e._disturbed=!1}function jr(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readableStreamController")&&e instanceof Lr}function qr(e){return void 0!==e._reader}function Mr(e,t){if(e._disturbed=!0,"closed"===e._state)return h(void 0);if("errored"===e._state)return p(e._storedError);Br(e);const r=e._reader;if(void 0!==r&<(r)){const e=r._readIntoRequests;r._readIntoRequests=new I,e.forEach((e=>{e._closeSteps(void 0)}))}return b(e._readableStreamController[A](t),n)}function Br(e){e._state="closed";const t=e._reader;if(void 0!==t&&(j(t),te(t))){const e=t._readRequests;t._readRequests=new I,e.forEach((e=>{e._closeSteps()}))}}function Wr(e,t){e._state="errored",e._storedError=t;const r=e._reader;void 0!==r&&(D(r,t),te(r)?ne(r,t):dt(r,t))}function Fr(e){return new TypeError(`ReadableStream.prototype.${e} can only be used on a ReadableStream`)}function Vr(e,t){B(e,t);const r=null==e?void 0:e.highWaterMark;return H(r,"highWaterMark","QueuingStrategyInit"),{highWaterMark:$(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,ve,{value:Lr.prototype.values,writable:!0,configurable:!0});const Hr=e=>e.byteLength;s(Hr,"size");class $r{constructor(e){V(e,1,"ByteLengthQueuingStrategy"),e=Vr(e,"First parameter"),this._byteLengthQueuingStrategyHighWaterMark=e.highWaterMark}get highWaterMark(){if(!zr(this))throw Gr("highWaterMark");return this._byteLengthQueuingStrategyHighWaterMark}get size(){if(!zr(this))throw Gr("size");return Hr}}function Gr(e){return new TypeError(`ByteLengthQueuingStrategy.prototype.${e} can only be used on a ByteLengthQueuingStrategy`)}function zr(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_byteLengthQueuingStrategyHighWaterMark")&&e instanceof $r}Object.defineProperties($r.prototype,{highWaterMark:{enumerable:!0},size:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty($r.prototype,Symbol.toStringTag,{value:"ByteLengthQueuingStrategy",configurable:!0});const Kr=()=>1;s(Kr,"size");class Jr{constructor(e){V(e,1,"CountQueuingStrategy"),e=Vr(e,"First parameter"),this._countQueuingStrategyHighWaterMark=e.highWaterMark}get highWaterMark(){if(!Qr(this))throw Yr("highWaterMark");return this._countQueuingStrategyHighWaterMark}get size(){if(!Qr(this))throw Yr("size");return Kr}}function Yr(e){return new TypeError(`CountQueuingStrategy.prototype.${e} can only be used on a CountQueuingStrategy`)}function Qr(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_countQueuingStrategyHighWaterMark")&&e instanceof Jr}function Zr(e,t,r){return W(e,r),r=>E(e,t,[r])}function Xr(e,t,r){return W(e,r),r=>S(e,t,[r])}function en(e,t,r){return W(e,r),(r,n)=>E(e,t,[r,n])}function tn(e,t,r){return W(e,r),r=>E(e,t,[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(e={},t={},r={}){void 0===e&&(e=null);const n=yt(t,"Second parameter"),o=yt(r,"Third parameter"),i=function(e,t){B(e,t);const r=null==e?void 0:e.cancel,n=null==e?void 0:e.flush,o=null==e?void 0:e.readableType,i=null==e?void 0:e.start,s=null==e?void 0:e.transform,a=null==e?void 0:e.writableType;return{cancel:void 0===r?void 0:tn(r,e,`${t} has member 'cancel' that`),flush:void 0===n?void 0:Zr(n,e,`${t} has member 'flush' that`),readableType:o,start:void 0===i?void 0:Xr(i,e,`${t} has member 'start' that`),transform:void 0===s?void 0:en(s,e,`${t} has member 'transform' that`),writableType:a}}(e,"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=pt(o,0),a=vt(o),u=pt(n,1),c=vt(n);let l;!function(e,t,r,n,o,i){function s(){return t}e._writable=function(e,t,r,n,o=1,i=()=>1){const s=Object.create(It.prototype);return Tt(s),Gt(s,Object.create(Ht.prototype),e,t,r,n,o,i),s}(s,(function(t){return function(e,t){const r=e._transformStreamController;return e._backpressure?b(e._backpressureChangePromise,(()=>{const n=e._writable;if("erroring"===n._state)throw n._storedError;return hn(r,t)})):hn(r,t)}(e,t)}),(function(){return function(e){const t=e._transformStreamController;if(void 0!==t._finishPromise)return t._finishPromise;const r=e._readable;t._finishPromise=d(((e,r)=>{t._finishPromise_resolve=e,t._finishPromise_reject=r}));const n=t._flushAlgorithm();return fn(t),y(n,(()=>("errored"===r._state?yn(t,r._storedError):(wr(r._readableStreamController),vn(t)),null)),(e=>(Sr(r._readableStreamController,e),yn(t,e),null))),t._finishPromise}(e)}),(function(t){return function(e,t){const r=e._transformStreamController;if(void 0!==r._finishPromise)return r._finishPromise;const n=e._readable;r._finishPromise=d(((e,t)=>{r._finishPromise_resolve=e,r._finishPromise_reject=t}));const o=r._cancelAlgorithm(t);return fn(r),y(o,(()=>("errored"===n._state?yn(r,n._storedError):(Sr(n._readableStreamController,t),vn(r)),null)),(e=>(Sr(n._readableStreamController,e),yn(r,e),null))),r._finishPromise}(e,t)}),r,n),e._readable=Ur(s,(function(){return function(e){return un(e,!1),e._backpressureChangePromise}(e)}),(function(t){return function(e,t){const r=e._transformStreamController;if(void 0!==r._finishPromise)return r._finishPromise;const n=e._writable;r._finishPromise=d(((e,t)=>{r._finishPromise_resolve=e,r._finishPromise_reject=t}));const o=r._cancelAlgorithm(t);return fn(r),y(o,(()=>("errored"===n._state?yn(r,n._storedError):(Yt(n._writableStreamController,t),an(e),vn(r)),null)),(t=>(Yt(n._writableStreamController,t),an(e),yn(r,t),null))),r._finishPromise}(e,t)}),o,i),e._backpressure=void 0,e._backpressureChangePromise=void 0,e._backpressureChangePromise_resolve=void 0,un(e,!0),e._transformStreamController=void 0}(this,d((e=>{l=e})),u,c,s,a),function(e,t){const r=Object.create(cn.prototype);let n,o,i;n=void 0!==t.transform?e=>t.transform(e,r):e=>{try{return dn(r,e),h(void 0)}catch(e){return p(e)}},o=void 0!==t.flush?()=>t.flush(r):()=>h(void 0),i=void 0!==t.cancel?e=>t.cancel(e):()=>h(void 0),function(e,t,r,n,o){t._controlledTransformStream=e,e._transformStreamController=t,t._transformAlgorithm=r,t._flushAlgorithm=n,t._cancelAlgorithm=o,t._finishPromise=void 0,t._finishPromise_resolve=void 0,t._finishPromise_reject=void 0}(e,r,n,o,i)}(this,i),void 0!==i.start?l(i.start(this._transformStreamController)):l(void 0)}get readable(){if(!nn(this))throw mn("readable");return this._readable}get writable(){if(!nn(this))throw mn("writable");return this._writable}}function nn(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_transformStreamController")&&e instanceof rn}function on(e,t){Sr(e._readable._readableStreamController,t),sn(e,t)}function sn(e,t){fn(e._transformStreamController),Yt(e._writable._writableStreamController,t),an(e)}function an(e){e._backpressure&&un(e,!1)}function un(e,t){void 0!==e._backpressureChangePromise&&e._backpressureChangePromise_resolve(),e._backpressureChangePromise=d((t=>{e._backpressureChangePromise_resolve=t})),e._backpressure=t}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(e=void 0){if(!ln(this))throw pn("enqueue");dn(this,e)}error(e=void 0){if(!ln(this))throw pn("error");var t;t=e,on(this._controlledTransformStream,t)}terminate(){if(!ln(this))throw pn("terminate");!function(e){const t=e._controlledTransformStream;wr(t._readable._readableStreamController),sn(t,new TypeError("TransformStream terminated"))}(this)}}function ln(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledTransformStream")&&e instanceof cn}function fn(e){e._transformAlgorithm=void 0,e._flushAlgorithm=void 0,e._cancelAlgorithm=void 0}function dn(e,t){const r=e._controlledTransformStream,n=r._readable._readableStreamController;if(!Ir(n))throw new TypeError("Readable side is not in a state that permits enqueue");try{_r(n,t)}catch(e){throw sn(r,e),r._readable._storedError}const o=function(e){return!gr(e)}(n);o!==r._backpressure&&un(r,!0)}function hn(e,t){return b(e._transformAlgorithm(t),void 0,(t=>{throw on(e._controlledTransformStream,t),t}))}function pn(e){return new TypeError(`TransformStreamDefaultController.prototype.${e} can only be used on a TransformStreamDefaultController`)}function vn(e){void 0!==e._finishPromise_resolve&&(e._finishPromise_resolve(),e._finishPromise_resolve=void 0,e._finishPromise_reject=void 0)}function yn(e,t){void 0!==e._finishPromise_reject&&(w(e._finishPromise),e._finishPromise_reject(t),e._finishPromise_resolve=void 0,e._finishPromise_reject=void 0)}function mn(e){return new TypeError(`TransformStream.prototype.${e} 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})}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={id:n,loaded:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.loaded=!0,i.exports}return r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.nmd=function(e){return e.paths=[],e.children||(e.children=[]),e},r(5047),r(972)}()}));
|
|
2
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("cloudbase",[],t):"object"==typeof exports?exports.cloudbase=t():e.cloudbase=t()}("undefined"!=typeof window?window:this,(function(){return function(){var e={2829:function(e,t,r){"use strict";var n;r.r(t),r.d(t,{AbstractSDKRequest:function(){return o},AbstractStorage:function(){return i},StorageType:function(){return n},formatUrl:function(){return s}}),function(e){e.local="local",e.none="none",e.session="session"}(n||(n={}));var o=function(){},i=function(){};function s(e,t,r){void 0===r&&(r={});var n=/\?/.test(t),o="";for(var i in r)""===o?!n&&(t+="?"):o+="&",o+=i+"="+encodeURIComponent(r[i]);return/^http(s)?\:\/\//.test(t+=o)?t:""+e+t}},190:function(e,t,r){"use strict";r.d(t,{ap:function(){return l},dD:function(){return d},ng:function(){return f},x5:function(){return c}});var n,o=r(2829),i=r(5993),s=(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},n(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},a.apply(this,arguments)},u="Error when aborting requestTask",c=function(e){function t(t){void 0===t&&(t={});var r=e.call(this)||this,n=t.timeout,o=t.timeoutMsg,i=t.restrictedMethods;return r._timeout=n||0,r._timeoutMsg=o||"请求超时",r._restrictedMethods=i||["get","post","upload","download"],r}return s(t,e),t.prototype.post=function(e){var t=this;return new Promise((function(r,n){var i=e.url,s=e.data,a=e.headers,u=wx.request({url:(0,o.formatUrl)("https:",i),data:s,timeout:t._timeout,method:"POST",header:a,success:function(e){e.statusCode>=200&&e.statusCode<300?r({statusCode:e.statusCode,status:e.statusCode,data:e.data}):n(e)},fail:function(e){n(e)},complete:function(e){if(e&&e.errMsg&&t._timeout&&-1!==t._restrictedMethods.indexOf("post")&&"request:fail timeout"===e.errMsg){console.warn(t._timeoutMsg);try{u.abort()}catch(e){}}}})}))},t.prototype.get=function(e){var t=this;return new Promise((function(r,n){var i=e.url,s=e.body,a=e.headers,c=(0,o.formatUrl)("https:",i),l=wx.request({url:c,data:s,timeout:t._timeout,method:"GET",header:a,success:function(e){e.statusCode>=200&&e.statusCode<300?r({statusCode:e.statusCode,status:e.statusCode,data:e.data}):n(e)},fail:function(e){n(e)},complete:function(e){if(e&&e.errMsg&&t._timeout&&-1!==t._restrictedMethods.indexOf("get")&&e.errMsg.includes("timeout")){console.warn(t._timeoutMsg);try{l.abort()}catch(e){console.warn(u,e)}}}})}))},t.prototype.upload=function(e){var t=this,r=this;return new Promise((function(n){return o=t,i=void 0,u=function(){var t,o,i,s,u,c;return function(e,t){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=t.call(e,s)}catch(e){i=[6,e],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 t=e.url,o=e.file,i=e.data,s=e.headers,u=e.onUploadProgress,c=wx.uploadFile({url:t,filePath:o,name:"file",formData:a({},i),header:s,timeout:this._timeout,success:function(e){var t={statusCode:e.statusCode,data:e.data||{}};200===e.statusCode&&i.success_action_status&&(t.statusCode=parseInt(i.success_action_status,10)),n(t)},fail:function(e){n(e)},complete:function(e){if(e&&e.errMsg&&r._timeout&&-1!==r._restrictedMethods.indexOf("upload")&&"request:fail timeout"===e.errMsg){console.warn(r._timeoutMsg);try{c.abort()}catch(e){}}}}),u&&c.onProgressUpdate((function(e){u(e)})),[2]}))},new((s=void 0)||(s=Promise))((function(e,t){function r(e){try{a(u.next(e))}catch(e){t(e)}}function n(e){try{a(u.throw(e))}catch(e){t(e)}}function a(t){var o;t.done?e(t.value):(o=t.value,o instanceof s?o:new s((function(e){e(o)}))).then(r,n)}a((u=u.apply(o,i||[])).next())}));var o,i,s,u}))},t.prototype.download=function(e){var t=this,r=this;return new Promise((function(n,i){var s=e.url,a=e.headers,u=wx.downloadFile({url:(0,o.formatUrl)("https:",s),header:a,timeout:t._timeout,success:function(e){200===e.statusCode&&e.tempFilePath?n({statusCode:200,tempFilePath:e.tempFilePath}):n(e)},fail:function(e){i(e)},complete:function(e){if(e&&e.errMsg&&r._timeout&&-1!==r._restrictedMethods.indexOf("download")&&"request:fail timeout"===e.errMsg){console.warn(r._timeoutMsg);try{u.abort()}catch(e){}}}})}))},t.prototype.fetch=function(e){var t=e.url,r=e.body,n=e.enableAbort,s=e.headers,a=e.method,c=e.stream,l=void 0!==c&&c,f=e.signal,d=e.timeout,h=this,p=null!=d?d:this._timeout,v=null,y=new i.Pz({start:function(e){v=e},cancel:function(){v=null}});return new Promise((function(e,i){l&&e({data:y});var c=wx.request({url:(0,o.formatUrl)("https:",t),data:r,timeout:p,method:a.toUpperCase(),header:s,success:function(t){null==v||v.close(),!l&&e(t)},fail:function(e){if(null==v||v.close(),i(e),l)throw e},complete:function(e){if(e&&e.errMsg&&p&&-1!==h._restrictedMethods.indexOf("post")&&n&&"request:fail timeout"===e.errMsg){console.warn(h._timeoutMsg);try{c.abort()}catch(e){console.warn(u,e)}}},enableChunked:l});if(c.onChunkReceived((function(e){null==v||v.enqueue(new Uint8Array(e.data))})),f){var d=function(){try{c.abort()}catch(e){console.warn(u,e)}};f.aborted?d():f.addEventListener("abort",(function(){return d()}))}}))},t.prototype.patch=function(e){var t=e.method,r=e.headers,n=JSON.parse(JSON.stringify(r||{}));return"PATCH"===t.toUpperCase()&&(n["X-HTTP-Method-Override"]="PATCH",t="POST"),this.post(a(a({},e),{method:t,headers:n}))},t}(o.AbstractSDKRequest),l={setItem:function(e,t){wx.setStorageSync(e,t)},getItem:function(e){return wx.getStorageSync(e)},removeItem:function(e){wx.removeStorageSync(e)},clear:function(){wx.clearStorageSync()}},f=function(e,t){void 0===t&&(t={});var r=wx.connectSocket(a({url:e},t));return{set onopen(e){r.onOpen(e)},set onmessage(e){r.onMessage(e)},set onclose(e){r.onClose(e)},set onerror(e){r.onError(e)},send:function(e){return r.send({data:e})},close:function(e,t){return r.close({code:e,reason:t})},get readyState(){return r.readyState},CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3}};function d(e){var t={},r=e.replace(/^[?#]/,"");return r?(r.split("&").forEach((function(e){var r=e.split("="),n=r[0],o=r[1];n=decodeURIComponent(n),o=decodeURIComponent(o),n&&(t[n]?Array.isArray(t[n])?t[n].push(o):t[n]=[t[n],o]:t[n]=o)})),t):t}var h={genAdapter:function(e){return{root:{globalThis:{}},reqClass:c,wsClass:f,captchaOptions:{openURIWithCallback:function(t){var r=e.EventBus,n={},o=t;console.log("openURIWithCallback",t);var i=t.match(/^(data:.*?)(\?[^#\s]*)?$/);if(i){o=i[1],console.log("openURIWithCallback url",o);var s=i[2];s&&(n=d(s))}console.log("openURIWithCallback queryObj",n);var u=n.token,c=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(n,["token"]);return/^data:/.test(o)&&!u?Promise.reject({error:"invalid_argument",error_description:"invalie captcha data: "+t}):u?new Promise((function(e){console.log("wait for captcha..."),r.$emit("CAPTCHA_DATA_CHANGE",a(a({},c),{token:u,url:o})),r.$once("RESOLVE_CAPTCHA_DATA",(function(t){e(t)}))})):Promise.reject({error:"unimplemented",error_description:"need to impl captcha data"})}},localStorage:l,primaryStorage:o.StorageType.local,getAppSign:function(){var e=wx.getAccountInfoSync();return"undefined"!=typeof App||"undefined"!=typeof getApp||wx.onAppHide||wx.offAppHide||wx.onAppShow||wx.offAppShow?e&&e.miniProgram?e.miniProgram.appId:"":e&&e.plugin?e.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(e){return!1}return!0},runtime:"wx_mp"};t.ZP=h},5304:function(e,t){!function(e){"use strict";var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},t(e,r)};var r=function(){return r=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)};function n(e,t,r,n){return new(r||(r=Promise))((function(t,o){function i(e){try{a(n.next(e))}catch(e){o(e)}}function s(e){try{a(n.throw(e))}catch(e){o(e)}}function a(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r((function(e){e(n)}))).then(i,s)}a((n=n.apply(e,[])).next())}))}function o(e,t){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=t.call(e,s)}catch(e){i=[6,e],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(e){function r(t,r){var n=e.call(this,t)||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(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)}(r,e),r}(Error);function s(){return"undefined"!=typeof window&&window||"undefined"!=typeof globalThis&&globalThis}function a(){try{var e=s();if(!e)return;return"undefined"==typeof wx?s().location.href:e.__wxRoute}catch(e){}}var u=function(e){var t=e.dataSourceName,r=e.methodName,u=e.params,c=e.realMethodName,l=e.callFunction,f=e.envType,d=void 0===f?"prod":f,h=e.mode;return n(void 0,0,void 0,(function(){var e,n,f,p,v,y;return o(this,(function(o){switch(o.label){case 0:e={data:{},requestId:""},o.label=1;case 1:return o.trys.push([1,3,,4]),[4,l({name:"lowcode-datasource",data:{dataSourceName:t,methodName:r,params:u,userAgent:(g=s(),(null==g?void 0:g.navigator)?g.navigator.userAgent:"undefined"!=typeof wx&&wx.getSystemInfo?(wx.getSystemInfo({success:function(e){e&&(m=["brand","model","version","system","platform","SDKVersion","language"].map((function(t){return"".concat(t,": ").concat(e[t])})).join(", "))}}),m):void 0),referrer:a(),"x-sdk-version":"1.5.0",envType:d,mode:h}})];case 2:if(n=o.sent(),f=(null===(v=null==n?void 0:n.result)||void 0===v?void 0:v.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(t?"".concat(t,"."):"").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 e.data=(null===(y=null==n?void 0:n.result)||void 0===y?void 0:y.data)||{},e.requestId=f,[3,4];case 3:throw"WxCloudSDKError"===(p=o.sent()).name?p:(console.log(p),new i("【错误】".concat(p.message,"\n 【操作】调用 models.").concat(t?"".concat(t,"."):"").concat(c,"\n 【请求ID】N/A"),{code:"UnknownError",originError:p}));case 4:return[2,e]}var m,g}))}))},c=function(e){var t=e.sql,r=e.params,i=e.config,s=e.callFunction,a=e.unsafe,c=void 0!==a&&a;return n(void 0,0,void 0,(function(){return o(this,(function(e){return[2,u({realMethodName:"$runSQL",methodName:"callWedaApi",params:{action:"RunMysqlCommand",data:{sqlTemplate:t,config:i,parameter:c?"":Object.entries(r||{}).reduce((function(e,t){var r=t[0],n=t[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"}e.push({key:r,type:o,value:"STRING"===o?n:JSON.stringify(n)})}return e}),[])||[]}},callFunction:s,mode:"sdk"})]}))}))},l=function(e){return{$runSQL:function(t,i,s){return n(this,0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return[4,c({sql:t,params:i,config:r(r({},s),{preparedStatements:!0}),callFunction:e})];case 1:return[2,n.sent()]}}))}))},$runSQLRaw:function(t,i){return n(this,0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return[4,c({sql:t,params:[],config:r(r({},i),{preparedStatements:!1}),callFunction:e})];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}}}},d=function(e){var t=l(e);return new Proxy({},{get:function(s,a){if("string"==typeof a)return Object.prototype.hasOwnProperty.call(t,a)?t[a]:function(e,t){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,d;return o(this,(function(o){switch(o.label){case 0:return n=r(r({},c.defaultParams||{}),i||{}),[4,u({callFunction:t,dataSourceName:e,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===(d=null==s?void 0:s.data)||void 0===d?void 0:d[f]:null==s?void 0:s.data,[2,l]}}))}))}}})}(a,e)}})},h={filter:{where:{}},select:{$master:!0}};function p(e){return{getUrl:function(t){return"".concat(t,"/").concat(e)},method:"post"}}var v={get:r(r({},p("get")),{defaultParams:r({},h)}),list:r(r({},p("list")),{defaultParams:r({},h)}),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")},y="Unknown error occurred",m="NotSupported",g=function(e,t,r,n){var o=l(e);return new Proxy({},{get:function(e,i){if("string"==typeof i)return Object.prototype.hasOwnProperty.call(o,i)?o[i]:w(r,i,t,n)}})},b=function(e,t,r,n,o){return new i("【错误】".concat(e,"\n【操作】调用 models.").concat(t,".").concat(r,"\n【错误码】").concat(n,"\n【请求ID】").concat(o),{code:n,requestId:o})},w=function(e,t,s,a){return new Proxy({},{get:function(u,c){if("runSQLTemplate"!==c){var l=v[c];if(!l){var f=new Error("不支持的操作: ".concat(c));throw new i(f.message||y,{originError:f,code:m,requestId:"N/A"})}return function(r){return void 0===r&&(r={}),n(void 0,0,void 0,(function(){var n,a,u,f,d,h,p,v,m,g;return o(this,(function(o){switch(o.label){case 0:n=l.getUrl,a=l.method,u=l.defaultParams,f=void 0===u?{}:u,d=Object.assign({},f,r),h="pre"===d.envType?"pre":"prod",p=[e,h,n(t)].join("/"),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,s({url:p,body:JSON.stringify(d),method:a})];case 2:if((v=o.sent()).code)throw b(null==v?void 0:v.message,t,c,null==v?void 0:v.code,null==v?void 0:v.requestId);return"get"===c&&Object.assign(v,{data:null!==(g=v.data.record)&&void 0!==g?g:v.data}),[2,v];case 3:throw m=o.sent(),new i((null==m?void 0:m.message)||y,{originError:m});case 4:return[2]}}))}))}}if(!(null==a?void 0:a.sqlBaseUrl))throw f=new Error("不支持的操作: ".concat(c)),new i(f.message||y,{originError:f,code:m,requestId:"N/A"});return function(e){return n(void 0,0,void 0,(function(){var n,u,l,f,d,h,p,v,m,g,w,_,S,E,I,O;return o(this,(function(o){switch(o.label){case 0:n=e.params,u=e.templateName,l=e.envType,f="pre"===l?"pre":"prod",d=[a.sqlBaseUrl,f,u,"run"].join("/"),h=Object.entries(n||{}).reduce((function(e,t){var r=t[0],n=t[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"}e.push({key:r,type:o,value:"STRING"===o?n:JSON.stringify(n)})}return e}),[]),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,s({url:d,body:JSON.stringify({parameter:h}),method:"POST"})];case 2:if(p=o.sent(),null===(m=null==p?void 0:p.Response)||void 0===m?void 0:m.Error)throw b(null===(w=null===(g=null==p?void 0:p.Response)||void 0===g?void 0:g.Error)||void 0===w?void 0:w.Message,t,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 v=o.sent(),new i((null==v?void 0:v.message)||y,{originError:v});case 4:return[2]}}))}))}}})};function _(e){if(!e)throw new Error("cloud is required");if(!e.callFunction)throw new Error("cloud.callFunction is required");var t=d(e.callFunction.bind(e));return e.models=t,e}var S={init:_,generateHTTPClient:g};e.default=S,e.generateHTTPClient=g,e.init=_,Object.defineProperty(e,"__esModule",{value:!0})}(t)},972:function(e,t,r){"use strict";var n=(this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(r(9917)),o=r(6334),i=r(2363),s=r(534),a=r(9063),u=r(7505),c=r(9679),l=r(4982),f=r(7596),d=r(2840),h=r(41),p=r(5348);n.default.registerVersion("3.3.2");try{(0,o.registerAuth)(n.default),(0,i.registerFunctions)(n.default),(0,s.registerStorage)(n.default),(0,p.registerDatabase)(n.default),(0,a.registerRealtime)(n.default),(0,u.registerAnalytics)(n.default),(0,c.registerModel)(n.default),(0,l.registerAi)(n.default),(0,f.registerCloudrun)(n.default),(0,d.registerMySQL)(n.default),(0,h.registerApis)(n.default)}catch(e){}try{window.cloudbase=n.default}catch(e){}t.default=n.default,e.exports=n.default},4982:function(e,t,r){"use strict";r.r(t),r.d(t,{AI:function(){return ot},Bot:function(){return M},SimpleChatModel:function(){return it},createAI:function(){return lt},createAi:function(){return ft},models:function(){return ut},registerAi:function(){return ht},utils:function(){return n}});var n={};r.r(n),r.d(n,{ReadableStream:function(){return E},TextDecoderStream:function(){return A},TransformStream:function(){return I},createAsyncIterable:function(){return R},createEventSourceParserTransformStream:function(){return O},createPromise:function(){return x},functionToolToModelTool:function(){return U},intoStandardStream:function(){return P},intoTextStream:function(){return C},isToolCallAssistantMessage:function(){return L},readableStream2JsonObject:function(){return N},toPolyfillReadable:function(){return T}});var o={};r.r(o),r.d(o,{ArkSimpleModel:function(){return ae},DSSimpleModel:function(){return de},DefaultImageModel:function(){return Me},DefaultSimpleModel:function(){return qe},HunYuanBetaSimpleModel:function(){return Z},HunYuanExpSimpleModel:function(){return Te},HunYuanOpenSimpleModel:function(){return Ce},HunYuanSimpleModel:function(){return re},MODELS:function(){return Ze},MoonshotSimpleModel:function(){return Se},ReactModel:function(){return $e},YiSimpleModel:function(){return me},ZhiPuSimpleModel:function(){return $},toolMap:function(){return Ke}});var i=r(5993),s=function(e,t){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},s(e,t)};function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}s(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function u(e){if(!e)throw new TypeError("Assertion failed")}function c(){}function l(e){return!(t=e,("object"!=typeof t||null===t)&&"function"!=typeof t||"function"!=typeof e.getReader);var t}function f(e){try{return e.getReader({mode:"byob"}).releaseLock(),!0}catch(e){return!1}}function d(e,t){var r=(void 0===t?{}:t).type;return u(l(e)),u(!1===e.locked),"bytes"===(r=h(r))?new m(e):new v(e)}function h(e){var t=String(e);if("bytes"===t)return t;if(void 0===e)return e;throw new RangeError("Invalid type is specified")}var p=function(){function e(e){this._underlyingReader=void 0,this._readerMode=void 0,this._readableStreamController=void 0,this._pendingRead=void 0,this._underlyingStream=e,this._attachDefaultReader()}return e.prototype.start=function(e){this._readableStreamController=e},e.prototype.cancel=function(e){return u(void 0!==this._underlyingReader),this._underlyingReader.cancel(e)},e.prototype._attachDefaultReader=function(){if("default"!==this._readerMode){this._detachReader();var e=this._underlyingStream.getReader();this._readerMode="default",this._attachReader(e)}},e.prototype._attachReader=function(e){var t=this;u(void 0===this._underlyingReader),this._underlyingReader=e;var r=this._underlyingReader.closed;r&&r.then((function(){return t._finishPendingRead()})).then((function(){e===t._underlyingReader&&t._readableStreamController.close()}),(function(r){e===t._underlyingReader&&t._readableStreamController.error(r)})).catch(c)},e.prototype._detachReader=function(){void 0!==this._underlyingReader&&(this._underlyingReader.releaseLock(),this._underlyingReader=void 0,this._readerMode=void 0)},e.prototype._pullWithDefaultReader=function(){var e=this;this._attachDefaultReader();var t=this._underlyingReader.read().then((function(t){var r=e._readableStreamController;t.done?e._tryClose():r.enqueue(t.value)}));return this._setPendingRead(t),t},e.prototype._tryClose=function(){try{this._readableStreamController.close()}catch(e){}},e.prototype._setPendingRead=function(e){var t,r=this,n=function(){r._pendingRead===t&&(r._pendingRead=void 0)};this._pendingRead=t=e.then(n,n)},e.prototype._finishPendingRead=function(){var e=this;if(this._pendingRead){var t=function(){return e._finishPendingRead()};return this._pendingRead.then(t,t)}},e}(),v=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return a(t,e),t.prototype.pull=function(){return this._pullWithDefaultReader()},t}(p);function y(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var m=function(e){function t(t){var r=this,n=f(t);return(r=e.call(this,t)||this)._supportsByob=n,r}return a(t,e),Object.defineProperty(t.prototype,"type",{get:function(){return"bytes"},enumerable:!1,configurable:!0}),t.prototype._attachByobReader=function(){if("byob"!==this._readerMode){u(this._supportsByob),this._detachReader();var e=this._underlyingStream.getReader({mode:"byob"});this._readerMode="byob",this._attachReader(e)}},t.prototype.pull=function(){if(this._supportsByob){var e=this._readableStreamController.byobRequest;if(e)return this._pullWithByobRequest(e)}return this._pullWithDefaultReader()},t.prototype._pullWithByobRequest=function(e){var t=this;this._attachByobReader();var r=new Uint8Array(e.view.byteLength),n=this._underlyingReader.read(r).then((function(r){var n,o,i;t._readableStreamController,r.done?(t._tryClose(),e.respond(0)):(n=r.value,o=e.view,i=y(n),y(o).set(i,0),e.respond(r.value.byteLength))}));return this._setPendingRead(n),n},t}(p);!function(){function e(e){var t=this;this._writableStreamController=void 0,this._pendingWrite=void 0,this._state="writable",this._storedError=void 0,this._underlyingWriter=e,this._errorPromise=new Promise((function(e,r){t._errorPromiseReject=r})),this._errorPromise.catch(c)}e.prototype.start=function(e){var t=this;this._writableStreamController=e,this._underlyingWriter.closed.then((function(){t._state="closed"})).catch((function(e){return t._finishErroring(e)}))},e.prototype.write=function(e){var t=this,r=this._underlyingWriter;if(null===r.desiredSize)return r.ready;var n=r.write(e);n.catch((function(e){return t._finishErroring(e)})),r.ready.catch((function(e){return t._startErroring(e)}));var o=Promise.race([n,this._errorPromise]);return this._setPendingWrite(o),o},e.prototype.close=function(){var e=this;return void 0===this._pendingWrite?this._underlyingWriter.close():this._finishPendingWrite().then((function(){return e.close()}))},e.prototype.abort=function(e){if("errored"!==this._state)return this._underlyingWriter.abort(e)},e.prototype._setPendingWrite=function(e){var t,r=this,n=function(){r._pendingWrite===t&&(r._pendingWrite=void 0)};this._pendingWrite=t=e.then(n,n)},e.prototype._finishPendingWrite=function(){var e=this;if(void 0===this._pendingWrite)return Promise.resolve();var t=function(){return e._finishPendingWrite()};return this._pendingWrite.then(t,t)},e.prototype._startErroring=function(e){var t=this;if("writable"===this._state){this._state="erroring",this._storedError=e;var r=function(){return t._finishErroring(e)};void 0===this._pendingWrite?r():this._finishPendingWrite().then(r,r),this._writableStreamController.error(e)}},e.prototype._finishErroring=function(e){"writable"===this._state&&this._startErroring(e),"erroring"===this._state&&(this._state="errored",this._errorPromiseReject(this._storedError))}}(),function(){function e(e,t){var r=this;this._transformStreamController=void 0,this._onRead=function(e){if(!e.done)return r._transformStreamController.enqueue(e.value),r._reader.read().then(r._onRead)},this._onError=function(e){r._flushReject(e),r._transformStreamController.error(e),r._reader.cancel(e).catch(c),r._writer.abort(e).catch(c)},this._onTerminate=function(){r._flushResolve(),r._transformStreamController.terminate();var e=new TypeError("TransformStream terminated");r._writer.abort(e).catch(c)},this._reader=e,this._writer=t,this._flushPromise=new Promise((function(e,t){r._flushResolve=e,r._flushReject=t}))}e.prototype.start=function(e){this._transformStreamController=e,this._reader.read().then(this._onRead).then(this._onTerminate,this._onError);var t=this._reader.closed;t&&t.then(this._onTerminate,this._onError)},e.prototype.transform=function(e){return this._writer.write(e)},e.prototype.flush=function(){var e=this;return this._writer.close().then((function(){return e._flushPromise}))}}();var g=[239,187,191],b=r(4410),w=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},_=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,o){!function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)}(n,o,(t=e[r](t)).done,t.value)}))}}},E=i.Pz,I=i.GJ,O=function(){var e;return new I({start:function(t){e=function(e){var t,r,n,o,i,s,a;return u(),{feed:function(e){r=r?r+e:e,t&&function(e){return g.every((function(t,r){return e.charCodeAt(r)===t}))}(r)&&(r=r.slice(g.length)),t=!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,d=n;u<0&&d<i;d++)":"===(f=r[d])&&l<0?l=d-s:"\r"===f?(a=!0,u=d-s):"\n"===f&&(u=d-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(){t=!0,r="",n=0,o=-1,i=void 0,s=void 0,a=""}function c(t,r,n,o){if(0===o)return a.length>0&&(e({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=t.slice(r,r+(c?o:n)),f=r+(u=c?o:" "===t[r+n+1]?n+2:n+1),d=o-u,h=t.slice(f,f+d).toString();if("data"===l)a+=h?"".concat(h,"\n"):"\n";else if("event"===l)s=h;else if("id"!==l||h.includes("\0")){if("retry"===l){var p=parseInt(h,10);Number.isNaN(p)||e({type:"reconnect-interval",value:p})}}else i=h}}((function(e){"event"===e.type&&t.enqueue(e)}))},transform:function(t){e.feed(t)}})},T=function(e){u(function(e){return!!function(e){if("function"!=typeof e)return!1;var t=!1;try{new e({start:function(){t=!0}})}catch(e){}return t}(e)&&!!l(new e)}(e));var t=function(e){try{return new e({type:"bytes"}),!0}catch(e){return!1}}(e);return function(r,n){var o=(void 0===n?{}:n).type;if("bytes"!==(o=h(o))||t||(o=void 0),r.constructor===e&&("bytes"!==o||f(r)))return r;if("bytes"===o){var i=d(r,{type:o});return new e(i)}return i=d(r),new e(i)}}(E),A=function(){function e(e,t){void 0===e&&(e="utf-8"),void 0===t&&(t={});var r=this;this.transform=new I({transform:function(e,t){var n=r.handle.decode(new Uint8Array(e),{stream:!0});n&&t.enqueue(n)},flush:function(e){var t=r.handle.decode();t&&e.enqueue(t),e.terminate()}}),this.handle=new b.TextDecoder(e,t)}return Object.defineProperty(e.prototype,"encoding",{get:function(){return this.handle.encoding},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fatal",{get:function(){return this.handle.fatal},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ignoreBOM",{get:function(){return this.handle.ignoreBOM},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"readable",{get:function(){return this.transform.readable},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"writable",{get:function(){return this.transform.writable},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,Symbol.toStringTag,{get:function(){return"TextDecoderStream"},enumerable:!1,configurable:!0}),e}();function R(e){var t=e;return t[Symbol.asyncIterator]=function(){var t=e.getReader();return{next:function(){return w(this,void 0,void 0,(function(){var e,r,n;return _(this,(function(o){switch(o.label){case 0:return[4,t.read()];case 1:return e=o.sent(),r=e.done,n=e.value,[2,r?{done:!0,value:void 0}:{done:!1,value:n}]}}))}))}}},t}function P(e){return R(e.pipeThrough(new A).pipeThrough(O()).pipeThrough(new I({transform:function(e,t){try{var r=JSON.parse(e.data);t.enqueue(r)}catch(r){"[DONE]"!==e.data?console.warn("Error when transforming event source data to json",r,e):t.terminate()}}})))}function C(e){return R(T(e).pipeThrough(new A))}function N(e){var t,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=C(e),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(),t=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||t||!(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 x(){var e,t;return{promise:new Promise((function(r,n){e=r,t=n})),res:e,rej:t}}function L(e){var t;return"assistant"===e.role&&"tool_calls"in e&&null!=(null===(t=e.tool_calls)||void 0===t?void 0:t[0])}function U(e){return{type:"function",function:{description:e.description,name:e.name,parameters:e.parameters}}}var k=function(){return k=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},k.apply(this,arguments)},D=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},j=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r},M=function(){function e(e,t){this.baseUrl=t;var r=arguments[2];this.req="string"==typeof r?function(t){var n=t.headers,o=void 0===n?{}:n,i=q(t,["headers"]);return e(k(k({},i),{headers:k(k({},o),{Authorization:"Bearer ".concat(r)})}))}:e}return e.prototype.list=function(e,t){return this.req({method:"get",url:this.join("bots"),data:e,timeout:null==t?void 0:t.timeout})},e.prototype.create=function(e,t){var r=e.botInfo;return this.req({method:"post",url:this.join("bots"),data:r,timeout:null==t?void 0:t.timeout})},e.prototype.get=function(e,t){var r=e.botId;return this.req({method:"get",url:this.join("bots/".concat(r)),timeout:null==t?void 0:t.timeout})},e.prototype.update=function(e,t){var r=e.botId,n=e.botInfo;return this.req({method:"PATCH",url:this.join("bots/".concat(r)),data:n,timeout:null==t?void 0:t.timeout})},e.prototype.delete=function(e,t){var r=e.botId;return this.req({method:"delete",url:this.join("bots/".concat(r)),timeout:null==t?void 0:t.timeout})},e.prototype.getChatRecords=function(e,t){return this.req({method:"get",url:this.join("bots/".concat(e.botId,"/records")),data:e,timeout:null==t?void 0:t.timeout})},e.prototype.sendFeedback=function(e,t){var r=e.userFeedback;return this.req({method:"post",url:this.join("bots/".concat(r.botId,"/feedback")),data:r,timeout:null==t?void 0:t.timeout})},e.prototype.getFeedback=function(e,t){return this.req({method:"get",url:this.join("bots/".concat(e.botId,"/feedback")),data:e,timeout:null==t?void 0:t.timeout})},e.prototype.uploadFiles=function(e,t){return D(this,void 0,void 0,(function(){return j(this,(function(r){return[2,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/files")),data:e,timeout:null==t?void 0:t.timeout})]}))}))},e.prototype.createConversation=function(e,t){var r=e.botId,n=q(e,["botId"]);return D(this,void 0,void 0,(function(){return j(this,(function(e){return[2,this.req({method:"post",url:this.join("bots/".concat(r,"/conversation")),data:n,timeout:null==t?void 0:t.timeout})]}))}))},e.prototype.getConversation=function(e,t){var r=e.pageSize,n=void 0===r?10:r,o=e.pageNumber,i=void 0===o?1:o,s=e.botId,a=q(e,["pageSize","pageNumber","botId"]);return D(this,void 0,void 0,(function(){var e,r;return j(this,(function(o){if(i<1)throw new Error("pageNumber must be greater than 0");return e=n*(i-1),r=n,[2,this.req({method:"get",url:this.join("bots/".concat(s,"/conversation")),data:k(k({},a),{offset:e,limit:r}),timeout:null==t?void 0:t.timeout})]}))}))},e.prototype.deleteConversation=function(e,t){var r=e.botId,n=e.conversationId,o=q(e,["botId","conversationId"]);return D(this,void 0,void 0,(function(){return j(this,(function(e){return[2,this.req({method:"delete",url:this.join("bots/".concat(r,"/conversation/").concat(n)),data:o,timeout:null==t?void 0:t.timeout})]}))}))},e.prototype.speechToText=function(e,t){return D(this,void 0,void 0,(function(){return j(this,(function(r){return[2,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/speech-to-text")),data:e,timeout:null==t?void 0:t.timeout})]}))}))},e.prototype.textToSpeech=function(e,t){return D(this,void 0,void 0,(function(){return j(this,(function(r){return[2,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/text-to-speech")),data:e,timeout:null==t?void 0:t.timeout})]}))}))},e.prototype.getTextToSpeechResult=function(e,t){return D(this,void 0,void 0,(function(){return j(this,(function(r){return[2,this.req({method:"get",url:this.join("bots/".concat(e.botId,"/text-to-speech")),data:e,timeout:null==t?void 0:t.timeout})]}))}))},e.prototype.getRecommendQuestions=function(e,t){return D(this,void 0,void 0,(function(){var r;return j(this,(function(n){switch(n.label){case 0:return[4,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/recommend-questions")),data:e,stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return r=n.sent(),[2,new B(r)]}}))}))},e.prototype.generateBot=function(e,t){return D(this,void 0,void 0,(function(){var r;return j(this,(function(n){switch(n.label){case 0:return[4,this.req({method:"post",url:this.join("generate-bot"),data:e,stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return r=n.sent(),[2,new B(r)]}}))}))},e.prototype.getPreview=function(e,t){return D(this,void 0,void 0,(function(){var r;return j(this,(function(n){switch(n.label){case 0:return[4,this.req({method:"post",url:this.join("preview"),data:e,stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return r=n.sent(),[2,new B(r)]}}))}))},e.prototype.generateImage=function(e,t){return this.req({method:"post",url:this.join("generate-image"),data:e,timeout:null==t?void 0:t.timeout})},e.prototype.sendMessage=function(e,t){return D(this,void 0,void 0,(function(){var r;return j(this,(function(n){switch(n.label){case 0:return[4,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/send-message")),data:e,stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return r=n.sent(),[2,new B(r)]}}))}))},e.prototype.join=function(e){return"".concat(this.baseUrl,"/").concat(e)},e}(),B=function(){function e(e){var t=T(e);this._eventSourceStream=t.pipeThrough(new A).pipeThrough(O())}return Object.defineProperty(e.prototype,"teeedStream",{get:function(){var e=this._eventSourceStream.tee(),t=e[0],r=e[1];return this._eventSourceStream=r,t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"eventSourceStream",{get:function(){return R(this.teeedStream)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dataStream",{get:function(){return R(this.eventSourceStream.pipeThrough(new I({transform:function(e,t){try{var r=JSON.parse(e.data);t.enqueue(r)}catch(r){"[DONE]"!==e.data?console.warn("Error when transforming event source data to json",r,e):t.terminate()}}})))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"textStream",{get:function(){return R(this.dataStream.pipeThrough(new I({transform:function(e,t){var r;t.enqueue(null!==(r=null==e?void 0:e.content)&&void 0!==r?r:"")}})))},enumerable:!1,configurable:!0}),e}(),W=function(){return W=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},W.apply(this,arguments)},F=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},V=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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(e){var t=e.messages,r=e.model,n=e.temperature,o=e.tool_choice,i=e.tools,s=e.top_p;return W(W({},e),{messages:t,model:r,temperature:n,tool_choice:(o&&"auto"!==o&&console.warn("`tool_choice` is not 'auto'"),o),tools:i,top_p:s})}var $=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="zhipu/api/paas/v4/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return F(this,void 0,void 0,(function(){var r,n;return V(this,(function(o){switch(o.label){case 0:return r=H(e),[4,this.req({url:this.url,data:W(W({},r),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return n=o.sent(),[2,W(W({},n),{rawResponse:n})]}}))}))},e.prototype.doStream=function(e,t){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(e),n=null,[4,this.req({url:this.url,data:W(W({},r),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=s.sent(),i=T(o),[2,R(P(i).pipeThrough(new I({transform:function(e,t){var r=e.choices.map((function(e){var t=e.delta;return null==n&&(n=L(t)),n?W(W({},e),{finish_reason:"tool_calls",delta:t}):e})),o=W(W({},e),{choices:r});t.enqueue(W(W({},o),{rawResponse:e}))}})))]}}))}))},e}(),G=function(){return G=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},G.apply(this,arguments)};function z(e){var t=e.messages,r=e.model,n=e.temperature,o=e.tool_choice,i=e.tools,s=e.top_p;return G(G({},e),{messages:(t.forEach((function(e){"tool_calls"in e&&e.tool_calls.filter((function(e){return"function"!==e.type})).forEach((function(t){return console.warn("`type` in tool_call is not 'function'",t,e)}))})),t),model:r,tools:function(){if(i)return i.forEach((function(e){"function"!==e.type&&console.warn("`type` in tool is not 'function'",e)})),i}(),top_p:s,tool_choice:o,temperature:n})}function K(e){return"object"!=typeof e||null==e?e:Array.isArray(e)?e.map((function(e){return K(e)})):Object.entries(e).reduce((function(e,t){var r,n=t[0],o=t[1];return e["_"===(r=n.replace(/[A-Z]/g,(function(e){return"_".concat(e.toLowerCase())}))).charAt(0)?r.slice(1):r]="object"==typeof o?K(o):o,e}),{})}var J=function(){return J=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},J.apply(this,arguments)},Y=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},Q=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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 e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="hunyuan-beta/openapi/v1/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){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({},z(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return r=n.sent(),[2,J(J({},r),{rawResponse:r})]}}))}))},e.prototype.doStream=function(e,t){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({},z(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return n=i.sent(),o=T(n),[2,R(P(o).pipeThrough(new I({transform:function(e,t){var n=e.choices.map((function(e){var t=e.delta;return null==r&&(r=L(t)),r?J(J({},e),{finish_reason:"tool_calls",delta:t}):e})),o=J(J({},e),{choices:n});t.enqueue(J(J({},o),{rawResponse:e}))}})))]}}))}))},e}(),X=function(){return X=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},X.apply(this,arguments)},ee=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},te=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="hunyuan",null!=r&&(this.subUrl=r)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return ee(this,void 0,void 0,(function(){var r,n;return te(this,(function(o){switch(o.label){case 0:return[4,this.req({url:this.url,headers:{"X-Tc-Action":"ChatCompletions"},data:X(X({},z(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return r=o.sent(),n=K(r.Response),[2,X(X({},n),{rawResponse:r})]}}))}))},e.prototype.doStream=function(e,t){return ee(this,void 0,void 0,(function(){var r,n,o;return te(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({},e),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return n=i.sent(),o=T(n),[2,R(P(o).pipeThrough(new I({transform:function(e,t){var n=K(e),o=n.choices.map((function(e){var t=e.delta;return null==r&&(r=L(t)),r?X(X({},e),{finish_reason:"tool_calls",delta:t}):e})),i=X(X({},n),{choices:o});t.enqueue(X(X({},i),{rawResponse:e}))}})))]}}))}))},e}(),ne=function(){return ne=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},ne.apply(this,arguments)},oe=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},ie=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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 se(e){var t=e.messages,r=e.model,n=e.temperature,o=e.tools,i=e.top_p;return ne(ne({},e),{messages:t,model:r,tools:o,top_p:i,temperature:n})}var ae=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="ark/api/v3/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return oe(this,void 0,void 0,(function(){var r;return ie(this,(function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:ne(ne({},se(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return r=n.sent(),[2,ne(ne({},r),{rawResponse:r})]}}))}))},e.prototype.doStream=function(e,t){return oe(this,void 0,void 0,(function(){var r,n,o;return ie(this,(function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:ne(ne({},se(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return n=i.sent(),o=T(n),[2,R(P(o).pipeThrough(new I({transform:function(e,t){var n=e.choices.map((function(e){var t=e.delta;return null==r&&(r=L(t)),r?ne(ne({},e),{finish_reason:"tool_calls",delta:t}):e})),o=ne(ne({},e),{choices:n});t.enqueue(ne(ne({},o),{rawResponse:e}))}})))]}}))}))},e}(),ue=function(){return ue=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},ue.apply(this,arguments)},ce=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},le=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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 fe(e){var t=e.messages,r=e.model,n=e.temperature,o=e.tools,i=e.top_p;return ue(ue({},e),{messages:t,model:r,tools:o,top_p:i,temperature:n})}var de=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="dashscope/compatible-mode/v1/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return ce(this,void 0,void 0,(function(){var r;return le(this,(function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:ue(ue({},fe(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return r=n.sent(),[2,ue(ue({},r),{rawResponse:r})]}}))}))},e.prototype.doStream=function(e,t){return ce(this,void 0,void 0,(function(){var r,n,o;return le(this,(function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:ue(ue({},fe(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return n=i.sent(),o=T(n),[2,R(P(o).pipeThrough(new I({transform:function(e,t){var n=e.choices.map((function(e){var t=Object.assign(e.delta,{role:"assistant"});return null==r&&(r=L(t)),ue(ue({},e),r?{finish_reason:"tool_calls",delta:t}:{delta:t})})),o=ue(ue({},e),{choices:n});t.enqueue(ue(ue({},o),{rawResponse:e}))}})))]}}))}))},e}(),he=function(){return he=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},he.apply(this,arguments)},pe=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},ve=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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 ye(e){var t=e.messages,r=e.model,n=e.temperature,o=e.tools,i=e.top_p;return he(he({},e),{messages:t,model:r,tools:o,top_p:i,temperature:n})}var me=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="01-ai/v1/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return pe(this,void 0,void 0,(function(){var r;return ve(this,(function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:he(he({},ye(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return r=n.sent(),[2,he(he({},r),{rawResponse:r})]}}))}))},e.prototype.doStream=function(e,t){return pe(this,void 0,void 0,(function(){var r,n,o,i,s;return ve(this,(function(a){switch(a.label){case 0:return r=null,[4,this.req({url:this.url,data:he(he({},ye(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return n=a.sent(),o=T(n),i=P(o),s=i.pipeThrough(new I({transform:function(e,t){var n,o,i,s,a,u;if((null===(i=null===(o=null===(n=null==e?void 0:e.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==e?void 0:e.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=e.choices.map((function(e){var t=Object.assign(e.delta,{role:"assistant"});return null==r&&(r=L(t)),he(he({},e),r?{finish_reason:"tool_calls",delta:t}:{delta:t})})),l=he(he({},e),{choices:c});t.enqueue(he(he({},l),{rawResponse:e}))}}})),[2,R(s)]}}))}))},e}(),ge=function(){return ge=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},ge.apply(this,arguments)},be=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},we=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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 _e(e){var t=e.messages,r=e.model,n=e.temperature,o=e.tools,i=e.top_p;return ge(ge({},e),{messages:t,model:r,tools:o,top_p:i,temperature:n})}var Se=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="moonshot/v1/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return be(this,void 0,void 0,(function(){var r;return we(this,(function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:ge(ge({},_e(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return r=n.sent(),[2,ge(ge({},r),{rawResponse:r})]}}))}))},e.prototype.doStream=function(e,t){return be(this,void 0,void 0,(function(){var r,n,o;return we(this,(function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:ge(ge({},_e(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return n=i.sent(),o=T(n),[2,R(P(o).pipeThrough(new I({transform:function(e,t){var n=e.choices.map((function(e){var t=e.delta;return null==r&&(r=L(t)),r?ge(ge({},e),{finish_reason:"tool_calls",delta:t}):e})),o=ge(ge({},e),{choices:n});t.enqueue(ge(ge({},o),{rawResponse:e}))}})))]}}))}))},e}(),Ee=function(){return Ee=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Ee.apply(this,arguments)},Ie=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},Oe=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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])}}},Te=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="hunyuan-exp/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e){return Ie(this,void 0,void 0,(function(){var t;return Oe(this,(function(r){switch(r.label){case 0:return[4,this.req({url:this.url,data:Ee(Ee({},z(e)),{stream:!1}),stream:!1})];case 1:return t=r.sent(),[2,Ee(Ee({},t),{rawResponse:t})]}}))}))},e.prototype.doStream=function(e){return Ie(this,void 0,void 0,(function(){var t,r,n;return Oe(this,(function(o){switch(o.label){case 0:return t=null,[4,this.req({url:this.url,data:Ee(Ee({},z(e)),{stream:!0}),stream:!0})];case 1:return r=o.sent(),n=T(r),[2,R(P(n).pipeThrough(new I({transform:function(e,r){var n=e.choices.map((function(e){var r=e.delta;return null==t&&(t=L(r)),t?Ee(Ee({},e),{finish_reason:"tool_calls",delta:r}):e})),o=Ee(Ee({},e),{choices:n});r.enqueue(Ee(Ee({},o),{rawResponse:e}))}})))]}}))}))},e}(),Ae=function(){return Ae=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Ae.apply(this,arguments)},Re=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},Pe=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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])}}},Ce=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="hunyuan-open/v1/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return Re(this,void 0,void 0,(function(){var r;return Pe(this,(function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:Ae(Ae({},z(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return r=n.sent(),[2,Ae(Ae({},r),{rawResponse:r})]}}))}))},e.prototype.doStream=function(e,t){return Re(this,void 0,void 0,(function(){var r,n,o;return Pe(this,(function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:Ae(Ae({},z(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return n=i.sent(),o=T(n),[2,R(P(o).pipeThrough(new I({transform:function(e,t){var n=e.choices.map((function(e){var t=e.delta;return null==r&&(r=L(t)),r?Ae(Ae({},e),{finish_reason:"tool_calls",delta:t}):e})),o=Ae(Ae({},e),{choices:n});t.enqueue(Ae(Ae({},o),{rawResponse:e}))}})))]}}))}))},e}(),Ne=function(){return Ne=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Ne.apply(this,arguments)},xe=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},Le=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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])}}},Ue=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="deepseek/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return xe(this,void 0,void 0,(function(){var r;return Le(this,(function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:Ne(Ne({},e),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return r=n.sent(),[2,Ne(Ne({},r),{rawResponse:r})]}}))}))},e.prototype.doStream=function(e,t){return xe(this,void 0,void 0,(function(){var r,n,o;return Le(this,(function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:Ne(Ne({},e),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return n=i.sent(),o=T(n),[2,R(P(o).pipeThrough(new I({transform:function(e,t){var n=e.choices.map((function(e){var t=e.delta;return null==r&&(r=L(t)),r?Ne(Ne({},e),{finish_reason:"tool_calls",delta:t}):e})),o=Ne(Ne({},e),{choices:n});t.enqueue(Ne(Ne({},o),{rawResponse:e}))}})))]}}))}))},e}(),ke=function(){return ke=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},ke.apply(this,arguments)},De=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},je=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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])}}},qe=function(){function e(e,t,r){void 0===r&&(r=""),this.req=e,this.baseUrl=t,this.subUrl=r}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e){return De(this,void 0,void 0,(function(){var t;return je(this,(function(r){switch(r.label){case 0:return[4,this.req({url:this.url,data:ke(ke({},e),{stream:!1}),stream:!1})];case 1:return t=r.sent(),[2,ke(ke({},t),{rawResponse:t})]}}))}))},e.prototype.doStream=function(e){return De(this,void 0,void 0,(function(){var t,r,n;return je(this,(function(o){switch(o.label){case 0:return t=null,[4,this.req({url:this.url,data:ke(ke({},e),{stream:!0}),stream:!0})];case 1:return r=o.sent(),n=T(r),[2,R(P(n).pipeThrough(new I({transform:function(e,r){var n=e.choices.map((function(e){var r=e.delta;return null==t&&(t=L(r)),t?ke(ke({},e),{finish_reason:"tool_calls",delta:r}):e})),o=ke(ke({},e),{choices:n});r.enqueue(ke(ke({},o),{rawResponse:e}))}})))]}}))}))},e}(),Me=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.provider=r,this.defaultGenerateImageSubUrl="images/generations",this.generateImageSubUrlConfig={"hunyuan-image":{"hunyuan-image-v3.0-v1.0.4":"images/ar/generations","hunyuan-image-v3.0-v1.0.1":"images/ar/generations"}},this.generateImage=this.generateImageImpl.bind(this)}return e.prototype.generateImageImpl=function(e){var t,r,n,o,i;return r=this,n=void 0,i=function(){var r,n;return function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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){switch(o.label){case 0:return r=this.defaultGenerateImageSubUrl,"object"==typeof e&&e&&"model"in e&&"string"==typeof e.model&&(n=null===(t=this.generateImageSubUrlConfig[this.provider])||void 0===t?void 0:t[e.model])&&(r=n),[4,this.req({url:this.getGenerateUrl(r),data:e,stream:!1})];case 1:return[2,o.sent()]}}))},new((o=void 0)||(o=Promise))((function(e,t){function s(e){try{u(i.next(e))}catch(e){t(e)}}function a(e){try{u(i.throw(e))}catch(e){t(e)}}function u(t){var r;t.done?e(t.value):(r=t.value,r instanceof o?r:new o((function(e){e(r)}))).then(s,a)}u((i=i.apply(r,n||[])).next())}))},e.prototype.getGenerateUrl=function(e){return"".concat(this.baseUrl,"/").concat(this.provider,"/").concat(e)},e}(),Be=function(){return Be=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Be.apply(this,arguments)},We=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},Fe=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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])}}},Ve=function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};function He(e){var t,r=e.onStepFinish,n=e.abortSignal,o=e.maxSteps,i=e.topP,s=e.toolChoice,a=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(e,["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},Be(Be({},a),{tools:null===(t=a.tools)||void 0===t?void 0:t.map((function(e){return"fn"in e?U(e):e})),top_p:null!=i?i:a.top_p,tool_choice:null!=s?s:a.tool_choice})]}var $e=function(){function e(e){this.model=e}return e.prototype.generateText=function(e,t){var r,n;return We(this,void 0,void 0,(function(){var o,i,s,a,u,c,l,f,d,h,p,v,y,m,g,b,w,_,S,E,I,O=this;return Fe(this,(function(T){switch(T.label){case 0:return o=[],i={completion_tokens:0,prompt_tokens:0,total_tokens:0},s=He(e),a=s[0],u=a.onStepFinish,c=a.maxSteps,l=void 0===c?10:c,f=s[1],[4,(d=function(){return O.model.doGenerate(f,t)})()];case 1:h=T.sent(),p=1,h.rawResponse&&o.push(h.rawResponse),v=null,T.label=2;case 2:if(!(p<l&&null!=(v=Ge(h))))return[3,9];y=Ye(h.usage),Qe(i,y),T.label=3;case 3:return T.trys.push([3,7,,8]),[4,Je(v)];case 4:return m=T.sent(),g=h.choices[0],[4,null==u?void 0:u({finishReason:g.finish_reason,messages:f.messages.slice(),text:g.message.content,toolCall:v,toolResult:m,stepUsage:y,totalUsage:Object.assign({},i)})];case 5:return T.sent(),ze(f.messages,g.message,m),[4,d()];case 6:return(h=T.sent()).rawResponse&&o.push(h.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==h?void 0:h.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=_?Ve(Ve([],f.messages,!0),[_],!1):f.messages,I=Ye(h.usage),Qe(i,I),[4,null==u?void 0:u({finishReason:w.finish_reason,messages:E.slice(),text:S,toolCall:Ge(h),toolResult:null,stepUsage:I,totalUsage:Object.assign({},i)})];case 10:return T.sent(),[2,{text:S,messages:E,usage:i,rawResponses:o}]}}))}))},e.prototype.streamText=function(e,t){var r;return We(this,void 0,void 0,(function(){var n,o,i,s,a,u,c,l,f,d,h,p,v,y,m,g,b,w,_,S,E,O,T,A,P,C,N,L,U,k,D,j,q,M,B,W,F=this;return Fe(this,(function(V){switch(V.label){case 0:return n={completion_tokens:0,prompt_tokens:0,total_tokens:0},o=He(e),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,t)})()];case 1:f=V.sent(),d=1,h=null,p=function(){var e=f.tee(),t=e[0],r=e[1];return f=R(t),function(e){var t,r,n,o,i,s,a,u,c,l;return We(this,void 0,void 0,(function(){var f,d,h,p,v,y,m,g,b,w,_,S,E;return Fe(this,(function(I){switch(I.label){case 0:f={completion_tokens:0,prompt_tokens:0,total_tokens:0},d=R(e),p={role:"assistant",content:"",tool_calls:[h={id:"",function:{name:"",arguments:""},type:""}]},I.label=1;case 1:I.trys.push([1,6,7,12]),v=!0,y=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,o){!function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)}(n,o,(t=e[r](t)).done,t.value)}))}}}(d),I.label=2;case 2:return[4,y.next()];case 3:if(m=I.sent(),t=m.done)return[3,5];o=m.value,v=!1;try{if(!(b=null==(g=o)?void 0:g.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)&&(h.id=S.id),(null==S?void 0:S.type)&&(h.type=S.type),(null===(s=null==S?void 0:S.function)||void 0===s?void 0:s.name)&&(h.function.name=S.function.name),(null===(a=null==S?void 0:S.function)||void 0===a?void 0:a.arguments)&&(h.function.arguments+=S.function.arguments),(null===(u=null==g?void 0:g.usage)||void 0===u?void 0:u.completion_tokens)&&(f.completion_tokens=g.usage.completion_tokens),(null===(c=null==g?void 0:g.usage)||void 0===c?void 0:c.prompt_tokens)&&(f.prompt_tokens=g.usage.prompt_tokens),(null===(l=null==g?void 0:g.usage)||void 0===l?void 0:l.total_tokens)&&(f.total_tokens=g.usage.total_tokens)}finally{v=!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]),v||t||!(n=y.return)?[3,9]:[4,n.call(y)];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(v=d<u)?[4,p()]:[3,4];case 3:v=null!=(h=V.sent()),V.label=4;case 4:if(!v)return[3,11];y=h.message,m=h.usage,Qe(n,m),g=null===(r=y.tool_calls)||void 0===r?void 0:r[0],V.label=5;case 5:return V.trys.push([5,9,,10]),[4,Je(g)];case 6:return b=V.sent(),[4,null==s?void 0:s({finishReason:"tool_calls",messages:c.messages.slice(),text:y.content,toolCall:g,toolResult:b,stepUsage:m,totalUsage:Object.assign({},n)})];case 7:return V.sent(),ze(c.messages,y,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:R(S),textStream:R(E.pipeThrough(new I({transform:function(e,t){var r,n,o,i=null===(o=null===(n=null===(r=null==e?void 0:e.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&&t.enqueue(i)}}))),usage:Promise.resolve(n),error:w}];case 10:return[3,2];case 11:return[4,p()];case 12:return(h=V.sent())?(O=h.message,T=h.usage,Qe(n,T),A=Ve(Ve([],c.messages,!0),[O],!1),s({messages:A.slice(),finishReason:"tool_call",stepUsage:T,text:O.content,toolCall:O.tool_calls[0],totalUsage:Object.assign({},n)}),P=f.tee(),C=P[0],N=P[1],[2,{messages:Promise.resolve(Ve(Ve([],c.messages,!0),[O],!1)),dataStream:R(C),textStream:R(N.pipeThrough(new I({transform:function(e,t){var r,n,o,i=null===(o=null===(n=null===(r=null==e?void 0:e.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&&t.enqueue(i)}}))),usage:Promise.resolve(n)}]):(L=x(),U=x(),k={role:"assistant",content:""},D="",j={completion_tokens:0,prompt_tokens:0,total_tokens:0},q=f.pipeThrough(new I({transform:function(e,t){var r,n,o,i,s,a,u,c,l=null===(o=null===(n=null===(r=null==e?void 0:e.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&&(k.content+=l);var f=null===(s=null===(i=null==e?void 0:e.choices)||void 0===i?void 0:i[0])||void 0===s?void 0:s.finish_reason;f&&(D=f),(null===(a=null==e?void 0:e.usage)||void 0===a?void 0:a.completion_tokens)&&(j.completion_tokens=e.usage.completion_tokens),(null===(u=null==e?void 0:e.usage)||void 0===u?void 0:u.prompt_tokens)&&(j.prompt_tokens=e.usage.prompt_tokens),(null===(c=null==e?void 0:e.usage)||void 0===c?void 0:c.total_tokens)&&(j.total_tokens=e.usage.total_tokens),t.enqueue(e)},flush:function(){L.res(Ve(Ve([],c.messages,!0),[k],!1)),Qe(n,j),U.res(Object.assign({},n)),null==s||s({messages:Ve(Ve([],c.messages,!0),[k],!1),finishReason:D,text:k.content,stepUsage:j,totalUsage:Object.assign({},n)})}})),M=q.tee(),B=M[0],W=M[1],[2,{messages:L.promise,dataStream:R(B),textStream:R(W.pipeThrough(new I({transform:function(e,t){var r,n,o,i=null===(o=null===(n=null===(r=null==e?void 0:e.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&&t.enqueue(i)}}))),usage:U.promise}])}}))}))},e}();function Ge(e){var t,r=null===(t=null==e?void 0:e.choices)||void 0===t?void 0:t[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 ze(e,t,r){e.push(t,{role:"tool",tool_call_id:t.tool_calls[0].id,content:JSON.stringify(r)})}var Ke=new Map;function Je(e){return Ke.get(e.function.name)(JSON.parse(e.function.arguments))}function Ye(e){var t,r,n;return{completion_tokens:null!==(t=null==e?void 0:e.completion_tokens)&&void 0!==t?t:0,prompt_tokens:null!==(r=null==e?void 0:e.prompt_tokens)&&void 0!==r?r:0,total_tokens:null!==(n=null==e?void 0:e.total_tokens)&&void 0!==n?n:0}}function Qe(e,t){e.completion_tokens+=t.completion_tokens,e.prompt_tokens+=t.prompt_tokens,e.total_tokens+=t.total_tokens}var Ze={hunyuan:re,"hunyuan-beta":Z,ark:ae,dashscope:de,"01-ai":me,moonshot:Se,zhipu:$,"hunyuan-exp":Te,"hunyuan-open":Ce,deepseek:Ue},Xe=r(3616),et=function(){return et=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},et.apply(this,arguments)},tt=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},rt=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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])}}},nt=Ze,ot=function(){function e(e,t,r){var n=this;this.req=e,this.baseUrl=t,this.modelRequest=function(e){var t=e.url,r=e.data,o=e.headers,i=e.stream,s=e.timeout;return tt(n,void 0,void 0,(function(){var e,n,a,u,c,l,f;return rt(this,(function(d){switch(d.label){case 0:return e={"Content-Type":"application/json"},i&&Object.assign(e,{Accept:"text/event-stream"}),[4,this.req.fetch({method:"post",headers:et(et((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),e),o),body:JSON.stringify(r),url:t,stream:i,timeout:s})];case 1:return n=d.sent(),a=n.data,u=n.header,[2,this.handleResponseData(a,u)]}}))}))},this.botRequest=function(e){var t=e.method,r=e.url,o=e.data,i=void 0===o?{}:o,s=e.headers,a=e.stream,u=e.timeout;return tt(n,void 0,void 0,(function(){var e,n,o,c,l,f,d,h;return rt(this,(function(p){switch(p.label){case 0:return"get"!==t?[3,2]:(e=this.handleResponseData,[4,this.req.fetch({url:"".concat(r,"?").concat((v=i,Object.entries(v).map((function(e){var t=e[0],r=e[1];return"".concat(t,"=").concat(r)})).join("&"))),method:t,headers:s,stream:a,timeout:u})]);case 1:return[2,e.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:et(et((f={},f[null===(d=this.i18n)||void 0===d?void 0:d.LANG_HEADER_KEY]=null===(h=this.i18n)||void 0===h?void 0:h.lang,f),n),s),stream:a,method:t,timeout:u})];case 3:return o=p.sent(),c=o.data,l=o.header,[2,this.handleResponseData(c,l)]}var v}))}))},this.aiBaseUrl="".concat(t,"/ai"),this.aiBotBaseUrl="".concat(t,"/aibot"),this.bot=new M(this.botRequest,this.aiBotBaseUrl),this.i18n=r,Xe.RR.$.on(Xe.RR.P,(function(e){var t;n.i18n=(null===(t=e.data)||void 0===t?void 0:t.i18n)||n.i18n}))}return e.prototype.handleResponseData=function(e,t){var r,n;return tt(this,void 0,void 0,(function(){var o,i;return rt(this,(function(s){switch(s.label){case 0:return o="".concat(this.i18n.t("请检查调用方式,或前往云开发 AI+ 首页查看文档"),":https://tcb.cloud.tencent.com/dev#/ai"),"object"==typeof e&&e&&"then"in e?[4,e]:[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,e];case 2:return(null===(n=null===(r=null==t?void 0:t.get)||void 0===r?void 0:r.call(t,"content-type"))||void 0===n?void 0:n.includes("application/json"))?[4,N(e)]:[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,e]}}))}))},e.prototype.createModel=function(e,t){var r,n=nt[e];if(n)r=new n(this.modelRequest,this.aiBaseUrl);else{var o="string"==typeof(null==t?void 0:t.defaultModelSubUrl)?t.defaultModelSubUrl:"/chat/completions";r=new qe(this.modelRequest,this.aiBaseUrl,"".concat(e).concat(o))}return new $e(r)},e.prototype.registerModel=function(e,t){null==nt[e]?nt[e]=t:console.warn("AI model ".concat(e," already exists!"))},e.prototype.createImageModel=function(e){return new Me(this.modelRequest,this.aiBaseUrl,e)},e.prototype.registerFunctionTool=function(e){Ke.has(e.name)&&console.warn("AI function tool ".concat(e.name," already exists and will be overwritten!")),Ke.set(e.name,e.fn)},e}(),it=function(){},st=function(){return st=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},st.apply(this,arguments)},at=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r},ut=at(o,["MODELS"]),ct=function(e){var t=e.getAccessToken,r=e.req;return{download:r.download,post:r.post,upload:r.upload,fetch:function(e){return n=void 0,o=void 0,s=function(){var n,o,i,s,a;return function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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=e.token,o=e.headers,i=void 0===o?{}:o,s=at(e,["token","headers"]),null==n?[3,1]:(a=n,[3,3]);case 1:return[4,t()];case 2:a=u.sent().accessToken,u.label=3;case 3:return[2,r.fetch(st({headers:st({Authorization:"Bearer ".concat(a)},i)},s))]}}))},new((i=void 0)||(i=Promise))((function(e,t){function r(e){try{u(s.next(e))}catch(e){t(e)}}function a(e){try{u(s.throw(e))}catch(e){t(e)}}function u(t){var n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i((function(e){e(n)}))).then(r,a)}u((s=s.apply(n,o||[])).next())}));var n,o,i,s}}};function lt(e){var t=e.env,r=e.baseUrl,n=e.req,o=e.getAccessToken,i=e.handleReqInstance,s=e.i18n;return new ot(function(){if(null==i){if(null==o)throw new Error("`getAccessToken` is required when `handleReqInstance` is not provided!");return ct({req:n,getAccessToken:o})}return i({req:n})}(),function(){if(null!=r)return r;if(null==t)throw new Error("`env` is required when `baseUrl` is not provided!");return"https://".concat(t,".api.tcloudbasegateway.com/v1")}(),s)}var ft=lt,dt={name:"ai",entity:{ai:function(e){var t,r=this,n=this.request;if(null==n.fetch)throw new Error("cloudbase.request.fetch() unimplemented!");return lt({req:n,baseUrl:null!==(t=null==e?void 0:e.baseUrl)&&void 0!==t?t:function(){var e=r.getEndPointWithKey("GATEWAY"),t=e.BASE_URL,n=e.PROTOCOL;return"".concat(n).concat(t)}(),handleReqInstance:function(e){return e.req},i18n:this.config.i18n})}}};function ht(e){try{e.registerComponent(dt)}catch(e){console.warn(e)}}try{window.registerAi=ht}catch(e){}},7505:function(e,t,r){"use strict";r.r(t),r.d(t,{registerAnalytics:function(){return d}});var n=r(3616),o=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},i=n._G.Sg,s=n._G.vM,a=n.BM.D,u="analytics",c=["mall"],l=new(function(){function e(){}return e.prototype.analytics=function(e){return t=this,r=void 0,o=function(){var t,r,n;return function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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(e){if("Object"!==Object.prototype.toString.call(e).slice(8,-1))return!1;var t=e.report_data,r=e.report_type;return!1!==c.includes(r)&&"Object"===Object.prototype.toString.call(t).slice(8,-1)&&!(void 0!==t.action_time&&!Number.isInteger(t.action_time))&&"string"==typeof t.action_type}(e))throw new Error(JSON.stringify({code:i.INVALID_PARAMS,msg:"[".concat(u,".analytics] invalid report data")}));return t=void 0===e.report_data.action_time?Math.floor(Date.now()/1e3):e.report_data.action_time,r={analytics_scene:e.report_type,analytics_data:Object.assign({},e.report_data,{action_time:t})},n={requestData:r},this.request.send("analytics.report",n),[2]}))},new((n=void 0)||(n=Promise))((function(e,i){function s(e){try{u(o.next(e))}catch(e){i(e)}}function a(e){try{u(o.throw(e))}catch(e){i(e)}}function u(t){var r;t.done?e(t.value):(r=t.value,r instanceof n?r:new n((function(e){e(r)}))).then(s,a)}u((o=o.apply(t,r||[])).next())}));var t,r,n,o},function(e,t,r,n){var o,i=arguments.length,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);i>3&&s&&Object.defineProperty(t,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)],e.prototype,"analytics",null),e}()),f={name:u,entity:{analytics:l.analytics}};try{cloudbase.registerComponent(f)}catch(e){}function d(e){try{e.registerComponent(f)}catch(e){console.warn(e)}}},41:function(e,t,r){"use strict";r.r(t),r.d(t,{generateApis:function(){return l},registerApis:function(){return h}});var n=r(794),o=function(){return o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},o.apply(this,arguments)},i=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},s=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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 a(e,t){var r,a,u,c;return i(this,void 0,void 0,(function(){var i,l,f,d,h,p,v,y,m,g,b,w,_,S,E,I,O,T,A,R,P,C,N;return s(this,(function(s){switch(s.label){case 0:l=(i=e||{}).name,f=i.body,d=i.path,h=void 0===d?"":d,p=i.method,v=void 0===p?"POST":p,y=i.headers,m=void 0===y?{}:y,g=(e||{}).token,b={};try{b=JSON.parse(f)}catch(e){b=f||{}}if(!l)throw new Error(JSON.stringify({code:n.ERRORS.INVALID_PARAMS,msg:"[apis] invalid api name"}));return w="",S=(_=this).gatewayOrigin,E=_.getAccessToken,I=_.env,S?w="".concat(S,"/v1"):this.getEndPointWithKey?(O=this.getEndPointWithKey("GATEWAY"),T=O.BASE_URL,A=O.PROTOCOL,w="".concat(A).concat(T)):w="https://".concat(I,".api.tcloudbasegateway.com/v1"),R="".concat(w,"/apis/").concat(l),P=h.startsWith("/")?h:"/".concat(h),E?[4,E()]:[3,2];case 1:C=s.sent().accessToken,m.Authorization="Bearer ".concat(C),s.label=2;case 2:if(N=["GET","HEAD"].includes(null===(r=null==v?void 0:v.toUpperCase)||void 0===r?void 0:r.call(v)))try{P="".concat(P).concat(P.includes("?")?"&":"?").concat(Object.keys(b).map((function(e){return"".concat(e,"=").concat(b[e])})).join("&"))}catch(e){}return[4,this.request.fetch(o(o(o({url:"".concat(R).concat(P),method:v||"POST",headers:o({"Content-Type":"application/json; charset=utf-8"},m)},N?{}:{body:JSON.stringify(b)}),{token:(null===(a=null==g?void 0:g.trim)||void 0===a?void 0:a.call(g))||(null===(c=null===(u=m.Authorization)||void 0===u?void 0:u.replace)||void 0===c?void 0:c.call(u,/^Bearer /,""))||null}),t))];case 3:return[4,s.sent().data];case 4:return[2,s.sent()]}}))}))}var u=["GET","POST","PUT","DELETE","HEAD","OPTIONS","PATCH","REQUEST"];function c(e){var t=this;return new Proxy({},{get:function(r,n){if("string"!=typeof n)throw new Error("[apis] method must be string");var c=n.toLocaleUpperCase();if(!u.includes(c))throw new Error("[apis] invalid method: ".concat(n));return function(r,n){return i(t,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,a.call(this,o({name:e,method:("REQUEST"===c?r.method:c)||"POST"},r),n)];case 1:return[2,t.sent()]}}))}))}}})}function l(e){var t=this;return Object.keys(e||{}).forEach((function(r){void 0!==e[r]&&(t[r]=e[r])})),new Proxy({},{get:function(e,r){if("string"==typeof r)return c.call(t,r)}})}var f="apis",d={name:f,IIFE:!0,entity:function(){Object.defineProperty(this.prototype,f,{get:function(){return l.call(this)},configurable:!0,enumerable:!0})}};function h(e){try{e.registerComponent(d)}catch(e){console.warn(e)}}try{cloudbase.registerComponent(d)}catch(e){}try{window.registerApis=h}catch(e){}},9917:function(e,t,r){"use strict";r.r(t),r.d(t,{LANGS:function(){return $},cloudbase:function(){return le},default:function(){return fe},getBaseEndPoint:function(){return L}});var n=r(3616),o=function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))},i=n._G.Sg,s={};function a(e,t){var r=t.name,n=t.namespace,a=t.entity,c=t.injectEvents,l=t.IIFE,f=void 0!==l&&l;if(s[r]||n&&e[n])throw new Error(JSON.stringify({code:i.INVALID_OPERATION,msg:"Duplicate component ".concat(r)}));if(f){if(!a||"function"!=typeof a)throw new Error(JSON.stringify({code:i.INVALID_PARAMS,msg:"IIFE component's entity must be a function"}));a.call(e)}if(s[r]=t,n?e.prototype[n]=a:u(e.prototype,a),c){var d=c.bus,h=c.events;if(!d||!h||0===h.length)return;var p=e.prototype.fire||function(){};e.prototype.events||(e.prototype.events={}),(e.prototype.events||{})[r]?e.prototype.events[r].events=o(o([],e.prototype.events[r].events,!0),h,!0):e.prototype.events[r]={bus:d,events:h},e.prototype.fire=function(e,t){p(e,t);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(e)){s.fire(e,t);break}}}}}function u(e,t){if(!(t instanceof Object))return t;switch(t.constructor){case Date:return new Date(t.getTime());case Object:void 0===e&&(e={});break;case Array:e=[];break;default:return t}for(var r=0,n=Object.keys(t);r<n.length;r++){var o=n[r];Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=u(e[o],t[o]))}return e}var c=r(190),l=r(2829),f=function(){return f=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},f.apply(this,arguments)},d={},h=function(){return h=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},h.apply(this,arguments)},p=n.Fs.q,v={},y={};function m(e){var t=e.env,r=e.platformInfo,n={userInfoKey:"".concat("user_info","_").concat(t)};v[t]=v[t]||new p(h(h({},e),{keys:n,platformInfo:r})),y[t]=y[t]||new p(h(h({},e),{keys:n,platformInfo:r,persistence:"local"}))}function g(e){return y[e]}var b=function(){return b=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},b.apply(this,arguments)},w=["ap-shanghai","ap-guangzhou","ap-shenzhen-fsi","ap-shanghai-fsi","ap-nanjing","ap-beijing","ap-chengdu","ap-chongqing","ap-hongkong"],_=n._G.tC,S=n._G.pM,E="",I="@cloudbase/js-sdk";function O(){return E}var T,A=[],R=["env","endPointKey","region"],P="https:";function C(e){return A.find((function(t){return R.filter((function(t){return null!=e[t]})).every((function(r){return t[r]===e[r]}))}))}function N(e){var t,r;e.protocol&&!/:$/.test(e.protocol)&&(e.protocol="".concat(e.protocol,":"));var n=C(e);n?(null!=e.baseUrl&&(n.baseUrl=e.baseUrl),null!=e.protocol&&(n.protocol=e.protocol)):A.push(b(b({},e),{protocol:null!==(t=e.protocol)&&void 0!==t?t:P})),"CLOUD_API"===e.endPointKey&&S(null!==(r=e.protocol)&&void 0!==r?r:P)}function x(e,t,r){return C({env:e,endPointKey:t,region:r})}function L(e,t){void 0===t&&(t="CLOUD_API");var r=x(e,t||"CLOUD_API"),n=r.protocol,o=r.baseUrl;return"".concat(n).concat(o).match(/(http(s)?:)?\/\/([^/?#]*)/)[0]}!function(e){e.NULL="NULL",e.ANONYMOUS="ANONYMOUS",e.WECHAT="WECHAT",e.WECHAT_PUBLIC="WECHAT-PUBLIC",e.WECHAT_OPEN="WECHAT-OPEN",e.CUSTOM="CUSTOM",e.EMAIL="EMAIL",e.USERNAME="USERNAME",e.PHONE="PHONE"}(T||(T={}));var U=function(){return U=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},U.apply(this,arguments)},k=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},D=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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,q=n.P6.genSeqId,M=n.P6.isFormData,B=n.P6.formatUrl,W=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"];function F(e,t,r){var n=e[t];e[t]=function(t){var o={},i={};r.forEach((function(r){var n=r.call(e,t),s=n.data,a=n.headers;Object.assign(o,s),Object.assign(i,a)}));var s=t.data;return s&&(M(s)?Object.keys(o).forEach((function(e){s.append(e,o[e])})):t.data=U(U({},s),o)),t.headers=U(U({},t.headers||{}),i),n.call(e,t)}}function V(){var e=q();return{data:{seqId:e},headers:{"X-SDK-Version":"@cloudbase/js-sdk/".concat(O()),"x-seqid":e}}}var H,$,G=function(){function e(e){var t=this;this.throwWhenRequestFail=!1,this.config=e;var r={timeout:this.config.timeout,timeoutMsg:"[@cloudbase/js-sdk] 请求在".concat(this.config.timeout/1e3,"s内未完成,已中断"),restrictedMethods:["post","put"],auth:e.auth};this.reqClass=new d.adapter.reqClass(r),this.throwWhenRequestFail=e.throw||!1,this.localCache=g(this.config.env),"GATEWAY"!==this.config.endPointMode&&(F(this.reqClass,"post",[V]),F(this.reqClass,"upload",[V]),F(this.reqClass,"download",[V])),n.RR.$.on(n.RR.P,(function(e){var r;t.config.i18n=(null===(r=e.data)||void 0===r?void 0:r.i18n)||t.config.i18n}))}return e.prototype.getAccessToken=function(e){return void 0===e&&(e=null),k(this,void 0,void 0,(function(){var t,r,n;return D(this,(function(o){switch(o.label){case 0:if(null!=e)return[2,e];if(!(t=this.config._fromApp).oauthInstance)throw new Error("you can't request without auth");return r=t.oauthInstance,n=r.oauth2client,[4,this.getOauthAccessTokenV2(n)];case 1:return[2,o.sent().accessToken]}}))}))},e.prototype.getDefaultHeaders=function(){var e,t,r;return(e={})[null===(t=this.config.i18n)||void 0===t?void 0:t.LANG_HEADER_KEY]=null===(r=this.config.i18n)||void 0===r?void 0:r.lang,e["X-SDK-Version"]="@cloudbase/js-sdk/".concat(O()),e},e.prototype.post=function(e,t){return k(this,void 0,void 0,(function(){return D(this,(function(r){switch(r.label){case 0:return[4,this.reqClass.post(U(U({},e),{headers:U(U({},e.headers),this.getDefaultHeaders()),customReqOpts:t}))];case 1:return[2,r.sent()]}}))}))},e.prototype.upload=function(e){return k(this,void 0,void 0,(function(){return D(this,(function(t){switch(t.label){case 0:return[4,this.reqClass.upload(U(U({},e),{headers:U(U({},e.headers),this.getDefaultHeaders())}))];case 1:return[2,t.sent()]}}))}))},e.prototype.download=function(e){return k(this,void 0,void 0,(function(){return D(this,(function(t){switch(t.label){case 0:return[4,this.reqClass.download(U(U({},e),{headers:U(U({},e.headers),this.getDefaultHeaders())}))];case 1:return[2,t.sent()]}}))}))},e.prototype.getBaseEndPoint=function(e){return void 0===e&&(e="CLOUD_API"),L(this.config.env,e)},e.prototype.getOauthAccessTokenV2=function(e){return k(this,void 0,void 0,(function(){var t,r;return D(this,(function(n){switch(n.label){case 0:return[4,e.getAccessToken()];case 1:return t=n.sent(),[4,e.getCredentials()];case 2:return r=n.sent(),[2,{accessToken:t,accessTokenExpire:new Date(r.expires_at).getTime()}]}}))}))},e.prototype.request=function(e,t,r,n){var o,i;return k(this,void 0,void 0,(function(){var s,a,u,c,l,f,d,h,p,v,y,m,g,b,w,_,S,E,I,O,T,A,R;return D(this,(function(P){switch(P.label){case 0:if(P.trys.push([0,4,,5]),s="x-tcb-trace_".concat(this.config.env),a="application/x-www-form-urlencoded",u=U({action:e,dataVersion:"2020-01-10",env:this.config.env},t),-1!==W.indexOf(e))return[3,2];if(!(c=this.config._fromApp).oauthInstance)throw new Error("you can't request without auth");return l=c.oauthInstance,f=l.oauth2client,d=u,[4,this.getOauthAccessTokenV2(f)];case 1:d.access_token=P.sent().accessToken,P.label=2;case 2:return"storage.uploadFile"===e?(h=new FormData,Object.keys(h).forEach((function(e){Object.prototype.hasOwnProperty.call(h,e)&&void 0!==h[e]&&h.append(e,u[e])})),a="multipart/form-data"):(a="application/json;charset=UTF-8",h={},Object.keys(u).forEach((function(e){void 0!==u[e]&&(h[e]=u[e])}))),p={headers:U(U({"content-type":a},this.getDefaultHeaders()),null==r?void 0:r.headers)},(null==r?void 0:r.onUploadProgress)&&(p.onUploadProgress=r.onUploadProgress),this.config.region&&(p.headers["X-TCB-Region"]=this.config.region),(v=this.localCache.getStore(s))&&(p.headers["X-TCB-Trace"]=v),y=void 0!==(null==r?void 0:r.parse)?r.parse:t.parse,m=void 0!==(null==r?void 0:r.inQuery)?r.inQuery:t.inQuery,g=void 0!==(null==r?void 0:r.search)?r.search:t.search,b=U(U({},(null==r?void 0:r.defaultQuery)||{}),{env:this.config.env}),y&&(b.parse=!0),m&&(b=U(U({},m),b)),w=(null==r?void 0:r.endPointMode)||this.config.endPointMode||"CLOUD_API",_=x(this.config.env,w),S=_.baseUrl,E=_.protocol,"GATEWAY"===w&&/^((database)\.)|(auth\.wsWebSign)/.test(e)&&(I=x(this.config.env,"CLOUD_API"),S="".concat(I.baseUrl.match(/\/\/([^/?#]*)/)[0],"/web")),O=void 0,O=r.pathname?B(E,"".concat(null===(o=L(this.config.env,w))||void 0===o?void 0:o.replace(/^https?:/,""),"/").concat(r.pathname),b):B(E,S,b),g&&(O+=g),[4,this.post(U({url:O,data:h},p),n)];case 3:if(T=P.sent(),(A=null===(i=T.header)||void 0===i?void 0:i["x-tcb-trace"])&&this.localCache.setStore(s,A),200!==Number(T.status)&&200!==Number(T.statusCode)||!T.data)throw new Error("network request error");return[2,T];case 4:R=P.sent();try{R.requestId=R.requestId||(null==r?void 0:r.headers["x-request-id"])||(null==r?void 0:r.headers["X-Request-Id"])||""}catch(e){}throw R;case 5:return[2]}}))}))},e.prototype.fetch=function(e){var t,r,n,o,i,s,a,u;return k(this,void 0,void 0,(function(){var c,l,f,d,h,p,v=this;return D(this,(function(y){switch(y.label){case 0:c=e.token,l=e.headers,f=void 0===l?{}:l,d=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(e,["token","headers"]),h=function(){return k(v,void 0,void 0,(function(){var e,t,r,n,o;return D(this,(function(i){switch(i.label){case 0:return t=(e=this.reqClass).fetch,n={},o={"X-SDK-Version":"@cloudbase/js-sdk/".concat(O())},r="Bearer ".concat,[4,this.getAccessToken(c)];case 1:return[2,t.apply(e,[U.apply(void 0,[(n.headers=U.apply(void 0,[U.apply(void 0,[(o.Authorization=r.apply("Bearer ",[i.sent()]),o),this.getDefaultHeaders()]),f]),n),d])])]}}))}))},y.label=1;case 1:return y.trys.push([1,3,,6]),[4,h()];case 2:return[2,y.sent()];case 3:p=y.sent();try{p.requestId=p.requestId||f["x-request-id"]||f["X-Request-Id"]||""}catch(e){}if("ACCESS_TOKEN_EXPIRED"!==(null==p?void 0:p.code))return[3,5];if("function"!=typeof(null===(o=null===(n=null===(r=null===(t=this.config)||void 0===t?void 0:t._fromApp)||void 0===r?void 0:r.oauthInstance)||void 0===n?void 0:n.authApi)||void 0===o?void 0:o.refreshTokenForce))throw p;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 y.sent(),[2,h()];case 5:throw p;case 6:return[2]}}))}))},e.prototype.send=function(e,t,r,n){return void 0===t&&(t={}),void 0===r&&(r={}),k(this,void 0,void 0,(function(){var o;return D(this,(function(i){switch(i.label){case 0:return[4,this.request(e,t,U(U({},r),{onUploadProgress:t.onUploadProgress}),n)];case 1:if((o=i.sent()).data.code&&this.throwWhenRequestFail)throw new Error(JSON.stringify({code:j.OPERATION_FAIL,msg:"[".concat(o.data.code,"] ").concat(o.data.message)}));return[2,o.data]}}))}))},e.prototype.gateWay=function(e,t){var r;return k(this,void 0,void 0,(function(){var o,i,s,a,u,c,l,f,d,h,p,v,y,m,g,b,w,_,S;return D(this,(function(E){switch(E.label){case 0:if(o=e.url,i=e.name,s=e.data,a=e.path,u=void 0===a?"":a,c=e.method,l=e.header,f=void 0===l?{}:l,!(i&&u||o))throw new Error(JSON.stringify({code:j.INVALID_PARAMS,msg:"[gateWay] invalid function name or path or url"}));try{d=s?JSON.stringify(s):""}catch(e){throw new Error(JSON.stringify({code:j.INVALID_PARAMS,msg:"[gateWay] invalid data"}))}if(h=n.P6.generateRequestId(),p=x(this.config.env,"GATEWAY"),v=p.baseUrl,y=p.protocol,m="".concat(y).concat(v).concat(o||"/".concat(u,"/").concat(i)),g=["GET","HEAD"].includes(null===(r=null==c?void 0:c.toUpperCase)||void 0===r?void 0:r.call(c)))try{b={};try{b=JSON.parse(s)}catch(e){b=s||{}}m="".concat(m).concat(m.includes("?")?"&":"?").concat(Object.keys(b).map((function(e){return"".concat(e,"=").concat(b[e])})).join("&"))}catch(e){}return[4,this.fetch(U(U({method:c||"POST",headers:U({"Content-Type":"application/json; charset=utf-8","X-Request-Id":h},f)},g?{}:{body:d}),{url:m,customReqOpts:t}))];case 1:return w=E.sent(),_=[U({requestId:h},w)],S={},[4,w.data];case 2:return[2,U.apply(void 0,_.concat([(S.data=E.sent(),S)]))]}}))}))},e}(),z={};!function(e){e.ZH="zh-CN",e.EN="en-US"}($||($={}));var K=((H={})[$.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"},H),J=function(e,t){var r;return(null===(r=K[t])||void 0===r?void 0:r[e])||e},Y=function(e,t){var r,o,i=function(e){return"lang_".concat(e.clientId||e.env)}(t),s=(e.adapter||{}).localStorage,a=t.lang||(null===(r=null==s?void 0:s.getItem)||void 0===r?void 0:r.call(s,i))||$.ZH;return null===(o=null==s?void 0:s.setItem)||void 0===o||o.call(s,i,a),new Proxy({t:function(e){return J(e,a)},LANG_HEADER_KEY:"Accept-Language",lang:a},{get:function(e,t){var r;return"lang"===t&&(null===(r=null==s?void 0:s.getItem)||void 0===r?void 0:r.call(s,i))||e[t]},set:function(e,t,r){var o;return"lang"===t&&r!==e[t]&&(e[t]=r,e.t=function(e){return J(e,r)},null===(o=null==s?void 0:s.setItem)||void 0===o||o.call(s,i,r),n.RR.$.fire(n.RR.P,{i18n:e})),e[t]=r,!0}})},Q=function(){return Q=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Q.apply(this,arguments)},Z=function(e,t,r,n){var o,i=arguments.length,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s},X=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},ee=n.j$.Fk,te=n.j$.xY,re=n._G.Sg,ne=n._G.vM,oe=n.P6.printWarn,ie=n.BM.D,se={timeout:15e3,persistence:"local"},ae=6e5,ue={},ce=function(){function e(e){this.cloudbaseConfig=e||this.cloudbaseConfig,this.authInstance=null,this.oauthInstance=null,this.version=O()}return Object.defineProperty(e.prototype,"config",{get:function(){return this.cloudbaseConfig},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"platform",{get:function(){return d},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cache",{get:function(){return e=this.cloudbaseConfig.env,v[e];var e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"localCache",{get:function(){return g(this.cloudbaseConfig.env)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"request",{get:function(){return e=this.cloudbaseConfig.env,z[e];var e},enumerable:!1,configurable:!0}),e.prototype.init=function(t){var r,n,o;if(void 0===t&&(t={env:""}),t.endPointMode=t.endPointMode||"GATEWAY",d.adapter||this.useDefaultAdapter(),!(t=this.dealNodeAdapterConfig(t)).env)throw new Error(JSON.stringify({code:re.INVALID_PARAMS,msg:"env must not be specified"}));this.isInitialized(t);var i={timeout:t.timeout||15e3,timeoutMsg:"[".concat(I,"][REQUEST TIMEOUT] request had been abort since didn't finished within").concat(t.timeout/1e3,"s"),auth:t.auth};this.requestClient=new d.adapter.reqClass(i),this.cloudbaseConfig=Q(Q(Q({},se),t),{i18n:Y(d,t)}),delete this.cloudbaseConfig.lang,this.cloudbaseConfig.timeout=this.formatTimeout(this.cloudbaseConfig.timeout);var s=this.cloudbaseConfig,a=s.env,u=s.persistence,c=s.debug,l=s.timeout,f=s.oauthClient,h=s.i18n;m({env:a,persistence:u,debug:c,platformInfo:this.platform}),function(e,t){N({env:e,region:t,baseUrl:"//".concat(e,".").concat(t||"ap-shanghai",".tcb-api.tencentcloudapi.com/web"),protocol:void 0,endPointKey:"CLOUD_API"})}(a,t.region||""),function(e,t,r){void 0===r&&(r="ap-shanghai"),r=r||"ap-shanghai";var n="//".concat(e,".api.tcloudbasegateway.com/v1");w.includes(r)||(n="//".concat(e,".api.intl.tcloudbasegateway.com/v1")),N({endPointKey:"GATEWAY",env:e,baseUrl:n,protocol:t})}(a,P,t.region||"");var p=new e(this.cloudbaseConfig);return function(e){z[e.env]=new G(U(U({},e),{throw:!0}))}({env:a,region:t.region||"",timeout:l,oauthClient:f,_fromApp:p,i18n:h,endPointMode:t.endPointMode,auth:t.auth}),p.requestClient=this.requestClient,null===(r=null==this?void 0:this.fire)||void 0===r||r.call(this,"cloudbase_init",p),this.try2InitAuth(p),(null===(n=d.adapter)||void 0===n?void 0:n.nodeTool)&&(null===(o=d.adapter)||void 0===o||o.nodeTool(p,this.cloudbaseConfig)),p},e.prototype.updateConfig=function(e){var t=e.persistence,r=e.debug;this.cloudbaseConfig.persistence=t,this.cloudbaseConfig.debug=r,m({env:this.cloudbaseConfig.env,persistence:t,debug:r,platformInfo:this.platform})},e.prototype.updateLang=function(e){var t;e&&e!==(null===(t=this.cloudbaseConfig.i18n)||void 0===t?void 0:t.lang)&&(this.cloudbaseConfig.i18n.lang=e)},e.prototype.registerExtension=function(e){ue[e.name]=e},e.prototype.invokeExtension=function(e,t){return r=this,n=void 0,i=function(){var r;return function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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=ue[e]))throw new Error(JSON.stringify({code:re.INVALID_PARAMS,msg:"extension:".concat(e," must be registered before invoke")}));return[4,r.invoke(t,this)];case 1:return[2,n.sent()]}}))},new((o=void 0)||(o=Promise))((function(e,t){function s(e){try{u(i.next(e))}catch(e){t(e)}}function a(e){try{u(i.throw(e))}catch(e){t(e)}}function u(t){var r;t.done?e(t.value):(r=t.value,r instanceof o?r:new o((function(e){e(r)}))).then(s,a)}u((i=i.apply(r,n||[])).next())}));var r,n,o,i},e.prototype.useAdapters=function(e,t){var r=ee(e,t)||{},n=r.adapter,o=r.runtime;n&&(d.adapter=n),o&&(d.runtime=o)},e.prototype.registerHook=function(t){!function(e,t){var r=t.entity,n=t.target;if(Object.prototype.hasOwnProperty.call(e,n))throw new Error(JSON.stringify({code:i.INVALID_OPERATION,msg:"target:".concat(n," is not exist")}));var s=e.prototype[n];if("function"!=typeof s)throw new Error(JSON.stringify({code:i.INVALID_OPERATION,msg:"target:".concat(n," is not a function which is the only type supports hook")}));e.prototype[n]=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return r.call.apply(r,o([this],e,!1)),s.call.apply(s,o([this],e,!1))}}(e,t)},e.prototype.registerComponent=function(t){a(e,t)},e.prototype.registerVersion=function(e){!function(e){E=e}(e),this.version=e},e.prototype.registerSdkName=function(e){!function(e){I=e,_(e)}(e)},e.prototype.isInitialized=function(e){return void 0===e&&(e=this.cloudbaseConfig),["your-env-id","your-envid","your_env_id","xxx-yyy","xxxx-yyy","envId","env-id","your-environment-id","REPLACE_ME"].some((function(t){return e.env.toLowerCase()===t.toLowerCase()}))&&oe(re.INVALID_PARAMS,'[CloudBase] 检测到环境 ID "'.concat(e.env,'" 可能是占位符,请替换为真实的环境 ID。\n')+" 获取方式:登录腾讯云开发平台 → 环境管理 → 环境设置 → 环境 ID\n 建议通过环境变量配置:process.env.CLOUDBASE_ENV 或 import.meta.env.VITE_CLOUDBASE_ENV"),!!(null==e?void 0:e.env)},e.prototype.registerEndPoint=function(e,t){N({baseUrl:e,protocol:t,env:this.config.env,endPointKey:"CLOUD_API"})},e.prototype.registerEndPointWithKey=function(e){N({env:this.config.env,endPointKey:e.key,baseUrl:e.url,protocol:e.protocol})},e.prototype.getEndPointWithKey=function(e){var t=x(this.config.env,e);return{BASE_URL:t.baseUrl,PROTOCOL:t.protocol}},e.prototype.parseCaptcha=function(e){return n.P6.parseCaptcha(e)},e.prototype.useDefaultAdapter=function(){var e=te.bind(this)(),t=e.adapter,r=e.runtime;d.adapter=t,d.runtime=r},e.prototype.formatTimeout=function(e){switch(!0){case e>ae:return oe(re.INVALID_PARAMS,"timeout is greater than maximum value[10min]"),ae;case e<100:return oe(re.INVALID_PARAMS,"timeout is less than maximum value[100ms]"),100;default:return e}},e.prototype.try2InitAuth=function(e){try{e.auth()}catch(e){console.log("try2InitAuth error:",e)}},e.prototype.dealNodeAdapterConfig=function(e){return e},Z([ie({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(ne)]}),X("design:type",Function),X("design:paramtypes",[Object]),X("design:returntype",e)],e.prototype,"init",null),Z([ie({title:"调用扩展能力失败",messages:["请确认以下各项:"," 1 - 调用 invokeExtension() 的语法或参数是否正确"," 2 - 被调用的扩展能力是否已经安装并通过 registerExtension() 注册","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(ne)]}),X("design:type",Function),X("design:paramtypes",[String,Object]),X("design:returntype",Promise)],e.prototype,"invokeExtension",null),e}(),le=new ce;le.useAdapters((c.x5.prototype.upload=function(e){var t=this,r=this;return new Promise((function(n){var o=e.url,i=e.file,s=e.data,a=e.headers,u=wx.getFileSystemManager(),c=wx.request({url:o,method:e.method,header:f({"content-type":" "},a),data:u.readFileSync(i),timeout:t._timeout,success:function(e){var t={statusCode:e.statusCode,data:e.data||{}};200===e.statusCode&&(null==s?void 0:s.success_action_status)&&(t.statusCode=parseInt(s.success_action_status,10)),n(t)},fail:function(e){n(e)},complete:function(e){if((null==e?void 0:e.errMsg)&&r._timeout&&-1!==r._restrictedMethods.indexOf("upload")&&"request:fail timeout"===e.errMsg){console.warn(r._timeoutMsg);try{c.abort()}catch(e){}}}})}))},c.ZP.genAdapter=function(e){return{root:{globalThis:{}},reqClass:c.x5,wsClass:c.ng,captchaOptions:{openURIWithCallback:function(t){var r=e.EventBus,n={},o=t;console.log("openURIWithCallback",t);var i=t.match(/^(data:.*?)(\?[^#\s]*)?$/);if(i){o=i[1],console.log("openURIWithCallback url",o);var s=i[2];s&&(n=(0,c.dD)(s))}console.log("openURIWithCallback queryObj",n);var a=n.token,u=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(n,["token"]);return/^data:/.test(o)&&!a?Promise.reject({error:"invalid_argument",error_description:"invalie captcha data: ".concat(t)}):a?new Promise((function(e){console.log("wait for captcha..."),r.$emit("CAPTCHA_DATA_CHANGE",f(f({},u),{token:a,url:o})),r.$once("RESOLVE_CAPTCHA_DATA",(function(t){e(t)}))})):Promise.reject({error:"unimplemented",error_description:"need to impl captcha data"})}},localStorage:c.ap,primaryStorage:l.StorageType.local,getAppSign:function(){var e=wx.getAccountInfoSync();return"undefined"!=typeof App||"undefined"!=typeof getApp||wx.onAppHide||wx.offAppHide||wx.onAppShow||wx.offAppShow?e&&e.miniProgram?e.miniProgram.appId:"":e&&e.plugin?e.plugin.appId:""}}},c.ZP));var fe=le},6334:function(e,t,r){"use strict";r.r(t),r.d(t,{AnonymousAuthProvider:function(){return Fe},Auth:function(){return et},AuthError:function(){return ce},AuthErrorCategory:function(){return ie},CustomAuthProvider:function(){return We},LoginState:function(){return Xe},User:function(){return Ze},WeixinAuthProvider:function(){return Be},generateAuthInstance:function(){return tt},registerAuth:function(){return it}});var n,o,i,s,a,u="/auth";!function(e){e.AUTH_SIGN_UP_URL="/v1/signup",e.AUTH_TOKEN_URL="/v1/token",e.AUTH_REVOKE_URL="/v1/revoke",e.WEDA_USER_URL="/v1/plugin/weda/userinfo",e.AUTH_RESET_PASSWORD="/v1/reset",e.AUTH_GET_DEVICE_CODE="/v1/device/code",e.CHECK_USERNAME="/v1/checkUsername",e.CHECK_IF_USER_EXIST="/v1/checkIfUserExist",e.GET_PROVIDER_TYPE="/v1/mgr/provider/providerSubType",e.AUTH_SIGN_IN_URL="/v1/signin",e.AUTH_SIGN_IN_ANONYMOUSLY_URL="/v1/signin/anonymously",e.AUTH_SIGN_IN_WITH_PROVIDER_URL="/v1/signin/with/provider",e.AUTH_SIGN_IN_WITH_WECHAT_URL="/v1/signin/wechat/noauth",e.AUTH_SIGN_IN_CUSTOM="/v1/signin/custom",e.PROVIDER_TOKEN_URL="/v1/provider/token",e.PROVIDER_URI_URL="/v1/provider/uri",e.USER_ME_URL="/v1/user/me",e.AUTH_SIGNOUT_URL="/v1/user/signout",e.USER_QUERY_URL="/v1/user/query",e.USER_PRIFILE_URL="/v1/user/profile",e.USER_BASIC_EDIT_URL="/v1/user/basic/edit",e.USER_TRANS_BY_PROVIDER_URL="/v1/user/trans/by/provider",e.PROVIDER_LIST="/v1/user/provider",e.PROVIDER_BIND_URL="/v1/user/provider/bind",e.PROVIDER_UNBIND_URL="/v1/user/provider",e.CHECK_PWD_URL="/v1/user/sudo",e.SUDO_URL="/v1/user/sudo",e.BIND_CONTACT_URL="/v1/user/contact",e.AUTH_SET_PASSWORD="/v1/user/password",e.AUTHORIZE_DEVICE_URL="/v1/user/device/authorize",e.AUTHORIZE_URL="/v1/user/authorize",e.AUTHORIZE_INFO_URL="/v1/user/authorize/info",e.AUTHORIZED_DEVICES_DELETE_URL="/v1/user/authorized/devices/",e.AUTH_REVOKE_ALL_URL="/v1/user/revoke/all",e.GET_USER_BEHAVIOR_LOG="/v1/user/security/history",e.VERIFICATION_URL="/v1/verification",e.VERIFY_URL="/v1/verification/verify",e.CAPTCHA_DATA_URL="/v1/captcha/data",e.VERIFY_CAPTCHA_DATA_URL="/v1/captcha/data/verify",e.GET_CAPTCHA_URL="/v1/captcha/init",e.GET_MINIPROGRAM_QRCODE="/v1/qrcode/generate",e.GET_MINIPROGRAM_QRCODE_STATUS="/v1/qrcode/get/status"}(n||(n={})),function(e){e.AUTH_SIGN_IN_URL="/v2/signin/username",e.AUTH_TOKEN_URL="/v2/token",e.USER_ME_URL="/v2/user/me",e.VERIFY_URL="/v2/signin/verificationcode",e.AUTH_SIGN_IN_WITH_PROVIDER_URL="/v2/signin/with/provider",e.AUTH_PUBLIC_KEY="/v2/signin/publichkey",e.AUTH_RESET_PASSWORD="/v2/signin/password/update"}(o||(o={})),function(e){e.REGISTER="REGISTER",e.SIGN_IN="SIGN_IN",e.PASSWORD_RESET="PASSWORD_RESET",e.EMAIL_ADDRESS_CHANGE="EMAIL_ADDRESS_CHANGE",e.PHONE_NUMBER_CHANGE="PHONE_NUMBER_CHANGE"}(i||(i={})),(a=s||(s={})).UNREACHABLE="unreachable",a.LOCAL="local",a.CANCELLED="cancelled",a.UNKNOWN="unknown",a.UNAUTHENTICATED="unauthenticated",a.RESOURCE_EXHAUSTED="resource_exhausted",a.FAILED_PRECONDITION="failed_precondition",a.INVALID_ARGUMENT="invalid_argument",a.DEADLINE_EXCEEDED="deadline_exceeded",a.NOT_FOUND="not_found",a.ALREADY_EXISTS="already_exists",a.PERMISSION_DENIED="permission_denied",a.ABORTED="aborted",a.OUT_OF_RANGE="out_of_range",a.UNIMPLEMENTED="unimplemented",a.INTERNAL="internal",a.UNAVAILABLE="unavailable",a.DATA_LOSS="data_loss",a.INVALID_PASSWORD="invalid_password",a.PASSWORD_NOT_SET="password_not_set",a.INVALID_STATUS="invalid_status",a.USER_PENDING="user_pending",a.USER_BLOCKED="user_blocked",a.INVALID_VERIFICATION_CODE="invalid_verification_code",a.TWO_FACTOR_REQUIRED="two_factor_required",a.INVALID_TWO_FACTOR="invalid_two_factor",a.INVALID_TWO_FACTOR_RECOVERY="invalid_two_factor_recovery",a.UNDER_REVIEW="under_review",a.INVALID_REQUEST="invalid_request",a.UNAUTHORIZED_CLIENT="unauthorized_client",a.ACCESS_DENIED="access_denied",a.UNSUPPORTED_RESPONSE_TYPE="unsupported_response_type",a.INVALID_SCOPE="invalid_scope",a.INVALID_GRANT="invalid_grant",a.SERVER_ERROR="server_error",a.TEMPORARILY_UNAVAILABLE="temporarily_unavailable",a.INTERACTION_REQUIRED="interaction_required",a.LOGIN_REQUIRED="login_required",a.ACCOUNT_SELECTION_REQUIRED="account_selection_required",a.CONSENT_REQUIRED="consent_required",a.INVALID_REQUEST_URI="invalid_request_uri",a.INVALID_REQUEST_OBJECT="invalid_request_object",a.REQUEST_NOT_SUPPORTED="request_not_supported",a.REQUEST_URI_NOT_SUPPORTED="request_uri_not_supported",a.REGISTRATION_NOT_SUPPORTED="registration_not_supported",a.CAPTCHA_REQUIRED="captcha_required",a.CAPTCHA_INVALID="captcha_invalid",a.PROVIDER_NOT_ENABLED="provider_not_enabled",a.LOGIN_METHOD_DISABLED="login_method_disabled",a.INVALID_USERNAME_OR_PASSWORD="invalid_username_or_password",a.INVALID_CREDENTIALS="invalid_credentials",a.WRONG_PASSWORD="wrong_password",a.USER_NOT_FOUND="user_not_found";var c,l="credentials_error",f={SIGNED_OUT:"SIGNED_OUT",SIGNED_IN:"SIGNED_IN",INITIAL_SESSION:"INITIAL_SESSION",PASSWORD_RECOVERY:"PASSWORD_RECOVERY",TOKEN_REFRESHED:"TOKEN_REFRESHED",USER_UPDATED:"USER_UPDATED",BIND_IDENTITY:"BIND_IDENTITY"},d={LOGIN_STATE_CHANGED:"loginStateChanged",AUTH_STATE_CHANGED:"authStateChanged"},h={SIGN_IN:"sign_in",BIND_IDENTITY:"bind_identity"},p="node-sdk-scope";function v(){return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(e=>{var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}!function(e){e.CLIENT_ID="client_id",e.CLIENT_SECRET="client_secret",e.RESPONSE_TYPE="response_type",e.SCOPE="scope",e.STATE="state",e.REDIRECT_URI="redirect_uri",e.ERROR="error",e.ERROR_DESCRIPTION="error_description",e.ERROR_URI="error_uri",e.GRANT_TYPE="grant_type",e.CODE="code",e.ACCESS_TOKEN="access_token",e.TOKEN_TYPE="token_type",e.EXPIRES_IN="expires_in",e.USERNAME="username",e.PASSWORD="password",e.REFRESH_TOKEN="refresh_token"}(c||(c={}));var y=r(4655);function m(e,t,r,n,o,i,s){try{var a=e[i](s),u=a.value}catch(e){return void r(e)}a.done?t(u):Promise.resolve(u).then(n,o)}function g(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function s(e){m(i,n,o,s,a,"next",e)}function a(e){m(i,n,o,s,a,"throw",e)}s(void 0)}))}}var b=new Map;class w{constructor(e){this.clientId=(null==e?void 0:e.clientId)||"",b=b||new Map}run(e,t){var r=this;return g((function*(){e="".concat(r.clientId,"_").concat(e);var n=b.get(e);return n||(n=new Promise(((n,o)=>{g((function*(){try{yield r.runIdlePromise();var i=t();n(yield i)}catch(e){o(e)}finally{b.delete(e)}}))()})),b.set(e,n)),n}))()}runIdlePromise(){return Promise.resolve()}}var _="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",S=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/,E=function(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!S.test(e))throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");var t;e+="==".slice(2-(3&e.length));for(var r,n,o="",i=0;i<e.length;)t=_.indexOf(e.charAt(i++))<<18|_.indexOf(e.charAt(i++))<<12|(r=_.indexOf(e.charAt(i++)))<<6|(n=_.indexOf(e.charAt(i++))),o+=64===r?String.fromCharCode(t>>16&255):64===n?String.fromCharCode(t>>16&255,t>>8&255):String.fromCharCode(t>>16&255,t>>8&255,255&t);return o};function I(){if("undefined"==typeof globalThis)return!1;var{wx:e}=globalThis;if(void 0===e)return!1;if(void 0===globalThis.Page)return!1;if(!e.getDeviceInfo)return!1;if(!e.getStorageSync)return!1;if(!e.setStorageSync)return!1;if(!e.connectSocket)return!1;if(!e.request)return!1;try{if(!e.getDeviceInfo())return!1;if("qq"===e.getDeviceInfo().platform)return!1}catch(e){return!1}return!0}var O=!1;function T(){O=O||void 0!==typeof window&&"miniprogram"===window.__wxjs_environment}try{I()||(O=O||!!navigator.userAgent.match(/miniprogram/i)||"miniprogram"===window.__wxjs_environment,window&&window.WeixinJSBridge&&window.WeixinJSBridge.invoke?T():"undefined"!=typeof document&&document.addEventListener("WeixinJSBridgeReady",T,!1))}catch(e){}var A=r(3616);function R(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function P(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?R(Object(r),!0).forEach((function(t){C(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):R(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function C(e,t,r){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function N(e,t,r,n,o,i,s){try{var a=e[i](s),u=a.value}catch(e){return void r(e)}a.done?t(u):Promise.resolve(u).then(n,o)}function x(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function s(e){N(i,n,o,s,a,"next",e)}function a(e){N(i,n,o,s,a,"throw",e)}s(void 0)}))}}var L="x-request-id",U="x-device-id",k="device_id",D=function(){var e=x((function*(e,t){var r=null,n=null;try{var o=Object.assign({},t);o.method||(o.method="GET"),o.body&&"string"!=typeof o.body&&(o.body=JSON.stringify(o.body));var i=yield fetch(e,o),a=yield i.json();null!=a&&a.error?(n=a).error_uri=new URL(e).pathname:r=a}catch(t){n={error:s.UNREACHABLE,error_description:t.message,error_uri:new URL(e).pathname}}if(n)throw n;return r}));return function(t,r){return e.apply(this,arguments)}}(),j=new class{constructor(e){this._env=(null==e?void 0:e.env)||""}getItem(e){var t=this;return x((function*(){return window.localStorage.getItem("".concat(e).concat(t._env))}))()}removeItem(e){var t=this;return x((function*(){window.localStorage.removeItem("".concat(e).concat(t._env))}))()}setItem(e,t){var r=this;return x((function*(){window.localStorage.setItem("".concat(e).concat(r._env),t)}))()}getItemSync(e){return window.localStorage.getItem("".concat(e).concat(this._env))}removeItemSync(e){window.localStorage.removeItem("".concat(e).concat(this._env))}setItemSync(e,t){window.localStorage.setItem("".concat(e).concat(this._env),t)}};function q(e){var t=!0;return null!=e&&e.expires_at&&null!=e&&e.access_token&&(t=e.expires_at<new Date),t}class M{constructor(e){this.credentials=null,this.accessKeyCredentials=null,this.singlePromise=null,this.tokenSectionName=e.tokenSectionName,this.storage=e.storage,this.clientId=e.clientId,this.singlePromise=new w({clientId:this.clientId}),this.credentials=e.credentials||null}getStorageCredentialsSync(){var e=null,t=this.storage.getItemSync(this.tokenSectionName);if(null!=t)try{var r;null!==(r=e=JSON.parse(t))&&void 0!==r&&r.expires_at&&(e.expires_at=new Date(e.expires_at))}catch(t){this.storage.removeItem(this.tokenSectionName),e=null}return e}setCredentials(e){var t=this;return x((function*(){if(null!=e&&e.expires_in){if(null!=e&&e.expires_at||(e.expires_at=new Date(Date.now()+1e3*(e.expires_in-30))),t.storage){var r=JSON.stringify(e);yield t.storage.setItem(t.tokenSectionName,r)}t.credentials=e}else t.storage&&(yield t.storage.removeItem(t.tokenSectionName)),t.credentials=null}))()}setAccessKeyCredentials(e){this.accessKeyCredentials=e,e.scope===p&&(this.credentials=e)}getCredentials(){var e=this;return x((function*(){return e.singlePromise.run("getCredentials",x((function*(){if(q(e.credentials)){var{credentials:t,isAccessKeyCredentials:r}=yield e.getStorageCredentials();if(r)return t;e.credentials=t}return e.credentials})))}))()}getStorageCredentials(){var e=this;return x((function*(){return e.singlePromise.run("_getStorageCredentials",x((function*(){var t=null,r=!1,n=yield e.storage.getItem(e.tokenSectionName);if(n)try{var o;null!==(o=t=JSON.parse(n))&&void 0!==o&&o.expires_at&&(t.expires_at=new Date(t.expires_at))}catch(r){yield e.storage.removeItem(e.tokenSectionName),t=null}else t=e.accessKeyCredentials||null,r=!0;return{credentials:t,isAccessKeyCredentials:r}})))}))()}}class B{constructor(e){var t;this.initializePromise=null,this.lockAcquired=!1,this.pendingInLock=[],this.singlePromise=null,e.clientSecret||(e.clientSecret=""),!e.clientId&&e.env&&(e.clientId=e.env),this.apiOrigin=e.apiOrigin,this.apiPath=e.apiPath||u,this.clientId=e.clientId,this.i18n=e.i18n,this.eventBus=e.eventBus,this.singlePromise=new w({clientId:this.clientId}),this.retry=this.formatRetry(e.retry,B.defaultRetry),e.baseRequest?this.baseRequest=e.baseRequest:this.baseRequest=D,this.tokenInURL=e.tokenInURL,this.headers=e.headers,this.storage=e.storage||j,this.localCredentials=new M({tokenSectionName:"credentials_".concat(e.clientId),storage:this.storage,clientId:e.clientId}),this.clientSecret=e.clientSecret,e.clientId&&(this.basicAuth="Basic ".concat(function(e){for(var t,r,n,o,i="",s=0,a=(e=String(e)).length%3;s<e.length;){if((r=e.charCodeAt(s++))>255||(n=e.charCodeAt(s++))>255||(o=e.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+=_.charAt((t=r<<16|n<<8|o)>>18&63)+_.charAt(t>>12&63)+_.charAt(t>>6&63)+_.charAt(63&t)}return a?i.slice(0,a-3)+"===".substring(a):i}("".concat(e.clientId,":").concat(this.clientSecret)))),this.wxCloud=e.wxCloud;try{I()&&(this.useWxCloud=e.useWxCloud,void 0===this.wxCloud&&e.env&&(wx.cloud.init({env:e.env}),this.wxCloud=wx.cloud))}catch(e){}this.refreshTokenFunc=e.refreshTokenFunc||this.defaultRefreshTokenFunc,this.anonymousSignInFunc=e.anonymousSignInFunc,this.onCredentialsError=e.onCredentialsError,this.getInitialSession=e.getInitialSession,this.onInitialSessionObtained=e.onInitialSessionObtained,this.logDebugMessages=null!==(t=e.debug)&&void 0!==t&&t,A.RR.$.on(A.RR.P,(e=>{var t;this.i18n=(null===(t=e.data)||void 0===t?void 0:t.i18n)||this.i18n}))}setGetInitialSession(e){this.getInitialSession=e}setOnInitialSessionObtained(e){this.onInitialSessionObtained=e}initialize(e){var t=this;return x((function*(){return t.initializePromise?yield t.initializePromise:void 0!==e?(t.initializePromise=e,yield t.initializePromise):(t.initializePromise=x((function*(){return yield t._acquireLock(-1,x((function*(){return yield t._initialize()})))}))(),yield t.initializePromise)}))()}setCredentials(e){var t=this;return x((function*(){return yield t.initializePromise,t._acquireLock(-1,x((function*(){return t.localCredentials.setCredentials(e)})))}))()}setAccessKeyCredentials(e){return this.localCredentials.setAccessKeyCredentials(e)}getAccessToken(){var e=this;return x((function*(){yield e.initializePromise;var t=yield e.getCredentials();if((null==t?void 0:t.scope)===p)return Promise.resolve(t.access_token);if(null!=t&&t.access_token)return Promise.resolve(t.access_token);var r={error:s.UNAUTHENTICATED};return Promise.reject(r)}))()}request(e,t){var r=this;return x((function*(){var n,o,i,a;t||(t={});var u=r.formatRetry(t.retry,r.retry);if(t.headers=P(P({},t.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&&(t.headers=P(P({},r.headers),t.headers)),t.headers[L]||(t.headers[L]=v()),!t.headers[U]){var c=yield r.getDeviceId();t.headers[U]=c}if(null!==(i=t)&&void 0!==i&&i.withBasicAuth&&r.basicAuth&&(t.headers.Authorization=r.basicAuth),null!==(a=t)&&void 0!==a&&a.withCredentials){var l=t.getCredentials?yield t.getCredentials():yield r.getCredentials();l&&(r.tokenInURL?(e.indexOf("?")<0&&(e+="?"),e+="access_token=".concat(l.access_token)):t.headers.Authorization="".concat(l.token_type," ").concat(l.access_token))}else r.clientId&&e.indexOf("client_id")<0&&(e+=e.indexOf("?")<0?"?":"&",e+="client_id=".concat(r.clientId));e.startsWith("/")&&(e="".concat(r.apiOrigin).concat(r.apiPath).concat(e));for(var f=null,d=u+1,h=0;h<d;h++){try{var p;if(null!==(p=f=t.useWxCloud||r.useWxCloud?yield r.wxCloudCallFunction(e,t):yield r.baseRequest(e,t))&&void 0!==p&&p.code)throw{error:f.code,error_description:f.message,error_uri:new URL(e).pathname};break}catch(e){try{e.requestId=e.requestId||t.headers[L]||""}catch(e){}if(t.withCredentials&&e&&e.error===s.UNAUTHENTICATED)return yield r.setCredentials(null),Promise.reject(e);if(h===u||!e||"unreachable"!==e.error)return Promise.reject(e)}yield r.sleep(B.retryInterval)}return f}))()}wxCloudCallFunction(e,t){var r=this;return x((function*(){var n=null,o=null;try{var i,a="";try{a=yield wx.getRendererUserAgent()}catch(e){}var{result:u}=yield r.wxCloud.callFunction({name:"httpOverCallFunction",data:{url:e,method:t.method,headers:P({origin:"https://servicewechat.com","User-Agent":a},t.headers),body:t.body}});null!=u&&null!==(i=u.body)&&void 0!==i&&i.error_code?(o=null==u?void 0:u.body).error_uri=(0,y.y)(e):n=null==u?void 0:u.body}catch(t){o={error:s.UNREACHABLE,error_description:t.message,error_uri:(0,y.y)(e)}}if(o)throw o;return n}))()}getCredentials(){var e=this;return x((function*(){return yield e.initializePromise,e._acquireLock(-1,x((function*(){return e._getCredentials()})))}))()}getCredentialsSync(){return this.localCredentials.getStorageCredentialsSync()}getCredentialsAsync(){return this.getCredentials()}getScope(){var e=this;return x((function*(){var t=yield e.localCredentials.getCredentials();if(!t){var r,n="credentials not found";return null===(r=e.onCredentialsError)||void 0===r||r.call(e,{msg:n}),e.unAuthenticatedError(n)}return t.scope}))()}getGroups(){var e=this;return x((function*(){var t=yield e.localCredentials.getCredentials();if(!t){var r,n="credentials not found";return null===(r=e.onCredentialsError)||void 0===r||r.call(e,{msg:n}),e.unAuthenticatedError(n)}return t.groups}))()}refreshToken(e,t){var r=this;return x((function*(){return yield r.initializePromise,r._acquireLock(-1,x((function*(){return r._refreshToken(e,t)})))}))()}_refreshToken(e,t){var r=this;return x((function*(){return r.singlePromise.run("_refreshToken",x((function*(){if((null==e?void 0:e.scope)===p)return e;if(!e||!e.refresh_token){var n,o="no refresh token found in credentials";return null===(n=r.onCredentialsError)||void 0===n||n.call(r,{msg:o}),r.unAuthenticatedError(o)}try{var i,a=yield r.refreshTokenFunc(e.refresh_token,e);return yield r.localCredentials.setCredentials(a),null===(i=r.eventBus)||void 0===i||i.fire(d.AUTH_STATE_CHANGED,{event:f.TOKEN_REFRESHED}),a}catch(e){var u;if(null!=t&&t.throwError)throw e;if(e.error===s.INVALID_GRANT){var c;yield r.localCredentials.setCredentials(null);var l=e.error_description;return null===(c=r.onCredentialsError)||void 0===c||c.call(r,{msg:l}),r.unAuthenticatedError(l)}return null===(u=r.onCredentialsError)||void 0===u||u.call(r,{msg:e.error_description}),Promise.reject(e)}})))}))()}anonymousLogin(e){var t=this;return x((function*(){return t.singlePromise.run("_anonymousLogin",x((function*(){if(t.anonymousSignInFunc){var r=yield t.anonymousSignInFunc(e);e=r||(yield t.localCredentials.getCredentials())}else e=yield t.anonymousSignIn(e);return e})))}))()}checkRetry(e){var t=null;if(("number"!=typeof e||e<B.minRetry||e>B.maxRetry)&&(t={error:s.UNREACHABLE,error_description:"wrong options param: retry"}),t)throw t;return e}formatRetry(e,t){return void 0===e?t:this.checkRetry(e)}sleep(e){return x((function*(){return new Promise((t=>{setTimeout((()=>{t()}),e)}))}))()}anonymousSignIn(e){var t=this;return x((function*(){return t.singlePromise.run("_anonymous",x((function*(){if(!e||"anonymous"!==e.scope)return t.unAuthenticatedError("no anonymous in credentials");try{var r=yield t.request(n.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",withBasicAuth:!0,body:{}});return yield t.localCredentials.setCredentials(r),r}catch(e){return e.error===s.INVALID_GRANT?(yield t.localCredentials.setCredentials(null),t.unAuthenticatedError(e.error_description)):Promise.reject(e)}})))}))()}defaultRefreshTokenFunc(e,t){var r=this;return x((function*(){if(void 0===e||""===e){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==t?void 0:t.version)&&(a=o.AUTH_TOKEN_URL),P(P({},yield r.request(a,{method:"POST",body:{client_id:r.clientId,client_secret:r.clientSecret,grant_type:"refresh_token",refresh_token:e}})),{},{version:(null==t?void 0:t.version)||"v1"})}))()}getDeviceId(){var e=this;return x((function*(){if(e.deviceID)return e.deviceID;var t=yield e.storage.getItem(k);return"string"==typeof t&&t.length>=16&&t.length<=48||(t=v(),yield e.storage.setItem(k,t)),e.deviceID=t,t}))()}unAuthenticatedError(e){var t={error:s.UNAUTHENTICATED,error_description:e};return Promise.reject(t)}_debug(){if(this.logDebugMessages){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];console.log("[OAuth2Client]",...t)}}_initialize(){var e=this;return x((function*(){try{if(!e.getInitialSession)return e._debug("#_initialize()","no getInitialSession callback set, skipping"),{error:null};e._debug("#_initialize()","calling getInitialSession callback");try{var{data:t,error:r}=yield e.getInitialSession();if(null!=t&&t.session&&(e._debug("#_initialize()","session obtained from getInitialSession",t.session),yield e.localCredentials.setCredentials(null==t?void 0:t.session)),e.onInitialSessionObtained){e._debug("#_initialize()","calling onInitialSessionObtained callback");try{yield e.onInitialSessionObtained(t,r)}catch(t){e._debug("#_initialize()","error in onInitialSessionObtained",t)}}return r?(e._debug("#_initialize()","error from getInitialSession",r),{error:r}):{error:null}}catch(t){return e._debug("#_initialize()","exception during getInitialSession",t),{error:t instanceof Error?t:new Error(String(t))}}}catch(r){return e._debug("#_initialize()","unexpected error",r),{error:r instanceof Error?r:new Error(String(r))}}finally{e._debug("#_initialize()","end")}}))()}_acquireLock(e,t){var r=this;return x((function*(){r._debug("#_acquireLock","begin",e);try{if(r.lockAcquired){var n=r.pendingInLock.length?r.pendingInLock[r.pendingInLock.length-1]:Promise.resolve(),o=x((function*(){return yield n,yield t()}))();return r.pendingInLock.push(x((function*(){try{yield o}catch(e){}}))()),o}r._debug("#_acquireLock","acquiring lock for client",r.clientId);try{r.lockAcquired=!0;var i=t();for(r.pendingInLock.push(x((function*(){try{yield i}catch(e){}}))()),yield i;r.pendingInLock.length;){var s=[...r.pendingInLock];yield Promise.all(s),r.pendingInLock.splice(0,s.length)}return yield i}finally{r._debug("#_acquireLock","releasing lock for client",r.clientId),r.lockAcquired=!1}}finally{r._debug("#_acquireLock","end")}}))()}_getCredentials(){var e=this;return x((function*(){var t=yield e.localCredentials.getCredentials();if(t.scope===p)return t;if(!t){var r,n="credentials not found";return null===(r=e.onCredentialsError)||void 0===r||r.call(e,{msg:n}),e.unAuthenticatedError(n)}if(q(t))if(t.refresh_token)try{t=yield e._refreshToken(t)}catch(r){var o;if("anonymous"!==t.scope)return null===(o=e.onCredentialsError)||void 0===o||o.call(e,{msg:r.error_description}),Promise.reject(r);t=yield e.anonymousLogin(t)}else{if("anonymous"!==t.scope){var i,s="no refresh token found in credentials";return null===(i=e.onCredentialsError)||void 0===i||i.call(e,{msg:s}),e.unAuthenticatedError(s)}t=yield e.anonymousLogin(t)}return t}))()}}B.defaultRetry=2,B.minRetry=0,B.maxRetry=5,B.retryInterval=1e3;var W=r(9689),F=r(5605);function V(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function H(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?V(Object(r),!0).forEach((function(t){$(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):V(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function $(e,t,r){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function G(e,t,r,n,o,i,s){try{var a=e[i](s),u=a.value}catch(e){return void r(e)}a.done?t(u):Promise.resolve(u).then(n,o)}function z(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function s(e){G(i,n,o,s,a,"next",e)}function a(e){G(i,n,o,s,a,"throw",e)}s(void 0)}))}}var K=(e,t)=>{var r;return function(){for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];clearTimeout(r),r=setTimeout((()=>e.apply(null,o)),t)}},J=new W.CloudbaseEventEmitter,Y="resolveCaptchaData",Q="padding:10px 8px;background:#007bff;color:#fff;border:none;border-radius:4px;cursor:pointer;flex:1;white-space:nowrap;margin-left:10px",Z="width:100%;padding:10px;background:#007bff;color:#fff;border:none;border-radius:4px;cursor:pointer",X="background:#6c757d;cursor:not-allowed",ee=e=>{var{oauthInstance:t,captchaState:r}=e,n="captcha-image",o=function(){var e=z((function*(){try{var e=yield t.createCaptchaData({state:r.state});r=H(H({},r),{},{captchaData:e.data,token:e.token}),document.getElementById(n).src=e.data}catch(e){console.error("刷新图形验证码失败",e)}}));return function(){return e.apply(this,arguments)}}(),i=(e,t,r)=>{var n=document.createElement(e);return t&&(n.style.cssText=t),r&&(n.textContent=r),n},s=i("div","position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.5);z-index:999"),a=i("div","position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:320px;padding:20px;background:#fff;border-radius:8px;box-shadow:0 0 10px rgba(0,0,0,0.2);z-index:1000");a.appendChild(i("p","margin-bottom:15px","请输入你看到的字符:"));var u=i("div","display:flex;align-items:center;justify-content:space-between;margin-bottom:15px"),c=i("img","width:100%;height:auto;border:1px solid #eee");c.id=n,c.src=r.captchaData,u.appendChild(c);var l=i("button",Q,"刷新");l.onclick=K(z((function*(){l.textContent="加载中...",l.disabled=!0,l.style.cssText="".concat(Q,";").concat(X);try{yield o()}finally{l.textContent="刷新",l.disabled=!1,l.style.cssText=Q}})),500),u.appendChild(l),a.appendChild(u);var f=i("input","width:100%;padding:14px 16px;margin-bottom:15px;box-sizing:border-box;border:2px solid #e8ecf4;border-radius:10px;font-size:15px");f.type="text",f.placeholder="输入字符",f.maxLength=4,a.appendChild(f);var d=i("div","color:#dc3545;font-size:12px;margin-bottom:10px;display:none;padding:8px;background:#f8d7da;border:1px solid #f5c6cb;border-radius:4px");a.appendChild(d);var h=e=>{d.textContent=e,d.style.display="block"},p=i("button",Z,"确定");p.onclick=K(z((function*(){var e=f.value.trim();if(e){d.style.display="none",p.textContent="验证中...",p.disabled=!0,p.style.cssText="".concat(Z,";").concat(X);try{var n=yield t.verifyCaptchaData({token:r.token,key:e});J.fire(Y,n),console.log("图形验证码校验成功"),document.body.removeChild(s),document.body.removeChild(a)}catch(e){console.error("图形验证码校验失败",e);var i=e.error_description||"图形验证码校验失败";h(i),f.value="",f.focus(),yield o()}finally{p.textContent="确定",p.disabled=!1,p.style.cssText=Z}}else h("请输入字符")})),500),a.appendChild(p),document.body.appendChild(s),document.body.appendChild(a)},te=function(){var e=z((function*(e,t){var{captchaData:r,state:n,token:o}=(0,F.parseCaptcha)(e);return ee({oauthInstance:t,captchaState:{captchaData:r,state:n,token:o}}),new Promise((e=>{console.log("等待图形验证码校验结果..."),J.on(Y,(t=>{e(null==t?void 0:t.data)}))}))}));return function(t,r){return e.apply(this,arguments)}}();function re(e,t,r,n,o,i,s){try{var a=e[i](s),u=a.value}catch(e){return void r(e)}a.done?t(u):Promise.resolve(u).then(n,o)}function ne(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function s(e){re(i,n,o,s,a,"next",e)}function a(e){re(i,n,o,s,a,"throw",e)}s(void 0)}))}}class oe{constructor(e){e.openURIWithCallback||(e.openURIWithCallback=this.getDefaultOpenURIWithCallback()),e.storage||(e.storage=j),this.config=e,this.tokenSectionName="captcha_".concat(e.clientId||e.env)}isMatch(){var e,t;return(null===(e=this.config)||void 0===e||null===(e=e.adapter)||void 0===e||null===(t=e.isMatch)||void 0===t?void 0:t.call(e))||I()}request(e,t){var r=this;return ne((function*(){t||(t={}),t.method||(t.method="GET");var n,o="".concat(t.method,":").concat(e),i=e;t.withCaptcha&&(i=yield r.appendCaptchaTokenToURL(e,o,!1));try{n=yield r.config.request(i,t)}catch(n){return n.error===s.CAPTCHA_REQUIRED||n.error===s.CAPTCHA_INVALID?(e=yield r.appendCaptchaTokenToURL(e,o,n.error===s.CAPTCHA_INVALID),r.config.request(e,t)):Promise.reject(n)}return n}))()}getDefaultOpenURIWithCallback(){return e=>te(e,this.config.oauthInstance)}getCaptchaToken(e,t){var r=this;return ne((function*(){if(!e){var o=yield r.findCaptchaToken();if(o)return o}var i=yield r.config.request(n.CAPTCHA_DATA_URL,{method:"POST",body:{state:t,redirect_uri:""},withCredentials:!1}),s="".concat(i.data,"?state=").concat(encodeURIComponent(t),"&token=").concat(encodeURIComponent(i.token)),a=yield r.config.openURIWithCallback(s);return r.saveCaptchaToken(a),a.captcha_token}))()}appendCaptchaTokenToURL(e,t,r){var n=this;return ne((function*(){var o=yield n.getCaptchaToken(r,t);return e.indexOf("?")>0?e+="&captcha_token=".concat(o):e+="?captcha_token=".concat(o),e}))()}saveCaptchaToken(e){var t=this;return ne((function*(){e.expires_at=new Date(Date.now()+1e3*(e.expires_in-10));var r=JSON.stringify(e);yield t.config.storage.setItem(t.tokenSectionName,r)}))()}findCaptchaToken(){var e=this;return ne((function*(){var t=yield e.config.storage.getItem(e.tokenSectionName);if(null!=t)try{var r=JSON.parse(t);return null!=r&&r.expires_at&&(r.expires_at=new Date(r.expires_at)),r.expires_at<new Date?null:r.captcha_token}catch(t){return yield e.config.storage.removeItem(e.tokenSectionName),null}return null}))()}}var ie,se=class{constructor(e){if(this.params={},"string"==typeof e)this.parse(e);else if(e&&"object"==typeof e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&this.append(t,e[t])}parse(e){e.split("&").forEach((e=>{var[t,r]=e.split("=").map(decodeURIComponent);this.append(t,r)}))}append(e,t){this.params[e]?this.params[e]=this.params[e].concat([t]):this.params[e]=[t]}get(e){return this.params[e]?this.params[e][0]:null}getAll(e){return this.params[e]||[]}delete(e){delete this.params[e]}has(e){return Object.prototype.hasOwnProperty.call(this.params,e)}set(e,t){this.params[e]=[t]}toString(){var e=this,t=[],r=function(r){Object.prototype.hasOwnProperty.call(e.params,r)&&e.params[r].forEach((e=>{t.push("".concat(encodeURIComponent(r),"=").concat(encodeURIComponent(e)))}))};for(var n in this.params)r(n);return t.join("&")}};!function(e){e.PROVIDER_NOT_ENABLED="PROVIDER_NOT_ENABLED",e.INVALID_CREDENTIALS="INVALID_CREDENTIALS",e.USER_NOT_FOUND="USER_NOT_FOUND",e.USER_STATUS_ABNORMAL="USER_STATUS_ABNORMAL",e.SERVICE_ERROR="SERVICE_ERROR",e.INVALID_PARAMS="INVALID_PARAMS",e.AUTH_METHOD_MISMATCH="AUTH_METHOD_MISMATCH",e.UNKNOWN="UNKNOWN"}(ie||(ie={}));var ae="https://tcb.cloud.tencent.com/dev?envId=#/identity/login-manage",ue="https://docs.cloudbase.net/api-reference/webv3-next/initialization";class ce extends Error{constructor(e,t){var r,n=e.error_description||e.message;super(n),this.__isAuthError=!0,this.name="AuthError",this.status=e.error,this.code=e.error_code,this.requestId=e.requestId,this.category=function(e,t){if(!e&&!t)return ie.UNKNOWN;try{var r=(e||"").toLowerCase();return t===s.FAILED_PRECONDITION||t===s.PROVIDER_NOT_ENABLED||t===s.LOGIN_METHOD_DISABLED||r.includes("身份源")||r.includes("开启")||r.includes("identity provider")||r.includes("provider not enabled")||r.includes("login method")||r.includes("登录方式")||r.includes("not enabled")||r.includes("未开启")||r.includes("未启用")||r.includes("请联系开发者")||r.includes("anonymous login is not enabled")||r.includes("匿名登录未开启")?ie.PROVIDER_NOT_ENABLED:t===s.INVALID_PASSWORD||t===s.INVALID_GRANT||t===s.INVALID_VERIFICATION_CODE||t===s.INVALID_USERNAME_OR_PASSWORD||t===s.INVALID_CREDENTIALS||t===s.WRONG_PASSWORD||t===s.UNAUTHENTICATED||t===s.INVALID_TWO_FACTOR||t===s.INVALID_TWO_FACTOR_RECOVERY||t===s.PASSWORD_NOT_SET||r.includes("密码不正确")||r.includes("password")||r.includes("invalid_password")||r.includes("凭据")||r.includes("credentials")||r.includes("验证码")||r.includes("verification")||r.includes("invalid_verification_code")||r.includes("invalid_username_or_password")||r.includes("username or password")||r.includes("用户名或密码")||r.includes("wrong password")||r.includes("incorrect password")?ie.INVALID_CREDENTIALS:t===s.NOT_FOUND||t===s.USER_NOT_FOUND||r.includes("用户不存在")||r.includes("not found")||r.includes("user not found")||r.includes("不存在")||r.includes("no such user")||r.includes("user does not exist")?ie.USER_NOT_FOUND:t===s.USER_BLOCKED||t===s.USER_PENDING||t===s.UNDER_REVIEW||t===s.INVALID_STATUS||r.includes("被封禁")||r.includes("blocked")||r.includes("pending")||r.includes("审核")||r.includes("review")||r.includes("locked")||r.includes("已锁定")?ie.USER_STATUS_ABNORMAL:t===s.SERVER_ERROR||t===s.UNAVAILABLE||t===s.TEMPORARILY_UNAVAILABLE||t===s.INTERNAL||t===s.UNREACHABLE||t===s.DEADLINE_EXCEEDED||t===s.DATA_LOSS||r.includes("network")||r.includes("timeout")||r.includes("服务")||r.includes("timed out")||r.includes("超时")?ie.SERVICE_ERROR:t===s.INVALID_ARGUMENT||t===s.INVALID_REQUEST||t===s.INVALID_SCOPE||t===s.INVALID_REQUEST_URI||t===s.INVALID_REQUEST_OBJECT?ie.INVALID_PARAMS:t===s.PERMISSION_DENIED||t===s.ACCESS_DENIED||t===s.UNAUTHORIZED_CLIENT?ie.PROVIDER_NOT_ENABLED:ie.UNKNOWN}catch(e){return t}}(n,this.status),this.helpMessage=function(e,t){var r=(null==t?void 0:t.method)||"signIn",n={signInWithPassword:"「用户名密码登录」",signInAnonymously:"「匿名登录」",signInWithOtp:"「短信验证码登录」或「邮箱验证码登录」",signUp:"「短信验证码登录」或「邮箱验证码登录」",signInWithOAuth:"对应的第三方身份源",signInWithIdToken:"对应的第三方身份源",signInWithOpenId:"「微信小程序 OpenID 登录」",signInWithPhoneAuth:"「微信小程序手机号授权登录」",signInWithCustomTicket:"「自定义登录」"}[r]||"对应的登录方式";switch(e){case ie.PROVIDER_NOT_ENABLED:return"[CloudBase Auth] 登录方式未开启\n\n"+" 当前调用的 ".concat(r,"() 所需的登录方式尚未在云开发控制台启用。\n")+" 需要开启的登录方式:".concat(n,"\n")+"\n 请按以下步骤开启:\n"+" 1. 打开云开发控制台:".concat(ae,"\n")+" 2. 选择对应的云开发环境\n 3. 进入「登录授权」页面,在「登录方式」或「身份源列表」中开启所需的登录方式\n\n 各登录方法与所需登录方式的对应关系:\n - signInWithPassword → 「用户名密码登录」\n - signInAnonymously → 「匿名登录」\n - signInWithOtp/signUp → 「短信验证码登录」或「邮箱验证码登录」\n - signInWithOAuth/signInWithIdToken → 对应的第三方身份源\n\n 如使用 CLI/MCP 工具,可通过 auth 工具查询和配置身份源状态。\n"+" 更多帮助请参考文档:".concat(ue);case ie.INVALID_CREDENTIALS:return"[CloudBase Auth] 凭据验证失败\n\n"+" 调用 ".concat(r,"() 时凭据校验未通过。\n")+"\n 请按优先级逐项排查:\n 1. 确认用户名/邮箱/手机号是否拼写正确、格式完整\n 2. 确认密码是否正确(注意大小写、特殊字符、前后空格)\n 3. 确认用户账号确实存在(可通过 auth.isUsernameRegistered() 检查)\n 4. 确认凭据参数来源可靠(环境变量、配置文件中的值是否已正确设置)\n 5. 如使用加密登录(is_encrypt: true),请确认公钥版本正确\n\n 如忘记密码,可通过 auth.resetPasswordForEmail() 重置密码。\n\n 提示:如果是 AI agent / 自动化测试场景,请确认 ENV_ID、USERNAME、PASSWORD\n 等环境变量已正确传入,且对应用户已在目标环境中注册。";case ie.USER_NOT_FOUND:return"[CloudBase Auth] 用户不存在\n\n 请检查以下项目:\n 1. 确认用户名/邮箱/手机号是否正确\n 2. 确认是在正确的云开发环境(envId)下操作\n 3. 如果是新用户,请先通过 auth.signUp() 注册\n"+" 4. 也可在云开发控制台手动创建用户:".concat(ae,"\n")+"\n 提示:不同环境(开发/测试/生产)的用户库是隔离的,请确认 envId 正确。";case ie.USER_STATUS_ABNORMAL:return"[CloudBase Auth] 用户状态异常\n\n 当前用户账号可能处于以下状态之一:\n - 账号已被封禁\n - 账号正在审核中\n - 账号已被锁定(多次密码错误)\n\n"+" 请联系管理员在云开发控制台检查用户状态:".concat(ae);case ie.SERVICE_ERROR:return"[CloudBase Auth] 服务异常\n\n 请检查以下项目:\n 1. 网络连接是否正常\n 2. 云开发环境是否正常运行\n 3. 稍后重试,如持续失败请联系技术支持\n\n 提示:如果是超时错误,请检查网络环境和请求频率。";case ie.INVALID_PARAMS:return"[CloudBase Auth] 参数错误\n\n 请检查传入的参数是否符合要求,参考 API 文档确认各参数的格式和约束。\n"+" 文档地址:".concat(ue);case ie.AUTH_METHOD_MISMATCH:return"[CloudBase Auth] 登录方式不匹配\n\n"+" 调用 ".concat(r,"() 时遇到错误,可能原因:\n")+" - 匿名登录失败后尝试了用户名密码登录,但凭据不正确或用户不存在\n - 应使用匿名登录但传入了密码参数\n - 应使用密码登录但未传入正确的凭据\n\n 建议:\n 1. 明确当前场景需要的登录方式:\n - 无需用户注册 → auth.signInAnonymously()\n - 有用户名和密码 → auth.signInWithPassword({ username, password })\n - 第三方平台 → auth.signInWithOAuth({ provider })\n 2. 不要在同一流程中混合使用不同的登录方式\n 3. 每种登录方式需要在控制台开启对应的身份源\n"+" 4. 控制台地址:".concat(ae);default:return"[CloudBase Auth] 操作失败\n\n 如果问题持续存在,建议:\n"+" 1. 检查云开发控制台的认证配置:".concat(ae,"\n")+" 2. 到官方问答社区提问:https://cnb.cool/tencent/cloud/cloudbase/community/-/issues\n"+" 3. 查阅文档:".concat(ue)}}(this.category,t),this.loginMethodHint=(r=null==t?void 0:t.method)&&{signInWithPassword:"当前使用「用户名密码登录」,需确保:\n ✓ 控制台已开启「用户名密码登录」\n ✓ 用户已注册且凭据正确\n 如果不需要用户系统,建议改用 auth.signInAnonymously()",signInAnonymously:"当前使用「匿名登录」,需确保:\n ✓ 控制台已开启「匿名登录」\n 注意:匿名用户无需用户名密码,适用于快速体验或临时访问场景",signInWithOtp:"当前使用「OTP 验证码登录」,需确保:\n ✓ 控制台已开启「短信验证码登录」或「邮箱验证码登录」",signInWithOAuth:"当前使用「第三方 OAuth 登录」,需确保:\n ✓ 控制台已配置并开启对应的第三方身份源"}[r]||""}}var le=["provider_redirect_uri","other_params"];function fe(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function de(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?fe(Object(r),!0).forEach((function(t){he(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):fe(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function he(e,t,r){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function pe(e,t,r,n,o,i,s){try{var a=e[i](s),u=a.value}catch(e){return void r(e)}a.done?t(u):Promise.resolve(u).then(n,o)}function ve(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function s(e){pe(i,n,o,s,a,"next",e)}function a(e){pe(i,n,o,s,a,"throw",e)}s(void 0)}))}}function ye(e,t){return me.apply(this,arguments)}function me(){return me=ve((function*(e,t){var n=function(){var e=ve((function*(){try{return r(7171)}catch(e){try{return yield Promise.resolve().then(r.bind(r,7171))}catch(e){return}}}));return function(){return e.apply(this,arguments)}}();try{var o;if(((null==t||null===(o=t.root)||void 0===o?void 0:o.globalThis)||globalThis).IS_MP_BUILD)return}catch(t){if(e)return n()}})),me.apply(this,arguments)}class ge{static parseParamsToSearch(e){return Object.keys(e).forEach((t=>{e[t]||delete e[t]})),new se(e).toString()}constructor(e){var{request:t}=e,r=e.credentialsClient;if(!r){var n={apiOrigin:e.apiOrigin,apiPath:e.apiPath,clientId:e.clientId,storage:e.storage,env:e.env,baseRequest:e.baseRequest,anonymousSignInFunc:e.anonymousSignInFunc,wxCloud:e.wxCloud,onCredentialsError:e.onCredentialsError,headers:e.headers||{},i18n:e.i18n,debug:e.debug};r=new B(n)}if(!t){var o=r.request.bind(r),i=new oe(de({env:e.env,clientId:e.clientId,request:o,storage:e.storage,adapter:e.adapter,oauthInstance:this},e.captchaOptions));t=i.request.bind(i)}this.config={env:e.env,apiOrigin:e.apiOrigin,apiPath:e.apiPath,clientId:e.clientId,request:t,credentialsClient:r,storage:e.storage||j,adapter:e.adapter}}getParamsByVersion(e,t){var r,i=(0,y.I)(e),s=(null===(r={v2:o}[null==i?void 0:i.version])||void 0===r?void 0:r[t])||n[t];return i&&delete i.version,{params:i,url:s}}signIn(e){var t=this;return ve((function*(){var r=e.version||"v1",n=t.getParamsByVersion(e,"AUTH_SIGN_IN_URL");n.params.query&&delete n.params.query;var o=yield t.getEncryptParams(n.params),i=yield t.config.request(n.url,{method:"POST",body:o});return yield t.config.credentialsClient.setCredentials(de(de({},i),{},{version:r})),Promise.resolve(i)}))()}signInAnonymously(){var e=arguments,t=this;return ve((function*(){var r=e.length>0&&void 0!==e[0]?e[0]:{},o=e.length>1&&void 0!==e[1]&&e[1],i=yield t.config.request(n.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",body:r,useWxCloud:o});return yield t.config.credentialsClient.setCredentials(i),Promise.resolve(i)}))()}signUp(e){var t=this;return ve((function*(){var r=yield t.config.request(n.AUTH_SIGN_UP_URL,{method:"POST",body:e});return yield t.config.credentialsClient.setCredentials(r),Promise.resolve(r)}))()}signOut(e){var t=this;return ve((function*(){var r={};if(e){try{r=yield t.config.request(n.AUTH_SIGNOUT_URL,{method:"POST",withCredentials:!0,body:e})}catch(e){e.error!==s.UNAUTHENTICATED&&console.log("sign_out_error",e)}return yield t.config.credentialsClient.setCredentials(),r}var o=yield t.config.credentialsClient.getAccessToken(),i=yield t.config.request(n.AUTH_REVOKE_URL,{method:"POST",body:{token:o}});return yield t.config.credentialsClient.setCredentials(),Promise.resolve(i)}))()}revokeAllDevices(){var e=this;return ve((function*(){yield e.config.request(n.AUTH_REVOKE_ALL_URL,{method:"DELETE",withCredentials:!0})}))()}revokeDevice(e){var t=this;return ve((function*(){yield t.config.request(n.AUTHORIZED_DEVICES_DELETE_URL+e.device_id,{method:"DELETE",withCredentials:!0})}))()}getVerification(e,t){var r=this;return ve((function*(){var o=!1;("CUR_USER"===e.target||(yield r.hasLoginState()))&&(o=!0);var i=(0,y.I)(e);return i.phone_number&&!/^\+\d{1,3}\s+\d+/.test(i.phone_number)&&(i.phone_number="+86 ".concat(i.phone_number)),r.config.request(n.VERIFICATION_URL,{method:"POST",body:i,withCaptcha:(null==t?void 0:t.withCaptcha)||!1,withCredentials:o})}))()}verify(e){var t=this;return ve((function*(){var r=t.getParamsByVersion(e,"VERIFY_URL"),n=yield t.config.request(r.url,{method:"POST",body:r.params});return"v2"===(null==e?void 0:e.version)&&(yield t.config.credentialsClient.setCredentials(de(de({},n),{},{version:"v2"}))),n}))()}genProviderRedirectUri(e){var t=this;return ve((function*(){var{provider_redirect_uri:r,other_params:o={}}=e,i=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.includes(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.includes(r)||{}.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(e,le);r&&!i.redirect_uri&&(i.redirect_uri=r);var s="".concat(n.PROVIDER_URI_URL,"?").concat(ge.parseParamsToSearch(i));return Object.keys(o).forEach((e=>{var t=o[e];("sign_out_uri"!==e||(null==t?void 0:t.length)>0)&&(s+="&other_params[".concat(e,"]=").concat(encodeURIComponent(t)))})),t.config.request(s,{method:"GET"})}))()}grantProviderToken(e){var t=arguments,r=this;return ve((function*(){var o=t.length>1&&void 0!==t[1]&&t[1];return r.config.request(n.PROVIDER_TOKEN_URL,{method:"POST",body:e,useWxCloud:o})}))()}patchProviderToken(e){var t=this;return ve((function*(){return t.config.request(n.PROVIDER_TOKEN_URL,{method:"PATCH",body:e})}))()}signInWithProvider(e){var t=arguments,r=this;return ve((function*(){var n=t.length>1&&void 0!==t[1]&&t[1],o=r.getParamsByVersion(e,"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(de(de({},i),{},{version:(null==e?void 0:e.version)||"v1"})),Promise.resolve(i)}))()}toBindIdentity(e){var t=this;return ve((function*(){var r,n,o,i=e.credentials||(yield t.config.credentialsClient.localCredentials.getCredentials());try{yield t.bindWithProvider({provider_token:e.provider_token},i),r={data:{type:h.BIND_IDENTITY,provider:e.provider},error:null}}catch(e){r={data:{type:h.BIND_IDENTITY},error:new ce(e)}}return e.fireEvent&&(null===(n=t.config.eventBus)||void 0===n||null===(o=n.fire)||void 0===o||o.call(n,d.AUTH_STATE_CHANGED,{event:f.BIND_IDENTITY,info:r})),r}))()}getInitialSession(){var e=this;return ve((function*(){var t={};try{var r,n,o,i,s;if("undefined"==typeof window||"undefined"==typeof document)return{data:null,error:null};var a=new URLSearchParams(null===(r=location)||void 0===r?void 0:r.search),u=a.get("code"),c=a.get("state");if(!u||!c)return{data:null,error:null};var l=null;try{l=JSON.parse(sessionStorage.getItem(c)||"null")}catch(e){}t={type:null===(n=l)||void 0===n?void 0:n.type};var f=a.get("error"),d=a.get("error_description");if(f||d)return{data:t,error:new ce({message:d||f||"Unknown error from OAuth provider"})};var p=(null===(o=l)||void 0===o?void 0:o.provider)||a.get("provider");if(!p)return{data:t,error:new ce({message:"Provider is required for OAuth verification"})};var v,y,m=location.origin+location.pathname,{provider_token:g}=yield e.grantProviderToken({provider_id:p,provider_redirect_uri:m,provider_code:u}),b=null;if(l.type===h.BIND_IDENTITY)v=yield e.config.credentialsClient.localCredentials.getCredentials(),y=yield e.toBindIdentity({provider:p,provider_token:g,credentials:v});else if(l.type===h.SIGN_IN){y=e.getParamsByVersion({provider:p},"AUTH_SIGN_IN_WITH_PROVIDER_URL"),v=yield e.config.request(y.url,{method:"POST",body:{provider_token:g}});try{b=yield e.getUserInfo({credentials:v})}catch(e){console.error("get user info error",e)}y={data:de(de({},t),{},{session:v,user:b}),error:null}}a.delete("code"),a.delete("state"),a.delete("provider"),e.restoreUrlState(void 0===(null===(i=l)||void 0===i?void 0:i.search)?"?".concat(a.toString()):l.search,(null===(s=l)||void 0===s?void 0:s.hash)||location.hash);try{sessionStorage.removeItem(c)}catch(e){}return y}catch(e){return{data:t,error:new ce(e)}}}))()}signInCustom(e){var t=this;return ve((function*(){var r=yield t.config.request(n.AUTH_SIGN_IN_CUSTOM,{method:"POST",body:e});return yield t.config.credentialsClient.setCredentials(r),Promise.resolve(r)}))()}signInWithWechat(){var e=arguments,t=this;return ve((function*(){var r=e.length>0&&void 0!==e[0]?e[0]:{},o=yield t.config.request(n.AUTH_SIGN_IN_WITH_WECHAT_URL,{method:"POST",body:r});return yield t.config.credentialsClient.setCredentials(o),Promise.resolve(o)}))()}bindWithProvider(e,t){var r=this;return ve((function*(){return r.config.request(n.PROVIDER_BIND_URL,{method:"POST",body:e,withCredentials:!0,getCredentials:t?()=>t:void 0})}))()}getUserProfile(e){var t=this;return ve((function*(){return t.getUserInfo(e)}))()}getUserInfo(){var e=arguments,t=this;return ve((function*(){var r,n=e.length>0&&void 0!==e[0]?e[0]:{},o=t.getParamsByVersion(n,"USER_ME_URL");if(null!==(r=o.params)&&void 0!==r&&r.query){var i=new se(o.params.query);o.url+="?".concat(i.toString())}var s=yield t.config.request(o.url,{method:"GET",withCredentials:!0,getCredentials:n.credentials?()=>n.credentials:void 0});return s.sub&&(s.uid=s.sub),s}))()}getWedaUserInfo(){var e=this;return ve((function*(){return yield e.config.request(n.WEDA_USER_URL,{method:"GET",withCredentials:!0})}))()}deleteMe(e){var t=this;return ve((function*(){var r=t.getParamsByVersion(e,"USER_ME_URL"),n="".concat(r.url,"?").concat(ge.parseParamsToSearch(r.params));return t.config.request(n,{method:"DELETE",withCredentials:!0})}))()}hasLoginState(){var e=this;return ve((function*(){try{return yield e.config.credentialsClient.getAccessToken(),!0}catch(e){return!1}}))()}hasLoginStateSync(){return this.config.credentialsClient.getCredentialsSync()}getLoginState(){var e=this;return ve((function*(){return e.config.credentialsClient.getCredentialsAsync()}))()}transByProvider(e){var t=this;return ve((function*(){return t.config.request(n.USER_TRANS_BY_PROVIDER_URL,{method:"PATCH",body:e,withCredentials:!0})}))()}grantToken(e){var t=this;return ve((function*(){var r=t.getParamsByVersion(e,"AUTH_TOKEN_URL");return t.config.request(r.url,{method:"POST",body:r.params})}))()}getProviders(){var e=this;return ve((function*(){return e.config.request(n.PROVIDER_LIST,{method:"GET",withCredentials:!0})}))()}unbindProvider(e){var t=this;return ve((function*(){return t.config.request("".concat(n.PROVIDER_UNBIND_URL,"/").concat(e.provider_id),{method:"DELETE",withCredentials:!0})}))()}checkPassword(e){var t=this;return ve((function*(){return t.config.request("".concat(n.CHECK_PWD_URL),{method:"POST",withCredentials:!0,body:e})}))()}editContact(e){var t=this;return ve((function*(){return t.config.request("".concat(n.BIND_CONTACT_URL),{method:"PATCH",withCredentials:!0,body:e})}))()}setPassword(e){var t=this;return ve((function*(){return t.config.request("".concat(n.AUTH_SET_PASSWORD),{method:"PATCH",withCredentials:!0,body:e})}))()}updatePasswordByOld(e){var t=this;return ve((function*(){var r=yield t.sudo({password:e.old_password});return t.setPassword({sudo_token:r.sudo_token,new_password:e.new_password})}))()}sudo(e){var t=this;return ve((function*(){return t.config.request("".concat(n.SUDO_URL),{method:"POST",withCredentials:!0,body:e})}))()}sendVerificationCodeToCurrentUser(e){var t=this;return ve((function*(){return e.target="CUR_USER",t.config.request(n.VERIFICATION_URL,{method:"POST",body:e,withCredentials:!0,withCaptcha:!0})}))()}changeBoundProvider(e){var t=this;return ve((function*(){return t.config.request("".concat(n.PROVIDER_LIST,"/").concat(e.provider_id,"/trans"),{method:"POST",body:{provider_trans_token:e.trans_token},withCredentials:!0})}))()}setUserProfile(e){var t=this;return ve((function*(){return t.config.request(n.USER_PRIFILE_URL,{method:"PATCH",body:e,withCredentials:!0})}))()}updateUserBasicInfo(e){var t=this;return ve((function*(){return t.config.request(n.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:e})}))()}queryUserProfile(e){var t=this;return ve((function*(){var r=new se(e);return t.config.request("".concat(n.USER_QUERY_URL,"?").concat(r.toString()),{method:"GET",withCredentials:!0})}))()}setCustomSignFunc(e){this.getCustomSignTicketFn=e}signInWithCustomTicket(){var e=this;return ve((function*(){var t=e.getCustomSignTicketFn;if(!t)return Promise.reject({error:"failed_precondition",error_description:"please use setCustomSignFunc to set custom sign function"});var r=yield t();return e.signInCustom({provider_id:"custom",ticket:r})}))()}resetPassword(e){var t=this;return ve((function*(){return t.config.request(n.AUTH_RESET_PASSWORD,{method:"POST",body:e})}))()}authorize(e){var t=this;return ve((function*(){return t.config.request(n.AUTHORIZE_URL,{method:"POST",withCredentials:!0,body:e})}))()}authorizeDevice(e){var t=this;return ve((function*(){return t.config.request(n.AUTHORIZE_DEVICE_URL,{method:"POST",withCredentials:!0,body:e})}))()}deviceAuthorize(e){var t=this;return ve((function*(){return t.config.request(n.AUTH_GET_DEVICE_CODE,{method:"POST",body:e,withCredentials:!0})}))()}authorizeInfo(e){var t=this;return ve((function*(){var r="".concat(n.AUTHORIZE_INFO_URL,"?").concat(ge.parseParamsToSearch(e)),o=!0,i=!1;return(yield t.hasLoginState())&&(i=!0,o=!1),t.config.request(r,{method:"GET",withBasicAuth:o,withCredentials:i})}))()}checkUsername(e){var t=this;return ve((function*(){return t.config.request(n.CHECK_USERNAME,{method:"GET",body:e,withCredentials:!0})}))()}checkIfUserExist(e){var t=this;return ve((function*(){var r=new se(e);return t.config.request("".concat(n.CHECK_IF_USER_EXIST,"?").concat(r.toString()),{method:"GET"})}))()}loginScope(){var e=this;return ve((function*(){return e.config.credentialsClient.getScope()}))()}loginGroups(){var e=this;return ve((function*(){return e.config.credentialsClient.getGroups()}))()}refreshTokenForce(e){var t=this;return ve((function*(){var r=yield t.config.credentialsClient.getCredentials();return yield t.config.credentialsClient.refreshToken(de(de({},r),{},{version:(null==e?void 0:e.version)||"v1"}))}))()}getCredentials(){var e=this;return ve((function*(){return e.config.credentialsClient.getCredentials()}))()}getPublicKey(){var e=this;return ve((function*(){return e.config.request(o.AUTH_PUBLIC_KEY,{method:"POST",body:{}})}))()}getEncryptParams(e){var t=this;return ve((function*(){var{isEncrypt:r}=e;delete e.isEncrypt;var n=(0,y.I)(e),o=yield ye(r,t.config.adapter);if(!o)return e;var i="",s="";try{var a=yield t.getPublicKey();if(i=a.public_key,s=a.public_key_thumbprint,!i||!s)throw a}catch(e){throw e}return{params:o.getEncryptInfo({publicKey:i,payload:n}),public_key_thumbprint:s}}))()}getProviderSubType(){var e=this;return ve((function*(){return e.config.request(n.GET_PROVIDER_TYPE,{method:"POST",body:{provider_id:"weda"}})}))()}verifyCaptchaData(e){var t=this;return ve((function*(){var{token:r,key:o}=e;return t.config.request(n.VERIFY_CAPTCHA_DATA_URL,{method:"POST",body:{token:r,key:o},withCredentials:!1})}))()}createCaptchaData(e){var t=this;return ve((function*(){var{state:r,redirect_uri:o}=e;return t.config.request(n.CAPTCHA_DATA_URL,{method:"POST",body:{state:r,redirect_uri:o},withCredentials:!1})}))()}getMiniProgramCode(e){var t=this;return ve((function*(){return t.config.request(n.GET_MINIPROGRAM_QRCODE,{method:"POST",body:e})}))()}getMiniProgramQrCodeStatus(e){var t=this;return ve((function*(){return t.config.request(n.GET_MINIPROGRAM_QRCODE_STATUS,{method:"POST",body:e})}))()}getUserBehaviorLog(e){var t=this;return ve((function*(){var r="".concat(n.GET_USER_BEHAVIOR_LOG,"?").concat({LOGIN:"query[action]=USER_LOGIN",MODIFY:"ne_query[action]=USER_LOGIN"}[e.type],"&limit=").concat(e.limit).concat(e.page_token?"&page_token=".concat(e.page_token):"");return t.config.request(r,{method:"GET",withCredentials:!0})}))()}modifyPassword(e){var t=this;return ve((function*(){var r="",o="",i=yield ye(!0,t.config.adapter);if(!i)throw new Error("do not support encrypt, a encrypt util required.");try{var s=yield t.getPublicKey();if(r=s.public_key,o=s.public_key_thumbprint,!r||!o)throw s}catch(e){throw e}var a=e.password?i.getEncryptInfo({publicKey:r,payload:e.password}):"",u=i.getEncryptInfo({publicKey:r,payload:e.new_password});return t.config.request(n.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:{user_id:e.user_id,encrypt_password:a,encrypt_new_password:u,public_key_thumbprint:o}})}))()}modifyPasswordWithoutLogin(e){var t=this;return ve((function*(){var r="",n="",i=yield ye(!0,t.config.adapter);if(!i)throw new Error("do not support encrypt, a encrypt util required.");try{var s=yield t.getPublicKey();if(r=s.public_key,n=s.public_key_thumbprint,!r||!n)throw s}catch(e){throw e}var a=e.password?i.getEncryptInfo({publicKey:r,payload:e.password}):"",u=i.getEncryptInfo({publicKey:r,payload:e.new_password});return t.config.request(o.AUTH_RESET_PASSWORD,{method:"POST",body:{username:e.username,password:a,new_password:u,public_key_thumbprint:n}})}))()}restoreUrlState(e,t){if(void 0!==e)try{var r=new URL(window.location.href);r.search=e,r.hash=t||"",window.history.replaceState(null,"",r.toString()),window.location.replace(r.toString())}catch(e){}}}function be(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function we(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?be(Object(r),!0).forEach((function(t){_e(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):be(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _e(e,t,r){return(t=function(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class Se{constructor(e){var{apiOrigin:t,apiPath:r=u,clientId:n,env:o,storage:i,request:s,baseRequest:a,anonymousSignInFunc:c,wxCloud:l,adapter:f,onCredentialsError:d,headers:h,i18n:p,useWxCloud:v,eventBus:y,detectSessionInUrl:m,debug:g}=e;if(this.detectSessionInUrl=null!=m&&m,this.oauth2client=new B({apiOrigin:t,apiPath:r,clientId:n,env:o,storage:i,baseRequest:a||s,anonymousSignInFunc:c,wxCloud:l,onCredentialsError:d,headers:h||{},i18n:p,useWxCloud:v,eventBus:y,debug:g}),this.authApi=new ge(we(we({credentialsClient:this.oauth2client},e),{},{request:s?this.oauth2client.request.bind(this.oauth2client):void 0,adapter:f})),m)this.oauth2client.setGetInitialSession(this.authApi.getInitialSession.bind(this.authApi));else try{var b=new URL(window.location.href),w=b.searchParams.get("code"),_=b.searchParams.get("state"),S=JSON.parse(sessionStorage.getItem(_)||"null");w&&_&&null!=S&&S.hash&&(b.hash=S.hash,window.history.replaceState(null,"",b.toString()),window.location.replace(b.toString()))}catch(e){}}initializeSession(e){this.detectSessionInUrl?(this.oauth2client.setOnInitialSessionObtained(e),this.oauth2client.initialize()):this.oauth2client.initialize(Promise.resolve({error:null}))}}var Ee,Ie,Oe=r(794),Te=r(141),Ae=r(6197),Re=r(190),Pe=r(8182),Ce=function(){return Ce=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Ce.apply(this,arguments)},Ne=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},xe=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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])}}},Le=function(){function e(e){var t,r;try{this.localStorage=(null==e?void 0:e.localStorage)||((null===(r=null===(t=null==e?void 0:e.adapter)||void 0===t?void 0:t.root)||void 0===r?void 0:r.globalThis)||globalThis).localStorage}catch(t){this.localStorage=(null==e?void 0:e.localStorage)||{}}}return e.prototype.getItem=function(e){return Ne(this,void 0,void 0,(function(){return xe(this,(function(t){return[2,this.localStorage.getItem(e)]}))}))},e.prototype.removeItem=function(e){return Ne(this,void 0,void 0,(function(){return xe(this,(function(t){return this.localStorage.removeItem(e),[2]}))}))},e.prototype.setItem=function(e,t){return Ne(this,void 0,void 0,(function(){return xe(this,(function(r){return this.localStorage.setItem(e,t),[2]}))}))},e.prototype.getItemSync=function(e){return this.localStorage.getItem(e)},e.prototype.setItemSync=function(e,t){this.localStorage.setItem(e,t)},e.prototype.removeItemSync=function(e){this.localStorage.removeItem(e)},e}(),Ue=/^[^:]+:\/\/[^/]+(\/[^?#]+)/,ke=function(e,t){var r,n,o,i,s=null===(r=null==t?void 0:t.headers)||void 0===r?void 0:r["x-request-id"];return e||(e={}),((null==e?void 0:e.code)||(null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.error_code))&&(e={error:e.code||e.data.error,error_description:e.data.error_description||e.message||e.code||e.data.error_code,request_id:e.requestId,error_code:null===(o=e.data)||void 0===o?void 0:o.error_code}),(null==e?void 0:e.request_id)||(e.request_id=e.request_id||s),(null==e?void 0:e.error)?(e.error_uri=(i=null==t?void 0:t.url,Ue.test(i)?RegExp.$1:i),e):(null==e?void 0:e.data)||{}},De=function(e){return e.adapter&&"default"!==e.adapter.type?function(e,t){var r=Ce({},e);try{if(!(null==e?void 0:e.storage)&&(null==t?void 0:t.localStorage)&&(r.storage=new Le({localStorage:t.localStorage,adapter:t})),!e.captchaOptions&&(null==t?void 0:t.captchaOptions)&&(r.captchaOptions=t.captchaOptions),!e.baseRequest&&!e.request&&(null==t?void 0:t.reqClass)){var n={timeout:1e4,restrictedMethods:["get","post","upload","download","request"],auth:e.auth},o=new t.reqClass(n);r.baseRequest=function(e,t){var r,n,i,s,a;return Ne(this,void 0,void 0,(function(){var u,c,l,f;return xe(this,(function(d){switch(d.label){case 0:if(u={},c=(null===(r=t.method)||void 0===r?void 0:r.toLocaleLowerCase())||"post","function"!=typeof(l=null===(i=null===(n=null==o?void 0:o[c])||void 0===n?void 0:n.bind)||void 0===i?void 0:i.call(n,o)))throw new Error("invalid 【".concat(c,"】 request method"));d.label=1;case 1:return d.trys.push([1,3,,4]),(null===(s=t.headers)||void 0===s?void 0:s["content-type"])&&!(null===(a=t.headers)||void 0===a?void 0:a["content-type"].includes("application/json"))||["string","undefined"].includes(typeof t.body)||(t.data=t.data||t.body,t.body=JSON.stringify(t.body)),[4,l(Ce({url:e},t))];case 2:return u=d.sent(),u=ke(u,Ce(Ce({},t),{url:e})),[3,4];case 3:throw f=d.sent(),u=Ce(Ce({},null==f?void 0:f.data),f);case 4:if(null==u?void 0:u.error)throw u;return[2,u]}}))}))}}}catch(e){console.error("user adapter generate fail:",e)}return r}(e,e.adapter):function(e,t){var r=Ce({},e),n={};if((null==t?void 0:t.captchaOptions)&&(r.captchaOptions=t.captchaOptions),!Re.ZP.isMatch()||e.storage&&e.baseRequest)return r;try{var o=Re.ZP.genAdapter({}),i=o.localStorage,s=o.reqClass;if(i&&(n.storage=new Le({localStorage:i,adapter:t})),s){var a=new s({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});n.request=function(e){return function(t,r){return Ne(this,void 0,void 0,(function(){return xe(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:t,data:i.body,timeout:e._timeout,method:i.method||"GET",header:i.headers,success:function(e){(e=ke(e,Ce(Ce({},r),{url:t}))).error&&o(e),n(e)},fail:function(e){o({error:"unreachable",error_description:e.message})},complete:function(t){if(t&&t.errMsg&&e._timeout&&-1!==e._restrictedMethods.indexOf("request")&&"request:fail timeout"===t.errMsg){console.warn(e._timeoutMsg);try{s.abort()}catch(e){}}}})}))]}))}))}}(a)}return r.captchaOptions&&(n.baseRequest=n.request,n.request=void 0),Ce(Ce({},r),n)}catch(e){console.error("adapter generate fail:",e)}return r}(e,e.adapter)},je=function(){return je=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},je.apply(this,arguments)},qe=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},Me=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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])}}},Be=function(){function e(e){}return e.prototype.signInWithRedirect=function(){throw new Error("[v1 兼容] WeixinAuthProvider.signInWithRedirect() 在当前版本中无法实现。 建议使用 auth.signInWithOAuth({ provider: 'providerId' }) 替代。")},e.prototype.getRedirectResult=function(e){return qe(this,void 0,void 0,(function(){return Me(this,(function(e){throw new Error("[v1 兼容] WeixinAuthProvider.getRedirectResult() 在当前版本中无法实现。 建议使用 auth.verifyOAuth({ code, state, provider }) 替代。")}))}))},e.prototype.getLinkRedirectResult=function(e){return qe(this,void 0,void 0,(function(){return Me(this,(function(e){throw new Error("[v1 兼容] WeixinAuthProvider.getLinkRedirectResult() 在当前版本中无法实现。 建议使用 auth.linkIdentity({ provider: 'providerId' }) 替代。")}))}))},e}(),We=function(){function e(e){this.authInstance=e.authInstance}return e.prototype.signIn=function(e){return qe(this,void 0,void 0,(function(){return Me(this,(function(t){switch(t.label){case 0:return[4,this.authInstance.signInWithCustomTicket((function(){return Promise.resolve(e)}))];case 1:return t.sent(),[2]}}))}))},e}(),Fe=function(){function e(e){this.authInstance=e.authInstance}return e.prototype.signIn=function(){return qe(this,void 0,void 0,(function(){return Me(this,(function(e){switch(e.label){case 0:return[4,this.authInstance.signInAnonymously({})];case 1:return e.sent(),[2]}}))}))},e}(),Ve=function(){function e(){}return e.prototype.weixinAuthProvider=function(e){return new Be({authInstance:this,appid:e.appid,scope:e.scope})},e.prototype.customAuthProvider=function(){return new We({authInstance:this})},e.prototype.anonymousAuthProvider=function(){return new Fe({authInstance:this})},e.prototype.signUpWithEmailAndPassword=function(e,t){return qe(this,void 0,void 0,(function(){return Me(this,(function(r){switch(r.label){case 0:return"string"!=typeof e&&(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"email must be a string"),"string"!=typeof t&&(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signUp({email:e,password:t})];case 1:return[2,r.sent()]}}))}))},e.prototype.signInWithEmailAndPassword=function(e,t){return qe(this,void 0,void 0,(function(){return Me(this,(function(r){switch(r.label){case 0:return"string"!=typeof e&&(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"email must be a string"),"string"!=typeof t&&(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signIn({username:e,password:t})];case 1:return r.sent(),[2,this.createLoginState()]}}))}))},e.prototype.sendPasswordResetEmail=function(e){return qe(this,void 0,void 0,(function(){return Me(this,(function(t){switch(t.label){case 0:return"string"!=typeof e&&(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"email must be a string"),[4,this.getVerification({email:e})];case 1:return t.sent(),[2]}}))}))},e.prototype.signInWithUsernameAndPassword=function(e,t){return qe(this,void 0,void 0,(function(){return Me(this,(function(r){switch(r.label){case 0:return"string"!=typeof e&&(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"username must be a string"),"string"!=typeof t&&(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signIn({username:e,password:t})];case 1:return r.sent(),[2,this.createLoginState()]}}))}))},e.prototype.sendPhoneCode=function(e){return qe(this,void 0,void 0,(function(){var t;return Me(this,(function(r){switch(r.label){case 0:return"string"!=typeof e&&(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),t=this.formatPhone(e),[4,this.getVerification({phone_number:t})];case 1:return r.sent(),[2,!0]}}))}))},e.prototype.signUpWithPhoneCode=function(e,t,r){return qe(this,void 0,void 0,(function(){var n;return Me(this,(function(o){switch(o.label){case 0:return"string"!=typeof e&&(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),"string"!=typeof t&&(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"phoneCode must be a string"),n=this.formatPhone(e),[4,this.signUp(je({phone_number:n,verification_code:t},r?{password:r}:{}))];case 1:return o.sent(),[2,this.createLoginState()]}}))}))},e.prototype.signInWithPhoneCodeOrPassword=function(e){return qe(this,void 0,void 0,(function(){var t,r,n,o;return Me(this,(function(i){switch(i.label){case 0:return t=e.phoneNumber,r=e.phoneCode,n=e.password,"string"!=typeof t&&(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),o=this.formatPhone(t),n?[4,this.signIn({username:o,password:n})]:[3,2];case 1:return i.sent(),[3,5];case 2:return r?[4,this.signIn({username:o,verification_token:r})]:[3,4];case 3:return i.sent(),[3,5];case 4:(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"phoneCode or password must be provided"),i.label=5;case 5:return[2,this.createLoginState()]}}))}))},e.prototype.forceResetPwdByPhoneCode=function(e){return qe(this,void 0,void 0,(function(){var t,r,n,o;return Me(this,(function(i){switch(i.label){case 0:return t=e.phoneNumber,r=e.phoneCode,n=e.password,"string"!=typeof t&&(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),"string"!=typeof r&&(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"phoneCode must be a string"),"string"!=typeof n&&(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"password must be a string"),o=this.formatPhone(t),[4,this.resetPassword({phone_number:o,new_password:n,verification_token:r})];case 1:return i.sent(),[4,this.signIn({username:o,password:n})];case 2:return i.sent(),[2,this.createLoginState()]}}))}))},e.prototype.shouldRefreshAccessToken=function(e){throw new Error("[v1 兼容] shouldRefreshAccessToken() 在当前版本中无法实现。 建议使用 auth.onAuthStateChange(callback) 来监听 TOKEN_REFRESHED 事件替代。")},e.prototype.onLoginStateExpired=function(e){var t=this;this.onLoginStateChanged((function(r){(null==r?void 0:r.eventType)===l&&e.call(t)}))},e.prototype.onAccessTokenRefreshed=function(e){var t=this;this.onAuthStateChange((function(r){r===f.TOKEN_REFRESHED&&e.call(t)}))},e.prototype.onAnonymousConverted=function(e){var t=this;this.onAuthStateChange((function(r){r===f.SIGNED_IN&&e.call(t)}))},e.prototype.onLoginTypeChanged=function(e){var t=this;this.onAuthStateChange((function(r){r!==f.SIGNED_IN&&r!==f.SIGNED_OUT||e.call(t)}))},e}(),He=(Ee=function(e,t){return Ee=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},Ee(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}Ee(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),$e=function(){return $e=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},$e.apply(this,arguments)},Ge=function(e,t,r,n){var o,i=arguments.length,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s},ze=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Ke=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},Je=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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])}}},Ye=function(){return"undefined"!=typeof window&&"undefined"!=typeof document},Qe=function(e){return function(t){e.fire(d.LOGIN_STATE_CHANGED,$e($e({},t),{eventType:l}))}},Ze=function(){function e(e){var t=e.cache,r=e.oauthInstance;this.cache=t,this.oauthInstance=r,this.setUserInfo()}return e.prototype.checkLocalInfo=function(){return Ke(this,void 0,void 0,(function(){return Je(this,(function(e){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]}))}))},e.prototype.checkLocalInfoAsync=function(){return Ke(this,void 0,void 0,(function(){var e,t,r,n;return Je(this,(function(o){switch(o.label){case 0:return e=this,[4,this.getLocalUserInfoAsync("uid")];case 1:return e.uid=o.sent(),t=this,[4,this.getLocalUserInfoAsync("gender")];case 2:return t.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]}}))}))},e.prototype.update=function(e){return Ke(this,void 0,void 0,(function(){var t;return Je(this,(function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.setUserProfile($e({},e))];case 1:return t=r.sent(),this.setLocalUserInfo(t),[2]}}))}))},e.prototype.updateUserBasicInfo=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.updateUserBasicInfo($e({},e))];case 1:return t.sent(),[4,this.refresh()];case 2:return t.sent(),[2]}}))}))},e.prototype.updatePassword=function(e,t){return this.oauthInstance.authApi.updatePasswordByOld({old_password:t,new_password:e})},e.prototype.updateUsername=function(e){return"string"!=typeof e&&(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"username must be a string"),this.update({username:e})},e.prototype.refresh=function(e){return Ke(this,void 0,void 0,(function(){var t;return Je(this,(function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.getUserInfo(e)];case 1:if("INVALID_ACCESS_TOKEN"===(t=r.sent()).code)throw this.setLocalUserInfo({}),t;return this.setLocalUserInfo(t),[2,t]}}))}))},e.prototype.getLocalUserInfo=function(e){var t=this.cache.keys.userInfoKey,r=this.cache.getStore(t);return e?r[e]:r||{}},e.prototype.setLocalUserInfo=function(e){var t=this.cache.keys.userInfoKey;this.cache.setStore(t,e),this.setUserInfo()},e.prototype.getLocalUserInfoAsync=function(e){return Ke(this,void 0,void 0,(function(){var t;return Je(this,(function(r){switch(r.label){case 0:return t=this.cache.keys.userInfoKey,[4,this.cache.getStoreAsync(t)];case 1:return[2,r.sent()[e]]}}))}))},e.prototype.setUserInfo=function(){var e=this,t=this.cache.keys.userInfoKey,r=this.cache.getStore(t);["uid","email","name","gender","picture","email_verified","phone_number","birthdate","zoneinfo","locale","sub","created_from","providers","username","created_at"].forEach((function(t){e[t]=r[t]}))},Ge([(0,Te.catchErrorsDecorator)({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[Object]),ze("design:returntype",Promise)],e.prototype,"update",null),Ge([(0,Te.catchErrorsDecorator)({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[String,String]),ze("design:returntype",void 0)],e.prototype,"updatePassword",null),Ge([(0,Te.catchErrorsDecorator)({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[String]),ze("design:returntype",void 0)],e.prototype,"updateUsername",null),Ge([(0,Te.catchErrorsDecorator)({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[Object]),ze("design:returntype",Promise)],e.prototype,"refresh",null),e}();(Ie=Ze).prototype.linkWithTicket=function(e){return qe(this,void 0,void 0,(function(){return Me(this,(function(e){throw new Error("[v1 兼容] User.linkWithTicket() 在当前版本中无法实现。 建议使用 auth.signInWithCustomTicket(() => Promise.resolve(ticket)) 替代。")}))}))},Ie.prototype.linkWithRedirect=function(e){throw new Error("[v1 兼容] User.linkWithRedirect() 在当前版本中无法实现。 建议使用 auth.linkIdentity({ provider: 'providerId' }) 替代。")},Ie.prototype.updateEmail=function(e,t){return qe(this,void 0,void 0,(function(){return Me(this,(function(t){switch(t.label){case 0:return"string"!=typeof e&&(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"newEmail must be a string"),[4,this.updateUserBasicInfo({email:e})];case 1:return t.sent(),[2]}}))}))},Ie.prototype.linkWithPhoneNumber=function(e,t){return qe(this,void 0,void 0,(function(){return Me(this,(function(e){throw new Error("[v1 兼容] User.linkWithPhoneNumber() 在当前版本中无法实现。 建议使用 auth.bindPhoneNumber({ phone_number, verification_token, sudo_token }) 替代。")}))}))},Ie.prototype.updatePhoneNumber=function(e,t){return qe(this,void 0,void 0,(function(){return Me(this,(function(e){throw new Error("[v1 兼容] User.updatePhoneNumber() 在当前版本中无法实现。 建议使用 auth.updateUser({ phone: newPhoneNumber }) 替代。")}))}))},Ie.prototype.unlink=function(e){return qe(this,void 0,void 0,(function(){return Me(this,(function(e){throw new Error("[v1 兼容] User.unlink() 在当前版本中无法实现。 建议使用 auth.unlinkIdentity({ provider: loginType }) 替代。")}))}))};var Xe=function(){function e(e){var t=e.envId,r=e.cache,n=e.oauthInstance;t||(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"envId is not defined"),this.cache=r,this.oauthInstance=n,this.user=new Ze({cache:this.cache,oauthInstance:n})}return e.prototype.checkLocalState=function(){var e;this.oauthLoginState=null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.hasLoginStateSync(),this.user.checkLocalInfo()},e.prototype.checkLocalStateAsync=function(){var e;return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){switch(t.label){case 0:return[4,null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.getLoginState()];case 1:return t.sent(),[4,this.user.checkLocalInfoAsync()];case 2:return t.sent(),[2]}}))}))},e}(),et=function(e){function t(t){var r=e.call(this)||this;return r.listeners=new Map,r.hasListenerSetUp=!1,r.config=t,r.oauthInstance=t.oauthInstance,r.cache=t.cache,r.init(),r.setAccessKey(),r}return He(t,e),t.prototype.signInAnonymously=function(e){return Ke(this,void 0,void 0,(function(){var t,r,n,o,i;return Je(this,(function(s){switch(s.label){case 0:return s.trys.push([0,4,,5]),[4,this.oauthInstance.authApi.signInAnonymously(e)];case 1:return s.sent(),[4,this.createLoginState()];case 2:return t=s.sent(),[4,this.getSession()];case 3:return r=s.sent().data,n=(void 0===r?{}:r).session,[2,$e($e({},t),{data:{user:n.user,session:n},error:null})];case 4:return o=s.sent(),(i=new ce(o,{method:"signInAnonymously"})).category===ie.PROVIDER_NOT_ENABLED?(console.error(i.helpMessage),console.error("[CloudBase Auth] 提示:匿名登录需要在控制台开启「匿名登录」。\n 如果您需要使用用户名密码登录,请改用 auth.signInWithPassword({ username, password })。\n 不要在匿名登录失败后自动回退到密码登录,这两种方式的使用场景不同。")):(console.warn("[CloudBase Auth] signInAnonymously 失败 [".concat(i.category,"]: ").concat(i.message)),i.loginMethodHint&&console.warn(i.loginMethodHint)),[2,{data:{},error:i}];case 5:return[2]}}))}))},t.prototype.signUp=function(e){return Ke(this,void 0,void 0,(function(){var t,r,n=this;return Je(this,(function(o){switch(o.label){case 0:return e.phone_number||e.verification_code||e.verification_token||e.provider_token?(e.phone_number=this.formatPhone(e.phone_number),[4,this.oauthInstance.authApi.signUp(e)]):[3,2];case 1:return o.sent(),[2,this.createLoginState()];case 2:return o.trys.push([2,4,,5]),this.validateAtLeastOne(e,[["email"],["phone"]],"You must provide either an email or phone number"),[4,this.getVerification(e.email?{email:e.email}:{phone_number:this.formatPhone(e.phone)})];case 3:return t=o.sent(),[2,{data:{verifyOtp:function(r){var o=r.token,i=r.messageId,s=void 0===i?t.verification_id:i;return Ke(n,void 0,void 0,(function(){var r,n,i,a,u;return Je(this,(function(c){switch(c.label){case 0:return c.trys.push([0,8,,9]),[4,this.verify({verification_id:s||t.verification_id,verification_code:o})];case 1:return r=c.sent(),t.is_user?[4,this.signIn({username:e.email||this.formatPhone(e.phone),verification_token:r.verification_token})]:[3,3];case 2:return c.sent(),[3,6];case 3:return delete(n=JSON.parse(JSON.stringify(e))).email,delete n.phone,[4,this.oauthInstance.authApi.signUp($e($e($e({},n),e.email?{email:e.email}:{phone_number:this.formatPhone(e.phone)}),{verification_token:r.verification_token,verification_code:o}))];case 4:return c.sent(),[4,this.createLoginState()];case 5:c.sent(),c.label=6;case 6:return[4,this.getSession()];case 7:return i=c.sent().data,[2,{data:{user:(a=(void 0===i?{}:i).session).user,session:a},error:null}];case 8:return u=c.sent(),[2,{data:{},error:new ce(u,{method:"signUp"})}];case 9:return[2]}}))}))}},error:null}];case 4:return r=o.sent(),[2,{data:{},error:new ce(r,{method:"signUp"})}];case 5:return[2]}}))}))},t.prototype.signOut=function(e){var t,r;return Ke(this,void 0,void 0,(function(){var n,o,i;return Je(this,(function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),n=this.cache.keys.userInfoKey,[4,this.oauthInstance.authApi.signOut(e)];case 1:return o=s.sent(),[4,this.cache.removeStoreAsync(n)];case 2:return s.sent(),this.setAccessKey(),null===(t=this.config.eventBus)||void 0===t||t.fire(d.LOGIN_STATE_CHANGED,{eventType:"sign_out"}),null===(r=this.config.eventBus)||void 0===r||r.fire(d.AUTH_STATE_CHANGED,{event:f.SIGNED_OUT}),[2,$e($e({},o),{data:{},error:null})];case 3:return i=s.sent(),[2,{data:{},error:new ce(i,{method:"signOut"})}];case 4:return[2]}}))}))},t.prototype.onAuthStateChange=function(e){var t=this;this.hasListenerSetUp||(this.setupListeners(),this.hasListenerSetUp=!0);var r=Math.random().toString(36);return this.listeners.has(r)||this.listeners.set(r,new Set),this.listeners.get(r).add(e),{data:{subscription:{id:r,callback:e,unsubscribe:function(){var n=t.listeners.get(r);n&&(n.delete(e),0===n.size&&t.listeners.delete(r))}}}}},t.prototype.signInWithPassword=function(e){return Ke(this,void 0,void 0,(function(){var t,r,n,o;return Je(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),this.validateAtLeastOne(e,[["username"],["email"],["phone"]],"You must provide either username, email, or phone"),this.validateParams(e,{password:{required:!0,message:"Password is required"}}),[4,this.signIn($e({username:e.username||e.email||this.formatPhone(e.phone),password:e.password},e.is_encrypt?{isEncrypt:!0,version:"v2"}:{}))];case 1:return i.sent(),[4,this.getSession()];case 2:return t=i.sent().data,[2,{data:{user:(r=(void 0===t?{}:t).session).user,session:r},error:null}];case 3:return n=i.sent(),(o=new ce(n,{method:"signInWithPassword"})).category===ie.PROVIDER_NOT_ENABLED?console.error(o.helpMessage):o.category===ie.INVALID_CREDENTIALS||o.category===ie.USER_NOT_FOUND?console.warn(o.helpMessage):console.warn("[CloudBase Auth] signInWithPassword 失败 [".concat(o.category,"]: ").concat(o.message)),o.loginMethodHint&&console.info(o.loginMethodHint),[2,{data:{},error:o}];case 4:return[2]}}))}))},t.prototype.signInWithIdToken=function(e){return Ke(this,void 0,void 0,(function(){var t,r,n;return Je(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),this.validateParams(e,{token:{required:!0,message:"Token is required"}}),[4,this.signInWithProvider({provider_token:e.token})];case 1:return o.sent(),[4,this.getSession()];case 2:return t=o.sent().data,[2,{data:{user:(r=(void 0===t?{}:t).session).user,session:r},error:null}];case 3:return n=o.sent(),[2,{data:{},error:new ce(n,{method:"signInWithIdToken"})}];case 4:return[2]}}))}))},t.prototype.signInWithOtp=function(e){var t,r,n,o;return Ke(this,void 0,void 0,(function(){var i,s,a=this;return Je(this,(function(u){switch(u.label){case 0:if(!(null===(t=e.options)||void 0===t?void 0:t.emailRedirectTo)&&(void 0===(null===(r=e.options)||void 0===r?void 0:r.shouldCreateUser)||(null===(n=e.options)||void 0===n?void 0:n.shouldCreateUser)))return[2,this.signUp({email:e.email,phone:e.phone})];u.label=1;case 1:return u.trys.push([1,3,,4]),this.validateAtLeastOne(e,[["email"],["phone"]],"You must provide either an email or phone number"),[4,this.getVerification($e({email_redirect_to:null===(o=e.options)||void 0===o?void 0:o.emailRedirectTo},e.email?{email:e.email}:{phone_number:this.formatPhone(e.phone)}))];case 2:return i=u.sent(),[2,{data:{user:null,session:null,verifyOtp:function(t){var r=t.token,n=t.messageId,o=void 0===n?i.verification_id:n;return Ke(a,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.verifyOtp({email:e.email,phone:e.phone,token:r,messageId:o})]}))}))}},error:null}];case 3:return s=u.sent(),[2,{data:{},error:new ce(s,{method:"signInWithOtp"})}];case 4:return[2]}}))}))},t.prototype.verifyOAuth=function(e){return Ke(this,void 0,void 0,(function(){var t,r,n,o,i,s,a,u,c;return Je(this,(function(l){switch(l.label){case 0:t={},l.label=1;case 1:return l.trys.push([1,7,,8]),r=(null==e?void 0:e.code)||A.P6.getQuery("code"),n=(null==e?void 0:e.state)||A.P6.getQuery("state"),r?n?(o=function(e){try{return JSON.parse(sessionStorage.getItem(e))}catch(e){return console.error("Failed to get browser session:",e),null}}(n),t.type=null==o?void 0:o.type,(i=(null==e?void 0:e.provider)||(null==o?void 0:o.provider)||A.P6.getQuery("provider"))?[4,this.grantProviderToken({provider_id:i,provider_redirect_uri:location.origin+location.pathname,provider_code:r})]:[2,{data:t,error:new ce({message:"Provider is required"})}]):[2,{data:{},error:new ce({message:"State is required"})}]:[2,{data:{},error:new ce({message:"Code is required"})}];case 2:return s=l.sent().provider_token,a=void 0,o.type!==h.BIND_IDENTITY?[3,4]:[4,this.oauthInstance.authApi.toBindIdentity({provider_token:s,provider:i,fireEvent:!0})];case 3:return a=l.sent(),[3,6];case 4:return[4,this.signInWithIdToken({token:s})];case 5:(a=l.sent()).data=$e($e({},t),a.data),l.label=6;case 6:return(u=new URLSearchParams(null===location||void 0===location?void 0:location.search)).delete("code"),u.delete("state"),a.data.redirectUrl=function(e,t){if(void 0!==e){var r=new URL(window.location.href);return r.search=e,r.hash=t||r.hash,window.history.replaceState({},"",r.href),r.href}}(void 0===(null==o?void 0:o.search)?"?".concat(u.toString()):null==o?void 0:o.search,(null==o?void 0:o.hash)||location.hash),function(e){try{return sessionStorage.removeItem(e),!0}catch(e){return console.error("Failed to remove browser session:",e),null}}(n),[2,a];case 7:return c=l.sent(),[2,{data:t,error:new ce(c,{method:"verifyOAuth"})}];case 8:return[2]}}))}))},t.prototype.signInWithOAuth=function(e){var t,r,n,o,i;return Ke(this,void 0,void 0,(function(){var s,a,u,c,l,f,d,p,v;return Je(this,(function(y){switch(y.label){case 0:return y.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}}),s=(null===(t=e.options)||void 0===t?void 0:t.redirectTo)||location.href,a=new URL(s),u=a.origin+a.pathname,c=(null===(r=e.options)||void 0===r?void 0:r.state)||"prd-".concat(e.provider,"-").concat(Math.random().toString(36).slice(2)),[4,this.genProviderRedirectUri({provider_id:e.provider,provider_redirect_uri:u,state:c})];case 1:return l=y.sent().uri,f=decodeURIComponent(l),d=f,(null===(n=e.options)||void 0===n?void 0:n.queryParams)&&(p=new URL(f),Object.entries(e.options.queryParams).forEach((function(e){var t=e[0],r=e[1];p.searchParams.set(t,r)})),d=p.toString()),function(e,t){try{sessionStorage.setItem(e,JSON.stringify(t))}catch(e){console.error("Failed to save to browser session:",e)}}(c,{provider:e.provider,search:a.search,hash:a.hash,type:(null===(o=e.options)||void 0===o?void 0:o.type)||h.SIGN_IN}),Ye()&&!(null===(i=e.options)||void 0===i?void 0:i.skipBrowserRedirect)&&window.location.assign(d),[2,{data:{url:d,provider:e.provider},error:null}];case 2:return v=y.sent(),[2,{data:{},error:new ce(v,{method:"signInWithOAuth"})}];case 3:return[2]}}))}))},t.prototype.getClaims=function(){return Ke(this,void 0,void 0,(function(){var e;return Je(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.getAccessToken()];case 1:return[2,{data:function(e){if("string"!=typeof e)throw new Error("Invalid token specified");try{var t=e.split(".").map(((e,t)=>2===t?e:JSON.parse(function(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("Illegal base64url string!")}try{return function(e){return decodeURIComponent(E(e).replace(/(.)/g,(e=>{var t=e.charCodeAt(0).toString(16).toUpperCase();return t.length<2&&(t="0".concat(t)),"%".concat(t)})))}(t)}catch(e){return E(t)}}(e))));return{claims:t[1],header:t[0],signature:t[2]}}catch(e){throw new Error("Invalid token specified: ".concat(e)?e.message:0)}}(t.sent().accessToken),error:null}];case 2:return e=t.sent(),[2,{data:{},error:new ce(e,{method:"getClaims"})}];case 3:return[2]}}))}))},t.prototype.resetPasswordForEmail=function(e,t){return Ke(this,void 0,void 0,(function(){var r,n,o,i,s,a,u=this;return Je(this,(function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),this.validateParams({emailOrPhone:e},{emailOrPhone:{required:!0,message:"Email or phone is required"}}),r=(t||{}).redirectTo,n=e.includes("@"),o=void 0,n?o={email:e}:(i=this.formatPhone(e),o={phone_number:i}),[4,this.getVerification(o)];case 1:return s=c.sent(),[2,{data:{updateUser:function(t){return Ke(u,void 0,void 0,(function(){var o,i,a,u;return Je(this,(function(c){switch(c.label){case 0:this.validateParams(t,{nonce:{required:!0,message:"Nonce is required"},password:{required:!0,message:"Password is required"}}),c.label=1;case 1:return c.trys.push([1,5,,6]),[4,this.verify({verification_id:s.verification_id,verification_code:t.nonce})];case 2:return o=c.sent(),[4,this.oauthInstance.authApi.resetPassword({email:n?e:void 0,phone_number:n?void 0:e,new_password:t.password,verification_token:o.verification_token})];case 3:return c.sent(),null===(u=this.config.eventBus)||void 0===u||u.fire(d.AUTH_STATE_CHANGED,{event:f.PASSWORD_RECOVERY}),[4,this.signInWithPassword({email:n?e:void 0,phone:n?void 0:e,password:t.password})];case 4:return i=c.sent(),r&&Ye()&&window.location.assign(r),[2,i];case 5:return a=c.sent(),[2,{data:{},error:new ce(a,{method:"resetPasswordForEmail"})}];case 6:return[2]}}))}))}},error:null}];case 2:return a=c.sent(),[2,{data:{},error:new ce(a,{method:"resetPasswordForEmail"})}];case 3:return[2]}}))}))},t.prototype.resetPasswordForOld=function(e){return Ke(this,void 0,void 0,(function(){var t,r,n;return Je(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,this.oauthInstance.authApi.updatePasswordByOld({old_password:e.old_password,new_password:e.new_password})];case 1:return o.sent(),[4,this.getSession()];case 2:return t=o.sent().data,[2,{data:{user:(r=(void 0===t?{}:t).session).user,session:r},error:null}];case 3:return n=o.sent(),[2,{data:{},error:new ce(n,{method:"resetPasswordForOld"})}];case 4:return[2]}}))}))},t.prototype.verifyOtp=function(e){return Ke(this,void 0,void 0,(function(){var t,r,n,o;return Je(this,(function(i){switch(i.label){case 0:return i.trys.push([0,6,,7]),t=e.type,this.validateParams(e,{token:{required:!0,message:"Token is required"},messageId:{required:!0,message:"messageId is required"}}),["phone_change","email_change"].includes(t)?[4,this.verify({verification_id:e.messageId,verification_code:e.token})]:[3,2];case 1:return i.sent(),[3,4];case 2:return[4,this.signInWithUsername({verificationInfo:{verification_id:e.messageId,is_user:!0},verificationCode:e.token,username:e.email||this.formatPhone(e.phone)||"",loginType:e.email?"email":"phone"})];case 3:i.sent(),i.label=4;case 4:return[4,this.getSession()];case 5:return r=i.sent().data,[2,{data:{user:(n=(void 0===r?{}:r).session).user,session:n},error:null}];case 6:return o=i.sent(),[2,{data:{},error:new ce(o,{method:"verifyOtp"})}];case 7:return[2]}}))}))},t.prototype.getSession=function(){return Ke(this,void 0,void 0,(function(){var e,t,r,n;return Je(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,this.oauthInstance.oauth2client.getCredentials()];case 1:return(e=o.sent())&&"accessKey"!==e.scope?[4,this.getUser(!1)]:[2,{data:{session:null},error:null}];case 2:return t=o.sent().data,r=(void 0===t?{}:t).user,[2,{data:{session:$e($e({},e),{user:r}),user:r},error:null}];case 3:return n=o.sent(),[2,{data:{},error:new ce(n,{method:"getSession"})}];case 4:return[2]}}))}))},t.prototype.refreshSession=function(e){return Ke(this,void 0,void 0,(function(){var t,r,n,o,i;return Je(this,(function(s){switch(s.label){case 0:return s.trys.push([0,4,,5]),[4,this.oauthInstance.oauth2client.localCredentials.getCredentials()];case 1:return(t=s.sent()).refresh_token=e||t.refresh_token,[4,this.oauthInstance.oauth2client.refreshToken(t)];case 2:return r=s.sent(),[4,this.getUser(!1)];case 3:return n=s.sent().data,[2,{data:{user:o=(void 0===n?{}:n).user,session:$e($e({},r),{user:o})},error:null}];case 4:return i=s.sent(),[2,{data:{},error:new ce(i,{method:"refreshSession"})}];case 5:return[2]}}))}))},t.prototype.getUser=function(e){return void 0===e&&(e=!0),Ke(this,void 0,void 0,(function(){var t,r;return Je(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),t=this.convertToUser,[4,this.getCurrentUser(e)];case 1:return[2,{data:{user:t.apply(this,[n.sent()])},error:null}];case 2:return r=n.sent(),[2,{data:{},error:new ce(r,{method:"getUser"})}];case 3:return[2]}}))}))},t.prototype.refreshUser=function(){return Ke(this,void 0,void 0,(function(){var e,t,r;return Je(this,(function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),[4,this.currentUser.refresh()];case 1:return n.sent(),[4,this.getSession()];case 2:return e=n.sent().data,[2,{data:{user:(t=(void 0===e?{}:e).session).user,session:t},error:null}];case 3:return r=n.sent(),[2,{data:{},error:new ce(r,{method:"refreshUser"})}];case 4:return[2]}}))}))},t.prototype.updateUser=function(e){var t;return Ke(this,void 0,void 0,(function(){var r,n,o,i,s,a,u,c,l,h,p,v,y=this;return Je(this,(function(m){switch(m.label){case 0:if(m.trys.push([0,8,,9]),!Object.keys(e).some((function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]})))throw new ce({message:"At least one field must be provided for update"});return r=e.email,n=e.phone,o=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(e,["email","phone"]),s=void 0!==n,a={},(i=void 0!==r)||s?(u=void 0,i?(u={email:e.email},c="email_change"):(l=this.formatPhone(e.phone),u={phone_number:l},c="phone_change"),[4,this.getVerification(u)]):[3,4];case 1:return h=m.sent(),Object.keys(o).length>0?[4,this.updateUserBasicInfo(o)]:[3,3];case 2:m.sent(),m.label=3;case 3:return a={messageId:h.verification_id,verifyOtp:function(t){return Ke(y,void 0,void 0,(function(){var r,n,o;return Je(this,(function(s){switch(s.label){case 0:return s.trys.push([0,11,,12]),t.email&&e.email===t.email?[4,this.verifyOtp({type:"email_change",email:e.email,token:t.token,messageId:h.verification_id})]:[3,3];case 1:return s.sent(),[4,this.updateUserBasicInfo({email:e.email})];case 2:return s.sent(),[3,9];case 3:return t.phone&&e.phone===t.phone?[4,this.verifyOtp({type:"phone_change",phone:e.phone,token:t.token,messageId:h.verification_id})]:[3,6];case 4:return s.sent(),[4,this.updateUserBasicInfo({phone:this.formatPhone(e.phone)})];case 5:return s.sent(),[3,9];case 6:return[4,this.verifyOtp({type:c,email:i?e.email:void 0,phone:i?void 0:e.phone,token:t.token,messageId:h.verification_id})];case 7:return s.sent(),[4,this.updateUserBasicInfo(e)];case 8:s.sent(),s.label=9;case 9:return[4,this.getUser(!1)];case 10:return r=s.sent().data.user,null===(o=this.config.eventBus)||void 0===o||o.fire(d.AUTH_STATE_CHANGED,{event:f.USER_UPDATED}),[2,{data:{user:r},error:null}];case 11:return n=s.sent(),[2,{data:{},error:new ce(n,{method:"updateUser"})}];case 12:return[2]}}))}))}},[3,6];case 4:return[4,this.updateUserBasicInfo(e)];case 5:m.sent(),m.label=6;case 6:return[4,this.getUser(!1)];case 7:return p=m.sent().data.user,null===(t=this.config.eventBus)||void 0===t||t.fire(d.AUTH_STATE_CHANGED,{event:f.USER_UPDATED}),[2,{data:$e({user:p},a),error:null}];case 8:return v=m.sent(),[2,{data:{},error:new ce(v,{method:"updateUser"})}];case 9:return[2]}}))}))},t.prototype.getUserIdentities=function(){var e;return Ke(this,void 0,void 0,(function(){var t,r;return Je(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.oauthInstance.authApi.getProviders()];case 1:return t=n.sent(),[2,{data:{identities:null===(e=null==t?void 0:t.data)||void 0===e?void 0:e.filter((function(e){return!!e.bind}))},error:null}];case 2:return r=n.sent(),[2,{data:{},error:new ce(r,{method:"getUserIdentities"})}];case 3:return[2]}}))}))},t.prototype.linkIdentity=function(e){return Ke(this,void 0,void 0,(function(){var t;return Je(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}}),[4,this.signInWithOAuth({provider:e.provider,options:{type:h.BIND_IDENTITY}})];case 1:return r.sent(),[2,{data:{provider:e.provider},error:null}];case 2:return t=r.sent(),[2,{data:{},error:new ce(t,{method:"linkIdentity"})}];case 3:return[2]}}))}))},t.prototype.unlinkIdentity=function(e){return Ke(this,void 0,void 0,(function(){var t;return Je(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}}),[4,this.oauthInstance.authApi.unbindProvider({provider_id:e.provider})];case 1:return r.sent(),[2,{data:{},error:null}];case 2:return t=r.sent(),[2,{data:{},error:new ce(t,{method:"unlinkIdentity"})}];case 3:return[2]}}))}))},t.prototype.reauthenticate=function(){return Ke(this,void 0,void 0,(function(){var e,t,r,n,o=this;return Je(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,this.getUser(!1)];case 1:return e=i.sent().data.user,this.validateAtLeastOne(e,[["email","phone"]],"You must provide either an email or phone number"),t=e.email?{email:e.email}:{phone_number:this.formatPhone(e.phone)},[4,this.getVerification(t)];case 2:return r=i.sent(),[2,{data:{updateUser:function(e){return Ke(o,void 0,void 0,(function(){var n,o,i,s,a;return Je(this,(function(u){switch(u.label){case 0:this.validateParams(e,{nonce:{required:!0,message:"Nonce is required"}}),u.label=1;case 1:return u.trys.push([1,9,,10]),e.password?[4,this.verify({verification_id:r.verification_id,verification_code:e.nonce})]:[3,5];case 2:return n=u.sent(),[4,this.oauthInstance.authApi.sudo({verification_token:n.verification_token})];case 3:return o=u.sent(),[4,this.oauthInstance.authApi.setPassword({new_password:e.password,sudo_token:o.sudo_token})];case 4:return u.sent(),[3,7];case 5:return[4,this.signInWithUsername($e($e({verificationInfo:r,verificationCode:e.nonce},t),{loginType:t.email?"email":"phone"}))];case 6:u.sent(),u.label=7;case 7:return[4,this.getSession()];case 8:return i=u.sent().data,[2,{data:{user:(s=(void 0===i?{}:i).session).user,session:s},error:null}];case 9:return a=u.sent(),[2,{data:{},error:new ce(a,{method:"reauthenticate"})}];case 10:return[2]}}))}))}},error:null}];case 3:return n=i.sent(),[2,{data:{},error:new ce(n,{method:"reauthenticate"})}];case 4:return[2]}}))}))},t.prototype.resend=function(e){return Ke(this,void 0,void 0,(function(){var t,r,n;return Je(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),this.validateAtLeastOne(e,[["email"],["phone"]],"You must provide either an email or phone number"),t="signup"===e.type?"ANY":"USER",r={target:t},"email"in e&&(r.email=e.email),"phone"in e&&(r.phone_number=this.formatPhone(e.phone)),[4,this.oauthInstance.authApi.getVerification(r)];case 1:return[2,{data:{messageId:o.sent().verification_id},error:null}];case 2:return n=o.sent(),[2,{data:{},error:new ce(n,{method:"resend"})}];case 3:return[2]}}))}))},t.prototype.setSession=function(e){var t;return Ke(this,void 0,void 0,(function(){var r,n,o;return Je(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),this.validateParams(e,{access_token:{required:!0,message:"Access token is required"},refresh_token:{required:!0,message:"Refresh token is required"}}),[4,this.oauthInstance.oauth2client.refreshToken(e,{throwError:!0})];case 1:return i.sent(),[4,this.getSession()];case 2:return r=i.sent().data,n=(void 0===r?{}:r).session,null===(t=this.config.eventBus)||void 0===t||t.fire(d.AUTH_STATE_CHANGED,{event:f.SIGNED_IN}),[2,{data:{user:n.user,session:n},error:null}];case 3:return o=i.sent(),[2,{data:{},error:new ce(o,{method:"setSession"})}];case 4:return[2]}}))}))},t.prototype.exchangeCodeForSession=function(){return Ke(this,void 0,void 0,(function(){return Je(this,(function(e){return[2]}))}))},t.prototype.deleteUser=function(e){return Ke(this,void 0,void 0,(function(){var t,r;return Je(this,(function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),this.validateParams(e,{password:{required:!0,message:"Password is required"}}),[4,this.oauthInstance.authApi.sudo(e)];case 1:return t=n.sent().sudo_token,[4,this.oauthInstance.authApi.deleteMe({sudo_token:t})];case 2:return n.sent(),[2,{data:{},error:null}];case 3:return r=n.sent(),[2,{data:{},error:new ce(r,{method:"deleteUser"})}];case 4:return[2]}}))}))},t.prototype.toDefaultLoginPage=function(e){return void 0===e&&(e={}),Ke(this,void 0,void 0,(function(){var t,r,n,o,i;return Je(this,(function(s){try{return t=e.config_version||"env",r=Object.keys(e.query||{}).map((function(t){return"".concat(t,"=").concat(e.query[t])})).join("&"),Re.ZP.isMatch()?wx.navigateTo({url:"/packages/$wd_system/pages/login/index".concat(r?"?".concat(r):"")}):(n=e.redirect_uri||window.location.href,o=new URL(n),i="".concat(o.origin,"/__auth/?app_id=").concat(e.app_id||"","&env_id=").concat(this.config.env,"&client_id=").concat(this.config.clientId||this.config.env,"&config_version=").concat(t,"&redirect_uri=").concat(encodeURIComponent(n)).concat(r?"&".concat(r):""),window.location.href=i),[2,{data:{},error:null}]}catch(e){return[2,{data:{},error:new ce(e,{method:"toDefaultLoginPage"})}]}return[2]}))}))},t.prototype.signInWithCustomTicket=function(e){return Ke(this,void 0,void 0,(function(){var t,r,n,o;return Je(this,(function(i){switch(i.label){case 0:e&&this.setCustomSignFunc(e),i.label=1;case 1:return i.trys.push([1,5,,6]),[4,this.oauthInstance.authApi.signInWithCustomTicket()];case 2:return i.sent(),[4,this.createLoginState()];case 3:return t=i.sent(),[4,this.getSession()];case 4:return r=i.sent().data,n=(void 0===r?{}:r).session,[2,$e($e({},t),{data:{user:n.user,session:n},error:null})];case 5:return o=i.sent(),[2,{data:{},error:new ce(o,{method:"signInWithCustomTicket"})}];case 6:return[2]}}))}))},t.prototype.signInWithOpenId=function(e){var t=(void 0===e?{}:e).useWxCloud,r=void 0===t||t;return Ke(this,void 0,void 0,(function(){var e,t,n,o,i,s,a=this;return Je(this,(function(u){switch(u.label){case 0:if(!Re.ZP.isMatch())throw Error("wx api undefined");e=wx.getAccountInfoSync().miniProgram,t=function(t){return Ke(a,void 0,void 0,(function(){var n,o;return Je(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==e?void 0:e.appId,provider_code:t,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.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]}}))}))},u.label=1;case 1:return u.trys.push([1,5,,6]),[4,new Promise((function(e,r){wx.login({success:function(n){return Ke(a,void 0,void 0,(function(){var o;return Je(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,t(n.code)];case 1:return i.sent(),e(!0),[3,3];case 2:return o=i.sent(),r(o),[3,3];case 3:return[2]}}))}))},fail:function(e){var t=new Error(null==e?void 0:e.errMsg);t.code=null==e?void 0:e.errno,r(t)}})}))];case 2:return u.sent(),[4,this.createLoginState()];case 3:return n=u.sent(),[4,this.getSession()];case 4:return o=u.sent().data,i=(void 0===o?{}:o).session,[2,$e($e({},n),{data:{user:i.user,session:i},error:null})];case 5:return s=u.sent(),[2,{data:{},error:new ce(s,{method:"signInWithOpenId"})}];case 6:return[2]}}))}))},t.prototype.signInWithPhoneAuth=function(e){var t=e.phoneCode,r=void 0===t?"":t,n=e.useWxCloud,o=void 0!==n&&n;return Ke(this,void 0,void 0,(function(){var e,t,n,i,s,a,u,c,l;return Je(this,(function(f){switch(f.label){case 0:return Re.ZP.isMatch()?(e=wx.getAccountInfoSync().miniProgram,t={provider_params:{provider_code_type:"phone",code:r,appid:e.appId},provider_id:e.appId},[4,wx.login()]):[2,{data:{},error:new ce({message:"wx api undefined"})}];case 1:n=f.sent().code,t.provider_code=n,f.label=2;case 2:return f.trys.push([2,5,,6]),[4,this.oauthInstance.authApi.grantProviderToken(t,o)];case 3:if((i=f.sent()).error_code)throw i;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:i.provider_token},o)];case 4:if(null==(s=f.sent())?void 0:s.error_code)throw s;return[3,6];case 5:return a=f.sent(),[2,{data:{},error:new ce(a,{method:"signInWithPhoneAuth"})}];case 6:return[4,this.createLoginState()];case 7:return u=f.sent(),[4,this.getSession()];case 8:return c=f.sent().data,l=(void 0===c?{}:c).session,[2,$e($e({},u),{data:{user:l.user,session:l},error:null})]}}))}))},t.prototype.bindPhoneNumber=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.editContact(e)]}))}))},t.prototype.unbindProvider=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.unbindProvider(e)]}))}))},t.prototype.bindEmail=function(e){return this.oauthInstance.authApi.editContact(e)},t.prototype.verify=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.verify(e)]}))}))},t.prototype.getVerification=function(e,t){return Ke(this,void 0,void 0,(function(){return Je(this,(function(r){return e.phone_number&&(e.phone_number=this.formatPhone(e.phone_number)),[2,this.oauthInstance.authApi.getVerification(e,t)]}))}))},Object.defineProperty(t.prototype,"currentUser",{get:function(){if("async"!==this.cache.mode){var e=this.hasLoginState();return e&&e.user||null}(0,F.printWarn)(Oe.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrentUser instead")},enumerable:!1,configurable:!0}),t.prototype.getCurrentUser=function(e){return void 0===e&&(e=!0),Ke(this,void 0,void 0,(function(){var t,r,n;return Je(this,(function(o){switch(o.label){case 0:return o.trys.push([0,4,,5]),e?[4,this.getLoginState()]:[3,3];case 1:return(t=o.sent())?[4,t.user.refresh()]:[3,3];case 2:o.sent(),o.label=3;case 3:return[3,5];case 4:return o.sent(),[3,5];case 5:return[4,this.getLoginState()];case 6:return(r=o.sent())?(n=r.user.getLocalUserInfo(),[4,r.user.checkLocalInfoAsync()]):[3,8];case 7:return o.sent(),[2,$e($e({},r.user),n)];case 8:return[2,null]}}))}))},t.prototype.signInAnonymouslyInWx=function(e){var t=(void 0===e?{}:e).useWxCloud;return Ke(this,void 0,void 0,(function(){var e,r,n=this;return Je(this,(function(o){switch(o.label){case 0:if(!Re.ZP.isMatch())throw Error("wx api undefined");return e=wx.getAccountInfoSync().miniProgram,r=function(r){return Ke(n,void 0,void 0,(function(){var n,o;return Je(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==e?void 0:e.appId,provider_code:r,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.appId}},t)];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},t)];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(e,t){wx.login({success:function(o){return Ke(n,void 0,void 0,(function(){var n;return Je(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,r(o.code)];case 1:return i.sent(),e(!0),[3,3];case 2:return n=i.sent(),t(n),[3,3];case 3:return[2]}}))}))},fail:function(e){var r=new Error(null==e?void 0:e.errMsg);r.code=null==e?void 0:e.errno,t(r)}})}))];case 1:return o.sent(),[2,this.createLoginState(void 0,{asyncRefreshUser:!0})]}}))}))},t.prototype.bindOpenId=function(){return Ke(this,void 0,void 0,(function(){var e,t,r=this;return Je(this,(function(n){switch(n.label){case 0:if(!Re.ZP.isMatch())throw Error("wx api undefined");return e=wx.getAccountInfoSync().miniProgram,t=function(t){return Ke(r,void 0,void 0,(function(){var r;return Je(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==e?void 0:e.appId,provider_code:t,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.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(e,n){wx.login({success:function(o){return Ke(r,void 0,void 0,(function(){var r;return Je(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,t(o.code)];case 1:return i.sent(),e(!0),[3,3];case 2:return r=i.sent(),n(r),[3,3];case 3:return[2]}}))}))},fail:function(e){var t=new Error(null==e?void 0:e.errMsg);t.code=null==e?void 0:e.errno,n(t)}})}))];case 1:return n.sent(),[2]}}))}))},t.prototype.signInWithUnionId=function(){return Ke(this,void 0,void 0,(function(){var e=this;return Je(this,(function(t){switch(t.label){case 0:if(!Re.ZP.isMatch())throw Error("wx api undefined");t.label=1;case 1:return t.trys.push([1,3,,4]),[4,new Promise((function(t,r){var n=wx.getAccountInfoSync().miniProgram;wx.login({success:function(o){return Ke(e,void 0,void 0,(function(){var e,i,s,a,u;return Je(this,(function(c){switch(c.label){case 0:e=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:e,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:e,provider_token:s})]:(r(i),[2]);case 3:return(null==(a=c.sent())?void 0:a.error_code)?(r(a),[2]):(t(!0),[3,5]);case 4:return u=c.sent(),r(u),[3,5];case 5:return[2]}}))}))},fail:function(e){var t=new Error(null==e?void 0:e.errMsg);t.code=null==e?void 0:e.errno,r(t)}})}))];case 2:return t.sent(),[3,4];case 3:throw t.sent();case 4:return[2,this.createLoginState()]}}))}))},t.prototype.signInWithSms=function(e){var t=e.verificationInfo,r=void 0===t?{verification_id:"",is_user:!1}:t,n=e.verificationCode,o=void 0===n?"":n,i=e.phoneNum,s=void 0===i?"":i,a=e.bindInfo,u=void 0===a?void 0:a;return Ke(this,void 0,void 0,(function(){return Je(this,(function(e){try{return[2,this.signInWithUsername({verificationInfo:r,verificationCode:o,bindInfo:u,username:s,loginType:"sms"})]}catch(e){throw e}return[2]}))}))},t.prototype.signInWithEmail=function(e){var t=e.verificationInfo,r=void 0===t?{verification_id:"",is_user:!1}:t,n=e.verificationCode,o=void 0===n?"":n,i=e.bindInfo,s=void 0===i?void 0:i,a=e.email,u=void 0===a?"":a;return Ke(this,void 0,void 0,(function(){return Je(this,(function(e){try{return[2,this.signInWithUsername({verificationInfo:r,verificationCode:o,bindInfo:s,username:u,loginType:"email"})]}catch(e){throw e}return[2]}))}))},t.prototype.setCustomSignFunc=function(e){this.oauthInstance.authApi.setCustomSignFunc(e)},t.prototype.signIn=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signIn(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}}))}))},t.prototype.setPassword=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.setPassword(e)]}))}))},t.prototype.isUsernameRegistered=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){switch(t.label){case 0:return"string"!=typeof e&&(0,F.throwError)(Oe.ERRORS.INVALID_PARAMS,"username must be a string"),[4,this.oauthInstance.authApi.checkIfUserExist({username:e})];case 1:return[2,t.sent().exist]}}))}))},t.prototype.hasLoginState=function(){var e;if("async"!==this.cache.mode)return(null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.hasLoginStateSync())?new Xe({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance}):null;(0,F.printWarn)(Oe.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState instead")},t.prototype.getLoginState=function(){return Ke(this,void 0,void 0,(function(){var e;return Je(this,(function(t){switch(t.label){case 0:e=null,t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.oauthInstance.authApi.getLoginState()];case 2:return e=t.sent(),[3,4];case 3:return t.sent(),[2,null];case 4:return e?[2,new Xe({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})]:[2,null]}}))}))},t.prototype.getUserInfo=function(){return Ke(this,void 0,void 0,(function(){return Je(this,(function(e){return[2,this.getCurrentUser()]}))}))},t.prototype.getWedaUserInfo=function(){return Ke(this,void 0,void 0,(function(){return Je(this,(function(e){return[2,this.oauthInstance.authApi.getWedaUserInfo()]}))}))},t.prototype.updateUserBasicInfo=function(e){return Ke(this,void 0,void 0,(function(){var t;return Je(this,(function(r){switch(r.label){case 0:return[4,this.getLoginState()];case 1:return(t=r.sent())?[4,t.user.updateUserBasicInfo(e)]:[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(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.bindWithProvider(e)]}))}))},t.prototype.queryUser=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.queryUserProfile(e)]}))}))},t.prototype.getAccessToken=function(){return Ke(this,void 0,void 0,(function(){return Je(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.oauth2client.getAccessToken()];case 1:return[2,{accessToken:e.sent(),env:this.config.env}]}}))}))},t.prototype.grantProviderToken=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.grantProviderToken(e)]}))}))},t.prototype.patchProviderToken=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.patchProviderToken(e)]}))}))},t.prototype.signInWithProvider=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signInWithProvider(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}}))}))},t.prototype.signInWithWechat=function(e){return void 0===e&&(e={}),Ke(this,void 0,void 0,(function(){return Je(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signInWithWechat(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}}))}))},t.prototype.grantToken=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.grantToken(e)];case 1:return t.sent(),[2,this.createLoginState()]}}))}))},t.prototype.genProviderRedirectUri=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.genProviderRedirectUri(e)]}))}))},t.prototype.resetPassword=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.resetPassword(e)]}))}))},t.prototype.deviceAuthorize=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.deviceAuthorize(e)]}))}))},t.prototype.sudo=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.sudo(e)]}))}))},t.prototype.deleteMe=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.deleteMe(e)]}))}))},t.prototype.getProviders=function(){return Ke(this,void 0,void 0,(function(){return Je(this,(function(e){return[2,this.oauthInstance.authApi.getProviders()]}))}))},t.prototype.loginScope=function(){return Ke(this,void 0,void 0,(function(){return Je(this,(function(e){return[2,this.oauthInstance.authApi.loginScope()]}))}))},t.prototype.loginGroups=function(){return Ke(this,void 0,void 0,(function(){return Je(this,(function(e){return[2,this.oauthInstance.authApi.loginGroups()]}))}))},t.prototype.onLoginStateChanged=function(e){var t;return Ke(this,void 0,void 0,(function(){var r,n=this;return Je(this,(function(o){switch(o.label){case 0:return null===(t=this.config.eventBus)||void 0===t||t.on(d.LOGIN_STATE_CHANGED,(function(t){return Ke(n,void 0,void 0,(function(){var r,n,o;return Je(this,(function(i){switch(i.label){case 0:return(null===(o=null==t?void 0:t.data)||void 0===o?void 0:o.eventType)===l?[3,2]:[4,this.getLoginState()];case 1:return n=i.sent(),[3,3];case 2:n={},i.label=3;case 3:return r=n,e.call(this,$e($e({},t),r)),[2]}}))}))})),[4,this.getLoginState()];case 1:return r=o.sent(),e.call(this,r),[2]}}))}))},t.prototype.refreshTokenForce=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.refreshTokenForce(e)]}))}))},t.prototype.getCredentials=function(){return Ke(this,void 0,void 0,(function(){return Je(this,(function(e){return[2,this.oauthInstance.authApi.getCredentials()]}))}))},t.prototype.setCredentials=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.oauth2client.setCredentials(e)];case 1:return t.sent(),[2]}}))}))},t.prototype.getProviderSubType=function(){return Ke(this,void 0,void 0,(function(){return Je(this,(function(e){return[2,this.oauthInstance.authApi.getProviderSubType()]}))}))},t.prototype.createCaptchaData=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.createCaptchaData(e)]}))}))},t.prototype.verifyCaptchaData=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.verifyCaptchaData(e)]}))}))},t.prototype.getMiniProgramQrCode=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.getMiniProgramCode(e)]}))}))},t.prototype.getMiniProgramQrCodeStatus=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.getMiniProgramQrCodeStatus(e)]}))}))},t.prototype.modifyPassword=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.modifyPassword(e)]}))}))},t.prototype.modifyPasswordWithoutLogin=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.modifyPasswordWithoutLogin(e)]}))}))},t.prototype.getUserBehaviorLog=function(e){return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){return[2,this.oauthInstance.authApi.getUserBehaviorLog(e)]}))}))},t.prototype.signInWithUsername=function(e){var t=e.verificationInfo,r=void 0===t?{verification_id:"",is_user:!1}:t,n=e.verificationCode,o=void 0===n?"":n,i=e.username,s=void 0===i?"":i,a=e.bindInfo,u=void 0===a?void 0:a,c=e.loginType,l=void 0===c?"":c;return Ke(this,void 0,void 0,(function(){var e,t,n,i,a,c,f;return Je(this,(function(d){switch(d.label){case 0:return d.trys.push([0,8,,9]),[4,this.oauthInstance.authApi.verify({verification_id:r.verification_id,verification_code:o})];case 1:if(null==(e=d.sent())?void 0:e.error_code)throw e;return t=e.verification_token,n=this.formatPhone(s),i={phone_number:n},"email"===l&&(i={email:n=s}),r.is_user?[4,this.oauthInstance.authApi.signIn({username:n,verification_token:t})]:[3,5];case 2:if(null==(a=d.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=d.sent())?void 0:c.error_code)throw c;d.label=4;case 4:return[3,7];case 5:return[4,this.oauthInstance.authApi.signUp($e($e({},i),{verification_token:t,provider_token:null==u?void 0:u.providerId}))];case 6:if(null==(f=d.sent())?void 0:f.error_code)throw f;d.label=7;case 7:return[2,this.createLoginState()];case 8:throw d.sent();case 9:return[2]}}))}))},t.prototype.createLoginState=function(e,t){var r,n;return Ke(this,void 0,void 0,(function(){var o;return Je(this,(function(i){switch(i.label){case 0:return[4,(o=new Xe({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})).checkLocalStateAsync()];case 1:return i.sent(),(null==t?void 0:t.userInfo)?(o.user.setLocalUserInfo(t.userInfo),[3,5]):[3,2];case 2:return(null==t?void 0:t.asyncRefreshUser)?(o.user.refresh(e),[3,5]):[3,3];case 3:return[4,o.user.refresh(e)];case 4:i.sent(),i.label=5;case 5:return null===(r=this.config.eventBus)||void 0===r||r.fire(d.LOGIN_STATE_CHANGED,{eventType:"sign_in"}),null===(n=this.config.eventBus)||void 0===n||n.fire(d.AUTH_STATE_CHANGED,{event:f.SIGNED_IN}),[2,o]}}))}))},t.prototype.setAccessKey=function(){var e,t;return Ke(this,void 0,void 0,(function(){var r,n;return Je(this,(function(o){if(r="",n="",this.config.accessKey?(r=this.config.accessKey,n="accessKey"):(null===(e=this.config.auth)||void 0===e?void 0:e.secretId)&&(null===(t=this.config.auth)||void 0===t?void 0:t.secretKey)&&(r="",n=p),!n)return[2];try{this.oauthInstance.oauth2client.setAccessKeyCredentials({access_token:r,token_type:"Bearer",scope:n,expires_at:new Date(+new Date+ +new Date),expires_in:+new Date+ +new Date})}catch(e){console.warn("accessKey error: ",e)}return[2]}))}))},t.prototype.formatPhone=function(e){return!/\s+/.test(e)&&/^\+\d{1,3}\d+/.test(e)?e.replace(/^(\+\d{1,2})(\d+)$/,"$1 $2"):/^\+\d{1,3}\s+/.test(e)?e:"+86 ".concat(e)},t.prototype.notifyListeners=function(e,t,r){this.listeners.forEach((function(n){n.forEach((function(n){try{n(e,t,r)}catch(e){console.error("Error in auth state change callback:",e)}}))}))},t.prototype.setupListeners=function(){var e,t=this;null===(e=this.config.eventBus)||void 0===e||e.on(d.AUTH_STATE_CHANGED,(function(e){return Ke(t,void 0,void 0,(function(){var t,r,n,o,i;return Je(this,(function(s){switch(s.label){case 0:return t=null===(o=null==e?void 0:e.data)||void 0===o?void 0:o.event,r=null===(i=null==e?void 0:e.data)||void 0===i?void 0:i.info,[4,this.getSession()];case 1:return n=s.sent().data.session,this.notifyListeners(t,n,r),[2]}}))}))}))},t.prototype.convertToUser=function(e){var t,r,n,o,i;if(!e)return null;var s=(null==e?void 0:e.email)||"",a=(null==e?void 0:e.phone_number)||"",u=(null==e?void 0:e.sub)||(null==e?void 0:e.uid)||"";return{id:u,aud:"authenticated",role:null===(r=null===(t=e.groups)||void 0===t?void 0:t.map)||void 0===r?void 0:r.call(t,(function(e){return"string"==typeof e?e:e.id})),email:s||"",email_confirmed_at:(null==e||e.email_verified,e.created_at),phone:a,phone_confirmed_at:a?e.created_at:void 0,confirmed_at:e.created_at,last_sign_in_at:e.last_sign_in_at,app_metadata:{provider:(null===(n=e.loginType)||void 0===n?void 0:n.toLowerCase())||"cloudbase",providers:[(null===(o=e.loginType)||void 0===o?void 0:o.toLowerCase())||"cloudbase"]},user_metadata:{name:null==e?void 0:e.name,picture:null==e?void 0:e.picture,username:null==e?void 0:e.username,gender:null==e?void 0:e.gender,locale:null==e?void 0:e.locale,uid:e.uid,nickName:e.nickName||(null==e?void 0:e.name),avatarUrl:e.avatarUrl||e.picture,location:e.location,hasPassword:e.hasPassword},identities:(null===(i=null==e?void 0:e.providers)||void 0===i?void 0:i.map((function(t){return{id:t.id||"",identity_id:t.id||"",user_id:u,identity_data:{provider_id:t.id,provider_user_id:t.provider_user_id,name:t.name},provider:t.id||"cloudbase",created_at:e.created_at,updated_at:e.updated_at,last_sign_in_at:e.last_sign_in_at}})))||[],created_at:e.created_at,updated_at:e.updated_at,is_anonymous:"anonymous"===e.name}},t.prototype.validateParams=function(e,t){for(var r=0,n=Object.entries(t);r<n.length;r++){var o=n[r],i=o[0],s=o[1];if(s.required&&(void 0===(null==e?void 0:e[i])||null===(null==e?void 0:e[i])||""===(null==e?void 0:e[i])))throw new ce({message:s.message})}},t.prototype.validateAtLeastOne=function(e,t,r){if(!t.some((function(t){return t.some((function(t){return void 0!==(null==e?void 0:e[t])&&null!==(null==e?void 0:e[t])&&""!==(null==e?void 0:e[t])}))})))throw new ce({message:r})},t.prototype.init=function(){var e;return Ke(this,void 0,void 0,(function(){return Je(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.oauthInstance.oauth2client.localCredentials.getCredentials()];case 1:return t.sent()&&(null===(e=this.config.eventBus)||void 0===e||e.fire(d.AUTH_STATE_CHANGED,{event:f.INITIAL_SESSION})),[3,3];case 2:return t.sent(),[3,3];case 3:return[2,{error:null}]}}))}))},Ge([(0,Te.catchErrorsDecorator)({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[Object]),ze("design:returntype",Promise)],t.prototype,"bindPhoneNumber",null),Ge([(0,Te.catchErrorsDecorator)({title:"解除三方绑定失败",messages:["请确认以下各项:"," 1 - 调用 auth().unbindProvider() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[Object]),ze("design:returntype",Promise)],t.prototype,"unbindProvider",null),Ge([(0,Te.catchErrorsDecorator)({title:"绑定邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[Object]),ze("design:returntype",void 0)],t.prototype,"bindEmail",null),Ge([(0,Te.catchErrorsDecorator)({title:"验证码验证失败",messages:["请确认以下各项:"," 1 - 调用 auth().verify() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[Object]),ze("design:returntype",Promise)],t.prototype,"verify",null),Ge([(0,Te.catchErrorsDecorator)({title:"获取验证码失败",messages:["请确认以下各项:"," 1 - 调用 auth().getVerification() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[Object,Object]),ze("design:returntype",Promise)],t.prototype,"getVerification",null),Ge([(0,Te.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrentUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[Object]),ze("design:returntype",Promise)],t.prototype,"getCurrentUser",null),Ge([(0,Te.catchErrorsDecorator)({title:"小程序匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymouslyInWx() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[Object]),ze("design:returntype",Promise)],t.prototype,"signInAnonymouslyInWx",null),Ge([(0,Te.catchErrorsDecorator)({title:"小程序绑定OpenID失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序openId静默登录"," 2 - 调用 auth().bindOpenId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[]),ze("design:returntype",Promise)],t.prototype,"bindOpenId",null),Ge([(0,Te.catchErrorsDecorator)({title:"小程序unionId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序unionId静默登录"," 2 - 调用 auth().signInWithUnionId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[]),ze("design:returntype",Promise)],t.prototype,"signInWithUnionId",null),Ge([(0,Te.catchErrorsDecorator)({title:"短信验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序短信验证码登陆"," 2 - 调用 auth().signInWithSms() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[Object]),ze("design:returntype",Promise)],t.prototype,"signInWithSms",null),Ge([(0,Te.catchErrorsDecorator)({title:"邮箱验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了邮箱登陆"," 2 - 调用 auth().signInWithEmail() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[Object]),ze("design:returntype",Promise)],t.prototype,"signInWithEmail",null),Ge([(0,Te.catchErrorsDecorator)({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[String]),ze("design:returntype",Promise)],t.prototype,"isUsernameRegistered",null),Ge([(0,Te.catchErrorsDecorator)({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[]),ze("design:returntype",Promise)],t.prototype,"getLoginState",null),Ge([(0,Te.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[]),ze("design:returntype",Promise)],t.prototype,"getUserInfo",null),Ge([(0,Te.catchErrorsDecorator)({title:"获取微搭插件用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getWedaUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[]),ze("design:returntype",Promise)],t.prototype,"getWedaUserInfo",null),Ge([(0,Te.catchErrorsDecorator)({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindWithProvider() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[Object]),ze("design:returntype",Promise)],t.prototype,"bindWithProvider",null),Ge([(0,Te.catchErrorsDecorator)({title:"获取身份源类型",messages:["请确认以下各项:"," 1 - 调用 auth().getProviderSubType() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Oe.COMMUNITY_SITE_URL)]}),ze("design:type",Function),ze("design:paramtypes",[]),ze("design:returntype",Promise)],t.prototype,"getProviderSubType",null),t}(Ve);function tt(e,t){var r,n,o,i,s=this,a=e.region,c=void 0===a?"ap-shanghai":a,l=e.i18n,p=e.accessKey,v=e.useWxCloud,y=(null==t?void 0:t.platform)||Pe.useDefaultAdapter.bind(t)(),m=y.runtime,g=y.adapter,b=t||{},w=b.env,_=b.clientId,S=b.debug,E=b.cache,I=b.app,O=(t||{}).apiOrigin;O||(O="https://".concat(w,".").concat(c,".tcb-api.tencentcloudapi.com"));var T={env:w,clientId:_,i18n:l,accessKey:p,useWxCloud:v,eventBus:new W.CloudbaseEventEmitter},A=new Se(De($e($e({},T),{apiOrigin:O,apiPath:(null==e?void 0:e.apiPath)||u,storage:null==e?void 0:e.storage,baseRequest:null==e?void 0:e.baseRequest,request:null==e?void 0:e.request,anonymousSignInFunc:null==e?void 0:e.anonymousSignInFunc,captchaOptions:null==e?void 0:e.captchaOptions,wxCloud:null==e?void 0:e.wxCloud,adapter:g,onCredentialsError:Qe(T.eventBus),headers:$e({"X-SDK-Version":"@cloudbase/js-sdk/".concat(e.sdkVersion)},e.headers||{}),detectSessionInUrl:e.detectSessionInUrl,debug:S,auth:null===(n=null===(r=t.app)||void 0===r?void 0:r.config)||void 0===n?void 0:n.auth}))),R=new et($e($e({},T),{region:c,persistence:e.persistence,debug:S,cache:E||new Ae.CloudbaseCache({persistence:e.persistence,keys:{userInfoKey:"user_info_".concat(w)},platformInfo:y}),runtime:m||"web",_fromApp:I,oauthInstance:A,auth:null===(i=null===(o=t.app)||void 0===o?void 0:o.config)||void 0===i?void 0:i.auth}));return A.initializeSession((function(e,t){return Ke(s,void 0,void 0,(function(){return Je(this,(function(r){return e?(e.type===h.SIGN_IN?t?T.eventBus.fire(d.AUTH_STATE_CHANGED,{event:f.SIGNED_IN,info:$e($e({},e),{error:t})}):e.user&&R.createLoginState({},{userInfo:e.user}):e.type===h.BIND_IDENTITY&&T.eventBus.fire(d.AUTH_STATE_CHANGED,{event:f.BIND_IDENTITY,info:$e($e({},e),{error:t})}),[2]):[2]}))}))})),{authInstance:R,oauthInstance:A}}var rt="auth";function nt(e,t){for(var r=[],n=0;n<=e.length;n++)r[n]=[n];for(var o=0;o<=t.length;o++)r[0][o]=o;for(n=1;n<=e.length;n++)for(o=1;o<=t.length;o++){var i=e[n-1].toLowerCase()===t[o-1].toLowerCase()?0:1;r[n][o]=Math.min(r[n-1][o]+1,r[n][o-1]+1,r[n-1][o-1]+i)}return r[e.length][t.length]}var ot={name:"auth",namespace:rt,entity:function(e){var t=function(e){var t;if(this.authInstance&&!e)return this.authInstance;e=e||{region:"",persistence:"local",apiPath:u};var r=this.platform.adapter,n=e.persistence||r.primaryStorage;n&&n!==this.config.persistence&&this.updateConfig({persistence:n});var o=tt($e($e({wxCloud:this.config.wxCloud,storage:this.config.storage},e),{persistence:this.config.persistence,i18n:this.config.i18n,accessKey:this.config.accessKey,useWxCloud:this.config.useWxCloud,sdkVersion:this.version,detectSessionInUrl:null===(t=this.config.auth)||void 0===t?void 0:t.detectSessionInUrl}),{env:this.config.env,clientId:this.config.clientId,apiOrigin:this.request.getBaseEndPoint(this.config.endPointMode||"CLOUD_API"),platform:this.platform,cache:this.cache,app:this,debug:this.config.debug}),i=o.authInstance,s=o.oauthInstance;return this.oauthInstance=s,this.authInstance=i,this.authInstance},r=t.call(this,e);Object.assign(t,r),Object.setPrototypeOf(t,Object.getPrototypeOf(r));var n="undefined"!=typeof Proxy?new Proxy(t,{get:function(e,t,r){var n=Reflect.get(e,t,r);if(void 0!==n||"string"!=typeof t)return n;var o=function(e,t){for(var r=null,n=1/0,o=0,i=t;o<i.length;o++){var s=i[o];if(!s.startsWith("_")&&"constructor"!==s){var a=nt(e,s);a<n&&(n=a,r=s)}}return r}(t,Object.getOwnPropertyNames(Object.getPrototypeOf(e)).concat(Object.keys(e)).filter((function(t){return"function"==typeof e[t]})));return o&&console.warn("[CloudBase Auth] auth.".concat(t," is not a function. Did you mean: auth.").concat(o,"() ?")),n}}):t;return this[rt]=n,n}};try{cloudbase.registerComponent(ot)}catch(e){}function it(e){try{e.registerComponent(ot)}catch(e){console.warn(e)}}},5348:function(e,t,r){"use strict";r.r(t),r.d(t,{registerDatabase:function(){return Yr}});var n,o,i={};r.r(i),r.d(i,{LineString:function(){return H},MultiLineString:function(){return J},MultiPoint:function(){return z},MultiPolygon:function(){return Q},Point:function(){return oe},Polygon:function(){return G}}),function(e){e.DocIDError="文档ID不合法",e.CollNameError="集合名称不合法",e.OpStrError="操作符不合法",e.DirectionError="排序字符不合法",e.IntergerError="must be integer",e.QueryParamTypeError="查询参数必须为对象",e.QueryParamValueError="查询参数对象值不能均为undefined"}(o||(o={}));var s,a,u="Object",c="GeoPoint",l="GeoLineString",f="GeoPolygon",d="GeoMultiPoint",h="GeoMultiLineString",p="GeoMultiPolygon",v="Date",y="ServerDate",m=["desc","asc"],g=["<","<=","==",">=",">"];!function(e){e.lt="<",e.gt=">",e.lte="<=",e.gte=">=",e.eq="=="}(s||(s={})),(n={})[s.eq]="$eq",n[s.lt]="$lt",n[s.lte]="$lte",n[s.gt]="$gt",n[s.gte]="$gte",function(e){e.WHERE="WHERE",e.DOC="DOC"}(a||(a={}));var b,w=(b=function(e,t){return b=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},b(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}b(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),_=[],S={},E=function(e){function t(t,r){if(r!==S)throw new TypeError("InternalSymbol cannot be constructed with new operator");return e.call(this,t)||this}return w(t,e),t.for=function(e){for(var r=0,n=_.length;r<n;r++)if(_[r].target===e)return _[r].instance;var o=new t(e,S);return _.push({target:e,instance:o}),o},t}((function(e){Object.defineProperties(this,{target:{enumerable:!1,writable:!1,configurable:!1,value:e}})})),I=E,O=I.for("UNSET_FIELD_NAME"),T=I.for("UPDATE_COMMAND"),A=I.for("QUERY_COMMAND"),R=I.for("LOGIC_COMMAND"),P=I.for("GEO_POINT"),C=I.for("SYMBOL_GEO_LINE_STRING"),N=I.for("SYMBOL_GEO_POLYGON"),x=I.for("SYMBOL_GEO_MULTI_POINT"),L=I.for("SYMBOL_GEO_MULTI_LINE_STRING"),U=I.for("SYMBOL_GEO_MULTI_POLYGON"),k=I.for("SERVER_DATE"),D=I.for("REGEXP"),j=function(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()},q=function(e){return"object"===j(e)},M=function(e){return"number"===j(e)},B=function(e){return Array.isArray(e)},W=function(e){return"date"===j(e)},F=function(e){return"regexp"===j(e)},V=function(e){return e&&e._internalType instanceof E},H=function(){function e(e){if(!B(e))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof e));if(e.length<2)throw new Error('"points" must contain 2 points at least');e.forEach((function(e){if(!(e instanceof oe))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof e,"[]"))})),this.points=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"LineString",coordinates:this.points.map((function(e){return e.toJSON().coordinates}))},t},e.prototype.toJSON=function(){return{type:"LineString",coordinates:this.points.map((function(e){return e.toJSON().coordinates}))}},e.validate=function(e){var t,r;if("LineString"!==e.type||!B(e.coordinates))return!1;try{for(var n=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(e.coordinates),o=n.next();!o.done;o=n.next()){var i=o.value;if(!M(i[0])||!M(i[1]))return!1}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}return!0},e.isClosed=function(e){var t=e.points[0],r=e.points[e.points.length-1];if(t.latitude===r.latitude&&t.longitude===r.longitude)return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return C},enumerable:!1,configurable:!0}),e}(),$=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},G=function(){function e(e){if(!B(e))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof e));if(0===e.length)throw new Error("Polygon must contain 1 linestring at least");e.forEach((function(e){if(!(e instanceof H))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof e,"[]"));if(!H.isClosed(e))throw new Error("LineString ".concat(e.points.map((function(e){return e.toReadableString()}))," is not a closed cycle"))})),this.lines=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"Polygon",coordinates:this.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))},t},e.prototype.toJSON=function(){return{type:"Polygon",coordinates:this.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))}},e.validate=function(e){var t,r,n,o;if("Polygon"!==e.type||!B(e.coordinates))return!1;try{for(var i=$(e.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,$(a)),c=u.next();!c.done;c=u.next()){var l=c.value;if(!M(l[0])||!M(l[1]))return!1}}catch(e){n={error:e}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}finally{if(n)throw n.error}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}return!0},e.isCloseLineString=function(e){var t=e[0],r=e[e.length-1];return t[0]===r[0]&&t[1]===r[1]},Object.defineProperty(e.prototype,"_internalType",{get:function(){return U},enumerable:!1,configurable:!0}),e}(),z=function(){function e(e){if(!B(e))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof e));if(0===e.length)throw new Error('"points" must contain 1 point at least');e.forEach((function(e){if(!(e instanceof oe))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof e,"[]"))})),this.points=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"MultiPoint",coordinates:this.points.map((function(e){return e.toJSON().coordinates}))},t},e.prototype.toJSON=function(){return{type:"MultiPoint",coordinates:this.points.map((function(e){return e.toJSON().coordinates}))}},e.validate=function(e){var t,r;if("MultiPoint"!==e.type||!B(e.coordinates))return!1;try{for(var n=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(e.coordinates),o=n.next();!o.done;o=n.next()){var i=o.value;if(!M(i[0])||!M(i[1]))return!1}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return x},enumerable:!1,configurable:!0}),e}(),K=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},J=function(){function e(e){if(!B(e))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof e));if(0===e.length)throw new Error("Polygon must contain 1 linestring at least");e.forEach((function(e){if(!(e instanceof H))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof e,"[]"))})),this.lines=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"MultiLineString",coordinates:this.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))},t},e.prototype.toJSON=function(){return{type:"MultiLineString",coordinates:this.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))}},e.validate=function(e){var t,r,n,o;if("MultiLineString"!==e.type||!B(e.coordinates))return!1;try{for(var i=K(e.coordinates),s=i.next();!s.done;s=i.next()){var a=s.value;try{for(var u=(n=void 0,K(a)),c=u.next();!c.done;c=u.next()){var l=c.value;if(!M(l[0])||!M(l[1]))return!1}}catch(e){n={error:e}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}finally{if(n)throw n.error}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return L},enumerable:!1,configurable:!0}),e}(),Y=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Q=function(){function e(e){var t,r;if(!B(e))throw new TypeError('"polygons" must be of type Polygon[]. Received type '.concat(typeof e));if(0===e.length)throw new Error("MultiPolygon must contain 1 polygon at least");try{for(var n=Y(e),o=n.next();!o.done;o=n.next()){var i=o.value;if(!(i instanceof G))throw new TypeError('"polygon" must be of type Polygon[]. Received type '.concat(typeof i,"[]"))}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}this.polygons=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"MultiPolygon",coordinates:this.polygons.map((function(e){return e.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))}))},t},e.prototype.toJSON=function(){return{type:"MultiPolygon",coordinates:this.polygons.map((function(e){return e.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))}))}},e.validate=function(e){var t,r,n,o,i,s;if("MultiPolygon"!==e.type||!B(e.coordinates))return!1;try{for(var a=Y(e.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 d=f.value;try{for(var h=(i=void 0,Y(d)),p=h.next();!p.done;p=h.next()){var v=p.value;if(!M(v[0])||!M(v[1]))return!1}}catch(e){i={error:e}}finally{try{p&&!p.done&&(s=h.return)&&s.call(h)}finally{if(i)throw i.error}}}}catch(e){n={error:e}}finally{try{f&&!f.done&&(o=l.return)&&o.call(l)}finally{if(n)throw n.error}}}}catch(e){t={error:e}}finally{try{u&&!u.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return N},enumerable:!1,configurable:!0}),e}(),Z=function(){function e(e){var t=(void 0===e?{}:e).offset,r=void 0===t?0:t;this.offset=r}return Object.defineProperty(e.prototype,"_internalType",{get:function(){return k},enumerable:!1,configurable:!0}),e.prototype.parse=function(){return{$date:{offset:this.offset}}},e}();function X(e){return new Z(e)}var ee,te=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s},re=function(){function e(){}return e.formatResDocumentData=function(t){return t.map((function(t){return e.formatField(t)}))},e.formatField=function(t){var r=Object.keys(t),n={};return Array.isArray(t)&&(n=[]),r.forEach((function(r){var o,i=t[r];switch(e.whichType(i)){case c:o=new oe(i.coordinates[0],i.coordinates[1]);break;case l:o=new H(i.coordinates.map((function(e){return new oe(e[0],e[1])})));break;case f:o=new G(i.coordinates.map((function(e){return new H(e.map((function(e){var t=te(e,2),r=t[0],n=t[1];return new oe(r,n)})))})));break;case d:o=new z(i.coordinates.map((function(e){return new oe(e[0],e[1])})));break;case h:o=new J(i.coordinates.map((function(e){return new H(e.map((function(e){var t=te(e,2),r=t[0],n=t[1];return new oe(r,n)})))})));break;case p:o=new Q(i.coordinates.map((function(e){return new G(e.map((function(e){return new H(e.map((function(e){var t=te(e,2),r=t[0],n=t[1];return new oe(r,n)})))})))})));break;case v:o=new Date(1e3*i.$timestamp);break;case u:case"Array":o=e.formatField(i);break;case y:o=new Date(i.$date);break;default:o=i}Array.isArray(n)?n.push(o):n[r]=o})),n},e.whichType=function(e){var t=Object.prototype.toString.call(e).slice(8,-1);if(t===v)return"BsonDate";if(t===u){if(e instanceof oe)return c;if(e instanceof Date)return v;if(e instanceof Z)return y;e.$timestamp?t=v:e.$date?t=y:oe.validate(e)?t=c:H.validate(e)?t=l:G.validate(e)?t=f:z.validate(e)?t=d:J.validate(e)?t=h:Q.validate(e)&&(t=p)}return t},e.generateDocId=function(){for(var e="",t=0;t<24;t++)e+="ABCDEFabcdef0123456789".charAt(Math.floor(22*Math.random()));return e},e}(),ne=function(){function e(){}return e.isGeopoint=function(e,t){if("Number"!==re.whichType(t))throw new Error("Geo Point must be number type");var r=Math.abs(t);if("latitude"===e&&r>90)throw new Error("latitude should be a number ranges from -90 to 90");if("longitude"===e&&r>180)throw new Error("longitude should be a number ranges from -180 to 180");return!0},e.isInteger=function(e,t){if(!Number.isInteger(t))throw new Error(e+o.IntergerError);return!0},e.isFieldOrder=function(e){if(-1===m.indexOf(e))throw new Error(o.DirectionError);return!0},e.isFieldPath=function(e){if(!/^[a-zA-Z0-9-_\.]/.test(e))throw new Error;return!0},e.isOperator=function(e){if(-1===g.indexOf(e))throw new Error(o.OpStrError);return!0},e.isCollName=function(e){if(!/^[a-zA-Z0-9]([a-zA-Z0-9-_]){1,32}$/.test(e))throw new Error(o.CollNameError);return!0},e.isDocID=function(e){if(!/^([a-fA-F0-9]){24}$/.test(e))throw new Error(o.DocIDError);return!0},e}(),oe=function(){function e(e,t){ne.isGeopoint("longitude",e),ne.isGeopoint("latitude",t),this.longitude=e,this.latitude=t}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"Point",coordinates:[this.longitude,this.latitude]},t},e.prototype.toJSON=function(){return{type:"Point",coordinates:[this.longitude,this.latitude]}},e.prototype.toReadableString=function(){return"[".concat(this.longitude,",").concat(this.latitude,"]")},e.validate=function(e){return"Point"===e.type&&B(e.coordinates)&&ne.isGeopoint("longitude",e.coordinates[0])&&ne.isGeopoint("latitude",e.coordinates[1])},Object.defineProperty(e.prototype,"_internalType",{get:function(){return P},enumerable:!1,configurable:!0}),e}(),ie=function(){var e=function(){};if(!Promise){e.promise={};var t=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}var r=new Promise((function(t,r){e=function(e,n){return e?r(e):t(n)}}));return e.promise=r,e};!function(e){e.SET="set",e.REMOVE="remove",e.INC="inc",e.MUL="mul",e.PUSH="push",e.PULL="pull",e.PULL_ALL="pullAll",e.POP="pop",e.SHIFT="shift",e.UNSHIFT="unshift",e.ADD_TO_SET="addToSet",e.BIT="bit",e.RENAME="rename",e.MAX="max",e.MIN="min"}(ee||(ee={}));var se,ae=function(){function e(e,t,r){this._internalType=T,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=e,this.operands=t,this.fieldName=r||O}return e.prototype._setFieldName=function(t){return new e(this.operator,this.operands,t)},e}();function ue(e){return e&&e instanceof ae&&e._internalType===T}!function(e){e.AND="and",e.OR="or",e.NOT="not",e.NOR="nor"}(se||(se={}));var ce=function(){function e(e,t,r){if(this._internalType=R,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=e,this.operands=t,this.fieldName=r||O,this.fieldName!==O)if(Array.isArray(t)){t=t.slice(),this.operands=t;for(var n=0,o=t.length;n<o;n++)(le(i=t[n])||pe(i))&&(t[n]=i._setFieldName(this.fieldName))}else{var i;(le(i=t)||pe(i))&&(t=i._setFieldName(this.fieldName))}}return e.prototype._setFieldName=function(t){var r=this.operands.map((function(r){return r instanceof e?r._setFieldName(t):r}));return new e(this.operator,r,t)},e.prototype.and=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return n.unshift(this),new e(se.AND,n,this.fieldName)},e.prototype.or=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return n.unshift(this),new e(se.OR,n,this.fieldName)},e}();function le(e){return e&&e instanceof ce&&e._internalType===R}var fe,de=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};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)}}();!function(e){e.EQ="eq",e.NEQ="neq",e.GT="gt",e.GTE="gte",e.LT="lt",e.LTE="lte",e.IN="in",e.NIN="nin",e.ALL="all",e.ELEM_MATCH="elemMatch",e.EXISTS="exists",e.SIZE="size",e.MOD="mod",e.GEO_NEAR="geoNear",e.GEO_WITHIN="geoWithin",e.GEO_INTERSECTS="geoIntersects"}(fe||(fe={}));var he=function(e){function t(t,r,n){var o=e.call(this,t,r,n)||this;return o.operator=t,o._internalType=A,o}return de(t,e),t.prototype.toJSON=function(){var e,t;switch(this.operator){case fe.IN:case fe.NIN:return(e={})["$"+this.operator]=this.operands,e;default:return(t={})["$"+this.operator]=this.operands[0],t}},t.prototype._setFieldName=function(e){return new t(this.operator,this.operands,e)},t.prototype.eq=function(e){var r=new t(fe.EQ,[e],this.fieldName);return this.and(r)},t.prototype.neq=function(e){var r=new t(fe.NEQ,[e],this.fieldName);return this.and(r)},t.prototype.gt=function(e){var r=new t(fe.GT,[e],this.fieldName);return this.and(r)},t.prototype.gte=function(e){var r=new t(fe.GTE,[e],this.fieldName);return this.and(r)},t.prototype.lt=function(e){var r=new t(fe.LT,[e],this.fieldName);return this.and(r)},t.prototype.lte=function(e){var r=new t(fe.LTE,[e],this.fieldName);return this.and(r)},t.prototype.in=function(e){var r=new t(fe.IN,e,this.fieldName);return this.and(r)},t.prototype.nin=function(e){var r=new t(fe.NIN,e,this.fieldName);return this.and(r)},t.prototype.geoNear=function(e){if(!(e.geometry instanceof oe))throw new TypeError('"geometry" must be of type Point. Received type '.concat(typeof e.geometry));if(void 0!==e.maxDistance&&!M(e.maxDistance))throw new TypeError('"maxDistance" must be of type Number. Received type '.concat(typeof e.maxDistance));if(void 0!==e.minDistance&&!M(e.minDistance))throw new TypeError('"minDistance" must be of type Number. Received type '.concat(typeof e.minDistance));var r=new t(fe.GEO_NEAR,[e],this.fieldName);return this.and(r)},t.prototype.geoWithin=function(e){if(!(e.geometry instanceof Q||e.geometry instanceof G))throw new TypeError('"geometry" must be of type Polygon or MultiPolygon. Received type '.concat(typeof e.geometry));var r=new t(fe.GEO_WITHIN,[e],this.fieldName);return this.and(r)},t.prototype.geoIntersects=function(e){if(!(e.geometry instanceof oe||e.geometry instanceof H||e.geometry instanceof G||e.geometry instanceof z||e.geometry instanceof J||e.geometry instanceof Q))throw new TypeError('"geometry" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type '.concat(typeof e.geometry));var r=new t(fe.GEO_INTERSECTS,[e],this.fieldName);return this.and(r)},t}(ce);function pe(e){return e&&e instanceof he&&e._internalType===A}function ve(e){return pe(e)}var ye={};for(var me in fe)ye[me]="$"+me;for(var me in se)ye[me]="$"+me;for(var me in ee)ye[me]="$"+me;function ge(e){return ye[e]||"$"+e}ye[fe.NEQ]="$ne",ye[ee.REMOVE]="$unset",ye[ee.SHIFT]="$pop",ye[ee.UNSHIFT]="$push";var be=function(){return be=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},be.apply(this,arguments)},we=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s},_e=function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};function Se(e){return Ee(e,[e])}function Ee(e,t){if(!V(e)){if(W(e))return{$date:+e};if(F(e))return{$regex:e.source,$options:e.flags};if(B(e))return e.map((function(e){if(t.indexOf(e)>-1)throw new Error("Cannot convert circular structure to JSON");return Ee(e,_e(_e([],we(t),!1),[e],!1))}));if(q(e)){var r=be({},e);for(var n in r){if(t.indexOf(r[n])>-1)throw new Error("Cannot convert circular structure to JSON");r[n]=Ee(r[n],_e(_e([],we(t),!1),[r[n]],!1))}return r}return e}switch(e._internalType){case P:return e.toJSON();case k:case D:return e.parse();default:return e.toJSON?e.toJSON():e}}var Ie=function(){return Ie=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Ie.apply(this,arguments)},Oe=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s},Te=function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};function Ae(e,t,r,n){var o=Ie({},e);for(var i in e)if(!/^\$/.test(i)){var s=e[i];if(s&&q(s)&&!t(s)){if(n.indexOf(s)>-1)throw new Error("Cannot convert circular structure to JSON");var a=Ae(s,t,Te(Te([],Oe(r),!1),[i],!1),Te(Te([],Oe(n),!1),[s],!1));o[i]=a;var u=!1;for(var c in a)/^\$/.test(c)?u=!0:(o["".concat(i,".").concat(c)]=a[c],delete o[i][c]);u||delete o[i]}}return o}function Re(e){return Ae(e,Ce,[],[e])}function Pe(e,t,r){for(var n in t[r]||delete e[r],t)e[n]?B(e[n])?e[n].push(t[n]):q(e[n])?q(t[n])?Object.assign(e[n],t[n]):(console.warn("unmergable condition, query is object but condition is ".concat(j(t),", can only overwrite"),t,r),e[n]=t[n]):(console.warn("to-merge query is of type ".concat(j(e),", can only overwrite"),e,t,r),e[n]=t[n]):e[n]=t[n]}function Ce(e){return V(e)||W(e)||F(e)}function Ne(e){return Se(e)}var xe=function(){function e(){}return e.encode=function(t){return(new e).encodeUpdate(t)},e.prototype.encodeUpdate=function(e){return ue(e)?this.encodeUpdateCommand(e):"object"===j(e)?this.encodeUpdateObject(e):e},e.prototype.encodeUpdateCommand=function(e){if(e.fieldName===O)throw new Error("Cannot encode a comparison command with unset field name");switch(e.operator){case ee.PUSH:case ee.PULL:case ee.PULL_ALL:case ee.POP:case ee.SHIFT:case ee.UNSHIFT:case ee.ADD_TO_SET:return this.encodeArrayUpdateCommand(e);default:return this.encodeFieldUpdateCommand(e)}},e.prototype.encodeFieldUpdateCommand=function(e){var t,r,n,o,i=ge(e.operator);return e.operator===ee.REMOVE?((t={})[i]=((r={})[e.fieldName]="",r),t):((n={})[i]=((o={})[e.fieldName]=e.operands[0],o),n)},e.prototype.encodeArrayUpdateCommand=function(e){var t,r,n,o,i,s,a,u,c,l,f=ge(e.operator);switch(e.operator){case ee.PUSH:var d=void 0;return d=B(e.operands)?{$each:e.operands.map(Ne)}:e.operands,(t={})[f]=((r={})[e.fieldName]=d,r),t;case ee.UNSHIFT:return d={$each:e.operands.map(Ne),$position:0},(n={})[f]=((o={})[e.fieldName]=d,o),n;case ee.POP:return(i={})[f]=((s={})[e.fieldName]=1,s),i;case ee.SHIFT:return(a={})[f]=((u={})[e.fieldName]=-1,u),a;default:return(c={})[f]=((l={})[e.fieldName]=Ne(e.operands),l),c}},e.prototype.encodeUpdateObject=function(e){var t=Re(e);for(var r in t)if(!/^\$/.test(r)){var n=t[r];if(ue(n))t[r]=n._setFieldName(r),Pe(t,this.encodeUpdateCommand(t[r]),r);else{t[r]=n=Ne(n);var o=new ae(ee.SET,[n],r);Pe(t,this.encodeUpdateCommand(o),r)}}return t},e}(),Le={};function Ue(e){if(!Vr.wsClientClass)throw new Error("to use realtime you must import realtime module first");var t=e.config.env;return Le[t]||(Le[t]=new Vr.wsClientClass({context:{appConfig:{docSizeLimit:1e3,realtimePingInterval:1e4,realtimePongWaitTimeout:5e3,request:Vr.createRequest(e.config)}}})),Le[t]}var ke=function(){return ke=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},ke.apply(this,arguments)},De=function(){function e(e,t,r,n){void 0===n&&(n={});var o=this;this.watch=function(e){return Ue(o._db).watch(ke(ke({},e),{envId:o._db.config.env,collectionName:o._coll,query:JSON.stringify({_id:o.id})}))},this._db=e,this._coll=t,this.id=r,this.request=Vr.createRequest(this._db.config),this.projection=n}return e.prototype.create=function(e,t){t=t||ie();var r={collectionName:this._coll,data:Se(e)};return this.id&&(r._id=this.id),this.request.send("database.addDocument",r).then((function(e){e.code?t(0,e):t(0,{id:e.data._id,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},e.prototype.set=function(e,t){if(t=t||ie(),!this.id)return Promise.resolve({code:"INVALID_PARAM",message:"docId不能为空"});if(!e||"object"!=typeof e)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(e.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var r=!1,n=function(e){if("object"==typeof e)for(var t in e)e[t]instanceof ae?r=!0:"object"==typeof e[t]&&n(e[t])};if(n(e),r)return Promise.resolve({code:"DATABASE_REQUEST_FAILED",message:"update operator complicit"});var o={collectionName:this._coll,queryType:a.DOC,data:Se(e),multi:!1,merge:!1,upsert:!0};return this.id&&(o.query={_id:this.id}),this.request.send("database.updateDocument",o).then((function(e){e.code?t(0,e):t(0,{updated:e.data.updated,upsertedId:e.data.upserted_id,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},e.prototype.update=function(e,t){if(t=t||ie(),!e||"object"!=typeof e)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(e.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var r={_id:this.id},n={collectionName:this._coll,data:xe.encode(e),query:r,queryType:a.DOC,multi:!1,merge:!0,upsert:!1};return this.request.send("database.updateDocument",n).then((function(e){e.code?t(0,e):t(0,{updated:e.data.updated,upsertedId:e.data.upserted_id,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},e.prototype.remove=function(e){e=e||ie();var t={_id:this.id},r={collectionName:this._coll,query:t,queryType:a.DOC,multi:!1};return this.request.send("database.deleteDocument",r).then((function(t){t.code?e(0,t):e(0,{deleted:t.data.deleted,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},e.prototype.get=function(e){e=e||ie();var t={_id:this.id},r={collectionName:this._coll,query:t,queryType:a.DOC,multi:!1,projection:this.projection};return this.request.send("database.queryDocument",r).then((function(t){if(t.code)e(0,t);else{var r=re.formatResDocumentData(t.data.list);e(0,{data:r,requestId:t.requestId})}})).catch((function(t){e(t)})),e.promise},e.prototype.field=function(t){for(var r in t)t[r]?t[r]=1:t[r]=0;return new e(this._db,this._coll,this.id,t)},e}(),je=function(){function e(){}return e.encode=function(e){return(new qe).encodeQuery(e)},e}(),qe=function(){function e(){}return e.prototype.encodeQuery=function(e,t){var r;return Ce(e)?le(e)?this.encodeLogicCommand(e):pe(e)?this.encodeQueryCommand(e):((r={})[t]=this.encodeQueryObject(e),r):q(e)?this.encodeQueryObject(e):e},e.prototype.encodeRegExp=function(e){return{$regex:e.source,$options:e.flags}},e.prototype.encodeLogicCommand=function(e){var t,r,n,o,i,s,a,u=this;switch(e.operator){case se.NOR:case se.AND:case se.OR:var c=ge(e.operator),l=e.operands.map((function(t){return u.encodeQuery(t,e.fieldName)}));return(t={})[c]=l,t;case se.NOT:c=ge(e.operator);var f=e.operands[0];return F(f)?((r={})[e.fieldName]=((n={})[c]=this.encodeRegExp(f),n),r):(l=this.encodeQuery(f)[e.fieldName],(o={})[e.fieldName]=((i={})[c]=l,i),o);default:if(c=ge(e.operator),1===e.operands.length){var d=this.encodeQuery(e.operands[0]);return(s={})[c]=d,s}return l=e.operands.map(this.encodeQuery.bind(this)),(a={})[c]=l,a}},e.prototype.encodeQueryCommand=function(e){return ve(e),this.encodeComparisonCommand(e)},e.prototype.encodeComparisonCommand=function(e){var t,r,n,o,i,s,a,u,c;if(e.fieldName===O)throw new Error("Cannot encode a comparison command with unset field name");var l=ge(e.operator);switch(e.operator){case fe.EQ:case fe.NEQ:case fe.LT:case fe.LTE:case fe.GT:case fe.GTE:case fe.ELEM_MATCH:case fe.EXISTS:case fe.SIZE:case fe.MOD:return(t={})[e.fieldName]=((r={})[l]=Ne(e.operands[0]),r),t;case fe.IN:case fe.NIN:case fe.ALL:return(n={})[e.fieldName]=((o={})[l]=Ne(e.operands),o),n;case fe.GEO_NEAR:var f=e.operands[0];return(i={})[e.fieldName]={$nearSphere:{$geometry:f.geometry.toJSON(),$maxDistance:f.maxDistance,$minDistance:f.minDistance}},i;case fe.GEO_WITHIN:return f=e.operands[0],(s={})[e.fieldName]={$geoWithin:{$geometry:f.geometry.toJSON()}},s;case fe.GEO_INTERSECTS:return f=e.operands[0],(a={})[e.fieldName]={$geoIntersects:{$geometry:f.geometry.toJSON()}},a;default:return(u={})[e.fieldName]=((c={})[l]=Ne(e.operands[0]),c),u}},e.prototype.encodeQueryObject=function(e){var t=Re(e);for(var r in t){var n=t[r];if(le(n)){t[r]=n._setFieldName(r);var o=this.encodeLogicCommand(t[r]);this.mergeConditionAfterEncode(t,o,r)}else ve(n)?(t[r]=n._setFieldName(r),o=this.encodeComparisonCommand(t[r]),this.mergeConditionAfterEncode(t,o,r)):Ce(n)&&(t[r]=Ne(n))}return t},e.prototype.mergeConditionAfterEncode=function(e,t,r){for(var n in t[r]||delete e[r],t)e[n]?B(e[n])?e[n]=e[n].concat(t[n]):q(e[n])?q(t[n])?Object.assign(e,t):(console.warn("unmergable condition, query is object but condition is ".concat(j(t),", can only overwrite"),t,r),e[n]=t[n]):(console.warn("to-merge query is of type ".concat(j(e),", can only overwrite"),e,t,r),e[n]=t[n]):e[n]=t[n]},e}(),Me=function(){return Me=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Me.apply(this,arguments)},Be=function(){function e(e,t,r,n,o){var i=this;this.watch=function(e){return Ue(i._db).watch(Me(Me({},e),{envId:i._db.config.env,collectionName:i._coll,query:JSON.stringify(i._fieldFilters||{}),limit:i._queryOptions.limit,orderBy:i._fieldOrders?i._fieldOrders.reduce((function(e,t){return e[t.field]=t.direction,e}),{}):void 0}))},this._db=e,this._coll=t,this._fieldFilters=r,this._fieldOrders=n||[],this._queryOptions=o||{},this._request=Vr.createRequest(this._db.config)}return e.prototype.get=function(e){e=e||ie();var t=[];this._fieldOrders&&this._fieldOrders.forEach((function(e){t.push(e)}));var r={collectionName:this._coll,queryType:a.WHERE};return this._fieldFilters&&(r.query=this._fieldFilters),t.length>0&&(r.order=t),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(t){if(t.code)e(0,t);else{var r={data:re.formatResDocumentData(t.data.list),requestId:t.requestId};void 0!==t.total&&(r.total=t.total),void 0!==t.limit&&(r.limit=t.limit),void 0!==t.offset&&(r.offset=t.offset),e(0,r)}})).catch((function(t){e(t)})),e.promise},e.prototype.count=function(e){e=e||ie();var t={collectionName:this._coll,queryType:a.WHERE};return this._fieldFilters&&(t.query=this._fieldFilters),this._request.send("database.countDocument",t).then((function(t){t.code?e(0,t):e(0,{requestId:t.requestId,total:t.data.total})})).catch((function(t){e(t)})),e.promise},e.prototype.where=function(t){if("Object"!==Object.prototype.toString.call(t).slice(8,-1))throw Error(o.QueryParamTypeError);var r=Object.keys(t),n=r.some((function(e){return void 0!==t[e]}));if(r.length&&!n)throw Error(o.QueryParamValueError);return new e(this._db,this._coll,je.encode(t),this._fieldOrders,this._queryOptions)},e.prototype.orderBy=function(t,r){ne.isFieldPath(t),ne.isFieldOrder(r);var n={field:t,direction:r},o=this._fieldOrders.concat(n);return new e(this._db,this._coll,this._fieldFilters,o,this._queryOptions)},e.prototype.limit=function(t){ne.isInteger("limit",t);var r=Me({},this._queryOptions);return r.limit=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,r)},e.prototype.skip=function(t){ne.isInteger("offset",t);var r=Me({},this._queryOptions);return r.offset=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,r)},e.prototype.update=function(e,t){if(t=t||ie(),!e||"object"!=typeof e)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(e.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:xe.encode(e)};return this._request.send("database.updateDocument",r).then((function(e){e.code?t(0,e):t(0,{requestId:e.requestId,updated:e.data.updated,upsertId:e.data.upsert_id})})).catch((function(e){t(e)})),t.promise},e.prototype.field=function(t){for(var r in t)t[r]?"object"!=typeof t[r]&&(t[r]=1):t[r]=0;var n=Me({},this._queryOptions);return n.projection=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},e.prototype.remove=function(e){e=e||ie(),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 t={collectionName:this._coll,query:je.encode(this._fieldFilters),queryType:a.WHERE,multi:!0};return this._request.send("database.deleteDocument",t).then((function(t){t.code?e(0,t):e(0,{requestId:t.requestId,deleted:t.data.deleted})})).catch((function(t){e(t)})),e.promise},e}();const We=(()=>{const e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype),Symbol.toStringTag).get;return t=>e.call(t)})();function Fe(e){return"Uint8Array"===We(e)}function Ve(e){return"object"==typeof e&&null!=e&&Symbol.toStringTag in e&&"Map"===e[Symbol.toStringTag]}function He(e,t){return JSON.stringify(e,((e,t)=>"bigint"==typeof t?{$numberLong:`${t}`}:Ve(t)?Object.fromEntries(t):t))}const $e=7,Ge=Symbol.for("@@mdb.bson.version"),ze=2147483647,Ke=-2147483648,Je=Math.pow(2,63)-1,Ye=-Math.pow(2,63),Qe=Math.pow(2,53),Ze=-Math.pow(2,53);Object.freeze({double:1,string:2,object:3,array:4,binData:5,undefined:6,objectId:7,bool:8,date:9,null:10,regex:11,dbPointer:12,javascript:13,symbol:14,javascriptWithScope:15,int:16,timestamp:17,long:18,decimal:19,minKey:-1,maxKey:127});class Xe extends Error{get bsonError(){return!0}get name(){return"BSONError"}constructor(e,t){super(e,t)}static isBSONError(e){return null!=e&&"object"==typeof e&&"bsonError"in e&&!0===e.bsonError&&"name"in e&&"message"in e&&"stack"in e}}class et extends Xe{get name(){return"BSONVersionError"}constructor(){super(`Unsupported BSON version, bson types must be from bson ${$e}.x.x`)}}class tt extends Xe{get name(){return"BSONRuntimeError"}constructor(e){super(e)}}class rt extends Xe{get name(){return"BSONOffsetError"}offset;constructor(e,t,r){super(`${e}. offset: ${t}`,r),this.offset=t}}let nt,ot;function it(e,t,r,n){if(n){nt??=new TextDecoder("utf8",{fatal:!0});try{return nt.decode(e.subarray(t,r))}catch(e){throw new Xe("Invalid UTF-8 string in BSON document",{cause:e})}}return ot??=new TextDecoder("utf8",{fatal:!1}),ot.decode(e.subarray(t,r))}function st(e,t,r){if(0===e.length)return"";const n=r-t;if(0===n)return"";if(n>20)return null;if(1===n&&e[t]<128)return String.fromCharCode(e[t]);if(2===n&&e[t]<128&&e[t+1]<128)return String.fromCharCode(e[t])+String.fromCharCode(e[t+1]);if(3===n&&e[t]<128&&e[t+1]<128&&e[t+2]<128)return String.fromCharCode(e[t])+String.fromCharCode(e[t+1])+String.fromCharCode(e[t+2]);const o=[];for(let n=t;n<r;n++){const t=e[n];if(t>127)return null;o.push(t)}return String.fromCharCode(...o)}function at(e){return lt.fromNumberArray(Array.from({length:e},(()=>Math.floor(256*Math.random()))))}function ut(e){return crypto.getRandomValues(lt.allocate(e))}const ct=(()=>{const{crypto:e}=globalThis;return null!=e&&"function"==typeof e.getRandomValues?ut:at})(),lt={isUint8Array:Fe,toLocalBufferType(e){if(Buffer.isBuffer(e))return e;if(ArrayBuffer.isView(e))return Buffer.from(e.buffer,e.byteOffset,e.byteLength);const t=e?.[Symbol.toStringTag]??Object.prototype.toString.call(e);if("ArrayBuffer"===t||"SharedArrayBuffer"===t||"[object ArrayBuffer]"===t||"[object SharedArrayBuffer]"===t)return Buffer.from(e);throw new Xe("Cannot create Buffer from the passed potentialBuffer.")},allocate(e){return Buffer.alloc(e)},allocateUnsafe(e){return Buffer.allocUnsafe(e)},compare(e,t){return lt.toLocalBufferType(e).compare(t)},concat(e){return Buffer.concat(e)},equals(e,t){return lt.toLocalBufferType(e).equals(t)},fromNumberArray(e){return Buffer.from(e)},fromBase64(e){return Buffer.from(e,"base64")},fromUTF8(e){return Buffer.from(e,"utf8")},toBase64(e){return lt.toLocalBufferType(e).toString("base64")},fromISO88591(e){return Buffer.from(e,"binary")},toISO88591(e){return lt.toLocalBufferType(e).toString("binary")},fromHex(e){return Buffer.from(e,"hex")},toHex(e){return lt.toLocalBufferType(e).toString("hex")},toUTF8(e,t,r,n){const o=r-t<=20?st(e,t,r):null;if(null!=o)return o;const i=lt.toLocalBufferType(e).toString("utf8",t,r);if(n)for(let n=0;n<i.length;n++)if(65533===i.charCodeAt(n)){it(e,t,r,!0);break}return i},utf8ByteLength(e){return Buffer.byteLength(e,"utf8")},encodeUTF8Into(e,t,r){const n=function(e,t,r){if(0===t.length)return 0;if(t.length>25)return null;if(e.length-r<t.length)return null;for(let n=0,o=r;n<t.length;n++,o++){const r=t.charCodeAt(n);if(r>127)return null;e[o]=r}return t.length}(e,t,r);return null!=n?n:lt.toLocalBufferType(e).write(t,r,void 0,"utf8")},randomBytes:ct,swap32(e){return lt.toLocalBufferType(e).swap32()}};function ft(e){if(e<0)throw new RangeError(`The argument 'byteLength' is invalid. Received ${e}`);return pt.fromNumberArray(Array.from({length:e},(()=>Math.floor(256*Math.random()))))}const dt=(()=>{const{crypto:e}=globalThis;if(null!=e&&"function"==typeof e.getRandomValues)return t=>e.getRandomValues(pt.allocate(t));if(function(){const{navigator:e}=globalThis;return"object"==typeof e&&"ReactNative"===e.product}()){const{console:e}=globalThis;e?.warn?.("BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.")}return ft})(),ht=/(\d|[a-f])/i,pt={isUint8Array:Fe,toLocalBufferType(e){const t=e?.[Symbol.toStringTag]??Object.prototype.toString.call(e);if("Uint8Array"===t)return e;if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength));if("ArrayBuffer"===t||"SharedArrayBuffer"===t||"[object ArrayBuffer]"===t||"[object SharedArrayBuffer]"===t)return new Uint8Array(e);throw new Xe("Cannot make a Uint8Array from passed potentialBuffer.")},allocate(e){if("number"!=typeof e)throw new TypeError(`The "size" argument must be of type number. Received ${String(e)}`);return new Uint8Array(e)},allocateUnsafe(e){return pt.allocate(e)},compare(e,t){if(e===t)return 0;const r=Math.min(e.length,t.length);for(let n=0;n<r;n++){if(e[n]<t[n])return-1;if(e[n]>t[n])return 1}return e.length<t.length?-1:e.length>t.length?1:0},concat(e){if(0===e.length)return pt.allocate(0);let t=0;for(const r of e)t+=r.length;const r=pt.allocate(t);let n=0;for(const t of e)r.set(t,n),n+=t.length;return r},equals(e,t){if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0},fromNumberArray(e){return Uint8Array.from(e)},fromBase64(e){return Uint8Array.from(atob(e),(e=>e.charCodeAt(0)))},fromUTF8(e){return(new TextEncoder).encode(e)},toBase64(e){return btoa(pt.toISO88591(e))},fromISO88591(e){return Uint8Array.from(e,(e=>255&e.charCodeAt(0)))},toISO88591(e){return Array.from(Uint16Array.from(e),(e=>String.fromCharCode(e))).join("")},fromHex(e){const t=e.length%2==0?e:e.slice(0,e.length-1),r=[];for(let e=0;e<t.length;e+=2){const n=t[e],o=t[e+1];if(!ht.test(n))break;if(!ht.test(o))break;const i=Number.parseInt(`${n}${o}`,16);r.push(i)}return Uint8Array.from(r)},toHex(e){return Array.from(e,(e=>e.toString(16).padStart(2,"0"))).join("")},toUTF8(e,t,r,n){const o=r-t<=20?st(e,t,r):null;return null!=o?o:it(e,t,r,n)},utf8ByteLength(e){return(new TextEncoder).encode(e).byteLength},encodeUTF8Into(e,t,r){const n=(new TextEncoder).encode(t);return e.set(n,r),n.byteLength},randomBytes:dt,swap32(e){if(e.length%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e.length;t+=4){const r=e[t],n=e[t+1],o=e[t+2],i=e[t+3];e[t]=i,e[t+1]=o,e[t+2]=n,e[t+3]=r}return e}},vt="function"==typeof Buffer&&!0!==Buffer.prototype?._isBuffer?lt:pt,yt=Symbol.for("@@mdb.bson.type");class mt{get[yt](){return this._bsontype}get[Ge](){return $e}[Symbol.for("nodejs.util.inspect.custom")](e,t,r){return this.inspect(e,t,r)}}const gt=new Float64Array(1),bt=new Uint8Array(gt.buffer,0,8);gt[0]=-1;const wt=0===bt[7],_t={isBigEndian:wt,getNonnegativeInt32LE(e,t){if(e[t+3]>127)throw new RangeError(`Size cannot be negative at offset: ${t}`);return e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24},getInt32LE(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24},getUint32LE(e,t){return e[t]+256*e[t+1]+65536*e[t+2]+16777216*e[t+3]},getUint32BE(e,t){return e[t+3]+256*e[t+2]+65536*e[t+1]+16777216*e[t]},getBigInt64LE(e,t){return(BigInt(e[t+4]+256*e[t+5]+65536*e[t+6]+(e[t+7]<<24))<<32n)+BigInt(e[t]+256*e[t+1]+65536*e[t+2]+16777216*e[t+3])},getFloat64LE:wt?(e,t)=>(bt[7]=e[t],bt[6]=e[t+1],bt[5]=e[t+2],bt[4]=e[t+3],bt[3]=e[t+4],bt[2]=e[t+5],bt[1]=e[t+6],bt[0]=e[t+7],gt[0]):(e,t)=>(bt[0]=e[t],bt[1]=e[t+1],bt[2]=e[t+2],bt[3]=e[t+3],bt[4]=e[t+4],bt[5]=e[t+5],bt[6]=e[t+6],bt[7]=e[t+7],gt[0]),setInt32BE(e,t,r){return e[t+3]=r,r>>>=8,e[t+2]=r,r>>>=8,e[t+1]=r,r>>>=8,e[t]=r,4},setInt32LE(e,t,r){return e[t]=r,r>>>=8,e[t+1]=r,r>>>=8,e[t+2]=r,r>>>=8,e[t+3]=r,4},setBigInt64LE(e,t,r){const n=0xffffffffn;let o=Number(r&n);e[t]=o,o>>=8,e[t+1]=o,o>>=8,e[t+2]=o,o>>=8,e[t+3]=o;let i=Number(r>>32n&n);return e[t+4]=i,i>>=8,e[t+5]=i,i>>=8,e[t+6]=i,i>>=8,e[t+7]=i,8},setFloat64LE:wt?(e,t,r)=>(gt[0]=r,e[t]=bt[7],e[t+1]=bt[6],e[t+2]=bt[5],e[t+3]=bt[4],e[t+4]=bt[3],e[t+5]=bt[2],e[t+6]=bt[1],e[t+7]=bt[0],8):(e,t,r)=>(gt[0]=r,e[t]=bt[0],e[t+1]=bt[1],e[t+2]=bt[2],e[t+3]=bt[3],e[t+4]=bt[4],e[t+5]=bt[5],e[t+6]=bt[6],e[t+7]=bt[7],8)};class St extends mt{get _bsontype(){return"Binary"}static BSON_BINARY_SUBTYPE_DEFAULT=0;static BUFFER_SIZE=256;static SUBTYPE_DEFAULT=0;static SUBTYPE_FUNCTION=1;static SUBTYPE_BYTE_ARRAY=2;static SUBTYPE_UUID_OLD=3;static SUBTYPE_UUID=4;static SUBTYPE_MD5=5;static SUBTYPE_ENCRYPTED=6;static SUBTYPE_COLUMN=7;static SUBTYPE_SENSITIVE=8;static SUBTYPE_VECTOR=9;static SUBTYPE_USER_DEFINED=128;static VECTOR_TYPE=Object.freeze({Int8:3,Float32:39,PackedBit:16});buffer;sub_type;position;constructor(e,t){if(super(),null!=e&&"string"==typeof e&&!ArrayBuffer.isView(e)&&("object"!=typeof(r=e)||null==r||!(Symbol.toStringTag in r)||"ArrayBuffer"!==r[Symbol.toStringTag]&&"SharedArrayBuffer"!==r[Symbol.toStringTag])&&!Array.isArray(e))throw new Xe("Binary can only be constructed from Uint8Array or number[]");var r;this.sub_type=t??St.BSON_BINARY_SUBTYPE_DEFAULT,null==e?(this.buffer=vt.allocate(St.BUFFER_SIZE),this.position=0):(this.buffer=Array.isArray(e)?vt.fromNumberArray(e):vt.toLocalBufferType(e),this.position=this.buffer.byteLength)}put(e){if("string"==typeof e&&1!==e.length)throw new Xe("only accepts single character String");if("number"!=typeof e&&1!==e.length)throw new Xe("only accepts single character Uint8Array or Array");let t;if(t="string"==typeof e?e.charCodeAt(0):"number"==typeof e?e:e[0],t<0||t>255)throw new Xe("only accepts number in a valid unsigned byte range 0-255");if(this.buffer.byteLength>this.position)this.buffer[this.position++]=t;else{const e=vt.allocate(St.BUFFER_SIZE+this.buffer.length);e.set(this.buffer,0),this.buffer=e,this.buffer[this.position++]=t}}write(e,t){if(t="number"==typeof t?t:this.position,this.buffer.byteLength<t+e.length){const t=vt.allocate(this.buffer.byteLength+e.length);t.set(this.buffer,0),this.buffer=t}if(ArrayBuffer.isView(e))this.buffer.set(vt.toLocalBufferType(e),t),this.position=t+e.byteLength>this.position?t+e.length:this.position;else if("string"==typeof e)throw new Xe("input cannot be string")}read(e,t){const r=e+(t=t&&t>0?t:this.position);return this.buffer.subarray(e,r>this.position?this.position:r)}value(){return this.buffer.length===this.position?this.buffer:this.buffer.subarray(0,this.position)}length(){return this.position}toJSON(){return vt.toBase64(this.buffer.subarray(0,this.position))}toString(e){return"hex"===e?vt.toHex(this.buffer.subarray(0,this.position)):"base64"===e?vt.toBase64(this.buffer.subarray(0,this.position)):vt.toUTF8(this.buffer,0,this.position,!1)}toExtendedJSON(e){e=e||{},this.sub_type===St.SUBTYPE_VECTOR&&Et(this);const t=vt.toBase64(this.buffer),r=Number(this.sub_type).toString(16);return e.legacy?{$binary:t,$type:1===r.length?"0"+r:r}:{$binary:{base64:t,subType:1===r.length?"0"+r:r}}}toUUID(){if(this.sub_type===St.SUBTYPE_UUID)return new Tt(this.buffer.subarray(0,this.position));throw new Xe(`Binary sub_type "${this.sub_type}" is not supported for converting to UUID. Only "${St.SUBTYPE_UUID}" is currently supported.`)}static createFromHexString(e,t){return new St(vt.fromHex(e),t)}static createFromBase64(e,t){return new St(vt.fromBase64(e),t)}static fromExtendedJSON(e,t){let r,n;if(t=t||{},"$binary"in e?t.legacy&&"string"==typeof e.$binary&&"$type"in e?(n=e.$type?parseInt(e.$type,16):0,r=vt.fromBase64(e.$binary)):"string"!=typeof e.$binary&&(n=e.$binary.subType?parseInt(e.$binary.subType,16):0,r=vt.fromBase64(e.$binary.base64)):"$uuid"in e&&(n=4,r=Tt.bytesFromString(e.$uuid)),!r)throw new Xe(`Unexpected Binary Extended JSON format ${JSON.stringify(e)}`);return 4===n?new Tt(r):new St(r,n)}inspect(e,t,r){return r??=He,`Binary.createFromBase64(${r(vt.toBase64(this.buffer.subarray(0,this.position)),t)}, ${r(this.sub_type,t)})`}toInt8Array(){if(this.sub_type!==St.SUBTYPE_VECTOR)throw new Xe("Binary sub_type is not Vector");if(this.buffer[0]!==St.VECTOR_TYPE.Int8)throw new Xe("Binary datatype field is not Int8");return Et(this),new Int8Array(this.buffer.buffer.slice(this.buffer.byteOffset+2,this.buffer.byteOffset+this.position))}toFloat32Array(){if(this.sub_type!==St.SUBTYPE_VECTOR)throw new Xe("Binary sub_type is not Vector");if(this.buffer[0]!==St.VECTOR_TYPE.Float32)throw new Xe("Binary datatype field is not Float32");Et(this);const e=new Uint8Array(this.buffer.buffer.slice(this.buffer.byteOffset+2,this.buffer.byteOffset+this.position));return _t.isBigEndian&&vt.swap32(e),new Float32Array(e.buffer)}toPackedBits(){if(this.sub_type!==St.SUBTYPE_VECTOR)throw new Xe("Binary sub_type is not Vector");if(this.buffer[0]!==St.VECTOR_TYPE.PackedBit)throw new Xe("Binary datatype field is not packed bit");return Et(this),new Uint8Array(this.buffer.buffer.slice(this.buffer.byteOffset+2,this.buffer.byteOffset+this.position))}toBits(){if(this.sub_type!==St.SUBTYPE_VECTOR)throw new Xe("Binary sub_type is not Vector");if(this.buffer[0]!==St.VECTOR_TYPE.PackedBit)throw new Xe("Binary datatype field is not packed bit");Et(this);const e=8*(this.length()-2)-this.buffer[1],t=new Int8Array(e);for(let e=0;e<t.length;e++){const r=e/8|0,n=this.buffer[r+2]>>7-e%8&1;t[e]=n}return t}static fromInt8Array(e){const t=vt.allocate(e.byteLength+2);t[0]=St.VECTOR_TYPE.Int8,t[1]=0;const r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);t.set(r,2);const n=new this(t,this.SUBTYPE_VECTOR);return Et(n),n}static fromFloat32Array(e){const t=vt.allocate(e.byteLength+2);t[0]=St.VECTOR_TYPE.Float32,t[1]=0;const r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);t.set(r,2),_t.isBigEndian&&vt.swap32(new Uint8Array(t.buffer,2));const n=new this(t,this.SUBTYPE_VECTOR);return Et(n),n}static fromPackedBits(e,t=0){const r=vt.allocate(e.byteLength+2);r[0]=St.VECTOR_TYPE.PackedBit,r[1]=t,r.set(e,2);const n=new this(r,this.SUBTYPE_VECTOR);return Et(n),n}static fromBits(e){const t=e.length+7>>>3,r=new Uint8Array(t+2);r[0]=St.VECTOR_TYPE.PackedBit;const n=e.length%8;r[1]=0===n?0:8-n;for(let t=0;t<e.length;t++){const n=t>>>3,o=e[t];if(0!==o&&1!==o)throw new Xe(`Invalid bit value at ${t}: must be 0 or 1, found ${e[t]}`);if(0===o)continue;const i=7-t%8;r[n+2]|=o<<i}return new this(r,St.SUBTYPE_VECTOR)}}function Et(e){if(e.sub_type!==St.SUBTYPE_VECTOR)return;const t=e.position,r=e.buffer[0],n=e.buffer[1];if((r===St.VECTOR_TYPE.Float32||r===St.VECTOR_TYPE.Int8)&&0!==n)throw new Xe("Invalid Vector: padding must be zero for int8 and float32 vectors");if(r===St.VECTOR_TYPE.Float32&&0!==t&&t-2!=0&&(t-2)%4!=0)throw new Xe("Invalid Vector: Float32 vector must contain a multiple of 4 bytes");if(r===St.VECTOR_TYPE.PackedBit&&0!==n&&2===t)throw new Xe("Invalid Vector: padding must be zero for packed bit vectors that are empty");if(r===St.VECTOR_TYPE.PackedBit&&n>7)throw new Xe(`Invalid Vector: padding must be a value between 0 and 7. found: ${n}`)}const It=/^[0-9A-F]{32}$/i,Ot=/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i;class Tt extends St{constructor(e){let t;if(null==e)t=Tt.generate();else if(e instanceof Tt)t=vt.toLocalBufferType(new Uint8Array(e.buffer));else if(ArrayBuffer.isView(e)&&16===e.byteLength)t=vt.toLocalBufferType(e);else{if("string"!=typeof e)throw new Xe("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).");t=Tt.bytesFromString(e)}super(t,4)}get id(){return this.buffer}set id(e){this.buffer=e}toHexString(e=!0){return e?[vt.toHex(this.buffer.subarray(0,4)),vt.toHex(this.buffer.subarray(4,6)),vt.toHex(this.buffer.subarray(6,8)),vt.toHex(this.buffer.subarray(8,10)),vt.toHex(this.buffer.subarray(10,16))].join("-"):vt.toHex(this.buffer)}toString(e){return"hex"===e?vt.toHex(this.id):"base64"===e?vt.toBase64(this.id):this.toHexString()}toJSON(){return this.toHexString()}equals(e){if(!e)return!1;if(e instanceof Tt)return vt.equals(e.id,this.id);try{return vt.equals(new Tt(e).id,this.id)}catch{return!1}}toBinary(){return new St(this.id,St.SUBTYPE_UUID)}static generate(){const e=vt.randomBytes(16);return e[6]=15&e[6]|64,e[8]=63&e[8]|128,e}static isValid(e){return!!e&&("string"==typeof e?Tt.isValidUUIDString(e):Fe(e)?16===e.byteLength:"Binary"===e._bsontype&&e.sub_type===this.SUBTYPE_UUID&&16===e.buffer.byteLength)}static createFromHexString(e){const t=Tt.bytesFromString(e);return new Tt(t)}static createFromBase64(e){return new Tt(vt.fromBase64(e))}static bytesFromString(e){if(!Tt.isValidUUIDString(e))throw new Xe("UUID string representation must be 32 hex digits or canonical hyphenated representation");return vt.fromHex(e.replace(/-/g,""))}static isValidUUIDString(e){return It.test(e)||Ot.test(e)}inspect(e,t,r){return r??=He,`new UUID(${r(this.toHexString(),t)})`}}class At extends mt{get _bsontype(){return"Code"}code;scope;constructor(e,t){super(),this.code=e.toString(),this.scope=t??null}toJSON(){return null!=this.scope?{code:this.code,scope:this.scope}:{code:this.code}}toExtendedJSON(){return this.scope?{$code:this.code,$scope:this.scope}:{$code:this.code}}static fromExtendedJSON(e){return new At(e.$code,e.$scope)}inspect(e,t,r){r??=He;let n=r(this.code,t);const o=n.includes("\n");return null!=this.scope&&(n+=`,${o?"\n":" "}${r(this.scope,t)}`),`new Code(${o?"\n":""}${n}${o&&null===this.scope?"\n":""})`}}class Rt extends mt{get _bsontype(){return"DBRef"}collection;oid;db;fields;constructor(e,t,r,n){super();const o=e.split(".");2===o.length&&(r=o.shift(),e=o.shift()),this.collection=e,this.oid=t,this.db=r,this.fields=n||{}}get namespace(){return this.collection}set namespace(e){this.collection=e}toJSON(){const e=Object.assign({$ref:this.collection,$id:this.oid},this.fields);return null!=this.db&&(e.$db=this.db),e}toExtendedJSON(e){e=e||{};let t={$ref:this.collection,$id:this.oid};return e.legacy||(this.db&&(t.$db=this.db),t=Object.assign(t,this.fields)),t}static fromExtendedJSON(e){const t=Object.assign({},e);return delete t.$ref,delete t.$id,delete t.$db,new Rt(e.$ref,e.$id,e.$db,t)}inspect(e,t,r){r??=He;const n=[r(this.namespace,t),r(this.oid,t),...this.db?[r(this.db,t)]:[],...Object.keys(this.fields).length>0?[r(this.fields,t)]:[]];return n[1]=r===He?`new ObjectId(${n[1]})`:n[1],`new DBRef(${n.join(", ")})`}}function Pt(e){if(""===e)return e;let t=0;const r="-"===e[t],n="+"===e[t];(n||r)&&(t+=1);let o=!1;for(;t<e.length&&"0"===e[t];++t)o=!0;return o?`${r?"-":""}${e.length===t?"0":e.slice(t)}`:n?e.slice(1):e}let Ct;try{Ct=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{}const Nt=4294967296,xt=0x10000000000000000,Lt=xt/2,Ut={},kt={},Dt=/^(\+?0|(\+|-)?[1-9][0-9]*)$/;class jt extends mt{get _bsontype(){return"Long"}get __isLong__(){return!0}high;low;unsigned;constructor(e=0,t,r){super();const n="boolean"==typeof t?t:Boolean(r),o="number"==typeof t?t:0,i="string"==typeof e?jt.fromString(e,n):"bigint"==typeof e?jt.fromBigInt(e,n):{low:0|e,high:0|o,unsigned:n};this.low=i.low,this.high=i.high,this.unsigned=i.unsigned}static TWO_PWR_24=jt.fromInt(16777216);static MAX_UNSIGNED_VALUE=jt.fromBits(-1,-1,!0);static ZERO=jt.fromInt(0);static UZERO=jt.fromInt(0,!0);static ONE=jt.fromInt(1);static UONE=jt.fromInt(1,!0);static NEG_ONE=jt.fromInt(-1);static MAX_VALUE=jt.fromBits(-1,2147483647,!1);static MIN_VALUE=jt.fromBits(0,-2147483648,!1);static fromBits(e,t,r){return new jt(e,t,r)}static fromInt(e,t){let r,n,o;return t?(o=0<=(e>>>=0)&&e<256)&&(n=kt[e],n)?n:(r=jt.fromBits(e,(0|e)<0?-1:0,!0),o&&(kt[e]=r),r):(o=-128<=(e|=0)&&e<128)&&(n=Ut[e],n)?n:(r=jt.fromBits(e,e<0?-1:0,!1),o&&(Ut[e]=r),r)}static fromNumber(e,t){if(isNaN(e))return t?jt.UZERO:jt.ZERO;if(t){if(e<0)return jt.UZERO;if(e>=xt)return jt.MAX_UNSIGNED_VALUE}else{if(e<=-Lt)return jt.MIN_VALUE;if(e+1>=Lt)return jt.MAX_VALUE}return e<0?jt.fromNumber(-e,t).neg():jt.fromBits(e%Nt|0,e/Nt|0,t)}static fromBigInt(e,t){const r=0xffffffffn;return new jt(Number(e&r),Number(e>>32n&r),t)}static _fromString(e,t,r){if(0===e.length)throw new Xe("empty string");if(r<2||36<r)throw new Xe("radix");let n;if((n=e.indexOf("-"))>0)throw new Xe("interior hyphen");if(0===n)return jt._fromString(e.substring(1),t,r).neg();const o=jt.fromNumber(Math.pow(r,8));let i=jt.ZERO;for(let t=0;t<e.length;t+=8){const n=Math.min(8,e.length-t),s=parseInt(e.substring(t,t+n),r);if(n<8){const e=jt.fromNumber(Math.pow(r,n));i=i.mul(e).add(jt.fromNumber(s))}else i=i.mul(o),i=i.add(jt.fromNumber(s))}return i.unsigned=t,i}static fromStringStrict(e,t,r){let n=!1;if("number"==typeof t?(r=t,t=!1):n=!!t,r??=10,e.trim()!==e)throw new Xe(`Input: '${e}' contains leading and/or trailing whitespace`);if(!function(e,t){const r="0123456789abcdefghijklmnopqrstuvwxyz".slice(0,t=t??10);return!new RegExp(`[^-+${r}]`,"i").test(e)&&e}(e,r))throw new Xe(`Input: '${e}' contains invalid characters for radix: ${r}`);const o=Pt(e),i=jt._fromString(o,n,r);if(i.toString(r).toLowerCase()!==o.toLowerCase())throw new Xe(`Input: ${e} is not representable as ${i.unsigned?"an unsigned":"a signed"} 64-bit Long ${null!=r?`with radix: ${r}`:""}`);return i}static fromString(e,t,r){let n=!1;return"number"==typeof t?(r=t,t=!1):n=!!t,r??=10,"NaN"===e&&r<24||("Infinity"===e||"+Infinity"===e||"-Infinity"===e)&&r<35?jt.ZERO:jt._fromString(e,n,r)}static fromBytes(e,t,r){return r?jt.fromBytesLE(e,t):jt.fromBytesBE(e,t)}static fromBytesLE(e,t){return new jt(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)}static fromBytesBE(e,t){return new jt(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)}static isLong(e){return null!=e&&"object"==typeof e&&"__isLong__"in e&&!0===e.__isLong__}static fromValue(e,t){return"number"==typeof e?jt.fromNumber(e,t):"string"==typeof e?jt.fromString(e,t):jt.fromBits(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}add(e){jt.isLong(e)||(e=jt.fromValue(e));const t=this.high>>>16,r=65535&this.high,n=this.low>>>16,o=65535&this.low,i=e.high>>>16,s=65535&e.high,a=e.low>>>16;let u=0,c=0,l=0,f=0;return f+=o+(65535&e.low),l+=f>>>16,f&=65535,l+=n+a,c+=l>>>16,l&=65535,c+=r+s,u+=c>>>16,c&=65535,u+=t+i,u&=65535,jt.fromBits(l<<16|f,u<<16|c,this.unsigned)}and(e){return jt.isLong(e)||(e=jt.fromValue(e)),jt.fromBits(this.low&e.low,this.high&e.high,this.unsigned)}compare(e){if(jt.isLong(e)||(e=jt.fromValue(e)),this.eq(e))return 0;const t=this.isNegative(),r=e.isNegative();return t&&!r?-1:!t&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1}comp(e){return this.compare(e)}divide(e){if(jt.isLong(e)||(e=jt.fromValue(e)),e.isZero())throw new Xe("division by zero");if(Ct){if(!this.unsigned&&-2147483648===this.high&&-1===e.low&&-1===e.high)return this;const t=(this.unsigned?Ct.div_u:Ct.div_s)(this.low,this.high,e.low,e.high);return jt.fromBits(t,Ct.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?jt.UZERO:jt.ZERO;let t,r,n;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return jt.UZERO;if(e.gt(this.shru(1)))return jt.UONE;n=jt.UZERO}else{if(this.eq(jt.MIN_VALUE))return e.eq(jt.ONE)||e.eq(jt.NEG_ONE)?jt.MIN_VALUE:e.eq(jt.MIN_VALUE)?jt.ONE:(t=this.shr(1).div(e).shl(1),t.eq(jt.ZERO)?e.isNegative()?jt.ONE:jt.NEG_ONE:(r=this.sub(e.mul(t)),n=t.add(r.div(e)),n));if(e.eq(jt.MIN_VALUE))return this.unsigned?jt.UZERO:jt.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();n=jt.ZERO}for(r=this;r.gte(e);){t=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));const o=Math.ceil(Math.log(t)/Math.LN2),i=o<=48?1:Math.pow(2,o-48);let s=jt.fromNumber(t),a=s.mul(e);for(;a.isNegative()||a.gt(r);)t-=i,s=jt.fromNumber(t,this.unsigned),a=s.mul(e);s.isZero()&&(s=jt.ONE),n=n.add(s),r=r.sub(a)}return n}div(e){return this.divide(e)}equals(e){return jt.isLong(e)||(e=jt.fromValue(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&this.high===e.high&&this.low===e.low}eq(e){return this.equals(e)}getHighBits(){return this.high}getHighBitsUnsigned(){return this.high>>>0}getLowBits(){return this.low}getLowBitsUnsigned(){return this.low>>>0}getNumBitsAbs(){if(this.isNegative())return this.eq(jt.MIN_VALUE)?64:this.neg().getNumBitsAbs();const e=0!==this.high?this.high:this.low;let t;for(t=31;t>0&&!(e&1<<t);t--);return 0!==this.high?t+33:t+1}greaterThan(e){return this.comp(e)>0}gt(e){return this.greaterThan(e)}greaterThanOrEqual(e){return this.comp(e)>=0}gte(e){return this.greaterThanOrEqual(e)}ge(e){return this.greaterThanOrEqual(e)}isEven(){return!(1&this.low)}isNegative(){return!this.unsigned&&this.high<0}isOdd(){return!(1&~this.low)}isPositive(){return this.unsigned||this.high>=0}isZero(){return 0===this.high&&0===this.low}lessThan(e){return this.comp(e)<0}lt(e){return this.lessThan(e)}lessThanOrEqual(e){return this.comp(e)<=0}lte(e){return this.lessThanOrEqual(e)}modulo(e){if(jt.isLong(e)||(e=jt.fromValue(e)),Ct){const t=(this.unsigned?Ct.rem_u:Ct.rem_s)(this.low,this.high,e.low,e.high);return jt.fromBits(t,Ct.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))}mod(e){return this.modulo(e)}rem(e){return this.modulo(e)}multiply(e){if(this.isZero())return jt.ZERO;if(jt.isLong(e)||(e=jt.fromValue(e)),Ct){const t=Ct.mul(this.low,this.high,e.low,e.high);return jt.fromBits(t,Ct.get_high(),this.unsigned)}if(e.isZero())return jt.ZERO;if(this.eq(jt.MIN_VALUE))return e.isOdd()?jt.MIN_VALUE:jt.ZERO;if(e.eq(jt.MIN_VALUE))return this.isOdd()?jt.MIN_VALUE:jt.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(jt.TWO_PWR_24)&&e.lt(jt.TWO_PWR_24))return jt.fromNumber(this.toNumber()*e.toNumber(),this.unsigned);const t=this.high>>>16,r=65535&this.high,n=this.low>>>16,o=65535&this.low,i=e.high>>>16,s=65535&e.high,a=e.low>>>16,u=65535&e.low;let c=0,l=0,f=0,d=0;return d+=o*u,f+=d>>>16,d&=65535,f+=n*u,l+=f>>>16,f&=65535,f+=o*a,l+=f>>>16,f&=65535,l+=r*u,c+=l>>>16,l&=65535,l+=n*a,c+=l>>>16,l&=65535,l+=o*s,c+=l>>>16,l&=65535,c+=t*u+r*a+n*s+o*i,c&=65535,jt.fromBits(f<<16|d,c<<16|l,this.unsigned)}mul(e){return this.multiply(e)}negate(){return!this.unsigned&&this.eq(jt.MIN_VALUE)?jt.MIN_VALUE:this.not().add(jt.ONE)}neg(){return this.negate()}not(){return jt.fromBits(~this.low,~this.high,this.unsigned)}notEquals(e){return!this.equals(e)}neq(e){return this.notEquals(e)}ne(e){return this.notEquals(e)}or(e){return jt.isLong(e)||(e=jt.fromValue(e)),jt.fromBits(this.low|e.low,this.high|e.high,this.unsigned)}shiftLeft(e){return jt.isLong(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?jt.fromBits(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):jt.fromBits(0,this.low<<e-32,this.unsigned)}shl(e){return this.shiftLeft(e)}shiftRight(e){return jt.isLong(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?jt.fromBits(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):jt.fromBits(this.high>>e-32,this.high>=0?0:-1,this.unsigned)}shr(e){return this.shiftRight(e)}shiftRightUnsigned(e){if(jt.isLong(e)&&(e=e.toInt()),0==(e&=63))return this;{const t=this.high;if(e<32){const r=this.low;return jt.fromBits(r>>>e|t<<32-e,t>>>e,this.unsigned)}return 32===e?jt.fromBits(t,0,this.unsigned):jt.fromBits(t>>>e-32,0,this.unsigned)}}shr_u(e){return this.shiftRightUnsigned(e)}shru(e){return this.shiftRightUnsigned(e)}subtract(e){return jt.isLong(e)||(e=jt.fromValue(e)),this.add(e.neg())}sub(e){return this.subtract(e)}toInt(){return this.unsigned?this.low>>>0:this.low}toNumber(){return this.unsigned?(this.high>>>0)*Nt+(this.low>>>0):this.high*Nt+(this.low>>>0)}toBigInt(){return BigInt(this.toString())}toBytes(e){return e?this.toBytesLE():this.toBytesBE()}toBytesLE(){const e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]}toBytesBE(){const e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]}toSigned(){return this.unsigned?jt.fromBits(this.low,this.high,!1):this}toString(e){if((e=e||10)<2||36<e)throw new Xe("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(jt.MIN_VALUE)){const t=jt.fromNumber(e),r=this.div(t),n=r.mul(t).sub(this);return r.toString(e)+n.toInt().toString(e)}return"-"+this.neg().toString(e)}const t=jt.fromNumber(Math.pow(e,6),this.unsigned);let r=this,n="";for(;;){const o=r.div(t);let i=(r.sub(o.mul(t)).toInt()>>>0).toString(e);if(r=o,r.isZero())return i+n;for(;i.length<6;)i="0"+i;n=""+i+n}}toUnsigned(){return this.unsigned?this:jt.fromBits(this.low,this.high,!0)}xor(e){return jt.isLong(e)||(e=jt.fromValue(e)),jt.fromBits(this.low^e.low,this.high^e.high,this.unsigned)}eqz(){return this.isZero()}le(e){return this.lessThanOrEqual(e)}toExtendedJSON(e){return e&&e.relaxed?this.toNumber():{$numberLong:this.toString()}}static fromExtendedJSON(e,t){const{useBigInt64:r=!1,relaxed:n=!0}={...t};if(e.$numberLong.length>20)throw new Xe("$numberLong string is too long");if(!Dt.test(e.$numberLong))throw new Xe(`$numberLong string "${e.$numberLong}" is in an invalid format`);if(r){const t=BigInt(e.$numberLong);return BigInt.asIntN(64,t)}const o=jt.fromString(e.$numberLong);return n?o.toNumber():o}inspect(e,t,r){return r??=He,`new Long(${r(this.toString(),t)}${this.unsigned?`, ${r(this.unsigned,t)}`:""})`}}const qt=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,Mt=/^(\+|-)?(Infinity|inf)$/i,Bt=/^(\+|-)?NaN$/i,Wt=6111,Ft=-6176,Vt=vt.fromNumberArray([124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),Ht=vt.fromNumberArray([248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),$t=vt.fromNumberArray([120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),Gt=/^([-+])?(\d+)?$/;function zt(e){return!isNaN(parseInt(e,10))}function Kt(e){const t=jt.fromNumber(1e9);let r=jt.fromNumber(0);if(!(e.parts[0]||e.parts[1]||e.parts[2]||e.parts[3]))return{quotient:e,rem:r};for(let n=0;n<=3;n++)r=r.shiftLeft(32),r=r.add(new jt(e.parts[n],0)),e.parts[n]=r.div(t).low,r=r.modulo(t);return{quotient:e,rem:r}}function Jt(e,t){throw new Xe(`"${e}" is not a valid Decimal128 string - ${t}`)}class Yt extends mt{get _bsontype(){return"Decimal128"}bytes;constructor(e){if(super(),"string"==typeof e)this.bytes=Yt.fromString(e).bytes;else{if(!(e instanceof Uint8Array||Fe(e)))throw new Xe("Decimal128 must take a Buffer or string");if(16!==e.byteLength)throw new Xe("Decimal128 must take a Buffer of 16 bytes");this.bytes=e}}static fromString(e){return Yt._fromString(e,{allowRounding:!1})}static fromStringWithRounding(e){return Yt._fromString(e,{allowRounding:!0})}static _fromString(e,t){let r=!1,n=!1,o=!1,i=!1,s=0,a=0,u=0,c=0,l=0;const f=[0];let d=0,h=0,p=0,v=0,y=new jt(0,0),m=new jt(0,0),g=0,b=0;if(e.length>=7e3)throw new Xe(e+" not a valid Decimal128 string");const w=e.match(qt),_=e.match(Mt),S=e.match(Bt);if(!w&&!_&&!S||0===e.length)throw new Xe(e+" not a valid Decimal128 string");if(w){const t=w[2],r=w[4],n=w[5],o=w[6];r&&void 0===o&&Jt(e,"missing exponent power"),r&&void 0===t&&Jt(e,"missing exponent base"),void 0===r&&(n||o)&&Jt(e,"missing e before exponent")}if("+"!==e[b]&&"-"!==e[b]||(n=!0,r="-"===e[b++]),!zt(e[b])&&"."!==e[b]){if("i"===e[b]||"I"===e[b])return new Yt(r?Ht:$t);if("N"===e[b])return new Yt(Vt)}for(;zt(e[b])||"."===e[b];)"."!==e[b]?(d<34&&("0"!==e[b]||i)&&(i||(l=a),i=!0,f[h++]=parseInt(e[b],10),d+=1),i&&(u+=1),o&&(c+=1),a+=1,b+=1):(o&&Jt(e,"contains multiple periods"),o=!0,b+=1);if(o&&!a)throw new Xe(e+" not a valid Decimal128 string");if("e"===e[b]||"E"===e[b]){const t=e.substr(++b).match(Gt);if(!t||!t[2])return new Yt(Vt);v=parseInt(t[0],10),b+=t[0].length}if(e[b])return new Yt(Vt);if(d){if(p=d-1,s=u,1!==s)for(;"0"===e[l+s-1+Number(n)+Number(o)];)s-=1}else f[0]=0,u=1,d=1,s=0;for(v<=c&&c>v+16384?v=Ft:v-=c;v>Wt;){if(p+=1,p>=34){if(0===s){v=Wt;break}Jt(e,"overflow")}v-=1}if(t.allowRounding){for(;v<Ft||d<u;){if(0===p&&s<d){v=Ft,s=0;break}if(d<u?u-=1:p-=1,v<Wt)v+=1;else{if(f.join("").match(/^0+$/)){v=Wt;break}Jt(e,"overflow")}}if(p+1<s){let t=a;o&&(l+=1,t+=1),n&&(l+=1,t+=1);const i=parseInt(e[l+p+1],10);let s=0;if(i>=5&&(s=1,5===i)){s=f[p]%2==1?1:0;for(let r=l+p+2;r<t;r++)if(parseInt(e[r],10)){s=1;break}}if(s){let e=p;for(;e>=0&&++f[e]>9;e--)if(f[e]=0,0===e){if(!(v<Wt))return new Yt(r?Ht:$t);v+=1,f[e]=1}}}}else{for(;v<Ft||d<u;){if(0===p){if(0===s){v=Ft;break}Jt(e,"exponent underflow")}d<u?("0"!==e[u-1+Number(n)+Number(o)]&&0!==s&&Jt(e,"inexact rounding"),u-=1):(0!==f[p]&&Jt(e,"inexact rounding"),p-=1),v<Wt?v+=1:Jt(e,"overflow")}p+1<s&&(o&&(l+=1),n&&(l+=1),0!==parseInt(e[l+p+1],10)&&Jt(e,"inexact rounding"))}if(y=jt.fromNumber(0),m=jt.fromNumber(0),0===s)y=jt.fromNumber(0),m=jt.fromNumber(0);else if(p<17){let e=0;for(m=jt.fromNumber(f[e++]),y=new jt(0,0);e<=p;e++)m=m.multiply(jt.fromNumber(10)),m=m.add(jt.fromNumber(f[e]))}else{let e=0;for(y=jt.fromNumber(f[e++]);e<=p-17;e++)y=y.multiply(jt.fromNumber(10)),y=y.add(jt.fromNumber(f[e]));for(m=jt.fromNumber(f[e++]);e<=p;e++)m=m.multiply(jt.fromNumber(10)),m=m.add(jt.fromNumber(f[e]))}const E=function(e,t){if(!e&&!t)return{high:jt.fromNumber(0),low:jt.fromNumber(0)};const r=e.shiftRightUnsigned(32),n=new jt(e.getLowBits(),0),o=t.shiftRightUnsigned(32),i=new jt(t.getLowBits(),0);let s=r.multiply(o),a=r.multiply(i);const u=n.multiply(o);let c=n.multiply(i);return s=s.add(a.shiftRightUnsigned(32)),a=new jt(a.getLowBits(),0).add(u).add(c.shiftRightUnsigned(32)),s=s.add(a.shiftRightUnsigned(32)),c=a.shiftLeft(32).add(new jt(c.getLowBits(),0)),{high:s,low:c}}(y,jt.fromString("100000000000000000"));E.low=E.low.add(m),function(e,t){const r=e.high>>>0,n=t.high>>>0;return r<n||r===n&&e.low>>>0<t.low>>>0}(E.low,m)&&(E.high=E.high.add(jt.fromNumber(1))),g=v+6176;const I={low:jt.fromNumber(0),high:jt.fromNumber(0)};E.high.shiftRightUnsigned(49).and(jt.fromNumber(1)).equals(jt.fromNumber(1))?(I.high=I.high.or(jt.fromNumber(3).shiftLeft(61)),I.high=I.high.or(jt.fromNumber(g).and(jt.fromNumber(16383).shiftLeft(47))),I.high=I.high.or(E.high.and(jt.fromNumber(0x7fffffffffff)))):(I.high=I.high.or(jt.fromNumber(16383&g).shiftLeft(49)),I.high=I.high.or(E.high.and(jt.fromNumber(562949953421311)))),I.low=E.low,r&&(I.high=I.high.or(jt.fromString("9223372036854775808")));const O=vt.allocateUnsafe(16);return b=0,O[b++]=255&I.low.low,O[b++]=I.low.low>>8&255,O[b++]=I.low.low>>16&255,O[b++]=I.low.low>>24&255,O[b++]=255&I.low.high,O[b++]=I.low.high>>8&255,O[b++]=I.low.high>>16&255,O[b++]=I.low.high>>24&255,O[b++]=255&I.high.low,O[b++]=I.high.low>>8&255,O[b++]=I.high.low>>16&255,O[b++]=I.high.low>>24&255,O[b++]=255&I.high.high,O[b++]=I.high.high>>8&255,O[b++]=I.high.high>>16&255,O[b++]=I.high.high>>24&255,new Yt(O)}toString(){let e,t=0;const r=new Array(36);for(let e=0;e<r.length;e++)r[e]=0;let n,o,i,s=0,a=!1,u={parts:[0,0,0,0]};const c=[];s=0;const l=this.bytes,f=l[s++]|l[s++]<<8|l[s++]<<16|l[s++]<<24,d=l[s++]|l[s++]<<8|l[s++]<<16|l[s++]<<24,h=l[s++]|l[s++]<<8|l[s++]<<16|l[s++]<<24,p=l[s++]|l[s++]<<8|l[s++]<<16|l[s++]<<24;s=0,(new jt(f,d),new jt(h,p)).lessThan(jt.ZERO)&&c.push("-");const v=p>>26&31;if(v>>3==3){if(30===v)return c.join("")+"Infinity";if(31===v)return"NaN";e=p>>15&16383,n=8+(p>>14&1)}else n=p>>14&7,e=p>>17&16383;const y=e-6176;if(u.parts[0]=(16383&p)+((15&n)<<14),u.parts[1]=h,u.parts[2]=d,u.parts[3]=f,0===u.parts[0]&&0===u.parts[1]&&0===u.parts[2]&&0===u.parts[3])a=!0;else for(i=3;i>=0;i--){let e=0;const t=Kt(u);if(u=t.quotient,e=t.rem.low,e)for(o=8;o>=0;o--)r[9*i+o]=e%10,e=Math.floor(e/10)}if(a)t=1,r[s]=0;else for(t=36;!r[s];)t-=1,s+=1;const m=t-1+y;if(m>=34||m<=-7||y>0){if(t>34)return c.push("0"),y>0?c.push(`E+${y}`):y<0&&c.push(`E${y}`),c.join("");c.push(`${r[s++]}`),t-=1,t&&c.push(".");for(let e=0;e<t;e++)c.push(`${r[s++]}`);c.push("E"),m>0?c.push(`+${m}`):c.push(`${m}`)}else if(y>=0)for(let e=0;e<t;e++)c.push(`${r[s++]}`);else{let e=t+y;if(e>0)for(let t=0;t<e;t++)c.push(`${r[s++]}`);else c.push("0");for(c.push(".");e++<0;)c.push("0");for(let n=0;n<t-Math.max(e-1,0);n++)c.push(`${r[s++]}`)}return c.join("")}toJSON(){return{$numberDecimal:this.toString()}}toExtendedJSON(){return{$numberDecimal:this.toString()}}static fromExtendedJSON(e){return Yt.fromString(e.$numberDecimal)}inspect(e,t,r){return r??=He,`new Decimal128(${r(this.toString(),t)})`}}class Qt extends mt{get _bsontype(){return"Double"}value;constructor(e){super(),e instanceof Number&&(e=e.valueOf()),this.value=+e}static fromString(e){const t=Number(e);if("NaN"===e)return new Qt(NaN);if("Infinity"===e)return new Qt(1/0);if("-Infinity"===e)return new Qt(-1/0);if(!Number.isFinite(t))throw new Xe(`Input: ${e} is not representable as a Double`);if(e.trim()!==e)throw new Xe(`Input: '${e}' contains whitespace`);if(""===e)throw new Xe("Input is an empty string");if(/[^-0-9.+eE]/.test(e))throw new Xe(`Input: '${e}' is not in decimal or exponential notation`);return new Qt(t)}valueOf(){return this.value}toJSON(){return this.value}toString(e){return this.value.toString(e)}toExtendedJSON(e){return e&&(e.legacy||e.relaxed&&isFinite(this.value))?this.value:Object.is(Math.sign(this.value),-0)?{$numberDouble:"-0.0"}:{$numberDouble:Number.isInteger(this.value)?this.value.toFixed(1):this.value.toString()}}static fromExtendedJSON(e,t){const r=parseFloat(e.$numberDouble);return t&&t.relaxed?r:new Qt(r)}inspect(e,t,r){return r??=He,`new Double(${r(this.value,t)})`}}class Zt extends mt{get _bsontype(){return"Int32"}value;constructor(e){super(),e instanceof Number&&(e=e.valueOf()),this.value=0|+e}static fromString(e){const t=Pt(e),r=Number(e);if(ze<r)throw new Xe(`Input: '${e}' is larger than the maximum value for Int32`);if(Ke>r)throw new Xe(`Input: '${e}' is smaller than the minimum value for Int32`);if(!Number.isSafeInteger(r))throw new Xe(`Input: '${e}' is not a safe integer`);if(r.toString()!==t)throw new Xe(`Input: '${e}' is not a valid Int32 string`);return new Zt(r)}valueOf(){return this.value}toString(e){return this.value.toString(e)}toJSON(){return this.value}toExtendedJSON(e){return e&&(e.relaxed||e.legacy)?this.value:{$numberInt:this.value.toString()}}static fromExtendedJSON(e,t){return t&&t.relaxed?parseInt(e.$numberInt,10):new Zt(e.$numberInt)}inspect(e,t,r){return r??=He,`new Int32(${r(this.value,t)})`}}class Xt extends mt{get _bsontype(){return"MaxKey"}toExtendedJSON(){return{$maxKey:1}}static fromExtendedJSON(){return new Xt}inspect(){return"new MaxKey()"}}class er extends mt{get _bsontype(){return"MinKey"}toExtendedJSON(){return{$minKey:1}}static fromExtendedJSON(){return new er}inspect(){return"new MinKey()"}}let tr=null;const rr=new WeakMap;class nr extends mt{get _bsontype(){return"ObjectId"}static index=Math.floor(16777215*Math.random());static cacheHexString;buffer;constructor(e){let t;if(super(),"object"==typeof e&&e&&"id"in e){if("string"!=typeof e.id&&!ArrayBuffer.isView(e.id))throw new Xe("Argument passed in must have an id that is of type string or Buffer");t="toHexString"in e&&"function"==typeof e.toHexString?vt.fromHex(e.toHexString()):e.id}else t=e;if(null==t)this.buffer=nr.generate();else if(ArrayBuffer.isView(t)&&12===t.byteLength)this.buffer=vt.toLocalBufferType(t);else{if("string"!=typeof t)throw new Xe("Argument passed in does not match the accepted types");if(!nr.validateHexString(t))throw new Xe("input must be a 24 character hex string, 12 byte Uint8Array, or an integer");this.buffer=vt.fromHex(t),nr.cacheHexString&&rr.set(this,t)}}get id(){return this.buffer}set id(e){this.buffer=e,nr.cacheHexString&&rr.set(this,vt.toHex(e))}static validateHexString(e){if(24!==e?.length)return!1;for(let t=0;t<24;t++){const r=e.charCodeAt(t);if(!(r>=48&&r<=57||r>=97&&r<=102||r>=65&&r<=70))return!1}return!0}toHexString(){if(nr.cacheHexString){const e=rr.get(this);if(e)return e}const e=vt.toHex(this.id);return nr.cacheHexString&&rr.set(this,e),e}static getInc(){return nr.index=(nr.index+1)%16777215}static generate(e){"number"!=typeof e&&(e=Math.floor(Date.now()/1e3));const t=nr.getInc(),r=vt.allocateUnsafe(12);return _t.setInt32BE(r,0,e),null===tr&&(tr=vt.randomBytes(5)),r[4]=tr[0],r[5]=tr[1],r[6]=tr[2],r[7]=tr[3],r[8]=tr[4],r[11]=255&t,r[10]=t>>8&255,r[9]=t>>16&255,r}toString(e){return"base64"===e?vt.toBase64(this.id):this.toHexString()}toJSON(){return this.toHexString()}static is(e){return null!=e&&"object"==typeof e&&"_bsontype"in e&&"ObjectId"===e._bsontype}equals(e){if(null==e)return!1;if(nr.is(e))return this.buffer[11]===e.buffer[11]&&vt.equals(this.buffer,e.buffer);if("string"==typeof e)return e.toLowerCase()===this.toHexString();if("object"==typeof e&&"function"==typeof e.toHexString){const t=e.toHexString(),r=this.toHexString();return"string"==typeof t&&t.toLowerCase()===r}return!1}getTimestamp(){const e=new Date,t=_t.getUint32BE(this.buffer,0);return e.setTime(1e3*Math.floor(t)),e}static createPk(){return new nr}serializeInto(e,t){return e[t]=this.buffer[0],e[t+1]=this.buffer[1],e[t+2]=this.buffer[2],e[t+3]=this.buffer[3],e[t+4]=this.buffer[4],e[t+5]=this.buffer[5],e[t+6]=this.buffer[6],e[t+7]=this.buffer[7],e[t+8]=this.buffer[8],e[t+9]=this.buffer[9],e[t+10]=this.buffer[10],e[t+11]=this.buffer[11],12}static createFromTime(e){const t=vt.allocate(12);for(let e=11;e>=4;e--)t[e]=0;return _t.setInt32BE(t,0,e),new nr(t)}static createFromHexString(e){if(24!==e?.length)throw new Xe("hex string must be 24 characters");return new nr(vt.fromHex(e))}static createFromBase64(e){if(16!==e?.length)throw new Xe("base64 string must be 16 characters");return new nr(vt.fromBase64(e))}static isValid(e){if(null==e)return!1;if("string"==typeof e)return nr.validateHexString(e);try{return new nr(e),!0}catch{return!1}}toExtendedJSON(){return this.toHexString?{$oid:this.toHexString()}:{$oid:this.toString("hex")}}static fromExtendedJSON(e){return new nr(e.$oid)}isCached(){return nr.cacheHexString&&rr.has(this)}inspect(e,t,r){return r??=He,`new ObjectId(${r(this.toHexString(),t)})`}}class or extends mt{get _bsontype(){return"BSONRegExp"}pattern;options;constructor(e,t){if(super(),this.pattern=e,this.options=(t??"").split("").sort().join(""),-1!==this.pattern.indexOf("\0"))throw new Xe(`BSON Regex patterns cannot contain null bytes, found: ${JSON.stringify(this.pattern)}`);if(-1!==this.options.indexOf("\0"))throw new Xe(`BSON Regex options cannot contain null bytes, found: ${JSON.stringify(this.options)}`);for(let e=0;e<this.options.length;e++)if("i"!==this.options[e]&&"m"!==this.options[e]&&"x"!==this.options[e]&&"l"!==this.options[e]&&"s"!==this.options[e]&&"u"!==this.options[e])throw new Xe(`The regular expression option [${this.options[e]}] is not supported`)}static parseOptions(e){return e?e.split("").sort().join(""):""}toExtendedJSON(e){return(e=e||{}).legacy?{$regex:this.pattern,$options:this.options}:{$regularExpression:{pattern:this.pattern,options:this.options}}}static fromExtendedJSON(e){if("$regex"in e){if("string"==typeof e.$regex)return new or(e.$regex,or.parseOptions(e.$options));if("BSONRegExp"===e.$regex._bsontype)return e}if("$regularExpression"in e)return new or(e.$regularExpression.pattern,or.parseOptions(e.$regularExpression.options));throw new Xe(`Unexpected BSONRegExp EJSON object form: ${JSON.stringify(e)}`)}inspect(e,t,r){const n=function(e){if(null!=e&&"object"==typeof e&&"stylize"in e&&"function"==typeof e.stylize)return e.stylize}(t)??(e=>e);return r??=He,`new BSONRegExp(${n(r(this.pattern),"regexp")}, ${n(r(this.options),"regexp")})`}}class ir extends mt{get _bsontype(){return"BSONSymbol"}value;constructor(e){super(),this.value=e}valueOf(){return this.value}toString(){return this.value}toJSON(){return this.value}toExtendedJSON(){return{$symbol:this.value}}static fromExtendedJSON(e){return new ir(e.$symbol)}inspect(e,t,r){return r??=He,`new BSONSymbol(${r(this.value,t)})`}}const sr=jt;class ar extends sr{get _bsontype(){return"Timestamp"}get[yt](){return"Timestamp"}static MAX_VALUE=jt.MAX_UNSIGNED_VALUE;get i(){return this.low>>>0}get t(){return this.high>>>0}constructor(e){if(null==e)super(0,0,!0);else if("bigint"==typeof e)super(e,!0);else if(jt.isLong(e))super(e.low,e.high,!0);else{if("object"!=typeof e||!("t"in e)||!("i"in e))throw new Xe("A Timestamp can only be constructed with: bigint, Long, or { t: number; i: number }");{if("number"!=typeof e.t&&("object"!=typeof e.t||"Int32"!==e.t._bsontype))throw new Xe("Timestamp constructed from { t, i } must provide t as a number");if("number"!=typeof e.i&&("object"!=typeof e.i||"Int32"!==e.i._bsontype))throw new Xe("Timestamp constructed from { t, i } must provide i as a number");const t=Number(e.t),r=Number(e.i);if(t<0||Number.isNaN(t))throw new Xe("Timestamp constructed from { t, i } must provide a positive t");if(r<0||Number.isNaN(r))throw new Xe("Timestamp constructed from { t, i } must provide a positive i");if(t>4294967295)throw new Xe("Timestamp constructed from { t, i } must provide t equal or less than uint32 max");if(r>4294967295)throw new Xe("Timestamp constructed from { t, i } must provide i equal or less than uint32 max");super(r,t,!0)}}}toJSON(){return{$timestamp:this.toString()}}static fromInt(e){return new ar(jt.fromInt(e,!0))}static fromNumber(e){return new ar(jt.fromNumber(e,!0))}static fromBits(e,t){return new ar({i:e,t:t})}static fromString(e,t){return new ar(jt.fromString(e,!0,t))}toExtendedJSON(){return{$timestamp:{t:this.t,i:this.i}}}static fromExtendedJSON(e){const t=jt.isLong(e.$timestamp.i)?e.$timestamp.i.getLowBitsUnsigned():e.$timestamp.i,r=jt.isLong(e.$timestamp.t)?e.$timestamp.t.getLowBitsUnsigned():e.$timestamp.t;return new ar({t:r,i:t})}inspect(e,t,r){return r??=He,`new Timestamp({ t: ${r(this.t,t)}, i: ${r(this.i,t)} })`}}jt.fromNumber(Qe),jt.fromNumber(Ze),new Set(["$db","$ref","$id","$clusterTime"]);const ur={$oid:nr,$binary:St,$uuid:St,$symbol:ir,$numberInt:Zt,$numberDecimal:Yt,$numberDouble:Qt,$numberLong:jt,$minKey:er,$maxKey:Xt,$regex:or,$regularExpression:or,$timestamp:ar};function cr(e,t={}){if("number"==typeof e){const r=e<=ze&&e>=Ke,n=e<=Je&&e>=Ye;if(t.relaxed||t.legacy)return e;if(Number.isInteger(e)&&!Object.is(e,-0)){if(r)return new Zt(e);if(n)return t.useBigInt64?BigInt(e):jt.fromNumber(e)}return new Qt(e)}if(null==e||"object"!=typeof e)return e;if(e.$undefined)return null;const r=Object.keys(e).filter((t=>t.startsWith("$")&&null!=e[t]));for(let n=0;n<r.length;n++){const o=ur[r[n]];if(o)return o.fromExtendedJSON(e,t)}if(null!=e.$date){const r=e.$date,n=new Date;if(t.legacy)if("number"==typeof r)n.setTime(r);else if("string"==typeof r)n.setTime(Date.parse(r));else{if("bigint"!=typeof r)throw new tt("Unrecognized type for EJSON date: "+typeof r);n.setTime(Number(r))}else if("string"==typeof r)n.setTime(Date.parse(r));else if(jt.isLong(r))n.setTime(r.toNumber());else if("number"==typeof r&&t.relaxed)n.setTime(r);else{if("bigint"!=typeof r)throw new tt("Unrecognized type for EJSON date: "+typeof r);n.setTime(Number(r))}return n}if(null!=e.$code){const t=Object.assign({},e);return e.$scope&&(t.$scope=cr(e.$scope)),At.fromExtendedJSON(e)}if(function(e){return null!=e&&"object"==typeof e&&"$id"in e&&null!=e.$id&&"$ref"in e&&"string"==typeof e.$ref&&(!("$db"in e)||"$db"in e&&"string"==typeof e.$db)}(e)||e.$dbPointer){const t=e.$ref?e:e.$dbPointer;if(t instanceof Rt)return t;const r=Object.keys(t).filter((e=>e.startsWith("$")));let n=!0;if(r.forEach((e=>{-1===["$ref","$id","$db"].indexOf(e)&&(n=!1)})),n)return Rt.fromExtendedJSON(t)}return e}function lr(e){const t=e.toISOString();return 0!==e.getUTCMilliseconds()?t:t.slice(0,-5)+"Z"}function fr(e,t){if(e instanceof Map||Ve(e)){const r=Object.create(null);for(const[t,n]of e){if("string"!=typeof t)throw new Xe("Can only serialize maps with string keys");r[t]=n}return fr(r,t)}if(("object"==typeof e||"function"==typeof e)&&null!==e){const r=t.seenObjects.findIndex((t=>t.obj===e));if(-1!==r){const e=t.seenObjects.map((e=>e.propertyName)),n=e.slice(0,r).map((e=>`${e} -> `)).join(""),o=e[r],i=" -> "+e.slice(r+1,e.length-1).map((e=>`${e} -> `)).join(""),s=e[e.length-1],a=" ".repeat(n.length+o.length/2),u="-".repeat(i.length+(o.length+s.length)/2-1);throw new Xe(`Converting circular structure to EJSON:\n ${n}${o}${i}${s}\n ${a}\\${u}/`)}t.seenObjects[t.seenObjects.length-1].obj=e}if(Array.isArray(e))return function(e,t){return e.map(((e,r)=>{t.seenObjects.push({propertyName:`index ${r}`,obj:null});try{return fr(e,t)}finally{t.seenObjects.pop()}}))}(e,t);if(void 0===e)return null;if(e instanceof Date||((r=e)instanceof Date||"[object Date]"===Object.prototype.toString.call(r))){const r=e.getTime(),n=r>-1&&r<2534023188e5;return t.legacy?t.relaxed&&n?{$date:e.getTime()}:{$date:lr(e)}:t.relaxed&&n?{$date:lr(e)}:{$date:{$numberLong:e.getTime().toString()}}}var r,n;if(!("number"!=typeof e||t.relaxed&&isFinite(e))){if(Number.isInteger(e)&&!Object.is(e,-0)){if(e>=Ke&&e<=ze)return{$numberInt:e.toString()};if(e>=Ye&&e<=Je)return{$numberLong:e.toString()}}return{$numberDouble:Object.is(e,-0)?"-0.0":e.toString()}}if("bigint"==typeof e)return t.relaxed?Number(BigInt.asIntN(64,e)):{$numberLong:BigInt.asIntN(64,e).toString()};if(e instanceof RegExp||((n=e)instanceof RegExp||"[object RegExp]"===Object.prototype.toString.call(n))){let r=e.flags;if(void 0===r){const t=e.toString().match(/[gimuy]*$/);t&&(r=t[0])}return new or(e.source,r).toExtendedJSON(t)}return null!=e&&"object"==typeof e?function(e,t){if(null==e||"object"!=typeof e)throw new Xe("not an object instance");const r=e._bsontype;if(void 0===r){const r={};for(const n of Object.keys(e)){t.seenObjects.push({propertyName:n,obj:null});try{const o=fr(e[n],t);"__proto__"===n?Object.defineProperty(r,n,{value:o,writable:!0,enumerable:!0,configurable:!0}):r[n]=o}finally{t.seenObjects.pop()}}return r}if(null!=e&&"object"==typeof e&&"string"==typeof e._bsontype&&e[Ge]!==$e)throw new et;if(function(e){return null!=e&&"object"==typeof e&&"_bsontype"in e&&"string"==typeof e._bsontype}(e)){let n=e;if("function"!=typeof n.toExtendedJSON){const t=dr[e._bsontype];if(!t)throw new Xe("Unrecognized or invalid _bsontype: "+e._bsontype);n=t(n)}return"Code"===r&&n.scope?n=new At(n.code,fr(n.scope,t)):"DBRef"===r&&n.oid&&(n=new Rt(fr(n.collection,t),fr(n.oid,t),fr(n.db,t),fr(n.fields,t))),n.toExtendedJSON(t)}throw new Xe("_bsontype must be a string, but was: "+typeof r)}(e,t):e}const dr={Binary:e=>new St(e.value(),e.sub_type),Code:e=>new At(e.code,e.scope),DBRef:e=>new Rt(e.collection||e.namespace,e.oid,e.db,e.fields),Decimal128:e=>new Yt(e.bytes),Double:e=>new Qt(e.value),Int32:e=>new Zt(e.value),Long:e=>jt.fromBits(null!=e.low?e.low:e.low_,null!=e.low?e.high:e.high_,null!=e.low?e.unsigned:e.unsigned_),MaxKey:()=>new Xt,MinKey:()=>new er,ObjectId:e=>new nr(e),BSONRegExp:e=>new or(e.pattern,e.options),BSONSymbol:e=>new ir(e.value),Timestamp:e=>ar.fromBits(e.low,e.high)};function hr(e,t){const r={useBigInt64:t?.useBigInt64??!1,relaxed:t?.relaxed??!0,legacy:t?.legacy??!1};return JSON.parse(e,((e,t)=>{if(-1!==e.indexOf("\0"))throw new Xe(`BSON Document field names cannot contain null bytes, found: ${JSON.stringify(e)}`);return cr(t,r)}))}function pr(e,t,r,n){null!=r&&"object"==typeof r&&(n=r,r=0),null==t||"object"!=typeof t||Array.isArray(t)||(n=t,t=void 0,r=0);const o=fr(e,Object.assign({relaxed:!0,legacy:!1},n,{seenObjects:[{propertyName:"(root)",obj:null}]}));return JSON.stringify(o,t,r)}const vr=Object.create(null);vr.parse=hr,vr.stringify=pr,vr.serialize=function(e,t){return t=t||{},JSON.parse(pr(e,t))},vr.deserialize=function(e,t){return t=t||{},hr(JSON.stringify(e),t)},Object.freeze(vr);function yr(e,t){try{return _t.getNonnegativeInt32LE(e,t)}catch(e){throw new rt("BSON size cannot be negative",t,{cause:e})}}function mr(e,t){let r=t;for(;0!==e[r];r++);if(r===e.length-1)throw new rt("Null terminator not found",t);return r}const gr=Object.create(null);gr.parseToElements=function(e,t=0){if(t??=0,e.length<5)throw new rt(`Input must be at least 5 bytes, got ${e.length} bytes`,t);const r=yr(e,t);if(r>e.length-t)throw new rt(`Parsed documentSize (${r} bytes) does not match input length (${e.length} bytes)`,t);if(0!==e[t+r-1])throw new rt("BSON documents must end in 0x00",t+r);const n=[];let o=t+4;for(;o<=r+t;){const i=e[o];if(o+=1,0===i){if(o-t!==r)throw new rt("Invalid 0x00 type byte",o);break}const s=o,a=mr(e,o)-s;let u;if(o+=a+1,1===i||18===i||9===i||17===i)u=8;else if(16===i)u=4;else if(7===i)u=12;else if(19===i)u=16;else if(8===i)u=1;else if(10===i||6===i||127===i||255===i)u=0;else if(11===i)u=mr(e,mr(e,o)+1)+1-o;else if(3===i||4===i||15===i)u=yr(e,o);else{if(2!==i&&5!==i&&12!==i&&13!==i&&14!==i)throw new rt(`Invalid 0x${i.toString(16).padStart(2,"0")} type byte`,o);u=yr(e,o)+4,5===i&&(u+=1),12===i&&(u+=12)}if(u>r)throw new rt("value reports length larger than document",o);n.push([i,s,a,o,u]),o+=u}return n},gr.ByteUtils=vt,gr.NumberUtils=_t,Object.freeze(gr);vt.allocate(17825792);var br=function(){function e(e,t){this._stages=[],e&&t&&(this._db=e,this._request=Vr.createRequest(this._db.config),this._collectionName=t)}return e.prototype.end=function(){return e=this,t=void 0,n=function(){var e;return function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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(t){switch(t.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(e=t.sent())&&e.data&&e.data.list?[2,{requestId:e.requestId,data:JSON.parse(e.data.list).map(vr.parse)}]:[2,e]}}))},new((r=void 0)||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}));var e,t,r,n},e.prototype.unwrap=function(){return this._stages},e.prototype.done=function(){return this._stages.map((function(e){var t,r=e.stageKey,n=e.stageValue;return(t={})[r]=JSON.parse(n),t}))},e.prototype._pipe=function(e,t){return this._stages.push({stageKey:"$".concat(e),stageValue:JSON.stringify(t)}),this},e.prototype.addFields=function(e){return this._pipe("addFields",e)},e.prototype.bucket=function(e){return this._pipe("bucket",e)},e.prototype.bucketAuto=function(e){return this._pipe("bucketAuto",e)},e.prototype.count=function(e){return this._pipe("count",e)},e.prototype.geoNear=function(e){return e.query&&(e.query=je.encode(e.query)),e.distanceMultiplier&&"number"==typeof e.distanceMultiplier&&(e.distanceMultiplier=e.distanceMultiplier),e.near&&(e.near=new oe(e.near.longitude,e.near.latitude).toJSON()),this._pipe("geoNear",e)},e.prototype.group=function(e){return this._pipe("group",e)},e.prototype.limit=function(e){return this._pipe("limit",e)},e.prototype.match=function(e){return this._pipe("match",je.encode(e))},e.prototype.project=function(e){return this._pipe("project",e)},e.prototype.lookup=function(e){return this._pipe("lookup",e)},e.prototype.replaceRoot=function(e){return this._pipe("replaceRoot",e)},e.prototype.sample=function(e){return this._pipe("sample",e)},e.prototype.skip=function(e){return this._pipe("skip",e)},e.prototype.sort=function(e){return this._pipe("sort",e)},e.prototype.sortByCount=function(e){return this._pipe("sortByCount",e)},e.prototype.unwind=function(e){return this._pipe("unwind",e)},e}(),wr=br,_r=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};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)}}(),Sr=function(e){function t(t,r){return e.call(this,t,r)||this}return _r(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return this._coll},enumerable:!1,configurable:!0}),t.prototype.doc=function(e){if("string"!=typeof e&&"number"!=typeof e)throw new Error("docId必须为字符串或数字");return new De(this._db,this._coll,e)},t.prototype.add=function(e,t){return new De(this._db,this._coll,void 0).create(e,t)},t.prototype.aggregate=function(){return new wr(this._db,this._coll)},t}(Be),Er={eq:function(e){return new he(fe.EQ,[e])},neq:function(e){return new he(fe.NEQ,[e])},lt:function(e){return new he(fe.LT,[e])},lte:function(e){return new he(fe.LTE,[e])},gt:function(e){return new he(fe.GT,[e])},gte:function(e){return new he(fe.GTE,[e])},in:function(e){return new he(fe.IN,e)},nin:function(e){return new he(fe.NIN,e)},all:function(e){return new he(fe.ALL,e)},elemMatch:function(e){return new he(fe.ELEM_MATCH,[e])},exists:function(e){return new he(fe.EXISTS,[e])},size:function(e){return new he(fe.SIZE,[e])},mod:function(e){return new he(fe.MOD,[e])},geoNear:function(e){return new he(fe.GEO_NEAR,[e])},geoWithin:function(e){return new he(fe.GEO_WITHIN,[e])},geoIntersects:function(e){return new he(fe.GEO_INTERSECTS,[e])},and:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=B(arguments[0])?arguments[0]:Array.from(arguments);return new ce(se.AND,r)},nor:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=B(arguments[0])?arguments[0]:Array.from(arguments);return new ce(se.NOR,r)},or:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=B(arguments[0])?arguments[0]:Array.from(arguments);return new ce(se.OR,r)},not:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=B(arguments[0])?arguments[0]:Array.from(arguments);return new ce(se.NOT,r)},set:function(e){return new ae(ee.SET,[e])},remove:function(){return new ae(ee.REMOVE,[])},inc:function(e){return new ae(ee.INC,[e])},mul:function(e){return new ae(ee.MUL,[e])},push:function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];if(q(t[0])&&t[0].hasOwnProperty("each")){var n=t[0];e={$each:n.each,$position:n.position,$sort:n.sort,$slice:n.slice}}else e=B(t[0])?t[0]:Array.from(t);return new ae(ee.PUSH,e)},pull:function(e){return new ae(ee.PULL,e)},pullAll:function(e){return new ae(ee.PULL_ALL,e)},pop:function(){return new ae(ee.POP,[])},shift:function(){return new ae(ee.SHIFT,[])},unshift:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=B(arguments[0])?arguments[0]:Array.from(arguments);return new ae(ee.UNSHIFT,r)},addToSet:function(e){return new ae(ee.ADD_TO_SET,e)},rename:function(e){return new ae(ee.RENAME,[e])},bit:function(e){return new ae(ee.BIT,[e])},max:function(e){return new ae(ee.MAX,[e])},min:function(e){return new ae(ee.MIN,[e])},expr:function(e){return{$expr:e}},jsonSchema:function(e){return{$jsonSchema:e}},text:function(e){return"string"===j(e)?{$search:e.search}:{$search:e.search,$language:e.language,$caseSensitive:e.caseSensitive,$diacriticSensitive:e.diacriticSensitive}},aggregate:{pipeline:function(){return new wr},abs:function(e){return new Ir("abs",e)},add:function(e){return new Ir("add",e)},ceil:function(e){return new Ir("ceil",e)},divide:function(e){return new Ir("divide",e)},exp:function(e){return new Ir("exp",e)},floor:function(e){return new Ir("floor",e)},ln:function(e){return new Ir("ln",e)},log:function(e){return new Ir("log",e)},log10:function(e){return new Ir("log10",e)},mod:function(e){return new Ir("mod",e)},multiply:function(e){return new Ir("multiply",e)},pow:function(e){return new Ir("pow",e)},sqrt:function(e){return new Ir("sqrt",e)},subtract:function(e){return new Ir("subtract",e)},trunc:function(e){return new Ir("trunc",e)},arrayElemAt:function(e){return new Ir("arrayElemAt",e)},arrayToObject:function(e){return new Ir("arrayToObject",e)},concatArrays:function(e){return new Ir("concatArrays",e)},filter:function(e){return new Ir("filter",e)},in:function(e){return new Ir("in",e)},indexOfArray:function(e){return new Ir("indexOfArray",e)},isArray:function(e){return new Ir("isArray",e)},map:function(e){return new Ir("map",e)},range:function(e){return new Ir("range",e)},reduce:function(e){return new Ir("reduce",e)},reverseArray:function(e){return new Ir("reverseArray",e)},size:function(e){return new Ir("size",e)},slice:function(e){return new Ir("slice",e)},zip:function(e){return new Ir("zip",e)},and:function(e){return new Ir("and",e)},not:function(e){return new Ir("not",e)},or:function(e){return new Ir("or",e)},cmp:function(e){return new Ir("cmp",e)},eq:function(e){return new Ir("eq",e)},gt:function(e){return new Ir("gt",e)},gte:function(e){return new Ir("gte",e)},lt:function(e){return new Ir("lt",e)},lte:function(e){return new Ir("lte",e)},neq:function(e){return new Ir("ne",e)},cond:function(e){return new Ir("cond",e)},ifNull:function(e){return new Ir("ifNull",e)},switch:function(e){return new Ir("switch",e)},dateFromParts:function(e){return new Ir("dateFromParts",e)},dateFromString:function(e){return new Ir("dateFromString",e)},dayOfMonth:function(e){return new Ir("dayOfMonth",e)},dayOfWeek:function(e){return new Ir("dayOfWeek",e)},dayOfYear:function(e){return new Ir("dayOfYear",e)},isoDayOfWeek:function(e){return new Ir("isoDayOfWeek",e)},isoWeek:function(e){return new Ir("isoWeek",e)},isoWeekYear:function(e){return new Ir("isoWeekYear",e)},millisecond:function(e){return new Ir("millisecond",e)},minute:function(e){return new Ir("minute",e)},month:function(e){return new Ir("month",e)},second:function(e){return new Ir("second",e)},hour:function(e){return new Ir("hour",e)},week:function(e){return new Ir("week",e)},year:function(e){return new Ir("year",e)},literal:function(e){return new Ir("literal",e)},mergeObjects:function(e){return new Ir("mergeObjects",e)},objectToArray:function(e){return new Ir("objectToArray",e)},allElementsTrue:function(e){return new Ir("allElementsTrue",e)},anyElementTrue:function(e){return new Ir("anyElementTrue",e)},setDifference:function(e){return new Ir("setDifference",e)},setEquals:function(e){return new Ir("setEquals",e)},setIntersection:function(e){return new Ir("setIntersection",e)},setIsSubset:function(e){return new Ir("setIsSubset",e)},setUnion:function(e){return new Ir("setUnion",e)},concat:function(e){return new Ir("concat",e)},dateToString:function(e){return new Ir("dateToString",e)},indexOfBytes:function(e){return new Ir("indexOfBytes",e)},indexOfCP:function(e){return new Ir("indexOfCP",e)},split:function(e){return new Ir("split",e)},strLenBytes:function(e){return new Ir("strLenBytes",e)},strLenCP:function(e){return new Ir("strLenCP",e)},strcasecmp:function(e){return new Ir("strcasecmp",e)},substr:function(e){return new Ir("substr",e)},substrBytes:function(e){return new Ir("substrBytes",e)},substrCP:function(e){return new Ir("substrCP",e)},toLower:function(e){return new Ir("toLower",e)},toUpper:function(e){return new Ir("toUpper",e)},meta:function(e){return new Ir("meta",e)},addToSet:function(e){return new Ir("addToSet",e)},avg:function(e){return new Ir("avg",e)},first:function(e){return new Ir("first",e)},last:function(e){return new Ir("last",e)},max:function(e){return new Ir("max",e)},min:function(e){return new Ir("min",e)},push:function(e){return new Ir("push",e)},stdDevPop:function(e){return new Ir("stdDevPop",e)},stdDevSamp:function(e){return new Ir("stdDevSamp",e)},sum:function(e){return new Ir("sum",e)},let:function(e){return new Ir("let",e)}},project:{slice:function(e){return new Or("slice",e)},elemMatch:function(e){return new Or("elemMatch",e)}}},Ir=function(e,t){this["$"+e]=t},Or=function(e,t){this["$"+e]=t},Tr=function(){function e(e){var t=e.regexp,r=e.options;if(!t)throw new TypeError("regexp must be a string");this.$regex=t,this.$options=r}return e.prototype.parse=function(){return{$regex:this.$regex,$options:this.$options}},Object.defineProperty(e.prototype,"_internalType",{get:function(){return D},enumerable:!1,configurable:!0}),e}();function Ar(e){return new Tr(e)}var Rr="insert document failed",Pr="DATABASE_TRANSACTION_CONFLICT",Cr=function(){return Cr=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Cr.apply(this,arguments)},Nr=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},xr=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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])}}},Lr="database.updateDocInTransaction",Ur=function(){function e(e,t,r){this._coll=t,this.id=r,this._transaction=e,this._request=this._transaction.getRequestMethod(),this._transactionId=this._transaction.getTransactionId()}return e.prototype.create=function(e){return Nr(this,void 0,void 0,(function(){var t,r,n,o;return xr(this,(function(i){switch(i.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,data:vr.stringify(Se(e),{relaxed:!1})},this.id&&(t._id=this.id),[4,this._request.send("database.insertDocInTransaction",t)];case 1:if((r=i.sent()).code)throw r;if(n=vr.parse(r.inserted),1==(o=vr.parse(r.ok))&&1==n)return[2,Cr(Cr({},r),{ok:o,inserted:n})];throw new Error(Rr)}}))}))},e.prototype.get=function(){return Nr(this,void 0,void 0,(function(){var e,t;return xr(this,(function(r){switch(r.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.getInTransaction",e)];case 1:if((t=r.sent()).code)throw t;return[2,{data:"null"!==t.data?re.formatField(vr.parse(t.data)):vr.parse(t.data),requestId:t.requestId}]}}))}))},e.prototype.set=function(e){return Nr(this,void 0,void 0,(function(){var t,r;return xr(this,(function(n){switch(n.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:vr.stringify(Se(e),{relaxed:!1}),upsert:!0},[4,this._request.send(Lr,t)];case 1:if((r=n.sent()).code)throw r;return[2,Cr(Cr({},r),{updated:vr.parse(r.updated),upserted:r.upserted?JSON.parse(r.upserted):null})]}}))}))},e.prototype.update=function(e){return Nr(this,void 0,void 0,(function(){var t,r;return xr(this,(function(n){switch(n.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:vr.stringify(xe.encode(e),{relaxed:!1})},[4,this._request.send(Lr,t)];case 1:if((r=n.sent()).code)throw r;return[2,Cr(Cr({},r),{updated:vr.parse(r.updated)})]}}))}))},e.prototype.delete=function(){return Nr(this,void 0,void 0,(function(){var e,t;return xr(this,(function(r){switch(r.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.deleteDocInTransaction",e)];case 1:if((t=r.sent()).code)throw t;return[2,Cr(Cr({},t),{deleted:vr.parse(t.deleted)})]}}))}))},e}(),kr=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};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)}}(),Dr=function(e){function t(t,r){return e.call(this,t,r)||this}return kr(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return this._coll},enumerable:!1,configurable:!0}),t.prototype.doc=function(e){if("string"!=typeof e&&"number"!=typeof e)throw new Error("docId必须为字符串或数字");return new Ur(this._transaction,this._coll,e)},t.prototype.add=function(e){var t;return void 0!==e._id&&(t=e._id),new Ur(this._transaction,this._coll,t).create(e)},t}((function(e,t){this._coll=t,this._transaction=e})),jr=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},qr=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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])}}},Mr=function(){function e(e){this._db=e,this._request=Vr.createRequest(this._db.config),this.aborted=!1,this.commited=!1,this.inited=!1}return e.prototype.init=function(){return jr(this,void 0,void 0,(function(){var e;return qr(this,(function(t){switch(t.label){case 0:return[4,this._request.send("database.startTransaction")];case 1:if((e=t.sent()).code)throw e;return this.inited=!0,this._id=e.transactionId,[2]}}))}))},e.prototype.collection=function(e){if(!e)throw new Error("Collection name is required");return new Dr(this,e)},e.prototype.getTransactionId=function(){return this._id},e.prototype.getRequestMethod=function(){return this._request},e.prototype.commit=function(){return jr(this,void 0,void 0,(function(){var e,t;return qr(this,(function(r){switch(r.label){case 0:return e={transactionId:this._id},[4,this._request.send("database.commitTransaction",e)];case 1:if((t=r.sent()).code)throw t;return this.commited=!0,[2,t]}}))}))},e.prototype.rollback=function(e){return jr(this,void 0,void 0,(function(){var t,r;return qr(this,(function(n){switch(n.label){case 0:return t={transactionId:this._id},[4,this._request.send("database.abortTransaction",t)];case 1:if((r=n.sent()).code)throw r;return this.aborted=!0,this.abortReason=e,[2,r]}}))}))},e}();function Br(){return jr(this,void 0,void 0,(function(){var e;return qr(this,(function(t){switch(t.label){case 0:return[4,(e=new Mr(this)).init()];case 1:return t.sent(),[2,e]}}))}))}function Wr(e,t){return void 0===t&&(t=3),jr(this,void 0,void 0,(function(){var r,n,o,i,s=this;return qr(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,10]),[4,(r=new Mr(this)).init()];case 1:return a.sent(),[4,e(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(e){return jr(s,void 0,void 0,(function(){return qr(this,(function(t){switch(t.label){case 0:if(r.aborted||r.commited)return[3,5];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,r.rollback()];case 2:case 3:return t.sent(),[3,4];case 4:throw e;case 5:if(!0===r.aborted)throw r.abortReason;throw e}}))}))},t<=0?[4,i(o)]:[3,6];case 5:a.sent(),a.label=6;case 6:return o&&o.code===Pr?[4,Wr.bind(this)(e,--t)]:[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 Fr,Vr=function(){function e(e){this.config=e,this.Geo=i,this.serverDate=X,this.command=Er,this.RegExp=Ar,this.startTransaction=Br,this.runTransaction=Wr,this.logicCommand=ce,this.updateCommand=ae,this.queryCommand=he}return e.createRequest=function(t){var r=new e.reqClass(t),n=r.send;return r.send=function(e,r){return t.instance&&(r.instance=t.instance),t.database&&(r.database=t.database),n.call(this,e,r)},r},e.prototype.collection=function(e){if(!e)throw new Error("Collection name is required");return new Sr(this,e)},e.prototype.createCollection=function(t){var r={collectionName:t};return e.createRequest(this.config).send("database.addCollection",r)},e}(),Hr=(Fr=function(e,t){return Fr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},Fr(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}Fr(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),$r=function(){return $r=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},$r.apply(this,arguments)},Gr=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},zr=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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])}}},Kr={filterRes:function(e){return delete e.header,delete e.statusCode,e},flattenResData:function(e){if("object"==typeof e.data&&null!==e.data){var t=$r($r({},e),e.data);return delete t.data,t}return e},safeParseEJSON:function(e){if("string"!=typeof e)return e;try{return vr.parse(e)}catch(t){return e}},buildQueryParams:function(e){return Object.entries(e).filter((function(e){e[0];var t=e[1];return null!=t&&""!==t})).map((function(e){var t=e[0],r=e[1],n="object"==typeof r?JSON.stringify(r):String(r);return"".concat(encodeURIComponent(t),"=").concat(encodeURIComponent(n))})).join("&")},getUrlPrefix:function(e){var t=(null==e?void 0:e.instance)||"(default)",r=(null==e?void 0:e.database)||"(default)";return"/database/instances/".concat(t,"/databases/").concat(r)},"database.queryDocument":function(e){var t,r,n,o,i;return Gr(this,void 0,void 0,(function(){var s,a,u,c;return zr(this,(function(l){switch(l.label){case 0:return s=!!(null===(t=e.query)||void 0===t?void 0:t._id),a=Kr.buildQueryParams($r({projection:e.projection,transactionId:e.transactionId},s?{}:{offset:null!==(r=e.offset)&&void 0!==r?r:0,limit:null!==(n=e.limit)&&void 0!==n?n:100,order:e.order,query:e.query?vr.stringify(e.query,{relaxed:!1}):void 0})),u="".concat(Kr.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents?").concat(a),s&&(u="".concat(Kr.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents/").concat((null===(o=e.query._id)||void 0===o?void 0:o.$eq)||e.query._id,"?").concat(a)),[4,this.gateWay({url:u,method:"GET"})];case 1:return(c=l.sent()).data=Kr.safeParseEJSON(JSON.stringify(c.data)),!s||c.code||(null===(i=c.data)||void 0===i?void 0:i.code)?[2,Kr.filterRes(c)]:[2,$r($r({},c),{data:{list:[c.data]}})]}}))}))},"database.addDocument":function(e){var t,r;return Gr(this,void 0,void 0,(function(){var n;return zr(this,(function(o){switch(o.label){case 0:return[4,this.gateWay({url:"".concat(Kr.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents"),method:"POST",data:$r({data:Array.isArray(e.data)?e.data:[e.data]},e.transactionId&&{transactionId:e.transactionId})})];case 1:return n=o.sent(),!Array.isArray(e.data)&&(null===(r=null===(t=n.data)||void 0===t?void 0:t.insertedIds)||void 0===r?void 0:r[0])&&(n=$r($r({},n),{data:$r({_id:n.data.insertedIds[0]},n.data)})),[2,Kr.filterRes(n)]}}))}))},"database.updateDocument":function(e){return Gr(this,void 0,void 0,(function(){var t;return zr(this,(function(r){switch(r.label){case 0:return[4,this.gateWay({url:"".concat(Kr.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents"),method:"PATCH",data:$r({query:e.query,data:e.data,multi:!!e.multi,upsert:!!e.upsert,replaceMode:!!e.replaceMode},e.transactionId&&{transactionId:e.transactionId})})];case 1:return t=r.sent(),[2,Kr.filterRes(t)]}}))}))},"database.deleteDocument":function(e){return Gr(this,void 0,void 0,(function(){var t;return zr(this,(function(r){switch(r.label){case 0:return[4,this.gateWay({url:"".concat(Kr.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents/remove"),method:"POST",data:$r({query:e.query,multi:!!e.multi},e.transactionId&&{transactionId:e.transactionId})})];case 1:return t=r.sent(),[2,Kr.filterRes(t)]}}))}))},"database.countDocument":function(e){return Gr(this,void 0,void 0,(function(){var t,r;return zr(this,(function(n){switch(n.label){case 0:return t=Kr.buildQueryParams({count:!0,query:e.query?vr.stringify(e.query,{relaxed:!1}):void 0}),[4,this.gateWay({url:"".concat(Kr.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents?").concat(t),method:"GET"})];case 1:return r=n.sent(),[2,Kr.filterRes(r)]}}))}))},"database.addCollection":function(e){return Gr(this,void 0,void 0,(function(){var t;return zr(this,(function(r){switch(r.label){case 0:return[4,this.gateWay({url:"".concat(Kr.getUrlPrefix(e),"/collections"),method:"POST",data:{collectionName:e.collectionName}})];case 1:return t=r.sent(),[2,Kr.filterRes(t)]}}))}))},"database.aggregate":function(e){var t;return Gr(this,void 0,void 0,(function(){var r,n;return zr(this,(function(o){switch(o.label){case 0:return r=e.stages.map((function(e){var t,r;try{var n="string"==typeof e.stageValue?JSON.parse(e.stageValue):e.stageValue;return(t={})[e.stageKey]=vr.serialize(n),t}catch(t){return(r={})[e.stageKey]=e.stageValue,r}})),[4,this.gateWay({url:"".concat(Kr.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents/aggregations"),method:"POST",data:{pipeline:r}})];case 1:return n=o.sent(),Array.isArray(null===(t=n.data)||void 0===t?void 0:t.list)&&(n.data.list=JSON.stringify(n.data.list.map((function(e){return JSON.stringify(e)})))),[2,Kr.filterRes(n)]}}))}))},"database.startTransaction":function(e){return Gr(this,void 0,void 0,(function(){var t;return zr(this,(function(r){switch(r.label){case 0:return[4,this.gateWay({url:"".concat(Kr.getUrlPrefix(e),"/transactions"),method:"POST"})];case 1:return t=r.sent(),[2,Kr.filterRes(Kr.flattenResData(t))]}}))}))},"database.commitTransaction":function(e){return Gr(this,void 0,void 0,(function(){var t;return zr(this,(function(r){switch(r.label){case 0:return[4,this.gateWay({url:"".concat(Kr.getUrlPrefix(e),"/transactions/").concat(e.transactionId,"/commit"),method:"POST"})];case 1:return t=r.sent(),[2,Kr.filterRes(t)]}}))}))},"database.abortTransaction":function(e){return Gr(this,void 0,void 0,(function(){var t;return zr(this,(function(r){switch(r.label){case 0:return[4,this.gateWay({url:"".concat(Kr.getUrlPrefix(e),"/transactions/").concat(e.transactionId,"/rollback"),method:"POST"})];case 1:return t=r.sent(),[2,Kr.filterRes(t)]}}))}))},"database.getInTransaction":function(e){var t;return Gr(this,void 0,void 0,(function(){var r;return zr(this,(function(n){switch(n.label){case 0:return[4,Kr["database.queryDocument"].call(this,e)];case 1:return"object"==typeof(r=n.sent()).data&&null!==r.data?(null===(t=r.data)||void 0===t?void 0:t.code)?[2,Kr.flattenResData(r)]:[2,$r($r({},r),{data:JSON.stringify(r.data)})]:[2,r]}}))}))},"database.updateDocInTransaction":function(e){return Gr(this,void 0,void 0,(function(){var t;return zr(this,(function(r){switch(r.label){case 0:return e.data=Kr.safeParseEJSON(e.data),[4,Kr["database.updateDocument"].call(this,e)];case 1:return t=r.sent(),[2,Kr.flattenResData(t)]}}))}))},"database.deleteDocInTransaction":function(e){return Gr(this,void 0,void 0,(function(){var t;return zr(this,(function(r){switch(r.label){case 0:return[4,Kr["database.deleteDocument"].call(this,e)];case 1:return t=r.sent(),[2,Kr.flattenResData(t)]}}))}))},"database.insertDocInTransaction":function(e){var t;return Gr(this,void 0,void 0,(function(){var r,n;return zr(this,(function(o){switch(o.label){case 0:return e.data=Kr.safeParseEJSON(e.data),[4,Kr["database.addDocument"].call(this,e)];case 1:return"object"==typeof(r=o.sent()).data&&null!==r.data?(n=!!(null===(t=r.data)||void 0===t?void 0:t._id),r=$r($r($r({},r),{inserted:n?1:0,ok:n?1:0}),r.data)):r=$r({inserted:0,ok:0},r),delete r.data,[2,r]}}))}))},"database.runCommands":function(e){return Gr(this,void 0,void 0,(function(){var t;return zr(this,(function(r){switch(r.label){case 0:return[4,this.gateWay({url:"".concat(Kr.getUrlPrefix(e),"/commands"),method:"POST",data:$r({commands:vr.serialize(e.commands)},e.transactionId&&{transactionId:e.transactionId})})];case 1:"object"==typeof(t=r.sent()).data&&null!==t.data&&(delete(t=$r($r({},t),t.data)).data,delete t.request_id);try{t=vr.deserialize(t)}catch(e){}return[2,Kr.filterRes(t)]}}))}))}},Jr={name:"database",entity:{database:function(e){var t=this.platform,r=t.adapter,n=t.runtime,o=function(e){function t(t){return e.call(this,t)||this}return Hr(t,e),t.prototype.send=function(t,r){return Gr(this,void 0,void 0,(function(){var n;return zr(this,(function(o){switch(o.label){case 0:return n=null,"GATEWAY"===this.config.endPointMode&&Kr[t]?[4,Kr[t].call(this,r)]:[3,2];case 1:return n=o.sent(),[3,4];case 2:return[4,e.prototype.send.call(this,t,r)];case 3:n=o.sent(),o.label=4;case 4:return[2,n]}}))}))},t}(this.request.constructor);return Vr.reqClass=o,Vr.getAccessToken=this.authInstance?this.authInstance.getAccessToken.bind(this.authInstance):function(){return""},Vr.runtime=n,this.wsClientClass&&(Vr.wsClass=r.wsClass,Vr.wsClientClass=this.wsClientClass),Vr.ws||(Vr.ws=null),new(function(e){function t(t){return e.call(this,t)||this}return Hr(t,e),t.prototype.runCommands=function(e){return Gr(this,void 0,void 0,(function(){return zr(this,(function(t){return[2,Vr.createRequest(this.config).send("database.runCommands",e)]}))}))},t}(Vr))($r($r($r({},this.config),{_fromApp:this}),e))}}};try{cloudbase.registerComponent(Jr)}catch(e){}function Yr(e){try{e.registerComponent(Jr)}catch(e){console.warn(e)}}try{window.registerDatabase=Yr}catch(e){}},7596:function(e,t,r){"use strict";r.r(t),r.d(t,{registerCloudrun:function(){return d},requestContainer:function(){return c}});var n=r(3616),o=function(){return o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},o.apply(this,arguments)},i=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},s=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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(e,t){var r;return i(this,void 0,void 0,(function(){var n,i,a,u,c,l,f,d,h,p,v,y,m,g,b;return s(this,(function(s){switch(s.label){case 0:if(n=e.name,i=e.data,a=e.path,u=void 0===a?"":a,c=e.method,l=e.header,f=void 0===l?{}:l,d=this.getEndPointWithKey("GATEWAY"),h=d.BASE_URL,p=d.PROTOCOL,v="".concat(p).concat(h,"/cloudrun/").concat(n),y=u.startsWith("/")?u:"/".concat(u),m=["GET","HEAD"].includes(null===(r=null==c?void 0:c.toUpperCase)||void 0===r?void 0:r.call(c)))try{g={};try{g=JSON.parse(i)}catch(e){g=i||{}}y="".concat(y).concat(y.includes("?")?"&":"?").concat(Object.keys(g).map((function(e){return"".concat(e,"=").concat(g[e])})).join("&"))}catch(e){}return[4,this.request.fetch(o(o({method:c||"POST",headers:Object.assign({},{"Content-Type":"application/json; charset=utf-8"},f)},m?{}:{body:i}),{url:"".concat(v).concat(y),customReqOpts:t}))];case 1:return b=s.sent(),"node-sdk"===(null==t?void 0:t.from)?[2,b]:[4,b.data];case 2:return[2,s.sent()]}}))}))}var l=new(function(){function e(){}return e.prototype.callContainer=function(e,t){return i(this,void 0,void 0,(function(){var r,n,i;return s(this,(function(s){switch(s.label){case 0:if(r=e.name,n=e.data,!r)throw new Error(JSON.stringify({code:a.INVALID_PARAMS,msg:"[".concat(u,".callContainer] invalid name")}));try{i=n?JSON.stringify(n):""}catch(e){throw new Error(JSON.stringify({code:a.INVALID_PARAMS,msg:"[".concat(u,".callContainer] invalid data")}))}return[4,c.call(this,o(o({},e),{data:i}),t)];case 1:return[2,s.sent()]}}))}))},e}()),f={name:u,entity:{callContainer:l.callContainer}};try{cloudbase.registerComponent(f)}catch(e){}function d(e){try{e.registerComponent(f)}catch(e){console.warn(e)}}try{window.registerCloudrun=d}catch(e){}},2363:function(e,t,r){"use strict";r.r(t),r.d(t,{registerFunctions:function(){return v}});var n=r(3616),o=r(7596),i=function(){return i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)},s=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},a=n._G.eX,u=n._G.Sg,c=n._G.vM,l=n.P6.execCallback,f=n.BM.D,d="functions",h=new(function(){function e(){}return e.prototype.callFunction=function(e,t,r){var s,c,f,h,p,v,y;return h=this,p=void 0,y=function(){var h,p,v,y,m,g,b,w,_,S,E,I,O,T,A,R,P,C,N,x,L,U;return function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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(k){switch(k.label){case 0:if(h=e.name,p=e.data,v=e.query,y=e.parse,m=e.search,g=e.type,b=e.path,w=void 0===b?"":b,_=e.method,S=e.header,E=void 0===S?{}:S,!h)throw new Error(JSON.stringify({code:u.INVALID_PARAMS,msg:"[".concat(d,".callFunction] invalid function name")}));try{I=p?JSON.stringify(p):""}catch(e){throw new Error(JSON.stringify({code:u.INVALID_PARAMS,msg:"[".concat(d,".callFunction] invalid data")}))}return"cloudrun"!==g?[3,2]:(O=n.P6.generateRequestId(),[4,o.requestContainer.call(this,{name:h,data:I,path:w,method:_,header:i(i({},E),{"X-Request-Id":O})})]);case 1:return[2,{result:L=k.sent(),requestId:O}];case 2:A=(T=this).request,R=T.config,P="functions.invokeFunction",C={inQuery:v,parse:y,search:m,function_name:h,request_data:I},N={},k.label=3;case 3:return k.trys.push([3,8,,9]),"GATEWAY"!==R.endPointMode?[3,5]:[4,A.gateWay(i(i({},e),{path:"functions"}),r)];case 4:return x=k.sent(),N=i({requestId:x.requestId},(null===(s=x.data)||void 0===s?void 0:s.code)?x.data:{data:{response_data:x.data}}),[3,7];case 5:return[4,A.send(P,C,{defaultQuery:(null===(c=null==p?void 0:p.params)||void 0===c?void 0:c.action)?{action:null===(f=null==p?void 0:p.params)||void 0===f?void 0:f.action}:{}},r)];case 6:N=k.sent(),k.label=7;case 7:if(N.code)return[2,l(t,null,N)];if(L=N.data.response_data,y||"GATEWAY"===R.endPointMode)return[2,l(t,null,{result:L,requestId:N.requestId})];try{return L=JSON.parse(N.data.response_data),[2,l(t,null,{result:L,requestId:N.requestId})]}catch(e){l(t,new Error("[".concat(a(),"][").concat(u.INVALID_PARAMS,"][").concat(d,".callFunction] response data must be json")))}return[3,9];case 8:return U=k.sent(),l(t,U),[3,9];case 9:return[2]}}))},new((v=void 0)||(v=Promise))((function(e,t){function r(e){try{o(y.next(e))}catch(e){t(e)}}function n(e){try{o(y.throw(e))}catch(e){t(e)}}function o(t){var o;t.done?e(t.value):(o=t.value,o instanceof v?o:new v((function(e){e(o)}))).then(r,n)}o((y=y.apply(h,p||[])).next())}))},function(e,t,r,n){var o,i=arguments.length,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);i>3&&s&&Object.defineProperty(t,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,Object]),s("design:returntype",Promise)],e.prototype,"callFunction",null),e}()),p={name:d,entity:{callFunction:h.callFunction}};try{cloudbase.registerComponent(p)}catch(e){}function v(e){try{e.registerComponent(p)}catch(e){console.warn(e)}}},9679:function(e,t,r){"use strict";r.r(t),r.d(t,{lazyGetEntity:function(){return h},registerModel:function(){return m}});var n=r(5304),o=r(3616),i={};for(var s in n)["default","lazyGetEntity","registerModel"].indexOf(s)<0&&(i[s]=function(e){return n[e]}.bind(0,s));r.d(t,i);var a=function(){return a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},a.apply(this,arguments)},u=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},c=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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",d=new WeakMap;function h(e){return new Proxy({},{get:function(t,r){var o=e.getEndPointWithKey("GATEWAY"),i=o.BASE_URL,s=o.PROTOCOL,l=a(a({},e),{BASE_URL:i,PROTOCOL:s}),f=d.get(l);return f||(f=function(e){var t=this,r=e.callFunction.bind(e),o=e.request.fetch.bind(e.request),i=e.getEndPointWithKey("GATEWAY"),s=i.BASE_URL,l=i.PROTOCOL,f="".concat(l).concat(s,"/model"),d="".concat(l).concat(s,"/sql"),h=(0,n.generateHTTPClient)(r,(function(e){return u(t,void 0,void 0,(function(){return c(this,(function(t){switch(t.label){case 0:return[4,o(a(a({},e),{headers:a({"Content-Type":"application/json"},e.headers)}))];case 1:return[4,t.sent().data];case 2:return[2,t.sent()]}}))}))}),f,{sqlBaseUrl:d});return h}(e),d.set(l,f)),f[r]}})}var p="cloudbase_init",v=new l;v.on(p,(function(e){var t=e.data;Object.assign(t,{models:h(t)})}));var y={name:f,namespace:f,entity:new Proxy({},{get:function(e,t){console.warn("【deprecated】Accessing Cloudbase.prototype.models.".concat(t,"."))}}),injectEvents:{bus:v,events:[p]}};try{cloudbase.registerComponent(y)}catch(e){}function m(e){try{e.registerComponent(y)}catch(e){console.warn(e)}}try{window.registerModel=m}catch(e){}},2840:function(e,t,r){"use strict";r.r(t),r.d(t,{registerMySQL:function(){return l}});var n=r(5090),o={};for(var i in n)["default","registerMySQL"].indexOf(i)<0&&(o[i]=function(e){return n[e]}.bind(0,i));r.d(t,o);var s=function(){return s=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},s.apply(this,arguments)};function a(e,t){var r=this,o=e.request.fetch.bind(e.request),i=t||{},a=i.instance,u=void 0===a?"default":a,c=i.database,l=void 0===c?e.config.env:c,f=e.getEndPointWithKey("GATEWAY"),d=f.BASE_URL,h=f.PROTOCOL,p="".concat(h).concat(d,"/rdb/rest"),v=(0,n.generateMySQLClient)(e,{mysqlBaseUrl:p,fetch:function(e,t){return n=r,i=void 0,c=function(){var r,n,i,a;return function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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(c){switch(c.label){case 0:return r={},t.headers instanceof Headers?t.headers.forEach((function(e,t){r[t]=e})):r=t.headers||{},[4,o(s(s({url:e.toString()},t),{headers:s({"Content-Type":"application/json","X-Db-Instance":u,"Accept-Profile":l,"Content-Profile":l},r),shouldThrowOnError:!1}))];case 1:n=c.sent(),i={},c.label=2;case 2:return c.trys.push([2,4,,5]),[4,n.data];case 3:return i=c.sent(),[3,5];case 4:if(!(a=c.sent()).message.includes("Unexpected end of JSON input"))throw a;return[3,5];case 5:return[2,{ok:(null==n?void 0:n.statusCode)>=200&&(null==n?void 0:n.statusCode)<300,status:(null==n?void 0:n.statusCode)||200,statusText:(null==n?void 0:n.statusMessage)||"OK",json:function(){return Promise.resolve(i||{})},text:function(){return Promise.resolve("string"==typeof i?i:JSON.stringify(i||{}))},headers:null==n?void 0:n.header}]}}))},new((a=void 0)||(a=Promise))((function(e,t){function r(e){try{s(c.next(e))}catch(e){t(e)}}function o(e){try{s(c.throw(e))}catch(e){t(e)}}function s(t){var n;t.done?e(t.value):(n=t.value,n instanceof a?n:new a((function(e){e(n)}))).then(r,o)}s((c=c.apply(n,i||[])).next())}));var n,i,a,c}});return v}var u={name:"mysql",entity:{mysql:function(e){return a(this,e)(e)}}},c={name:"rdb",entity:{rdb:function(e){return a(this,e)(e)}}};try{cloudbase.registerComponent(u),cloudbase.registerComponent(c)}catch(e){}function l(e){try{e.registerComponent(u),e.registerComponent(c)}catch(e){console.warn(e)}}try{window.registerMySQL=l}catch(e){}},7171:function(e,t,r){"use strict";var n;if(r.r(t),r.d(t,{getEncryptInfo:function(){return M}}),!globalThis.IS_MP_BUILD){var o="undefined"!=typeof globalThis?globalThis.navigator:window.globalThis,i="0123456789abcdefghijklmnopqrstuvwxyz";function B(e){return i.charAt(e)}function W(e,t){return e&t}function F(e,t){return e|t}function V(e,t){return e^t}function H(e,t){return e&~t}function $(e){if(0==e)return-1;var t=0;return 65535&e||(e>>=16,t+=16),255&e||(e>>=8,t+=8),15&e||(e>>=4,t+=4),3&e||(e>>=2,t+=2),1&e||++t,t}function G(e){for(var t=0;0!=e;)e&=e-1,++t;return t}var s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function z(e){var t,r,n="";for(t=0;t+3<=e.length;t+=3)r=parseInt(e.substring(t,t+3),16),n+=s.charAt(r>>6)+s.charAt(63&r);for(t+1==e.length?(r=parseInt(e.substring(t,t+1),16),n+=s.charAt(r<<2)):t+2==e.length&&(r=parseInt(e.substring(t,t+2),16),n+=s.charAt(r>>2)+s.charAt((3&r)<<4));(3&n.length)>0;)n+="=";return n}function K(e){var t,r="",n=0,o=0;for(t=0;t<e.length&&"="!=e.charAt(t);++t){var i=s.indexOf(e.charAt(t));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(e){var t;if(void 0===a){var r="0123456789ABCDEF";for(a={},t=0;t<16;++t)a[r.charAt(t)]=t;for(r=r.toLowerCase(),t=10;t<16;++t)a[r.charAt(t)]=t;for(t=0;t<8;++t)a[" \f\n\r\t \u2028\u2029".charAt(t)]=-1}var n=[],o=0,i=0;for(t=0;t<e.length;++t){var s=e.charAt(t);if("="==s)break;if(-1!=(s=a[s])){if(void 0===s)throw new Error("Illegal character at offset "+t);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(e){var t;if(void 0===u){for(u=Object.create(null),t=0;t<64;++t)u["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(t)]=t;for(t=0;t<9;++t)u["= \f\n\r\t \u2028\u2029".charAt(t)]=-1}var r=[],n=0,o=0;for(t=0;t<e.length;++t){var i=e.charAt(t);if("="==i)break;if(-1!=(i=u[i])){if(void 0===i)throw new Error("Illegal character at offset "+t);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(e){var t=l.re.exec(e);if(t)if(t[1])e=t[1];else{if(!t[2])throw new Error("RegExp out of sync");e=t[2]}return l.decode(e)}},f=1e13;class J{constructor(e){this.buf=[+e||0]}mulAdd(e,t){var r,n,o=this.buf,i=o.length;for(r=0;r<i;++r)(n=o[r]*e+t)<f?t=0:n-=(t=0|n/f)*f,o[r]=n;t>0&&(o[r]=t)}sub(e){var t,r,n=this.buf,o=n.length;for(t=0;t<o;++t)(r=n[t]-e)<0?(r+=f,e=1):e=0,n[t]=r;for(;0===n[n.length-1];)n.pop()}toString(e){if(10!=(e||10))throw new Error("only base 10 is supported");for(var t=this.buf,r=t[t.length-1].toString(),n=t.length-2;n>=0;--n)r+=(f+t[n]).toString().substring(1);return r}valueOf(){for(var e=this.buf,t=0,r=e.length-1;r>=0;--r)t=t*f+e[r];return t}simplify(){var e=this.buf;return 1==e.length?e[0]:this}}var d,h=/^(\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(e,t){return e.length>t&&(e=e.substring(0,t)+"…"),e}class Q{constructor(e,t){this.hexDigits="0123456789ABCDEF",e instanceof Q?(this.enc=e.enc,this.pos=e.pos):(this.enc=e,this.pos=t)}get(e){if(void 0===e&&(e=this.pos++),e>=this.enc.length)throw new Error("Requesting byte offset "+e+" on a stream of length "+this.enc.length);return"string"==typeof this.enc?this.enc.charCodeAt(e):this.enc[e]}hexByte(e){return this.hexDigits.charAt(e>>4&15)+this.hexDigits.charAt(15&e)}hexDump(e,t,r){for(var n="",o=e;o<t;++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(e,t){for(var r=e;r<t;++r){var n=this.get(r);if(n<32||n>176)return!1}return!0}parseStringISO(e,t){for(var r="",n=e;n<t;++n)r+=String.fromCharCode(this.get(n));return r}parseStringUTF(e,t){for(var r="",n=e;n<t;){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(e,t){for(var r,n,o="",i=e;i<t;)r=this.get(i++),n=this.get(i++),o+=String.fromCharCode(r<<8|n);return o}parseTime(e,t,r){var n=this.parseStringISO(e,t),o=(r?h: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(e,t){for(var r,n=this.get(e),o=n>127,i=o?255:0,s="";n==i&&++e<t;)n=this.get(e);if(0==(r=t-e))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=e+1;u<t;++u)a.mulAdd(256,this.get(u));return s+a.toString()}parseBitString(e,t,r){for(var n=this.get(e),o="("+((t-e-1<<3)-n)+" bit)\n",i="",s=e+1;s<t;++s){for(var a=this.get(s),u=s==t-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(e,t,r){if(this.isASCII(e,t))return Y(this.parseStringISO(e,t),r);var n=t-e,o="("+n+" byte)\n";n>(r/=2)&&(t=e+r);for(var i=e;i<t;++i)o+=this.hexByte(this.get(i));return n>r&&(o+="…"),o}parseOID(e,t,r){for(var n="",o=new J,i=0,s=e;s<t;++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(e,t,r,n,o){if(!(n instanceof X))throw new Error("Invalid tag value.");this.stream=e,this.header=t,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(e){if(void 0===this.tag)return null;void 0===e&&(e=1/0);var t=this.posContent(),r=Math.abs(this.length);if(!this.tag.isUniversal())return null!==this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(t,t+r,e);switch(this.tag.tagNumber){case 1:return 0===this.stream.get(t)?"false":"true";case 2:return this.stream.parseInteger(t,t+r);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(t,t+r,e);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(t,t+r,e);case 6:return this.stream.parseOID(t,t+r,e);case 16:case 17:return null!==this.sub?"("+this.sub.length+" elem)":"(no elem)";case 12:return Y(this.stream.parseStringUTF(t,t+r),e);case 18:case 19:case 20:case 21:case 22:case 26:return Y(this.stream.parseStringISO(t,t+r),e);case 30:return Y(this.stream.parseStringBMP(t,t+r),e);case 23:case 24:return this.stream.parseTime(t,t+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(e){void 0===e&&(e="");var t=e+this.typeName()+" @"+this.stream.pos;if(this.length>=0&&(t+="+"),t+=this.length,this.tag.tagConstructed?t+=" (constructed)":!this.tag.isUniversal()||3!=this.tag.tagNumber&&4!=this.tag.tagNumber||null===this.sub||(t+=" (encapsulates)"),t+="\n",null!==this.sub){e+=" ";for(var r=0,n=this.sub.length;r<n;++r)t+=this.sub[r].toPrettyString(e)}return t}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(e){var t=e.get(),r=127&t;if(r==t)return r;if(r>6)throw new Error("Length over 48 bits not supported at position "+(e.pos-1));if(0===r)return null;t=0;for(var n=0;n<r;++n)t=256*t+e.get();return t}getHexStringValue(){var e=this.toHexString(),t=2*this.header,r=2*this.length;return e.substr(t,r)}static decode(e){var t;t=e instanceof Q?e:new Q(e,0);var r=new Q(t),n=new X(t),o=Z.decodeLength(t),i=t.pos,s=i-r.pos,a=null,u=function(){var e=[];if(null!==o){for(var r=i+o;t.pos<r;)e[e.length]=Z.decode(t);if(t.pos!=r)throw new Error("Content size is not correct for container starting at offset "+i)}else try{for(;;){var n=Z.decode(t);if(n.tag.isEOC())break;e[e.length]=n}o=i-t.pos}catch(e){throw new Error("Exception while decoding undefined length content: "+e)}return e};if(n.tagConstructed)a=u();else if(n.isUniversal()&&(3==n.tagNumber||4==n.tagNumber))try{if(3==n.tagNumber&&0!=t.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(e){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);t.pos=i+Math.abs(o)}return new Z(r,s,o,n,a)}}class X{constructor(e){var t=e.get();if(this.tagClass=t>>6,this.tagConstructed=!!(32&t),this.tagNumber=31&t,31==this.tagNumber){var r=new J;do{t=e.get(),r.mulAdd(128,127&t)}while(128&t);this.tagNumber=r.simplify()}}isUniversal(){return 0===this.tagClass}isEOC(){return 0===this.tagClass&&0===this.tagNumber}}var v=[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],y=(1<<26)/v[v.length-1];class ee{constructor(e,t,r){null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}toString(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,n=(1<<t)-1,o=!1,i="",s=this.t,a=this.DB-s*this.DB%t;if(s-- >0)for(a<this.DB&&(r=this[s]>>a)>0&&(o=!0,i=B(r));s>=0;)a<t?(r=(this[s]&(1<<a)-1)<<t-a,r|=this[--s]>>(a+=this.DB-t)):(r=this[s]>>(a-=t)&n,a<=0&&(a+=this.DB,--s)),r>0&&(o=!0),o&&(i+=B(r));return o?i:"0"}negate(){var e=te();return ee.ZERO.subTo(this,e),e}abs(){return this.s<0?this.negate():this}compareTo(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this[r]-e[r]))return t;return 0}bitLength(){return this.t<=0?0:this.DB*(this.t-1)+ue(this[this.t-1]^this.s&this.DM)}mod(e){var t=te();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(ee.ZERO)>0&&e.subTo(t,t),t}modPowInt(e,t){var r;return r=e<256||t.isEven()?new g(t):new b(t),this.exp(e,r)}clone(){var e=te();return this.copyTo(e),e}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 e=this.t,t=[];t[0]=this.s;var r,n=this.DB-e*this.DB%8,o=0;if(e-- >0)for(n<this.DB&&(r=this[e]>>n)!=(this.s&this.DM)>>n&&(t[o++]=r|this.s<<this.DB-n);e>=0;)n<8?(r=(this[e]&(1<<n)-1)<<8-n,r|=this[--e]>>(n+=this.DB-8)):(r=this[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),128&r&&(r|=-256),0==o&&(128&this.s)!=(128&r)&&++o,(o>0||r!=this.s)&&(t[o++]=r);return t}equals(e){return 0==this.compareTo(e)}min(e){return this.compareTo(e)<0?this:e}max(e){return this.compareTo(e)>0?this:e}and(e){var t=te();return this.bitwiseTo(e,W,t),t}or(e){var t=te();return this.bitwiseTo(e,F,t),t}xor(e){var t=te();return this.bitwiseTo(e,V,t),t}andNot(e){var t=te();return this.bitwiseTo(e,H,t),t}not(){for(var e=te(),t=0;t<this.t;++t)e[t]=this.DM&~this[t];return e.t=this.t,e.s=~this.s,e}shiftLeft(e){var t=te();return e<0?this.rShiftTo(-e,t):this.lShiftTo(e,t),t}shiftRight(e){var t=te();return e<0?this.lShiftTo(-e,t):this.rShiftTo(e,t),t}getLowestSetBit(){for(var e=0;e<this.t;++e)if(0!=this[e])return e*this.DB+$(this[e]);return this.s<0?this.t*this.DB:-1}bitCount(){for(var e=0,t=this.s&this.DM,r=0;r<this.t;++r)e+=G(this[r]^t);return e}testBit(e){var t=Math.floor(e/this.DB);return t>=this.t?0!=this.s:!!(this[t]&1<<e%this.DB)}setBit(e){return this.changeBit(e,F)}clearBit(e){return this.changeBit(e,H)}flipBit(e){return this.changeBit(e,V)}add(e){var t=te();return this.addTo(e,t),t}subtract(e){var t=te();return this.subTo(e,t),t}multiply(e){var t=te();return this.multiplyTo(e,t),t}divide(e){var t=te();return this.divRemTo(e,t,null),t}remainder(e){var t=te();return this.divRemTo(e,null,t),t}divideAndRemainder(e){var t=te(),r=te();return this.divRemTo(e,t,r),[t,r]}modPow(e,t){var r,n,o=e.bitLength(),i=ae(1);if(o<=0)return i;r=o<18?1:o<48?3:o<144?4:o<768?5:6,n=o<8?new g(t):t.isEven()?new w(t):new b(t);var s=[],a=3,u=r-1,c=(1<<r)-1;if(s[1]=n.convert(this),r>1){var l=te();for(n.sqrTo(s[1],l);a<=c;)s[a]=te(),n.mulTo(l,s[a-2],s[a]),a+=2}var f,d,h=e.t-1,p=!0,v=te();for(o=ue(e[h])-1;h>=0;){for(o>=u?f=e[h]>>o-u&c:(f=(e[h]&(1<<o+1)-1)<<u-o,h>0&&(f|=e[h-1]>>this.DB+o-u)),a=r;!(1&f);)f>>=1,--a;if((o-=a)<0&&(o+=this.DB,--h),p)s[f].copyTo(i),p=!1;else{for(;a>1;)n.sqrTo(i,v),n.sqrTo(v,i),a-=2;a>0?n.sqrTo(i,v):(d=i,i=v,v=d),n.mulTo(v,s[f],i)}for(;h>=0&&!(e[h]&1<<o);)n.sqrTo(i,v),d=i,i=v,v=d,--o<0&&(o=this.DB-1,--h)}return n.revert(i)}modInverse(e){var t=e.isEven();if(this.isEven()&&t||0==e.signum())return ee.ZERO;for(var r=e.clone(),n=this.clone(),o=ae(1),i=ae(0),s=ae(0),a=ae(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),t?(o.isEven()&&i.isEven()||(o.addTo(this,o),i.subTo(e,i)),o.rShiftTo(1,o)):i.isEven()||i.subTo(e,i),i.rShiftTo(1,i);for(;n.isEven();)n.rShiftTo(1,n),t?(s.isEven()&&a.isEven()||(s.addTo(this,s),a.subTo(e,a)),s.rShiftTo(1,s)):a.isEven()||a.subTo(e,a),a.rShiftTo(1,a);r.compareTo(n)>=0?(r.subTo(n,r),t&&o.subTo(s,o),i.subTo(a,i)):(n.subTo(r,n),t&&s.subTo(o,s),a.subTo(i,a))}return 0!=n.compareTo(ee.ONE)?ee.ZERO:a.compareTo(e)>=0?a.subtract(e):a.signum()<0?(a.addTo(e,a),a.signum()<0?a.add(e):a):a}pow(e){return this.exp(e,new m)}gcd(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var n=t;t=r,r=n}var o=t.getLowestSetBit(),i=r.getLowestSetBit();if(i<0)return t;for(o<i&&(i=o),i>0&&(t.rShiftTo(i,t),r.rShiftTo(i,r));t.signum()>0;)(o=t.getLowestSetBit())>0&&t.rShiftTo(o,t),(o=r.getLowestSetBit())>0&&r.rShiftTo(o,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return i>0&&r.lShiftTo(i,r),r}isProbablePrime(e){var t,r=this.abs();if(1==r.t&&r[0]<=v[v.length-1]){for(t=0;t<v.length;++t)if(r[0]==v[t])return!0;return!1}if(r.isEven())return!1;for(t=1;t<v.length;){for(var n=v[t],o=t+1;o<v.length&&n<y;)n*=v[o++];for(n=r.modInt(n);t<o;)if(n%v[t++]==0)return!1}return r.millerRabin(e)}copyTo(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s}fromInt(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+this.DV:this.t=0}fromString(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return void this.fromRadix(e,t);r=2}this.t=0,this.s=0;for(var n=e.length,o=!1,i=0;--n>=0;){var s=8==r?255&+e[n]:se(e,n);s<0?"-"==e.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&+e[0]&&(this.s=-1,i>0&&(this[this.t-1]|=(1<<this.DB-i)-1<<i)),this.clamp(),o&&ee.ZERO.subTo(this,this)}clamp(){for(var e=this.s&this.DM;this.t>0&&this[this.t-1]==e;)--this.t}dlShiftTo(e,t){var r;for(r=this.t-1;r>=0;--r)t[r+e]=this[r];for(r=e-1;r>=0;--r)t[r]=0;t.t=this.t+e,t.s=this.s}drShiftTo(e,t){for(var r=e;r<this.t;++r)t[r-e]=this[r];t.t=Math.max(this.t-e,0),t.s=this.s}lShiftTo(e,t){for(var r=e%this.DB,n=this.DB-r,o=(1<<n)-1,i=Math.floor(e/this.DB),s=this.s<<r&this.DM,a=this.t-1;a>=0;--a)t[a+i+1]=this[a]>>n|s,s=(this[a]&o)<<r;for(a=i-1;a>=0;--a)t[a]=0;t[i]=s,t.t=this.t+i+1,t.s=this.s,t.clamp()}rShiftTo(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var n=e%this.DB,o=this.DB-n,i=(1<<n)-1;t[0]=this[r]>>n;for(var s=r+1;s<this.t;++s)t[s-r-1]|=(this[s]&i)<<o,t[s-r]=this[s]>>n;n>0&&(t[this.t-r-1]|=(this.s&i)<<o),t.t=this.t-r,t.clamp()}}subTo(e,t){for(var r=0,n=0,o=Math.min(e.t,this.t);r<o;)n+=this[r]-e[r],t[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n-=e.s;r<this.t;)n+=this[r],t[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n-=e[r],t[r++]=n&this.DM,n>>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t[r++]=this.DV+n:n>0&&(t[r++]=n),t.t=r,t.clamp()}multiplyTo(e,t){var r=this.abs(),n=e.abs(),o=r.t;for(t.t=o+n.t;--o>=0;)t[o]=0;for(o=0;o<n.t;++o)t[o+r.t]=r.am(0,n[o],t,o,0,r.t);t.s=0,t.clamp(),this.s!=e.s&&ee.ZERO.subTo(t,t)}squareTo(e){for(var t=this.abs(),r=e.t=2*t.t;--r>=0;)e[r]=0;for(r=0;r<t.t-1;++r){var n=t.am(r,t[r],e,2*r,0,1);(e[r+t.t]+=t.am(r+1,2*t[r],e,2*r+1,n,t.t-r-1))>=t.DV&&(e[r+t.t]-=t.DV,e[r+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(r,t[r],e,2*r,0,1)),e.s=0,e.clamp()}divRemTo(e,t,r){var n=e.abs();if(!(n.t<=0)){var o=this.abs();if(o.t<n.t)return null!=t&&t.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=te());var i=te(),s=this.s,a=e.s,u=this.DB-ue(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),d=this.FV/f,h=(1<<this.F1)/f,p=1<<this.F2,v=r.t,y=v-c,m=null==t?te():t;for(i.dlShiftTo(y,m),r.compareTo(m)>=0&&(r[r.t++]=1,r.subTo(m,r)),ee.ONE.dlShiftTo(c,m),m.subTo(i,i);i.t<c;)i[i.t++]=0;for(;--y>=0;){var g=r[--v]==l?this.DM:Math.floor(r[v]*d+(r[v-1]+p)*h);if((r[v]+=i.am(0,g,r,y,0,c))<g)for(i.dlShiftTo(y,m),r.subTo(m,r);r[v]<--g;)r.subTo(m,r)}null!=t&&(r.drShiftTo(c,t),s!=a&&ee.ZERO.subTo(t,t)),r.t=c,r.clamp(),u>0&&r.rShiftTo(u,r),s<0&&ee.ZERO.subTo(r,r)}}}invDigit(){if(this.t<1)return 0;var e=this[0];if(!(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t}isEven(){return 0==(this.t>0?1&this[0]:this.s)}exp(e,t){if(e>4294967295||e<1)return ee.ONE;var r=te(),n=te(),o=t.convert(this),i=ue(e)-1;for(o.copyTo(r);--i>=0;)if(t.sqrTo(r,n),(e&1<<i)>0)t.mulTo(n,o,r);else{var s=r;r=n,n=s}return t.revert(r)}chunkSize(e){return Math.floor(Math.LN2*this.DB/Math.log(e))}toRadix(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),n=ae(r),o=te(),i=te(),s="";for(this.divRemTo(n,o,i);o.signum()>0;)s=(r+i.intValue()).toString(e).substr(1)+s,o.divRemTo(n,o,i);return i.intValue().toString(e)+s}fromRadix(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),o=!1,i=0,s=0,a=0;a<e.length;++a){var u=se(e,a);u<0?"-"==e.charAt(a)&&0==this.signum()&&(o=!0):(s=t*s+u,++i>=r&&(this.dMultiply(n),this.dAddOffset(s,0),i=0,s=0))}i>0&&(this.dMultiply(Math.pow(t,i)),this.dAddOffset(s,0)),o&&ee.ZERO.subTo(this,this)}fromNumber(e,t,r){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(ee.ONE.shiftLeft(e-1),F,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(ee.ONE.shiftLeft(e-1),this);else{var n=[],o=7&e;n.length=1+(e>>3),t.nextBytes(n),o>0?n[0]&=(1<<o)-1:n[0]=0,this.fromString(n,256)}}bitwiseTo(e,t,r){var n,o,i=Math.min(e.t,this.t);for(n=0;n<i;++n)r[n]=t(this[n],e[n]);if(e.t<this.t){for(o=e.s&this.DM,n=i;n<this.t;++n)r[n]=t(this[n],o);r.t=this.t}else{for(o=this.s&this.DM,n=i;n<e.t;++n)r[n]=t(o,e[n]);r.t=e.t}r.s=t(this.s,e.s),r.clamp()}changeBit(e,t){var r=ee.ONE.shiftLeft(e);return this.bitwiseTo(r,t,r),r}addTo(e,t){for(var r=0,n=0,o=Math.min(e.t,this.t);r<o;)n+=this[r]+e[r],t[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n+=e.s;r<this.t;)n+=this[r],t[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n+=e[r],t[r++]=n&this.DM,n>>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t[r++]=n:n<-1&&(t[r++]=this.DV+n),t.t=r,t.clamp()}dMultiply(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()}dAddOffset(e,t){if(0!=e){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=e;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}}multiplyLowerTo(e,t,r){var n=Math.min(this.t+e.t,t);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,e[n],r,n,0,this.t);for(o=Math.min(e.t,t);n<o;++n)this.am(0,e[n],r,n,0,t-n);r.clamp()}multiplyUpperTo(e,t,r){--t;var n=r.t=this.t+e.t-t;for(r.s=0;--n>=0;)r[n]=0;for(n=Math.max(t-this.t,0);n<e.t;++n)r[this.t+n-t]=this.am(t-n,e[n],r,0,0,this.t+n-t);r.clamp(),r.drShiftTo(1,r)}modInt(e){if(e<=0)return 0;var t=this.DV%e,r=this.s<0?e-1:0;if(this.t>0)if(0==t)r=this[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this[n])%e;return r}millerRabin(e){var t=this.subtract(ee.ONE),r=t.getLowestSetBit();if(r<=0)return!1;var n=t.shiftRight(r);(e=e+1>>1)>v.length&&(e=v.length);for(var o=te(),i=0;i<e;++i){o.fromInt(v[Math.floor(Math.random()*v.length)]);var s=o.modPow(n,this);if(0!=s.compareTo(ee.ONE)&&0!=s.compareTo(t)){for(var a=1;a++<r&&0!=s.compareTo(t);)if(0==(s=s.modPowInt(2,this)).compareTo(ee.ONE))return!1;if(0!=s.compareTo(t))return!1}}return!0}square(){var e=te();return this.squareTo(e),e}gcda(e,t){var r=this.s<0?this.negate():this.clone(),n=e.s<0?e.negate():e.clone();if(r.compareTo(n)<0){var o=r;r=n,n=o}var i=r.getLowestSetBit(),s=n.getLowestSetBit();if(s<0)t(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(){t(n)}),0))};setTimeout(a,10)}}fromNumberAsync(e,t,r,n){if("number"==typeof t)if(e<2)this.fromInt(1);else{this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(ee.ONE.shiftLeft(e-1),F,this),this.isEven()&&this.dAddOffset(1,0);var o=this,i=function(){o.dAddOffset(2,0),o.bitLength()>e&&o.subTo(ee.ONE.shiftLeft(e-1),o),o.isProbablePrime(t)?setTimeout((function(){n()}),0):setTimeout(i,0)};setTimeout(i,0)}else{var s=[],a=7&e;s.length=1+(e>>3),t.nextBytes(s),a>0?s[0]&=(1<<a)-1:s[0]=0,this.fromString(s,256)}}}var m=function(){function e(){}return e.prototype.convert=function(e){return e},e.prototype.revert=function(e){return e},e.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},e.prototype.sqrTo=function(e,t){e.squareTo(t)},e}(),g=function(){function e(e){this.m=e}return e.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},e.prototype.revert=function(e){return e},e.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},e.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},e.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},e}(),b=function(){function e(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}return e.prototype.convert=function(e){var t=te();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(ee.ZERO)>0&&this.m.subTo(t,t),t},e.prototype.revert=function(e){var t=te();return e.copyTo(t),this.reduce(t),t},e.prototype.reduce=function(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t<this.m.t;++t){var r=32767&e[t],n=r*this.mpl+((r*this.mph+(e[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(e[r=t+this.m.t]+=this.m.am(0,n,e,t,0,this.m.t);e[r]>=e.DV;)e[r]-=e.DV,e[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},e.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},e.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},e}(),w=function(){function e(e){this.m=e,this.r2=te(),this.q3=te(),ee.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e)}return e.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=te();return e.copyTo(t),this.reduce(t),t},e.prototype.revert=function(e){return e},e.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},e.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},e.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},e}();function te(){return new ee(null)}function re(e,t){return new ee(e,t)}function ne(e,t,r,n,o,i){for(;--i>=0;){var s=t*this[e++]+r[n]+o;o=Math.floor(s/67108864),r[n++]=67108863&s}return o}function oe(e,t,r,n,o,i){for(var s=32767&t,a=t>>15;--i>=0;){var u=32767&this[e],c=this[e++]>>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 ie(e,t,r,n,o,i){for(var s=16383&t,a=t>>14;--i>=0;){var u=16383&this[e],c=this[e++]>>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)?(ee.prototype.am=oe,d=30):"Netscape"!=(null==o?void 0:o.appName)?(ee.prototype.am=ne,d=26):(ee.prototype.am=ie,d=28),ee.prototype.DB=d,ee.prototype.DM=(1<<d)-1,ee.prototype.DV=1<<d,ee.prototype.FV=Math.pow(2,52),ee.prototype.F1=52-d,ee.prototype.F2=2*d-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 se(e,t){var r=E[e.charCodeAt(t)];return null==r?-1:r}function ae(e){var t=te();return t.fromInt(e),t}function ue(e){var t,r=1;return 0!=(t=e>>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}ee.ZERO=ae(0),ee.ONE=ae(1);class ce{constructor(){this.i=0,this.j=0,this.S=[]}init(e){var t,r,n;for(t=0;t<256;++t)this.S[t]=t;for(r=0,t=0;t<256;++t)r=r+this.S[t]+e[t%e.length]&255,n=this.S[t],this.S[t]=this.S[r],this.S[r]=n;this.i=0,this.j=0}next(){var e;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,e=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=e,this.S[e+this.S[this.i]&255]}}var I,O,T=null;if(null==T){T=[],O=0;var A,R,P=void 0;if("undefined"!=typeof window&&null!==(A=window)&&void 0!==A&&A.crypto&&null!==(R=window)&&void 0!==R&&R.crypto.getRandomValues){var C,N=new Uint32Array(256);for(null===(C=window)||void 0===C||C.crypto.getRandomValues(N),P=0;P<N.length;++P)T[O++]=255&N[P]}var x,L,U,k=function(e){var t,r,n;if(this.count=this.count||0,this.count>=256||O>=256){if("undefined"!=typeof window)if(null!==(t=window)&&void 0!==t&&t.removeEventListener)null===(n=window)||void 0===n||n.removeEventListener("mousemove",k,!1);else if(null!==(r=window)&&void 0!==r&&r.detachEvent){var o;null===(o=window)||void 0===o||o.detachEvent("onmousemove",k)}}else try{var i=e.x+e.y;T[O++]=255&i,this.count+=1}catch(e){}};if("undefined"!=typeof window)if(null!==(x=window)&&void 0!==x&&x.addEventListener)null===(U=window)||void 0===U||U.addEventListener("mousemove",k,!1);else if(null!==(L=window)&&void 0!==L&&L.attachEvent){var D;null===(D=window)||void 0===D||D.attachEvent("onmousemove",k)}}function le(){if(null==I){for(I=new ce;O<256;){var e=Math.floor(65536*Math.random());T[O++]=255&e}for(I.init(T),O=0;O<T.length;++O)T[O]=0;O=0}return I.next()}class fe{constructor(){}nextBytes(e){for(var t=0;t<e.length;++t)e[t]=le()}}function de(e,t){if(t<e.length+11)return console.error("Message too long for RSA"),null;for(var r=[],n=e.length-1;n>=0&&t>0;){var o=e.charCodeAt(n--);o<128?r[--t]=o:o>127&&o<2048?(r[--t]=63&o|128,r[--t]=o>>6|192):(r[--t]=63&o|128,r[--t]=o>>6&63|128,r[--t]=o>>12|224)}r[--t]=0;for(var i=new fe,s=[];t>2;){for(s[0]=0;0==s[0];)i.nextBytes(s);r[--t]=s[0]}return r[--t]=2,r[--t]=0,new ee(r)}class he{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(e){return e.modPowInt(this.e,this.n)}doPrivate(e){if(null==this.p||null==this.q)return e.modPow(this.d,this.n);for(var t=e.mod(this.p).modPow(this.dmp1,this.p),r=e.mod(this.q).modPow(this.dmq1,this.q);t.compareTo(r)<0;)t=t.add(this.p);return t.subtract(r).multiply(this.coeff).mod(this.p).multiply(this.q).add(r)}setPublic(e,t){null!=e&&null!=t&&e.length>0&&t.length>0?(this.n=re(e,16),this.e=parseInt(t,16)):console.error("Invalid RSA public key")}encrypt(e){var t=de(e,this.n.bitLength()+7>>3);if(null==t)return null;var r=this.doPublic(t);if(null==r)return null;var n=r.toString(16);return 1&n.length?"0"+n:n}encryptLong(e){var t=this,r=(this.n.bitLength()+7>>3)-11;try{var n="";return e.length>r?(e.match(/.{1,117}/g).forEach((function(e){var r=t.encrypt(e);n+=r})),z(n)):z(this.encrypt(e))}catch(e){return!1}}decryptLong(e){var t=this,r=this.n.bitLength()+7>>3;e=K(e);try{if(e.length>r){var n="";return e.match(/.{1,256}/g).forEach((function(e){var r=t.decrypt(e);n+=r})),n}return this.decrypt(e)}catch(e){return!1}}setPrivate(e,t,r){null!=e&&null!=t&&e.length>0&&t.length>0?(this.n=re(e,16),this.e=parseInt(t,16),this.d=re(r,16)):console.error("Invalid RSA private key")}setPrivateEx(e,t,r,n,o,i,s,a){null!=e&&null!=t&&e.length>0&&t.length>0?(this.n=re(e,16),this.e=parseInt(t,16),this.d=re(r,16),this.p=re(n,16),this.q=re(o,16),this.dmp1=re(i,16),this.dmq1=re(s,16),this.coeff=re(a,16)):console.error("Invalid RSA private key")}generate(e,t){var r=new fe,n=e>>1;this.e=parseInt(t,16);for(var o=new ee(t,16);;){for(;this.p=new ee(e-n,1,r),0!=this.p.subtract(ee.ONE).gcd(o).compareTo(ee.ONE)||!this.p.isProbablePrime(10););for(;this.q=new ee(n,1,r),0!=this.q.subtract(ee.ONE).gcd(o).compareTo(ee.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(ee.ONE),a=this.q.subtract(ee.ONE),u=s.multiply(a);if(0==u.gcd(o).compareTo(ee.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(e){var t=re(e,16),r=this.doPrivate(t);return null==r?null:pe(r,this.n.bitLength()+7>>3)}generateAsync(e,t,r){var n=new fe,o=e>>1;this.e=parseInt(t,16);var i=new ee(t,16),s=this,a=()=>{var t=()=>{if(s.p.compareTo(s.q)<=0){var e=s.p;s.p=s.q,s.q=e}var t=s.p.subtract(ee.ONE),n=s.q.subtract(ee.ONE),o=t.multiply(n);0==o.gcd(i).compareTo(ee.ONE)?(s.n=s.p.multiply(s.q),s.d=i.modInverse(o),s.dmp1=s.d.mod(t),s.dmq1=s.d.mod(n),s.coeff=s.q.modInverse(s.p),setTimeout((function(){r()}),0)):setTimeout(a,0)},u=()=>{s.q=te(),s.q.fromNumberAsync(o,1,n,(function(){s.q.subtract(ee.ONE).gcda(i,(function(e){0==e.compareTo(ee.ONE)&&s.q.isProbablePrime(10)?setTimeout(t,0):setTimeout(u,0)}))}))},c=()=>{s.p=te(),s.p.fromNumberAsync(e-o,1,n,(function(){s.p.subtract(ee.ONE).gcda(i,(function(e){0==e.compareTo(ee.ONE)&&s.p.isProbablePrime(10)?setTimeout(u,0):setTimeout(c,0)}))}))};setTimeout(c,0)};setTimeout(a,0)}}function pe(e,t){for(var r=e.toByteArray(),n=0;n<r.length&&0==r[n];)++n;if(r.length-n!=t-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 ve extends he{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";super(),e&&("string"==typeof e?this.parseKey(e):(this.hasPrivateKeyProperty(e)||this.hasPublicKeyProperty(e))&&this.parsePropertiesFrom(e))}parseKey(e){try{var t=0,r=0,n=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(e)?c.decode(e):l.unarmor(e),o=Z.decode(n);if(3===o.sub.length&&(o=o.sub[2].sub[0]),9===o.sub.length){t=o.sub[1].getHexStringValue(),this.n=re(t,16),r=o.sub[2].getHexStringValue(),this.e=parseInt(r,16);var i=o.sub[3].getHexStringValue();this.d=re(i,16);var s=o.sub[4].getHexStringValue();this.p=re(s,16);var a=o.sub[5].getHexStringValue();this.q=re(a,16);var u=o.sub[6].getHexStringValue();this.dmp1=re(u,16);var f=o.sub[7].getHexStringValue();this.dmq1=re(f,16);var d=o.sub[8].getHexStringValue();this.coeff=re(d,16)}else{if(2!==o.sub.length)return!1;var h=o.sub[1].sub[0];t=h.sub[0].getHexStringValue(),this.n=re(t,16),r=h.sub[1].getHexStringValue(),this.e=parseInt(r,16)}return!0}catch(e){return!1}}hasPublicKeyProperty(e){return(e=e||{}).hasOwnProperty("n")&&e.hasOwnProperty("e")}hasPrivateKeyProperty(e){return(e=e||{}).hasOwnProperty("n")&&e.hasOwnProperty("e")&&e.hasOwnProperty("d")&&e.hasOwnProperty("p")&&e.hasOwnProperty("q")&&e.hasOwnProperty("dmp1")&&e.hasOwnProperty("dmq1")&&e.hasOwnProperty("coeff")}parsePropertiesFrom(e){this.n=e.n,this.e=e.e,e.hasOwnProperty("d")&&(this.d=e.d,this.p=e.p,this.q=e.q,this.dmp1=e.dmp1,this.dmq1=e.dmq1,this.coeff=e.coeff)}}(n=function(e){e=e||{},this.default_key_size=parseInt(e.default_key_size,10)||1024,this.default_public_exponent=e.default_public_exponent||"010001",this.log=e.log||!1,this.key=null}).prototype.setKey=function(e){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new ve(e)},n.prototype.setPrivateKey=function(e){this.setKey(e)},n.prototype.setPublicKey=function(e){this.setKey(e)},n.prototype.decrypt=function(e){try{return this.getKey().decrypt(K(e))}catch(e){return!1}},n.prototype.encrypt=function(e){try{return z(this.getKey().encrypt(e))}catch(e){return!1}},n.prototype.encryptLong=function(e){try{for(var t=this.getKey().encryptLong(e)||"",r=this.getKey().decryptLong(t)||"",n=0,o=/null$/g;o.test(r)&&(n++,t=this.getKey().encryptLong(e)||"",r=this.getKey().decryptLong(t)||"",!(n>10)););return t}catch(e){return!1}},n.prototype.getKey=function(e){if(!this.key){if(this.key=new ve,e&&"[object Function]"==={}.toString.call(e))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,e);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},n.version="3.1.4"}var j=n,q=r(4655),M=function(){var{publicKey:e="",payload:t={}}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!e)return"";try{var r=(0,q.I)(t),n=new j;return n.setPublicKey(e),n.encryptLong("object"==typeof r?JSON.stringify(r):r)}catch(e){console.error("encrypt error:",e)}return""}},4655:function(e,t,r){"use strict";r.d(t,{I:function(){return n},y:function(){return o}});var n=e=>{var t=t=>{for(var r in e)e.hasOwnProperty(r)&&(t[r]=n(e[r]));return t},r=null==e?"NullOrUndefined":Object.prototype.toString.call(e).slice(8,-1);if(["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"].includes(r))return e.slice();switch(r){case"Object":return t(Object.create(Object.getPrototypeOf(e)));case"Array":return t([]);case"Date":return new Date(e.valueOf());case"RegExp":return new RegExp(e.source,(e.global?"g":"")+(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.sticky?"y":"")+(e.unicode?"u":""));default:return e}},o=e=>{var t=e.match(/^(?:http(s)?:\/\/[^\/]+)?(\/[^\?#]*)/);return t&&t[2]||""}},9063:function(e,t,r){"use strict";r.r(t),r.d(t,{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(e){return void 0===e&&(e=""),"".concat(e?"".concat(e,"_"):"").concat(+new Date,"_").concat(Math.random())}var l,f,d=function(e){this.close=e.close,this.onChange=e.onChange,this.onError=e.onError,e.debug&&Object.defineProperty(this,"virtualClient",{get:function(){return e.virtualClient}})},h=function(e){var t,r,n=e.id,o=e.docChanges,i=e.docs,s=e.msgType,a=e.type;Object.defineProperties(this,{id:{get:function(){return n},enumerable:!0},docChanges:{get:function(){return t||(t=JSON.parse(JSON.stringify(o))),t},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(e,t){return l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},l(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}l(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),v=function(e){function t(t){var r=e.call(this,"Watch Error ".concat(JSON.stringify(t.msgData)," (requestid: ").concat(t.requestId,")"))||this;return r.isRealtimeErrorMessageError=!0,r.payload=t,r}return p(t,e),t}(Error),y=function(e){return null==e?void 0:e.isRealtimeErrorMessageError},m=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type="timeout",t.payload=null,t.generic=!0,t}return p(t,e),t}(Error),g=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type="cancelled",t.payload=null,t.generic=!0,t}return p(t,e),t}(Error),b=function(e){function t(t){var r=e.call(this,t.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(e){this.errMsg=e}}}),r.errCode=t.errCode||"UNKNOWN_ERROR",r.errMsg=t.errMsg,r}return p(t,e),Object.defineProperty(t.prototype,"message",{get:function(){return"errCode: ".concat(this.errCode," | errMsg: ").concat(this.errMsg)},set:function(e){this.errMsg=e},enumerable:!1,configurable:!0}),t}(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(e){return void 0===e&&(e=0),new Promise((function(t){return setTimeout(t,e)}))},S=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},E=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};!function(e){e.LOGGINGIN="LOGGINGIN",e.INITING="INITING",e.REBUILDING="REBUILDING",e.ACTIVE="ACTIVE",e.ERRORED="ERRORED",e.CLOSING="CLOSING",e.CLOSED="CLOSED",e.PAUSED="PAUSED",e.RESUMING="RESUMING"}(f||(f={}));var O=function(){function e(e){var t=this;this.watchStatus=f.INITING,this.wsLogin=function(e,r){return S(t,void 0,void 0,(function(){var t;return E(this,(function(n){switch(n.label){case 0:return this.watchStatus=f.LOGGINGIN,[4,this.login(e,r)];case 1:return t=n.sent(),this.envId||(this.envId=t.envId),[2,t]}}))}))},this.initWatch=function(e){return S(t,void 0,void 0,(function(){var t,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(t,n){S(r,void 0,void 0,(function(){var r,o,i,s,a,u,l,d,p,v;return E(this,(function(y){switch(y.label){case 0:return y.trys.push([0,3,,4]),this.watchStatus===f.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,t()]):[4,this.wsLogin(this.envId,e)];case 1:return r=y.sent().envId,this.watchStatus===f.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,t()]):(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=y.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,d=a;l<d.length;l++)d[l].ID=u;this.handleServerEvents(i)}else this.sessionInfo.currentEventId=u,p=new h({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,t(),[3,4];case 3:return v=y.sent(),this.handleWatchEstablishmentError(v,{operationName:"INIT_WATCH",resolve:t,reject:n}),[3,4];case 4:return[2]}}))}))})),t=!1,n.label=1;case 1:return n.trys.push([1,,3,4]),[4,this.initWatchPromise];case 2:return n.sent(),t=!0,[3,4];case 3:return this.initWatchPromise=void 0,[7];case 4:return console.log("[realtime] initWatch ".concat(t?"success":"fail")),[2]}}))}))},this.rebuildWatch=function(e){return S(t,void 0,void 0,(function(){var t,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(t,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,t()]):[4,this.wsLogin(this.envId,e)];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,t()]):(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,t(),[3,4];case 3:return s=a.sent(),this.handleWatchEstablishmentError(s,{operationName:"REBUILD_WATCH",resolve:t,reject:n}),[3,4];case 4:return[2]}}))}))})),t=!1,n.label=1;case 1:return n.trys.push([1,,3,4]),[4,this.rebuildWatchPromise];case 2:return n.sent(),t=!0,[3,4];case 3:return this.rebuildWatchPromise=void 0,[7];case 4:return console.log("[realtime] rebuildWatch ".concat(t?"success":"fail")),[2]}}))}))},this.handleWatchEstablishmentError=function(e,r){return S(t,void 0,void 0,(function(){var t,n,o,i=this;return E(this,(function(s){return t="INIT_WATCH"===r.operationName,n=function(){i.closeWithError(new b({errCode:t?w.SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:w.SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL,errMsg:e})),r.reject(e)},o=function(e){i.useRetryTicket(r.operationName)?t?(i.initWatchPromise=void 0,r.resolve(i.initWatch(e))):(i.rebuildWatchPromise=void 0,r.resolve(i.rebuildWatch(e))):n()},this.handleCommonError(e,{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 e,t=this;return E(this,(function(n){switch(n.label){case 0:return n.trys.push([0,8,,9]),e=function(){return S(t,void 0,void 0,(function(){return E(this,(function(e){switch(e.label){case 0:return this.pause(),[4,this.onceWSConnected()];case 1:return e.sent(),o(!0),[2]}}))}))},this.isWSConnected()?[3,2]:[4,e()];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 g("".concat(r.operationName," cancelled due to pause after unknownError"))),[3,7]);case 4:return this.isWSConnected()?[3,6]:[4,e()];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(t,void 0,void 0,(function(){var e,t,r;return E(this,(function(n){switch(n.label){case 0:if(e=this.sessionInfo?this.sessionInfo.queryID:"",this.watchStatus!==f.ACTIVE)return this.watchStatus=f.CLOSED,this.onWatchClose(this,e),[2];n.label=1;case 1:return n.trys.push([1,3,4,5]),this.watchStatus=f.CLOSING,t={watchId:this.watchId,requestId:c(),msgType:"CLOSE_WATCH",msgData:null},[4,this.send({msg:t})];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,e),[7];case 5:return[2]}}))}))},this.scheduleSendACK=function(){t.clearACKSchedule(),t.ackTimeoutId=setTimeout((function(){t.waitExpectedTimeoutId?t.scheduleSendACK():t.sendACK()}),1e4)},this.clearACKSchedule=function(){t.ackTimeoutId&&clearTimeout(t.ackTimeoutId)},this.sendACK=function(){return S(t,void 0,void 0,(function(){var e,t,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?(e={watchId:this.watchId,requestId:c(),msgType:"CHECK_LAST",msgData:{queryID:this.sessionInfo.queryID,eventID:this.sessionInfo.currentEventId}},[4,this.send({msg:e})]):(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(t=n.sent(),y(t))switch((r=t.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:t})),[3,3];case 3:return[2]}}))}))},this.handleCommonError=function(e,t){if(y(e))switch(e.payload.msgData.code){case"CHECK_LOGIN_FAILED":case"SIGN_EXPIRED_ERROR":case"SIGN_INVALID_ERROR":case"SIGN_PARAM_INVALID":return void t.onSignError(e);default:return void t.onNotRetryableError(e)}else{if(function(e){return"timeout"===e.type}(e))return void t.onTimeoutError(e);if(function(e){return"cancelled"===e.type}(e))return void t.onCancelledError(e)}t.onUnknownError(e)},this.watchId="watchid_".concat(+new Date,"_").concat(Math.random()),this.envId=e.envId,this.collectionName=e.collectionName,this.query=e.query,this.limit=e.limit,this.orderBy=e.orderBy,this.send=e.send,this.login=e.login,this.isWSConnected=e.isWSConnected,this.onceWSConnected=e.onceWSConnected,this.getWaitExpectedTimeoutLength=e.getWaitExpectedTimeoutLength,this.onWatchStart=e.onWatchStart,this.onWatchClose=e.onWatchClose,this.debug=e.debug,this.availableRetries={INIT_WATCH:2,REBUILD_WATCH:2,CHECK_LAST:2},this.listener=new d({close:function(){t.closeWatch()},onChange:e.onChange,onError:e.onError,debug:this.debug,virtualClient:this}),this.initWatch()}return e.prototype.onMessage=function(e){var t=this;switch(this.watchStatus){case f.PAUSED:if("ERROR"!==e.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(),e.msgType){case"NEXT_EVENT":console.warn("nextevent ".concat(e.msgData.currEvent," ignored"),e),this.handleServerEvents(e);break;case"CHECK_EVENT":this.sessionInfo.currentEventId<e.msgData.currEvent&&(this.sessionInfo.expectEventId=e.msgData.currEvent,this.clearWaitExpectedEvent(),this.waitExpectedTimeoutId=setTimeout((function(){t.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(e.msgData.code," - ").concat(e.msgData.message)}));break;default:console.warn("[realtime listener] virtual client receive unexpected msg ".concat(e.msgType,": "),e)}else console.warn("[realtime listener] internal non-fatal error: sessionInfo not found while message is received.")},e.prototype.closeWithError=function(e){var t;this.watchStatus=f.ERRORED,this.clearACKSchedule(),this.listener.onError(e),this.onWatchClose(this,(null===(t=this.sessionInfo)||void 0===t?void 0:t.queryID)||""),console.log("[realtime] client closed (".concat(this.collectionName," ").concat(this.query,") (watchId ").concat(this.watchId,")"))},e.prototype.pause=function(){this.watchStatus=f.PAUSED,console.log("[realtime] client paused (".concat(this.collectionName," ").concat(this.query,") (watchId ").concat(this.watchId,")"))},e.prototype.resume=function(){return S(this,void 0,void 0,(function(){var e;return E(this,(function(t){switch(t.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,")")),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.sessionInfo?this.rebuildWatch():this.initWatch()];case 2:return t.sent(),console.log("[realtime] client successfully resumed (".concat(this.collectionName," ").concat(this.query,") (").concat(this.watchId,")")),[3,4];case 3:return e=t.sent(),console.error("[realtime] client resume failed (".concat(this.collectionName," ").concat(this.query,") (").concat(this.watchId,")"),e),[3,4];case 4:return[2]}}))}))},e.prototype.useRetryTicket=function(e){return!!(this.availableRetries[e]&&this.availableRetries[e]>0)&&(this.availableRetries[e]-=1,console.log("[realtime] ".concat(e," use a retry ticket, now only ").concat(this.availableRetries[e]," retry left")),!0)},e.prototype.handleServerEvents=function(e){return S(this,void 0,void 0,(function(){var t;return E(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.scheduleSendACK(),[4,this.handleServerEventsInternel(e)];case 1:return r.sent(),this.postHandleServerEventsValidityCheck(e),[3,3];case 2:throw t=r.sent(),console.error("[realtime listener] internal non-fatal error: handle server events failed with error: ",t),t;case 3:return[2]}}))}))},e.prototype.handleServerEventsInternel=function(e){return S(this,void 0,void 0,(function(){var t,r,n,i,a,c,l,f,d,p,v,y;return E(this,(function(m){switch(m.label){case 0:if(t=e.requestId,r=e.msgData.events,n=e.msgType,!r.length||!this.sessionInfo)return[2];i=this.sessionInfo;try{a=r.map(T)}catch(e){return this.closeWithError(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA,errMsg:e})),[2]}c=I([],i.currentDocs,!0),l=!1,f=function(r,f){var p,v,y,m,g,_,S,O,T,A,R,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(t,")")),[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(v=c.find((function(e){return e._id===p.docId})),v){if(y=u()(v),p.updatedFields&&Object.keys(p.updatedFields).forEach((function(e){o()(y,e,p.updatedFields[e])})),p.removedFields)for(m=0,g=p.removedFields;m<g.length;m++)_=g[m],s()(y,_);p.doc=y}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(e.requestId,")")}),d.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(e.requestId,")")}),d.closeWithError(O),O;break;case"remove":(S=c.find((function(e){return e._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(e){return e._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(e.requestId,")")}),d.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(e){return e._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(e){return e._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)&&(A=I([],c,!0),R=a.slice(0,r+1).filter((function(e){return e.id===p.id})),d.sessionInfo.currentEventId=p.id,d.sessionInfo.currentDocs=c,P=new h({id:p.id,docChanges:R,docs:A,msgType:n}),d.listener.onChange(P)),[3,4];case 2:return console.warn("[realtime listener] event received is out of order, cur ".concat(d.sessionInfo.currentEventId," but got ").concat(p.id)),[4,d.rebuildWatch()];case 3:return E.sent(),[2,{value:void 0}];case 4:return[2]}}))},d=this,p=0,v=a.length,m.label=1;case 1:return p<v?[5,f(p,v)]:[3,4];case 2:if("object"==typeof(y=m.sent()))return[2,y.value];m.label=3;case 3:return p++,[3,1];case 4:return[2]}}))}))},e.prototype.postHandleServerEventsValidityCheck=function(e){this.sessionInfo?(this.sessionInfo.expectEventId&&this.sessionInfo.currentEventId>=this.sessionInfo.expectEventId&&this.clearWaitExpectedEvent(),this.sessionInfo.currentEventId<e.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")},e.prototype.clearWaitExpectedEvent=function(){this.waitExpectedTimeoutId&&(clearTimeout(this.waitExpectedTimeoutId),this.waitExpectedTimeoutId=void 0)},e}();function T(e){var t={id:e.ID,dataType:e.DataType,queueType:e.QueueType,docId:e.DocID,doc:e.Doc&&"{}"!==e.Doc?JSON.parse(e.Doc):void 0};return"update"===e.DataType&&(e.UpdatedFields&&(t.updatedFields=JSON.parse(e.UpdatedFields)),(e.removedFields||e.RemovedFields)&&(t.removedFields=JSON.parse(e.removedFields))),t}var A,R={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(e){e[e.NormalClosure=1e3]="NormalClosure",e[e.GoingAway=1001]="GoingAway",e[e.ProtocolError=1002]="ProtocolError",e[e.UnsupportedData=1003]="UnsupportedData",e[e.NoStatusReceived=1005]="NoStatusReceived",e[e.AbnormalClosure=1006]="AbnormalClosure",e[e.InvalidFramePayloadData=1007]="InvalidFramePayloadData",e[e.PolicyViolation=1008]="PolicyViolation",e[e.MessageTooBig=1009]="MessageTooBig",e[e.MissingExtension=1010]="MissingExtension",e[e.InternalError=1011]="InternalError",e[e.ServiceRestart=1012]="ServiceRestart",e[e.TryAgainLater=1013]="TryAgainLater",e[e.BadGateway=1014]="BadGateway",e[e.TLSHandshake=1015]="TLSHandshake",e[e.ReconnectWebSocket=3e3]="ReconnectWebSocket",e[e.NoRealtimeListeners=3001]="NoRealtimeListeners",e[e.HeartbeatPingError=3002]="HeartbeatPingError",e[e.HeartbeatPongTimeoutError=3003]="HeartbeatPongTimeoutError",e[e.NoAuthentication=3050]="NoAuthentication"}(A||(A={}));var P=function(e,t){var r=R[e],n=r?"".concat(r.name,", code ").concat(e,", reason ").concat(t||r.description):"code ".concat(e);return new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED,errMsg:n})},C=null,N="web";function x(){return C}function L(){return N}function U(e){N=e}var k=function(){return k=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},k.apply(this,arguments)},D=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},j=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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 e(e){var t=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(e){return D(t,void 0,void 0,(function(){var t=this;return j(this,(function(r){return[2,new Promise((function(r,n){D(t,void 0,void 0,(function(){var t,o,i,s,a,u,c,l,f=this;return j(this,(function(d){switch(d.label){case 0:o=!1,i=!1,s=function(e){o=!0,t&&clearTimeout(t),r(e)},a=function(e){i=!0,t&&clearTimeout(t),n(e)},e.timeout&&(t=setTimeout((function(){D(f,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return o&&i?[3,2]:[4,_(0)];case 1:e.sent(),o&&i||a(new m("wsclient.send timedout")),e.label=2;case 2:return[2]}}))}))}),e.timeout)),d.label=1;case 1:return d.trys.push([1,8,,9]),void 0===this.wsInitPromise&&null===this.wsInitPromise?[3,3]:[4,this.wsInitPromise];case 2:d.sent(),d.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];e.waitResponse&&(u={resolve:s,reject:a,skipOnMessage:e.skipOnMessage},this.wsResponseWait.set(e.msg.requestId,u)),d.label=4;case 4:return d.trys.push([4,6,,7]),[4,this.ws.send(JSON.stringify(e.msg))];case 5:return d.sent(),e.waitResponse||s(void 0),[3,7];case 6:return(c=d.sent())&&(a(c),e.waitResponse&&this.wsResponseWait.delete(e.msg.requestId)),[3,7];case 7:return[3,9];case 8:return l=d.sent(),a(l),[3,9];case 9:return[2]}}))}))}))]}))}))},this.closeAllClients=function(e){t.virtualWSClient.forEach((function(t){t.closeWithError(e)}))},this.pauseClients=function(e){(e||t.virtualWSClient).forEach((function(e){e.pause()}))},this.resumeClients=function(e){(e||t.virtualWSClient).forEach((function(e){e.resume()}))},this.initWebSocketConnection=function(e,r){return void 0===r&&(r=t.maxReconnect),D(t,void 0,void 0,(function(){var t=this;return j(this,(function(n){switch(n.label){case 0:if(e&&this.reconnectState)return[2];if(e&&(this.reconnectState=!0),void 0!==this.wsInitPromise&&null!==this.wsInitPromise)return[2,this.wsInitPromise];e&&this.pauseClients(),this.close(A.ReconnectWebSocket),this.wsInitPromise=new Promise((function(n,o){D(t,void 0,void 0,(function(){var t,i,s=this;return j(this,(function(a){switch(a.label){case 0:return a.trys.push([0,6,,11]),[4,this.getWsSign()];case 1:return t=a.sent(),[4,new Promise((function(e){var r=t.wsUrl||"wss://tcb-ws.tencentcloudapi.com",n=x();s.ws=n?new n(r):new WebSocket(r),e(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(),e&&(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(),e&&(this.reconnectState=!1),a.label=8;case 8:return n(this.initWebSocketConnection(e,r-1)),[3,10];case 9:o(i),e&&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(e){return(0,e.resolve)()})),[3,5];case 3:return n.sent(),this.wsReadySubsribers.forEach((function(e){return(0,e.reject)()})),[3,5];case 4:return this.wsInitPromise=void 0,this.wsReadySubsribers=[],[7];case 5:return[2]}}))}))},this.initWebSocketEvent=function(){return new Promise((function(e,r){if(!t.ws)throw new Error("can not initWebSocketEvent, ws not exists");var n=!1;t.ws.onopen=function(t){console.warn("[realtime] ws event: open",t),n=!0,e()},t.ws.onerror=function(e){t.logins=new Map,n?(console.error("[realtime] ws event: error",e),t.clearHeartbeat(),t.virtualWSClient.forEach((function(t){return t.closeWithError(new b({errCode:w.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR,errMsg:e}))}))):(console.error("[realtime] ws open failed with ws event: error",e),r(e))},t.ws.onclose=function(e){switch(console.warn("[realtime] ws event: close",e),t.logins=new Map,t.clearHeartbeat(),e.code){case A.ReconnectWebSocket:case A.NoRealtimeListeners:break;case A.HeartbeatPingError:case A.HeartbeatPongTimeoutError:case A.NormalClosure:case A.AbnormalClosure:t.maxReconnect>0?t.initWebSocketConnection(!0,t.maxReconnect):t.closeAllClients(P(e.code));break;case A.NoAuthentication:t.closeAllClients(P(e.code,e.reason));break;default:t.maxReconnect>0?t.initWebSocketConnection(!0,t.maxReconnect):t.closeAllClients(P(e.code))}},t.ws.onmessage=function(e){var r,n,o=(null===(r=e.data)||void 0===r?void 0:r.data)||e.data;t.heartbeat();try{n="string"==typeof o?JSON.parse(o):o}catch(e){throw new Error("[realtime] onMessage parse res.data error: ".concat(e))}if("ERROR"===n.msgType){var i=null;t.virtualWSClient.forEach((function(e){e.watchId===n.watchId&&(i=e)})),i&&i.listener.onError(n)}var s=t.wsResponseWait.get(n.requestId);if(s){try{"ERROR"===n.msgType?s.reject(new v(n)):s.resolve(n)}catch(e){console.error("ws onMessage responseWaitSpec.resolve(msg) errored:",e)}finally{t.wsResponseWait.delete(n.requestId)}if(s.skipOnMessage)return}if("PONG"!==n.msgType){var a=n.watchId&&t.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=t.queryIdClientMap.get(n.msgData.queryID))&&a.onMessage(n);break;default:for(var u=0,c=Array.from(t.watchIdClientMap.entries());u<c.length;u++){c[u][1].onMessage(n);break}}}else if(t.lastPingSendTS){var l=Date.now()-t.lastPingSendTS;if(l>1e4)return void console.warn("[realtime] untrusted rtt observed: ".concat(l));t.rttObserved.length>=3&&t.rttObserved.splice(0,t.rttObserved.length-3+1),t.rttObserved.push(l)}},t.heartbeat()}))},this.isWSConnected=function(){return Boolean(t.ws&&1===t.ws.readyState)},this.onceWSConnected=function(){return D(t,void 0,void 0,(function(){var e=this;return j(this,(function(t){return this.isWSConnected()?[2]:null!==this.wsInitPromise&&void 0!==this.wsInitPromise?[2,this.wsInitPromise]:[2,new Promise((function(t,r){e.wsReadySubsribers.push({resolve:t,reject:r})}))]}))}))},this.webLogin=function(e,r){return D(t,void 0,void 0,(function(){var t,n,o,i,s,a,u,l,f=this;return j(this,(function(d){switch(d.label){case 0:if(!r)if(e){if(t=this.logins.get(e)){if(t.loggedIn&&t.loginResult)return[2,t.loginResult];if(null!==t.loggingInPromise&&void 0!==t.loggingInPromise)return[2,t.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(e,t){D(f,void 0,void 0,(function(){var r,n,o,i,s;return j(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?t(new Error("".concat(i.msgData.code," ").concat(i.msgData.message))):e({envId:r.envId}),[3,4];case 3:return s=a.sent(),t(s),[3,4];case 4:return[2]}}))}))})),i=e&&this.logins.get(e),s=Date.now(),i?(i.loggedIn=!1,i.loggingInPromise=o,i.loginStartTS=s):(i={loggedIn:!1,loggingInPromise:o,loginStartTS:s},this.logins.set(e||"",i)),d.label=1;case 1:return d.trys.push([1,3,,4]),[4,o];case 2:if(a=d.sent(),(u=e&&this.logins.get(e))&&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=d.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 D(t,void 0,void 0,(function(){var e,t,r,n,o,i,s;return j(this,(function(a){switch(a.label){case 0:return this.wsSign&&this.wsSign.expiredTs>Date.now()?[2,this.wsSign]:(e=Date.now()+6e4,[4,this.context.appConfig.request.send("auth.wsWebSign",{runtime:L()})]);case 1:if((t=a.sent()).code)throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败: ".concat(t.code));if(t.data)return r=t.data,n=r.signStr,o=r.wsUrl,i=r.secretVersion,s=r.envId,[2,{signStr:n,wsUrl:o,secretVersion:i,envId:s,expiredTs:e}];throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败")}}))}))},this.getWaitExpectedTimeoutLength=function(){return t.rttObserved.length?t.rttObserved.reduce((function(e,t){return e+t}))/t.rttObserved.length*1.5:5e3},this.ping=function(){return D(t,void 0,void 0,(function(){var e;return j(this,(function(t){switch(t.label){case 0:return e={watchId:void 0,requestId:c(),msgType:"PING",msgData:null},[4,this.send({msg:e})];case 1:return t.sent(),[2]}}))}))},this.onWatchStart=function(e,r){t.queryIdClientMap.set(r,e)},this.onWatchClose=function(e,r){r&&t.queryIdClientMap.delete(r),t.watchIdClientMap.delete(e.watchId),t.virtualWSClient.delete(e),t.virtualWSClient.size||t.close(A.NoRealtimeListeners)},this.maxReconnect=e.maxReconnect||5,this.reconnectInterval=e.reconnectInterval||1e4,this.context=e.context}return e.prototype.clearHeartbeat=function(){this.pingTimeoutId&&clearTimeout(this.pingTimeoutId),this.pongTimeoutId&&clearTimeout(this.pongTimeoutId)},e.prototype.close=function(e){this.clearHeartbeat(),this.ws&&(this.ws.close(e,R[e].name),this.ws=void 0)},e.prototype.watch=function(e){this.ws||void 0!==this.wsInitPromise&&null!==this.wsInitPromise||this.initWebSocketConnection(!1);var t=new O(k(k({},e),{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(t),this.watchIdClientMap.set(t.watchId,t),t.listener},e.prototype.heartbeat=function(e){var t=this;this.clearHeartbeat(),this.pingTimeoutId=setTimeout((function(){D(t,void 0,void 0,(function(){var e=this;return j(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),this.ws&&1===this.ws.readyState?(this.lastPingSendTS=Date.now(),[4,this.ping()]):[2];case 1:return t.sent(),this.pingFailed=0,this.pongTimeoutId=setTimeout((function(){console.error("pong timed out"),e.pongMissed<2?(e.pongMissed+=1,e.heartbeat(!0)):e.initWebSocketConnection(!0)}),this.context.appConfig.realtimePongWaitTimeout),[3,3];case 2:return t.sent(),this.pingFailed<2?(this.pingFailed+=1,this.heartbeat()):this.close(A.HeartbeatPingError),[3,3];case 3:return[2]}}))}))}),e?0:this.context.appConfig.realtimePingInterval)},e}(),M={target:"database",entity:function(){var e,t=this.platform,r=t.adapter,n=t.runtime;e=r.wsClass,C=e,U(n)}},B={name:"realtime",IIFE:!0,entity:function(){this.prototype.wsClientClass=q}};try{cloudbase.registerComponent(B),cloudbase.registerHook(M)}catch(e){}function W(e){try{e.registerComponent(B),e.registerHook(M)}catch(e){console.warn(e)}}},534:function(e,t,r){"use strict";r.r(t),r.d(t,{COMPONENT_NAME:function(){return I},CloudbaseStorage:function(){return P},SupabaseFileAPILikeStorage:function(){return x},registerStorage:function(){return U}});var n,o,i=(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),s=function(e){function t(t){var r=e.call(this,t)||this;return r.__isStorageError=!0,r.name="StorageError",r}return i(t,e),t}(Error);function a(e){return"object"==typeof e&&null!==e&&"__isStorageError"in e}(function(e){function t(t,r,n){var o=e.call(this,t)||this;return o.name="StorageApiError",o.status=r,o.statusCode=n,o}i(t,e),t.prototype.toJSON=function(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}})(s),i((function(e,t){var r=o.call(this,e)||this;return r.name="StorageUnknownError",r.originalError=t,r}),o=s);var u,c=r(3616),l=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};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)}}(),f=function(){return f=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},f.apply(this,arguments)},d=function(e,t,r,n){var o,i=arguments.length,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s},h=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},p=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},v=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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(e){e.put="put",e.post="post"}(u||(u={}));var y=c._G.eX,m=c._G.Sg,g=c._G.vM,b=c.P6.isArray,w=c.P6.isString,_=c.P6.isPalinObject,S=c.P6.execCallback,E=c.BM.D,I="storage",O=function(e,t,r){return p(void 0,void 0,void 0,(function(){var n,o,i;return v(this,(function(s){switch(s.label){case 0:return[4,e.gateWay({path:"storages",name:"get-objects-upload-info",data:[f({objectId:t.path},t.headers?{signedHeader:Object.keys(t.headers).reduce((function(e,r){var n;return f(f({},e),((n={})[r]=[t.headers[r]],n))}),{})}:{})]},r)];case 1:return n=s.sent(),o=(null===(i=n.data)||void 0===i?void 0:i[0])||{},[2,n=f(f({},n),{data:f(f({},o.code?f({},o):{}),{authorization:o.authorization,token:o.token,url:o.uploadUrl,fileId:o.cloudObjectId,cosFileId:o.cloudObjectMeta,download_url:o.downloadUrl})})]}}))}))},T=function(e,t,r){return p(void 0,void 0,void 0,(function(){var n,o;return v(this,(function(i){switch(i.label){case 0:return[4,e.gateWay({path:"storages",name:"get-objects-download-info",data:t.convertedFileList.map((function(e){return{cloudObjectId:e.fileid}}))},r)];case 1:return n=i.sent(),[2,n=f(f({},n),{data:{download_list:null===(o=n.data)||void 0===o?void 0:o.map((function(e){return{code:e.code||"SUCCESS",message:e.message,fileid:e.cloudObjectId,download_url:e.downloadUrl,fileID:e.cloudObjectId,tempFileURL:e.downloadUrl}}))}})]}}))}))},A=function(e,t,r){return p(void 0,void 0,void 0,(function(){var n,o;return v(this,(function(i){switch(i.label){case 0:return[4,e.gateWay({path:"storages",name:"delete-objects",data:t.fileList.map((function(e){return{cloudObjectId:e}}))},r)];case 1:return n=i.sent(),[2,n=f(f({},n),{data:{delete_list:null===(o=n.data)||void 0===o?void 0:o.map((function(e){return{code:e.code||"SUCCESS",fileID:e.cloudObjectId,message:e.message}}))}})]}}))}))},R=function(e,t,r){return p(void 0,void 0,void 0,(function(){var n,o;return v(this,(function(i){switch(i.label){case 0:return[4,e.gateWay({path:"storages",name:"copy-objects",data:t.convertedFileList.map((function(e){return{srcPath:e.src_path,dstPath:e.dst_path,overwrite:e.overwrite,removeOriginal:e.remove_original}}))},r)];case 1:return n=i.sent(),[2,n=f(f({},n),{data:{copy_list:null===(o=n.data)||void 0===o?void 0:o.map((function(e){return{code:e.code||"SUCCESS",fileID:e.cloudObjectId,message:e.message}}))}})]}}))}))},P=function(){function e(){}return e.prototype.isGateWay=function(){return"GATEWAY"===(this.config.endPointMode||"CLOUD_API")},e.prototype.uploadFile=function(e,t){return p(this,void 0,void 0,(function(){var r,n,o,i,s,a,c,l,d,h,p,g,b,_,E,O,T,A,R,P,C,N,x,L;return v(this,(function(v){switch(v.label){case 0:if(r=e.cloudPath,n=e.filePath,o=e.onUploadProgress,N=e.method,i=void 0===N?"put":N,x=e.headers,s=void 0===x?{}:x,a=e.fileContent,!w(r)||!n&&!a)throw new Error(JSON.stringify({code:m.INVALID_PARAMS,msg:"[".concat(I,".uploadFile] invalid params")}));return c={put:u.put,post:u.post}[i.toLocaleLowerCase()]||u.put,[4,this.getUploadMetadata({cloudPath:r,method:c,headers:c===u.put?s:void 0,customReqOpts:e.customReqOpts})];case 1:return l=v.sent(),d=l.data,h=l.requestId,p=d.url,g=d.authorization,b=d.token,_=d.fileId,E=d.cosFileId,O=d.download_url,A=f(f({},T={url:p,file:n,name:r,onUploadProgress:o,fileContent:a,fileId:_,requestId:h}),{method:u.put,headers:f(f({},s),{authorization:g,"x-cos-meta-fileid":E,"x-cos-security-token":b})}),R=f(f({},T),{method:u.post,data:{key:r,signature:g,"x-cos-meta-fileid":E,success_action_status:"201","x-cos-security-token":b}}),(L={})[u.put]={params:A,isSuccess:function(e){return e>=200&&e<300}},L[u.post]={params:R,isSuccess:function(e){return 201===e}},P=L,[4,this.request.upload(P[c].params)];case 2:return C=v.sent(),P[c].isSuccess(C.statusCode)?[2,S(t,null,{fileID:_,download_url:O,requestId:h})]:[2,S(t,new Error("[".concat(y(),"][").concat(m.OPERATION_FAIL,"][").concat(I,"]:").concat(C.data)))]}}))}))},e.prototype.getUploadMetadata=function(e,t){return p(this,void 0,void 0,(function(){var r,n,o,i,s,a,c,l;return v(this,(function(f){switch(f.label){case 0:if(r=e.cloudPath,n=e.method,o=e.headers,!w(r))throw new Error(JSON.stringify({code:m.INVALID_PARAMS,msg:"[".concat(I,".getUploadMetadata] invalid cloudPath")}));i=this.request,s="storage.getUploadMetadata",f.label=1;case 1:return f.trys.push([1,6,,7]),a=void 0,c={path:r},n&&(c.method=n),n===u.put&&o&&(c.headers=o),this.isGateWay()?[4,O(i,c,e.customReqOpts)]:[3,3];case 2:return a=f.sent(),[3,5];case 3:return[4,i.send(s,c,e.customReqOpts)];case 4:a=f.sent(),f.label=5;case 5:return[2,S(t,null,a)];case 6:return l=f.sent(),[2,S(t,l)];case 7:return[2]}}))}))},e.prototype.deleteFile=function(e,t){return p(this,void 0,void 0,(function(){var r,n,o,i,s,a,u,c;return v(this,(function(l){switch(l.label){case 0:if(!(r=e.fileList)||!b(r)||0===r.length)throw new Error(JSON.stringify({code:m.INVALID_PARAMS,msg:"[".concat(I,".deleteFile] fileList must not be empty")}));for(n=0,o=r;n<o.length;n++)if(!(i=o[n])||!w(i))throw new Error(JSON.stringify({code:m.INVALID_PARAMS,msg:"[".concat(I,".deleteFile] fileID must be string")}));return s="storage.batchDeleteFile",a=this.request,u={},this.isGateWay()?[4,A(a,{fileList:r},e.customReqOpts)]:[3,2];case 1:return u=l.sent(),[3,4];case 2:return[4,a.send(s,{fileid_list:r},e.customReqOpts)];case 3:u=l.sent(),l.label=4;case 4:return u.code?[2,S(t,null,u)]:(c={fileList:u.data.delete_list,requestId:u.requestId},[2,S(t,null,c)])}}))}))},e.prototype.getTempFileURL=function(e,t){return p(this,void 0,void 0,(function(){var r,n,o,i,s,a,u,c;return v(this,(function(l){switch(l.label){case 0:if(!(r=e.fileList)||!b(r)||0===r.length)throw new Error(JSON.stringify({code:m.INVALID_PARAMS,msg:"[".concat(I,".getTempFileURL] fileList must not be empty")}));for(n=[],o=0,i=r;o<i.length;o++)if(s=i[o],_(s)){if(!Object.prototype.hasOwnProperty.call(s,"fileID"))throw new Error(JSON.stringify({code:m.INVALID_PARAMS,msg:"[".concat(I,".getTempFileURL] file info must include fileID")}));n.push({fileid:s.fileID,max_age:s.maxAge||7200})}else{if(!w(s))throw new Error(JSON.stringify({code:m.INVALID_PARAMS,msg:"[".concat(I,".getTempFileURL] invalid fileList")}));n.push({fileid:s})}return a="storage.batchGetDownloadUrl",u=this.request,c={},this.isGateWay()?[4,T(u,{convertedFileList:n},e.customReqOpts)]:[3,2];case 1:return c=l.sent(),[3,4];case 2:return[4,u.send(a,{file_list:n},e.customReqOpts)];case 3:c=l.sent(),l.label=4;case 4:return c.code?[2,S(t,null,c)]:[2,S(t,null,{fileList:c.data.download_list,requestId:c.requestId})]}}))}))},e.prototype.downloadFile=function(e,t){return p(this,void 0,void 0,(function(){var r,n,o,i,s,a;return v(this,(function(u){switch(u.label){case 0:if(r=e.fileID,!w(r))throw new Error(JSON.stringify({code:m.INVALID_PARAMS,msg:"[".concat(I,".getTempFileURL] fileID must be string")}));return[4,this.getTempFileURL.call(this,{fileList:[{fileID:r,maxAge:600}],customReqOpts:e.customReqOpts})];case 1:return n=u.sent(),"SUCCESS"!==(o=n.fileList[0]).code?[2,S(t,o)]:(i=this.request,s=encodeURI(o.download_url),[4,i.download({url:s,tempFilePath:e.tempFilePath})]);case 2:return a=u.sent(),[2,S(t,null,a)]}}))}))},e.prototype.copyFile=function(e,t){return p(this,void 0,void 0,(function(){var r,n,o,i,s,a,u,c,l;return v(this,(function(f){switch(f.label){case 0:if(!(r=e.fileList)||!b(r)||0===r.length)throw new Error(JSON.stringify({code:m.INVALID_PARAMS,msg:"[".concat(I,".copyFile] fileList must not be empty")}));for(n=[],o=0,i=r;o<i.length;o++){if(s=i[o],a=s.srcPath,u=s.dstPath,!a||!u||"string"!=typeof a||"string"!=typeof u)throw new Error(JSON.stringify({code:m.INVALID_PARAMS,msg:"[".concat(I,".copyFile] srcPath and dstPath may not be empty")}));if(a===u)throw new Error(JSON.stringify({code:m.INVALID_PARAMS,msg:"[".concat(I,".copyFile] srcPath and dstPath can not be the same")}));n.push({src_path:a,dst_path:u,overwrite:s.overwrite,remove_original:s.removeOriginal})}return c=this.request,l={},this.isGateWay()?[4,R(c,{convertedFileList:n},e.customReqOpts)]:[3,2];case 1:return l=f.sent(),[3,4];case 2:return[4,c.send("storage.batchCopyFile",{file_list:n},e.customReqOpts)];case 3:l=f.sent(),f.label=4;case 4:return l.code?[2,S(t,null,l)]:[2,S(t,null,{fileList:l.data.copy_list,requestId:l.requestId})]}}))}))},e.prototype.getFileInfo=function(e){var t;return p(this,void 0,void 0,(function(){var r,n=this;return v(this,(function(o){switch(o.label){case 0:return[4,this.getTempFileURL(e)];case 1:return(null==(r=o.sent())?void 0:r.fileList)&&(null===(t=null==r?void 0:r.fileList)||void 0===t?void 0:t.length)>0?[4,Promise.all(r.fileList.map((function(e){return p(n,void 0,void 0,(function(){var t,r,n,o,i;return v(this,(function(s){switch(s.label){case 0:if("SUCCESS"!==e.code)return[2,{code:e.code,fileID:e.fileID,tempFileURL:e.tempFileURL,message:e.message}];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.request.fetch({url:e.tempFileURL,method:"HEAD"})];case 2:return t=s.sent(),r=t.header,Headers&&r instanceof Headers&&(r=Object.fromEntries(t.header.entries())),n=parseInt(r["content-length"])||0,o=r["content-type"]||"",[400,404].includes(Number(t.statusCode))?[2,{code:"FILE_NOT_FOUND",fileID:e.fileID,tempFileURL:e.tempFileURL,message:"file not found"}]:[2,{code:e.code,fileID:e.fileID,tempFileURL:e.tempFileURL,cloudId:e.fileID,fileName:e.fileID.split("/").pop(),contentType:o,mime:o.split(";")[0].trim(),size:n,etag:r.etag||"",lastModified:r["last-modified"]||"",cacheControl:r["cache-control"]||""}];case 3:return i=s.sent(),[2,{code:"FETCH_FILE_INFO_ERROR",fileID:e.fileID,tempFileURL:e.tempFileURL,message:i.message}];case 4:return[2]}}))}))})))]:[3,3];case 2:return[2,{fileList:o.sent(),requestId:r.requestId}];case 3:return[2,{fileList:[],requestId:r.requestId}]}}))}))},d([E({customInfo:{className:"Cloudbase",methodName:"uploadFile"},title:"上传文件失败",messages:["请确认以下各项:"," 1 - 调用 uploadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(g)]}),h("design:type",Function),h("design:paramtypes",[Object,Function]),h("design:returntype",Promise)],e.prototype,"uploadFile",null),d([E({customInfo:{className:"Cloudbase",methodName:"getUploadMetadata"},title:"获取上传元信息失败",messages:["请确认以下各项:"," 1 - 调用 getUploadMetadata() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(g)]}),h("design:type",Function),h("design:paramtypes",[Object,Function]),h("design:returntype",Promise)],e.prototype,"getUploadMetadata",null),d([E({customInfo:{className:"Cloudbase",methodName:"deleteFile"},title:"删除文件失败",messages:["请确认以下各项:"," 1 - 调用 deleteFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(g)]}),h("design:type",Function),h("design:paramtypes",[Object,Function]),h("design:returntype",Promise)],e.prototype,"deleteFile",null),d([E({customInfo:{className:"Cloudbase",methodName:"getTempFileURL"},title:"获取文件下载链接",messages:["请确认以下各项:"," 1 - 调用 getTempFileURL() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(g)]}),h("design:type",Function),h("design:paramtypes",[Object,Function]),h("design:returntype",Promise)],e.prototype,"getTempFileURL",null),d([E({customInfo:{className:"Cloudbase",methodName:"downloadFile"},title:"下载文件失败",messages:["请确认以下各项:"," 1 - 调用 downloadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(g)]}),h("design:type",Function),h("design:paramtypes",[Object,Function]),h("design:returntype",Promise)],e.prototype,"downloadFile",null),d([E({customInfo:{className:"Cloudbase",methodName:"copyFile"},title:"批量复制文件",messages:["请确认以下各项:"," 1 - 调用 copyFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(g)]}),h("design:type",Function),h("design:paramtypes",[Object,Function]),h("design:returntype",Promise)],e.prototype,"copyFile",null),e}(),C=new P,N={name:I,entity:{uploadFile:C.uploadFile,deleteFile:C.deleteFile,getTempFileURL:C.getTempFileURL,downloadFile:C.downloadFile,getUploadMetadata:C.getUploadMetadata,copyFile:C.copyFile,getFileInfo:C.getFileInfo,isGateWay:C.isGateWay}},x=function(e){function t(t){var r=e.call(this)||this;return r.shouldThrowOnError=!1,r.bucketId="",r.context=t,r}return l(t,e),Object.defineProperty(t.prototype,"config",{get:function(){var e;return null===(e=this.context)||void 0===e?void 0:e.config},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"request",{get:function(){var e;return null===(e=this.context)||void 0===e?void 0:e.request},enumerable:!1,configurable:!0}),t.prototype.throwOnError=function(){return this.shouldThrowOnError=!0,this},t.prototype.from=function(e){return this.bucketId=e||"",this},t.prototype.upload=function(e,t,r){return p(this,void 0,void 0,(function(){var n,o,i,s,u,c,l,d,h;return v(this,(function(p){switch(p.label){case 0:n=f({upsert:!0},r),o=n.cacheControl,i=n.contentType,s=n.metadata,p.label=1;case 1:return p.trys.push([1,3,,4]),u=this._getCloudPath(e),c={cloudPath:u,filePath:t},(o||i||s)&&(l={},o&&(l["cache-control"]=o),i&&(l["content-type"]=i),s&&(l["x-cos-metadata-metadata"]=this.toBase64(JSON.stringify(s))),c.headers=l),[4,this.uploadFile(c)];case 2:if(!(d=p.sent()).fileID)throw new Error(JSON.stringify({code:m.OPERATION_FAIL,msg:"[".concat(I,".update] no fileID returned")}));return[2,{data:{id:d.fileID,path:e,fullPath:e},error:null}];case 3:if(h=p.sent(),this.shouldThrowOnError)throw h;if(a(h))return[2,{data:null,error:h}];throw h;case 4:return[2]}}))}))},t.prototype.uploadToSignedUrl=function(e,t,r,n){return p(this,void 0,void 0,(function(){return v(this,(function(t){return[2,this.upload(e,r,n)]}))}))},t.prototype.createSignedUploadUrl=function(e){return p(this,void 0,void 0,(function(){var t,r,n;return v(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),t=this._getCloudPath(e),[4,this.getUploadMetadata({cloudPath:t})];case 1:return[2,{data:{signedUrl:(r=o.sent().data).url,token:r.token,path:e,authorization:r.authorization,id:r.fileId,cosFileId:r.cosFileId,downloadUrl:r.download_url},error:null}];case 2:if(n=o.sent(),this.shouldThrowOnError)throw n;return[2,{data:null,error:n instanceof s?n:new s(n.message)}];case 3:return[2]}}))}))},t.prototype.update=function(e,t,r){return p(this,void 0,void 0,(function(){return v(this,(function(n){return[2,this.upload(e,t,f(f({},r),{upsert:!0}))]}))}))},t.prototype.move=function(e,t){return p(this,void 0,void 0,(function(){var r,n;return v(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.copyFile({fileList:[{srcPath:this._getCloudPath(e),dstPath:this._getCloudPath(t),overwrite:!0,removeOriginal:!0}]})];case 1:if((r=o.sent()).fileList[0].code&&"SUCCESS"!==r.fileList[0].code)throw new s(r.fileList[0].message||"Move failed");return[2,{data:{message:"File moved from ".concat(e," to ").concat(t)},error:null}];case 2:if(n=o.sent(),this.shouldThrowOnError)throw n;if(a(n))return[2,{data:null,error:n}];throw n;case 3:return[2]}}))}))},t.prototype.copy=function(e,t){return p(this,void 0,void 0,(function(){var r,n;return v(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.copyFile({fileList:[{srcPath:this._getCloudPath(e),dstPath:this._getCloudPath(t),overwrite:!0,removeOriginal:!1}]})];case 1:if((r=o.sent()).fileList[0].code&&"SUCCESS"!==r.fileList[0].code)throw new s(r.fileList[0].message||"Copy failed");return[2,{data:{path:this._getCloudPath(t)},error:null}];case 2:if(n=o.sent(),this.shouldThrowOnError)throw n;if(a(n))return[2,{data:null,error:n}];throw n;case 3:return[2]}}))}))},t.prototype.createSignedUrl=function(e,t,r){return p(this,void 0,void 0,(function(){var n,o,i,u,c,l,f;return v(this,(function(d){switch(d.label){case 0:return d.trys.push([0,2,,3]),n=this._normalizeCloudId(e),[4,this.getTempFileURL({fileList:[{fileID:n,maxAge:t}]})];case 1:if("SUCCESS"!==(o=d.sent()).fileList[0].code)throw new s("Failed to create signed URL: [".concat(o.fileList[0].code,"] ").concat(o.fileList[0].fileID));return i=o.fileList[0].download_url,u=[],void 0!==(null==r?void 0:r.download)&&("string"==typeof r.download?u.push("download=".concat(encodeURIComponent(r.download))):!0===r.download&&u.push("download=true")),(null==r?void 0:r.transform)&&(c=this._transformOptsToQueryString(r.transform))&&u.push(c),u.length>0&&(l=i.includes("?")?"&":"?",i="".concat(i).concat(l).concat(u.join("&"))),[2,{data:{signedUrl:i},error:null}];case 2:if(f=d.sent(),this.shouldThrowOnError)throw f;if(a(f))return[2,{data:null,error:f}];throw f;case 3:return[2]}}))}))},t.prototype.createSignedUrls=function(e,t){return p(this,void 0,void 0,(function(){var r,n,o=this;return v(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),r=e.map((function(e){return{fileID:o._normalizeCloudId(e),maxAge:t}})),[4,this.getTempFileURL({fileList:r})];case 1:return[2,{data:i.sent().fileList.map((function(t,r){return{path:e[r],signedUrl:t.tempFileURL||"",error:"SUCCESS"===t.code?null:t.message}})),error:null}];case 2:if(n=i.sent(),this.shouldThrowOnError)throw n;if(a(n))return[2,{data:null,error:n}];throw n;case 3:return[2]}}))}))},t.prototype.download=function(e,t){return p(this,void 0,void 0,(function(){var r,n,o=this;return v(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),n={},[4,p(o,void 0,void 0,(function(){var r,n,o,i;return v(this,(function(a){switch(a.label){case 0:return[4,this.createSignedUrl(e,600,{transform:t})];case 1:if((r=a.sent()).error)throw r.error;return n=encodeURI(null===(i=r.data)||void 0===i?void 0:i.signedUrl),[4,this.request.reqClass.get({url:n,headers:{},responseType:"blob"})];case 2:if(!(o=a.sent().data))throw new s("Download failed: no file content");return[2,new Blob([o])]}}))}))];case 1:return[2,(n.data=i.sent(),n.error=null,n)];case 2:if(r=i.sent(),this.shouldThrowOnError)throw r;if(a(r))return[2,{data:null,error:r}];throw r;case 3:return[2]}}))}))},t.prototype.info=function(e){return p(this,void 0,void 0,(function(){var t,r,n,o,i,a,u,c;return v(this,(function(l){switch(l.label){case 0:return l.trys.push([0,2,,3]),t=e.startsWith("cloud://"),r=t?this._extractPathFromFileId(e):e,n=t?this._extractBucketFromFileId(e):this.bucketId,[4,this.getFileInfo({fileList:[this._normalizeCloudId(e)]})];case 1:if(o=l.sent(),"SUCCESS"!==(i=o.fileList[0]).code)throw new s(i.message);return a=(new Date).toISOString(),u=(i.lastModified?new Date(i.lastModified):new Date).toISOString(),[2,{data:{id:i.fileID,version:"1",name:r,bucketId:n,updatedAt:u,createdAt:u,lastAccessedAt:a,size:i.size,cacheControl:i.cacheControl,contentType:i.contentType,etag:i.etag,lastModified:u,metadata:{}},error:null}];case 2:if(c=l.sent(),this.shouldThrowOnError)throw c;return[2,{data:null,error:c instanceof s?c:new s(c.message)}];case 3:return[2]}}))}))},t.prototype.exists=function(e){return p(this,void 0,void 0,(function(){var t,r,n;return v(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.getFileInfo({fileList:[this._normalizeCloudId(e)]})];case 1:if(t=o.sent(),"FILE_NOT_FOUND"===(r=t.fileList[0]).code)return[2,{data:!1,error:null}];if("SUCCESS"!==r.code)throw new s(r.message);return[2,{data:!0,error:null}];case 2:if(n=o.sent(),this.shouldThrowOnError)throw n;if(a(n))return[2,{data:null,error:n}];throw n;case 3:return[2]}}))}))},t.prototype.getPublicUrl=function(e,t){return p(this,void 0,void 0,(function(){var r;return v(this,(function(n){switch(n.label){case 0:return[4,this.createSignedUrl(e,600,t)];case 1:return(r=n.sent()).data?[2,{data:{publicUrl:r.data.signedUrl}}]:[2,{data:null,error:r.error}]}}))}))},t.prototype.remove=function(e){return p(this,void 0,void 0,(function(){var t,r,n,o,i,u,c,l,f,d,h=this;return v(this,(function(p){switch(p.label){case 0:for(p.trys.push([0,3,,4]),t=10,r=[],n=0;n<e.length;n+=t)r.push(e.slice(n,n+t));return[4,Promise.all(r.map((function(e){return Promise.all(e.map((function(e){return h.info(e)})))})))];case 1:return o=p.sent(),i=new Map,o.flat().forEach((function(r,n){r.data&&i.set(e[Math.floor(n/t)*t+n%t],r.data)})),u=e.map((function(e){return h._normalizeCloudId(e)})),[4,this.deleteFile({fileList:u})];case 2:if(c=p.sent(),(l=c.fileList.filter((function(e){return"SUCCESS"!==e.code}))).length>0)throw new s("Delete failed for ".concat(l.length," file(s)"));return f=(new Date).toISOString(),[2,{data:e.map((function(e){var t=i.get(e);return{name:null==t?void 0:t.name,id:null==t?void 0:t.id,bucket_id:null==t?void 0:t.bucketId,owner:void 0,updated_at:(null==t?void 0:t.updatedAt)||f,created_at:null==t?void 0:t.createdAt,last_accessed_at:(null==t?void 0:t.lastAccessedAt)||f,metadata:(null==t?void 0:t.metadata)||{},buckets:{id:null==t?void 0:t.bucketId,name:null==t?void 0:t.bucketId,owner:void 0,public:!1,created_at:"",updated_at:f}}})),error:null}];case 3:if(d=p.sent(),this.shouldThrowOnError)throw d;if(a(d))return[2,{data:null,error:d}];throw d;case 4:return[2]}}))}))},t.prototype.list=function(){return p(this,void 0,void 0,(function(){return v(this,(function(e){throw new s("Not implemented")}))}))},t.prototype._getCloudPath=function(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")},t.prototype._normalizeCloudId=function(e){var t;if(/^cloud:\/\//.test(e))return e;var r=this._getCloudPath(e);if(!this.bucketId)throw new s("bucketId is not set");var n=(null===(t=this.config)||void 0===t?void 0:t.env)||"";return n?"cloud://".concat(n,".").concat(this.bucketId,"/").concat(r):void 0},t.prototype.toBase64=function(e){return"undefined"!=typeof Buffer?Buffer.from(e).toString("base64"):btoa(e)},t.prototype._transformOptsToQueryString=function(e){var t=["imageMogr2"];if(e.width||e.height){var r=e.width||"",n=e.height||"";"fill"===e.resize?t.push("thumbnail/".concat(r,"x").concat(n,"!")):"contain"===e.resize?t.push("thumbnail/".concat(r,"x").concat(n)):t.push("thumbnail/".concat(r,"x").concat(n,"^"))}if(e.format&&"origin"!==e.format&&t.push("format/".concat(e.format)),void 0!==e.quality){var o=Math.max(1,Math.min(100,e.quality));t.push("quality/".concat(o))}return t.join("/")},t.prototype._extractPathFromFileId=function(e){var t=e.replace(/^cloud:\/\//,"").split("/");return t.length<2?e:t.slice(1).join("/")},t.prototype._extractBucketFromFileId=function(e){var t=e.replace(/^cloud:\/\//,"").split("/");if(t.length<1)return"";var r=t[0],n=r.indexOf(".");return-1===n?r:r.substring(n+1)},t}(P),L={name:"".concat(I,"/supabase"),IIFE:!0,entity:function(){var e=new WeakMap;Object.defineProperty(this.prototype,"storage",{get:function(){if(e.has(this))return e.get(this);var t=this,r=new Proxy({},{get:function(e,r){return"config"===r?t.config:"request"===r?t.request:void 0}}),n=new x(r);return e.set(this,n),n},configurable:!0,enumerable:!0})}};try{cloudbase.registerComponent(N),cloudbase.registerComponent(L)}catch(e){}function U(e){try{e.registerComponent(N),e.registerComponent(L)}catch(e){console.warn(e)}}try{window.registerStorage=U}catch(e){}},8182:function(e,t,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.useDefaultAdapter=t.useAdapters=t.RUNTIME=void 0;var a,u=s(r(4274)),c=r(5605);!function(e){e.WEB="web",e.WX_MP="wx_mp"}(a=t.RUNTIME||(t.RUNTIME={})),t.useAdapters=function(e,t){for(var r=0,o=(0,c.isArray)(e)?e:[e];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(t)),runtime:u}}},t.useDefaultAdapter=function(){return{adapter:n({},u.genAdapter()),runtime:a.WEB}}},4274:function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)},s=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},a=this&&this.__generator||function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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(t,"__esModule",{value:!0}),t.WebRequest=t.genAdapter=void 0;var u=r(2829),c=r(5605),l=r(2946),f=function(e){function t(t){var r=e.call(this)||this,n=t.timeout,o=t.timeoutMsg,i=t.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=o||"请求超时",r.restrictedMethods=i||["get","post","upload","download"],r}return o(t,e),t.prototype.get=function(e){return this.request(i(i({},e),{method:"get"}),this.restrictedMethods.includes("get"))},t.prototype.post=function(e){return this.request(i(i({},e),{method:"post"}),this.restrictedMethods.includes("post"))},t.prototype.put=function(e){return this.request(i(i({},e),{method:"put"}))},t.prototype.upload=function(e){var t=e.data,r=e.file,n=e.name,o=e.method,s=e.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(t).forEach((function(e){c.append(e,t[e])})),c.append("key",n),c.append("file",r),this.request(i(i({},e),{data:c,method:u}),this.restrictedMethods.includes("upload"))):this.request(i(i({},e),{method:"put",headers:a,body:r}),this.restrictedMethods.includes("upload"))},t.prototype.download=function(e){return s(this,void 0,void 0,(function(){var t,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({},e),{headers:{},responseType:"blob"}))];case 1:return t=s.sent().data,r=window.URL.createObjectURL(new Blob([t])),n=decodeURIComponent(new URL(e.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(t){t({statusCode:200,tempFilePath:e.url})}))]}}))}))},t.prototype.fetch=function(e){var t;return s(this,void 0,void 0,(function(){var r,n,o,u,c,l,f,d,h,p,v,y,m,g=this;return a(this,(function(b){switch(b.label){case 0:return r=new AbortController,n=e.url,o=e.enableAbort,u=void 0!==o&&o,c=e.stream,l=void 0!==c&&c,f=e.signal,d=e.timeout,h=e.shouldThrowOnError,p=void 0===h||h,v=null!=d?d:this.timeout,f&&(f.aborted&&r.abort(),f.addEventListener("abort",(function(){return r.abort()}))),y=null,u&&v&&(y=setTimeout((function(){console.warn(g.timeoutMsg),r.abort(new Error(g.timeoutMsg))}),v)),[4,fetch(n,i(i({},e),{signal:r.signal})).then((function(e){return s(g,void 0,void 0,(function(){var t,r,n;return a(this,(function(o){switch(o.label){case 0:return clearTimeout(y),p?e.ok?(t=e,[3,3]):[3,1]:[3,4];case 1:return n=(r=Promise).reject,[4,e.json()];case 2:t=n.apply(r,[o.sent()]),o.label=3;case 3:return[2,t];case 4:return[2,e]}}))}))})).catch((function(e){if(clearTimeout(y),p)return Promise.reject(e)}))];case 1:return m=b.sent(),[2,{data:l?m.body:(null===(t=m.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))?m.json():m.text(),statusCode:m.status,header:m.headers}]}}))}))},t.prototype.request=function(e,t){var r=this;void 0===t&&(t=!1);var n=String(e.method).toLowerCase()||"get";return new Promise((function(o){var i,s,a=e.url,u=e.headers,f=void 0===u?{}:u,d=e.data,h=e.responseType,p=e.withCredentials,v=e.body,y=e.onUploadProgress,m=(0,c.formatUrl)((0,l.getProtocol)(),a,"get"===n?d:{}),g=new XMLHttpRequest;g.open(n,m),h&&(g.responseType=h),Object.keys(f).forEach((function(e){g.setRequestHeader(e,f[e])})),y&&g.upload.addEventListener("progress",y),g.onreadystatechange=function(){var e={};if(4===g.readyState){var t=g.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};t.forEach((function(e){var t=e.split(": "),n=t.shift().toLowerCase(),o=t.join(": ");r[n]=o})),e.header=r,e.statusCode=g.status;try{e.data="blob"===h?g.response:JSON.parse(g.responseText)}catch(t){e.data="blob"===h?g.response:g.responseText}clearTimeout(i),o(e)}},t&&r.timeout&&(i=setTimeout((function(){console.warn(r.timeoutMsg),g.abort()}),r.timeout)),s=(0,c.isFormData)(d)?d:"application/x-www-form-urlencoded"===f["content-type"]?(0,c.toQueryString)(d):v||(d?JSON.stringify(d):void 0),p&&(g.withCredentials=!0),g.send(s)}))},t}(u.AbstractSDKRequest);t.WebRequest=f,t.genAdapter=function(){return{type:"default",root:window,reqClass:f,wsClass:WebSocket,localStorage:localStorage}}},2946:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.COMMUNITY_SITE_URL=t.IS_DEBUG_MODE=t.getProtocol=t.setProtocol=t.getSdkName=t.setSdkName=void 0;var r="@cloudbase/js-sdk";t.setSdkName=function(e){r=e},t.getSdkName=function(){return r};var n="https:";t.setProtocol=function(e){n=e},t.getProtocol=function(){return n},t.IS_DEBUG_MODE=!1,t.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},6205:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ERRORS=void 0,t.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(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.OATUH_LOGINTYPE=void 0,o(r(2946),t),o(r(6205),t),t.OATUH_LOGINTYPE="constants"},7718:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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(t,"__esModule",{value:!0}),t.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(e){var t=e.err,r=e.className,n=e.methodName,o=e.sourceLink;if(!o)return null;var i,s=t.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(e){return u.test(e)}));if(-1!==f){var d=s.filter((function(e,t){return t>f}));d.unshift(s[f].replace(l,"".concat(r,".").concat(n)).replace(c,o)),(i=new Error).stack="".concat(a?"@debugger":"Error","\n").concat(d.join("\n"))}return i}t.catchErrorsDecorator=function(e){var t=e.mode,r=void 0===t?"async":t,a=e.customInfo,f=void 0===a?{}:a,d=e.title,h=e.messages,p=void 0===h?[]:h;return function(e,t,a){if(s.IS_DEBUG_MODE){var h=f.className||e.constructor.name,v=f.methodName||t,y=a.value,m=function(){var e="",t=(new Error).stack.split("\n"),r=t.findIndex((function(e){return u.test(e)}));if(-1!==r){var n=c.exec(t[r+1]||"");e=n?n[0]:""}return e}();a.value="sync"===r?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=l({err:new Error,className:h,methodName:v,sourceLink:m});try{return y.apply(this,e)}catch(e){var n=e,o=e.message,s=e.error,a=e.error_description,u={title:d||"".concat(h,".").concat(v," failed"),content:[{type:"error",body:e}]};if(o&&/^\{.*\}$/.test(o)){var c=JSON.parse(o);u.subtitle=o,c.code&&(r?(r.code=c.code,r.msg=c.msg):(e.code=c.code,e.message=c.msg),n=r||e,u.content=p.map((function(e){return{type:"info",body:e}})))}throw s&&a&&(u.subtitle=a,r?(r.code=s,r.msg=a):(e.code=s,e.message=a),n=r||e,u.content=p.map((function(e){return{type:"info",body:e}}))),(0,i.printGroupLog)(u),n}}:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n(this,void 0,void 0,(function(){var t,r,n,s,a,u,c,f;return o(this,(function(o){switch(o.label){case 0:t=l({err:new Error,className:h,methodName:v,sourceLink:m}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,y.apply(this,e)];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:d||"".concat(h,".").concat(v," failed"),content:[{type:"error",body:r}]},s&&/^\{.*\}$/.test(s)&&(f=JSON.parse(s),c.subtitle=f,f.code&&(t?(t.code=f.code,t.message=f.msg):(r.code=f.code,r.message=f.msg),n=t||r,c.content=p.map((function(e){return{type:"info",body:e}})))),a&&u&&(c.subtitle=u,t?(t.code=a,t.msg=u):(r.code=a,r.message=u),n=t||r,c.content=p.map((function(e){return{type:"info",body:e}}))),(0,i.printGroupLog)(c),n;case 4:return[2]}}))}))}}}}},141:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(7718),t)},6197:function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},s=this&&this.__generator||function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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(t,"__esModule",{value:!0}),t.CloudbaseCache=void 0;var a=r(2829),u=r(5605),c=r(794),l=function(e){function t(t){var r=e.call(this)||this;return r.root=t,t.tcbCacheObject||(t.tcbCacheObject={}),r}return o(t,e),t.prototype.setItem=function(e,t){this.root.tcbCacheObject[e]=t},t.prototype.getItem=function(e){return this.root.tcbCacheObject[e]},t.prototype.removeItem=function(e){delete this.root.tcbCacheObject[e]},t.prototype.clear=function(){delete this.root.tcbCacheObject},t}(a.AbstractStorage),f=function(){function e(e){this.keys={};var t=e.persistence,r=e.platformInfo,n=void 0===r?{}:r,o=e.keys,i=void 0===o?{}:o;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||t,this.storage=function(e,t){switch(e){case"local":default:return t.localStorage?t.localStorage:((0,u.printWarn)(c.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new l(t.root));case"none":return new l(t.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(e.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),e.prototype.setStore=function(e,t,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:t};this.storage.setItem(e,JSON.stringify(n))}catch(e){throw new Error(JSON.stringify({code:c.ERRORS.OPERATION_FAIL,msg:"[".concat((0,c.getSdkName)(),"][").concat(c.ERRORS.OPERATION_FAIL,"]setStore failed"),info:e}))}}else(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(e,t,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:t},[4,this.storage.setItem(e,JSON.stringify(n))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},e.prototype.getStore=function(e,t){var r;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return{IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(e){return""}t=t||"localCachev1";var n=this.storage.getItem(e);return n&&n.indexOf(t)>=0?JSON.parse(n).content:""}(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,t){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,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return[2,{IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(e){return[2,""]}return t=t||"localCachev1",[4,this.storage.getItem(e)];case 1:return(n=o.sent())&&n.indexOf(t)>=0?[2,JSON.parse(n).content]:[2,""]}}))}))},e.prototype.removeStore=function(e){"async"!==this.mode?this.storage.removeItem(e):(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.storage.removeItem(e)];case 1:return t.sent(),[2]}}))}))},e}();t.CloudbaseCache=f},9689:function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.removeEventListener=t.activateEvent=t.addEventListener=t.CloudbaseEventEmitter=t.IErrorEvent=t.CloudbaseEvent=void 0;var s=r(5605),a=function(e,t){this.data=t||null,this.name=e};t.CloudbaseEvent=a;var u=function(e){function t(t,r){var n=e.call(this,"error",{error:t,data:r})||this;return n.error=t,n}return o(t,e),t}(a);t.IErrorEvent=u;var c=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){return function(e,t,r){r[e]=r[e]||[],r[e].push(t)}(e,t,this.listeners),this},e.prototype.off=function(e,t){return function(e,t,r){if(null==r?void 0:r[e]){var n=r[e].indexOf(t);-1!==n&&r[e].splice(n,1)}}(e,t,this.listeners),this},e.prototype.fire=function(e,t){if((0,s.isInstanceOf)(e,u))return console.error(e.error),this;var r=(0,s.isString)(e)?new a(e,t||{}):e,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},e.prototype.listens=function(e){return this.listeners[e]&&this.listeners[e].length>0},e}();t.CloudbaseEventEmitter=c;var l=new c;t.addEventListener=function(e,t){l.on(e,t)},t.activateEvent=function(e,t){void 0===t&&(t={}),l.fire(e,t)},t.removeEventListener=function(e,t){l.off(e,t)}},5605:function(e,t,r){"use strict";var n=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.parseCaptcha=t.parseQueryString=t.transformPhone=t.sleep=t.printGroupLog=t.throwError=t.printInfo=t.printError=t.printWarn=t.execCallback=t.createPromiseCallback=t.removeParam=t.getHash=t.getQuery=t.toQueryString=t.formatUrl=t.generateRequestId=t.genSeqId=t.isFormData=t.isInstanceOf=t.isNull=t.isPalinObject=t.isUndefined=t.isString=t.isArray=void 0;var o=r(794);t.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isString=function(e){return"string"==typeof e},t.isUndefined=function(e){return void 0===e},t.isPalinObject=function(e){return"[object Object]"===Object.prototype.toString.call(e)},t.isNull=function(e){return"[object Null]"===Object.prototype.toString.call(e)},t.isInstanceOf=function(e,t){return e instanceof t},t.isFormData=function(e){return"[object FormData]"===Object.prototype.toString.call(e)},t.genSeqId=function(){return Math.random().toString(16).slice(2)},t.generateRequestId=function(){var e=(new Date).getTime(),t=(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 e>0?(n=(e+n)%16|0,e=Math.floor(e/16)):(n=(t+n)%16|0,t=Math.floor(t/16)),("x"===r?n:7&n|8).toString(16)}))},t.formatUrl=function(e,t,r){void 0===r&&(r={});var n=/\?/.test(t),o="";return Object.keys(r).forEach((function(e){""===o?!n&&(t+="?"):o+="&",o+="".concat(e,"=").concat(encodeURIComponent(r[e]))})),/^http(s)?:\/\//.test(t+=o)?t:"".concat(e).concat(t)},t.toQueryString=function(e){void 0===e&&(e={});var t=[];return Object.keys(e).forEach((function(r){t.push("".concat(r,"=").concat(encodeURIComponent(e[r])))})),t.join("&")},t.getQuery=function(e,t){if("undefined"==typeof window)return!1;var r=t||decodeURIComponent(window.location.search),n=new RegExp("(^|&)".concat(e,"=([^&]*)(&|$)")),o=r.substr(r.indexOf("?")+1).match(n);return null!=o?o[2]:""},t.getHash=function(e){if("undefined"==typeof window)return"";var t=window.location.hash.match(new RegExp("[#?&/]".concat(e,"=([^&#]*)")));return t?t[1]:""},t.removeParam=function(e,t){var r=t.split("?")[0],n=[],o=-1!==t.indexOf("?")?t.split("?")[1]:"";if(""!==o){for(var i=(n=o.split("&")).length-1;i>=0;i-=1)n[i].split("=")[0]===e&&n.splice(i,1);r="".concat(r,"?").concat(n.join("&"))}return r},t.createPromiseCallback=function(){var e={};if(!Promise){(e=function(){}).promise={};var t=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}var r=new Promise((function(t,r){e=function(e,n){return e?r(e):t(n)}}));return e.promise=r,e},t.execCallback=function(e,t,r){if(void 0===r&&(r=null),e&&"function"==typeof e)return e(t,r);if(t)throw t;return r},t.printWarn=function(e,t){console.warn("[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t))},t.printError=function(e,t){console.error({code:e,msg:"[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t)})},t.printInfo=function(e,t){console.log("[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t))},t.throwError=function(e,t){throw new Error(JSON.stringify({code:e,msg:"[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t)}))},t.printGroupLog=function(e){var t,r=e.title,n=e.subtitle,o=void 0===n?"":n,i=e.content,s=void 0===i?[]:i,a=e.printTrace,u=void 0!==a&&a,c=e.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 d=f[l],h=d.type,p=d.body;switch(h){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===(t=console.groupEnd)||void 0===t||t.call(console)},t.sleep=function(e){return void 0===e&&(e=0),new Promise((function(t){return setTimeout(t,e)}))},t.transformPhone=function(e){return"+86".concat(e)},t.parseQueryString=function(e){e=e.replace(/^\?/,"");var t={};return e.split("&").forEach((function(e){var r=e.split("="),n=r[0],o=r[1];n=decodeURIComponent(n),o=decodeURIComponent(o),n&&(t[n]?Array.isArray(t[n])?t[n].push(o):t[n]=[t[n],o]:t[n]=o)})),t},t.parseCaptcha=function(e){var r={},o=e.match(/^(data:.*?)(\?[^#\s]*)?$/);if(o){e=o[1];var i=o[2];i&&(r=(0,t.parseQueryString)(i))}var s=r.token,a=n(r,["token"]);return/^data:/.test(e)&&!s?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(e)}:s?{state:a.state,token:s,captchaData:e}:{error:"unimplemented",error_description:"need to impl captcha data"}}},3616:function(e,t,r){"use strict";r.d(t,{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 y},Sg:function(){return m},Fk:function(){return v},eX:function(){return d},pM:function(){return p},tC:function(){return f}});var o={};r.r(o),r.d(o,{createPromiseCallback:function(){return U},execCallback:function(){return k},formatUrl:function(){return P},genSeqId:function(){return A},generateRequestId:function(){return R},getHash:function(){return x},getQuery:function(){return N},isArray:function(){return w},isFormData:function(){return T},isInstanceOf:function(){return O},isNull:function(){return I},isPalinObject:function(){return E},isString:function(){return _},isUndefined:function(){return S},parseCaptcha:function(){return H},parseQueryString:function(){return V},printError:function(){return j},printGroupLog:function(){return B},printInfo:function(){return q},printWarn:function(){return D},removeParam:function(){return L},sleep:function(){return W},throwError:function(){return M},toQueryString:function(){return C},transformPhone:function(){return F}});var i={};r.r(i),r.d(i,{Fk:function(){return X},xY:function(){return ee}});var s={};r.r(s),r.d(s,{q:function(){return ie}});var a={};r.r(a),r.d(a,{yE:function(){return ce}});var u={};r.r(u),r.d(u,{P:function(){return fe},$:function(){return le}});var c={};r.r(c),r.d(c,{D:function(){return me}});var l="@cloudbase/js-sdk";function f(e){l=e}function d(){return l}var h="https:";function p(e){h=e}var v=!1,y="https://support.qq.com/products/148793",m={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"},g=r(2829),b=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r};function w(e){return"[object Array]"===Object.prototype.toString.call(e)}function _(e){return"string"==typeof e}function S(e){return void 0===e}function E(e){return"[object Object]"===Object.prototype.toString.call(e)}function I(e){return"[object Null]"===Object.prototype.toString.call(e)}function O(e,t){return e instanceof t}function T(e){return"[object FormData]"===Object.prototype.toString.call(e)}function A(){return Math.random().toString(16).slice(2)}function R(){var e=(new Date).getTime(),t=(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 e>0?(n=(e+n)%16|0,e=Math.floor(e/16)):(n=(t+n)%16|0,t=Math.floor(t/16)),("x"===r?n:7&n|8).toString(16)}))}function P(e,t,r){void 0===r&&(r={});var n=/\?/.test(t),o="";return Object.keys(r).forEach((function(e){""===o?!n&&(t+="?"):o+="&",o+="".concat(e,"=").concat(encodeURIComponent(r[e]))})),/^http(s)?:\/\//.test(t+=o)?t:"".concat(e).concat(t)}function C(e){void 0===e&&(e={});var t=[];return Object.keys(e).forEach((function(r){t.push("".concat(r,"=").concat(encodeURIComponent(e[r])))})),t.join("&")}function N(e,t){if("undefined"==typeof window)return!1;var r=t||decodeURIComponent(window.location.search),n=new RegExp("(^|&)".concat(e,"=([^&]*)(&|$)")),o=r.substr(r.indexOf("?")+1).match(n);return null!=o?o[2]:""}var x=function(e){if("undefined"==typeof window)return"";var t=window.location.hash.match(new RegExp("[#?&/]".concat(e,"=([^&#]*)")));return t?t[1]:""};function L(e,t){var r=t.split("?")[0],n=[],o=-1!==t.indexOf("?")?t.split("?")[1]:"";if(""!==o){for(var i=(n=o.split("&")).length-1;i>=0;i-=1)n[i].split("=")[0]===e&&n.splice(i,1);r="".concat(r,"?").concat(n.join("&"))}return r}function U(){var e={};if(!Promise){(e=function(){}).promise={};var t=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}var r=new Promise((function(t,r){e=function(e,n){return e?r(e):t(n)}}));return e.promise=r,e}function k(e,t,r){if(void 0===r&&(r=null),e&&"function"==typeof e)return e(t,r);if(t)throw t;return r}function D(e,t){console.warn("[".concat(d(),"][").concat(e,"]:").concat(t))}function j(e,t){console.error({code:e,msg:"[".concat(d(),"][").concat(e,"]:").concat(t)})}function q(e,t){console.log("[".concat(d(),"][").concat(e,"]:").concat(t))}function M(e,t){throw new Error(JSON.stringify({code:e,msg:"[".concat(d(),"][").concat(e,"]:").concat(t)}))}function B(e){var t,r=e.title,n=e.subtitle,o=void 0===n?"":n,i=e.content,s=void 0===i?[]:i,a=e.printTrace,u=void 0!==a&&a,c=e.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 d=f[l],h=d.type,p=d.body;switch(h){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===(t=console.groupEnd)||void 0===t||t.call(console)}var W=function(e){return void 0===e&&(e=0),new Promise((function(t){return setTimeout(t,e)}))};function F(e){return"+86".concat(e)}var V=function(e){e=e.replace(/^\?/,"");var t={};return e.split("&").forEach((function(e){var r=e.split("="),n=r[0],o=r[1];n=decodeURIComponent(n),o=decodeURIComponent(o),n&&(t[n]?Array.isArray(t[n])?t[n].push(o):t[n]=[t[n],o]:t[n]=o)})),t};function H(e){var t={},r=e.match(/^(data:.*?)(\?[^#\s]*)?$/);if(r){e=r[1];var n=r[2];n&&(t=V(n))}var o=t.token,i=b(t,["token"]);return/^data:/.test(e)&&!o?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(e)}:o?{state:i.state,token:o,captchaData:e}:{error:"unimplemented",error_description:"need to impl captcha data"}}var $,G,z=($=function(e,t){return $=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},$(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}$(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),K=function(){return K=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},K.apply(this,arguments)},J=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},Y=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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(e){function t(t){var r=e.call(this)||this,n=t.timeout,o=t.timeoutMsg,i=t.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=o||"请求超时",r.restrictedMethods=i||["get","post","upload","download"],r}return z(t,e),t.prototype.get=function(e){return this.request(K(K({},e),{method:"get"}),this.restrictedMethods.includes("get"))},t.prototype.post=function(e){return this.request(K(K({},e),{method:"post"}),this.restrictedMethods.includes("post"))},t.prototype.put=function(e){return this.request(K(K({},e),{method:"put"}))},t.prototype.upload=function(e){var t=e.data,r=e.file,n=e.name,o=e.method,i=e.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(t).forEach((function(e){u.append(e,t[e])})),u.append("key",n),u.append("file",r),this.request(K(K({},e),{data:u,method:a}),this.restrictedMethods.includes("upload"))):this.request(K(K({},e),{method:"put",headers:s,body:r}),this.restrictedMethods.includes("upload"))},t.prototype.download=function(e){return J(this,void 0,void 0,(function(){var t,r,n,o;return Y(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.get(K(K({},e),{headers:{},responseType:"blob"}))];case 1:return t=i.sent().data,r=window.URL.createObjectURL(new Blob([t])),n=decodeURIComponent(new URL(e.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(t){t({statusCode:200,tempFilePath:e.url})}))]}}))}))},t.prototype.fetch=function(e){var t;return J(this,void 0,void 0,(function(){var r,n,o,i,s,a,u,c,l,f,d,h,p,v=this;return Y(this,(function(y){switch(y.label){case 0:return r=new AbortController,n=e.url,o=e.enableAbort,i=void 0!==o&&o,s=e.stream,a=void 0!==s&&s,u=e.signal,c=e.timeout,l=e.shouldThrowOnError,f=void 0===l||l,d=null!=c?c:this.timeout,u&&(u.aborted&&r.abort(),u.addEventListener("abort",(function(){return r.abort()}))),h=null,i&&d&&(h=setTimeout((function(){console.warn(v.timeoutMsg),r.abort(new Error(v.timeoutMsg))}),d)),[4,fetch(n,K(K({},e),{signal:r.signal})).then((function(e){return J(v,void 0,void 0,(function(){var t,r,n;return Y(this,(function(o){switch(o.label){case 0:return clearTimeout(h),f?e.ok?(t=e,[3,3]):[3,1]:[3,4];case 1:return n=(r=Promise).reject,[4,e.json()];case 2:t=n.apply(r,[o.sent()]),o.label=3;case 3:return[2,t];case 4:return[2,e]}}))}))})).catch((function(e){if(clearTimeout(h),f)return Promise.reject(e)}))];case 1:return p=y.sent(),[2,{data:a?p.body:(null===(t=p.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))?p.json():p.text(),statusCode:p.status,header:p.headers}]}}))}))},t.prototype.request=function(e,t){var r=this;void 0===t&&(t=!1);var n=String(e.method).toLowerCase()||"get";return new Promise((function(o){var i,s,a=e.url,u=e.headers,c=void 0===u?{}:u,l=e.data,f=e.responseType,d=e.withCredentials,p=e.body,v=e.onUploadProgress,y=P(h,a,"get"===n?l:{}),m=new XMLHttpRequest;m.open(n,y),f&&(m.responseType=f),Object.keys(c).forEach((function(e){m.setRequestHeader(e,c[e])})),v&&m.upload.addEventListener("progress",v),m.onreadystatechange=function(){var e={};if(4===m.readyState){var t=m.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};t.forEach((function(e){var t=e.split(": "),n=t.shift().toLowerCase(),o=t.join(": ");r[n]=o})),e.header=r,e.statusCode=m.status;try{e.data="blob"===f?m.response:JSON.parse(m.responseText)}catch(t){e.data="blob"===f?m.response:m.responseText}clearTimeout(i),o(e)}},t&&r.timeout&&(i=setTimeout((function(){console.warn(r.timeoutMsg),m.abort()}),r.timeout)),s=T(l)?l:"application/x-www-form-urlencoded"===c["content-type"]?C(l):p||(l?JSON.stringify(l):void 0),d&&(m.withCredentials=!0),m.send(s)}))},t}(g.AbstractSDKRequest),Z=function(){return Z=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Z.apply(this,arguments)};function X(e,t){for(var r=0,n=w(e)?e:[e];r<n.length;r++){var o=n[r],i=o.isMatch,s=o.genAdapter,a=o.runtime;if(i())return{adapter:Z({isMatch:i},s(t)),runtime:a}}}function ee(){return{adapter:Z({},{type:"default",root:window,reqClass:Q,wsClass:WebSocket,localStorage:localStorage}),runtime:G.WEB}}!function(e){e.WEB="web",e.WX_MP="wx_mp"}(G||(G={}));var te=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};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)}}(),re=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},ne=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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])}}},oe=function(e){function t(t){var r=e.call(this)||this;return r.root=t,t.tcbCacheObject||(t.tcbCacheObject={}),r}return te(t,e),t.prototype.setItem=function(e,t){this.root.tcbCacheObject[e]=t},t.prototype.getItem=function(e){return this.root.tcbCacheObject[e]},t.prototype.removeItem=function(e){delete this.root.tcbCacheObject[e]},t.prototype.clear=function(){delete this.root.tcbCacheObject},t}(g.AbstractStorage),ie=function(){function e(e){this.keys={};var t=e.persistence,r=e.platformInfo,n=void 0===r?{}:r,o=e.keys,i=void 0===o?{}:o;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||t,this.storage=function(e,t){switch(e){case"local":default:return t.localStorage?t.localStorage:(D(m.INVALID_PARAMS,"localStorage is not supported on current platform"),new oe(t.root));case"none":return new oe(t.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(e.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),e.prototype.setStore=function(e,t,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:t};this.storage.setItem(e,JSON.stringify(n))}catch(e){throw new Error(JSON.stringify({code:m.OPERATION_FAIL,msg:"[".concat(d(),"][").concat(m.OPERATION_FAIL,"]setStore failed"),info:e}))}}else D(m.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(e,t,r){return re(this,void 0,void 0,(function(){var n;return ne(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:t},[4,this.storage.setItem(e,JSON.stringify(n))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},e.prototype.getStore=function(e,t){var r;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return{IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(e){return""}t=t||"localCachev1";var n=this.storage.getItem(e);return n&&n.indexOf(t)>=0?JSON.parse(n).content:""}D(m.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,t){var r;return re(this,void 0,void 0,(function(){var n;return ne(this,(function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return[2,{IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(e){return[2,""]}return t=t||"localCachev1",[4,this.storage.getItem(e)];case 1:return(n=o.sent())&&n.indexOf(t)>=0?[2,JSON.parse(n).content]:[2,""]}}))}))},e.prototype.removeStore=function(e){"async"!==this.mode?this.storage.removeItem(e):D(m.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(e){return re(this,void 0,void 0,(function(){return ne(this,(function(t){switch(t.label){case 0:return[4,this.storage.removeItem(e)];case 1:return t.sent(),[2]}}))}))},e}(),se=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};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)}}(),ae=function(e,t){this.data=t||null,this.name=e},ue=function(e){function t(t,r){var n=e.call(this,"error",{error:t,data:r})||this;return n.error=t,n}return se(t,e),t}(ae),ce=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){return function(e,t,r){r[e]=r[e]||[],r[e].push(t)}(e,t,this.listeners),this},e.prototype.off=function(e,t){return function(e,t,r){if(null==r?void 0:r[e]){var n=r[e].indexOf(t);-1!==n&&r[e].splice(n,1)}}(e,t,this.listeners),this},e.prototype.fire=function(e,t){if(O(e,ue))return console.error(e.error),this;var r=_(e)?new ae(e,t||{}):e,n=r.name;if(this.listens(n)){r.target=this;for(var o=0,i=this.listeners[n]?function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}([],this.listeners[n],!0):[];o<i.length;o++)i[o].call(this,r)}return this},e.prototype.listens=function(e){return this.listeners[e]&&this.listeners[e].length>0},e}();new ce;var le=new ce,fe="lang_change",de=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},he=function(e,t){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=t.call(e,s)}catch(e){a=[6,e],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])}}},pe=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(pe=-1!==navigator.userAgent.indexOf("Firefox"));var ve=pe?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,ye=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function me(e){var t=e.mode,r=void 0===t?"async":t,n=e.customInfo,o=void 0===n?{}:n,i=e.title,s=e.messages,a=void 0===s?[]:s;return function(e,t,n){if(v){var s=o.className||e.constructor.name,u=o.methodName||t,c=n.value,l=function(){var e="",t=(new Error).stack.split("\n"),r=t.findIndex((function(e){return ve.test(e)}));if(-1!==r){var n=ye.exec(t[r+1]||"");e=n?n[0]:""}return e}();n.value="sync"===r?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=ge({err:new Error,className:s,methodName:u,sourceLink:l});try{return c.apply(this,e)}catch(e){var n=e,o=e.message,f=e.error,d=e.error_description,h={title:i||"".concat(s,".").concat(u," failed"),content:[{type:"error",body:e}]};if(o&&/^\{.*\}$/.test(o)){var p=JSON.parse(o);h.subtitle=o,p.code&&(r?(r.code=p.code,r.msg=p.msg):(e.code=p.code,e.message=p.msg),n=r||e,h.content=a.map((function(e){return{type:"info",body:e}})))}throw f&&d&&(h.subtitle=d,r?(r.code=f,r.msg=d):(e.code=f,e.message=d),n=r||e,h.content=a.map((function(e){return{type:"info",body:e}}))),B(h),n}}:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return de(this,void 0,void 0,(function(){var t,r,n,o,f,d,h,p;return he(this,(function(v){switch(v.label){case 0:t=ge({err:new Error,className:s,methodName:u,sourceLink:l}),v.label=1;case 1:return v.trys.push([1,3,,4]),[4,c.apply(this,e)];case 2:return[2,v.sent()];case 3:throw r=v.sent(),n=r,o=r.message,f=r.error,d=r.error_description,h={title:i||"".concat(s,".").concat(u," failed"),content:[{type:"error",body:r}]},o&&/^\{.*\}$/.test(o)&&(p=JSON.parse(o),h.subtitle=p,p.code&&(t?(t.code=p.code,t.message=p.msg):(r.code=p.code,r.message=p.msg),n=t||r,h.content=a.map((function(e){return{type:"info",body:e}})))),f&&d&&(h.subtitle=d,t?(t.code=f,t.msg=d):(r.code=f,r.message=d),n=t||r,h.content=a.map((function(e){return{type:"info",body:e}}))),B(h),n;case 4:return[2]}}))}))}}}}function ge(e){var t=e.err,r=e.className,n=e.methodName,o=e.sourceLink;if(!o)return null;var i,s=t.stack.split("\n"),a=pe?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]\\s*\\(.*\\)$")),u=pe?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]")),c=s.findIndex((function(e){return a.test(e)}));if(-1!==c){var l=s.filter((function(e,t){return t>c}));l.unshift(s[c].replace(u,"".concat(r,".").concat(n)).replace(ye,o)),(i=new Error).stack="".concat(pe?"@debugger":"Error","\n").concat(l.join("\n"))}return i}function be(e){this.message=e}function we(e){this.message=e}be.prototype=new Error,be.prototype.name="InvalidCharacterError","undefined"!=typeof window&&window.atob&&window.atob.bind(window),we.prototype=new Error,we.prototype.name="InvalidTokenError"},9515:function(e,t,r){var n=r(8761)(r(7772),"DataView");e.exports=n},9612:function(e,t,r){var n=r(2118),o=r(6909),i=r(8138),s=r(4174),a=r(7942);function u(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];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,e.exports=u},235:function(e,t,r){var n=r(3945),o=r(1846),i=r(8028),s=r(2344),a=r(4769);function u(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];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,e.exports=u},326:function(e,t,r){var n=r(8761)(r(7772),"Map");e.exports=n},6738:function(e,t,r){var n=r(2411),o=r(6417),i=r(6928),s=r(9493),a=r(4150);function u(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];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,e.exports=u},2760:function(e,t,r){var n=r(8761)(r(7772),"Promise");e.exports=n},2143:function(e,t,r){var n=r(8761)(r(7772),"Set");e.exports=n},6571:function(e,t,r){var n=r(235),o=r(5243),i=r(2858),s=r(4417),a=r(8605),u=r(1418);function c(e){var t=this.__data__=new n(e);this.size=t.size}c.prototype.clear=o,c.prototype.delete=i,c.prototype.get=s,c.prototype.has=a,c.prototype.set=u,e.exports=c},857:function(e,t,r){var n=r(7772).Symbol;e.exports=n},9162:function(e,t,r){var n=r(7772).Uint8Array;e.exports=n},3215:function(e,t,r){var n=r(8761)(r(7772),"WeakMap");e.exports=n},2517:function(e){e.exports=function(e,t){for(var r=-1,n=null==e?0:e.length;++r<n&&!1!==t(e[r],r,e););return e}},7552:function(e){e.exports=function(e,t){for(var r=-1,n=null==e?0:e.length,o=0,i=[];++r<n;){var s=e[r];t(s,r,e)&&(i[o++]=s)}return i}},1634:function(e,t,r){var n=r(6473),o=r(9631),i=r(6152),s=r(3226),a=r(9045),u=r(7598),c=Object.prototype.hasOwnProperty;e.exports=function(e,t){var r=i(e),l=!r&&o(e),f=!r&&!l&&s(e),d=!r&&!l&&!f&&u(e),h=r||l||f||d,p=h?n(e.length,String):[],v=p.length;for(var y in e)!t&&!c.call(e,y)||h&&("length"==y||f&&("offset"==y||"parent"==y)||d&&("buffer"==y||"byteLength"==y||"byteOffset"==y)||a(y,v))||p.push(y);return p}},343:function(e){e.exports=function(e,t){for(var r=-1,n=null==e?0:e.length,o=Array(n);++r<n;)o[r]=t(e[r],r,e);return o}},5067:function(e){e.exports=function(e,t){for(var r=-1,n=t.length,o=e.length;++r<n;)e[o+r]=t[r];return e}},91:function(e,t,r){var n=r(3940),o=r(1225),i=Object.prototype.hasOwnProperty;e.exports=function(e,t,r){var s=e[t];i.call(e,t)&&o(s,r)&&(void 0!==r||t in e)||n(e,t,r)}},2218:function(e,t,r){var n=r(1225);e.exports=function(e,t){for(var r=e.length;r--;)if(n(e[r][0],t))return r;return-1}},7993:function(e,t,r){var n=r(752),o=r(249);e.exports=function(e,t){return e&&n(t,o(t),e)}},5906:function(e,t,r){var n=r(752),o=r(8582);e.exports=function(e,t){return e&&n(t,o(t),e)}},3940:function(e,t,r){var n=r(3043);e.exports=function(e,t,r){"__proto__"==t&&n?n(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}},8874:function(e,t,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),d=r(3483),h=r(6939),p=r(940),v=r(9854),y=r(8222),m=r(8725),g=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]",A="[object Object]",R={};R[O]=R["[object Array]"]=R["[object ArrayBuffer]"]=R["[object DataView]"]=R["[object Boolean]"]=R["[object Date]"]=R["[object Float32Array]"]=R["[object Float64Array]"]=R["[object Int8Array]"]=R["[object Int16Array]"]=R["[object Int32Array]"]=R["[object Map]"]=R["[object Number]"]=R[A]=R["[object RegExp]"]=R["[object Set]"]=R["[object String]"]=R["[object Symbol]"]=R["[object Uint8Array]"]=R["[object Uint8ClampedArray]"]=R["[object Uint16Array]"]=R["[object Uint32Array]"]=!0,R["[object Error]"]=R[T]=R["[object WeakMap]"]=!1,e.exports=function e(t,r,P,C,N,x){var L,U=1&r,k=2&r,D=4&r;if(P&&(L=N?P(t,C,N,x):P(t)),void 0!==L)return L;if(!_(t))return t;var j=g(t);if(j){if(L=v(t),!U)return c(t,L)}else{var q=p(t),M=q==T||"[object GeneratorFunction]"==q;if(b(t))return u(t,U);if(q==A||q==O||M&&!N){if(L=k||M?{}:m(t),!U)return k?f(t,a(L,t)):l(t,s(L,t))}else{if(!R[q])return N?t:{};L=y(t,q,U)}}x||(x=new n);var B=x.get(t);if(B)return B;x.set(t,L),S(t)?t.forEach((function(n){L.add(e(n,r,P,n,t,x))})):w(t)&&t.forEach((function(n,o){L.set(o,e(n,r,P,o,t,x))}));var W=j?void 0:(D?k?h:d:k?I:E)(t);return o(W||t,(function(n,o){W&&(n=t[o=n]),i(L,o,e(n,r,P,o,t,x))})),L}},9413:function(e,t,r){var n=r(9259),o=Object.create,i=function(){function e(){}return function(t){if(!n(t))return{};if(o)return o(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}}();e.exports=i},3324:function(e,t,r){var n=r(7297),o=r(3812);e.exports=function(e,t){for(var r=0,i=(t=n(t,e)).length;null!=e&&r<i;)e=e[o(t[r++])];return r&&r==i?e:void 0}},1897:function(e,t,r){var n=r(5067),o=r(6152);e.exports=function(e,t,r){var i=t(e);return o(e)?i:n(i,r(e))}},3366:function(e,t,r){var n=r(857),o=r(2107),i=r(7157),s=n?n.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":s&&s in Object(e)?o(e):i(e)}},5183:function(e,t,r){var n=r(3366),o=r(5125);e.exports=function(e){return o(e)&&"[object Arguments]"==n(e)}},4511:function(e,t,r){var n=r(940),o=r(5125);e.exports=function(e){return o(e)&&"[object Map]"==n(e)}},6840:function(e,t,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,d=RegExp("^"+l.call(f).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");e.exports=function(e){return!(!i(e)||o(e))&&(n(e)?d:a).test(s(e))}},8436:function(e,t,r){var n=r(940),o=r(5125);e.exports=function(e){return o(e)&&"[object Set]"==n(e)}},5522:function(e,t,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,e.exports=function(e){return i(e)&&o(e.length)&&!!s[n(e)]}},6411:function(e,t,r){var n=r(6001),o=r(4248),i=Object.prototype.hasOwnProperty;e.exports=function(e){if(!n(e))return o(e);var t=[];for(var r in Object(e))i.call(e,r)&&"constructor"!=r&&t.push(r);return t}},8390:function(e,t,r){var n=r(9259),o=r(6001),i=r(2966),s=Object.prototype.hasOwnProperty;e.exports=function(e){if(!n(e))return i(e);var t=o(e),r=[];for(var a in e)("constructor"!=a||!t&&s.call(e,a))&&r.push(a);return r}},2857:function(e,t,r){var n=r(91),o=r(7297),i=r(9045),s=r(9259),a=r(3812);e.exports=function(e,t,r,u){if(!s(e))return e;for(var c=-1,l=(t=o(t,e)).length,f=l-1,d=e;null!=d&&++c<l;){var h=a(t[c]),p=r;if("__proto__"===h||"constructor"===h||"prototype"===h)return e;if(c!=f){var v=d[h];void 0===(p=u?u(v,h,d):void 0)&&(p=s(v)?v:i(t[c+1])?[]:{})}n(d,h,p),d=d[h]}return e}},9872:function(e){e.exports=function(e,t,r){var n=-1,o=e.length;t<0&&(t=-t>o?0:o+t),(r=r>o?o:r)<0&&(r+=o),o=t>r?0:r-t>>>0,t>>>=0;for(var i=Array(o);++n<o;)i[n]=e[n+t];return i}},6473:function(e){e.exports=function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}},1054:function(e,t,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;e.exports=function e(t){if("string"==typeof t)return t;if(i(t))return o(t,e)+"";if(s(t))return u?u.call(t):"";var r=t+"";return"0"==r&&1/t==-1/0?"-0":r}},7826:function(e){e.exports=function(e){return function(t){return e(t)}}},9078:function(e,t,r){var n=r(7297),o=r(6974),i=r(2721),s=r(3812);e.exports=function(e,t){return t=n(t,e),null==(e=i(e,t))||delete e[s(o(t))]}},7297:function(e,t,r){var n=r(6152),o=r(1401),i=r(4452),s=r(6188);e.exports=function(e,t){return n(e)?e:o(e,t)?[e]:i(s(e))}},9882:function(e,t,r){var n=r(9162);e.exports=function(e){var t=new e.constructor(e.byteLength);return new n(t).set(new n(e)),t}},2175:function(e,t,r){e=r.nmd(e);var n=r(7772),o=t&&!t.nodeType&&t,i=o&&e&&!e.nodeType&&e,s=i&&i.exports===o?n.Buffer:void 0,a=s?s.allocUnsafe:void 0;e.exports=function(e,t){if(t)return e.slice();var r=e.length,n=a?a(r):new e.constructor(r);return e.copy(n),n}},4727:function(e,t,r){var n=r(9882);e.exports=function(e,t){var r=t?n(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}},6058:function(e){var t=/\w*$/;e.exports=function(e){var r=new e.constructor(e.source,t.exec(e));return r.lastIndex=e.lastIndex,r}},169:function(e,t,r){var n=r(857),o=n?n.prototype:void 0,i=o?o.valueOf:void 0;e.exports=function(e){return i?Object(i.call(e)):{}}},6190:function(e,t,r){var n=r(9882);e.exports=function(e,t){var r=t?n(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}},1522:function(e){e.exports=function(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}},752:function(e,t,r){var n=r(91),o=r(3940);e.exports=function(e,t,r,i){var s=!r;r||(r={});for(var a=-1,u=t.length;++a<u;){var c=t[a],l=i?i(r[c],e[c],c,r,e):void 0;void 0===l&&(l=e[c]),s?o(r,c,l):n(r,c,l)}return r}},7680:function(e,t,r){var n=r(752),o=r(633);e.exports=function(e,t){return n(e,o(e),t)}},9987:function(e,t,r){var n=r(752),o=r(2680);e.exports=function(e,t){return n(e,o(e),t)}},4019:function(e,t,r){var n=r(7772)["__core-js_shared__"];e.exports=n},3043:function(e,t,r){var n=r(8761),o=function(){try{var e=n(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();e.exports=o},1242:function(e,t,r){var n="object"==typeof r.g&&r.g&&r.g.Object===Object&&r.g;e.exports=n},3483:function(e,t,r){var n=r(1897),o=r(633),i=r(249);e.exports=function(e){return n(e,i,o)}},6939:function(e,t,r){var n=r(1897),o=r(2680),i=r(8582);e.exports=function(e){return n(e,i,o)}},7937:function(e,t,r){var n=r(8304);e.exports=function(e,t){var r=e.__data__;return n(t)?r["string"==typeof t?"string":"hash"]:r.map}},8761:function(e,t,r){var n=r(6840),o=r(8109);e.exports=function(e,t){var r=o(e,t);return n(r)?r:void 0}},7353:function(e,t,r){var n=r(241)(Object.getPrototypeOf,Object);e.exports=n},2107:function(e,t,r){var n=r(857),o=Object.prototype,i=o.hasOwnProperty,s=o.toString,a=n?n.toStringTag:void 0;e.exports=function(e){var t=i.call(e,a),r=e[a];try{e[a]=void 0;var n=!0}catch(e){}var o=s.call(e);return n&&(t?e[a]=r:delete e[a]),o}},633:function(e,t,r){var n=r(7552),o=r(981),i=Object.prototype.propertyIsEnumerable,s=Object.getOwnPropertySymbols,a=s?function(e){return null==e?[]:(e=Object(e),n(s(e),(function(t){return i.call(e,t)})))}:o;e.exports=a},2680:function(e,t,r){var n=r(5067),o=r(7353),i=r(633),s=r(981),a=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)n(t,i(e)),e=o(e);return t}:s;e.exports=a},940:function(e,t,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]",d="[object Set]",h="[object WeakMap]",p="[object DataView]",v=c(n),y=c(o),m=c(i),g=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)!=d||a&&w(new a)!=h)&&(w=function(e){var t=u(e),r="[object Object]"==t?e.constructor:void 0,n=r?c(r):"";if(n)switch(n){case v:return p;case y:return l;case m:return f;case g:return d;case b:return h}return t}),e.exports=w},8109:function(e){e.exports=function(e,t){return null==e?void 0:e[t]}},2118:function(e,t,r){var n=r(9191);e.exports=function(){this.__data__=n?n(null):{},this.size=0}},6909:function(e){e.exports=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}},8138:function(e,t,r){var n=r(9191),o=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;if(n){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return o.call(t,e)?t[e]:void 0}},4174:function(e,t,r){var n=r(9191),o=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;return n?void 0!==t[e]:o.call(t,e)}},7942:function(e,t,r){var n=r(9191);e.exports=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=n&&void 0===t?"__lodash_hash_undefined__":t,this}},9854:function(e){var t=Object.prototype.hasOwnProperty;e.exports=function(e){var r=e.length,n=new e.constructor(r);return r&&"string"==typeof e[0]&&t.call(e,"index")&&(n.index=e.index,n.input=e.input),n}},8222:function(e,t,r){var n=r(9882),o=r(4727),i=r(6058),s=r(169),a=r(6190);e.exports=function(e,t,r){var u=e.constructor;switch(t){case"[object ArrayBuffer]":return n(e);case"[object Boolean]":case"[object Date]":return new u(+e);case"[object DataView]":return o(e,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(e,r);case"[object Map]":case"[object Set]":return new u;case"[object Number]":case"[object String]":return new u(e);case"[object RegExp]":return i(e);case"[object Symbol]":return s(e)}}},8725:function(e,t,r){var n=r(9413),o=r(7353),i=r(6001);e.exports=function(e){return"function"!=typeof e.constructor||i(e)?{}:n(o(e))}},9045:function(e){var t=/^(?:0|[1-9]\d*)$/;e.exports=function(e,r){var n=typeof e;return!!(r=null==r?9007199254740991:r)&&("number"==n||"symbol"!=n&&t.test(e))&&e>-1&&e%1==0&&e<r}},1401:function(e,t,r){var n=r(6152),o=r(4795),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;e.exports=function(e,t){if(n(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!o(e))||s.test(e)||!i.test(e)||null!=t&&e in Object(t)}},8304:function(e){e.exports=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}},7394:function(e,t,r){var n,o=r(4019),i=(n=/[^.]+$/.exec(o&&o.keys&&o.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"";e.exports=function(e){return!!i&&i in e}},6001:function(e){var t=Object.prototype;e.exports=function(e){var r=e&&e.constructor;return e===("function"==typeof r&&r.prototype||t)}},3945:function(e){e.exports=function(){this.__data__=[],this.size=0}},1846:function(e,t,r){var n=r(2218),o=Array.prototype.splice;e.exports=function(e){var t=this.__data__,r=n(t,e);return!(r<0||(r==t.length-1?t.pop():o.call(t,r,1),--this.size,0))}},8028:function(e,t,r){var n=r(2218);e.exports=function(e){var t=this.__data__,r=n(t,e);return r<0?void 0:t[r][1]}},2344:function(e,t,r){var n=r(2218);e.exports=function(e){return n(this.__data__,e)>-1}},4769:function(e,t,r){var n=r(2218);e.exports=function(e,t){var r=this.__data__,o=n(r,e);return o<0?(++this.size,r.push([e,t])):r[o][1]=t,this}},2411:function(e,t,r){var n=r(9612),o=r(235),i=r(326);e.exports=function(){this.size=0,this.__data__={hash:new n,map:new(i||o),string:new n}}},6417:function(e,t,r){var n=r(7937);e.exports=function(e){var t=n(this,e).delete(e);return this.size-=t?1:0,t}},6928:function(e,t,r){var n=r(7937);e.exports=function(e){return n(this,e).get(e)}},9493:function(e,t,r){var n=r(7937);e.exports=function(e){return n(this,e).has(e)}},4150:function(e,t,r){var n=r(7937);e.exports=function(e,t){var r=n(this,e),o=r.size;return r.set(e,t),this.size+=r.size==o?0:1,this}},7777:function(e,t,r){var n=r(733);e.exports=function(e){var t=n(e,(function(e){return 500===r.size&&r.clear(),e})),r=t.cache;return t}},9191:function(e,t,r){var n=r(8761)(Object,"create");e.exports=n},4248:function(e,t,r){var n=r(241)(Object.keys,Object);e.exports=n},2966:function(e){e.exports=function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}},4146:function(e,t,r){e=r.nmd(e);var n=r(1242),o=t&&!t.nodeType&&t,i=o&&e&&!e.nodeType&&e,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(e){}}();e.exports=a},7157:function(e){var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},241:function(e){e.exports=function(e,t){return function(r){return e(t(r))}}},2721:function(e,t,r){var n=r(3324),o=r(9872);e.exports=function(e,t){return t.length<2?e:n(e,o(t,0,-1))}},7772:function(e,t,r){var n=r(1242),o="object"==typeof self&&self&&self.Object===Object&&self,i=n||o||Function("return this")();e.exports=i},5243:function(e,t,r){var n=r(235);e.exports=function(){this.__data__=new n,this.size=0}},2858:function(e){e.exports=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}},4417:function(e){e.exports=function(e){return this.__data__.get(e)}},8605:function(e){e.exports=function(e){return this.__data__.has(e)}},1418:function(e,t,r){var n=r(235),o=r(326),i=r(6738);e.exports=function(e,t){var r=this.__data__;if(r instanceof n){var s=r.__data__;if(!o||s.length<199)return s.push([e,t]),this.size=++r.size,this;r=this.__data__=new i(s)}return r.set(e,t),this.size=r.size,this}},4452:function(e,t,r){var n=r(7777),o=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,i=/\\(\\)?/g,s=n((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(o,(function(e,r,n,o){t.push(n?o.replace(i,"$1"):r||e)})),t}));e.exports=s},3812:function(e,t,r){var n=r(4795);e.exports=function(e){if("string"==typeof e||n(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}},7035:function(e){var t=Function.prototype.toString;e.exports=function(e){if(null!=e){try{return t.call(e)}catch(e){}try{return e+""}catch(e){}}return""}},9850:function(e,t,r){var n=r(8874);e.exports=function(e){return n(e,5)}},1225:function(e){e.exports=function(e,t){return e===t||e!=e&&t!=t}},9631:function(e,t,r){var n=r(5183),o=r(5125),i=Object.prototype,s=i.hasOwnProperty,a=i.propertyIsEnumerable,u=n(function(){return arguments}())?n:function(e){return o(e)&&s.call(e,"callee")&&!a.call(e,"callee")};e.exports=u},6152:function(e){var t=Array.isArray;e.exports=t},7878:function(e,t,r){var n=r(1049),o=r(1158);e.exports=function(e){return null!=e&&o(e.length)&&!n(e)}},3226:function(e,t,r){e=r.nmd(e);var n=r(7772),o=r(6330),i=t&&!t.nodeType&&t,s=i&&e&&!e.nodeType&&e,a=s&&s.exports===i?n.Buffer:void 0,u=(a?a.isBuffer:void 0)||o;e.exports=u},1049:function(e,t,r){var n=r(3366),o=r(9259);e.exports=function(e){if(!o(e))return!1;var t=n(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}},1158:function(e){e.exports=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}},4714:function(e,t,r){var n=r(4511),o=r(7826),i=r(4146),s=i&&i.isMap,a=s?o(s):n;e.exports=a},9259:function(e){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},5125:function(e){e.exports=function(e){return null!=e&&"object"==typeof e}},3679:function(e,t,r){var n=r(8436),o=r(7826),i=r(4146),s=i&&i.isSet,a=s?o(s):n;e.exports=a},4795:function(e,t,r){var n=r(3366),o=r(5125);e.exports=function(e){return"symbol"==typeof e||o(e)&&"[object Symbol]"==n(e)}},7598:function(e,t,r){var n=r(5522),o=r(7826),i=r(4146),s=i&&i.isTypedArray,a=s?o(s):n;e.exports=a},249:function(e,t,r){var n=r(1634),o=r(6411),i=r(7878);e.exports=function(e){return i(e)?n(e):o(e)}},8582:function(e,t,r){var n=r(1634),o=r(8390),i=r(7878);e.exports=function(e){return i(e)?n(e,!0):o(e)}},6974:function(e){e.exports=function(e){var t=null==e?0:e.length;return t?e[t-1]:void 0}},733:function(e,t,r){var n=r(6738);function o(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var r=function(){var n=arguments,o=t?t.apply(this,n):n[0],i=r.cache;if(i.has(o))return i.get(o);var s=e.apply(this,n);return r.cache=i.set(o,s)||i,s};return r.cache=new(o.Cache||n),r}o.Cache=n,e.exports=o},6765:function(e,t,r){var n=r(2857);e.exports=function(e,t,r){return null==e?e:n(e,t,r)}},981:function(e){e.exports=function(){return[]}},6330:function(e){e.exports=function(){return!1}},6188:function(e,t,r){var n=r(1054);e.exports=function(e){return null==e?"":n(e)}},7195:function(e,t,r){var n=r(9078);e.exports=function(e,t){return null==e||n(e,t)}},5047:function(e){var t=function(e){"use strict";var t,r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var i=t&&t.prototype instanceof m?t:m,s=Object.create(i.prototype),a=new C(n||[]);return o(s,"_invoke",{value:T(e,r,a)}),s}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=l;var d="suspendedStart",h="suspendedYield",p="executing",v="completed",y={};function m(){}function g(){}function b(){}var w={};c(w,s,(function(){return this}));var _=Object.getPrototypeOf,S=_&&_(_(N([])));S&&S!==r&&n.call(S,s)&&(w=S);var E=b.prototype=m.prototype=Object.create(w);function I(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function O(e,t){function r(o,i,s,a){var u=f(e[o],e,i);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,s,a)}),(function(e){r("throw",e,s,a)})):t.resolve(l).then((function(e){c.value=e,s(c)}),(function(e){return r("throw",e,s,a)}))}a(u.arg)}var i;o(this,"_invoke",{value:function(e,n){function o(){return new t((function(t,o){r(e,n,t,o)}))}return i=i?i.then(o,o):o()}})}function T(e,r,n){var o=d;return function(i,s){if(o===p)throw new Error("Generator is already running");if(o===v){if("throw"===i)throw s;return{value:t,done:!0}}for(n.method=i,n.arg=s;;){var a=n.delegate;if(a){var u=A(a,n);if(u){if(u===y)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===d)throw o=v,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=p;var c=f(e,r,n);if("normal"===c.type){if(o=n.done?v:h,c.arg===y)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(o=v,n.method="throw",n.arg=c.arg)}}}function A(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,A(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var i=f(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,y;var s=i.arg;return s?s.done?(r[e.resultName]=s.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,y):s:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function R(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function P(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function C(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(R,this),this.reset(!0)}function N(e){if(null!=e){var r=e[s];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}throw new TypeError(typeof e+" is not iterable")}return g.prototype=b,o(E,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:g,configurable:!0}),g.displayName=c(b,u,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,c(e,u,"GeneratorFunction")),e.prototype=Object.create(E),e},e.awrap=function(e){return{__await:e}},I(O.prototype),c(O.prototype,a,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var s=new O(l(t,r,n,o),i);return e.isGeneratorFunction(r)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},I(E),c(E,u,"Generator"),c(E,s,(function(){return this})),c(E,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=N,C.prototype={constructor:C,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(P),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return a.type="throw",a.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!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(e,t){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"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=e,s.arg=t,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),P(r),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;P(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:N(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),y}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}},4410:function(e,t,r){var n,o;void 0===(o="function"==typeof(n=function(){"use strict";var e=void 0!==r.g?r.g:self;if(void 0!==e.TextEncoder&&void 0!==e.TextDecoder)return{TextEncoder:e.TextEncoder,TextDecoder:e.TextDecoder};var t=["utf8","utf-8","unicode-1-1-utf-8"];return{TextEncoder:function(e){if(t.indexOf(e)<0&&null!=e)throw new RangeError("Invalid encoding type. Only utf-8 is supported");this.encoding="utf-8",this.encode=function(e){if("string"!=typeof e)throw new TypeError("passed argument must be of type string");var t=unescape(encodeURIComponent(e)),r=new Uint8Array(t.length);return t.split("").forEach((function(e,t){r[t]=e.charCodeAt(0)})),r}},TextDecoder:function(e,r){if(t.indexOf(e)<0&&null!=e)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(e,t){if(void 0===e)return"";if("boolean"!=typeof(void 0!==t&&"stream"in t&&t.stream))throw new TypeError("stream option must be boolean");if(ArrayBuffer.isView(e)){var r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n=new Array(r.length);return r.forEach((function(e,t){n[t]=String.fromCharCode(e)})),decodeURIComponent(escape(n.join("")))}throw new TypeError("passed argument must be an array buffer view")}}}})?n.apply(t,[]):n)||(e.exports=o)},5090:function(e,t,r){!function(e){"use strict";var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},t(e,r)};function n(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)}var o=function(){return o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},o.apply(this,arguments)};function i(e,t,r,n){return new(r||(r=Promise))((function(t,o){function i(e){try{a(n.next(e))}catch(e){o(e)}}function s(e){try{a(n.throw(e))}catch(e){o(e)}}function a(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r((function(e){e(n)}))).then(i,s)}a((n=n.apply(e,[])).next())}))}function s(e,t){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=t.call(e,s)}catch(e){i=[6,e],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 a=function(e){function t(t,r){var n=e.call(this,t)||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 n(t,e),t}(Error);function u(){return"undefined"!=typeof window&&window||"undefined"!=typeof globalThis&&globalThis}function c(){try{var e=u();if(!e)return;return"undefined"==typeof wx?u().location.href:e.__wxRoute}catch(e){}}var l=function(e){var t=e.dataSourceName,r=e.methodName,n=e.params,o=e.realMethodName,l=e.callFunction,f=e.envType,d=void 0===f?"prod":f,h=e.mode;return i(void 0,0,void 0,(function(){var e,i,f,p,v,y;return s(this,(function(s){switch(s.label){case 0:e={data:{},requestId:""},s.label=1;case 1:return s.trys.push([1,3,,4]),[4,l({name:"lowcode-datasource",data:{dataSourceName:t,methodName:r,params:n,userAgent:(g=u(),(null==g?void 0:g.navigator)?g.navigator.userAgent:"undefined"!=typeof wx&&wx.getSystemInfo?(wx.getSystemInfo({success:function(e){e&&(m=["brand","model","version","system","platform","SDKVersion","language"].map((function(t){return"".concat(t,": ").concat(e[t])})).join(", "))}}),m):void 0),referrer:c(),"x-sdk-version":"1.7.1",envType:d,mode:h}})];case 2:if(i=s.sent(),f=(null===(v=null==i?void 0:i.result)||void 0===v?void 0:v.requestId)||(null==i?void 0:i.requestId)||(null==i?void 0:i.requestID),null==i?void 0:i.result.code)throw new a("【错误】".concat(null==i?void 0:i.result.message,"\n【操作】调用 models.").concat(t?"".concat(t,"."):"").concat(o,"\n【错误码】").concat(null==i?void 0:i.result.code,"\n【请求ID】").concat(f||"N/A"),{code:null==i?void 0:i.result.code,requestId:f});return e.data=(null===(y=null==i?void 0:i.result)||void 0===y?void 0:y.data)||{},e.requestId=f,[3,4];case 3:throw"WxCloudSDKError"===(p=s.sent()).name?p:(console.log(p),new a("【错误】".concat(p.message,"\n 【操作】调用 models.").concat(t?"".concat(t,"."):"").concat(o,"\n 【请求ID】N/A"),{code:"UnknownError",originError:p}));case 4:return[2,e]}var m,g}))}))},f=function(e){var t=e.sql,r=e.params,n=e.config,o=e.callFunction,a=e.unsafe,u=void 0!==a&&a;return i(void 0,0,void 0,(function(){return s(this,(function(e){return[2,l({realMethodName:"$runSQL",methodName:"callWedaApi",params:{action:"RunMysqlCommand",data:{sqlTemplate:t,config:n,parameter:u?"":Object.entries(r||{}).reduce((function(e,t){var r=t[0],n=t[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"}e.push({key:r,type:o,value:"STRING"===o?n:JSON.stringify(n)})}return e}),[])||[]}},callFunction:o,mode:"sdk"})]}))}))},d=function(e){return{$runSQL:function(t,r,n){return i(this,0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,f({sql:t,params:r,config:o(o({},n),{preparedStatements:!0}),callFunction:e})];case 1:return[2,i.sent()]}}))}))},$runSQLRaw:function(t,r){return i(this,0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,f({sql:t,params:[],config:o(o({},r),{preparedStatements:!1}),callFunction:e})];case 1:return[2,n.sent()]}}))}))}}},h={filter:{where:{}},select:{$master:!0}};function p(e){return{getUrl:function(t){return"".concat(t,"/").concat(e)},method:"post"}}var v={get:o(o({},p("get")),{defaultParams:o({},h)}),list:o(o({},p("list")),{defaultParams:o({},h)}),create:p("create"),createMany:p("createMany"),update:o(o({},p("update")),{method:"put"}),updateMany:o(o({},p("updateMany")),{method:"put"}),upsert:p("upsert"),delete:p("delete"),deleteMany:p("deleteMany")},y="Unknown error occurred",m="NotSupported",g=function(e,t,r,n){var o=d(e);return new Proxy({},{get:function(e,i){if("string"==typeof i)return Object.prototype.hasOwnProperty.call(o,i)?o[i]:w(r,i,t,n)}})},b=function(e,t,r,n,o){return new a("【错误】".concat(e,"\n【操作】调用 models.").concat(t,".").concat(r,"\n【错误码】").concat(n,"\n【请求ID】").concat(o),{code:n,requestId:o})},w=function(e,t,r,n){return new Proxy({},{get:function(u,c){if("runSQLTemplate"!==c){var l=v[c];if(!l){var f=new Error("不支持的操作: ".concat(c));throw new a(f.message||y,{originError:f,code:m,requestId:"N/A"})}return function(n){return void 0===n&&(n={}),i(void 0,0,void 0,(function(){var o,i,u,f,d,h,p,v,m,g;return s(this,(function(s){switch(s.label){case 0:o=l.getUrl,i=l.method,u=l.defaultParams,f=void 0===u?{}:u,d=Object.assign({},f,n),h="pre"===d.envType?"pre":"prod",p=[e,h,o(t)].join("/"),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,r({url:p,body:JSON.stringify(d),method:i})];case 2:if((v=s.sent()).code)throw b(null==v?void 0:v.message,t,c,null==v?void 0:v.code,null==v?void 0:v.requestId);return"get"===c&&Object.assign(v,{data:null!==(g=v.data.record)&&void 0!==g?g:v.data}),[2,v];case 3:throw m=s.sent(),new a((null==m?void 0:m.message)||y,{originError:m});case 4:return[2]}}))}))}}if(!(null==n?void 0:n.sqlBaseUrl))throw f=new Error("不支持的操作: ".concat(c)),new a(f.message||y,{originError:f,code:m,requestId:"N/A"});return function(e){return i(void 0,0,void 0,(function(){var i,u,l,f,d,h,p,v,m,g,w,_,S,E,I,O;return s(this,(function(s){switch(s.label){case 0:i=e.params,u=e.templateName,l=e.envType,f="pre"===l?"pre":"prod",d=[n.sqlBaseUrl,f,u,"run"].join("/"),h=Object.entries(i||{}).reduce((function(e,t){var r=t[0],n=t[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"}e.push({key:r,type:o,value:"STRING"===o?n:JSON.stringify(n)})}return e}),[]),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,r({url:d,body:JSON.stringify({parameter:h}),method:"POST"})];case 2:if(p=s.sent(),null===(m=null==p?void 0:p.Response)||void 0===m?void 0:m.Error)throw b(null===(w=null===(g=null==p?void 0:p.Response)||void 0===g?void 0:g.Error)||void 0===w?void 0:w.Message,t,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,o(o({},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 v=s.sent(),new a((null==v?void 0:v.message)||y,{originError:v});case 4:return[2]}}))}))}}})},_={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}}}},S=function(e){var t=d(e);return new Proxy({},{get:function(r,n){if("string"==typeof n)return Object.prototype.hasOwnProperty.call(t,n)?t[n]:function(e,t){return new Proxy({},{get:function(r,n){var u=_[n];if(!u){var c=new Error("不支持的操作: ".concat(n));throw new a(c.message||"Unknown error occurred",{originError:c,code:"NotSupported",requestId:"N/A"})}return function(r){return i(void 0,0,void 0,(function(){var i,a,c,f,d;return s(this,(function(s){switch(s.label){case 0:return i=o(o({},u.defaultParams||{}),r||{}),[4,l({callFunction:t,dataSourceName:e,methodName:u.methodName,realMethodName:n,params:i,envType:null==r?void 0:r.envType})];case 1:return a=s.sent(),c={data:{}},f=u.responseKey,c.data=f?null===(d=null==a?void 0:a.data)||void 0===d?void 0:d[f]:null==a?void 0:a.data,[2,c]}}))}))}}})}(n,e)}})},E=function(){function e(e){var t=this;this.map=new Map,e&&(e instanceof Headers?e.forEach((function(e,r){t.append(r,e)})):Array.isArray(e)?e.forEach((function(e){var r=e[0],n=e[1];t.append(r,n)})):"object"==typeof e&&Object.keys(e).forEach((function(r){t.append(r,e[r])})))}return e.prototype.append=function(e,t){var r=e.toLowerCase(),n=this.map.get(r);n?this.map.set(r,"".concat(n,", ").concat(t)):this.map.set(r,String(t))},e.prototype.delete=function(e){this.map.delete(e.toLowerCase())},e.prototype.forEach=function(e,t){var r=this;this.map.forEach((function(n,o){e.call(t,n,o,r)}))},e.prototype.get=function(e){return this.map.get(e.toLowerCase())||null},e.prototype.has=function(e){return this.map.has(e.toLowerCase())},e.prototype.set=function(e,t){this.map.set(e.toLowerCase(),String(t))},e.prototype.entries=function(){return this.map.entries()},e.prototype.keys=function(){return this.map.keys()},e.prototype.values=function(){return this.map.values()},e.prototype.getSetCookie=function(){var e=[];return this.map.forEach((function(t,r){"set-cookie"===r&&e.push(t)})),e},e.prototype.toJSON=function(){var e={};return this.map.forEach((function(t,r){e[r]=t})),e},e.prototype[Symbol.iterator]=function(){return this.entries()},e}();"object"!=typeof globalThis||globalThis.Headers||(globalThis.Headers=E);var I="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==r.g?r.g:"undefined"!=typeof self?self:{};function O(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var T,A,R=function(e){try{return!!e()}catch(e){return!0}},P=!R((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),C=P,N=Function.prototype,x=N.call,L=C&&N.bind.bind(x,x),U=C?L:function(e){return function(){return x.apply(e,arguments)}},k=U,D=k({}.toString),j=k("".slice),q=function(e){return j(D(e),8,-1)},M=R,B=q,W=Object,F=U("".split),V=M((function(){return!W("z").propertyIsEnumerable(0)}))?function(e){return"String"===B(e)?F(e,""):W(e)}:W,H=function(e){return null==e},$=H,G=TypeError,z=function(e){if($(e))throw new G("Can't call method on "+e);return e},K=V,J=z,Y=function(e){return K(J(e))},Q={},Z=function(e){return e&&e.Math===Math&&e},X=Z("object"==typeof globalThis&&globalThis)||Z("object"==typeof window&&window)||Z("object"==typeof self&&self)||Z("object"==typeof I&&I)||Z("object"==typeof I&&I)||function(){return this}()||Function("return this")(),ee="object"==typeof document&&document.all,te=void 0===ee&&void 0!==ee?function(e){return"function"==typeof e||e===ee}:function(e){return"function"==typeof e},re=te,ne=X.WeakMap,oe=re(ne)&&/native code/.test(String(ne)),ie=te,se=function(e){return"object"==typeof e?null!==e:ie(e)},ae=!R((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]})),ue={},ce=se,le=X.document,fe=ce(le)&&ce(le.createElement),de=function(e){return fe?le.createElement(e):{}},he=de,pe=!ae&&!R((function(){return 7!==Object.defineProperty(he("div"),"a",{get:function(){return 7}}).a})),ve=ae&&R((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),ye=se,me=String,ge=TypeError,be=function(e){if(ye(e))return e;throw new ge(me(e)+" is not an object")},we=P,_e=Function.prototype.call,Se=we?_e.bind(_e):function(){return _e.apply(_e,arguments)},Ee={},Ie=Ee,Oe=X,Te=te,Ae=function(e){return Te(e)?e:void 0},Re=function(e,t){return arguments.length<2?Ae(Ie[e])||Ae(Oe[e]):Ie[e]&&Ie[e][t]||Oe[e]&&Oe[e][t]},Pe=U({}.isPrototypeOf),Ce=X.navigator,Ne=Ce&&Ce.userAgent,xe=X,Le=Ne?String(Ne):"",Ue=xe.process,ke=xe.Deno,De=Ue&&Ue.versions||ke&&ke.version,je=De&&De.v8;je&&(A=(T=je.split("."))[0]>0&&T[0]<4?1:+(T[0]+T[1])),!A&&Le&&(!(T=Le.match(/Edge\/(\d+)/))||T[1]>=74)&&(T=Le.match(/Chrome\/(\d+)/))&&(A=+T[1]);var qe=A,Me=R,Be=X.String,We=!!Object.getOwnPropertySymbols&&!Me((function(){var e=Symbol("symbol detection");return!Be(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&qe&&qe<41})),Fe=We&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,Ve=Re,He=te,$e=Pe,Ge=Object,ze=Fe?function(e){return"symbol"==typeof e}:function(e){var t=Ve("Symbol");return He(t)&&$e(t.prototype,Ge(e))},Ke=String,Je=function(e){try{return Ke(e)}catch(e){return"Object"}},Ye=te,Qe=Je,Ze=TypeError,Xe=function(e){if(Ye(e))return e;throw new Ze(Qe(e)+" is not a function")},et=Xe,tt=H,rt=function(e,t){var r=e[t];return tt(r)?void 0:et(r)},nt=Se,ot=te,it=se,st=TypeError,at={exports:{}},ut=X,ct=Object.defineProperty,lt=X,ft="__core-js_shared__",dt=at.exports=lt[ft]||function(e,t){try{ct(ut,e,{value:t,configurable:!0,writable:!0})}catch(r){ut[e]=t}return t}(ft,{});(dt.versions||(dt.versions=[])).push({version:"3.45.0",mode:"pure",copyright:"© 2014-2025 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.45.0/LICENSE",source:"https://github.com/zloirock/core-js"});var ht=at.exports,pt=ht,vt=function(e,t){return pt[e]||(pt[e]=t||{})},yt=z,mt=Object,gt=function(e){return mt(yt(e))},bt=gt,wt=U({}.hasOwnProperty),_t=Object.hasOwn||function(e,t){return wt(bt(e),t)},St=U,Et=0,It=Math.random(),Ot=St(1.1.toString),Tt=function(e){return"Symbol("+(void 0===e?"":e)+")_"+Ot(++Et+It,36)},At=vt,Rt=_t,Pt=Tt,Ct=We,Nt=Fe,xt=X.Symbol,Lt=At("wks"),Ut=Nt?xt.for||xt:xt&&xt.withoutSetter||Pt,kt=function(e){return Rt(Lt,e)||(Lt[e]=Ct&&Rt(xt,e)?xt[e]:Ut("Symbol."+e)),Lt[e]},Dt=Se,jt=se,qt=ze,Mt=rt,Bt=function(e,t){var r,n;if("string"===t&&ot(r=e.toString)&&!it(n=nt(r,e)))return n;if(ot(r=e.valueOf)&&!it(n=nt(r,e)))return n;if("string"!==t&&ot(r=e.toString)&&!it(n=nt(r,e)))return n;throw new st("Can't convert object to primitive value")},Wt=TypeError,Ft=kt("toPrimitive"),Vt=ze,Ht=function(e){var t=function(e,t){if(!jt(e)||qt(e))return e;var r,n=Mt(e,Ft);if(n){if(void 0===t&&(t="default"),r=Dt(n,e,t),!jt(r)||qt(r))return r;throw new Wt("Can't convert object to primitive value")}return void 0===t&&(t="number"),Bt(e,t)}(e,"string");return Vt(t)?t:t+""},$t=ae,Gt=pe,zt=ve,Kt=be,Jt=Ht,Yt=TypeError,Qt=Object.defineProperty,Zt=Object.getOwnPropertyDescriptor,Xt="enumerable",er="configurable",tr="writable";ue.f=$t?zt?function(e,t,r){if(Kt(e),t=Jt(t),Kt(r),"function"==typeof e&&"prototype"===t&&"value"in r&&tr in r&&!r[tr]){var n=Zt(e,t);n&&n[tr]&&(e[t]=r.value,r={configurable:er in r?r[er]:n[er],enumerable:Xt in r?r[Xt]:n[Xt],writable:!1})}return Qt(e,t,r)}:Qt:function(e,t,r){if(Kt(e),t=Jt(t),Kt(r),Gt)try{return Qt(e,t,r)}catch(e){}if("get"in r||"set"in r)throw new Yt("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var rr,nr,or,ir=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},sr=ue,ar=ir,ur=ae?function(e,t,r){return sr.f(e,t,ar(1,r))}:function(e,t,r){return e[t]=r,e},cr=Tt,lr=vt("keys"),fr=function(e){return lr[e]||(lr[e]=cr(e))},dr={},hr=oe,pr=X,vr=se,yr=ur,mr=_t,gr=ht,br=fr,wr=dr,_r="Object already initialized",Sr=pr.TypeError,Er=pr.WeakMap;if(hr||gr.state){var Ir=gr.state||(gr.state=new Er);Ir.get=Ir.get,Ir.has=Ir.has,Ir.set=Ir.set,rr=function(e,t){if(Ir.has(e))throw new Sr(_r);return t.facade=e,Ir.set(e,t),t},nr=function(e){return Ir.get(e)||{}},or=function(e){return Ir.has(e)}}else{var Or=br("state");wr[Or]=!0,rr=function(e,t){if(mr(e,Or))throw new Sr(_r);return t.facade=e,yr(e,Or,t),t},nr=function(e){return mr(e,Or)?e[Or]:{}},or=function(e){return mr(e,Or)}}var Tr={set:rr,get:nr,has:or,enforce:function(e){return or(e)?nr(e):rr(e,{})},getterFor:function(e){return function(t){var r;if(!vr(t)||(r=nr(t)).type!==e)throw new Sr("Incompatible receiver, "+e+" required");return r}}},Ar=P,Rr=Function.prototype,Pr=Rr.apply,Cr=Rr.call,Nr="object"==typeof Reflect&&Reflect.apply||(Ar?Cr.bind(Pr):function(){return Cr.apply(Pr,arguments)}),xr=q,Lr=U,Ur=function(e){if("Function"===xr(e))return Lr(e)},kr={},Dr={},jr={}.propertyIsEnumerable,qr=Object.getOwnPropertyDescriptor,Mr=qr&&!jr.call({1:2},1);Dr.f=Mr?function(e){var t=qr(this,e);return!!t&&t.enumerable}:jr;var Br=ae,Wr=Se,Fr=Dr,Vr=ir,Hr=Y,$r=Ht,Gr=_t,zr=pe,Kr=Object.getOwnPropertyDescriptor;kr.f=Br?Kr:function(e,t){if(e=Hr(e),t=$r(t),zr)try{return Kr(e,t)}catch(e){}if(Gr(e,t))return Vr(!Wr(Fr.f,e,t),e[t])};var Jr=R,Yr=te,Qr=/#|\.prototype\./,Zr=function(e,t){var r=en[Xr(e)];return r===rn||r!==tn&&(Yr(t)?Jr(t):!!t)},Xr=Zr.normalize=function(e){return String(e).replace(Qr,".").toLowerCase()},en=Zr.data={},tn=Zr.NATIVE="N",rn=Zr.POLYFILL="P",nn=Zr,on=Xe,sn=P,an=Ur(Ur.bind),un=function(e,t){return on(e),void 0===t?e:sn?an(e,t):function(){return e.apply(t,arguments)}},cn=X,ln=Nr,fn=Ur,dn=te,hn=kr.f,pn=nn,vn=Ee,yn=un,mn=ur,gn=_t,bn=function(e){var t=function(r,n,o){if(this instanceof t){switch(arguments.length){case 0:return new e;case 1:return new e(r);case 2:return new e(r,n)}return new e(r,n,o)}return ln(e,this,arguments)};return t.prototype=e.prototype,t},wn=function(e,t){var r,n,o,i,s,a,u,c,l,f=e.target,d=e.global,h=e.stat,p=e.proto,v=d?cn:h?cn[f]:cn[f]&&cn[f].prototype,y=d?vn:vn[f]||mn(vn,f,{})[f],m=y.prototype;for(i in t)n=!(r=pn(d?i:f+(h?".":"#")+i,e.forced))&&v&&gn(v,i),a=y[i],n&&(u=e.dontCallGetSet?(l=hn(v,i))&&l.value:v[i]),s=n&&u?u:t[i],(r||p||typeof a!=typeof s)&&(c=e.bind&&n?yn(s,cn):e.wrap&&n?bn(s):p&&dn(s)?fn(s):s,(e.sham||s&&s.sham||a&&a.sham)&&mn(c,"sham",!0),mn(y,i,c),p&&(gn(vn,o=f+"Prototype")||mn(vn,o,{}),mn(vn[o],i,s),e.real&&m&&(r||!m[i])&&mn(m,i,s)))},_n=ae,Sn=_t,En=Function.prototype,In=_n&&Object.getOwnPropertyDescriptor,On=Sn(En,"name"),Tn={EXISTS:On,PROPER:On&&"something"===function(){}.name,CONFIGURABLE:On&&(!_n||_n&&In(En,"name").configurable)},An={},Rn=Math.ceil,Pn=Math.floor,Cn=Math.trunc||function(e){var t=+e;return(t>0?Pn:Rn)(t)},Nn=function(e){var t=+e;return t!=t||0===t?0:Cn(t)},xn=Nn,Ln=Math.max,Un=Math.min,kn=function(e,t){var r=xn(e);return r<0?Ln(r+t,0):Un(r,t)},Dn=Nn,jn=Math.min,qn=function(e){return t=e.length,(r=Dn(t))>0?jn(r,9007199254740991):0;var t,r},Mn=Y,Bn=kn,Wn=qn,Fn=function(e){return function(t,r,n){var o=Mn(t),i=Wn(o);if(0===i)return!e&&-1;var s,a=Bn(n,i);if(e&&r!=r){for(;i>a;)if((s=o[a++])!=s)return!0}else for(;i>a;a++)if((e||a in o)&&o[a]===r)return e||a||0;return!e&&-1}},Vn={includes:Fn(!0),indexOf:Fn(!1)},Hn=_t,$n=Y,Gn=Vn.indexOf,zn=dr,Kn=U([].push),Jn=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Yn=Jn,Qn=Object.keys||function(e){return function(e,t){var r,n=$n(e),o=0,i=[];for(r in n)!Hn(zn,r)&&Hn(n,r)&&Kn(i,r);for(;t.length>o;)Hn(n,r=t[o++])&&(~Gn(i,r)||Kn(i,r));return i}(e,Yn)},Zn=ae,Xn=ve,eo=ue,to=be,ro=Y,no=Qn;An.f=Zn&&!Xn?Object.defineProperties:function(e,t){to(e);for(var r,n=ro(t),o=no(t),i=o.length,s=0;i>s;)eo.f(e,r=o[s++],n[r]);return e};var oo,io=Re("document","documentElement"),so=be,ao=An,uo=Jn,co=dr,lo=io,fo=de,ho="prototype",po="script",vo=fr("IE_PROTO"),yo=function(){},mo=function(e){return"<"+po+">"+e+"</"+po+">"},go=function(e){e.write(mo("")),e.close();var t=e.parentWindow.Object;return e=null,t},bo=function(){try{oo=new ActiveXObject("htmlfile")}catch(e){}var e,t,r;bo="undefined"!=typeof document?document.domain&&oo?go(oo):(t=fo("iframe"),r="java"+po+":",t.style.display="none",lo.appendChild(t),t.src=String(r),(e=t.contentWindow.document).open(),e.write(mo("document.F=Object")),e.close(),e.F):go(oo);for(var n=uo.length;n--;)delete bo[ho][uo[n]];return bo()};co[vo]=!0;var wo,_o,So,Eo=Object.create||function(e,t){var r;return null!==e?(yo[ho]=so(e),r=new yo,yo[ho]=null,r[vo]=e):r=bo(),void 0===t?r:ao.f(r,t)},Io=!R((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),Oo=_t,To=te,Ao=gt,Ro=Io,Po=fr("IE_PROTO"),Co=Object,No=Co.prototype,xo=Ro?Co.getPrototypeOf:function(e){var t=Ao(e);if(Oo(t,Po))return t[Po];var r=t.constructor;return To(r)&&t instanceof r?r.prototype:t instanceof Co?No:null},Lo=ur,Uo=function(e,t,r,n){return n&&n.enumerable?e[t]=r:Lo(e,t,r),e},ko=R,Do=te,jo=se,qo=Eo,Mo=xo,Bo=Uo,Wo=kt("iterator"),Fo=!1;[].keys&&("next"in(So=[].keys())?(_o=Mo(Mo(So)))!==Object.prototype&&(wo=_o):Fo=!0),wo=!jo(wo)||ko((function(){var e={};return wo[Wo].call(e)!==e}))?{}:qo(wo),Do(wo[Wo])||Bo(wo,Wo,(function(){return this}));var Vo={IteratorPrototype:wo,BUGGY_SAFARI_ITERATORS:Fo},Ho={};Ho[kt("toStringTag")]="z";var $o="[object z]"===String(Ho),Go=$o,zo=te,Ko=q,Jo=kt("toStringTag"),Yo=Object,Qo="Arguments"===Ko(function(){return arguments}()),Zo=Go?Ko:function(e){var t,r,n;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=function(e,t){try{return e[t]}catch(e){}}(t=Yo(e),Jo))?r:Qo?Ko(t):"Object"===(n=Ko(t))&&zo(t.callee)?"Arguments":n},Xo=Zo,ei=$o?{}.toString:function(){return"[object "+Xo(this)+"]"},ti=$o,ri=ue.f,ni=ur,oi=_t,ii=ei,si=kt("toStringTag"),ai=function(e,t,r,n){var o=r?e:e&&e.prototype;o&&(oi(o,si)||ri(o,si,{configurable:!0,value:t}),n&&!ti&&ni(o,"toString",ii))},ui=Vo.IteratorPrototype,ci=Eo,li=ir,fi=ai,di=Q,hi=function(){return this},pi=function(e,t,r,n){var o=t+" Iterator";return e.prototype=ci(ui,{next:li(+!n,r)}),fi(e,o,!1,!0),di[o]=hi,e},vi=wn,yi=Se,mi=Tn,gi=pi,bi=xo,wi=ai,_i=Uo,Si=Q,Ei=Vo,Ii=mi.PROPER,Oi=Ei.BUGGY_SAFARI_ITERATORS,Ti=kt("iterator"),Ai="keys",Ri="values",Pi="entries",Ci=function(){return this},Ni=function(e,t,r,n,o,i,s){gi(r,t,n);var a,u,c,l=function(e){if(e===o&&v)return v;if(!Oi&&e&&e in h)return h[e];switch(e){case Ai:case Ri:case Pi:return function(){return new r(this,e)}}return function(){return new r(this)}},f=t+" Iterator",d=!1,h=e.prototype,p=h[Ti]||h["@@iterator"]||o&&h[o],v=!Oi&&p||l(o),y="Array"===t&&h.entries||p;if(y&&(a=bi(y.call(new e)))!==Object.prototype&&a.next&&(wi(a,f,!0,!0),Si[f]=Ci),Ii&&o===Ri&&p&&p.name!==Ri&&(d=!0,v=function(){return yi(p,this)}),o)if(u={values:l(Ri),keys:i?v:l(Ai),entries:l(Pi)},s)for(c in u)(Oi||d||!(c in h))&&_i(h,c,u[c]);else vi({target:t,proto:!0,forced:Oi||d},u);return s&&h[Ti]!==v&&_i(h,Ti,v,{name:o}),Si[t]=v,u},xi=function(e,t){return{value:e,done:t}},Li=Y,Ui=Q,ki=Tr;ue.f;var Di=Ni,ji=xi,qi="Array Iterator",Mi=ki.set,Bi=ki.getterFor(qi);Di(Array,"Array",(function(e,t){Mi(this,{type:qi,target:Li(e),index:0,kind:t})}),(function(){var e=Bi(this),t=e.target,r=e.index++;if(!t||r>=t.length)return e.target=null,ji(void 0,!0);switch(e.kind){case"keys":return ji(r,!1);case"values":return ji(t[r],!1)}return ji([r,t[r]],!1)}),"values"),Ui.Arguments=Ui.Array;var Wi=wn,Fi=U,Vi=kn,Hi=RangeError,$i=String.fromCharCode,Gi=String.fromCodePoint,zi=Fi([].join);Wi({target:"String",stat:!0,arity:1,forced:!!Gi&&1!==Gi.length},{fromCodePoint:function(e){for(var t,r=[],n=arguments.length,o=0;n>o;){if(t=+arguments[o++],Vi(t,1114111)!==t)throw new Hi(t+" is not a valid code point");r[o]=t<65536?$i(t):$i(55296+((t-=65536)>>10),t%1024+56320)}return zi(r,"")}});var Ki=X,Ji=ae,Yi=Object.getOwnPropertyDescriptor,Qi=R,Zi=!0,Xi=kt("iterator"),es=!Qi((function(){var e=new URL("b?a=1&b=2&c=3","https://a"),t=e.searchParams,r=new URLSearchParams("a=1&a=2&b=3"),n="";return e.pathname="c%20d",t.forEach((function(e,r){t.delete("b"),n+=r+e})),r.delete("a",2),r.delete("b",void 0),!e.toJSON||!r.has("a",1)||r.has("a",2)||!r.has("a",void 0)||r.has("b")||!t.size&&Zi||!t.sort||"https://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[Xi]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("https://тест").host||"#%D0%B1"!==new URL("https://a#б").hash||"a1c3"!==n||"x"!==new URL("https://x",void 0).host})),ts=ue,rs=function(e,t,r){return ts.f(e,t,r)},ns=Uo,os=Pe,is=TypeError,ss=function(e,t){if(os(t,e))return e;throw new is("Incorrect invocation")},as=Zo,us=String,cs=function(e){if("Symbol"===as(e))throw new TypeError("Cannot convert a Symbol value to a string");return us(e)},ls=Zo,fs=rt,ds=H,hs=Q,ps=kt("iterator"),vs=function(e){if(!ds(e))return fs(e,ps)||fs(e,"@@iterator")||hs[ls(e)]},ys=Se,ms=Xe,gs=be,bs=Je,ws=vs,_s=TypeError,Ss=function(e,t){var r=arguments.length<2?ws(e):t;if(ms(r))return gs(ys(r,e));throw new _s(bs(e)+" is not iterable")},Es=TypeError,Is=function(e,t){if(e<t)throw new Es("Not enough arguments");return e},Os=U([].slice),Ts=Os,As=Math.floor,Rs=function(e,t){var r=e.length;if(r<8)for(var n,o,i=1;i<r;){for(o=i,n=e[i];o&&t(e[o-1],n)>0;)e[o]=e[--o];o!==i++&&(e[o]=n)}else for(var s=As(r/2),a=Rs(Ts(e,0,s),t),u=Rs(Ts(e,s),t),c=a.length,l=u.length,f=0,d=0;f<c||d<l;)e[f+d]=f<c&&d<l?t(a[f],u[d])<=0?a[f++]:u[d++]:f<c?a[f++]:u[d++];return e},Ps=wn,Cs=X,Ns=function(e){if(!Ji)return Ki[e];var t=Yi(Ki,e);return t&&t.value},xs=Re,Ls=Se,Us=U,ks=ae,Ds=es,js=Uo,qs=rs,Ms=function(e,t,r){for(var n in t)r&&r.unsafe&&e[n]?e[n]=t[n]:ns(e,n,t[n],r);return e},Bs=ai,Ws=pi,Fs=Tr,Vs=ss,Hs=te,$s=_t,Gs=un,zs=Zo,Ks=be,Js=se,Ys=cs,Qs=Eo,Zs=ir,Xs=Ss,ea=vs,ta=xi,ra=Is,na=Rs,oa=kt("iterator"),ia="URLSearchParams",sa=ia+"Iterator",aa=Fs.set,ua=Fs.getterFor(ia),ca=Fs.getterFor(sa),la=Ns("fetch"),fa=Ns("Request"),da=Ns("Headers"),ha=fa&&fa.prototype,pa=da&&da.prototype,va=Cs.TypeError,ya=Cs.encodeURIComponent,ma=String.fromCharCode,ga=xs("String","fromCodePoint"),ba=parseInt,wa=Us("".charAt),_a=Us([].join),Sa=Us([].push),Ea=Us("".replace),Ia=Us([].shift),Oa=Us([].splice),Ta=Us("".split),Aa=Us("".slice),Ra=Us(/./.exec),Pa=/\+/g,Ca=/^[0-9a-f]+$/i,Na=function(e,t){var r=Aa(e,t,t+2);return Ra(Ca,r)?ba(r,16):NaN},xa=function(e){for(var t=0,r=128;r>0&&e&r;r>>=1)t++;return t},La=function(e){var t=null;switch(e.length){case 1:t=e[0];break;case 2:t=(31&e[0])<<6|63&e[1];break;case 3:t=(15&e[0])<<12|(63&e[1])<<6|63&e[2];break;case 4:t=(7&e[0])<<18|(63&e[1])<<12|(63&e[2])<<6|63&e[3]}return t>1114111?null:t},Ua=function(e){for(var t=(e=Ea(e,Pa," ")).length,r="",n=0;n<t;){var o=wa(e,n);if("%"===o){if("%"===wa(e,n+1)||n+3>t){r+="%",n++;continue}var i=Na(e,n+1);if(i!=i){r+=o,n++;continue}n+=2;var s=xa(i);if(0===s)o=ma(i);else{if(1===s||s>4){r+="�",n++;continue}for(var a=[i],u=1;u<s&&!(3+ ++n>t||"%"!==wa(e,n));){var c=Na(e,n+1);if(c!=c){n+=3;break}if(c>191||c<128)break;Sa(a,c),n+=2,u++}if(a.length!==s){r+="�";continue}var l=La(a);null===l?r+="�":o=ga(l)}}r+=o,n++}return r},ka=/[!'()~]|%20/g,Da={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},ja=function(e){return Da[e]},qa=function(e){return Ea(ya(e),ka,ja)},Ma=Ws((function(e,t){aa(this,{type:sa,target:ua(e).entries,index:0,kind:t})}),ia,(function(){var e=ca(this),t=e.target,r=e.index++;if(!t||r>=t.length)return e.target=null,ta(void 0,!0);var n=t[r];switch(e.kind){case"keys":return ta(n.key,!1);case"values":return ta(n.value,!1)}return ta([n.key,n.value],!1)}),!0),Ba=function(e){this.entries=[],this.url=null,void 0!==e&&(Js(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===wa(e,0)?Aa(e,1):e:Ys(e)))};Ba.prototype={type:ia,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,n,o,i,s,a,u=this.entries,c=ea(e);if(c)for(r=(t=Xs(e,c)).next;!(n=Ls(r,t)).done;){if(i=(o=Xs(Ks(n.value))).next,(s=Ls(i,o)).done||(a=Ls(i,o)).done||!Ls(i,o).done)throw new va("Expected sequence with length 2");Sa(u,{key:Ys(s.value),value:Ys(a.value)})}else for(var l in e)$s(e,l)&&Sa(u,{key:l,value:Ys(e[l])})},parseQuery:function(e){if(e)for(var t,r,n=this.entries,o=Ta(e,"&"),i=0;i<o.length;)(t=o[i++]).length&&(r=Ta(t,"="),Sa(n,{key:Ua(Ia(r)),value:Ua(_a(r,"="))}))},serialize:function(){for(var e,t=this.entries,r=[],n=0;n<t.length;)e=t[n++],Sa(r,qa(e.key)+"="+qa(e.value));return _a(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var Wa=function(){Vs(this,Fa);var e=aa(this,new Ba(arguments.length>0?arguments[0]:void 0));ks||(this.size=e.entries.length)},Fa=Wa.prototype;if(Ms(Fa,{append:function(e,t){var r=ua(this);ra(arguments.length,2),Sa(r.entries,{key:Ys(e),value:Ys(t)}),ks||this.length++,r.updateURL()},delete:function(e){for(var t=ua(this),r=ra(arguments.length,1),n=t.entries,o=Ys(e),i=r<2?void 0:arguments[1],s=void 0===i?i:Ys(i),a=0;a<n.length;){var u=n[a];if(u.key!==o||void 0!==s&&u.value!==s)a++;else if(Oa(n,a,1),void 0!==s)break}ks||(this.size=n.length),t.updateURL()},get:function(e){var t=ua(this).entries;ra(arguments.length,1);for(var r=Ys(e),n=0;n<t.length;n++)if(t[n].key===r)return t[n].value;return null},getAll:function(e){var t=ua(this).entries;ra(arguments.length,1);for(var r=Ys(e),n=[],o=0;o<t.length;o++)t[o].key===r&&Sa(n,t[o].value);return n},has:function(e){for(var t=ua(this).entries,r=ra(arguments.length,1),n=Ys(e),o=r<2?void 0:arguments[1],i=void 0===o?o:Ys(o),s=0;s<t.length;){var a=t[s++];if(a.key===n&&(void 0===i||a.value===i))return!0}return!1},set:function(e,t){var r=ua(this);ra(arguments.length,1);for(var n,o=r.entries,i=!1,s=Ys(e),a=Ys(t),u=0;u<o.length;u++)(n=o[u]).key===s&&(i?Oa(o,u--,1):(i=!0,n.value=a));i||Sa(o,{key:s,value:a}),ks||(this.size=o.length),r.updateURL()},sort:function(){var e=ua(this);na(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,r=ua(this).entries,n=Gs(e,arguments.length>1?arguments[1]:void 0),o=0;o<r.length;)n((t=r[o++]).value,t.key,this)},keys:function(){return new Ma(this,"keys")},values:function(){return new Ma(this,"values")},entries:function(){return new Ma(this,"entries")}},{enumerable:!0}),js(Fa,oa,Fa.entries,{name:"entries"}),js(Fa,"toString",(function(){return ua(this).serialize()}),{enumerable:!0}),ks&&qs(Fa,"size",{get:function(){return ua(this).entries.length},configurable:!0,enumerable:!0}),Bs(Wa,ia),Ps({global:!0,constructor:!0,forced:!Ds},{URLSearchParams:Wa}),!Ds&&Hs(da)){var Va=Us(pa.has),Ha=Us(pa.set),$a=function(e){if(Js(e)){var t,r=e.body;if(zs(r)===ia)return t=e.headers?new da(e.headers):new da,Va(t,"content-type")||Ha(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),Qs(e,{body:Zs(0,Ys(r)),headers:Zs(0,t)})}return e};if(Hs(la)&&Ps({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return la(e,arguments.length>1?$a(arguments[1]):{})}}),Hs(fa)){var Ga=function(e){return Vs(this,ha),new fa(e,arguments.length>1?$a(arguments[1]):{})};ha.constructor=Ga,Ga.prototype=ha,Ps({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:Ga})}}var za={URLSearchParams:Wa,getState:ua},Ka=U,Ja=Nn,Ya=cs,Qa=z,Za=Ka("".charAt),Xa=Ka("".charCodeAt),eu=Ka("".slice),tu=function(e){return function(t,r){var n,o,i=Ya(Qa(t)),s=Ja(r),a=i.length;return s<0||s>=a?e?"":void 0:(n=Xa(i,s))<55296||n>56319||s+1===a||(o=Xa(i,s+1))<56320||o>57343?e?Za(i,s):n:e?eu(i,s,s+2):o-56320+(n-55296<<10)+65536}},ru={codeAt:tu(!1),charAt:tu(!0)},nu=ru.charAt,ou=cs,iu=Tr,su=Ni,au=xi,uu="String Iterator",cu=iu.set,lu=iu.getterFor(uu);su(String,"String",(function(e){cu(this,{type:uu,string:ou(e),index:0})}),(function(){var e,t=lu(this),r=t.string,n=t.index;return n>=r.length?au(void 0,!0):(e=nu(r,n),t.index+=e.length,au(e,!1))}));var fu={};fu.f=Object.getOwnPropertySymbols;var du=ae,hu=U,pu=Se,vu=R,yu=Qn,mu=fu,gu=Dr,bu=gt,wu=V,_u=Object.assign,Su=Object.defineProperty,Eu=hu([].concat),Iu=!_u||vu((function(){if(du&&1!==_u({b:1},_u(Su({},"a",{enumerable:!0,get:function(){Su(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},r=Symbol("assign detection"),n="abcdefghijklmnopqrst";return e[r]=7,n.split("").forEach((function(e){t[e]=e})),7!==_u({},e)[r]||yu(_u({},t)).join("")!==n}))?function(e,t){for(var r=bu(e),n=arguments.length,o=1,i=mu.f,s=gu.f;n>o;)for(var a,u=wu(arguments[o++]),c=i?Eu(yu(u),i(u)):yu(u),l=c.length,f=0;l>f;)a=c[f++],du&&!pu(s,u,a)||(r[a]=u[a]);return r}:_u,Ou=Se,Tu=be,Au=rt,Ru=be,Pu=Q,Cu=kt("iterator"),Nu=Array.prototype,xu=te,Lu=ht,Uu=U(Function.toString);xu(Lu.inspectSource)||(Lu.inspectSource=function(e){return Uu(e)});var ku=Lu.inspectSource,Du=U,ju=R,qu=te,Mu=Zo,Bu=ku,Wu=function(){},Fu=Re("Reflect","construct"),Vu=/^\s*(?:class|function)\b/,Hu=Du(Vu.exec),$u=!Vu.test(Wu),Gu=function(e){if(!qu(e))return!1;try{return Fu(Wu,[],e),!0}catch(e){return!1}},zu=function(e){if(!qu(e))return!1;switch(Mu(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return $u||!!Hu(Vu,Bu(e))}catch(e){return!0}};zu.sham=!0;var Ku,Ju=!Fu||ju((function(){var e;return Gu(Gu.call)||!Gu(Object)||!Gu((function(){e=!0}))||e}))?zu:Gu,Yu=ae,Qu=ue,Zu=ir,Xu=un,ec=Se,tc=gt,rc=function(e,t,r,n){try{return n?t(Ru(r)[0],r[1]):t(r)}catch(t){!function(e,t,r){var n,o;Tu(e);try{if(!(n=Au(e,"return"))){if("throw"===t)throw r;return r}n=Ou(n,e)}catch(e){o=!0,n=e}if("throw"===t)throw r;if(o)throw n;Tu(n)}(e,"throw",t)}},nc=function(e){return void 0!==e&&(Pu.Array===e||Nu[Cu]===e)},oc=Ju,ic=qn,sc=function(e,t,r){Yu?Qu.f(e,t,Zu(0,r)):e[t]=r},ac=Ss,uc=vs,cc=Array,lc=U,fc=2147483647,dc=/[^\0-\u007E]/,hc=/[.\u3002\uFF0E\uFF61]/g,pc="Overflow: input needs wider integers to process",vc=RangeError,yc=lc(hc.exec),mc=Math.floor,gc=String.fromCharCode,bc=lc("".charCodeAt),wc=lc([].join),_c=lc([].push),Sc=lc("".replace),Ec=lc("".split),Ic=lc("".toLowerCase),Oc=function(e){return e+22+75*(e<26)},Tc=function(e,t,r){var n=0;for(e=r?mc(e/700):e>>1,e+=mc(e/t);e>455;)e=mc(e/35),n+=36;return mc(n+36*e/(e+38))},Ac=function(e){var t,r,n=[],o=(e=function(e){for(var t=[],r=0,n=e.length;r<n;){var o=bc(e,r++);if(o>=55296&&o<=56319&&r<n){var i=bc(e,r++);56320==(64512&i)?_c(t,((1023&o)<<10)+(1023&i)+65536):(_c(t,o),r--)}else _c(t,o)}return t}(e)).length,i=128,s=0,a=72;for(t=0;t<e.length;t++)(r=e[t])<128&&_c(n,gc(r));var u=n.length,c=u;for(u&&_c(n,"-");c<o;){var l=fc;for(t=0;t<e.length;t++)(r=e[t])>=i&&r<l&&(l=r);var f=c+1;if(l-i>mc((fc-s)/f))throw new vc(pc);for(s+=(l-i)*f,i=l,t=0;t<e.length;t++){if((r=e[t])<i&&++s>fc)throw new vc(pc);if(r===i){for(var d=s,h=36;;){var p=h<=a?1:h>=a+26?26:h-a;if(d<p)break;var v=d-p,y=36-p;_c(n,gc(Oc(p+v%y))),d=mc(v/y),h+=36}_c(n,gc(Oc(d))),a=Tc(s,f,c===u),s=0,c++}}s++,i++}return wc(n,"")},Rc=wn,Pc=ae,Cc=es,Nc=X,xc=un,Lc=U,Uc=Uo,kc=rs,Dc=ss,jc=_t,qc=Iu,Mc=function(e){var t=tc(e),r=oc(this),n=arguments.length,o=n>1?arguments[1]:void 0,i=void 0!==o;i&&(o=Xu(o,n>2?arguments[2]:void 0));var s,a,u,c,l,f,d=uc(t),h=0;if(!d||this===cc&&nc(d))for(s=ic(t),a=r?new this(s):cc(s);s>h;h++)f=i?o(t[h],h):t[h],sc(a,h,f);else for(a=r?new this:[],l=(c=ac(t,d)).next;!(u=ec(l,c)).done;h++)f=i?rc(c,o,[u.value,h],!0):u.value,sc(a,h,f);return a.length=h,a},Bc=Os,Wc=ru.codeAt,Fc=function(e){var t,r,n=[],o=Ec(Sc(Ic(e),hc,"."),".");for(t=0;t<o.length;t++)r=o[t],_c(n,yc(dc,r)?"xn--"+Ac(r):r);return wc(n,".")},Vc=cs,Hc=ai,$c=Is,Gc=za,zc=Tr,Kc=zc.set,Jc=zc.getterFor("URL"),Yc=Gc.URLSearchParams,Qc=Gc.getState,Zc=Nc.URL,Xc=Nc.TypeError,el=Nc.parseInt,tl=Math.floor,rl=Math.pow,nl=Lc("".charAt),ol=Lc(/./.exec),il=Lc([].join),sl=Lc(1.1.toString),al=Lc([].pop),ul=Lc([].push),cl=Lc("".replace),ll=Lc([].shift),fl=Lc("".split),dl=Lc("".slice),hl=Lc("".toLowerCase),pl=Lc([].unshift),vl="Invalid scheme",yl="Invalid host",ml="Invalid port",gl=/[a-z]/i,bl=/[\d+-.a-z]/i,wl=/\d/,_l=/^0x/i,Sl=/^[0-7]+$/,El=/^\d+$/,Il=/^[\da-f]+$/i,Ol=/[\0\t\n\r #%/:<>?@[\\\]^|]/,Tl=/[\0\t\n\r #/:<>?@[\\\]^|]/,Al=/^[\u0000-\u0020]+/,Rl=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,Pl=/[\t\n\r]/g,Cl=function(e){var t,r,n,o;if("number"==typeof e){for(t=[],r=0;r<4;r++)pl(t,e%256),e=tl(e/256);return il(t,".")}if("object"==typeof e){for(t="",n=function(e){for(var t=null,r=1,n=null,o=0,i=0;i<8;i++)0!==e[i]?(o>r&&(t=n,r=o),n=null,o=0):(null===n&&(n=i),++o);return o>r?n:t}(e),r=0;r<8;r++)o&&0===e[r]||(o&&(o=!1),n===r?(t+=r?":":"::",o=!0):(t+=sl(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},Nl={},xl=qc({},Nl,{" ":1,'"':1,"<":1,">":1,"`":1}),Ll=qc({},xl,{"#":1,"?":1,"{":1,"}":1}),Ul=qc({},Ll,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),kl=function(e,t){var r=Wc(e,0);return r>32&&r<127&&!jc(t,e)?e:encodeURIComponent(e)},Dl={ftp:21,file:null,http:80,https:443,ws:80,wss:443},jl=function(e,t){var r;return 2===e.length&&ol(gl,nl(e,0))&&(":"===(r=nl(e,1))||!t&&"|"===r)},ql=function(e){var t;return e.length>1&&jl(dl(e,0,2))&&(2===e.length||"/"===(t=nl(e,2))||"\\"===t||"?"===t||"#"===t)},Ml=function(e){return"."===e||"%2e"===hl(e)},Bl={},Wl={},Fl={},Vl={},Hl={},$l={},Gl={},zl={},Kl={},Jl={},Yl={},Ql={},Zl={},Xl={},ef={},tf={},rf={},nf={},of={},sf={},af={},uf=function(e,t,r){var n,o,i,s=Vc(e);if(t){if(o=this.parse(s))throw new Xc(o);this.searchParams=null}else{if(void 0!==r&&(n=new uf(r,!0)),o=this.parse(s,null,n))throw new Xc(o);(i=Qc(new Yc)).bindURL(this),this.searchParams=i}};uf.prototype={type:"URL",parse:function(e,t,r){var n,o,i,s,a,u=this,c=t||Bl,l=0,f="",d=!1,h=!1,p=!1;for(e=Vc(e),t||(u.scheme="",u.username="",u.password="",u.host=null,u.port=null,u.path=[],u.query=null,u.fragment=null,u.cannotBeABaseURL=!1,e=cl(e,Al,""),e=cl(e,Rl,"$1")),e=cl(e,Pl,""),n=Mc(e);l<=n.length;){switch(o=n[l],c){case Bl:if(!o||!ol(gl,o)){if(t)return vl;c=Fl;continue}f+=hl(o),c=Wl;break;case Wl:if(o&&(ol(bl,o)||"+"===o||"-"===o||"."===o))f+=hl(o);else{if(":"!==o){if(t)return vl;f="",c=Fl,l=0;continue}if(t&&(u.isSpecial()!==jc(Dl,f)||"file"===f&&(u.includesCredentials()||null!==u.port)||"file"===u.scheme&&!u.host))return;if(u.scheme=f,t)return void(u.isSpecial()&&Dl[u.scheme]===u.port&&(u.port=null));f="","file"===u.scheme?c=Xl:u.isSpecial()&&r&&r.scheme===u.scheme?c=Vl:u.isSpecial()?c=zl:"/"===n[l+1]?(c=Hl,l++):(u.cannotBeABaseURL=!0,ul(u.path,""),c=of)}break;case Fl:if(!r||r.cannotBeABaseURL&&"#"!==o)return vl;if(r.cannotBeABaseURL&&"#"===o){u.scheme=r.scheme,u.path=Bc(r.path),u.query=r.query,u.fragment="",u.cannotBeABaseURL=!0,c=af;break}c="file"===r.scheme?Xl:$l;continue;case Vl:if("/"!==o||"/"!==n[l+1]){c=$l;continue}c=Kl,l++;break;case Hl:if("/"===o){c=Jl;break}c=nf;continue;case $l:if(u.scheme=r.scheme,o===Ku)u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=Bc(r.path),u.query=r.query;else if("/"===o||"\\"===o&&u.isSpecial())c=Gl;else if("?"===o)u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=Bc(r.path),u.query="",c=sf;else{if("#"!==o){u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=Bc(r.path),u.path.length--,c=nf;continue}u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=Bc(r.path),u.query=r.query,u.fragment="",c=af}break;case Gl:if(!u.isSpecial()||"/"!==o&&"\\"!==o){if("/"!==o){u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,c=nf;continue}c=Jl}else c=Kl;break;case zl:if(c=Kl,"/"!==o||"/"!==nl(f,l+1))continue;l++;break;case Kl:if("/"!==o&&"\\"!==o){c=Jl;continue}break;case Jl:if("@"===o){d&&(f="%40"+f),d=!0,i=Mc(f);for(var v=0;v<i.length;v++){var y=i[v];if(":"!==y||p){var m=kl(y,Ul);p?u.password+=m:u.username+=m}else p=!0}f=""}else if(o===Ku||"/"===o||"?"===o||"#"===o||"\\"===o&&u.isSpecial()){if(d&&""===f)return"Invalid authority";l-=Mc(f).length+1,f="",c=Yl}else f+=o;break;case Yl:case Ql:if(t&&"file"===u.scheme){c=tf;continue}if(":"!==o||h){if(o===Ku||"/"===o||"?"===o||"#"===o||"\\"===o&&u.isSpecial()){if(u.isSpecial()&&""===f)return yl;if(t&&""===f&&(u.includesCredentials()||null!==u.port))return;if(s=u.parseHost(f))return s;if(f="",c=rf,t)return;continue}"["===o?h=!0:"]"===o&&(h=!1),f+=o}else{if(""===f)return yl;if(s=u.parseHost(f))return s;if(f="",c=Zl,t===Ql)return}break;case Zl:if(!ol(wl,o)){if(o===Ku||"/"===o||"?"===o||"#"===o||"\\"===o&&u.isSpecial()||t){if(""!==f){var g=el(f,10);if(g>65535)return ml;u.port=u.isSpecial()&&g===Dl[u.scheme]?null:g,f=""}if(t)return;c=rf;continue}return ml}f+=o;break;case Xl:if(u.scheme="file","/"===o||"\\"===o)c=ef;else{if(!r||"file"!==r.scheme){c=nf;continue}switch(o){case Ku:u.host=r.host,u.path=Bc(r.path),u.query=r.query;break;case"?":u.host=r.host,u.path=Bc(r.path),u.query="",c=sf;break;case"#":u.host=r.host,u.path=Bc(r.path),u.query=r.query,u.fragment="",c=af;break;default:ql(il(Bc(n,l),""))||(u.host=r.host,u.path=Bc(r.path),u.shortenPath()),c=nf;continue}}break;case ef:if("/"===o||"\\"===o){c=tf;break}r&&"file"===r.scheme&&!ql(il(Bc(n,l),""))&&(jl(r.path[0],!0)?ul(u.path,r.path[0]):u.host=r.host),c=nf;continue;case tf:if(o===Ku||"/"===o||"\\"===o||"?"===o||"#"===o){if(!t&&jl(f))c=nf;else if(""===f){if(u.host="",t)return;c=rf}else{if(s=u.parseHost(f))return s;if("localhost"===u.host&&(u.host=""),t)return;f="",c=rf}continue}f+=o;break;case rf:if(u.isSpecial()){if(c=nf,"/"!==o&&"\\"!==o)continue}else if(t||"?"!==o)if(t||"#"!==o){if(o!==Ku&&(c=nf,"/"!==o))continue}else u.fragment="",c=af;else u.query="",c=sf;break;case nf:if(o===Ku||"/"===o||"\\"===o&&u.isSpecial()||!t&&("?"===o||"#"===o)){if(".."===(a=hl(a=f))||"%2e."===a||".%2e"===a||"%2e%2e"===a?(u.shortenPath(),"/"===o||"\\"===o&&u.isSpecial()||ul(u.path,"")):Ml(f)?"/"===o||"\\"===o&&u.isSpecial()||ul(u.path,""):("file"===u.scheme&&!u.path.length&&jl(f)&&(u.host&&(u.host=""),f=nl(f,0)+":"),ul(u.path,f)),f="","file"===u.scheme&&(o===Ku||"?"===o||"#"===o))for(;u.path.length>1&&""===u.path[0];)ll(u.path);"?"===o?(u.query="",c=sf):"#"===o&&(u.fragment="",c=af)}else f+=kl(o,Ll);break;case of:"?"===o?(u.query="",c=sf):"#"===o?(u.fragment="",c=af):o!==Ku&&(u.path[0]+=kl(o,Nl));break;case sf:t||"#"!==o?o!==Ku&&("'"===o&&u.isSpecial()?u.query+="%27":u.query+="#"===o?"%23":kl(o,Nl)):(u.fragment="",c=af);break;case af:o!==Ku&&(u.fragment+=kl(o,xl))}l++}},parseHost:function(e){var t,r,n;if("["===nl(e,0)){if("]"!==nl(e,e.length-1))return yl;if(!(t=function(e){var t,r,n,o,i,s,a,u=[0,0,0,0,0,0,0,0],c=0,l=null,f=0,d=function(){return nl(e,f)};if(":"===d()){if(":"!==nl(e,1))return;f+=2,l=++c}for(;d();){if(8===c)return;if(":"!==d()){for(t=r=0;r<4&&ol(Il,d());)t=16*t+el(d(),16),f++,r++;if("."===d()){if(0===r)return;if(f-=r,c>6)return;for(n=0;d();){if(o=null,n>0){if(!("."===d()&&n<4))return;f++}if(!ol(wl,d()))return;for(;ol(wl,d());){if(i=el(d(),10),null===o)o=i;else{if(0===o)return;o=10*o+i}if(o>255)return;f++}u[c]=256*u[c]+o,2!=++n&&4!==n||c++}if(4!==n)return;break}if(":"===d()){if(f++,!d())return}else if(d())return;u[c++]=t}else{if(null!==l)return;f++,l=++c}}if(null!==l)for(s=c-l,c=7;0!==c&&s>0;)a=u[c],u[c--]=u[l+s-1],u[l+--s]=a;else if(8!==c)return;return u}(dl(e,1,-1))))return yl;this.host=t}else if(this.isSpecial()){if(e=Fc(e),ol(Ol,e))return yl;if(null===(t=function(e){var t,r,n,o,i,s,a,u=fl(e,".");if(u.length&&""===u[u.length-1]&&u.length--,(t=u.length)>4)return e;for(r=[],n=0;n<t;n++){if(""===(o=u[n]))return e;if(i=10,o.length>1&&"0"===nl(o,0)&&(i=ol(_l,o)?16:8,o=dl(o,8===i?1:2)),""===o)s=0;else{if(!ol(10===i?El:8===i?Sl:Il,o))return e;s=el(o,i)}ul(r,s)}for(n=0;n<t;n++)if(s=r[n],n===t-1){if(s>=rl(256,5-t))return null}else if(s>255)return null;for(a=al(r),n=0;n<r.length;n++)a+=r[n]*rl(256,3-n);return a}(e)))return yl;this.host=t}else{if(ol(Tl,e))return yl;for(t="",r=Mc(e),n=0;n<r.length;n++)t+=kl(r[n],Nl);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"===this.scheme},includesCredentials:function(){return""!==this.username||""!==this.password},isSpecial:function(){return jc(Dl,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"===this.scheme&&1===t&&jl(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,r=e.username,n=e.password,o=e.host,i=e.port,s=e.path,a=e.query,u=e.fragment,c=t+":";return null!==o?(c+="//",e.includesCredentials()&&(c+=r+(n?":"+n:"")+"@"),c+=Cl(o),null!==i&&(c+=":"+i)):"file"===t&&(c+="//"),c+=e.cannotBeABaseURL?s[0]:s.length?"/"+il(s,"/"):"",null!==a&&(c+="?"+a),null!==u&&(c+="#"+u),c},setHref:function(e){var t=this.parse(e);if(t)throw new Xc(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"===e)try{return new cf(e.path[0]).origin}catch(e){return"null"}return"file"!==e&&this.isSpecial()?e+"://"+Cl(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(Vc(e)+":",Bl)},getUsername:function(){return this.username},setUsername:function(e){var t=Mc(Vc(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<t.length;r++)this.username+=kl(t[r],Ul)}},getPassword:function(){return this.password},setPassword:function(e){var t=Mc(Vc(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<t.length;r++)this.password+=kl(t[r],Ul)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?Cl(e):Cl(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,Yl)},getHostname:function(){var e=this.host;return null===e?"":Cl(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,Ql)},getPort:function(){var e=this.port;return null===e?"":Vc(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""===(e=Vc(e))?this.port=null:this.parse(e,Zl))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+il(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,rf))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""===(e=Vc(e))?this.query=null:("?"===nl(e,0)&&(e=dl(e,1)),this.query="",this.parse(e,sf)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!==(e=Vc(e))?("#"===nl(e,0)&&(e=dl(e,1)),this.fragment="",this.parse(e,af)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var cf=function(e){var t=Dc(this,lf),r=$c(arguments.length,1)>1?arguments[1]:void 0,n=Kc(t,new uf(e,!1,r));Pc||(t.href=n.serialize(),t.origin=n.getOrigin(),t.protocol=n.getProtocol(),t.username=n.getUsername(),t.password=n.getPassword(),t.host=n.getHost(),t.hostname=n.getHostname(),t.port=n.getPort(),t.pathname=n.getPathname(),t.search=n.getSearch(),t.searchParams=n.getSearchParams(),t.hash=n.getHash())},lf=cf.prototype,ff=function(e,t){return{get:function(){return Jc(this)[e]()},set:t&&function(e){return Jc(this)[t](e)},configurable:!0,enumerable:!0}};if(Pc&&(kc(lf,"href",ff("serialize","setHref")),kc(lf,"origin",ff("getOrigin")),kc(lf,"protocol",ff("getProtocol","setProtocol")),kc(lf,"username",ff("getUsername","setUsername")),kc(lf,"password",ff("getPassword","setPassword")),kc(lf,"host",ff("getHost","setHost")),kc(lf,"hostname",ff("getHostname","setHostname")),kc(lf,"port",ff("getPort","setPort")),kc(lf,"pathname",ff("getPathname","setPathname")),kc(lf,"search",ff("getSearch","setSearch")),kc(lf,"searchParams",ff("getSearchParams")),kc(lf,"hash",ff("getHash","setHash"))),Uc(lf,"toJSON",(function(){return Jc(this).serialize()}),{enumerable:!0}),Uc(lf,"toString",(function(){return Jc(this).serialize()}),{enumerable:!0}),Zc){var df=Zc.createObjectURL,hf=Zc.revokeObjectURL;df&&Uc(cf,"createObjectURL",xc(df,Zc)),hf&&Uc(cf,"revokeObjectURL",xc(hf,Zc))}Hc(cf,"URL"),Rc({global:!0,constructor:!0,forced:!Cc,sham:!Pc},{URL:cf});var pf=wn,vf=R,yf=Is,mf=cs,gf=es,bf=Re("URL"),wf=gf&&vf((function(){bf.canParse()})),_f=vf((function(){return 1!==bf.canParse.length}));pf({target:"URL",stat:!0,forced:!wf||_f},{canParse:function(e){var t=yf(arguments.length,1),r=mf(e),n=t<2||void 0===arguments[1]?void 0:mf(arguments[1]);try{return!!new bf(r,n)}catch(e){return!1}}});var Sf=wn,Ef=Is,If=cs,Of=es,Tf=Re("URL");Sf({target:"URL",stat:!0,forced:!Of},{parse:function(e){var t=Ef(arguments.length,1),r=If(e),n=t<2||void 0===arguments[1]?void 0:If(arguments[1]);try{return new Tf(r,n)}catch(e){return null}}});var Af=O(Ee.URL),Rf=function(e){function t(t){var r=e.call(this,t.message)||this;return r.name="PostgrestError",r.details=t.details,r.hint=t.hint,r.code=t.code,r}return n(t,e),t}(Error),Pf=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.select=function(e){var t=!1,r=(null!=e?e:"*").split("").map((function(e){return/\s/.test(e)&&!t?"":('"'===e&&(t=!t),e)})).join("");return this.url.searchParams.set("select",r),this.headers.append("Prefer","return=representation"),this},t.prototype.order=function(e,t){var r=void 0===t?{}:t,n=r.ascending,o=void 0===n||n,i=r.nullsFirst,s=r.foreignTable,a=r.referencedTable,u=void 0===a?s:a,c=u?"".concat(u,".order"):"order",l=this.url.searchParams.get(c);return this.url.searchParams.set(c,"".concat(l?"".concat(l,","):"").concat(e,".").concat(o?"asc":"desc").concat(void 0===i?"":i?".nullsfirst":".nullslast")),this},t.prototype.limit=function(e,t){var r=void 0===t?{}:t,n=r.foreignTable,o=r.referencedTable,i=void 0===o?n:o,s=void 0===i?"limit":"".concat(i,".limit");return this.url.searchParams.set(s,"".concat(e)),this},t.prototype.range=function(e,t,r){var n=void 0===r?{}:r,o=n.foreignTable,i=n.referencedTable,s=void 0===i?o:i,a=void 0===s?"offset":"".concat(s,".offset"),u=void 0===s?"limit":"".concat(s,".limit");return this.url.searchParams.set(a,"".concat(e)),this.url.searchParams.set(u,"".concat(t-e+1)),this},t.prototype.abortSignal=function(e){return this.signal=e,this},t.prototype.single=function(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this},t.prototype.maybeSingle=function(){return"GET"===this.method?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this},t.prototype.csv=function(){return this.headers.set("Accept","text/csv"),this},t.prototype.geojson=function(){return this.headers.set("Accept","application/geo+json"),this},t.prototype.explain=function(e){var t,r=void 0===e?{}:e,n=r.analyze,o=void 0!==n&&n,i=r.verbose,s=void 0!==i&&i,a=r.settings,u=void 0!==a&&a,c=r.buffers,l=void 0!==c&&c,f=r.wal,d=void 0!==f&&f,h=r.format,p=void 0===h?"text":h,v=[o?"analyze":null,s?"verbose":null,u?"settings":null,l?"buffers":null,d?"wal":null].filter(Boolean).join("|"),y=null!==(t=this.headers.get("Accept"))&&void 0!==t?t:"application/json";return this.headers.set("Accept","application/vnd.pgrst.plan+".concat(p,'; for="').concat(y,'"; options=').concat(v,";")),this},t.prototype.rollback=function(){return this.headers.append("Prefer","tx=rollback"),this},t.prototype.returns=function(){return this},t.prototype.maxAffected=function(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer","max-affected=".concat(e)),this},t}(function(){function e(e){var t,r;this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=null!==(t=e.shouldThrowOnError)&&void 0!==t&&t,this.signal=e.signal,this.isMaybeSingle=null!==(r=e.isMaybeSingle)&&void 0!==r&&r,e.fetch?this.fetch=e.fetch:this.fetch=fetch}return e.prototype.throwOnError=function(){return this.shouldThrowOnError=!0,this},e.prototype.setHeader=function(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this},e.prototype.then=function(e,t){var r=this;void 0===this.schema||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),"GET"!==this.method&&"HEAD"!==this.method&&this.headers.set("Content-Type","application/json");var n=(0,this.fetch)(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then((function(e){return i(r,0,void 0,(function(){var t,r,n,o,i,a,u,c,l,f,d,h;return s(this,(function(s){switch(s.label){case 0:return t=null,r=null,n=null,o=e.status,i=e.statusText,e.ok?"HEAD"===this.method?[3,2]:[4,e.text()]:[3,3];case 1:""===(c=s.sent())||(r="text/csv"===this.headers.get("Accept")||this.headers.get("Accept")&&(null===(l=this.headers.get("Accept"))||void 0===l?void 0:l.includes("application/vnd.pgrst.plan+text"))?c:JSON.parse(c)),s.label=2;case 2:return a=null===(f=this.headers.get("Prefer"))||void 0===f?void 0:f.match(/count=(exact|planned|estimated)/),u=null===(d=e.headers.get("content-range"))||void 0===d?void 0:d.split("/"),a&&u&&u.length>1&&(n=parseInt(u[1])),this.isMaybeSingle&&"GET"===this.method&&Array.isArray(r)&&(r.length>1?(t={code:"PGRST116",details:"Results contain ".concat(r.length," rows, application/vnd.pgrst.object+json requires 1 row"),hint:null,message:"JSON object requested, multiple (or no) rows returned"},r=null,n=null,o=406,i="Not Acceptable"):r=1===r.length?r[0]:null),[3,5];case 3:return[4,e.text()];case 4:c=s.sent();try{t=JSON.parse(c),Array.isArray(t)&&404===e.status&&(r=[],t=null,o=200,i="OK")}catch(r){404===e.status&&""===c?(o=204,i="No Content"):t={message:c}}if(t&&this.isMaybeSingle&&(null===(h=null==t?void 0:t.details)||void 0===h?void 0:h.includes("0 rows"))&&(t=null,o=200,i="OK"),t&&this.shouldThrowOnError)throw new Rf(t);s.label=5;case 5:return[2,{error:t,data:r,count:n,status:o,statusText:i}]}}))}))}));return this.shouldThrowOnError||(n=n.catch((function(e){var t,r,n;return{error:{message:"".concat(null!==(t=null==e?void 0:e.name)&&void 0!==t?t:"FetchError",": ").concat(null==e?void 0:e.message),details:"".concat(null!==(r=null==e?void 0:e.stack)&&void 0!==r?r:""),hint:"",code:"".concat(null!==(n=null==e?void 0:e.code)&&void 0!==n?n:"")},data:null,count:null,status:0,statusText:""}}))),n.then(e,t)},e.prototype.returns=function(){return this},e.prototype.overrideTypes=function(){return this},e}()),Cf=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.eq=function(e,t){return this.url.searchParams.append(e,"eq.".concat(t)),this},t.prototype.neq=function(e,t){return this.url.searchParams.append(e,"neq.".concat(t)),this},t.prototype.gt=function(e,t){return this.url.searchParams.append(e,"gt.".concat(t)),this},t.prototype.gte=function(e,t){return this.url.searchParams.append(e,"gte.".concat(t)),this},t.prototype.lt=function(e,t){return this.url.searchParams.append(e,"lt.".concat(t)),this},t.prototype.lte=function(e,t){return this.url.searchParams.append(e,"lte.".concat(t)),this},t.prototype.like=function(e,t){return this.url.searchParams.append(e,"like.".concat(t)),this},t.prototype.likeAllOf=function(e,t){return this.url.searchParams.append(e,"like(all).{".concat(t.join(","),"}")),this},t.prototype.likeAnyOf=function(e,t){return this.url.searchParams.append(e,"like(any).{".concat(t.join(","),"}")),this},t.prototype.ilike=function(e,t){return this.url.searchParams.append(e,"ilike.".concat(t)),this},t.prototype.ilikeAllOf=function(e,t){return this.url.searchParams.append(e,"ilike(all).{".concat(t.join(","),"}")),this},t.prototype.ilikeAnyOf=function(e,t){return this.url.searchParams.append(e,"ilike(any).{".concat(t.join(","),"}")),this},t.prototype.is=function(e,t){return this.url.searchParams.append(e,"is.".concat(t)),this},t.prototype.in=function(e,t){var r=Array.from(new Set(t)).map((function(e){return"string"==typeof e&&new RegExp("[,()]").test(e)?'"'.concat(e,'"'):"".concat(e)})).join(",");return this.url.searchParams.append(e,"in.(".concat(r,")")),this},t.prototype.contains=function(e,t){return"string"==typeof t?this.url.searchParams.append(e,"cs.".concat(t)):Array.isArray(t)?this.url.searchParams.append(e,"cs.{".concat(t.join(","),"}")):this.url.searchParams.append(e,"cs.".concat(JSON.stringify(t))),this},t.prototype.containedBy=function(e,t){return"string"==typeof t?this.url.searchParams.append(e,"cd.".concat(t)):Array.isArray(t)?this.url.searchParams.append(e,"cd.{".concat(t.join(","),"}")):this.url.searchParams.append(e,"cd.".concat(JSON.stringify(t))),this},t.prototype.rangeGt=function(e,t){return this.url.searchParams.append(e,"sr.".concat(t)),this},t.prototype.rangeGte=function(e,t){return this.url.searchParams.append(e,"nxl.".concat(t)),this},t.prototype.rangeLt=function(e,t){return this.url.searchParams.append(e,"sl.".concat(t)),this},t.prototype.rangeLte=function(e,t){return this.url.searchParams.append(e,"nxr.".concat(t)),this},t.prototype.rangeAdjacent=function(e,t){return this.url.searchParams.append(e,"adj.".concat(t)),this},t.prototype.overlaps=function(e,t){return"string"==typeof t?this.url.searchParams.append(e,"ov.".concat(t)):this.url.searchParams.append(e,"ov.{".concat(t.join(","),"}")),this},t.prototype.textSearch=function(e,t,r){var n=void 0===r?{}:r,o=n.config,i=n.type,s="";"plain"===i?s="pl":"phrase"===i?s="ph":"websearch"===i&&(s="w");var a=void 0===o?"":"(".concat(o,")");return this.url.searchParams.append(e,"".concat(s,"fts").concat(a,".").concat(t)),this},t.prototype.match=function(e){var t=this;return Object.entries(e).forEach((function(e){var r=e[0],n=e[1];t.url.searchParams.append(r,"eq.".concat(n))})),this},t.prototype.not=function(e,t,r){return this.url.searchParams.append(e,"not.".concat(t,".").concat(r)),this},t.prototype.or=function(e,t){var r=void 0===t?{}:t,n=r.foreignTable,o=r.referencedTable,i=void 0===o?n:o,s=i?"".concat(i,".or"):"or";return this.url.searchParams.append(s,"(".concat(e,")")),this},t.prototype.filter=function(e,t,r){return this.url.searchParams.append(e,"".concat(t,".").concat(r)),this},t}(Pf),Nf=function(e){function t(t,r){var n=r.headers,o=void 0===n?{}:n,i=r.fetch;return e.call(this,t,{headers:o,schema:void 0,fetch:i})||this}return n(t,e),t}(function(){function e(e,t){var r=t.headers,n=void 0===r?{}:r,o=t.schema,i=t.fetch;this.url=e,this.headers=new Headers(n),this.schema=o,this.fetch=i}return e.prototype.select=function(e,t){var r=void 0===t?{}:t,n=r.head,o=void 0!==n&&n,i=r.count,s=o?"HEAD":"GET",a=!1,u=(null!=e?e:"*").split("").map((function(e){return/\s/.test(e)&&!a?"":('"'===e&&(a=!a),e)})).join("");return this.url.searchParams.set("select",u),i&&this.headers.append("Prefer","count=".concat(i)),new Cf({method:s,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})},e.prototype.insert=function(e,t){var r,n=void 0===t?{}:t,o=n.count,i=n.defaultToNull,s=void 0===i||i;if(o&&this.headers.append("Prefer","count=".concat(o)),s||this.headers.append("Prefer","missing=default"),Array.isArray(e)){var a=e.reduce((function(e,t){return e.concat(Object.keys(t))}),[]);if(a.length>0){var u=Array.from(new Set(a)).map((function(e){return'"'.concat(e,'"')}));this.url.searchParams.set("columns",u.join(","))}}return new Cf({method:"POST",url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:null!==(r=this.fetch)&&void 0!==r?r:fetch})},e.prototype.upsert=function(e,t){var r,n=void 0===t?{}:t,o=n.onConflict,i=n.ignoreDuplicates,s=void 0!==i&&i,a=n.count,u=n.defaultToNull,c=void 0===u||u;if(this.headers.append("Prefer","resolution=".concat(s?"ignore":"merge","-duplicates")),void 0!==o&&this.url.searchParams.set("on_conflict",o),a&&this.headers.append("Prefer","count=".concat(a)),c||this.headers.append("Prefer","missing=default"),Array.isArray(e)){var l=e.reduce((function(e,t){return e.concat(Object.keys(t))}),[]);if(l.length>0){var f=Array.from(new Set(l)).map((function(e){return'"'.concat(e,'"')}));this.url.searchParams.set("columns",f.join(","))}}return new Cf({method:"POST",url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:null!==(r=this.fetch)&&void 0!==r?r:fetch})},e.prototype.update=function(e,t){var r,n=(void 0===t?{}:t).count;return n&&this.headers.append("Prefer","count=".concat(n)),new Cf({method:"PATCH",url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:null!==(r=this.fetch)&&void 0!==r?r:fetch})},e.prototype.delete=function(e){var t,r=(void 0===e?{}:e).count;return r&&this.headers.append("Prefer","count=".concat(r)),new Cf({method:"DELETE",url:this.url,headers:this.headers,schema:this.schema,fetch:null!==(t=this.fetch)&&void 0!==t?t:fetch})},e}()),xf=function(){function e(e,t){var r=void 0===t?{}:t,n=r.headers,o=void 0===n?{}:n,i=r.fetch;this.url=e,this.headers=new Headers(o),this.fetch=i}return e.prototype.from=function(e){var t=new Af("".concat(this.url,"/").concat(e));return new Nf(t,{headers:this.headers,fetch:this.fetch})},e}();function Lf(e,t){if(!e)throw new Error("cloud is required");if(!e.callFunction)throw new Error("cloud.callFunction is required");var r=e.callFunction.bind(e);return e.models=S(r),e.mysql=Uf(e,{envId:null==t?void 0:t.envId}),e}function Uf(e,t){var r=null==t?void 0:t.envId,n=(null==t?void 0:t.mysqlBaseUrl)||kf(e,null==t?void 0:t.envId).mysql,a=null==t?void 0:t.fetch;return function(t){var u=this;return new xf(n,{fetch:a||function(n,a){return i(u,0,void 0,(function(){var i,u,c;return s(this,(function(s){return i=(null==t?void 0:t.instance)||"default",u=(null==t?void 0:t.database)||r,c={},(null==a?void 0:a.headers)instanceof Headers?a.headers.forEach((function(e,t){c[t]=e})):c=(null==a?void 0:a.headers)||{},[2,e.callFunction({name:"httpOverCallFunction",data:{url:n.toString(),method:(null==a?void 0:a.method)||"GET",headers:o(o({},c||{}),{"Content-Type":"application/json","X-Db-Instance":i,"Accept-Profile":u,"Content-Profile":u}),body:null==a?void 0:a.body}}).then((function(e){var t=null==e?void 0:e.result;return{ok:(null==t?void 0:t.statusCode)>=200&&(null==t?void 0:t.statusCode)<300,status:(null==t?void 0:t.statusCode)||200,statusText:(null==t?void 0:t.statusMessage)||"OK",json:function(){return Promise.resolve((null==t?void 0:t.body)||{})},text:function(){return Promise.resolve("string"==typeof(null==t?void 0:t.body)?t.body:JSON.stringify((null==t?void 0:t.body)||{}))},headers:new Headers((null==t?void 0:t.headers)||{})}}))]}))}))}})}}function kf(e,t){var r,n,o,i,s=t||(null===(n=null===(r=null==e?void 0:e.extend)||void 0===r?void 0:r.AI)||void 0===n?void 0:n.env);if("string"==typeof s&&s.trim()||(s=null===(o=null==e?void 0:e.config)||void 0===o?void 0:o.env),"string"==typeof s&&s.trim()||(s=null===(i=null==e?void 0:e.config)||void 0===i?void 0:i.envName),"string"!=typeof s||!s.trim())throw new Error("Generating default gateway base url failed: env not found");return s=s.trim(),{model:"https://".concat(s,".api.tcloudbasegateway.com/v1/model"),sql:"https://".concat(s,".api.tcloudbasegateway.com/v1/sql"),mysql:"https://".concat(s,".api.tcloudbasegateway.com/v1/rdb/rest")}}var Df={init:Lf,generateHTTPClient:g,generateMySQLClient:Uf};e.default=Df,e.generateHTTPClient=g,e.generateMySQLClient=Uf,e.init=Lf,e.initHTTPOverCallFunction=function(e,t){var r=this;if(!e)throw new Error("cloud is required");if(!e.callFunction)throw new Error("cloud.callFunction is required");var n,a=e.callFunction.bind(e);try{var u=(null==t?void 0:t.baseUrl)||kf(e,null==t?void 0:t.envId).model,c=(null==t?void 0:t.sqlBaseUrl)||kf(e,null==t?void 0:t.envId).sql;n=g(a,(function(e){var t=e.url,n=e.body,u=e.method,c=e.headers;return i(r,0,void 0,(function(){var e,r;return s(this,(function(i){switch(i.label){case 0:return[4,a({name:"httpOverCallFunction",data:{url:t,method:null==u?void 0:u.toUpperCase(),headers:o(o({},c||{}),{"Content-Type":"application/json"}),body:n}})];case 1:return e=i.sent(),[2,null===(r=null==e?void 0:e.result)||void 0===r?void 0:r.body]}}))}))}),u,{sqlBaseUrl:c})}catch(e){console.error("init http orm client failed, try call function orm",e),n=S(a)}return e.models=n,e.mysql=Uf(e,{envId:null==t?void 0:t.envId,mysqlBaseUrl:null==t?void 0:t.mysqlBaseUrl}),e},Object.defineProperty(e,"__esModule",{value:!0})}(t)},5993:function(e,t,r){"use strict";function n(){}function o(e){return"object"==typeof e&&null!==e||"function"==typeof e}r.d(t,{GJ:function(){return rn},Pz:function(){return Lr}});const i=n;function s(e,t){try{Object.defineProperty(e,"name",{value:t,configurable:!0})}catch(e){}}const a=Promise,u=Promise.resolve.bind(a),c=Promise.prototype.then,l=Promise.reject.bind(a),f=u;function d(e){return new a(e)}function h(e){return d((t=>t(e)))}function p(e){return l(e)}function v(e,t,r){return c.call(e,t,r)}function y(e,t,r){v(v(e,t,r),void 0,i)}function m(e,t){y(e,t)}function g(e,t){y(e,void 0,t)}function b(e,t,r){return v(e,t,r)}function w(e){v(e,void 0,i)}let _=e=>{if("function"==typeof queueMicrotask)_=queueMicrotask;else{const e=h(void 0);_=t=>v(e,t)}return _(e)};function S(e,t,r){if("function"!=typeof e)throw new TypeError("Argument is not a function");return Function.prototype.apply.call(e,t,r)}function E(e,t,r){try{return h(S(e,t,r))}catch(e){return p(e)}}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(e){const t=this._back;let r=t;16383===t._elements.length&&(r={_elements:[],_next:void 0}),t._elements.push(e),r!==t&&(this._back=r,t._next=r),++this._size}shift(){const e=this._front;let t=e;const r=this._cursor;let n=r+1;const o=e._elements,i=o[r];return 16384===n&&(t=e._next,n=0),--this._size,this._cursor=n,e!==t&&(this._front=t),o[r]=void 0,i}forEach(e){let t=this._cursor,r=this._front,n=r._elements;for(;!(t===n.length&&void 0===r._next||t===n.length&&(r=r._next,n=r._elements,t=0,0===n.length));)e(n[t]),++t}peek(){const e=this._front,t=this._cursor;return e._elements[t]}}const O=Symbol("[[AbortSteps]]"),T=Symbol("[[ErrorSteps]]"),A=Symbol("[[CancelSteps]]"),R=Symbol("[[PullSteps]]"),P=Symbol("[[ReleaseSteps]]");function C(e,t){e._ownerReadableStream=t,t._reader=e,"readable"===t._state?U(e):"closed"===t._state?function(e){U(e),j(e)}(e):k(e,t._storedError)}function N(e,t){return Mr(e._ownerReadableStream,t)}function x(e){const t=e._ownerReadableStream;"readable"===t._state?D(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")):function(e){k(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness"))}(e),t._readableStreamController[P](),t._reader=void 0,e._ownerReadableStream=void 0}function L(e){return new TypeError("Cannot "+e+" a stream using a released reader")}function U(e){e._closedPromise=d(((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r}))}function k(e,t){U(e),D(e,t)}function D(e,t){void 0!==e._closedPromise_reject&&(w(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}function j(e){void 0!==e._closedPromise_resolve&&(e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}const q=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},M=Math.trunc||function(e){return e<0?Math.ceil(e):Math.floor(e)};function B(e,t){if(void 0!==e&&"object"!=typeof(r=e)&&"function"!=typeof r)throw new TypeError(`${t} is not an object.`);var r}function W(e,t){if("function"!=typeof e)throw new TypeError(`${t} is not a function.`)}function F(e,t){if(!function(e){return"object"==typeof e&&null!==e||"function"==typeof e}(e))throw new TypeError(`${t} is not an object.`)}function V(e,t,r){if(void 0===e)throw new TypeError(`Parameter ${t} is required in '${r}'.`)}function H(e,t,r){if(void 0===e)throw new TypeError(`${t} is required in '${r}'.`)}function $(e){return Number(e)}function G(e){return 0===e?0:e}function z(e,t){const r=Number.MAX_SAFE_INTEGER;let n=Number(e);if(n=G(n),!q(n))throw new TypeError(`${t} is not a finite number`);if(n=function(e){return G(M(e))}(n),n<0||n>r)throw new TypeError(`${t} is outside the accepted range of 0 to ${r}, inclusive`);return q(n)&&0!==n?n:0}function K(e,t){if(!jr(e))throw new TypeError(`${t} is not a ReadableStream.`)}function J(e){return new ee(e)}function Y(e,t){e._reader._readRequests.push(t)}function Q(e,t,r){const n=e._reader._readRequests.shift();r?n._closeSteps():n._chunkSteps(t)}function Z(e){return e._reader._readRequests.length}function X(e){const t=e._reader;return void 0!==t&&!!te(t)}class ee{constructor(e){if(V(e,1,"ReadableStreamDefaultReader"),K(e,"First parameter"),qr(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");C(this,e),this._readRequests=new I}get closed(){return te(this)?this._closedPromise:p(oe("closed"))}cancel(e=void 0){return te(this)?void 0===this._ownerReadableStream?p(L("cancel")):N(this,e):p(oe("cancel"))}read(){if(!te(this))return p(oe("read"));if(void 0===this._ownerReadableStream)return p(L("read from"));let e,t;const r=d(((r,n)=>{e=r,t=n}));return re(this,{_chunkSteps:t=>e({value:t,done:!1}),_closeSteps:()=>e({value:void 0,done:!0}),_errorSteps:e=>t(e)}),r}releaseLock(){if(!te(this))throw oe("releaseLock");void 0!==this._ownerReadableStream&&function(e){x(e),ne(e,new TypeError("Reader was released"))}(this)}}function te(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readRequests")&&e instanceof ee}function re(e,t){const r=e._ownerReadableStream;r._disturbed=!0,"closed"===r._state?t._closeSteps():"errored"===r._state?t._errorSteps(r._storedError):r._readableStreamController[R](t)}function ne(e,t){const r=e._readRequests;e._readRequests=new I,r.forEach((e=>{e._errorSteps(t)}))}function oe(e){return new TypeError(`ReadableStreamDefaultReader.prototype.${e} can only be used on a ReadableStreamDefaultReader`)}var ie,se,ae;function ue(e){return e.slice()}function ce(e,t,r,n,o){new Uint8Array(e).set(new Uint8Array(r,n,o),t)}Object.defineProperties(ee.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),s(ee.prototype.cancel,"cancel"),s(ee.prototype.read,"read"),s(ee.prototype.releaseLock,"releaseLock"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(ee.prototype,Symbol.toStringTag,{value:"ReadableStreamDefaultReader",configurable:!0});let le=e=>(le="function"==typeof e.transfer?e=>e.transfer():"function"==typeof structuredClone?e=>structuredClone(e,{transfer:[e]}):e=>e,le(e)),fe=e=>(fe="boolean"==typeof e.detached?e=>e.detached:e=>0===e.byteLength,fe(e));function de(e,t,r){if(e.slice)return e.slice(t,r);const n=r-t,o=new ArrayBuffer(n);return ce(o,0,e,t,n),o}function he(e,t){const r=e[t];if(null!=r){if("function"!=typeof r)throw new TypeError(`${String(t)} is not a function`);return r}}function pe(e){try{const t=e.done,r=e.value;return v(f(r),(e=>({done:t,value:e})))}catch(e){return p(e)}}const ve=null!==(ae=null!==(ie=Symbol.asyncIterator)&&void 0!==ie?ie:null===(se=Symbol.for)||void 0===se?void 0:se.call(Symbol,"Symbol.asyncIterator"))&&void 0!==ae?ae:"@@asyncIterator";function ye(e,t="sync",r){if(void 0===r)if("async"===t){if(void 0===(r=he(e,ve)))return function(e){const t={next(){let t;try{t=me(e)}catch(e){return p(e)}return pe(t)},return(t){let r;try{const n=he(e.iterator,"return");if(void 0===n)return h({done:!0,value:t});r=S(n,e.iterator,[t])}catch(e){return p(e)}return o(r)?pe(r):p(new TypeError("The iterator.return() method must return an object"))}};return{iterator:t,nextMethod:t.next,done:!1}}(ye(e,"sync",he(e,Symbol.iterator)))}else r=he(e,Symbol.iterator);if(void 0===r)throw new TypeError("The object is not iterable");const n=S(r,e,[]);if(!o(n))throw new TypeError("The iterator method must return an object");return{iterator:n,nextMethod:n.next,done:!1}}function me(e){const t=S(e.nextMethod,e.iterator,[]);if(!o(t))throw new TypeError("The iterator.next() method must return an object");return t}class ge{constructor(e,t){this._ongoingPromise=void 0,this._isFinished=!1,this._reader=e,this._preventCancel=t}next(){const e=()=>this._nextSteps();return this._ongoingPromise=this._ongoingPromise?b(this._ongoingPromise,e,e):e(),this._ongoingPromise}return(e){const t=()=>this._returnSteps(e);return this._ongoingPromise?b(this._ongoingPromise,t,t):t()}_nextSteps(){if(this._isFinished)return Promise.resolve({value:void 0,done:!0});const e=this._reader;let t,r;const n=d(((e,n)=>{t=e,r=n}));return re(e,{_chunkSteps:e=>{this._ongoingPromise=void 0,_((()=>t({value:e,done:!1})))},_closeSteps:()=>{this._ongoingPromise=void 0,this._isFinished=!0,x(e),t({value:void 0,done:!0})},_errorSteps:t=>{this._ongoingPromise=void 0,this._isFinished=!0,x(e),r(t)}}),n}_returnSteps(e){if(this._isFinished)return Promise.resolve({value:e,done:!0});this._isFinished=!0;const t=this._reader;if(!this._preventCancel){const r=N(t,e);return x(t),b(r,(()=>({value:e,done:!0})))}return x(t),h({value:e,done:!0})}}const be={next(){return we(this)?this._asyncIteratorImpl.next():p(_e("next"))},return(e){return we(this)?this._asyncIteratorImpl.return(e):p(_e("return"))},[ve](){return this}};function we(e){if(!o(e))return!1;if(!Object.prototype.hasOwnProperty.call(e,"_asyncIteratorImpl"))return!1;try{return e._asyncIteratorImpl instanceof ge}catch(e){return!1}}function _e(e){return new TypeError(`ReadableStreamAsyncIterator.${e} can only be used on a ReadableSteamAsyncIterator`)}Object.defineProperty(be,ve,{enumerable:!1});const Se=Number.isNaN||function(e){return e!=e};function Ee(e){const t=de(e.buffer,e.byteOffset,e.byteOffset+e.byteLength);return new Uint8Array(t)}function Ie(e){const t=e._queue.shift();return e._queueTotalSize-=t.size,e._queueTotalSize<0&&(e._queueTotalSize=0),t.value}function Oe(e,t,r){if("number"!=typeof(n=r)||Se(n)||n<0||r===1/0)throw new RangeError("Size must be a finite, non-NaN, non-negative number.");var n;e._queue.push({value:t,size:r}),e._queueTotalSize+=r}function Te(e){e._queue=new I,e._queueTotalSize=0}function Ae(e){return e===DataView}class Re{constructor(){throw new TypeError("Illegal constructor")}get view(){if(!Ne(this))throw rt("view");return this._view}respond(e){if(!Ne(this))throw rt("respond");if(V(e,1,"respond"),e=z(e,"First parameter"),void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");if(fe(this._view.buffer))throw new TypeError("The BYOB request's buffer has been detached and so cannot be used as a response");Xe(this._associatedReadableByteStreamController,e)}respondWithNewView(e){if(!Ne(this))throw rt("respondWithNewView");if(V(e,1,"respondWithNewView"),!ArrayBuffer.isView(e))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(fe(e.buffer))throw new TypeError("The given view's buffer has been detached and so cannot be used as a response");et(this._associatedReadableByteStreamController,e)}}Object.defineProperties(Re.prototype,{respond:{enumerable:!0},respondWithNewView:{enumerable:!0},view:{enumerable:!0}}),s(Re.prototype.respond,"respond"),s(Re.prototype.respondWithNewView,"respondWithNewView"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Re.prototype,Symbol.toStringTag,{value:"ReadableStreamBYOBRequest",configurable:!0});class Pe{constructor(){throw new TypeError("Illegal constructor")}get byobRequest(){if(!Ce(this))throw nt("byobRequest");return Qe(this)}get desiredSize(){if(!Ce(this))throw nt("desiredSize");return Ze(this)}close(){if(!Ce(this))throw nt("close");if(this._closeRequested)throw new TypeError("The stream has already been closed; do not close it again!");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 closed`);ze(this)}enqueue(e){if(!Ce(this))throw nt("enqueue");if(V(e,1,"enqueue"),!ArrayBuffer.isView(e))throw new TypeError("chunk must be an array buffer view");if(0===e.byteLength)throw new TypeError("chunk must have non-zero byteLength");if(0===e.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 t=this._controlledReadableByteStream._state;if("readable"!==t)throw new TypeError(`The stream (in ${t} state) is not in the readable state and cannot be enqueued to`);Ke(this,e)}error(e=void 0){if(!Ce(this))throw nt("error");Je(this,e)}[A](e){Le(this),Te(this);const t=this._cancelAlgorithm(e);return Ge(this),t}[R](e){const t=this._controlledReadableByteStream;if(this._queueTotalSize>0)return void Ye(this,e);const r=this._autoAllocateChunkSize;if(void 0!==r){let n;try{n=new ArrayBuffer(r)}catch(t){return void e._errorSteps(t)}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(t,e),xe(this)}[P](){if(this._pendingPullIntos.length>0){const e=this._pendingPullIntos.peek();e.readerType="none",this._pendingPullIntos=new I,this._pendingPullIntos.push(e)}}}function Ce(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableByteStream")&&e instanceof Pe}function Ne(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_associatedReadableByteStreamController")&&e instanceof Re}function xe(e){const t=function(e){const t=e._controlledReadableByteStream;return"readable"===t._state&&(!e._closeRequested&&(!!e._started&&(!!(X(t)&&Z(t)>0)||(!!(ut(t)&&at(t)>0)||Ze(e)>0))))}(e);t&&(e._pulling?e._pullAgain=!0:(e._pulling=!0,y(e._pullAlgorithm(),(()=>(e._pulling=!1,e._pullAgain&&(e._pullAgain=!1,xe(e)),null)),(t=>(Je(e,t),null)))))}function Le(e){Fe(e),e._pendingPullIntos=new I}function Ue(e,t){let r=!1;"closed"===e._state&&(r=!0);const n=ke(t);"default"===t.readerType?Q(e,n,r):function(e,t,r){const n=e._reader._readIntoRequests.shift();r?n._closeSteps(t):n._chunkSteps(t)}(e,n,r)}function ke(e){const t=e.bytesFilled,r=e.elementSize;return new e.viewConstructor(e.buffer,e.byteOffset,t/r)}function De(e,t,r,n){e._queue.push({buffer:t,byteOffset:r,byteLength:n}),e._queueTotalSize+=n}function je(e,t,r,n){let o;try{o=de(t,r,r+n)}catch(t){throw Je(e,t),t}De(e,o,0,n)}function qe(e,t){t.bytesFilled>0&&je(e,t.buffer,t.byteOffset,t.bytesFilled),$e(e)}function Me(e,t){const r=Math.min(e._queueTotalSize,t.byteLength-t.bytesFilled),n=t.bytesFilled+r;let o=r,i=!1;const s=n-n%t.elementSize;s>=t.minimumFill&&(o=s-t.bytesFilled,i=!0);const a=e._queue;for(;o>0;){const r=a.peek(),n=Math.min(o,r.byteLength),i=t.byteOffset+t.bytesFilled;ce(t.buffer,i,r.buffer,r.byteOffset,n),r.byteLength===n?a.shift():(r.byteOffset+=n,r.byteLength-=n),e._queueTotalSize-=n,Be(0,n,t),o-=n}return i}function Be(e,t,r){r.bytesFilled+=t}function We(e){0===e._queueTotalSize&&e._closeRequested?(Ge(e),Br(e._controlledReadableByteStream)):xe(e)}function Fe(e){null!==e._byobRequest&&(e._byobRequest._associatedReadableByteStreamController=void 0,e._byobRequest._view=null,e._byobRequest=null)}function Ve(e){for(;e._pendingPullIntos.length>0;){if(0===e._queueTotalSize)return;const t=e._pendingPullIntos.peek();Me(e,t)&&($e(e),Ue(e._controlledReadableByteStream,t))}}function He(e,t){const r=e._pendingPullIntos.peek();Fe(e),"closed"===e._controlledReadableByteStream._state?function(e,t){"none"===t.readerType&&$e(e);const r=e._controlledReadableByteStream;if(ut(r))for(;at(r)>0;)Ue(r,$e(e))}(e,r):function(e,t,r){if(Be(0,t,r),"none"===r.readerType)return qe(e,r),void Ve(e);if(r.bytesFilled<r.minimumFill)return;$e(e);const n=r.bytesFilled%r.elementSize;if(n>0){const t=r.byteOffset+r.bytesFilled;je(e,r.buffer,t-n,n)}r.bytesFilled-=n,Ue(e._controlledReadableByteStream,r),Ve(e)}(e,t,r),xe(e)}function $e(e){return e._pendingPullIntos.shift()}function Ge(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0}function ze(e){const t=e._controlledReadableByteStream;if(!e._closeRequested&&"readable"===t._state)if(e._queueTotalSize>0)e._closeRequested=!0;else{if(e._pendingPullIntos.length>0){const t=e._pendingPullIntos.peek();if(t.bytesFilled%t.elementSize!=0){const t=new TypeError("Insufficient bytes to fill elements in the given buffer");throw Je(e,t),t}}Ge(e),Br(t)}}function Ke(e,t){const r=e._controlledReadableByteStream;if(e._closeRequested||"readable"!==r._state)return;const{buffer:n,byteOffset:o,byteLength:i}=t;if(fe(n))throw new TypeError("chunk's buffer is detached and so cannot be enqueued");const s=le(n);if(e._pendingPullIntos.length>0){const t=e._pendingPullIntos.peek();if(fe(t.buffer))throw new TypeError("The BYOB request's buffer has been detached and so cannot be filled with an enqueued chunk");Fe(e),t.buffer=le(t.buffer),"none"===t.readerType&&qe(e,t)}X(r)?(function(e){const t=e._controlledReadableByteStream._reader;for(;t._readRequests.length>0;){if(0===e._queueTotalSize)return;Ye(e,t._readRequests.shift())}}(e),0===Z(r)?De(e,s,o,i):(e._pendingPullIntos.length>0&&$e(e),Q(r,new Uint8Array(s,o,i),!1))):ut(r)?(De(e,s,o,i),Ve(e)):De(e,s,o,i),xe(e)}function Je(e,t){const r=e._controlledReadableByteStream;"readable"===r._state&&(Le(e),Te(e),Ge(e),Wr(r,t))}function Ye(e,t){const r=e._queue.shift();e._queueTotalSize-=r.byteLength,We(e);const n=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);t._chunkSteps(n)}function Qe(e){if(null===e._byobRequest&&e._pendingPullIntos.length>0){const t=e._pendingPullIntos.peek(),r=new Uint8Array(t.buffer,t.byteOffset+t.bytesFilled,t.byteLength-t.bytesFilled),n=Object.create(Re.prototype);!function(e,t,r){e._associatedReadableByteStreamController=t,e._view=r}(n,e,r),e._byobRequest=n}return e._byobRequest}function Ze(e){const t=e._controlledReadableByteStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function Xe(e,t){const r=e._pendingPullIntos.peek();if("closed"===e._controlledReadableByteStream._state){if(0!==t)throw new TypeError("bytesWritten must be 0 when calling respond() on a closed stream")}else{if(0===t)throw new TypeError("bytesWritten must be greater than 0 when calling respond() on a readable stream");if(r.bytesFilled+t>r.byteLength)throw new RangeError("bytesWritten out of range")}r.buffer=le(r.buffer),He(e,t)}function et(e,t){const r=e._pendingPullIntos.peek();if("closed"===e._controlledReadableByteStream._state){if(0!==t.byteLength)throw new TypeError("The view's length must be 0 when calling respondWithNewView() on a closed stream")}else if(0===t.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!==t.byteOffset)throw new RangeError("The region specified by view does not match byobRequest");if(r.bufferByteLength!==t.buffer.byteLength)throw new RangeError("The buffer of view has different capacity than byobRequest");if(r.bytesFilled+t.byteLength>r.byteLength)throw new RangeError("The region specified by view is larger than byobRequest");const n=t.byteLength;r.buffer=le(t.buffer),He(e,n)}function tt(e,t,r,n,o,i,s){t._controlledReadableByteStream=e,t._pullAgain=!1,t._pulling=!1,t._byobRequest=null,t._queue=t._queueTotalSize=void 0,Te(t),t._closeRequested=!1,t._started=!1,t._strategyHWM=i,t._pullAlgorithm=n,t._cancelAlgorithm=o,t._autoAllocateChunkSize=s,t._pendingPullIntos=new I,e._readableStreamController=t,y(h(r()),(()=>(t._started=!0,xe(t),null)),(e=>(Je(t,e),null)))}function rt(e){return new TypeError(`ReadableStreamBYOBRequest.prototype.${e} can only be used on a ReadableStreamBYOBRequest`)}function nt(e){return new TypeError(`ReadableByteStreamController.prototype.${e} can only be used on a ReadableByteStreamController`)}function ot(e,t){if("byob"!=(e=`${e}`))throw new TypeError(`${t} '${e}' is not a valid enumeration value for ReadableStreamReaderMode`);return e}function it(e){return new ct(e)}function st(e,t){e._reader._readIntoRequests.push(t)}function at(e){return e._reader._readIntoRequests.length}function ut(e){const t=e._reader;return void 0!==t&&!!lt(t)}Object.defineProperties(Pe.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},byobRequest:{enumerable:!0},desiredSize:{enumerable:!0}}),s(Pe.prototype.close,"close"),s(Pe.prototype.enqueue,"enqueue"),s(Pe.prototype.error,"error"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Pe.prototype,Symbol.toStringTag,{value:"ReadableByteStreamController",configurable:!0});class ct{constructor(e){if(V(e,1,"ReadableStreamBYOBReader"),K(e,"First parameter"),qr(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");if(!Ce(e._readableStreamController))throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");C(this,e),this._readIntoRequests=new I}get closed(){return lt(this)?this._closedPromise:p(ht("closed"))}cancel(e=void 0){return lt(this)?void 0===this._ownerReadableStream?p(L("cancel")):N(this,e):p(ht("cancel"))}read(e,t={}){if(!lt(this))return p(ht("read"));if(!ArrayBuffer.isView(e))return p(new TypeError("view must be an array buffer view"));if(0===e.byteLength)return p(new TypeError("view must have non-zero byteLength"));if(0===e.buffer.byteLength)return p(new TypeError("view's buffer must have non-zero byteLength"));if(fe(e.buffer))return p(new TypeError("view's buffer has been detached"));let r;try{r=function(e,t){var r;return B(e,t),{min:z(null!==(r=null==e?void 0:e.min)&&void 0!==r?r:1,`${t} has member 'min' that`)}}(t,"options")}catch(e){return p(e)}const n=r.min;if(0===n)return p(new TypeError("options.min must be greater than 0"));if(function(e){return Ae(e.constructor)}(e)){if(n>e.byteLength)return p(new RangeError("options.min must be less than or equal to view's byteLength"))}else if(n>e.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=d(((e,t)=>{o=e,i=t}));return ft(this,e,n,{_chunkSteps:e=>o({value:e,done:!1}),_closeSteps:e=>o({value:e,done:!0}),_errorSteps:e=>i(e)}),s}releaseLock(){if(!lt(this))throw ht("releaseLock");void 0!==this._ownerReadableStream&&function(e){x(e),dt(e,new TypeError("Reader was released"))}(this)}}function lt(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readIntoRequests")&&e instanceof ct}function ft(e,t,r,n){const o=e._ownerReadableStream;o._disturbed=!0,"errored"===o._state?n._errorSteps(o._storedError):function(e,t,r,n){const o=e._controlledReadableByteStream,i=t.constructor,s=function(e){return Ae(e)?1:e.BYTES_PER_ELEMENT}(i),{byteOffset:a,byteLength:u}=t,c=r*s;let l;try{l=le(t.buffer)}catch(e){return void n._errorSteps(e)}const f={buffer:l,bufferByteLength:l.byteLength,byteOffset:a,byteLength:u,bytesFilled:0,minimumFill:c,elementSize:s,viewConstructor:i,readerType:"byob"};if(e._pendingPullIntos.length>0)return e._pendingPullIntos.push(f),void st(o,n);if("closed"!==o._state){if(e._queueTotalSize>0){if(Me(e,f)){const t=ke(f);return We(e),void n._chunkSteps(t)}if(e._closeRequested){const t=new TypeError("Insufficient bytes to fill elements in the given buffer");return Je(e,t),void n._errorSteps(t)}}e._pendingPullIntos.push(f),st(o,n),xe(e)}else{const e=new i(f.buffer,f.byteOffset,0);n._closeSteps(e)}}(o._readableStreamController,t,r,n)}function dt(e,t){const r=e._readIntoRequests;e._readIntoRequests=new I,r.forEach((e=>{e._errorSteps(t)}))}function ht(e){return new TypeError(`ReadableStreamBYOBReader.prototype.${e} can only be used on a ReadableStreamBYOBReader`)}function pt(e,t){const{highWaterMark:r}=e;if(void 0===r)return t;if(Se(r)||r<0)throw new RangeError("Invalid highWaterMark");return r}function vt(e){const{size:t}=e;return t||(()=>1)}function yt(e,t){B(e,t);const r=null==e?void 0:e.highWaterMark,n=null==e?void 0:e.size;return{highWaterMark:void 0===r?void 0:$(r),size:void 0===n?void 0:mt(n,`${t} has member 'size' that`)}}function mt(e,t){return W(e,t),t=>$(e(t))}function gt(e,t,r){return W(e,r),r=>E(e,t,[r])}function bt(e,t,r){return W(e,r),()=>E(e,t,[])}function wt(e,t,r){return W(e,r),r=>S(e,t,[r])}function _t(e,t,r){return W(e,r),(r,n)=>E(e,t,[r,n])}function St(e,t){if(!At(e))throw new TypeError(`${t} is not a WritableStream.`)}Object.defineProperties(ct.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),s(ct.prototype.cancel,"cancel"),s(ct.prototype.read,"read"),s(ct.prototype.releaseLock,"releaseLock"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(ct.prototype,Symbol.toStringTag,{value:"ReadableStreamBYOBReader",configurable:!0});const Et="function"==typeof AbortController;class It{constructor(e={},t={}){void 0===e?e=null:F(e,"First parameter");const r=yt(t,"Second parameter"),n=function(e,t){B(e,t);const r=null==e?void 0:e.abort,n=null==e?void 0:e.close,o=null==e?void 0:e.start,i=null==e?void 0:e.type,s=null==e?void 0:e.write;return{abort:void 0===r?void 0:gt(r,e,`${t} has member 'abort' that`),close:void 0===n?void 0:bt(n,e,`${t} has member 'close' that`),start:void 0===o?void 0:wt(o,e,`${t} has member 'start' that`),write:void 0===s?void 0:_t(s,e,`${t} has member 'write' that`),type:i}}(e,"First parameter");if(Tt(this),void 0!==n.type)throw new RangeError("Invalid type is specified");const o=vt(r);!function(e,t,r,n){const o=Object.create(Ht.prototype);let i,s,a,u;i=void 0!==t.start?()=>t.start(o):()=>{},s=void 0!==t.write?e=>t.write(e,o):()=>h(void 0),a=void 0!==t.close?()=>t.close():()=>h(void 0),u=void 0!==t.abort?e=>t.abort(e):()=>h(void 0),Gt(e,o,i,s,a,u,r,n)}(this,n,pt(r,1),o)}get locked(){if(!At(this))throw Xt("locked");return Rt(this)}abort(e=void 0){return At(this)?Rt(this)?p(new TypeError("Cannot abort a stream that already has a writer")):Pt(this,e):p(Xt("abort"))}close(){return At(this)?Rt(this)?p(new TypeError("Cannot close a stream that already has a writer")):Ut(this)?p(new TypeError("Cannot close an already-closing stream")):Ct(this):p(Xt("close"))}getWriter(){if(!At(this))throw Xt("getWriter");return Ot(this)}}function Ot(e){return new jt(e)}function Tt(e){e._state="writable",e._storedError=void 0,e._writer=void 0,e._writableStreamController=void 0,e._writeRequests=new I,e._inFlightWriteRequest=void 0,e._closeRequest=void 0,e._inFlightCloseRequest=void 0,e._pendingAbortRequest=void 0,e._backpressure=!1}function At(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_writableStreamController")&&e instanceof It}function Rt(e){return void 0!==e._writer}function Pt(e,t){var r;if("closed"===e._state||"errored"===e._state)return h(void 0);e._writableStreamController._abortReason=t,null===(r=e._writableStreamController._abortController)||void 0===r||r.abort(t);const n=e._state;if("closed"===n||"errored"===n)return h(void 0);if(void 0!==e._pendingAbortRequest)return e._pendingAbortRequest._promise;let o=!1;"erroring"===n&&(o=!0,t=void 0);const i=d(((r,n)=>{e._pendingAbortRequest={_promise:void 0,_resolve:r,_reject:n,_reason:t,_wasAlreadyErroring:o}}));return e._pendingAbortRequest._promise=i,o||xt(e,t),i}function Ct(e){const t=e._state;if("closed"===t||"errored"===t)return p(new TypeError(`The stream (in ${t} state) is not in the writable state and cannot be closed`));const r=d(((t,r)=>{const n={_resolve:t,_reject:r};e._closeRequest=n})),n=e._writer;var o;return void 0!==n&&e._backpressure&&"writable"===t&&fr(n),Oe(o=e._writableStreamController,Vt,0),Jt(o),r}function Nt(e,t){"writable"!==e._state?Lt(e):xt(e,t)}function xt(e,t){const r=e._writableStreamController;e._state="erroring",e._storedError=t;const n=e._writer;void 0!==n&&Bt(n,t),!function(e){return void 0!==e._inFlightWriteRequest||void 0!==e._inFlightCloseRequest}(e)&&r._started&&Lt(e)}function Lt(e){e._state="errored",e._writableStreamController[T]();const t=e._storedError;if(e._writeRequests.forEach((e=>{e._reject(t)})),e._writeRequests=new I,void 0===e._pendingAbortRequest)return void kt(e);const r=e._pendingAbortRequest;if(e._pendingAbortRequest=void 0,r._wasAlreadyErroring)return r._reject(t),void kt(e);y(e._writableStreamController[O](r._reason),(()=>(r._resolve(),kt(e),null)),(t=>(r._reject(t),kt(e),null)))}function Ut(e){return void 0!==e._closeRequest||void 0!==e._inFlightCloseRequest}function kt(e){void 0!==e._closeRequest&&(e._closeRequest._reject(e._storedError),e._closeRequest=void 0);const t=e._writer;void 0!==t&&ir(t,e._storedError)}function Dt(e,t){const r=e._writer;void 0!==r&&t!==e._backpressure&&(t?function(e){ar(e)}(r):fr(r)),e._backpressure=t}Object.defineProperties(It.prototype,{abort:{enumerable:!0},close:{enumerable:!0},getWriter:{enumerable:!0},locked:{enumerable:!0}}),s(It.prototype.abort,"abort"),s(It.prototype.close,"close"),s(It.prototype.getWriter,"getWriter"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(It.prototype,Symbol.toStringTag,{value:"WritableStream",configurable:!0});class jt{constructor(e){if(V(e,1,"WritableStreamDefaultWriter"),St(e,"First parameter"),Rt(e))throw new TypeError("This stream has already been locked for exclusive writing by another writer");this._ownerWritableStream=e,e._writer=this;const t=e._state;if("writable"===t)!Ut(e)&&e._backpressure?ar(this):cr(this),nr(this);else if("erroring"===t)ur(this,e._storedError),nr(this);else if("closed"===t)cr(this),nr(this),sr(this);else{const t=e._storedError;ur(this,t),or(this,t)}}get closed(){return qt(this)?this._closedPromise:p(tr("closed"))}get desiredSize(){if(!qt(this))throw tr("desiredSize");if(void 0===this._ownerWritableStream)throw rr("desiredSize");return function(e){const t=e._ownerWritableStream,r=t._state;return"errored"===r||"erroring"===r?null:"closed"===r?0:Kt(t._writableStreamController)}(this)}get ready(){return qt(this)?this._readyPromise:p(tr("ready"))}abort(e=void 0){return qt(this)?void 0===this._ownerWritableStream?p(rr("abort")):function(e,t){return Pt(e._ownerWritableStream,t)}(this,e):p(tr("abort"))}close(){if(!qt(this))return p(tr("close"));const e=this._ownerWritableStream;return void 0===e?p(rr("close")):Ut(e)?p(new TypeError("Cannot close an already-closing stream")):Mt(this)}releaseLock(){if(!qt(this))throw tr("releaseLock");void 0!==this._ownerWritableStream&&Wt(this)}write(e=void 0){return qt(this)?void 0===this._ownerWritableStream?p(rr("write to")):Ft(this,e):p(tr("write"))}}function qt(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_ownerWritableStream")&&e instanceof jt}function Mt(e){return Ct(e._ownerWritableStream)}function Bt(e,t){"pending"===e._readyPromiseState?lr(e,t):function(e,t){ur(e,t)}(e,t)}function Wt(e){const t=e._ownerWritableStream,r=new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");Bt(e,r),function(e,t){"pending"===e._closedPromiseState?ir(e,t):function(e,t){or(e,t)}(e,t)}(e,r),t._writer=void 0,e._ownerWritableStream=void 0}function Ft(e,t){const r=e._ownerWritableStream,n=r._writableStreamController,o=function(e,t){try{return e._strategySizeAlgorithm(t)}catch(t){return Yt(e,t),1}}(n,t);if(r!==e._ownerWritableStream)return p(rr("write to"));const i=r._state;if("errored"===i)return p(r._storedError);if(Ut(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(e){return d(((t,r)=>{const n={_resolve:t,_reject:r};e._writeRequests.push(n)}))}(r);return function(e,t,r){try{Oe(e,t,r)}catch(t){return void Yt(e,t)}const n=e._controlledWritableStream;Ut(n)||"writable"!==n._state||Dt(n,Qt(e)),Jt(e)}(n,t,o),s}Object.defineProperties(jt.prototype,{abort:{enumerable:!0},close:{enumerable:!0},releaseLock:{enumerable:!0},write:{enumerable:!0},closed:{enumerable:!0},desiredSize:{enumerable:!0},ready:{enumerable:!0}}),s(jt.prototype.abort,"abort"),s(jt.prototype.close,"close"),s(jt.prototype.releaseLock,"releaseLock"),s(jt.prototype.write,"write"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(jt.prototype,Symbol.toStringTag,{value:"WritableStreamDefaultWriter",configurable:!0});const Vt={};class Ht{constructor(){throw new TypeError("Illegal constructor")}get abortReason(){if(!$t(this))throw er("abortReason");return this._abortReason}get signal(){if(!$t(this))throw er("signal");if(void 0===this._abortController)throw new TypeError("WritableStreamDefaultController.prototype.signal is not supported");return this._abortController.signal}error(e=void 0){if(!$t(this))throw er("error");"writable"===this._controlledWritableStream._state&&Zt(this,e)}[O](e){const t=this._abortAlgorithm(e);return zt(this),t}[T](){Te(this)}}function $t(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledWritableStream")&&e instanceof Ht}function Gt(e,t,r,n,o,i,s,a){t._controlledWritableStream=e,e._writableStreamController=t,t._queue=void 0,t._queueTotalSize=void 0,Te(t),t._abortReason=void 0,t._abortController=function(){if(Et)return new AbortController}(),t._started=!1,t._strategySizeAlgorithm=a,t._strategyHWM=s,t._writeAlgorithm=n,t._closeAlgorithm=o,t._abortAlgorithm=i;const u=Qt(t);Dt(e,u),y(h(r()),(()=>(t._started=!0,Jt(t),null)),(r=>(t._started=!0,Nt(e,r),null)))}function zt(e){e._writeAlgorithm=void 0,e._closeAlgorithm=void 0,e._abortAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function Kt(e){return e._strategyHWM-e._queueTotalSize}function Jt(e){const t=e._controlledWritableStream;if(!e._started)return;if(void 0!==t._inFlightWriteRequest)return;if("erroring"===t._state)return void Lt(t);if(0===e._queue.length)return;const r=e._queue.peek().value;r===Vt?function(e){const t=e._controlledWritableStream;(function(e){e._inFlightCloseRequest=e._closeRequest,e._closeRequest=void 0})(t),Ie(e);const r=e._closeAlgorithm();zt(e),y(r,(()=>(function(e){e._inFlightCloseRequest._resolve(void 0),e._inFlightCloseRequest=void 0,"erroring"===e._state&&(e._storedError=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._resolve(),e._pendingAbortRequest=void 0)),e._state="closed";const t=e._writer;void 0!==t&&sr(t)}(t),null)),(e=>(function(e,t){e._inFlightCloseRequest._reject(t),e._inFlightCloseRequest=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._reject(t),e._pendingAbortRequest=void 0),Nt(e,t)}(t,e),null)))}(e):function(e,t){const r=e._controlledWritableStream;!function(e){e._inFlightWriteRequest=e._writeRequests.shift()}(r),y(e._writeAlgorithm(t),(()=>{!function(e){e._inFlightWriteRequest._resolve(void 0),e._inFlightWriteRequest=void 0}(r);const t=r._state;if(Ie(e),!Ut(r)&&"writable"===t){const t=Qt(e);Dt(r,t)}return Jt(e),null}),(t=>("writable"===r._state&&zt(e),function(e,t){e._inFlightWriteRequest._reject(t),e._inFlightWriteRequest=void 0,Nt(e,t)}(r,t),null)))}(e,r)}function Yt(e,t){"writable"===e._controlledWritableStream._state&&Zt(e,t)}function Qt(e){return Kt(e)<=0}function Zt(e,t){const r=e._controlledWritableStream;zt(e),xt(r,t)}function Xt(e){return new TypeError(`WritableStream.prototype.${e} can only be used on a WritableStream`)}function er(e){return new TypeError(`WritableStreamDefaultController.prototype.${e} can only be used on a WritableStreamDefaultController`)}function tr(e){return new TypeError(`WritableStreamDefaultWriter.prototype.${e} can only be used on a WritableStreamDefaultWriter`)}function rr(e){return new TypeError("Cannot "+e+" a stream using a released writer")}function nr(e){e._closedPromise=d(((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r,e._closedPromiseState="pending"}))}function or(e,t){nr(e),ir(e,t)}function ir(e,t){void 0!==e._closedPromise_reject&&(w(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="rejected")}function sr(e){void 0!==e._closedPromise_resolve&&(e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="resolved")}function ar(e){e._readyPromise=d(((t,r)=>{e._readyPromise_resolve=t,e._readyPromise_reject=r})),e._readyPromiseState="pending"}function ur(e,t){ar(e),lr(e,t)}function cr(e){ar(e),fr(e)}function lr(e,t){void 0!==e._readyPromise_reject&&(w(e._readyPromise),e._readyPromise_reject(t),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="rejected")}function fr(e){void 0!==e._readyPromise_resolve&&(e._readyPromise_resolve(void 0),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="fulfilled")}Object.defineProperties(Ht.prototype,{abortReason:{enumerable:!0},signal:{enumerable:!0},error:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Ht.prototype,Symbol.toStringTag,{value:"WritableStreamDefaultController",configurable:!0});const dr="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof global?global:void 0,hr=function(){const e=null==dr?void 0:dr.DOMException;return function(e){if("function"!=typeof e&&"object"!=typeof e)return!1;if("DOMException"!==e.name)return!1;try{return new e,!0}catch(e){return!1}}(e)?e:void 0}()||function(){const e=function(e,t){this.message=e||"",this.name=t||"Error",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)};return s(e,"DOMException"),e.prototype=Object.create(Error.prototype),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,configurable:!0}),e}();function pr(e,t,r,o,i,s){const a=J(e),u=Ot(t);e._disturbed=!0;let c=!1,l=h(void 0);return d(((f,b)=>{let _;if(void 0!==s){if(_=()=>{const r=void 0!==s.reason?s.reason:new hr("Aborted","AbortError"),n=[];o||n.push((()=>"writable"===t._state?Pt(t,r):h(void 0))),i||n.push((()=>"readable"===e._state?Mr(e,r):h(void 0))),A((()=>Promise.all(n.map((e=>e())))),!0,r)},s.aborted)return void _();s.addEventListener("abort",_)}var S,E,I;if(T(e,a._closedPromise,(e=>(o?R(!0,e):A((()=>Pt(t,e)),!0,e),null))),T(t,u._closedPromise,(t=>(i?R(!0,t):A((()=>Mr(e,t)),!0,t),null))),S=e,E=a._closedPromise,I=()=>(r?R():A((()=>function(e){const t=e._ownerWritableStream,r=t._state;return Ut(t)||"closed"===r?h(void 0):"errored"===r?p(t._storedError):Mt(e)}(u))),null),"closed"===S._state?I():m(E,I),Ut(t)||"closed"===t._state){const t=new TypeError("the destination writable stream closed before all data could be piped to it");i?R(!0,t):A((()=>Mr(e,t)),!0,t)}function O(){const e=l;return v(l,(()=>e!==l?O():void 0))}function T(e,t,r){"errored"===e._state?r(e._storedError):g(t,r)}function A(e,r,n){function o(){return y(e(),(()=>P(r,n)),(e=>P(!0,e))),null}c||(c=!0,"writable"!==t._state||Ut(t)?o():m(O(),o))}function R(e,r){c||(c=!0,"writable"!==t._state||Ut(t)?P(e,r):m(O(),(()=>P(e,r))))}function P(e,t){return Wt(u),x(a),void 0!==s&&s.removeEventListener("abort",_),e?b(t):f(void 0),null}w(d(((e,t)=>{!function r(o){o?e():v(c?h(!0):v(u._readyPromise,(()=>d(((e,t)=>{re(a,{_chunkSteps:t=>{l=v(Ft(u,t),void 0,n),e(!1)},_closeSteps:()=>e(!0),_errorSteps:t})})))),r,t)}(!1)})))}))}class vr{constructor(){throw new TypeError("Illegal constructor")}get desiredSize(){if(!yr(this))throw Tr("desiredSize");return Er(this)}close(){if(!yr(this))throw Tr("close");if(!Ir(this))throw new TypeError("The stream is not in a state that permits close");wr(this)}enqueue(e=void 0){if(!yr(this))throw Tr("enqueue");if(!Ir(this))throw new TypeError("The stream is not in a state that permits enqueue");return _r(this,e)}error(e=void 0){if(!yr(this))throw Tr("error");Sr(this,e)}[A](e){Te(this);const t=this._cancelAlgorithm(e);return br(this),t}[R](e){const t=this._controlledReadableStream;if(this._queue.length>0){const r=Ie(this);this._closeRequested&&0===this._queue.length?(br(this),Br(t)):mr(this),e._chunkSteps(r)}else Y(t,e),mr(this)}[P](){}}function yr(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableStream")&&e instanceof vr}function mr(e){gr(e)&&(e._pulling?e._pullAgain=!0:(e._pulling=!0,y(e._pullAlgorithm(),(()=>(e._pulling=!1,e._pullAgain&&(e._pullAgain=!1,mr(e)),null)),(t=>(Sr(e,t),null)))))}function gr(e){const t=e._controlledReadableStream;return!!Ir(e)&&!!e._started&&(!!(qr(t)&&Z(t)>0)||Er(e)>0)}function br(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function wr(e){if(!Ir(e))return;const t=e._controlledReadableStream;e._closeRequested=!0,0===e._queue.length&&(br(e),Br(t))}function _r(e,t){if(!Ir(e))return;const r=e._controlledReadableStream;if(qr(r)&&Z(r)>0)Q(r,t,!1);else{let r;try{r=e._strategySizeAlgorithm(t)}catch(t){throw Sr(e,t),t}try{Oe(e,t,r)}catch(t){throw Sr(e,t),t}}mr(e)}function Sr(e,t){const r=e._controlledReadableStream;"readable"===r._state&&(Te(e),br(e),Wr(r,t))}function Er(e){const t=e._controlledReadableStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function Ir(e){const t=e._controlledReadableStream._state;return!e._closeRequested&&"readable"===t}function Or(e,t,r,n,o,i,s){t._controlledReadableStream=e,t._queue=void 0,t._queueTotalSize=void 0,Te(t),t._started=!1,t._closeRequested=!1,t._pullAgain=!1,t._pulling=!1,t._strategySizeAlgorithm=s,t._strategyHWM=i,t._pullAlgorithm=n,t._cancelAlgorithm=o,e._readableStreamController=t,y(h(r()),(()=>(t._started=!0,mr(t),null)),(e=>(Sr(t,e),null)))}function Tr(e){return new TypeError(`ReadableStreamDefaultController.prototype.${e} can only be used on a ReadableStreamDefaultController`)}function Ar(e){return o(t=e)&&void 0!==t.getReader?function(e){let t;return t=Ur(n,(function(){let r;try{r=e.read()}catch(r){return p(r)}return b(r,(e=>{if(!o(e))throw new TypeError("The promise returned by the reader.read() method must fulfill with an object");if(e.done)wr(t._readableStreamController);else{const r=e.value;_r(t._readableStreamController,r)}}))}),(function(t){try{return h(e.cancel(t))}catch(t){return p(t)}}),0),t}(e.getReader()):function(e){let t;const r=ye(e,"async");return t=Ur(n,(function(){let e;try{e=me(r)}catch(e){return p(e)}return b(h(e),(e=>{if(!o(e))throw new TypeError("The promise returned by the iterator.next() method must fulfill with an object");if(e.done)wr(t._readableStreamController);else{const r=e.value;_r(t._readableStreamController,r)}}))}),(function(e){const t=r.iterator;let n;try{n=he(t,"return")}catch(e){return p(e)}return void 0===n?h(void 0):b(E(n,t,[e]),(e=>{if(!o(e))throw new TypeError("The promise returned by the iterator.return() method must fulfill with an object")}))}),0),t}(e);var t}function Rr(e,t,r){return W(e,r),r=>E(e,t,[r])}function Pr(e,t,r){return W(e,r),r=>E(e,t,[r])}function Cr(e,t,r){return W(e,r),r=>S(e,t,[r])}function Nr(e,t){if("bytes"!=(e=`${e}`))throw new TypeError(`${t} '${e}' is not a valid enumeration value for ReadableStreamType`);return e}function xr(e,t){B(e,t);const r=null==e?void 0:e.preventAbort,n=null==e?void 0:e.preventCancel,o=null==e?void 0:e.preventClose,i=null==e?void 0:e.signal;return void 0!==i&&function(e,t){if(!function(e){if("object"!=typeof e||null===e)return!1;try{return"boolean"==typeof e.aborted}catch(e){return!1}}(e))throw new TypeError(`${t} is not an AbortSignal.`)}(i,`${t} has member 'signal' that`),{preventAbort:Boolean(r),preventCancel:Boolean(n),preventClose:Boolean(o),signal:i}}Object.defineProperties(vr.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},desiredSize:{enumerable:!0}}),s(vr.prototype.close,"close"),s(vr.prototype.enqueue,"enqueue"),s(vr.prototype.error,"error"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(vr.prototype,Symbol.toStringTag,{value:"ReadableStreamDefaultController",configurable:!0});class Lr{constructor(e={},t={}){void 0===e?e=null:F(e,"First parameter");const r=yt(t,"Second parameter"),n=function(e,t){B(e,t);const r=e,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:z(n,`${t} has member 'autoAllocateChunkSize' that`),cancel:void 0===o?void 0:Rr(o,r,`${t} has member 'cancel' that`),pull:void 0===i?void 0:Pr(i,r,`${t} has member 'pull' that`),start:void 0===s?void 0:Cr(s,r,`${t} has member 'start' that`),type:void 0===a?void 0:Nr(a,`${t} has member 'type' that`)}}(e,"First parameter");if(Dr(this),"bytes"===n.type){if(void 0!==r.size)throw new RangeError("The strategy for a byte stream cannot have a size function");!function(e,t,r){const n=Object.create(Pe.prototype);let o,i,s;o=void 0!==t.start?()=>t.start(n):()=>{},i=void 0!==t.pull?()=>t.pull(n):()=>h(void 0),s=void 0!==t.cancel?e=>t.cancel(e):()=>h(void 0);const a=t.autoAllocateChunkSize;if(0===a)throw new TypeError("autoAllocateChunkSize must be greater than 0");tt(e,n,o,i,s,r,a)}(this,n,pt(r,0))}else{const e=vt(r);!function(e,t,r,n){const o=Object.create(vr.prototype);let i,s,a;i=void 0!==t.start?()=>t.start(o):()=>{},s=void 0!==t.pull?()=>t.pull(o):()=>h(void 0),a=void 0!==t.cancel?e=>t.cancel(e):()=>h(void 0),Or(e,o,i,s,a,r,n)}(this,n,pt(r,1),e)}}get locked(){if(!jr(this))throw Fr("locked");return qr(this)}cancel(e=void 0){return jr(this)?qr(this)?p(new TypeError("Cannot cancel a stream that already has a reader")):Mr(this,e):p(Fr("cancel"))}getReader(e=void 0){if(!jr(this))throw Fr("getReader");return void 0===function(e,t){B(e,t);const r=null==e?void 0:e.mode;return{mode:void 0===r?void 0:ot(r,`${t} has member 'mode' that`)}}(e,"First parameter").mode?J(this):it(this)}pipeThrough(e,t={}){if(!jr(this))throw Fr("pipeThrough");V(e,1,"pipeThrough");const r=function(e,t){B(e,t);const r=null==e?void 0:e.readable;H(r,"readable","ReadableWritablePair"),K(r,`${t} has member 'readable' that`);const n=null==e?void 0:e.writable;return H(n,"writable","ReadableWritablePair"),St(n,`${t} has member 'writable' that`),{readable:r,writable:n}}(e,"First parameter"),n=xr(t,"Second parameter");if(qr(this))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream");if(Rt(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(e,t={}){if(!jr(this))return p(Fr("pipeTo"));if(void 0===e)return p("Parameter 1 is required in 'pipeTo'.");if(!At(e))return p(new TypeError("ReadableStream.prototype.pipeTo's first argument must be a WritableStream"));let r;try{r=xr(t,"Second parameter")}catch(e){return p(e)}return qr(this)?p(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream")):Rt(e)?p(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream")):pr(this,e,r.preventClose,r.preventAbort,r.preventCancel,r.signal)}tee(){if(!jr(this))throw Fr("tee");return ue(function(e){return Ce(e._readableStreamController)?function(e){let t,r,n,o,i,s=J(e),a=!1,u=!1,c=!1,l=!1,f=!1;const p=d((e=>{i=e}));function v(e){g(e._closedPromise,(t=>(e!==s||(Je(n._readableStreamController,t),Je(o._readableStreamController,t),l&&f||i(void 0)),null)))}function y(){lt(s)&&(x(s),s=J(e),v(s)),re(s,{_chunkSteps:t=>{_((()=>{u=!1,c=!1;const r=t;let s=t;if(!l&&!f)try{s=Ee(t)}catch(t){return Je(n._readableStreamController,t),Je(o._readableStreamController,t),void i(Mr(e,t))}l||Ke(n._readableStreamController,r),f||Ke(o._readableStreamController,s),a=!1,u?b():c&&w()}))},_closeSteps:()=>{a=!1,l||ze(n._readableStreamController),f||ze(o._readableStreamController),n._readableStreamController._pendingPullIntos.length>0&&Xe(n._readableStreamController,0),o._readableStreamController._pendingPullIntos.length>0&&Xe(o._readableStreamController,0),l&&f||i(void 0)},_errorSteps:()=>{a=!1}})}function m(t,r){te(s)&&(x(s),s=it(e),v(s));const d=r?o:n,h=r?n:o;ft(s,t,1,{_chunkSteps:t=>{_((()=>{u=!1,c=!1;const n=r?f:l;if(r?l:f)n||et(d._readableStreamController,t);else{let r;try{r=Ee(t)}catch(t){return Je(d._readableStreamController,t),Je(h._readableStreamController,t),void i(Mr(e,t))}n||et(d._readableStreamController,t),Ke(h._readableStreamController,r)}a=!1,u?b():c&&w()}))},_closeSteps:e=>{a=!1;const t=r?f:l,n=r?l:f;t||ze(d._readableStreamController),n||ze(h._readableStreamController),void 0!==e&&(t||et(d._readableStreamController,e),!n&&h._readableStreamController._pendingPullIntos.length>0&&Xe(h._readableStreamController,0)),t&&n||i(void 0)},_errorSteps:()=>{a=!1}})}function b(){if(a)return u=!0,h(void 0);a=!0;const e=Qe(n._readableStreamController);return null===e?y():m(e._view,!1),h(void 0)}function w(){if(a)return c=!0,h(void 0);a=!0;const e=Qe(o._readableStreamController);return null===e?y():m(e._view,!0),h(void 0)}function S(){}return n=kr(S,b,(function(n){if(l=!0,t=n,f){const n=ue([t,r]),o=Mr(e,n);i(o)}return p})),o=kr(S,w,(function(n){if(f=!0,r=n,l){const n=ue([t,r]),o=Mr(e,n);i(o)}return p})),v(s),[n,o]}(e):function(e){const t=J(e);let r,n,o,i,s,a=!1,u=!1,c=!1,l=!1;const f=d((e=>{s=e}));function p(){return a?(u=!0,h(void 0)):(a=!0,re(t,{_chunkSteps:e=>{_((()=>{u=!1;const t=e,r=e;c||_r(o._readableStreamController,t),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}}),h(void 0))}function v(){}return o=Ur(v,p,(function(t){if(c=!0,r=t,l){const t=ue([r,n]),o=Mr(e,t);s(o)}return f})),i=Ur(v,p,(function(t){if(l=!0,n=t,c){const t=ue([r,n]),o=Mr(e,t);s(o)}return f})),g(t._closedPromise,(e=>(Sr(o._readableStreamController,e),Sr(i._readableStreamController,e),c&&l||s(void 0),null))),[o,i]}(e)}(this))}values(e=void 0){if(!jr(this))throw Fr("values");return function(e,t){const r=J(e),n=new ge(r,t),o=Object.create(be);return o._asyncIteratorImpl=n,o}(this,function(e){B(e,"First parameter");const t=null==e?void 0:e.preventCancel;return{preventCancel:Boolean(t)}}(e).preventCancel)}[ve](e){return this.values(e)}static from(e){return Ar(e)}}function Ur(e,t,r,n=1,o=()=>1){const i=Object.create(Lr.prototype);return Dr(i),Or(i,Object.create(vr.prototype),e,t,r,n,o),i}function kr(e,t,r){const n=Object.create(Lr.prototype);return Dr(n),tt(n,Object.create(Pe.prototype),e,t,r,0,void 0),n}function Dr(e){e._state="readable",e._reader=void 0,e._storedError=void 0,e._disturbed=!1}function jr(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readableStreamController")&&e instanceof Lr}function qr(e){return void 0!==e._reader}function Mr(e,t){if(e._disturbed=!0,"closed"===e._state)return h(void 0);if("errored"===e._state)return p(e._storedError);Br(e);const r=e._reader;if(void 0!==r&<(r)){const e=r._readIntoRequests;r._readIntoRequests=new I,e.forEach((e=>{e._closeSteps(void 0)}))}return b(e._readableStreamController[A](t),n)}function Br(e){e._state="closed";const t=e._reader;if(void 0!==t&&(j(t),te(t))){const e=t._readRequests;t._readRequests=new I,e.forEach((e=>{e._closeSteps()}))}}function Wr(e,t){e._state="errored",e._storedError=t;const r=e._reader;void 0!==r&&(D(r,t),te(r)?ne(r,t):dt(r,t))}function Fr(e){return new TypeError(`ReadableStream.prototype.${e} can only be used on a ReadableStream`)}function Vr(e,t){B(e,t);const r=null==e?void 0:e.highWaterMark;return H(r,"highWaterMark","QueuingStrategyInit"),{highWaterMark:$(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,ve,{value:Lr.prototype.values,writable:!0,configurable:!0});const Hr=e=>e.byteLength;s(Hr,"size");class $r{constructor(e){V(e,1,"ByteLengthQueuingStrategy"),e=Vr(e,"First parameter"),this._byteLengthQueuingStrategyHighWaterMark=e.highWaterMark}get highWaterMark(){if(!zr(this))throw Gr("highWaterMark");return this._byteLengthQueuingStrategyHighWaterMark}get size(){if(!zr(this))throw Gr("size");return Hr}}function Gr(e){return new TypeError(`ByteLengthQueuingStrategy.prototype.${e} can only be used on a ByteLengthQueuingStrategy`)}function zr(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_byteLengthQueuingStrategyHighWaterMark")&&e instanceof $r}Object.defineProperties($r.prototype,{highWaterMark:{enumerable:!0},size:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty($r.prototype,Symbol.toStringTag,{value:"ByteLengthQueuingStrategy",configurable:!0});const Kr=()=>1;s(Kr,"size");class Jr{constructor(e){V(e,1,"CountQueuingStrategy"),e=Vr(e,"First parameter"),this._countQueuingStrategyHighWaterMark=e.highWaterMark}get highWaterMark(){if(!Qr(this))throw Yr("highWaterMark");return this._countQueuingStrategyHighWaterMark}get size(){if(!Qr(this))throw Yr("size");return Kr}}function Yr(e){return new TypeError(`CountQueuingStrategy.prototype.${e} can only be used on a CountQueuingStrategy`)}function Qr(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_countQueuingStrategyHighWaterMark")&&e instanceof Jr}function Zr(e,t,r){return W(e,r),r=>E(e,t,[r])}function Xr(e,t,r){return W(e,r),r=>S(e,t,[r])}function en(e,t,r){return W(e,r),(r,n)=>E(e,t,[r,n])}function tn(e,t,r){return W(e,r),r=>E(e,t,[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(e={},t={},r={}){void 0===e&&(e=null);const n=yt(t,"Second parameter"),o=yt(r,"Third parameter"),i=function(e,t){B(e,t);const r=null==e?void 0:e.cancel,n=null==e?void 0:e.flush,o=null==e?void 0:e.readableType,i=null==e?void 0:e.start,s=null==e?void 0:e.transform,a=null==e?void 0:e.writableType;return{cancel:void 0===r?void 0:tn(r,e,`${t} has member 'cancel' that`),flush:void 0===n?void 0:Zr(n,e,`${t} has member 'flush' that`),readableType:o,start:void 0===i?void 0:Xr(i,e,`${t} has member 'start' that`),transform:void 0===s?void 0:en(s,e,`${t} has member 'transform' that`),writableType:a}}(e,"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=pt(o,0),a=vt(o),u=pt(n,1),c=vt(n);let l;!function(e,t,r,n,o,i){function s(){return t}e._writable=function(e,t,r,n,o=1,i=()=>1){const s=Object.create(It.prototype);return Tt(s),Gt(s,Object.create(Ht.prototype),e,t,r,n,o,i),s}(s,(function(t){return function(e,t){const r=e._transformStreamController;return e._backpressure?b(e._backpressureChangePromise,(()=>{const n=e._writable;if("erroring"===n._state)throw n._storedError;return hn(r,t)})):hn(r,t)}(e,t)}),(function(){return function(e){const t=e._transformStreamController;if(void 0!==t._finishPromise)return t._finishPromise;const r=e._readable;t._finishPromise=d(((e,r)=>{t._finishPromise_resolve=e,t._finishPromise_reject=r}));const n=t._flushAlgorithm();return fn(t),y(n,(()=>("errored"===r._state?yn(t,r._storedError):(wr(r._readableStreamController),vn(t)),null)),(e=>(Sr(r._readableStreamController,e),yn(t,e),null))),t._finishPromise}(e)}),(function(t){return function(e,t){const r=e._transformStreamController;if(void 0!==r._finishPromise)return r._finishPromise;const n=e._readable;r._finishPromise=d(((e,t)=>{r._finishPromise_resolve=e,r._finishPromise_reject=t}));const o=r._cancelAlgorithm(t);return fn(r),y(o,(()=>("errored"===n._state?yn(r,n._storedError):(Sr(n._readableStreamController,t),vn(r)),null)),(e=>(Sr(n._readableStreamController,e),yn(r,e),null))),r._finishPromise}(e,t)}),r,n),e._readable=Ur(s,(function(){return function(e){return un(e,!1),e._backpressureChangePromise}(e)}),(function(t){return function(e,t){const r=e._transformStreamController;if(void 0!==r._finishPromise)return r._finishPromise;const n=e._writable;r._finishPromise=d(((e,t)=>{r._finishPromise_resolve=e,r._finishPromise_reject=t}));const o=r._cancelAlgorithm(t);return fn(r),y(o,(()=>("errored"===n._state?yn(r,n._storedError):(Yt(n._writableStreamController,t),an(e),vn(r)),null)),(t=>(Yt(n._writableStreamController,t),an(e),yn(r,t),null))),r._finishPromise}(e,t)}),o,i),e._backpressure=void 0,e._backpressureChangePromise=void 0,e._backpressureChangePromise_resolve=void 0,un(e,!0),e._transformStreamController=void 0}(this,d((e=>{l=e})),u,c,s,a),function(e,t){const r=Object.create(cn.prototype);let n,o,i;n=void 0!==t.transform?e=>t.transform(e,r):e=>{try{return dn(r,e),h(void 0)}catch(e){return p(e)}},o=void 0!==t.flush?()=>t.flush(r):()=>h(void 0),i=void 0!==t.cancel?e=>t.cancel(e):()=>h(void 0),function(e,t,r,n,o){t._controlledTransformStream=e,e._transformStreamController=t,t._transformAlgorithm=r,t._flushAlgorithm=n,t._cancelAlgorithm=o,t._finishPromise=void 0,t._finishPromise_resolve=void 0,t._finishPromise_reject=void 0}(e,r,n,o,i)}(this,i),void 0!==i.start?l(i.start(this._transformStreamController)):l(void 0)}get readable(){if(!nn(this))throw mn("readable");return this._readable}get writable(){if(!nn(this))throw mn("writable");return this._writable}}function nn(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_transformStreamController")&&e instanceof rn}function on(e,t){Sr(e._readable._readableStreamController,t),sn(e,t)}function sn(e,t){fn(e._transformStreamController),Yt(e._writable._writableStreamController,t),an(e)}function an(e){e._backpressure&&un(e,!1)}function un(e,t){void 0!==e._backpressureChangePromise&&e._backpressureChangePromise_resolve(),e._backpressureChangePromise=d((t=>{e._backpressureChangePromise_resolve=t})),e._backpressure=t}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(e=void 0){if(!ln(this))throw pn("enqueue");dn(this,e)}error(e=void 0){if(!ln(this))throw pn("error");var t;t=e,on(this._controlledTransformStream,t)}terminate(){if(!ln(this))throw pn("terminate");!function(e){const t=e._controlledTransformStream;wr(t._readable._readableStreamController),sn(t,new TypeError("TransformStream terminated"))}(this)}}function ln(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledTransformStream")&&e instanceof cn}function fn(e){e._transformAlgorithm=void 0,e._flushAlgorithm=void 0,e._cancelAlgorithm=void 0}function dn(e,t){const r=e._controlledTransformStream,n=r._readable._readableStreamController;if(!Ir(n))throw new TypeError("Readable side is not in a state that permits enqueue");try{_r(n,t)}catch(e){throw sn(r,e),r._readable._storedError}const o=function(e){return!gr(e)}(n);o!==r._backpressure&&un(r,!0)}function hn(e,t){return b(e._transformAlgorithm(t),void 0,(t=>{throw on(e._controlledTransformStream,t),t}))}function pn(e){return new TypeError(`TransformStreamDefaultController.prototype.${e} can only be used on a TransformStreamDefaultController`)}function vn(e){void 0!==e._finishPromise_resolve&&(e._finishPromise_resolve(),e._finishPromise_resolve=void 0,e._finishPromise_reject=void 0)}function yn(e,t){void 0!==e._finishPromise_reject&&(w(e._finishPromise),e._finishPromise_reject(t),e._finishPromise_resolve=void 0,e._finishPromise_reject=void 0)}function mn(e){return new TypeError(`TransformStream.prototype.${e} 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})}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={id:n,loaded:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.loaded=!0,i.exports}return r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.nmd=function(e){return e.paths=[],e.children||(e.children=[]),e},r(5047),r(972)}()}));
|