@cloudbase/js-sdk 2.24.4 → 2.24.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see auth.js.LICENSE.txt */
2
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("cloudbase_auth",[],t):"object"==typeof exports?exports.cloudbase_auth=t():e.cloudbase_auth=t()}("undefined"!=typeof window?window:this,(()=>(()=>{"use strict";var e={760:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.registerAuth=void 0;var n=r(15);t.registerAuth=n.registerAuth;try{window.registerAuth=t.registerAuth}catch(e){}},325:(e,t,r)=>{var n;r.r(t),r.d(t,{AbstractSDKRequest:()=>o,AbstractStorage:()=>i,StorageType:()=>n,formatUrl:()=>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}},15:(e,t,r)=>{r.r(t),r.d(t,{Auth:()=>xi,LoginState:()=>qi,User:()=>Di,eventBus:()=>Li,generateAuthInstance:()=>ji,registerAuth:()=>Bi});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";var c,l="credentials_error",d={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"},h={LOGIN_STATE_CHANGED:"loginStateChanged",AUTH_STATE_CHANGED:"authStateChanged"},f={SIGN_IN:"sign_in",BIND_IDENTITY:"bind_identity"};function p(){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 v=r(655);function y(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){y(i,n,o,s,a,"next",e)}function a(e){y(i,n,o,s,a,"throw",e)}s(void 0)}))}}var m=new Map;class _{constructor(e){this.clientId=(null==e?void 0:e.clientId)||"",m=m||new Map}run(e,t){var r=this;return g((function*(){e="".concat(r.clientId,"_").concat(e);var n=m.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{m.delete(e)}}))()})),m.set(e,n)),n}))()}runIdlePromise(){return Promise.resolve()}}var b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",w=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/,S=function(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!w.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=b.indexOf(e.charAt(i++))<<18|b.indexOf(e.charAt(i++))<<12|(r=b.indexOf(e.charAt(i++)))<<6|(n=b.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.getSystemInfoSync)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.getSystemInfoSync())return!1;if("qq"===e.getSystemInfoSync().AppPlatform)return!1}catch(e){return!1}return!0}var T=!1;function E(){T=T||void 0!==typeof window&&"miniprogram"===window.__wxjs_environment}try{I()||(T=T||!!navigator.userAgent.match(/miniprogram/i)||"miniprogram"===window.__wxjs_environment,window&&window.WeixinJSBridge&&window.WeixinJSBridge.invoke?E():"undefined"!=typeof document&&document.addEventListener("WeixinJSBridgeReady",E,!1))}catch(Y){}var O="@cloudbase/js-sdk";function P(){return O}var R="INVALID_OPERATION",C="OPERATION_FAIL",A=r(325);function U(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]:""}function k(e,t){console.warn("[".concat(P(),"][").concat(e,"]:").concat(t))}var L,N,D=(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)}),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)},x=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])}}};!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}D(t,e),t.prototype.get=function(e){return this.request(q(q({},e),{method:"get"}),this.restrictedMethods.includes("get"))},t.prototype.post=function(e){return this.request(q(q({},e),{method:"post"}),this.restrictedMethods.includes("post"))},t.prototype.put=function(e){return this.request(q(q({},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(q(q({},e),{data:u,method:a}),this.restrictedMethods.includes("upload"))):this.request(q(q({},e),{method:"put",headers:s,body:r}),this.restrictedMethods.includes("upload"))},t.prototype.download=function(e){return x(this,void 0,void 0,(function(){var t,r,n,o;return j(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.get(q(q({},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 x(this,void 0,void 0,(function(){var r,n,o,i,s,a,u,c,l,d,h,f,p,v=this;return j(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,d=void 0===l||l,h=null!=c?c:this.timeout,u&&(u.aborted&&r.abort(),u.addEventListener("abort",(function(){return r.abort()}))),f=null,i&&h&&(f=setTimeout((function(){console.warn(v.timeoutMsg),r.abort(new Error(v.timeoutMsg))}),h)),[4,fetch(n,q(q({},e),{signal:r.signal})).then((function(e){return x(v,void 0,void 0,(function(){var t,r,n;return j(this,(function(o){switch(o.label){case 0:return clearTimeout(f),d?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(f),d)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,u=e.url,c=e.headers,l=void 0===c?{}:c,d=e.data,h=e.responseType,f=e.withCredentials,p=e.body,v=e.onUploadProgress,y=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)}("https:",u,"get"===n?d:{}),g=new XMLHttpRequest;g.open(n,y),h&&(g.responseType=h),Object.keys(l).forEach((function(e){g.setRequestHeader(e,l[e])})),v&&g.upload.addEventListener("progress",v),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)),a=d,s="[object FormData]"===Object.prototype.toString.call(a)?d:"application/x-www-form-urlencoded"===l["content-type"]?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("&")}(d):p||(d?JSON.stringify(d):void 0),f&&(g.withCredentials=!0),g.send(s)}))}}(A.AbstractSDKRequest),function(e){e.WEB="web",e.WX_MP="wx_mp"}(N||(N={}));var M=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)}}(),B=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())}))},W=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])}}},F=function(e){function t(t){var r=e.call(this)||this;return r.root=t,t.tcbCacheObject||(t.tcbCacheObject={}),r}return M(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);!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:(k("INVALID_PARAMS","localStorage is not supported on current platform"),new F(t.root));case"none":return new F(t.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}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,msg:"[".concat(P(),"][").concat(C,"]setStore failed"),info:e}))}}else k(R,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(e,t,r){return B(this,void 0,void 0,(function(){var n;return W(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})||void 0===r?void 0:r.tcb_token))return{IS_MP_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:""}k(R,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,t){var r;return B(this,void 0,void 0,(function(){var n;return W(this,(function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!0})||void 0===r?void 0:r.tcb_token))return[2,{IS_MP_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(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):k(R,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(e){return B(this,void 0,void 0,(function(){return W(this,(function(t){switch(t.label){case 0:return[4,this.storage.removeItem(e)];case 1:return t.sent(),[2]}}))}))}}();var H=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)}}(),V=function(e,t){this.data=t||null,this.name=e},z=function(e){function t(t,r){var n=e.call(this,"error",{error:t,data:r})||this;return n.error=t,n}return H(t,e),t}(V),G=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(e instanceof z)return console.error(e.error),this;var r="string"==typeof e?new V(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 G;var K=new G;function Y(e){this.message=e}function $(e){this.message=e}function Q(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 J(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Q(Object(r),!0).forEach((function(t){Z(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Q(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Z(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 X(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 ee(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function s(e){X(i,n,o,s,a,"next",e)}function a(e){X(i,n,o,s,a,"throw",e)}s(void 0)}))}}"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.indexOf("Firefox"),Y.prototype=new Error,Y.prototype.name="InvalidCharacterError","undefined"!=typeof window&&window.atob&&window.atob.bind(window),$.prototype=new Error,$.prototype.name="InvalidTokenError";var te="x-request-id",re="x-device-id",ne="device_id",oe=function(){var e=ee((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)}}(),ie=new class{constructor(e){this._env=(null==e?void 0:e.env)||""}getItem(e){var t=this;return ee((function*(){return window.localStorage.getItem("".concat(e).concat(t._env))}))()}removeItem(e){var t=this;return ee((function*(){window.localStorage.removeItem("".concat(e).concat(t._env))}))()}setItem(e,t){var r=this;return ee((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 se(e){var t=!0;return null!=e&&e.expires_at&&null!=e&&e.access_token&&(t=e.expires_at<new Date),t}class ae{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 _({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 ee((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}getCredentials(){var e=this;return ee((function*(){return e.singlePromise.run("getCredentials",ee((function*(){if(se(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 ee((function*(){return e.singlePromise.run("_getStorageCredentials",ee((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 ue{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 _({clientId:this.clientId}),this.retry=this.formatRetry(e.retry,ue.defaultRetry),e.baseRequest?this.baseRequest=e.baseRequest:this.baseRequest=oe,this.tokenInURL=e.tokenInURL,this.headers=e.headers,this.storage=e.storage||ie,this.localCredentials=new ae({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+=b.charAt((t=r<<16|n<<8|o)>>18&63)+b.charAt(t>>12&63)+b.charAt(t>>6&63)+b.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,K.on("lang_change",(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 ee((function*(){return t.initializePromise?yield t.initializePromise:void 0!==e?(t.initializePromise=e,yield t.initializePromise):(t.initializePromise=ee((function*(){return yield t._acquireLock(-1,ee((function*(){return yield t._initialize()})))}))(),yield t.initializePromise)}))()}setCredentials(e){var t=this;return ee((function*(){return yield t.initializePromise,t._acquireLock(-1,ee((function*(){return t.localCredentials.setCredentials(e)})))}))()}setAccessKeyCredentials(e){return this.localCredentials.setAccessKeyCredentials(e)}getAccessToken(){var e=this;return ee((function*(){yield e.initializePromise;var t=yield e.getCredentials();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 ee((function*(){var n,o,i,a;t||(t={});var u=r.formatRetry(t.retry,r.retry);if(t.headers=J(J({},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=J(J({},r.headers),t.headers)),t.headers[te]||(t.headers[te]=p()),!t.headers[re]){var c=yield r.getDeviceId();t.headers[re]=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 d=null,h=u+1,f=0;f<h;f++){try{d=t.useWxCloud||r.useWxCloud?yield r.wxCloudCallFunction(e,t):yield r.baseRequest(e,t);break}catch(e){if(t.withCredentials&&e&&e.error===s.UNAUTHENTICATED)return yield r.setCredentials(null),Promise.reject(e);if(f===u||!e||"unreachable"!==e.error)return Promise.reject(e)}yield r.sleep(ue.retryInterval)}return d}))()}wxCloudCallFunction(e,t){var r=this;return ee((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:J({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,v.y)(e):n=null==u?void 0:u.body}catch(t){o={error:s.UNREACHABLE,error_description:t.message,error_uri:(0,v.y)(e)}}if(o)throw o;return n}))()}getCredentials(){var e=this;return ee((function*(){return yield e.initializePromise,e._acquireLock(-1,ee((function*(){return e._getCredentials()})))}))()}getCredentialsSync(){return this.localCredentials.getStorageCredentialsSync()}getCredentialsAsync(){return this.getCredentials()}getScope(){var e=this;return ee((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 ee((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 ee((function*(){return yield r.initializePromise,r._acquireLock(-1,ee((function*(){return r._refreshToken(e,t)})))}))()}_refreshToken(e,t){var r=this;return ee((function*(){return r.singlePromise.run("_refreshToken",ee((function*(){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(h.AUTH_STATE_CHANGED,{event:d.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 ee((function*(){return t.singlePromise.run("_anonymousLogin",ee((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<ue.minRetry||e>ue.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 ee((function*(){return new Promise((t=>{setTimeout((()=>{t()}),e)}))}))()}anonymousSignIn(e){var t=this;return ee((function*(){return t.singlePromise.run("_anonymous",ee((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 ee((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),J(J({},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 ee((function*(){if(e.deviceID)return e.deviceID;var t=yield e.storage.getItem(ne);return"string"==typeof t&&t.length>=16&&t.length<=48||(t=p(),yield e.storage.setItem(ne,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 ee((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 ee((function*(){r._debug("#_acquireLock","begin",e);try{if(r.lockAcquired){var n=r.pendingInLock.length?r.pendingInLock[r.pendingInLock.length-1]:Promise.resolve(),o=ee((function*(){return yield n,yield t()}))();return r.pendingInLock.push(ee((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(ee((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 ee((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)}if(se(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}))()}}ue.defaultRetry=2,ue.minRetry=0,ue.maxRetry=5,ue.retryInterval=1e3;var ce=r(689),le=r(616);function de(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 he(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?de(Object(r),!0).forEach((function(t){fe(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):de(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function fe(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)}))}}var ye=(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)}},ge=new ce.CloudbaseEventEmitter,me="resolveCaptchaData",_e="padding:10px 8px;background:#007bff;color:#fff;border:none;border-radius:4px;cursor:pointer;flex:1;white-space:nowrap;margin-left:10px",be="width:100%;padding:10px;background:#007bff;color:#fff;border:none;border-radius:4px;cursor:pointer",we="background:#6c757d;cursor:not-allowed",Se=e=>{var{oauthInstance:t,captchaState:r}=e,n="captcha-image",o=function(){var e=ve((function*(){try{var e=yield t.createCaptchaData({state:r.state});r=he(he({},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",_e,"刷新");l.onclick=ye(ve((function*(){l.textContent="加载中...",l.disabled=!0,l.style.cssText="".concat(_e,";").concat(we);try{yield o()}finally{l.textContent="刷新",l.disabled=!1,l.style.cssText=_e}})),500),u.appendChild(l),a.appendChild(u);var d=i("input","width:100%;padding:14px 16px;margin-bottom:15px;box-sizing:border-box;border:2px solid #e8ecf4;border-radius:10px;font-size:15px");d.type="text",d.placeholder="输入字符",d.maxLength=4,a.appendChild(d);var h=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(h);var f=e=>{h.textContent=e,h.style.display="block"},p=i("button",be,"确定");p.onclick=ye(ve((function*(){var e=d.value.trim();if(e){h.style.display="none",p.textContent="验证中...",p.disabled=!0,p.style.cssText="".concat(be,";").concat(we);try{var n=yield t.verifyCaptchaData({token:r.token,key:e});ge.fire(me,n),console.log("图形验证码校验成功"),document.body.removeChild(s),document.body.removeChild(a)}catch(e){console.error("图形验证码校验失败",e);var i=e.error_description||"图形验证码校验失败";f(i),d.value="",d.focus(),yield o()}finally{p.textContent="确定",p.disabled=!1,p.style.cssText=be}}else f("请输入字符")})),500),a.appendChild(p),document.body.appendChild(s),document.body.appendChild(a)},Ie=function(){var e=ve((function*(e,t){var{captchaData:r,state:n,token:o}=(0,le.parseCaptcha)(e);return Se({oauthInstance:t,captchaState:{captchaData:r,state:n,token:o}}),new Promise((e=>{console.log("等待图形验证码校验结果..."),ge.on(me,(t=>{e(null==t?void 0:t.data)}))}))}));return function(t,r){return e.apply(this,arguments)}}();function Te(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 Ee(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function s(e){Te(i,n,o,s,a,"next",e)}function a(e){Te(i,n,o,s,a,"throw",e)}s(void 0)}))}}class Oe{constructor(e){e.openURIWithCallback||(e.openURIWithCallback=this.getDefaultOpenURIWithCallback()),e.storage||(e.storage=ie),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 Ee((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=>Ie(e,this.config.oauthInstance)}getCaptchaToken(e,t){var r=this;return Ee((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 Ee((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 Ee((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 Ee((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}))()}}const Pe=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("&")}};var Re=["provider_redirect_uri","other_params"];function Ce(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 Ae(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function s(e){Ce(i,n,o,s,a,"next",e)}function a(e){Ce(i,n,o,s,a,"throw",e)}s(void 0)}))}}function Ue(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 ke(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Ue(Object(r),!0).forEach((function(t){Le(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ue(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Le(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 Ne(e,t){try{var n;if(((null==t||null===(n=t.root)||void 0===n?void 0:n.globalThis)||globalThis).IS_MP_BUILD)return}catch(t){if(e)return(()=>{try{return r(171)}catch(e){return}})()}}class De{static parseParamsToSearch(e){return Object.keys(e).forEach((t=>{e[t]||delete e[t]})),new Pe(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 ue(n)}if(!t){var o=r.request.bind(r),i=new Oe(ke({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||ie,adapter:e.adapter}}getParamsByVersion(e,t){var r,i=(0,v.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 Ae((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(ke(ke({},i),{},{version:r})),Promise.resolve(i)}))()}signInAnonymously(){var e=arguments,t=this;return Ae((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 Ae((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 Ae((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 Ae((function*(){yield e.config.request(n.AUTH_REVOKE_ALL_URL,{method:"DELETE",withCredentials:!0})}))()}revokeDevice(e){var t=this;return Ae((function*(){yield t.config.request(n.AUTHORIZED_DEVICES_DELETE_URL+e.device_id,{method:"DELETE",withCredentials:!0})}))()}getVerification(e,t){var r=this;return Ae((function*(){var o=!1;("CUR_USER"===e.target||(yield r.hasLoginState()))&&(o=!0);var i=(0,v.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 Ae((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(ke(ke({},n),{},{version:"v2"}))),n}))()}genProviderRedirectUri(e){var t=this;return Ae((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,Re);r&&!i.redirect_uri&&(i.redirect_uri=r);var s="".concat(n.PROVIDER_URI_URL,"?").concat(De.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 Ae((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 Ae((function*(){return t.config.request(n.PROVIDER_TOKEN_URL,{method:"PATCH",body:e})}))()}signInWithProvider(e){var t=arguments,r=this;return Ae((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(ke(ke({},i),{},{version:(null==e?void 0:e.version)||"v1"})),Promise.resolve(i)}))()}toBindIdentity(e){var t=this;return Ae((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:f.BIND_IDENTITY,provider:e.provider},error:null}}catch(e){r={data:{type:f.BIND_IDENTITY},error:new qe(e)}}return e.fireEvent&&(null===(n=t.config.eventBus)||void 0===n||null===(o=n.fire)||void 0===o||o.call(n,h.AUTH_STATE_CHANGED,{event:d.BIND_IDENTITY,info:r})),r}))()}getInitialSession(){var e=this;return Ae((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 d=a.get("error"),h=a.get("error_description");if(d||h)return{data:t,error:new qe({message:h||d||"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 qe({message:"Provider is required for OAuth verification"})};var v,y,g=location.origin+location.pathname,{provider_token:m}=yield e.grantProviderToken({provider_id:p,provider_redirect_uri:g,provider_code:u}),_=null;if(l.type===f.BIND_IDENTITY)v=yield e.config.credentialsClient.localCredentials.getCredentials(),y=yield e.toBindIdentity({provider:p,provider_token:m,credentials:v});else if(l.type===f.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:m}});try{_=yield e.getUserInfo({credentials:v})}catch(e){console.error("get user info error",e)}y={data:ke(ke({},t),{},{session:v,user:_}),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 qe(e)}}}))()}signInCustom(e){var t=this;return Ae((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 Ae((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 Ae((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 Ae((function*(){return t.getUserInfo(e)}))()}getUserInfo(){var e=arguments,t=this;return Ae((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 Pe(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 Ae((function*(){return yield e.config.request(n.WEDA_USER_URL,{method:"GET",withCredentials:!0})}))()}deleteMe(e){var t=this;return Ae((function*(){var r=t.getParamsByVersion(e,"USER_ME_URL"),n="".concat(r.url,"?").concat(De.parseParamsToSearch(r.params));return t.config.request(n,{method:"DELETE",withCredentials:!0})}))()}hasLoginState(){var e=this;return Ae((function*(){try{return yield e.config.credentialsClient.getAccessToken(),!0}catch(e){return!1}}))()}hasLoginStateSync(){return this.config.credentialsClient.getCredentialsSync()}getLoginState(){var e=this;return Ae((function*(){return e.config.credentialsClient.getCredentialsAsync()}))()}transByProvider(e){var t=this;return Ae((function*(){return t.config.request(n.USER_TRANS_BY_PROVIDER_URL,{method:"PATCH",body:e,withCredentials:!0})}))()}grantToken(e){var t=this;return Ae((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 Ae((function*(){return e.config.request(n.PROVIDER_LIST,{method:"GET",withCredentials:!0})}))()}unbindProvider(e){var t=this;return Ae((function*(){return t.config.request("".concat(n.PROVIDER_UNBIND_URL,"/").concat(e.provider_id),{method:"DELETE",withCredentials:!0})}))()}checkPassword(e){var t=this;return Ae((function*(){return t.config.request("".concat(n.CHECK_PWD_URL),{method:"POST",withCredentials:!0,body:e})}))()}editContact(e){var t=this;return Ae((function*(){return t.config.request("".concat(n.BIND_CONTACT_URL),{method:"PATCH",withCredentials:!0,body:e})}))()}setPassword(e){var t=this;return Ae((function*(){return t.config.request("".concat(n.AUTH_SET_PASSWORD),{method:"PATCH",withCredentials:!0,body:e})}))()}updatePasswordByOld(e){var t=this;return Ae((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 Ae((function*(){return t.config.request("".concat(n.SUDO_URL),{method:"POST",withCredentials:!0,body:e})}))()}sendVerificationCodeToCurrentUser(e){var t=this;return Ae((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 Ae((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 Ae((function*(){return t.config.request(n.USER_PRIFILE_URL,{method:"PATCH",body:e,withCredentials:!0})}))()}updateUserBasicInfo(e){var t=this;return Ae((function*(){return t.config.request(n.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:e})}))()}queryUserProfile(e){var t=this;return Ae((function*(){var r=new Pe(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 Ae((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 Ae((function*(){return t.config.request(n.AUTH_RESET_PASSWORD,{method:"POST",body:e})}))()}authorize(e){var t=this;return Ae((function*(){return t.config.request(n.AUTHORIZE_URL,{method:"POST",withCredentials:!0,body:e})}))()}authorizeDevice(e){var t=this;return Ae((function*(){return t.config.request(n.AUTHORIZE_DEVICE_URL,{method:"POST",withCredentials:!0,body:e})}))()}deviceAuthorize(e){var t=this;return Ae((function*(){return t.config.request(n.AUTH_GET_DEVICE_CODE,{method:"POST",body:e,withCredentials:!0})}))()}authorizeInfo(e){var t=this;return Ae((function*(){var r="".concat(n.AUTHORIZE_INFO_URL,"?").concat(De.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 Ae((function*(){return t.config.request(n.CHECK_USERNAME,{method:"GET",body:e,withCredentials:!0})}))()}checkIfUserExist(e){var t=this;return Ae((function*(){var r=new Pe(e);return t.config.request("".concat(n.CHECK_IF_USER_EXIST,"?").concat(r.toString()),{method:"GET"})}))()}loginScope(){var e=this;return Ae((function*(){return e.config.credentialsClient.getScope()}))()}loginGroups(){var e=this;return Ae((function*(){return e.config.credentialsClient.getGroups()}))()}refreshTokenForce(e){var t=this;return Ae((function*(){var r=yield t.config.credentialsClient.getCredentials();return yield t.config.credentialsClient.refreshToken(ke(ke({},r),{},{version:(null==e?void 0:e.version)||"v1"}))}))()}getCredentials(){var e=this;return Ae((function*(){return e.config.credentialsClient.getCredentials()}))()}getPublicKey(){var e=this;return Ae((function*(){return e.config.request(o.AUTH_PUBLIC_KEY,{method:"POST",body:{}})}))()}getEncryptParams(e){var t=this;return Ae((function*(){var{isEncrypt:r}=e;delete e.isEncrypt;var n=(0,v.I)(e),o=Ne(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 Ae((function*(){return e.config.request(n.GET_PROVIDER_TYPE,{method:"POST",body:{provider_id:"weda"}})}))()}verifyCaptchaData(e){var t=this;return Ae((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 Ae((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 Ae((function*(){return t.config.request(n.GET_MINIPROGRAM_QRCODE,{method:"POST",body:e})}))()}getMiniProgramQrCodeStatus(e){var t=this;return Ae((function*(){return t.config.request(n.GET_MINIPROGRAM_QRCODE_STATUS,{method:"POST",body:e})}))()}getUserBehaviorLog(e){var t=this;return Ae((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 Ae((function*(){var r="",o="",i=Ne(!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 Ae((function*(){var r="",n="",i=Ne(!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())}catch(e){}}}class qe extends Error{constructor(e){super(e.error_description||e.message),this.__isAuthError=!0,this.name="AuthError",this.status=e.error,this.code=e.error_code}}function xe(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 je(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?xe(Object(r),!0).forEach((function(t){Me(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):xe(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Me(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 Be{constructor(e){var{apiOrigin:t,apiPath:r=u,clientId:n,env:o,storage:i,request:s,baseRequest:a,anonymousSignInFunc:c,wxCloud:l,adapter:d,onCredentialsError:h,headers:f,i18n:p,useWxCloud:v,eventBus:y,detectSessionInUrl:g,debug:m}=e;this.detectSessionInUrl=null!=g&&g,this.oauth2client=new ue({apiOrigin:t,apiPath:r,clientId:n,env:o,storage:i,baseRequest:a||s,anonymousSignInFunc:c,wxCloud:l,onCredentialsError:h,headers:f||{},i18n:p,useWxCloud:v,eventBus:y,debug:m}),this.authApi=new De(je(je({credentialsClient:this.oauth2client},e),{},{request:s?this.oauth2client.request.bind(this.oauth2client):void 0,adapter:d})),g&&this.oauth2client.setGetInitialSession(this.authApi.getInitialSession.bind(this.authApi))}initializeSession(e){this.detectSessionInUrl?(this.oauth2client.setOnInitialSessionObtained(e),this.oauth2client.initialize()):this.oauth2client.initialize(Promise.resolve({error:null}))}}var We=r(794),Fe=r(141),He=r(197);function Ve(){}function ze(e){return"object"==typeof e&&null!==e||"function"==typeof e}const Ge=Ve;function Ke(e,t){try{Object.defineProperty(e,"name",{value:t,configurable:!0})}catch(e){}}const Ye=Promise,$e=Promise.resolve.bind(Ye),Qe=Promise.prototype.then,Je=Promise.reject.bind(Ye),Ze=$e;function Xe(e){return new Ye(e)}function et(e){return Xe((t=>t(e)))}function tt(e){return Je(e)}function rt(e,t,r){return Qe.call(e,t,r)}function nt(e,t,r){rt(rt(e,t,r),void 0,Ge)}function ot(e,t){nt(e,t)}function it(e,t){nt(e,void 0,t)}function st(e,t,r){return rt(e,t,r)}function at(e){rt(e,void 0,Ge)}let ut=e=>{if("function"==typeof queueMicrotask)ut=queueMicrotask;else{const e=et(void 0);ut=t=>rt(e,t)}return ut(e)};function ct(e,t,r){if("function"!=typeof e)throw new TypeError("Argument is not a function");return Function.prototype.apply.call(e,t,r)}function lt(e,t,r){try{return et(ct(e,t,r))}catch(e){return tt(e)}}class dt{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 ht=Symbol("[[AbortSteps]]"),ft=Symbol("[[ErrorSteps]]"),pt=Symbol("[[CancelSteps]]"),vt=Symbol("[[PullSteps]]"),yt=Symbol("[[ReleaseSteps]]");function gt(e,t){e._ownerReadableStream=t,t._reader=e,"readable"===t._state?wt(e):"closed"===t._state?function(e){wt(e),Tt(e)}(e):St(e,t._storedError)}function mt(e,t){return Ro(e._ownerReadableStream,t)}function _t(e){const t=e._ownerReadableStream;"readable"===t._state?It(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")):function(e){St(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness"))}(e),t._readableStreamController[yt](),t._reader=void 0,e._ownerReadableStream=void 0}function bt(e){return new TypeError("Cannot "+e+" a stream using a released reader")}function wt(e){e._closedPromise=Xe(((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r}))}function St(e,t){wt(e),It(e,t)}function It(e,t){void 0!==e._closedPromise_reject&&(at(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}function Tt(e){void 0!==e._closedPromise_resolve&&(e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}const Et=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},Ot=Math.trunc||function(e){return e<0?Math.ceil(e):Math.floor(e)};function Pt(e,t){if(void 0!==e&&"object"!=typeof(r=e)&&"function"!=typeof r)throw new TypeError(`${t} is not an object.`);var r}function Rt(e,t){if("function"!=typeof e)throw new TypeError(`${t} is not a function.`)}function Ct(e,t){if(!function(e){return"object"==typeof e&&null!==e||"function"==typeof e}(e))throw new TypeError(`${t} is not an object.`)}function At(e,t,r){if(void 0===e)throw new TypeError(`Parameter ${t} is required in '${r}'.`)}function Ut(e,t,r){if(void 0===e)throw new TypeError(`${t} is required in '${r}'.`)}function kt(e){return Number(e)}function Lt(e){return 0===e?0:e}function Nt(e,t){const r=Number.MAX_SAFE_INTEGER;let n=Number(e);if(n=Lt(n),!Et(n))throw new TypeError(`${t} is not a finite number`);if(n=function(e){return Lt(Ot(e))}(n),n<0||n>r)throw new TypeError(`${t} is outside the accepted range of 0 to ${r}, inclusive`);return Et(n)&&0!==n?n:0}function Dt(e,t){if(!Oo(e))throw new TypeError(`${t} is not a ReadableStream.`)}function qt(e){return new Wt(e)}function xt(e,t){e._reader._readRequests.push(t)}function jt(e,t,r){const n=e._reader._readRequests.shift();r?n._closeSteps():n._chunkSteps(t)}function Mt(e){return e._reader._readRequests.length}function Bt(e){const t=e._reader;return void 0!==t&&!!Ft(t)}class Wt{constructor(e){if(At(e,1,"ReadableStreamDefaultReader"),Dt(e,"First parameter"),Po(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");gt(this,e),this._readRequests=new dt}get closed(){return Ft(this)?this._closedPromise:tt(zt("closed"))}cancel(e=void 0){return Ft(this)?void 0===this._ownerReadableStream?tt(bt("cancel")):mt(this,e):tt(zt("cancel"))}read(){if(!Ft(this))return tt(zt("read"));if(void 0===this._ownerReadableStream)return tt(bt("read from"));let e,t;const r=Xe(((r,n)=>{e=r,t=n}));return Ht(this,{_chunkSteps:t=>e({value:t,done:!1}),_closeSteps:()=>e({value:void 0,done:!0}),_errorSteps:e=>t(e)}),r}releaseLock(){if(!Ft(this))throw zt("releaseLock");void 0!==this._ownerReadableStream&&function(e){_t(e),Vt(e,new TypeError("Reader was released"))}(this)}}function Ft(e){return!!ze(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readRequests")&&e instanceof Wt}function Ht(e,t){const r=e._ownerReadableStream;r._disturbed=!0,"closed"===r._state?t._closeSteps():"errored"===r._state?t._errorSteps(r._storedError):r._readableStreamController[vt](t)}function Vt(e,t){const r=e._readRequests;e._readRequests=new dt,r.forEach((e=>{e._errorSteps(t)}))}function zt(e){return new TypeError(`ReadableStreamDefaultReader.prototype.${e} can only be used on a ReadableStreamDefaultReader`)}var Gt,Kt,Yt;function $t(e){return e.slice()}function Qt(e,t,r,n,o){new Uint8Array(e).set(new Uint8Array(r,n,o),t)}Object.defineProperties(Wt.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),Ke(Wt.prototype.cancel,"cancel"),Ke(Wt.prototype.read,"read"),Ke(Wt.prototype.releaseLock,"releaseLock"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Wt.prototype,Symbol.toStringTag,{value:"ReadableStreamDefaultReader",configurable:!0});let Jt=e=>(Jt="function"==typeof e.transfer?e=>e.transfer():"function"==typeof structuredClone?e=>structuredClone(e,{transfer:[e]}):e=>e,Jt(e)),Zt=e=>(Zt="boolean"==typeof e.detached?e=>e.detached:e=>0===e.byteLength,Zt(e));function Xt(e,t,r){if(e.slice)return e.slice(t,r);const n=r-t,o=new ArrayBuffer(n);return Qt(o,0,e,t,n),o}function er(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 tr(e){try{const t=e.done,r=e.value;return rt(Ze(r),(e=>({done:t,value:e})))}catch(e){return tt(e)}}const rr=null!==(Yt=null!==(Gt=Symbol.asyncIterator)&&void 0!==Gt?Gt:null===(Kt=Symbol.for)||void 0===Kt?void 0:Kt.call(Symbol,"Symbol.asyncIterator"))&&void 0!==Yt?Yt:"@@asyncIterator";function nr(e,t="sync",r){if(void 0===r)if("async"===t){if(void 0===(r=er(e,rr)))return function(e){const t={next(){let t;try{t=or(e)}catch(e){return tt(e)}return tr(t)},return(t){let r;try{const n=er(e.iterator,"return");if(void 0===n)return et({done:!0,value:t});r=ct(n,e.iterator,[t])}catch(e){return tt(e)}return ze(r)?tr(r):tt(new TypeError("The iterator.return() method must return an object"))}};return{iterator:t,nextMethod:t.next,done:!1}}(nr(e,"sync",er(e,Symbol.iterator)))}else r=er(e,Symbol.iterator);if(void 0===r)throw new TypeError("The object is not iterable");const n=ct(r,e,[]);if(!ze(n))throw new TypeError("The iterator method must return an object");return{iterator:n,nextMethod:n.next,done:!1}}function or(e){const t=ct(e.nextMethod,e.iterator,[]);if(!ze(t))throw new TypeError("The iterator.next() method must return an object");return t}class ir{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?st(this._ongoingPromise,e,e):e(),this._ongoingPromise}return(e){const t=()=>this._returnSteps(e);return this._ongoingPromise?st(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=Xe(((e,n)=>{t=e,r=n}));return Ht(e,{_chunkSteps:e=>{this._ongoingPromise=void 0,ut((()=>t({value:e,done:!1})))},_closeSteps:()=>{this._ongoingPromise=void 0,this._isFinished=!0,_t(e),t({value:void 0,done:!0})},_errorSteps:t=>{this._ongoingPromise=void 0,this._isFinished=!0,_t(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=mt(t,e);return _t(t),st(r,(()=>({value:e,done:!0})))}return _t(t),et({value:e,done:!0})}}const sr={next(){return ar(this)?this._asyncIteratorImpl.next():tt(ur("next"))},return(e){return ar(this)?this._asyncIteratorImpl.return(e):tt(ur("return"))},[rr](){return this}};function ar(e){if(!ze(e))return!1;if(!Object.prototype.hasOwnProperty.call(e,"_asyncIteratorImpl"))return!1;try{return e._asyncIteratorImpl instanceof ir}catch(e){return!1}}function ur(e){return new TypeError(`ReadableStreamAsyncIterator.${e} can only be used on a ReadableSteamAsyncIterator`)}Object.defineProperty(sr,rr,{enumerable:!1});const cr=Number.isNaN||function(e){return e!=e};function lr(e){const t=Xt(e.buffer,e.byteOffset,e.byteOffset+e.byteLength);return new Uint8Array(t)}function dr(e){const t=e._queue.shift();return e._queueTotalSize-=t.size,e._queueTotalSize<0&&(e._queueTotalSize=0),t.value}function hr(e,t,r){if("number"!=typeof(n=r)||cr(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 fr(e){e._queue=new dt,e._queueTotalSize=0}function pr(e){return e===DataView}class vr{constructor(){throw new TypeError("Illegal constructor")}get view(){if(!mr(this))throw Hr("view");return this._view}respond(e){if(!mr(this))throw Hr("respond");if(At(e,1,"respond"),e=Nt(e,"First parameter"),void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");if(Zt(this._view.buffer))throw new TypeError("The BYOB request's buffer has been detached and so cannot be used as a response");Br(this._associatedReadableByteStreamController,e)}respondWithNewView(e){if(!mr(this))throw Hr("respondWithNewView");if(At(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(Zt(e.buffer))throw new TypeError("The given view's buffer has been detached and so cannot be used as a response");Wr(this._associatedReadableByteStreamController,e)}}Object.defineProperties(vr.prototype,{respond:{enumerable:!0},respondWithNewView:{enumerable:!0},view:{enumerable:!0}}),Ke(vr.prototype.respond,"respond"),Ke(vr.prototype.respondWithNewView,"respondWithNewView"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(vr.prototype,Symbol.toStringTag,{value:"ReadableStreamBYOBRequest",configurable:!0});class yr{constructor(){throw new TypeError("Illegal constructor")}get byobRequest(){if(!gr(this))throw Vr("byobRequest");return jr(this)}get desiredSize(){if(!gr(this))throw Vr("desiredSize");return Mr(this)}close(){if(!gr(this))throw Vr("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`);Nr(this)}enqueue(e){if(!gr(this))throw Vr("enqueue");if(At(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`);Dr(this,e)}error(e=void 0){if(!gr(this))throw Vr("error");qr(this,e)}[pt](e){br(this),fr(this);const t=this._cancelAlgorithm(e);return Lr(this),t}[vt](e){const t=this._controlledReadableByteStream;if(this._queueTotalSize>0)return void xr(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)}xt(t,e),_r(this)}[yt](){if(this._pendingPullIntos.length>0){const e=this._pendingPullIntos.peek();e.readerType="none",this._pendingPullIntos=new dt,this._pendingPullIntos.push(e)}}}function gr(e){return!!ze(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableByteStream")&&e instanceof yr}function mr(e){return!!ze(e)&&!!Object.prototype.hasOwnProperty.call(e,"_associatedReadableByteStreamController")&&e instanceof vr}function _r(e){const t=function(e){const t=e._controlledReadableByteStream;return"readable"===t._state&&(!e._closeRequested&&(!!e._started&&(!!(Bt(t)&&Mt(t)>0)||(!!($r(t)&&Yr(t)>0)||Mr(e)>0))))}(e);t&&(e._pulling?e._pullAgain=!0:(e._pulling=!0,nt(e._pullAlgorithm(),(()=>(e._pulling=!1,e._pullAgain&&(e._pullAgain=!1,_r(e)),null)),(t=>(qr(e,t),null)))))}function br(e){Cr(e),e._pendingPullIntos=new dt}function wr(e,t){let r=!1;"closed"===e._state&&(r=!0);const n=Sr(t);"default"===t.readerType?jt(e,n,r):function(e,t,r){const n=e._reader._readIntoRequests.shift();r?n._closeSteps(t):n._chunkSteps(t)}(e,n,r)}function Sr(e){const t=e.bytesFilled,r=e.elementSize;return new e.viewConstructor(e.buffer,e.byteOffset,t/r)}function Ir(e,t,r,n){e._queue.push({buffer:t,byteOffset:r,byteLength:n}),e._queueTotalSize+=n}function Tr(e,t,r,n){let o;try{o=Xt(t,r,r+n)}catch(t){throw qr(e,t),t}Ir(e,o,0,n)}function Er(e,t){t.bytesFilled>0&&Tr(e,t.buffer,t.byteOffset,t.bytesFilled),kr(e)}function Or(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;Qt(t.buffer,i,r.buffer,r.byteOffset,n),r.byteLength===n?a.shift():(r.byteOffset+=n,r.byteLength-=n),e._queueTotalSize-=n,Pr(0,n,t),o-=n}return i}function Pr(e,t,r){r.bytesFilled+=t}function Rr(e){0===e._queueTotalSize&&e._closeRequested?(Lr(e),Co(e._controlledReadableByteStream)):_r(e)}function Cr(e){null!==e._byobRequest&&(e._byobRequest._associatedReadableByteStreamController=void 0,e._byobRequest._view=null,e._byobRequest=null)}function Ar(e){for(;e._pendingPullIntos.length>0;){if(0===e._queueTotalSize)return;const t=e._pendingPullIntos.peek();Or(e,t)&&(kr(e),wr(e._controlledReadableByteStream,t))}}function Ur(e,t){const r=e._pendingPullIntos.peek();Cr(e),"closed"===e._controlledReadableByteStream._state?function(e,t){"none"===t.readerType&&kr(e);const r=e._controlledReadableByteStream;if($r(r))for(;Yr(r)>0;)wr(r,kr(e))}(e,r):function(e,t,r){if(Pr(0,t,r),"none"===r.readerType)return Er(e,r),void Ar(e);if(r.bytesFilled<r.minimumFill)return;kr(e);const n=r.bytesFilled%r.elementSize;if(n>0){const t=r.byteOffset+r.bytesFilled;Tr(e,r.buffer,t-n,n)}r.bytesFilled-=n,wr(e._controlledReadableByteStream,r),Ar(e)}(e,t,r),_r(e)}function kr(e){return e._pendingPullIntos.shift()}function Lr(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0}function Nr(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 qr(e,t),t}}Lr(e),Co(t)}}function Dr(e,t){const r=e._controlledReadableByteStream;if(e._closeRequested||"readable"!==r._state)return;const{buffer:n,byteOffset:o,byteLength:i}=t;if(Zt(n))throw new TypeError("chunk's buffer is detached and so cannot be enqueued");const s=Jt(n);if(e._pendingPullIntos.length>0){const t=e._pendingPullIntos.peek();if(Zt(t.buffer))throw new TypeError("The BYOB request's buffer has been detached and so cannot be filled with an enqueued chunk");Cr(e),t.buffer=Jt(t.buffer),"none"===t.readerType&&Er(e,t)}Bt(r)?(function(e){const t=e._controlledReadableByteStream._reader;for(;t._readRequests.length>0;){if(0===e._queueTotalSize)return;xr(e,t._readRequests.shift())}}(e),0===Mt(r)?Ir(e,s,o,i):(e._pendingPullIntos.length>0&&kr(e),jt(r,new Uint8Array(s,o,i),!1))):$r(r)?(Ir(e,s,o,i),Ar(e)):Ir(e,s,o,i),_r(e)}function qr(e,t){const r=e._controlledReadableByteStream;"readable"===r._state&&(br(e),fr(e),Lr(e),Ao(r,t))}function xr(e,t){const r=e._queue.shift();e._queueTotalSize-=r.byteLength,Rr(e);const n=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);t._chunkSteps(n)}function jr(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(vr.prototype);!function(e,t,r){e._associatedReadableByteStreamController=t,e._view=r}(n,e,r),e._byobRequest=n}return e._byobRequest}function Mr(e){const t=e._controlledReadableByteStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function Br(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=Jt(r.buffer),Ur(e,t)}function Wr(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=Jt(t.buffer),Ur(e,n)}function Fr(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,fr(t),t._closeRequested=!1,t._started=!1,t._strategyHWM=i,t._pullAlgorithm=n,t._cancelAlgorithm=o,t._autoAllocateChunkSize=s,t._pendingPullIntos=new dt,e._readableStreamController=t,nt(et(r()),(()=>(t._started=!0,_r(t),null)),(e=>(qr(t,e),null)))}function Hr(e){return new TypeError(`ReadableStreamBYOBRequest.prototype.${e} can only be used on a ReadableStreamBYOBRequest`)}function Vr(e){return new TypeError(`ReadableByteStreamController.prototype.${e} can only be used on a ReadableByteStreamController`)}function zr(e,t){if("byob"!=(e=`${e}`))throw new TypeError(`${t} '${e}' is not a valid enumeration value for ReadableStreamReaderMode`);return e}function Gr(e){return new Qr(e)}function Kr(e,t){e._reader._readIntoRequests.push(t)}function Yr(e){return e._reader._readIntoRequests.length}function $r(e){const t=e._reader;return void 0!==t&&!!Jr(t)}Object.defineProperties(yr.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},byobRequest:{enumerable:!0},desiredSize:{enumerable:!0}}),Ke(yr.prototype.close,"close"),Ke(yr.prototype.enqueue,"enqueue"),Ke(yr.prototype.error,"error"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(yr.prototype,Symbol.toStringTag,{value:"ReadableByteStreamController",configurable:!0});class Qr{constructor(e){if(At(e,1,"ReadableStreamBYOBReader"),Dt(e,"First parameter"),Po(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");if(!gr(e._readableStreamController))throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");gt(this,e),this._readIntoRequests=new dt}get closed(){return Jr(this)?this._closedPromise:tt(en("closed"))}cancel(e=void 0){return Jr(this)?void 0===this._ownerReadableStream?tt(bt("cancel")):mt(this,e):tt(en("cancel"))}read(e,t={}){if(!Jr(this))return tt(en("read"));if(!ArrayBuffer.isView(e))return tt(new TypeError("view must be an array buffer view"));if(0===e.byteLength)return tt(new TypeError("view must have non-zero byteLength"));if(0===e.buffer.byteLength)return tt(new TypeError("view's buffer must have non-zero byteLength"));if(Zt(e.buffer))return tt(new TypeError("view's buffer has been detached"));let r;try{r=function(e,t){var r;return Pt(e,t),{min:Nt(null!==(r=null==e?void 0:e.min)&&void 0!==r?r:1,`${t} has member 'min' that`)}}(t,"options")}catch(e){return tt(e)}const n=r.min;if(0===n)return tt(new TypeError("options.min must be greater than 0"));if(function(e){return pr(e.constructor)}(e)){if(n>e.byteLength)return tt(new RangeError("options.min must be less than or equal to view's byteLength"))}else if(n>e.length)return tt(new RangeError("options.min must be less than or equal to view's length"));if(void 0===this._ownerReadableStream)return tt(bt("read from"));let o,i;const s=Xe(((e,t)=>{o=e,i=t}));return Zr(this,e,n,{_chunkSteps:e=>o({value:e,done:!1}),_closeSteps:e=>o({value:e,done:!0}),_errorSteps:e=>i(e)}),s}releaseLock(){if(!Jr(this))throw en("releaseLock");void 0!==this._ownerReadableStream&&function(e){_t(e),Xr(e,new TypeError("Reader was released"))}(this)}}function Jr(e){return!!ze(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readIntoRequests")&&e instanceof Qr}function Zr(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 pr(e)?1:e.BYTES_PER_ELEMENT}(i),{byteOffset:a,byteLength:u}=t,c=r*s;let l;try{l=Jt(t.buffer)}catch(e){return void n._errorSteps(e)}const d={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(d),void Kr(o,n);if("closed"!==o._state){if(e._queueTotalSize>0){if(Or(e,d)){const t=Sr(d);return Rr(e),void n._chunkSteps(t)}if(e._closeRequested){const t=new TypeError("Insufficient bytes to fill elements in the given buffer");return qr(e,t),void n._errorSteps(t)}}e._pendingPullIntos.push(d),Kr(o,n),_r(e)}else{const e=new i(d.buffer,d.byteOffset,0);n._closeSteps(e)}}(o._readableStreamController,t,r,n)}function Xr(e,t){const r=e._readIntoRequests;e._readIntoRequests=new dt,r.forEach((e=>{e._errorSteps(t)}))}function en(e){return new TypeError(`ReadableStreamBYOBReader.prototype.${e} can only be used on a ReadableStreamBYOBReader`)}function tn(e,t){const{highWaterMark:r}=e;if(void 0===r)return t;if(cr(r)||r<0)throw new RangeError("Invalid highWaterMark");return r}function rn(e){const{size:t}=e;return t||(()=>1)}function nn(e,t){Pt(e,t);const r=null==e?void 0:e.highWaterMark,n=null==e?void 0:e.size;return{highWaterMark:void 0===r?void 0:kt(r),size:void 0===n?void 0:on(n,`${t} has member 'size' that`)}}function on(e,t){return Rt(e,t),t=>kt(e(t))}function sn(e,t,r){return Rt(e,r),r=>lt(e,t,[r])}function an(e,t,r){return Rt(e,r),()=>lt(e,t,[])}function un(e,t,r){return Rt(e,r),r=>ct(e,t,[r])}function cn(e,t,r){return Rt(e,r),(r,n)=>lt(e,t,[r,n])}function ln(e,t){if(!vn(e))throw new TypeError(`${t} is not a WritableStream.`)}Object.defineProperties(Qr.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),Ke(Qr.prototype.cancel,"cancel"),Ke(Qr.prototype.read,"read"),Ke(Qr.prototype.releaseLock,"releaseLock"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Qr.prototype,Symbol.toStringTag,{value:"ReadableStreamBYOBReader",configurable:!0});const dn="function"==typeof AbortController;class hn{constructor(e={},t={}){void 0===e?e=null:Ct(e,"First parameter");const r=nn(t,"Second parameter"),n=function(e,t){Pt(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:sn(r,e,`${t} has member 'abort' that`),close:void 0===n?void 0:an(n,e,`${t} has member 'close' that`),start:void 0===o?void 0:un(o,e,`${t} has member 'start' that`),write:void 0===s?void 0:cn(s,e,`${t} has member 'write' that`),type:i}}(e,"First parameter");if(pn(this),void 0!==n.type)throw new RangeError("Invalid type is specified");const o=rn(r);!function(e,t,r,n){const o=Object.create(kn.prototype);let i,s,a,u;i=void 0!==t.start?()=>t.start(o):()=>{},s=void 0!==t.write?e=>t.write(e,o):()=>et(void 0),a=void 0!==t.close?()=>t.close():()=>et(void 0),u=void 0!==t.abort?e=>t.abort(e):()=>et(void 0),Nn(e,o,i,s,a,u,r,n)}(this,n,tn(r,1),o)}get locked(){if(!vn(this))throw Wn("locked");return yn(this)}abort(e=void 0){return vn(this)?yn(this)?tt(new TypeError("Cannot abort a stream that already has a writer")):gn(this,e):tt(Wn("abort"))}close(){return vn(this)?yn(this)?tt(new TypeError("Cannot close a stream that already has a writer")):Sn(this)?tt(new TypeError("Cannot close an already-closing stream")):mn(this):tt(Wn("close"))}getWriter(){if(!vn(this))throw Wn("getWriter");return fn(this)}}function fn(e){return new En(e)}function pn(e){e._state="writable",e._storedError=void 0,e._writer=void 0,e._writableStreamController=void 0,e._writeRequests=new dt,e._inFlightWriteRequest=void 0,e._closeRequest=void 0,e._inFlightCloseRequest=void 0,e._pendingAbortRequest=void 0,e._backpressure=!1}function vn(e){return!!ze(e)&&!!Object.prototype.hasOwnProperty.call(e,"_writableStreamController")&&e instanceof hn}function yn(e){return void 0!==e._writer}function gn(e,t){var r;if("closed"===e._state||"errored"===e._state)return et(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 et(void 0);if(void 0!==e._pendingAbortRequest)return e._pendingAbortRequest._promise;let o=!1;"erroring"===n&&(o=!0,t=void 0);const i=Xe(((r,n)=>{e._pendingAbortRequest={_promise:void 0,_resolve:r,_reject:n,_reason:t,_wasAlreadyErroring:o}}));return e._pendingAbortRequest._promise=i,o||bn(e,t),i}function mn(e){const t=e._state;if("closed"===t||"errored"===t)return tt(new TypeError(`The stream (in ${t} state) is not in the writable state and cannot be closed`));const r=Xe(((t,r)=>{const n={_resolve:t,_reject:r};e._closeRequest=n})),n=e._writer;var o;return void 0!==n&&e._backpressure&&"writable"===t&&Xn(n),hr(o=e._writableStreamController,Un,0),xn(o),r}function _n(e,t){"writable"!==e._state?wn(e):bn(e,t)}function bn(e,t){const r=e._writableStreamController;e._state="erroring",e._storedError=t;const n=e._writer;void 0!==n&&Rn(n,t),!function(e){return void 0!==e._inFlightWriteRequest||void 0!==e._inFlightCloseRequest}(e)&&r._started&&wn(e)}function wn(e){e._state="errored",e._writableStreamController[ft]();const t=e._storedError;if(e._writeRequests.forEach((e=>{e._reject(t)})),e._writeRequests=new dt,void 0===e._pendingAbortRequest)return void In(e);const r=e._pendingAbortRequest;if(e._pendingAbortRequest=void 0,r._wasAlreadyErroring)return r._reject(t),void In(e);nt(e._writableStreamController[ht](r._reason),(()=>(r._resolve(),In(e),null)),(t=>(r._reject(t),In(e),null)))}function Sn(e){return void 0!==e._closeRequest||void 0!==e._inFlightCloseRequest}function In(e){void 0!==e._closeRequest&&(e._closeRequest._reject(e._storedError),e._closeRequest=void 0);const t=e._writer;void 0!==t&&Kn(t,e._storedError)}function Tn(e,t){const r=e._writer;void 0!==r&&t!==e._backpressure&&(t?function(e){$n(e)}(r):Xn(r)),e._backpressure=t}Object.defineProperties(hn.prototype,{abort:{enumerable:!0},close:{enumerable:!0},getWriter:{enumerable:!0},locked:{enumerable:!0}}),Ke(hn.prototype.abort,"abort"),Ke(hn.prototype.close,"close"),Ke(hn.prototype.getWriter,"getWriter"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(hn.prototype,Symbol.toStringTag,{value:"WritableStream",configurable:!0});class En{constructor(e){if(At(e,1,"WritableStreamDefaultWriter"),ln(e,"First parameter"),yn(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)!Sn(e)&&e._backpressure?$n(this):Jn(this),zn(this);else if("erroring"===t)Qn(this,e._storedError),zn(this);else if("closed"===t)Jn(this),zn(this),Yn(this);else{const t=e._storedError;Qn(this,t),Gn(this,t)}}get closed(){return On(this)?this._closedPromise:tt(Hn("closed"))}get desiredSize(){if(!On(this))throw Hn("desiredSize");if(void 0===this._ownerWritableStream)throw Vn("desiredSize");return function(e){const t=e._ownerWritableStream,r=t._state;return"errored"===r||"erroring"===r?null:"closed"===r?0:qn(t._writableStreamController)}(this)}get ready(){return On(this)?this._readyPromise:tt(Hn("ready"))}abort(e=void 0){return On(this)?void 0===this._ownerWritableStream?tt(Vn("abort")):function(e,t){return gn(e._ownerWritableStream,t)}(this,e):tt(Hn("abort"))}close(){if(!On(this))return tt(Hn("close"));const e=this._ownerWritableStream;return void 0===e?tt(Vn("close")):Sn(e)?tt(new TypeError("Cannot close an already-closing stream")):Pn(this)}releaseLock(){if(!On(this))throw Hn("releaseLock");void 0!==this._ownerWritableStream&&Cn(this)}write(e=void 0){return On(this)?void 0===this._ownerWritableStream?tt(Vn("write to")):An(this,e):tt(Hn("write"))}}function On(e){return!!ze(e)&&!!Object.prototype.hasOwnProperty.call(e,"_ownerWritableStream")&&e instanceof En}function Pn(e){return mn(e._ownerWritableStream)}function Rn(e,t){"pending"===e._readyPromiseState?Zn(e,t):function(e,t){Qn(e,t)}(e,t)}function Cn(e){const t=e._ownerWritableStream,r=new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");Rn(e,r),function(e,t){"pending"===e._closedPromiseState?Kn(e,t):function(e,t){Gn(e,t)}(e,t)}(e,r),t._writer=void 0,e._ownerWritableStream=void 0}function An(e,t){const r=e._ownerWritableStream,n=r._writableStreamController,o=function(e,t){try{return e._strategySizeAlgorithm(t)}catch(t){return jn(e,t),1}}(n,t);if(r!==e._ownerWritableStream)return tt(Vn("write to"));const i=r._state;if("errored"===i)return tt(r._storedError);if(Sn(r)||"closed"===i)return tt(new TypeError("The stream is closing or closed and cannot be written to"));if("erroring"===i)return tt(r._storedError);const s=function(e){return Xe(((t,r)=>{const n={_resolve:t,_reject:r};e._writeRequests.push(n)}))}(r);return function(e,t,r){try{hr(e,t,r)}catch(t){return void jn(e,t)}const n=e._controlledWritableStream;Sn(n)||"writable"!==n._state||Tn(n,Mn(e)),xn(e)}(n,t,o),s}Object.defineProperties(En.prototype,{abort:{enumerable:!0},close:{enumerable:!0},releaseLock:{enumerable:!0},write:{enumerable:!0},closed:{enumerable:!0},desiredSize:{enumerable:!0},ready:{enumerable:!0}}),Ke(En.prototype.abort,"abort"),Ke(En.prototype.close,"close"),Ke(En.prototype.releaseLock,"releaseLock"),Ke(En.prototype.write,"write"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(En.prototype,Symbol.toStringTag,{value:"WritableStreamDefaultWriter",configurable:!0});const Un={};class kn{constructor(){throw new TypeError("Illegal constructor")}get abortReason(){if(!Ln(this))throw Fn("abortReason");return this._abortReason}get signal(){if(!Ln(this))throw Fn("signal");if(void 0===this._abortController)throw new TypeError("WritableStreamDefaultController.prototype.signal is not supported");return this._abortController.signal}error(e=void 0){if(!Ln(this))throw Fn("error");"writable"===this._controlledWritableStream._state&&Bn(this,e)}[ht](e){const t=this._abortAlgorithm(e);return Dn(this),t}[ft](){fr(this)}}function Ln(e){return!!ze(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledWritableStream")&&e instanceof kn}function Nn(e,t,r,n,o,i,s,a){t._controlledWritableStream=e,e._writableStreamController=t,t._queue=void 0,t._queueTotalSize=void 0,fr(t),t._abortReason=void 0,t._abortController=function(){if(dn)return new AbortController}(),t._started=!1,t._strategySizeAlgorithm=a,t._strategyHWM=s,t._writeAlgorithm=n,t._closeAlgorithm=o,t._abortAlgorithm=i;const u=Mn(t);Tn(e,u),nt(et(r()),(()=>(t._started=!0,xn(t),null)),(r=>(t._started=!0,_n(e,r),null)))}function Dn(e){e._writeAlgorithm=void 0,e._closeAlgorithm=void 0,e._abortAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function qn(e){return e._strategyHWM-e._queueTotalSize}function xn(e){const t=e._controlledWritableStream;if(!e._started)return;if(void 0!==t._inFlightWriteRequest)return;if("erroring"===t._state)return void wn(t);if(0===e._queue.length)return;const r=e._queue.peek().value;r===Un?function(e){const t=e._controlledWritableStream;(function(e){e._inFlightCloseRequest=e._closeRequest,e._closeRequest=void 0})(t),dr(e);const r=e._closeAlgorithm();Dn(e),nt(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&&Yn(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),_n(e,t)}(t,e),null)))}(e):function(e,t){const r=e._controlledWritableStream;!function(e){e._inFlightWriteRequest=e._writeRequests.shift()}(r),nt(e._writeAlgorithm(t),(()=>{!function(e){e._inFlightWriteRequest._resolve(void 0),e._inFlightWriteRequest=void 0}(r);const t=r._state;if(dr(e),!Sn(r)&&"writable"===t){const t=Mn(e);Tn(r,t)}return xn(e),null}),(t=>("writable"===r._state&&Dn(e),function(e,t){e._inFlightWriteRequest._reject(t),e._inFlightWriteRequest=void 0,_n(e,t)}(r,t),null)))}(e,r)}function jn(e,t){"writable"===e._controlledWritableStream._state&&Bn(e,t)}function Mn(e){return qn(e)<=0}function Bn(e,t){const r=e._controlledWritableStream;Dn(e),bn(r,t)}function Wn(e){return new TypeError(`WritableStream.prototype.${e} can only be used on a WritableStream`)}function Fn(e){return new TypeError(`WritableStreamDefaultController.prototype.${e} can only be used on a WritableStreamDefaultController`)}function Hn(e){return new TypeError(`WritableStreamDefaultWriter.prototype.${e} can only be used on a WritableStreamDefaultWriter`)}function Vn(e){return new TypeError("Cannot "+e+" a stream using a released writer")}function zn(e){e._closedPromise=Xe(((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r,e._closedPromiseState="pending"}))}function Gn(e,t){zn(e),Kn(e,t)}function Kn(e,t){void 0!==e._closedPromise_reject&&(at(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="rejected")}function Yn(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 $n(e){e._readyPromise=Xe(((t,r)=>{e._readyPromise_resolve=t,e._readyPromise_reject=r})),e._readyPromiseState="pending"}function Qn(e,t){$n(e),Zn(e,t)}function Jn(e){$n(e),Xn(e)}function Zn(e,t){void 0!==e._readyPromise_reject&&(at(e._readyPromise),e._readyPromise_reject(t),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="rejected")}function Xn(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(kn.prototype,{abortReason:{enumerable:!0},signal:{enumerable:!0},error:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(kn.prototype,Symbol.toStringTag,{value:"WritableStreamDefaultController",configurable:!0});const eo="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof global?global:void 0,to=function(){const e=null==eo?void 0:eo.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 Ke(e,"DOMException"),e.prototype=Object.create(Error.prototype),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,configurable:!0}),e}();function ro(e,t,r,n,o,i){const s=qt(e),a=fn(t);e._disturbed=!0;let u=!1,c=et(void 0);return Xe(((l,d)=>{let h;if(void 0!==i){if(h=()=>{const r=void 0!==i.reason?i.reason:new to("Aborted","AbortError"),s=[];n||s.push((()=>"writable"===t._state?gn(t,r):et(void 0))),o||s.push((()=>"readable"===e._state?Ro(e,r):et(void 0))),m((()=>Promise.all(s.map((e=>e())))),!0,r)},i.aborted)return void h();i.addEventListener("abort",h)}var f,p,v;if(g(e,s._closedPromise,(e=>(n?_(!0,e):m((()=>gn(t,e)),!0,e),null))),g(t,a._closedPromise,(t=>(o?_(!0,t):m((()=>Ro(e,t)),!0,t),null))),f=e,p=s._closedPromise,v=()=>(r?_():m((()=>function(e){const t=e._ownerWritableStream,r=t._state;return Sn(t)||"closed"===r?et(void 0):"errored"===r?tt(t._storedError):Pn(e)}(a))),null),"closed"===f._state?v():ot(p,v),Sn(t)||"closed"===t._state){const t=new TypeError("the destination writable stream closed before all data could be piped to it");o?_(!0,t):m((()=>Ro(e,t)),!0,t)}function y(){const e=c;return rt(c,(()=>e!==c?y():void 0))}function g(e,t,r){"errored"===e._state?r(e._storedError):it(t,r)}function m(e,r,n){function o(){return nt(e(),(()=>b(r,n)),(e=>b(!0,e))),null}u||(u=!0,"writable"!==t._state||Sn(t)?o():ot(y(),o))}function _(e,r){u||(u=!0,"writable"!==t._state||Sn(t)?b(e,r):ot(y(),(()=>b(e,r))))}function b(e,t){return Cn(a),_t(s),void 0!==i&&i.removeEventListener("abort",h),e?d(t):l(void 0),null}at(Xe(((e,t)=>{!function r(n){n?e():rt(u?et(!0):rt(a._readyPromise,(()=>Xe(((e,t)=>{Ht(s,{_chunkSteps:t=>{c=rt(An(a,t),void 0,Ve),e(!1)},_closeSteps:()=>e(!0),_errorSteps:t})})))),r,t)}(!1)})))}))}class no{constructor(){throw new TypeError("Illegal constructor")}get desiredSize(){if(!oo(this))throw vo("desiredSize");return ho(this)}close(){if(!oo(this))throw vo("close");if(!fo(this))throw new TypeError("The stream is not in a state that permits close");uo(this)}enqueue(e=void 0){if(!oo(this))throw vo("enqueue");if(!fo(this))throw new TypeError("The stream is not in a state that permits enqueue");return co(this,e)}error(e=void 0){if(!oo(this))throw vo("error");lo(this,e)}[pt](e){fr(this);const t=this._cancelAlgorithm(e);return ao(this),t}[vt](e){const t=this._controlledReadableStream;if(this._queue.length>0){const r=dr(this);this._closeRequested&&0===this._queue.length?(ao(this),Co(t)):io(this),e._chunkSteps(r)}else xt(t,e),io(this)}[yt](){}}function oo(e){return!!ze(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableStream")&&e instanceof no}function io(e){so(e)&&(e._pulling?e._pullAgain=!0:(e._pulling=!0,nt(e._pullAlgorithm(),(()=>(e._pulling=!1,e._pullAgain&&(e._pullAgain=!1,io(e)),null)),(t=>(lo(e,t),null)))))}function so(e){const t=e._controlledReadableStream;return!!fo(e)&&!!e._started&&(!!(Po(t)&&Mt(t)>0)||ho(e)>0)}function ao(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function uo(e){if(!fo(e))return;const t=e._controlledReadableStream;e._closeRequested=!0,0===e._queue.length&&(ao(e),Co(t))}function co(e,t){if(!fo(e))return;const r=e._controlledReadableStream;if(Po(r)&&Mt(r)>0)jt(r,t,!1);else{let r;try{r=e._strategySizeAlgorithm(t)}catch(t){throw lo(e,t),t}try{hr(e,t,r)}catch(t){throw lo(e,t),t}}io(e)}function lo(e,t){const r=e._controlledReadableStream;"readable"===r._state&&(fr(e),ao(e),Ao(r,t))}function ho(e){const t=e._controlledReadableStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function fo(e){const t=e._controlledReadableStream._state;return!e._closeRequested&&"readable"===t}function po(e,t,r,n,o,i,s){t._controlledReadableStream=e,t._queue=void 0,t._queueTotalSize=void 0,fr(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,nt(et(r()),(()=>(t._started=!0,io(t),null)),(e=>(lo(t,e),null)))}function vo(e){return new TypeError(`ReadableStreamDefaultController.prototype.${e} can only be used on a ReadableStreamDefaultController`)}function yo(e){return ze(t=e)&&void 0!==t.getReader?function(e){let t;return t=Io(Ve,(function(){let r;try{r=e.read()}catch(r){return tt(r)}return st(r,(e=>{if(!ze(e))throw new TypeError("The promise returned by the reader.read() method must fulfill with an object");if(e.done)uo(t._readableStreamController);else{const r=e.value;co(t._readableStreamController,r)}}))}),(function(t){try{return et(e.cancel(t))}catch(t){return tt(t)}}),0),t}(e.getReader()):function(e){let t;const r=nr(e,"async");return t=Io(Ve,(function(){let e;try{e=or(r)}catch(e){return tt(e)}return st(et(e),(e=>{if(!ze(e))throw new TypeError("The promise returned by the iterator.next() method must fulfill with an object");if(e.done)uo(t._readableStreamController);else{const r=e.value;co(t._readableStreamController,r)}}))}),(function(e){const t=r.iterator;let n;try{n=er(t,"return")}catch(e){return tt(e)}return void 0===n?et(void 0):st(lt(n,t,[e]),(e=>{if(!ze(e))throw new TypeError("The promise returned by the iterator.return() method must fulfill with an object")}))}),0),t}(e);var t}function go(e,t,r){return Rt(e,r),r=>lt(e,t,[r])}function mo(e,t,r){return Rt(e,r),r=>lt(e,t,[r])}function _o(e,t,r){return Rt(e,r),r=>ct(e,t,[r])}function bo(e,t){if("bytes"!=(e=`${e}`))throw new TypeError(`${t} '${e}' is not a valid enumeration value for ReadableStreamType`);return e}function wo(e,t){Pt(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(no.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},desiredSize:{enumerable:!0}}),Ke(no.prototype.close,"close"),Ke(no.prototype.enqueue,"enqueue"),Ke(no.prototype.error,"error"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(no.prototype,Symbol.toStringTag,{value:"ReadableStreamDefaultController",configurable:!0});class So{constructor(e={},t={}){void 0===e?e=null:Ct(e,"First parameter");const r=nn(t,"Second parameter"),n=function(e,t){Pt(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:Nt(n,`${t} has member 'autoAllocateChunkSize' that`),cancel:void 0===o?void 0:go(o,r,`${t} has member 'cancel' that`),pull:void 0===i?void 0:mo(i,r,`${t} has member 'pull' that`),start:void 0===s?void 0:_o(s,r,`${t} has member 'start' that`),type:void 0===a?void 0:bo(a,`${t} has member 'type' that`)}}(e,"First parameter");if(Eo(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(yr.prototype);let o,i,s;o=void 0!==t.start?()=>t.start(n):()=>{},i=void 0!==t.pull?()=>t.pull(n):()=>et(void 0),s=void 0!==t.cancel?e=>t.cancel(e):()=>et(void 0);const a=t.autoAllocateChunkSize;if(0===a)throw new TypeError("autoAllocateChunkSize must be greater than 0");Fr(e,n,o,i,s,r,a)}(this,n,tn(r,0))}else{const e=rn(r);!function(e,t,r,n){const o=Object.create(no.prototype);let i,s,a;i=void 0!==t.start?()=>t.start(o):()=>{},s=void 0!==t.pull?()=>t.pull(o):()=>et(void 0),a=void 0!==t.cancel?e=>t.cancel(e):()=>et(void 0),po(e,o,i,s,a,r,n)}(this,n,tn(r,1),e)}}get locked(){if(!Oo(this))throw Uo("locked");return Po(this)}cancel(e=void 0){return Oo(this)?Po(this)?tt(new TypeError("Cannot cancel a stream that already has a reader")):Ro(this,e):tt(Uo("cancel"))}getReader(e=void 0){if(!Oo(this))throw Uo("getReader");return void 0===function(e,t){Pt(e,t);const r=null==e?void 0:e.mode;return{mode:void 0===r?void 0:zr(r,`${t} has member 'mode' that`)}}(e,"First parameter").mode?qt(this):Gr(this)}pipeThrough(e,t={}){if(!Oo(this))throw Uo("pipeThrough");At(e,1,"pipeThrough");const r=function(e,t){Pt(e,t);const r=null==e?void 0:e.readable;Ut(r,"readable","ReadableWritablePair"),Dt(r,`${t} has member 'readable' that`);const n=null==e?void 0:e.writable;return Ut(n,"writable","ReadableWritablePair"),ln(n,`${t} has member 'writable' that`),{readable:r,writable:n}}(e,"First parameter"),n=wo(t,"Second parameter");if(Po(this))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream");if(yn(r.writable))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream");return at(ro(this,r.writable,n.preventClose,n.preventAbort,n.preventCancel,n.signal)),r.readable}pipeTo(e,t={}){if(!Oo(this))return tt(Uo("pipeTo"));if(void 0===e)return tt("Parameter 1 is required in 'pipeTo'.");if(!vn(e))return tt(new TypeError("ReadableStream.prototype.pipeTo's first argument must be a WritableStream"));let r;try{r=wo(t,"Second parameter")}catch(e){return tt(e)}return Po(this)?tt(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream")):yn(e)?tt(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream")):ro(this,e,r.preventClose,r.preventAbort,r.preventCancel,r.signal)}tee(){if(!Oo(this))throw Uo("tee");return $t(function(e){return gr(e._readableStreamController)?function(e){let t,r,n,o,i,s=qt(e),a=!1,u=!1,c=!1,l=!1,d=!1;const h=Xe((e=>{i=e}));function f(e){it(e._closedPromise,(t=>(e!==s||(qr(n._readableStreamController,t),qr(o._readableStreamController,t),l&&d||i(void 0)),null)))}function p(){Jr(s)&&(_t(s),s=qt(e),f(s)),Ht(s,{_chunkSteps:t=>{ut((()=>{u=!1,c=!1;const r=t;let s=t;if(!l&&!d)try{s=lr(t)}catch(t){return qr(n._readableStreamController,t),qr(o._readableStreamController,t),void i(Ro(e,t))}l||Dr(n._readableStreamController,r),d||Dr(o._readableStreamController,s),a=!1,u?y():c&&g()}))},_closeSteps:()=>{a=!1,l||Nr(n._readableStreamController),d||Nr(o._readableStreamController),n._readableStreamController._pendingPullIntos.length>0&&Br(n._readableStreamController,0),o._readableStreamController._pendingPullIntos.length>0&&Br(o._readableStreamController,0),l&&d||i(void 0)},_errorSteps:()=>{a=!1}})}function v(t,r){Ft(s)&&(_t(s),s=Gr(e),f(s));const h=r?o:n,p=r?n:o;Zr(s,t,1,{_chunkSteps:t=>{ut((()=>{u=!1,c=!1;const n=r?d:l;if(r?l:d)n||Wr(h._readableStreamController,t);else{let r;try{r=lr(t)}catch(t){return qr(h._readableStreamController,t),qr(p._readableStreamController,t),void i(Ro(e,t))}n||Wr(h._readableStreamController,t),Dr(p._readableStreamController,r)}a=!1,u?y():c&&g()}))},_closeSteps:e=>{a=!1;const t=r?d:l,n=r?l:d;t||Nr(h._readableStreamController),n||Nr(p._readableStreamController),void 0!==e&&(t||Wr(h._readableStreamController,e),!n&&p._readableStreamController._pendingPullIntos.length>0&&Br(p._readableStreamController,0)),t&&n||i(void 0)},_errorSteps:()=>{a=!1}})}function y(){if(a)return u=!0,et(void 0);a=!0;const e=jr(n._readableStreamController);return null===e?p():v(e._view,!1),et(void 0)}function g(){if(a)return c=!0,et(void 0);a=!0;const e=jr(o._readableStreamController);return null===e?p():v(e._view,!0),et(void 0)}function m(){}return n=To(m,y,(function(n){if(l=!0,t=n,d){const n=$t([t,r]),o=Ro(e,n);i(o)}return h})),o=To(m,g,(function(n){if(d=!0,r=n,l){const n=$t([t,r]),o=Ro(e,n);i(o)}return h})),f(s),[n,o]}(e):function(e){const t=qt(e);let r,n,o,i,s,a=!1,u=!1,c=!1,l=!1;const d=Xe((e=>{s=e}));function h(){return a?(u=!0,et(void 0)):(a=!0,Ht(t,{_chunkSteps:e=>{ut((()=>{u=!1;const t=e,r=e;c||co(o._readableStreamController,t),l||co(i._readableStreamController,r),a=!1,u&&h()}))},_closeSteps:()=>{a=!1,c||uo(o._readableStreamController),l||uo(i._readableStreamController),c&&l||s(void 0)},_errorSteps:()=>{a=!1}}),et(void 0))}function f(){}return o=Io(f,h,(function(t){if(c=!0,r=t,l){const t=$t([r,n]),o=Ro(e,t);s(o)}return d})),i=Io(f,h,(function(t){if(l=!0,n=t,c){const t=$t([r,n]),o=Ro(e,t);s(o)}return d})),it(t._closedPromise,(e=>(lo(o._readableStreamController,e),lo(i._readableStreamController,e),c&&l||s(void 0),null))),[o,i]}(e)}(this))}values(e=void 0){if(!Oo(this))throw Uo("values");return function(e,t){const r=qt(e),n=new ir(r,t),o=Object.create(sr);return o._asyncIteratorImpl=n,o}(this,function(e){Pt(e,"First parameter");const t=null==e?void 0:e.preventCancel;return{preventCancel:Boolean(t)}}(e).preventCancel)}[rr](e){return this.values(e)}static from(e){return yo(e)}}function Io(e,t,r,n=1,o=()=>1){const i=Object.create(So.prototype);return Eo(i),po(i,Object.create(no.prototype),e,t,r,n,o),i}function To(e,t,r){const n=Object.create(So.prototype);return Eo(n),Fr(n,Object.create(yr.prototype),e,t,r,0,void 0),n}function Eo(e){e._state="readable",e._reader=void 0,e._storedError=void 0,e._disturbed=!1}function Oo(e){return!!ze(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readableStreamController")&&e instanceof So}function Po(e){return void 0!==e._reader}function Ro(e,t){if(e._disturbed=!0,"closed"===e._state)return et(void 0);if("errored"===e._state)return tt(e._storedError);Co(e);const r=e._reader;if(void 0!==r&&Jr(r)){const e=r._readIntoRequests;r._readIntoRequests=new dt,e.forEach((e=>{e._closeSteps(void 0)}))}return st(e._readableStreamController[pt](t),Ve)}function Co(e){e._state="closed";const t=e._reader;if(void 0!==t&&(Tt(t),Ft(t))){const e=t._readRequests;t._readRequests=new dt,e.forEach((e=>{e._closeSteps()}))}}function Ao(e,t){e._state="errored",e._storedError=t;const r=e._reader;void 0!==r&&(It(r,t),Ft(r)?Vt(r,t):Xr(r,t))}function Uo(e){return new TypeError(`ReadableStream.prototype.${e} can only be used on a ReadableStream`)}function ko(e,t){Pt(e,t);const r=null==e?void 0:e.highWaterMark;return Ut(r,"highWaterMark","QueuingStrategyInit"),{highWaterMark:kt(r)}}Object.defineProperties(So,{from:{enumerable:!0}}),Object.defineProperties(So.prototype,{cancel:{enumerable:!0},getReader:{enumerable:!0},pipeThrough:{enumerable:!0},pipeTo:{enumerable:!0},tee:{enumerable:!0},values:{enumerable:!0},locked:{enumerable:!0}}),Ke(So.from,"from"),Ke(So.prototype.cancel,"cancel"),Ke(So.prototype.getReader,"getReader"),Ke(So.prototype.pipeThrough,"pipeThrough"),Ke(So.prototype.pipeTo,"pipeTo"),Ke(So.prototype.tee,"tee"),Ke(So.prototype.values,"values"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(So.prototype,Symbol.toStringTag,{value:"ReadableStream",configurable:!0}),Object.defineProperty(So.prototype,rr,{value:So.prototype.values,writable:!0,configurable:!0});const Lo=e=>e.byteLength;Ke(Lo,"size");class No{constructor(e){At(e,1,"ByteLengthQueuingStrategy"),e=ko(e,"First parameter"),this._byteLengthQueuingStrategyHighWaterMark=e.highWaterMark}get highWaterMark(){if(!qo(this))throw Do("highWaterMark");return this._byteLengthQueuingStrategyHighWaterMark}get size(){if(!qo(this))throw Do("size");return Lo}}function Do(e){return new TypeError(`ByteLengthQueuingStrategy.prototype.${e} can only be used on a ByteLengthQueuingStrategy`)}function qo(e){return!!ze(e)&&!!Object.prototype.hasOwnProperty.call(e,"_byteLengthQueuingStrategyHighWaterMark")&&e instanceof No}Object.defineProperties(No.prototype,{highWaterMark:{enumerable:!0},size:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(No.prototype,Symbol.toStringTag,{value:"ByteLengthQueuingStrategy",configurable:!0});const xo=()=>1;Ke(xo,"size");class jo{constructor(e){At(e,1,"CountQueuingStrategy"),e=ko(e,"First parameter"),this._countQueuingStrategyHighWaterMark=e.highWaterMark}get highWaterMark(){if(!Bo(this))throw Mo("highWaterMark");return this._countQueuingStrategyHighWaterMark}get size(){if(!Bo(this))throw Mo("size");return xo}}function Mo(e){return new TypeError(`CountQueuingStrategy.prototype.${e} can only be used on a CountQueuingStrategy`)}function Bo(e){return!!ze(e)&&!!Object.prototype.hasOwnProperty.call(e,"_countQueuingStrategyHighWaterMark")&&e instanceof jo}function Wo(e,t,r){return Rt(e,r),r=>lt(e,t,[r])}function Fo(e,t,r){return Rt(e,r),r=>ct(e,t,[r])}function Ho(e,t,r){return Rt(e,r),(r,n)=>lt(e,t,[r,n])}function Vo(e,t,r){return Rt(e,r),r=>lt(e,t,[r])}Object.defineProperties(jo.prototype,{highWaterMark:{enumerable:!0},size:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(jo.prototype,Symbol.toStringTag,{value:"CountQueuingStrategy",configurable:!0});class zo{constructor(e={},t={},r={}){void 0===e&&(e=null);const n=nn(t,"Second parameter"),o=nn(r,"Third parameter"),i=function(e,t){Pt(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:Vo(r,e,`${t} has member 'cancel' that`),flush:void 0===n?void 0:Wo(n,e,`${t} has member 'flush' that`),readableType:o,start:void 0===i?void 0:Fo(i,e,`${t} has member 'start' that`),transform:void 0===s?void 0:Ho(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=tn(o,0),a=rn(o),u=tn(n,1),c=rn(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(hn.prototype);return pn(s),Nn(s,Object.create(kn.prototype),e,t,r,n,o,i),s}(s,(function(t){return function(e,t){const r=e._transformStreamController;return e._backpressure?st(e._backpressureChangePromise,(()=>{const n=e._writable;if("erroring"===n._state)throw n._storedError;return ti(r,t)})):ti(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=Xe(((e,r)=>{t._finishPromise_resolve=e,t._finishPromise_reject=r}));const n=t._flushAlgorithm();return Xo(t),nt(n,(()=>("errored"===r._state?oi(t,r._storedError):(uo(r._readableStreamController),ni(t)),null)),(e=>(lo(r._readableStreamController,e),oi(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=Xe(((e,t)=>{r._finishPromise_resolve=e,r._finishPromise_reject=t}));const o=r._cancelAlgorithm(t);return Xo(r),nt(o,(()=>("errored"===n._state?oi(r,n._storedError):(lo(n._readableStreamController,t),ni(r)),null)),(e=>(lo(n._readableStreamController,e),oi(r,e),null))),r._finishPromise}(e,t)}),r,n),e._readable=Io(s,(function(){return function(e){return Qo(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=Xe(((e,t)=>{r._finishPromise_resolve=e,r._finishPromise_reject=t}));const o=r._cancelAlgorithm(t);return Xo(r),nt(o,(()=>("errored"===n._state?oi(r,n._storedError):(jn(n._writableStreamController,t),$o(e),ni(r)),null)),(t=>(jn(n._writableStreamController,t),$o(e),oi(r,t),null))),r._finishPromise}(e,t)}),o,i),e._backpressure=void 0,e._backpressureChangePromise=void 0,e._backpressureChangePromise_resolve=void 0,Qo(e,!0),e._transformStreamController=void 0}(this,Xe((e=>{l=e})),u,c,s,a),function(e,t){const r=Object.create(Jo.prototype);let n,o,i;n=void 0!==t.transform?e=>t.transform(e,r):e=>{try{return ei(r,e),et(void 0)}catch(e){return tt(e)}},o=void 0!==t.flush?()=>t.flush(r):()=>et(void 0),i=void 0!==t.cancel?e=>t.cancel(e):()=>et(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(!Go(this))throw ii("readable");return this._readable}get writable(){if(!Go(this))throw ii("writable");return this._writable}}function Go(e){return!!ze(e)&&!!Object.prototype.hasOwnProperty.call(e,"_transformStreamController")&&e instanceof zo}function Ko(e,t){lo(e._readable._readableStreamController,t),Yo(e,t)}function Yo(e,t){Xo(e._transformStreamController),jn(e._writable._writableStreamController,t),$o(e)}function $o(e){e._backpressure&&Qo(e,!1)}function Qo(e,t){void 0!==e._backpressureChangePromise&&e._backpressureChangePromise_resolve(),e._backpressureChangePromise=Xe((t=>{e._backpressureChangePromise_resolve=t})),e._backpressure=t}Object.defineProperties(zo.prototype,{readable:{enumerable:!0},writable:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(zo.prototype,Symbol.toStringTag,{value:"TransformStream",configurable:!0});class Jo{constructor(){throw new TypeError("Illegal constructor")}get desiredSize(){if(!Zo(this))throw ri("desiredSize");return ho(this._controlledTransformStream._readable._readableStreamController)}enqueue(e=void 0){if(!Zo(this))throw ri("enqueue");ei(this,e)}error(e=void 0){if(!Zo(this))throw ri("error");var t;t=e,Ko(this._controlledTransformStream,t)}terminate(){if(!Zo(this))throw ri("terminate");!function(e){const t=e._controlledTransformStream;uo(t._readable._readableStreamController),Yo(t,new TypeError("TransformStream terminated"))}(this)}}function Zo(e){return!!ze(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledTransformStream")&&e instanceof Jo}function Xo(e){e._transformAlgorithm=void 0,e._flushAlgorithm=void 0,e._cancelAlgorithm=void 0}function ei(e,t){const r=e._controlledTransformStream,n=r._readable._readableStreamController;if(!fo(n))throw new TypeError("Readable side is not in a state that permits enqueue");try{co(n,t)}catch(e){throw Yo(r,e),r._readable._storedError}const o=function(e){return!so(e)}(n);o!==r._backpressure&&Qo(r,!0)}function ti(e,t){return st(e._transformAlgorithm(t),void 0,(t=>{throw Ko(e._controlledTransformStream,t),t}))}function ri(e){return new TypeError(`TransformStreamDefaultController.prototype.${e} can only be used on a TransformStreamDefaultController`)}function ni(e){void 0!==e._finishPromise_resolve&&(e._finishPromise_resolve(),e._finishPromise_resolve=void 0,e._finishPromise_reject=void 0)}function oi(e,t){void 0!==e._finishPromise_reject&&(at(e._finishPromise),e._finishPromise_reject(t),e._finishPromise_resolve=void 0,e._finishPromise_reject=void 0)}function ii(e){return new TypeError(`TransformStream.prototype.${e} can only be used on a TransformStream`)}Object.defineProperties(Jo.prototype,{enqueue:{enumerable:!0},error:{enumerable:!0},terminate:{enumerable:!0},desiredSize:{enumerable:!0}}),Ke(Jo.prototype.enqueue,"enqueue"),Ke(Jo.prototype.error,"error"),Ke(Jo.prototype.terminate,"terminate"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Jo.prototype,Symbol.toStringTag,{value:"TransformStreamDefaultController",configurable:!0});var si=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)t.hasOwnProperty(r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),ai=function(){return ai=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},ai.apply(this,arguments)},ui="Error when aborting requestTask",ci=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 si(t,e),t.prototype.post=function(e){var t=this;return new Promise((function(r,n){var o=e.url,i=e.data,s=e.headers,a=wx.request({url:(0,A.formatUrl)("https:",o),data:i,timeout:t._timeout,method:"POST",header:s,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{a.abort()}catch(e){}}}})}))},t.prototype.get=function(e){var t=this;return new Promise((function(r,n){var o=e.url,i=e.body,s=e.headers,a=(0,A.formatUrl)("https:",o),u=wx.request({url:a,data:i,timeout:t._timeout,method:"GET",header:s,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{u.abort()}catch(e){console.warn(ui,e)}}}})}))},t.prototype.upload=function(e){var t=this,r=this;return new Promise((function(n){return 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())}))}(t,void 0,void 0,(function(){var t,o,i,s,a,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(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(c){return t=e.url,o=e.file,i=e.data,s=e.headers,a=e.onUploadProgress,u=wx.uploadFile({url:t,filePath:o,name:"file",formData:ai({},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{u.abort()}catch(e){}}}}),a&&u.onProgressUpdate((function(e){a(e)})),[2]}))}))}))},t.prototype.download=function(e){var t=this,r=this;return new Promise((function(n,o){var i=e.url,s=e.headers,a=wx.downloadFile({url:(0,A.formatUrl)("https:",i),header:s,timeout:t._timeout,success:function(e){200===e.statusCode&&e.tempFilePath?n({statusCode:200,tempFilePath:e.tempFilePath}):n(e)},fail:function(e){o(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{a.abort()}catch(e){}}}})}))},t.prototype.fetch=function(e){var t=e.url,r=e.body,n=e.enableAbort,o=e.headers,i=e.method,s=e.stream,a=void 0!==s&&s,u=e.signal,c=e.timeout,l=this,d=null!=c?c:this._timeout,h=null,f=new So({start:function(e){h=e},cancel:function(){h=null}});return new Promise((function(e,s){a&&e({data:f});var c=wx.request({url:(0,A.formatUrl)("https:",t),data:r,timeout:d,method:i.toUpperCase(),header:o,success:function(t){var r;null===(r=h)||void 0===r||r.close(),!a&&e(t)},fail:function(e){var t;if(null===(t=h)||void 0===t||t.close(),s(e),a)throw e},complete:function(e){if(e&&e.errMsg&&d&&-1!==l._restrictedMethods.indexOf("post")&&n&&"request:fail timeout"===e.errMsg){console.warn(l._timeoutMsg);try{c.abort()}catch(e){console.warn(ui,e)}}},enableChunked:a});if(c.onChunkReceived((function(e){var t;null===(t=h)||void 0===t||t.enqueue(new Uint8Array(e.data))})),u){var p=function(){try{c.abort()}catch(e){console.warn(ui,e)}};u.aborted?p():u.addEventListener("abort",(function(){return p()}))}}))},t}(A.AbstractSDKRequest),li={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()}},di=function(e,t){void 0===t&&(t={});var r=wx.connectSocket(ai({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}};const hi=function(e){return{root:{globalThis:{}},reqClass:ci,wsClass:di,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=function(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}(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: "+t}):a?new Promise((function(e){console.log("wait for captcha..."),r.$emit("CAPTCHA_DATA_CHANGE",ai(ai({},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:li,primaryStorage:A.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:""}}},fi=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};var pi=r(182),vi=function(){return vi=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},vi.apply(this,arguments)},yi=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())}))},gi=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])}}},mi=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 yi(this,void 0,void 0,(function(){return gi(this,(function(t){return[2,this.localStorage.getItem(e)]}))}))},e.prototype.removeItem=function(e){return yi(this,void 0,void 0,(function(){return gi(this,(function(t){return this.localStorage.removeItem(e),[2]}))}))},e.prototype.setItem=function(e,t){return yi(this,void 0,void 0,(function(){return gi(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}(),_i=/^[^:]+:\/\/[^/]+(\/[^?#]+)/,bi=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,_i.test(i)?RegExp.$1:i),e):(null==e?void 0:e.data)||{}},wi=function(e){return e.adapter&&"default"!==e.adapter.type?function(e,t){var r=vi({},e);try{if(!(null==e?void 0:e.storage)&&(null==t?void 0:t.localStorage)&&(r.storage=new mi({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=new t.reqClass({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});r.baseRequest=function(e,t){var r,o,i,s,a;return yi(this,void 0,void 0,(function(){var u,c,l,d;return gi(this,(function(h){switch(h.label){case 0:if(u={},c=(null===(r=t.method)||void 0===r?void 0:r.toLocaleLowerCase())||"post","function"!=typeof(l=null===(i=null===(o=null==n?void 0:n[c])||void 0===o?void 0:o.bind)||void 0===i?void 0:i.call(o,n)))throw new Error("invalid 【".concat(c,"】 request method"));h.label=1;case 1:return h.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(vi({url:e},t))];case 2:return u=h.sent(),u=bi(u,vi(vi({},t),{url:e})),[3,4];case 3:throw d=h.sent(),u=d,d;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=vi({},e),n={};if((null==t?void 0:t.captchaOptions)&&(r.captchaOptions=t.captchaOptions),!fi()||e.storage&&e.baseRequest)return r;try{var o=hi({}),i=o.localStorage,s=o.reqClass;if(i&&(n.storage=new mi({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 yi(this,void 0,void 0,(function(){return gi(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=bi(e,vi(vi({},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),vi(vi({},r),n)}catch(e){console.error("adapter generate fail:",e)}return r}(e,e.adapter)},Si=function(){return Si=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},Si.apply(this,arguments)},Ii=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())}))},Ti=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])}}},Ei=function(){return"undefined"!=typeof window&&"undefined"!=typeof document},Oi=function(){function e(e){this.listeners=new Map,this.hasListenerSetUp=!1,this.config=e,this.oauthInstance=e.oauthInstance,this.cache=e.cache,this.init()}return Object.defineProperty(e.prototype,"currentUser",{get:function(){var e=this.hasLoginState();return e&&e.user||null},enumerable:!1,configurable:!0}),e.prototype.hasLoginState=function(){throw new Error("Auth.hasLoginState() is not implemented")},e.prototype.setAccessKey=function(){return Ii(this,void 0,void 0,(function(){return Ti(this,(function(e){throw new Error("Auth.setAccessKey() is not implemented")}))}))},e.prototype.signIn=function(e){return Ii(this,void 0,void 0,(function(){return Ti(this,(function(e){throw new Error("Auth.signIn() is not implemented")}))}))},e.prototype.signInWithProvider=function(e){return Ii(this,void 0,void 0,(function(){return Ti(this,(function(e){throw new Error("Auth.signInWithProvider() is not implemented")}))}))},e.prototype.genProviderRedirectUri=function(e){return Ii(this,void 0,void 0,(function(){return Ti(this,(function(e){throw new Error("Auth.genProviderRedirectUri() is not implemented")}))}))},e.prototype.getAccessToken=function(){return Ii(this,void 0,void 0,(function(){return Ti(this,(function(e){throw new Error("Auth.getAccessToken() is not implemented")}))}))},e.prototype.getUserInfo=function(){return Ii(this,void 0,void 0,(function(){return Ti(this,(function(e){throw new Error("Auth.getUserInfo() is not implemented")}))}))},e.prototype.updateUserBasicInfo=function(e){return Ii(this,void 0,void 0,(function(){return Ti(this,(function(e){throw new Error("Auth.updateUserBasicInfo() is not implemented")}))}))},e.prototype.setCustomSignFunc=function(e){throw new Error("Auth.setCustomSignFunc() is not implemented")},e.prototype.grantProviderToken=function(e){return Ii(this,void 0,void 0,(function(){return Ti(this,(function(e){throw new Error("Auth.grantProviderToken() is not implemented")}))}))},e.prototype.bindWithProvider=function(e){return Ii(this,void 0,void 0,(function(){return Ti(this,(function(e){throw new Error("Auth.bindWithProvider() is not implemented")}))}))},e.prototype.signInWithUsername=function(e){return Ii(this,void 0,void 0,(function(){return Ti(this,(function(e){throw new Error("Auth.signInWithUsername() is not implemented")}))}))},e.prototype.getVerification=function(e,t){return Ii(this,void 0,void 0,(function(){return Ti(this,(function(e){throw new Error("Auth.getVerification() is not implemented")}))}))},e.prototype.createLoginState=function(e,t){return Ii(this,void 0,void 0,(function(){return Ti(this,(function(e){throw new Error("Auth.createLoginState() is not implemented")}))}))},e.prototype.verify=function(e){return Ii(this,void 0,void 0,(function(){return Ti(this,(function(e){throw new Error("Auth.verify() is not implemented")}))}))},e.prototype.signInAnonymously=function(e){return Ii(this,void 0,void 0,(function(){var t,r,n,o;return Ti(this,(function(i){switch(i.label){case 0:return i.trys.push([0,4,,5]),[4,this.oauthInstance.authApi.signInAnonymously(e)];case 1:return i.sent(),[4,this.createLoginState()];case 2:return t=i.sent(),[4,this.getSession()];case 3:return r=i.sent().data,n=(void 0===r?{}:r).session,[2,Si(Si({},t),{data:{user:n.user,session:n},error:null})];case 4:return o=i.sent(),[2,{data:{},error:new qe(o)}];case 5:return[2]}}))}))},e.prototype.signUp=function(e){return Ii(this,void 0,void 0,(function(){var t,r,n=this;return Ti(this,(function(o){switch(o.label){case 0:return e.phone_number||e.verification_code||e.verification_token||e.provider_token?[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 Ii(n,void 0,void 0,(function(){var r,n,i,a,u;return Ti(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(Si(Si(Si({},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 qe(u)}];case 9:return[2]}}))}))}},error:null}];case 4:return r=o.sent(),[2,{data:{},error:new qe(r)}];case 5:return[2]}}))}))},e.prototype.signOut=function(e){return Ii(this,void 0,void 0,(function(){var t,r,n;return Ti(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),t=this.cache.keys.userInfoKey,[4,this.oauthInstance.authApi.signOut(e)];case 1:return r=o.sent(),[4,this.cache.removeStoreAsync(t)];case 2:return o.sent(),this.setAccessKey(),Li.fire(h.LOGIN_STATE_CHANGED,{eventType:"sign_out"}),Li.fire(h.AUTH_STATE_CHANGED,{event:d.SIGNED_OUT}),[2,Si(Si({},r),{data:{},error:null})];case 3:return n=o.sent(),[2,{data:{},error:new qe(n)}];case 4:return[2]}}))}))},e.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))}}}}},e.prototype.signInWithPassword=function(e){return Ii(this,void 0,void 0,(function(){var t,r,n;return Ti(this,(function(o){switch(o.label){case 0:return o.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(Si({username:e.username||e.email||this.formatPhone(e.phone),password:e.password},e.is_encrypt?{isEncrypt:!0,version:"v2"}:{}))];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 qe(n)}];case 4:return[2]}}))}))},e.prototype.signInWithIdToken=function(e){return Ii(this,void 0,void 0,(function(){var t,r,n;return Ti(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 qe(n)}];case 4:return[2]}}))}))},e.prototype.signInWithOtp=function(e){return Ii(this,void 0,void 0,(function(){var t,r,n=this;return Ti(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"),[4,this.getVerification(e.email?{email:e.email}:{phone_number:this.formatPhone(e.phone)})];case 1:return t=o.sent(),[2,{data:{user:null,session:null,verifyOtp:function(r){var o=r.token,i=r.messageId,s=void 0===i?t.verification_id:i;return Ii(n,void 0,void 0,(function(){return Ti(this,(function(t){return[2,this.verifyOtp({email:e.email,phone:e.phone,token:o,messageId:s})]}))}))}},error:null}];case 2:return r=o.sent(),[2,{data:{},error:new qe(r)}];case 3:return[2]}}))}))},e.prototype.verifyOAuth=function(e){return Ii(this,void 0,void 0,(function(){var t,r,n,o,i,s,a,u,c;return Ti(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)||U("code"),n=(null==e?void 0:e.state)||U("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)||U("provider"))?[4,this.grantProviderToken({provider_id:i,provider_redirect_uri:location.origin+location.pathname,provider_code:r})]:[2,{data:t,error:new qe({message:"Provider is required"})}]):[2,{data:{},error:new qe({message:"State is required"})}]:[2,{data:{},error:new qe({message:"Code is required"})}];case 2:return s=l.sent().provider_token,a=void 0,o.type!==f.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=Si(Si({},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"),function(e,t){if(void 0!==e){var r=new URL(window.location.href);r.search=e,r.hash=t||r.hash,window.history.replaceState({},"",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 qe(c)}];case 8:return[2]}}))}))},e.prototype.signInWithOAuth=function(e){var t,r,n,o,i;return Ii(this,void 0,void 0,(function(){var s,a,u,c,l,d,h,p,v;return Ti(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,d=decodeURIComponent(l),h=d,(null===(n=e.options)||void 0===n?void 0:n.queryParams)&&(p=new URL(d),Object.entries(e.options.queryParams).forEach((function(e){var t=e[0],r=e[1];p.searchParams.set(t,r)})),h=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)||f.SIGN_IN}),Ei()&&!(null===(i=e.options)||void 0===i?void 0:i.skipBrowserRedirect)&&window.location.assign(h),[2,{data:{url:h,provider:e.provider},error:null}];case 2:return v=y.sent(),[2,{data:{},error:new qe(v)}];case 3:return[2]}}))}))},e.prototype.signInWithSSO=function(){return Ii(this,void 0,void 0,(function(){return Ti(this,(function(e){return[2]}))}))},e.prototype.signInWithWeb3=function(){return Ii(this,void 0,void 0,(function(){return Ti(this,(function(e){return[2]}))}))},e.prototype.getClaims=function(){return Ii(this,void 0,void 0,(function(){var e,t,r;return Ti(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getAccessToken()];case 1:return e=n.sent().accessToken,t=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(S(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 S(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)}}(e),[2,{data:t,error:null}];case 2:return r=n.sent(),[2,{data:{},error:new qe(r)}];case 3:return[2]}}))}))},e.prototype.resetPasswordForEmail=function(e,t){return Ii(this,void 0,void 0,(function(){var r,n,o,i,s,a,u=this;return Ti(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 Ii(u,void 0,void 0,(function(){var o,i,a;return Ti(this,(function(u){switch(u.label){case 0:this.validateParams(t,{nonce:{required:!0,message:"Nonce is required"},password:{required:!0,message:"Password is required"}}),u.label=1;case 1:return u.trys.push([1,5,,6]),[4,this.verify({verification_id:s.verification_id,verification_code:t.nonce})];case 2:return o=u.sent(),[4,this.oauthInstance.authApi.resetPassword({email:n?e:void 0,phone:n?void 0:e,new_password:t.password,verification_token:o.verification_token})];case 3:return u.sent(),Li.fire(h.AUTH_STATE_CHANGED,{event:d.PASSWORD_RECOVERY}),[4,this.signInWithPassword({email:n?e:void 0,phone:n?void 0:e,password:t.password})];case 4:return i=u.sent(),r&&Ei()&&window.location.assign(r),[2,i];case 5:return a=u.sent(),[2,{data:{},error:new qe(a)}];case 6:return[2]}}))}))}},error:null}];case 2:return a=c.sent(),[2,{data:{},error:new qe(a)}];case 3:return[2]}}))}))},e.prototype.resetPasswordForOld=function(e){return Ii(this,void 0,void 0,(function(){var t,r,n;return Ti(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 qe(n)}];case 4:return[2]}}))}))},e.prototype.verifyOtp=function(e){return Ii(this,void 0,void 0,(function(){var t,r,n,o;return Ti(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 qe(o)}];case 7:return[2]}}))}))},e.prototype.getSession=function(){return Ii(this,void 0,void 0,(function(){var e,t,r,n;return Ti(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:Si(Si({},e),{user:r})},error:null}];case 3:return n=o.sent(),[2,{data:{},error:new qe(n)}];case 4:return[2]}}))}))},e.prototype.refreshSession=function(e){return Ii(this,void 0,void 0,(function(){var t,r,n,o,i;return Ti(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:Si(Si({},r),{user:o})},error:null}];case 4:return i=s.sent(),[2,{data:{},error:new qe(i)}];case 5:return[2]}}))}))},e.prototype.getUser=function(){return Ii(this,void 0,void 0,(function(){var e,t;return Ti(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),e=this.convertToUser,[4,this.getUserInfo()];case 1:return[2,{data:{user:e.apply(this,[r.sent()])},error:null}];case 2:return t=r.sent(),[2,{data:{},error:new qe(t)}];case 3:return[2]}}))}))},e.prototype.refreshUser=function(){return Ii(this,void 0,void 0,(function(){var e,t,r;return Ti(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 qe(r)}];case 4:return[2]}}))}))},e.prototype.updateUser=function(e){return Ii(this,void 0,void 0,(function(){var t,r,n,o,i,s,a,u,c,l,f,p,v=this;return Ti(this,(function(y){switch(y.label){case 0:if(y.trys.push([0,8,,9]),!Object.keys(e).some((function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]})))throw new qe({message:"At least one field must be provided for update"});return t=e.email,r=e.phone,n=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"]),i=void 0!==r,s={},(o=void 0!==t)||i?(a=void 0,o?(a={email:e.email},u="email_change"):(c=this.formatPhone(e.phone),a={phone_number:c},u="phone_change"),[4,this.getVerification(a)]):[3,4];case 1:return l=y.sent(),Object.keys(n).length>0?[4,this.updateUserBasicInfo(n)]:[3,3];case 2:y.sent(),y.label=3;case 3:return s={messageId:l.verification_id,verifyOtp:function(t){return Ii(v,void 0,void 0,(function(){var r,n;return Ti(this,(function(i){switch(i.label){case 0:return i.trys.push([0,11,,12]),t.email&&e.email===t.email?[4,this.verifyOtp({type:"email_change",email:e.email,token:t.token,messageId:l.verification_id})]:[3,3];case 1:return i.sent(),[4,this.updateUserBasicInfo({email:e.email})];case 2:return i.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:l.verification_id})]:[3,6];case 4:return i.sent(),[4,this.updateUserBasicInfo({phone:this.formatPhone(e.phone)})];case 5:return i.sent(),[3,9];case 6:return[4,this.verifyOtp({type:u,email:o?e.email:void 0,phone:o?void 0:e.phone,token:t.token,messageId:l.verification_id})];case 7:return i.sent(),[4,this.updateUserBasicInfo(e)];case 8:i.sent(),i.label=9;case 9:return[4,this.getUser()];case 10:return r=i.sent().data.user,Li.fire(h.AUTH_STATE_CHANGED,{event:d.USER_UPDATED}),[2,{data:{user:r},error:null}];case 11:return n=i.sent(),[2,{data:{},error:new qe(n)}];case 12:return[2]}}))}))}},[3,6];case 4:return[4,this.updateUserBasicInfo(e)];case 5:y.sent(),y.label=6;case 6:return[4,this.getUser()];case 7:return f=y.sent().data.user,Li.fire(h.AUTH_STATE_CHANGED,{event:d.USER_UPDATED}),[2,{data:Si({user:f},s),error:null}];case 8:return p=y.sent(),[2,{data:{},error:new qe(p)}];case 9:return[2]}}))}))},e.prototype.getUserIdentities=function(){var e;return Ii(this,void 0,void 0,(function(){var t,r;return Ti(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 qe(r)}];case 3:return[2]}}))}))},e.prototype.linkIdentity=function(e){return Ii(this,void 0,void 0,(function(){var t;return Ti(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:f.BIND_IDENTITY}})];case 1:return r.sent(),[2,{data:{provider:e.provider},error:null}];case 2:return t=r.sent(),[2,{data:{},error:new qe(t)}];case 3:return[2]}}))}))},e.prototype.unlinkIdentity=function(e){return Ii(this,void 0,void 0,(function(){var t;return Ti(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 qe(t)}];case 3:return[2]}}))}))},e.prototype.reauthenticate=function(){return Ii(this,void 0,void 0,(function(){var e,t,r,n,o=this;return Ti(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 Ii(o,void 0,void 0,(function(){var n,o,i,s,a;return Ti(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(Si(Si({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 qe(a)}];case 10:return[2]}}))}))}},error:null}];case 3:return n=i.sent(),[2,{data:{},error:new qe(n)}];case 4:return[2]}}))}))},e.prototype.resend=function(e){return Ii(this,void 0,void 0,(function(){var t,r,n;return Ti(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 qe(n)}];case 3:return[2]}}))}))},e.prototype.setSession=function(e){return Ii(this,void 0,void 0,(function(){var t,r,n;return Ti(this,(function(o){switch(o.label){case 0:return o.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,{throwOnError:!0})];case 1:return o.sent(),[4,this.getSession()];case 2:return t=o.sent().data,r=(void 0===t?{}:t).session,Li.fire(h.AUTH_STATE_CHANGED,{event:d.SIGNED_IN}),[2,{data:{user:r.user,session:r},error:null}];case 3:return n=o.sent(),[2,{data:{},error:new qe(n)}];case 4:return[2]}}))}))},e.prototype.exchangeCodeForSession=function(){return Ii(this,void 0,void 0,(function(){return Ti(this,(function(e){return[2]}))}))},e.prototype.deleteUser=function(e){return Ii(this,void 0,void 0,(function(){var t,r;return Ti(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 qe(r)}];case 4:return[2]}}))}))},e.prototype.toDefaultLoginPage=function(e){return void 0===e&&(e={}),Ii(this,void 0,void 0,(function(){var t,r,n,o,i;return Ti(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("&"),fi()?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 qe(e)}]}return[2]}))}))},e.prototype.signInWithCustomTicket=function(e){return Ii(this,void 0,void 0,(function(){var t,r,n,o;return Ti(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,Si(Si({},t),{data:{user:n.user,session:n},error:null})];case 5:return o=i.sent(),[2,{data:{},error:new qe(o)}];case 6:return[2]}}))}))},e.prototype.signInWithOpenId=function(e){var t=(void 0===e?{}:e).useWxCloud,r=void 0===t||t;return Ii(this,void 0,void 0,(function(){var e,t,n,o,i,s,a=this;return Ti(this,(function(u){switch(u.label){case 0:if(!fi())throw Error("wx api undefined");e=wx.getAccountInfoSync().miniProgram,t=function(t){return Ii(a,void 0,void 0,(function(){var n,o;return Ti(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 Ii(a,void 0,void 0,(function(){var o;return Ti(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,Si(Si({},n),{data:{user:i.user,session:i},error:null})];case 5:return s=u.sent(),[2,{data:{},error:new qe(s)}];case 6:return[2]}}))}))},e.prototype.signInWithPhoneAuth=function(e){var t=e.phoneCode,r=void 0===t?"":t;return Ii(this,void 0,void 0,(function(){var e,t,n,o,i,s,a,u,c;return Ti(this,(function(l){switch(l.label){case 0:return fi()?(e=wx.getAccountInfoSync().miniProgram,t={provider_params:{provider_code_type:"phone"},provider_id:e.appId},[4,wx.login()]):[2,{data:{},error:new qe({message:"wx api undefined"})}];case 1:n=l.sent().code,t.provider_code=n,l.label=2;case 2:return l.trys.push([2,6,,7]),[4,this.oauthInstance.authApi.grantProviderToken(t)];case 3:if((o=l.sent()).error_code)throw o;return[4,this.oauthInstance.authApi.patchProviderToken({provider_token:o.provider_token,provider_id:e.appId,provider_params:{code:r,provider_code_type:"phone"}})];case 4:if((o=l.sent()).error_code)throw o;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:o.provider_token})];case 5:if(null==(i=l.sent())?void 0:i.error_code)throw i;return[3,7];case 6:return s=l.sent(),[2,{data:{},error:new qe(s)}];case 7:return[4,this.createLoginState()];case 8:return a=l.sent(),[4,this.getSession()];case 9:return u=l.sent().data,c=(void 0===u?{}:u).session,[2,Si(Si({},a),{data:{user:c.user,session:c},error:null})]}}))}))},e.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)},e.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)}}))}))},e.prototype.init=function(){return Ii(this,void 0,void 0,(function(){return Ti(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.oauthInstance.oauth2client.localCredentials.getCredentials()];case 1:return e.sent()&&Li.fire(h.AUTH_STATE_CHANGED,{event:d.INITIAL_SESSION}),[3,3];case 2:return e.sent(),[3,3];case 3:return[2,{error:null}]}}))}))},e.prototype.setupListeners=function(){var e=this;Li.on(h.AUTH_STATE_CHANGED,(function(t){return Ii(e,void 0,void 0,(function(){var e,r,n,o,i;return Ti(this,(function(s){switch(s.label){case 0:return e=null===(o=null==t?void 0:t.data)||void 0===o?void 0:o.event,r=null===(i=null==t?void 0:t.data)||void 0===i?void 0:i.info,[4,this.getSession()];case 1:return n=s.sent().data.session,this.notifyListeners(e,n,r),[2]}}))}))}))},e.prototype.convertToUser=function(e){var t,r,n;if(!e)return null;var o=(null==e?void 0:e.email)||(null==e?void 0:e.username),i=null==e?void 0:e.phone_number,s=(null==e?void 0:e.sub)||(null==e?void 0:e.uid)||"";return{id:s,aud:"authenticated",role:e.groups,email:o||"",email_confirmed_at:(null==e||e.email_verified,e.created_at),phone:i,phone_confirmed_at:i?e.created_at:void 0,confirmed_at:e.created_at,last_sign_in_at:e.last_sign_in_at,app_metadata:{provider:(null===(t=e.loginType)||void 0===t?void 0:t.toLowerCase())||"cloudbase",providers:[(null===(r=e.loginType)||void 0===r?void 0:r.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,avatarUrl:e.avatarUrl||e.picture,location:e.location,hasPassword:e.hasPassword},identities:(null===(n=null==e?void 0:e.providers)||void 0===n?void 0:n.map((function(t){return{id:t.id||"",identity_id:t.id||"",user_id:s,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}},e.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 qe({message:s.message})}},e.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 qe({message:r})},e}(),Pi=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)}}(),Ri=function(){return Ri=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},Ri.apply(this,arguments)},Ci=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},Ai=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Ui=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())}))},ki=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])}}},Li=new ce.CloudbaseEventEmitter,Ni=function(e){Li.fire(h.LOGIN_STATE_CHANGED,Ri(Ri({},e),{eventType:l}))},Di=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 Ui(this,void 0,void 0,(function(){return ki(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 Ui(this,void 0,void 0,(function(){var e,t,r,n;return ki(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 Ui(this,void 0,void 0,(function(){var t;return ki(this,(function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.setUserProfile(Ri({},e))];case 1:return t=r.sent(),this.setLocalUserInfo(t),[2]}}))}))},e.prototype.updateUserBasicInfo=function(e){return Ui(this,void 0,void 0,(function(){return ki(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.updateUserBasicInfo(Ri({},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,le.throwError)(We.ERRORS.INVALID_PARAMS,"username must be a string"),this.update({username:e})},e.prototype.refresh=function(e){return Ui(this,void 0,void 0,(function(){var t;return ki(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 Ui(this,void 0,void 0,(function(){var t;return ki(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]}))},Ci([(0,Fe.catchErrorsDecorator)({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[Object]),Ai("design:returntype",Promise)],e.prototype,"update",null),Ci([(0,Fe.catchErrorsDecorator)({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[String,String]),Ai("design:returntype",void 0)],e.prototype,"updatePassword",null),Ci([(0,Fe.catchErrorsDecorator)({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[String]),Ai("design:returntype",void 0)],e.prototype,"updateUsername",null),Ci([(0,Fe.catchErrorsDecorator)({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[Object]),Ai("design:returntype",Promise)],e.prototype,"refresh",null),e}(),qi=function(){function e(e){var t=e.envId,r=e.cache,n=e.oauthInstance;t||(0,le.throwError)(We.ERRORS.INVALID_PARAMS,"envId is not defined"),this.cache=r,this.oauthInstance=n,this.user=new Di({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 Ui(this,void 0,void 0,(function(){return ki(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}(),xi=function(e){function t(t){var r=e.call(this,t)||this;return r.setAccessKey(),r}return Pi(t,e),t.prototype.bindPhoneNumber=function(e){return Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.editContact(e)]}))}))},t.prototype.unbindProvider=function(e){return Ui(this,void 0,void 0,(function(){return ki(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 Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.verify(e)]}))}))},t.prototype.getVerification=function(e,t){return Ui(this,void 0,void 0,(function(){return ki(this,(function(r){return[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,le.printWarn)(We.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrentUser instead")},enumerable:!1,configurable:!0}),t.prototype.getCurrentUser=function(){return Ui(this,void 0,void 0,(function(){var e,t;return ki(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,Ri(Ri({},e.user),t)];case 3:return[2,null]}}))}))},t.prototype.signInAnonymouslyInWx=function(e){var t=(void 0===e?{}:e).useWxCloud;return Ui(this,void 0,void 0,(function(){var e,r,n=this;return ki(this,(function(o){switch(o.label){case 0:if(!fi())throw Error("wx api undefined");return e=wx.getAccountInfoSync().miniProgram,r=function(r){return Ui(n,void 0,void 0,(function(){var n,o;return ki(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 Ui(n,void 0,void 0,(function(){var n;return ki(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 Ui(this,void 0,void 0,(function(){var e,t,r=this;return ki(this,(function(n){switch(n.label){case 0:if(!fi())throw Error("wx api undefined");return e=wx.getAccountInfoSync().miniProgram,t=function(t){return Ui(r,void 0,void 0,(function(){var r;return ki(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 Ui(r,void 0,void 0,(function(){var r;return ki(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 Ui(this,void 0,void 0,(function(){var e=this;return ki(this,(function(t){switch(t.label){case 0:if(!fi())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 Ui(e,void 0,void 0,(function(){var e,i,s,a,u;return ki(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 Ui(this,void 0,void 0,(function(){return ki(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 Ui(this,void 0,void 0,(function(){return ki(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 Ui(this,void 0,void 0,(function(){return ki(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 Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.setPassword(e)]}))}))},t.prototype.isUsernameRegistered=function(e){return Ui(this,void 0,void 0,(function(){return ki(this,(function(t){switch(t.label){case 0:return"string"!=typeof e&&(0,le.throwError)(We.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 qi({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance}):null;(0,le.printWarn)(We.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState insteed")},t.prototype.getLoginState=function(){return Ui(this,void 0,void 0,(function(){var e;return ki(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 qi({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})]:[2,null]}}))}))},t.prototype.getUserInfo=function(){return Ui(this,void 0,void 0,(function(){return ki(this,(function(e){return[2,this.getCurrentUser()]}))}))},t.prototype.getWedaUserInfo=function(){return Ui(this,void 0,void 0,(function(){return ki(this,(function(e){return[2,this.oauthInstance.authApi.getWedaUserInfo()]}))}))},t.prototype.updateUserBasicInfo=function(e){return Ui(this,void 0,void 0,(function(){var t;return ki(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 Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.bindWithProvider(e)]}))}))},t.prototype.queryUser=function(e){return Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.queryUserProfile(e)]}))}))},t.prototype.getAccessToken=function(){return Ui(this,void 0,void 0,(function(){return ki(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 Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.grantProviderToken(e)]}))}))},t.prototype.patchProviderToken=function(e){return Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.patchProviderToken(e)]}))}))},t.prototype.signInWithProvider=function(e){return Ui(this,void 0,void 0,(function(){return ki(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={}),Ui(this,void 0,void 0,(function(){return ki(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 Ui(this,void 0,void 0,(function(){return ki(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 Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.genProviderRedirectUri(e)]}))}))},t.prototype.resetPassword=function(e){return Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.resetPassword(e)]}))}))},t.prototype.deviceAuthorize=function(e){return Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.deviceAuthorize(e)]}))}))},t.prototype.sudo=function(e){return Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.sudo(e)]}))}))},t.prototype.deleteMe=function(e){return Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.deleteMe(e)]}))}))},t.prototype.getProviders=function(){return Ui(this,void 0,void 0,(function(){return ki(this,(function(e){return[2,this.oauthInstance.authApi.getProviders()]}))}))},t.prototype.loginScope=function(){return Ui(this,void 0,void 0,(function(){return ki(this,(function(e){return[2,this.oauthInstance.authApi.loginScope()]}))}))},t.prototype.loginGroups=function(){return Ui(this,void 0,void 0,(function(){return ki(this,(function(e){return[2,this.oauthInstance.authApi.loginGroups()]}))}))},t.prototype.onLoginStateChanged=function(e){return Ui(this,void 0,void 0,(function(){var t,r=this;return ki(this,(function(n){switch(n.label){case 0:return Li.on(h.LOGIN_STATE_CHANGED,(function(t){return Ui(r,void 0,void 0,(function(){var r,n,o;return ki(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,Ri(Ri({},t),r)),[2]}}))}))})),[4,this.getLoginState()];case 1:return t=n.sent(),e.call(this,t),[2]}}))}))},t.prototype.refreshTokenForce=function(e){return Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.refreshTokenForce(e)]}))}))},t.prototype.getCredentials=function(){return Ui(this,void 0,void 0,(function(){return ki(this,(function(e){return[2,this.oauthInstance.authApi.getCredentials()]}))}))},t.prototype.setCredentials=function(e){return Ui(this,void 0,void 0,(function(){return ki(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 Ui(this,void 0,void 0,(function(){return ki(this,(function(e){return[2,this.oauthInstance.authApi.getProviderSubType()]}))}))},t.prototype.createCaptchaData=function(e){return Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.createCaptchaData(e)]}))}))},t.prototype.verifyCaptchaData=function(e){return Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.verifyCaptchaData(e)]}))}))},t.prototype.getMiniProgramQrCode=function(e){return Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.getMiniProgramCode(e)]}))}))},t.prototype.getMiniProgramQrCodeStatus=function(e){return Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.getMiniProgramQrCodeStatus(e)]}))}))},t.prototype.modifyPassword=function(e){return Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.modifyPassword(e)]}))}))},t.prototype.modifyPasswordWithoutLogin=function(e){return Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.modifyPasswordWithoutLogin(e)]}))}))},t.prototype.getUserBehaviorLog=function(e){return Ui(this,void 0,void 0,(function(){return ki(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 Ui(this,void 0,void 0,(function(){var e,t,n,i,a,c,d;return ki(this,(function(h){switch(h.label){case 0:return h.trys.push([0,8,,9]),[4,this.oauthInstance.authApi.verify({verification_id:r.verification_id,verification_code:o})];case 1:if(null==(e=h.sent())?void 0:e.error_code)throw e;return t=e.verification_token,n=/^\+\d{1,3}\s+/.test(s)?s:"+86 ".concat(s),i={phone_number:n},"email"===l&&(i={email:n=s}),r.is_user?[4,this.oauthInstance.authApi.signIn({username:n,verification_token:t})]:[3,5];case 2:if(null==(a=h.sent())?void 0:a.error_code)throw a;return u?[4,this.oauthInstance.authApi.bindWithProvider({provider_token:null==u?void 0:u.providerToken})]:[3,4];case 3:if(null==(c=h.sent())?void 0:c.error_code)throw c;h.label=4;case 4:return[3,7];case 5:return[4,this.oauthInstance.authApi.signUp(Ri(Ri({},i),{verification_token:t,provider_token:null==u?void 0:u.providerId}))];case 6:if(null==(d=h.sent())?void 0:d.error_code)throw d;h.label=7;case 7:return[2,this.createLoginState()];case 8:throw h.sent();case 9:return[2]}}))}))},t.prototype.createLoginState=function(e,t){return Ui(this,void 0,void 0,(function(){var r;return ki(this,(function(n){switch(n.label){case 0:return[4,(r=new qi({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})).checkLocalStateAsync()];case 1:return n.sent(),(null==t?void 0:t.userInfo)?(r.user.setLocalUserInfo(t.userInfo),[3,5]):[3,2];case 2:return(null==t?void 0:t.asyncRefreshUser)?(r.user.refresh(e),[3,5]):[3,3];case 3:return[4,r.user.refresh(e)];case 4:n.sent(),n.label=5;case 5:return Li.fire(h.LOGIN_STATE_CHANGED,{eventType:"sign_in"}),Li.fire(h.AUTH_STATE_CHANGED,{event:d.SIGNED_IN}),[2,r]}}))}))},t.prototype.setAccessKey=function(){return Ui(this,void 0,void 0,(function(){return ki(this,(function(e){if(this.config.accessKey)try{this.oauthInstance.oauth2client.setAccessKeyCredentials({access_token:this.config.accessKey,token_type:"Bearer",scope:"accessKey",expires_at:new Date(+new Date+ +new Date),expires_in:+new Date+ +new Date})}catch(e){console.warn("accessKey error: ",e)}return[2]}))}))},Ci([(0,Fe.catchErrorsDecorator)({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[Object]),Ai("design:returntype",Promise)],t.prototype,"bindPhoneNumber",null),Ci([(0,Fe.catchErrorsDecorator)({title:"解除三方绑定失败",messages:["请确认以下各项:"," 1 - 调用 auth().unbindProvider() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[Object]),Ai("design:returntype",Promise)],t.prototype,"unbindProvider",null),Ci([(0,Fe.catchErrorsDecorator)({title:"绑定邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[Object]),Ai("design:returntype",void 0)],t.prototype,"bindEmail",null),Ci([(0,Fe.catchErrorsDecorator)({title:"验证码验证失败",messages:["请确认以下各项:"," 1 - 调用 auth().verify() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[Object]),Ai("design:returntype",Promise)],t.prototype,"verify",null),Ci([(0,Fe.catchErrorsDecorator)({title:"获取验证码失败",messages:["请确认以下各项:"," 1 - 调用 auth().getVerification() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[Object,Object]),Ai("design:returntype",Promise)],t.prototype,"getVerification",null),Ci([(0,Fe.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrentUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[]),Ai("design:returntype",Promise)],t.prototype,"getCurrentUser",null),Ci([(0,Fe.catchErrorsDecorator)({title:"小程序匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymouslyInWx() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[Object]),Ai("design:returntype",Promise)],t.prototype,"signInAnonymouslyInWx",null),Ci([(0,Fe.catchErrorsDecorator)({title:"小程序绑定OpenID失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序openId静默登录"," 2 - 调用 auth().bindOpenId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[]),Ai("design:returntype",Promise)],t.prototype,"bindOpenId",null),Ci([(0,Fe.catchErrorsDecorator)({title:"小程序unionId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序unionId静默登录"," 2 - 调用 auth().signInWithUnionId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[]),Ai("design:returntype",Promise)],t.prototype,"signInWithUnionId",null),Ci([(0,Fe.catchErrorsDecorator)({title:"短信验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序短信验证码登陆"," 2 - 调用 auth().signInWithSms() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[Object]),Ai("design:returntype",Promise)],t.prototype,"signInWithSms",null),Ci([(0,Fe.catchErrorsDecorator)({title:"邮箱验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了邮箱登陆"," 2 - 调用 auth().signInWithEmail() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[Object]),Ai("design:returntype",Promise)],t.prototype,"signInWithEmail",null),Ci([(0,Fe.catchErrorsDecorator)({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[String]),Ai("design:returntype",Promise)],t.prototype,"isUsernameRegistered",null),Ci([(0,Fe.catchErrorsDecorator)({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[]),Ai("design:returntype",Promise)],t.prototype,"getLoginState",null),Ci([(0,Fe.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[]),Ai("design:returntype",Promise)],t.prototype,"getUserInfo",null),Ci([(0,Fe.catchErrorsDecorator)({title:"获取微搭插件用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getWedaUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[]),Ai("design:returntype",Promise)],t.prototype,"getWedaUserInfo",null),Ci([(0,Fe.catchErrorsDecorator)({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindWithProvider() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[Object]),Ai("design:returntype",Promise)],t.prototype,"bindWithProvider",null),Ci([(0,Fe.catchErrorsDecorator)({title:"获取身份源类型",messages:["请确认以下各项:"," 1 - 调用 auth().getProviderSubType() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[]),Ai("design:returntype",Promise)],t.prototype,"getProviderSubType",null),t}(Oi);function ji(e,t){var r=this,n=e.region,o=void 0===n?"ap-shanghai":n,i=e.i18n,s=e.accessKey,a=e.useWxCloud,c=(null==t?void 0:t.platform)||pi.useDefaultAdapter.bind(t)(),l=c.runtime,p=c.adapter,v=t||{},y=v.env,g=v.clientId,m=v.debug,_=v.cache,b=v.app,w=(t||{}).apiOrigin;w||(w="https://".concat(y,".").concat(o,".tcb-api.tencentcloudapi.com"));var S={env:y,clientId:g,i18n:i,accessKey:s,useWxCloud:a,eventBus:Li},I=new Be(wi(Ri(Ri({},S),{apiOrigin:w,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:p,onCredentialsError:Ni,headers:Ri({"X-SDK-Version":"@cloudbase/js-sdk/".concat(e.sdkVersion)},e.headers||{}),detectSessionInUrl:e.detectSessionInUrl,debug:m}))),T=new xi(Ri(Ri({},S),{region:o,persistence:e.persistence,debug:m,cache:_||new He.CloudbaseCache({persistence:e.persistence,keys:{userInfoKey:"user_info_".concat(y)},platformInfo:c}),runtime:l||"web",_fromApp:b,oauthInstance:I}));return I.initializeSession((function(e,t){return Ui(r,void 0,void 0,(function(){return ki(this,(function(r){return e?(e.type===f.SIGN_IN?t?Li.fire(h.AUTH_STATE_CHANGED,{event:d.SIGNED_IN,info:Ri(Ri({},e),{error:t})}):e.user&&T.createLoginState({},{userInfo:e.user}):e.type===f.BIND_IDENTITY&&Li.fire(h.AUTH_STATE_CHANGED,{event:d.BIND_IDENTITY,info:Ri(Ri({},e),{error:t})}),[2]):[2]}))}))})),{authInstance:T,oauthInstance:I}}var Mi={name:"auth",namespace:"auth",entity: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=ji(Ri(Ri({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}};try{cloudbase.registerComponent(Mi)}catch(Y){}function Bi(e){try{e.registerComponent(Mi)}catch(e){console.warn(e)}}},171:(e,t,r)=>{var n;if(r.r(t),r.d(t,{getEncryptInfo:()=>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 H(e,t){return e^t}function V(e,t){return e&~t}function z(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 K(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 Y(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)}},d=1e13;class ${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)<d?t=0:n-=(t=0|n/d)*d,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+=d,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+=(d+t[n]).toString().substring(1);return r}valueOf(){for(var e=this.buf,t=0,r=e.length-1;r>=0;--r)t=t*d+e[r];return t}simplify(){var e=this.buf;return 1==e.length?e[0]:this}}var h,f=/^(\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 Q(e,t){return e.length>t&&(e=e.substring(0,t)+"…"),e}class J{constructor(e,t){this.hexDigits="0123456789ABCDEF",e instanceof J?(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?f: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 $(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+Q(i,r)}return o+i}parseOctetString(e,t,r){if(this.isASCII(e,t))return Q(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 $,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 $)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 Q(n,r);o=new $,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 Q(this.stream.parseStringUTF(t,t+r),e);case 18:case 19:case 20:case 21:case 22:case 26:return Q(this.stream.parseStringISO(t,t+r),e);case 30:return Q(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 J?e:new J(e,0);var r=new J(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 $;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 m(t):new _(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,H,t),t}andNot(e){var t=te();return this.bitwiseTo(e,V,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+z(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,V)}flipBit(e){return this.changeBit(e,H)}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 m(t):t.isEven()?new b(t):new _(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 d,h,f=e.t-1,p=!0,v=te();for(o=ue(e[f])-1;f>=0;){for(o>=u?d=e[f]>>o-u&c:(d=(e[f]&(1<<o+1)-1)<<u-o,f>0&&(d|=e[f-1]>>this.DB+o-u)),a=r;!(1&d);)d>>=1,--a;if((o-=a)<0&&(o+=this.DB,--f),p)s[d].copyTo(i),p=!1;else{for(;a>1;)n.sqrTo(i,v),n.sqrTo(v,i),a-=2;a>0?n.sqrTo(i,v):(h=i,i=v,v=h),n.mulTo(v,s[d],i)}for(;f>=0&&!(e[f]&1<<o);)n.sqrTo(i,v),h=i,i=v,v=h,--o<0&&(o=this.DB-1,--f)}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 g)}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 d=l*(1<<this.F1)+(c>1?i[c-2]>>this.F2:0),h=this.FV/d,f=(1<<this.F1)/d,p=1<<this.F2,v=r.t,y=v-c,g=null==t?te():t;for(i.dlShiftTo(y,g),r.compareTo(g)>=0&&(r[r.t++]=1,r.subTo(g,r)),ee.ONE.dlShiftTo(c,g),g.subTo(i,i);i.t<c;)i[i.t++]=0;for(;--y>=0;){var m=r[--v]==l?this.DM:Math.floor(r[v]*h+(r[v-1]+p)*f);if((r[v]+=i.am(0,m,r,y,0,c))<m)for(i.dlShiftTo(y,g),r.subTo(g,r);r[v]<--m;)r.subTo(g,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 g=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}(),m=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}(),_=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}(),b=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,h=30):"Netscape"!=(null==o?void 0:o.appName)?(ee.prototype.am=ne,h=26):(ee.prototype.am=ie,h=28),ee.prototype.DB=h,ee.prototype.DM=(1<<h)-1,ee.prototype.DV=1<<h,ee.prototype.FV=Math.pow(2,52),ee.prototype.F1=52-h,ee.prototype.F2=2*h-52;var w,S,I=[];for(w="0".charCodeAt(0),S=0;S<=9;++S)I[w++]=S;for(w="a".charCodeAt(0),S=10;S<36;++S)I[w++]=S;for(w="A".charCodeAt(0),S=10;S<36;++S)I[w++]=S;function se(e,t){var r=I[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 T,E,O=null;if(null==O){var P,R,C,A;O=[],E=0;var U=void 0;if(null!==(P=window)&&void 0!==P&&P.crypto&&null!==(R=window)&&void 0!==R&&R.crypto.getRandomValues){var k,L=new Uint32Array(256);for(null===(k=window)||void 0===k||k.crypto.getRandomValues(L),U=0;U<L.length;++U)O[E++]=255&L[U]}var N,D=function(e){var t,r,n;if(this.count=this.count||0,this.count>=256||E>=256){if(null!==(t=window)&&void 0!==t&&t.removeEventListener)null===(n=window)||void 0===n||n.removeEventListener("mousemove",D,!1);else if(null!==(r=window)&&void 0!==r&&r.detachEvent){var o;null===(o=window)||void 0===o||o.detachEvent("onmousemove",D)}}else try{var i=e.x+e.y;O[E++]=255&i,this.count+=1}catch(e){}};if(null!==(C=window)&&void 0!==C&&C.addEventListener)null===(N=window)||void 0===N||N.addEventListener("mousemove",D,!1);else if(null!==(A=window)&&void 0!==A&&A.attachEvent){var q;null===(q=window)||void 0===q||q.attachEvent("onmousemove",D)}}function le(){if(null==T){for(T=new ce;E<256;){var e=Math.floor(65536*Math.random());O[E++]=255&e}for(T.init(O),E=0;E<O.length;++E)O[E]=0;E=0}return T.next()}class de{constructor(){}nextBytes(e){for(var t=0;t<e.length;++t)e[t]=le()}}function he(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 de,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 fe{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=he(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})),K(n)):K(this.encrypt(e))}catch(e){return!1}}decryptLong(e){var t=this,r=this.n.bitLength()+7>>3;e=Y(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 de,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 de,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 fe{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 d=o.sub[7].getHexStringValue();this.dmq1=re(d,16);var h=o.sub[8].getHexStringValue();this.coeff=re(h,16)}else{if(2!==o.sub.length)return!1;var f=o.sub[1].sub[0];t=f.sub[0].getHexStringValue(),this.n=re(t,16),r=f.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(Y(e))}catch(e){return!1}},n.prototype.encrypt=function(e){try{return K(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"}const x=n;var j=r(655),M=function(){var{publicKey:e="",payload:t={}}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!e)return"";try{var r=(0,j.I)(t),n=new x;return n.setPublicKey(e),n.encryptLong("object"==typeof r?JSON.stringify(r):r)}catch(e){console.error("encrypt error:",e)}return""}},655:(e,t,r)=>{r.d(t,{I:()=>n,y:()=>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]||""}},182:function(e,t,r){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(274)),c=r(616);!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}}},274:function(e,t,r){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(325),c=r(616),l=r(946),d=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,d,h,f,p,v,y,g,m=this;return a(this,(function(_){switch(_.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,d=e.signal,h=e.timeout,f=e.shouldThrowOnError,p=void 0===f||f,v=null!=h?h:this.timeout,d&&(d.aborted&&r.abort(),d.addEventListener("abort",(function(){return r.abort()}))),y=null,u&&v&&(y=setTimeout((function(){console.warn(m.timeoutMsg),r.abort(new Error(m.timeoutMsg))}),v)),[4,fetch(n,i(i({},e),{signal:r.signal})).then((function(e){return s(m,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 g=_.sent(),[2,{data:l?g.body:(null===(t=g.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))?g.json():g.text(),statusCode:g.status,header:g.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,d=void 0===u?{}:u,h=e.data,f=e.responseType,p=e.withCredentials,v=e.body,y=e.onUploadProgress,g=(0,c.formatUrl)((0,l.getProtocol)(),a,"get"===n?h:{}),m=new XMLHttpRequest;m.open(n,g),f&&(m.responseType=f),Object.keys(d).forEach((function(e){m.setRequestHeader(e,d[e])})),y&&m.upload.addEventListener("progress",y),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=(0,c.isFormData)(h)?h:"application/x-www-form-urlencoded"===d["content-type"]?(0,c.toQueryString)(h):v||(h?JSON.stringify(h):void 0),p&&(m.withCredentials=!0),m.send(s)}))},t}(u.AbstractSDKRequest);t.WebRequest=d,t.genAdapter=function(){return{type:"default",root:window,reqClass:d,wsClass:WebSocket,localStorage}}},946:(e,t)=>{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"},205:(e,t)=>{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){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(946),t),o(r(205),t),t.OATUH_LOGINTYPE="constants"},718:function(e,t,r){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(616),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,"\\]")),d=s.findIndex((function(e){return u.test(e)}));if(-1!==d){var h=s.filter((function(e,t){return t>d}));h.unshift(s[d].replace(l,"".concat(r,".").concat(n)).replace(c,o)),(i=new Error).stack="".concat(a?"@debugger":"Error","\n").concat(h.join("\n"))}return i}t.catchErrorsDecorator=function(e){var t=e.mode,r=void 0===t?"async":t,a=e.customInfo,d=void 0===a?{}:a,h=e.title,f=e.messages,p=void 0===f?[]:f;return function(e,t,a){if(s.IS_DEBUG_MODE){var f=d.className||e.constructor.name,v=d.methodName||t,y=a.value,g=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:f,methodName:v,sourceLink:g});try{return y.apply(this,e)}catch(e){var n=e,o=e.message,s=e.error,a=e.error_description,u={title:h||"".concat(f,".").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,d;return o(this,(function(o){switch(o.label){case 0:t=l({err:new Error,className:f,methodName:v,sourceLink:g}),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:h||"".concat(f,".").concat(v," failed"),content:[{type:"error",body:r}]},s&&/^\{.*\}$/.test(s)&&(d=JSON.parse(s),c.subtitle=d,d.code&&(t?(t.code=d.code,t.message=d.msg):(r.code=d.code,r.message=d.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){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(718),t)},197:function(e,t,r){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(325),u=r(616),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),d=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})||void 0===r?void 0:r.tcb_token))return{IS_MP_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})||void 0===r?void 0:r.tcb_token))return[2,{IS_MP_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=d},689:function(e,t,r){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(616),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)}},616:function(e,t,r){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,d=s;l<d.length;l++){var h=d[l],f=h.type,p=h.body;switch(f){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"}}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,r),i.exports}return r.d=(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.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r(760)})()));
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("cloudbase_auth",[],t):"object"==typeof exports?exports.cloudbase_auth=t():e.cloudbase_auth=t()}("undefined"!=typeof window?window:this,(()=>(()=>{"use strict";var e={760:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.registerAuth=void 0;var n=r(15);t.registerAuth=n.registerAuth;try{window.registerAuth=t.registerAuth}catch(e){}},325:(e,t,r)=>{var n;r.r(t),r.d(t,{AbstractSDKRequest:()=>o,AbstractStorage:()=>i,StorageType:()=>n,formatUrl:()=>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}},15:(e,t,r)=>{r.r(t),r.d(t,{Auth:()=>xi,LoginState:()=>qi,User:()=>Di,eventBus:()=>Li,generateAuthInstance:()=>ji,registerAuth:()=>Bi});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";var c,l="credentials_error",d={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"},h={LOGIN_STATE_CHANGED:"loginStateChanged",AUTH_STATE_CHANGED:"authStateChanged"},f={SIGN_IN:"sign_in",BIND_IDENTITY:"bind_identity"};function p(){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 v=r(655);function y(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){y(i,n,o,s,a,"next",e)}function a(e){y(i,n,o,s,a,"throw",e)}s(void 0)}))}}var m=new Map;class _{constructor(e){this.clientId=(null==e?void 0:e.clientId)||"",m=m||new Map}run(e,t){var r=this;return g((function*(){e="".concat(r.clientId,"_").concat(e);var n=m.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{m.delete(e)}}))()})),m.set(e,n)),n}))()}runIdlePromise(){return Promise.resolve()}}var b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",w=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/,S=function(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!w.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=b.indexOf(e.charAt(i++))<<18|b.indexOf(e.charAt(i++))<<12|(r=b.indexOf(e.charAt(i++)))<<6|(n=b.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.getSystemInfoSync)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.getSystemInfoSync())return!1;if("qq"===e.getSystemInfoSync().AppPlatform)return!1}catch(e){return!1}return!0}var T=!1;function E(){T=T||void 0!==typeof window&&"miniprogram"===window.__wxjs_environment}try{I()||(T=T||!!navigator.userAgent.match(/miniprogram/i)||"miniprogram"===window.__wxjs_environment,window&&window.WeixinJSBridge&&window.WeixinJSBridge.invoke?E():"undefined"!=typeof document&&document.addEventListener("WeixinJSBridgeReady",E,!1))}catch(Y){}var O="@cloudbase/js-sdk";function P(){return O}var R="INVALID_OPERATION",C="OPERATION_FAIL",A=r(325);function U(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]:""}function k(e,t){console.warn("[".concat(P(),"][").concat(e,"]:").concat(t))}var L,N,D=(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)}),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)},x=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])}}};!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}D(t,e),t.prototype.get=function(e){return this.request(q(q({},e),{method:"get"}),this.restrictedMethods.includes("get"))},t.prototype.post=function(e){return this.request(q(q({},e),{method:"post"}),this.restrictedMethods.includes("post"))},t.prototype.put=function(e){return this.request(q(q({},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(q(q({},e),{data:u,method:a}),this.restrictedMethods.includes("upload"))):this.request(q(q({},e),{method:"put",headers:s,body:r}),this.restrictedMethods.includes("upload"))},t.prototype.download=function(e){return x(this,void 0,void 0,(function(){var t,r,n,o;return j(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.get(q(q({},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 x(this,void 0,void 0,(function(){var r,n,o,i,s,a,u,c,l,d,h,f,p,v=this;return j(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,d=void 0===l||l,h=null!=c?c:this.timeout,u&&(u.aborted&&r.abort(),u.addEventListener("abort",(function(){return r.abort()}))),f=null,i&&h&&(f=setTimeout((function(){console.warn(v.timeoutMsg),r.abort(new Error(v.timeoutMsg))}),h)),[4,fetch(n,q(q({},e),{signal:r.signal})).then((function(e){return x(v,void 0,void 0,(function(){var t,r,n;return j(this,(function(o){switch(o.label){case 0:return clearTimeout(f),d?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(f),d)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,u=e.url,c=e.headers,l=void 0===c?{}:c,d=e.data,h=e.responseType,f=e.withCredentials,p=e.body,v=e.onUploadProgress,y=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)}("https:",u,"get"===n?d:{}),g=new XMLHttpRequest;g.open(n,y),h&&(g.responseType=h),Object.keys(l).forEach((function(e){g.setRequestHeader(e,l[e])})),v&&g.upload.addEventListener("progress",v),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)),a=d,s="[object FormData]"===Object.prototype.toString.call(a)?d:"application/x-www-form-urlencoded"===l["content-type"]?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("&")}(d):p||(d?JSON.stringify(d):void 0),f&&(g.withCredentials=!0),g.send(s)}))}}(A.AbstractSDKRequest),function(e){e.WEB="web",e.WX_MP="wx_mp"}(N||(N={}));var M=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)}}(),B=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())}))},W=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])}}},F=function(e){function t(t){var r=e.call(this)||this;return r.root=t,t.tcbCacheObject||(t.tcbCacheObject={}),r}return M(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);!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:(k("INVALID_PARAMS","localStorage is not supported on current platform"),new F(t.root));case"none":return new F(t.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}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,msg:"[".concat(P(),"][").concat(C,"]setStore failed"),info:e}))}}else k(R,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(e,t,r){return B(this,void 0,void 0,(function(){var n;return W(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})||void 0===r?void 0:r.tcb_token))return{IS_MP_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:""}k(R,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,t){var r;return B(this,void 0,void 0,(function(){var n;return W(this,(function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!0})||void 0===r?void 0:r.tcb_token))return[2,{IS_MP_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(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):k(R,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(e){return B(this,void 0,void 0,(function(){return W(this,(function(t){switch(t.label){case 0:return[4,this.storage.removeItem(e)];case 1:return t.sent(),[2]}}))}))}}();var H=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)}}(),V=function(e,t){this.data=t||null,this.name=e},z=function(e){function t(t,r){var n=e.call(this,"error",{error:t,data:r})||this;return n.error=t,n}return H(t,e),t}(V),G=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(e instanceof z)return console.error(e.error),this;var r="string"==typeof e?new V(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 G;var K=new G;function Y(e){this.message=e}function $(e){this.message=e}function Q(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 J(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Q(Object(r),!0).forEach((function(t){Z(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Q(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Z(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 X(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 ee(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function s(e){X(i,n,o,s,a,"next",e)}function a(e){X(i,n,o,s,a,"throw",e)}s(void 0)}))}}"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.indexOf("Firefox"),Y.prototype=new Error,Y.prototype.name="InvalidCharacterError","undefined"!=typeof window&&window.atob&&window.atob.bind(window),$.prototype=new Error,$.prototype.name="InvalidTokenError";var te="x-request-id",re="x-device-id",ne="device_id",oe=function(){var e=ee((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)}}(),ie=new class{constructor(e){this._env=(null==e?void 0:e.env)||""}getItem(e){var t=this;return ee((function*(){return window.localStorage.getItem("".concat(e).concat(t._env))}))()}removeItem(e){var t=this;return ee((function*(){window.localStorage.removeItem("".concat(e).concat(t._env))}))()}setItem(e,t){var r=this;return ee((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 se(e){var t=!0;return null!=e&&e.expires_at&&null!=e&&e.access_token&&(t=e.expires_at<new Date),t}class ae{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 _({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 ee((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}getCredentials(){var e=this;return ee((function*(){return e.singlePromise.run("getCredentials",ee((function*(){if(se(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 ee((function*(){return e.singlePromise.run("_getStorageCredentials",ee((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 ue{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 _({clientId:this.clientId}),this.retry=this.formatRetry(e.retry,ue.defaultRetry),e.baseRequest?this.baseRequest=e.baseRequest:this.baseRequest=oe,this.tokenInURL=e.tokenInURL,this.headers=e.headers,this.storage=e.storage||ie,this.localCredentials=new ae({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+=b.charAt((t=r<<16|n<<8|o)>>18&63)+b.charAt(t>>12&63)+b.charAt(t>>6&63)+b.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,K.on("lang_change",(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 ee((function*(){return t.initializePromise?yield t.initializePromise:void 0!==e?(t.initializePromise=e,yield t.initializePromise):(t.initializePromise=ee((function*(){return yield t._acquireLock(-1,ee((function*(){return yield t._initialize()})))}))(),yield t.initializePromise)}))()}setCredentials(e){var t=this;return ee((function*(){return yield t.initializePromise,t._acquireLock(-1,ee((function*(){return t.localCredentials.setCredentials(e)})))}))()}setAccessKeyCredentials(e){return this.localCredentials.setAccessKeyCredentials(e)}getAccessToken(){var e=this;return ee((function*(){yield e.initializePromise;var t=yield e.getCredentials();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 ee((function*(){var n,o,i,a;t||(t={});var u=r.formatRetry(t.retry,r.retry);if(t.headers=J(J({},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=J(J({},r.headers),t.headers)),t.headers[te]||(t.headers[te]=p()),!t.headers[re]){var c=yield r.getDeviceId();t.headers[re]=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 d=null,h=u+1,f=0;f<h;f++){try{d=t.useWxCloud||r.useWxCloud?yield r.wxCloudCallFunction(e,t):yield r.baseRequest(e,t);break}catch(e){if(t.withCredentials&&e&&e.error===s.UNAUTHENTICATED)return yield r.setCredentials(null),Promise.reject(e);if(f===u||!e||"unreachable"!==e.error)return Promise.reject(e)}yield r.sleep(ue.retryInterval)}return d}))()}wxCloudCallFunction(e,t){var r=this;return ee((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:J({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,v.y)(e):n=null==u?void 0:u.body}catch(t){o={error:s.UNREACHABLE,error_description:t.message,error_uri:(0,v.y)(e)}}if(o)throw o;return n}))()}getCredentials(){var e=this;return ee((function*(){return yield e.initializePromise,e._acquireLock(-1,ee((function*(){return e._getCredentials()})))}))()}getCredentialsSync(){return this.localCredentials.getStorageCredentialsSync()}getCredentialsAsync(){return this.getCredentials()}getScope(){var e=this;return ee((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 ee((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 ee((function*(){return yield r.initializePromise,r._acquireLock(-1,ee((function*(){return r._refreshToken(e,t)})))}))()}_refreshToken(e,t){var r=this;return ee((function*(){return r.singlePromise.run("_refreshToken",ee((function*(){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(h.AUTH_STATE_CHANGED,{event:d.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 ee((function*(){return t.singlePromise.run("_anonymousLogin",ee((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<ue.minRetry||e>ue.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 ee((function*(){return new Promise((t=>{setTimeout((()=>{t()}),e)}))}))()}anonymousSignIn(e){var t=this;return ee((function*(){return t.singlePromise.run("_anonymous",ee((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 ee((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),J(J({},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 ee((function*(){if(e.deviceID)return e.deviceID;var t=yield e.storage.getItem(ne);return"string"==typeof t&&t.length>=16&&t.length<=48||(t=p(),yield e.storage.setItem(ne,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 ee((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 ee((function*(){r._debug("#_acquireLock","begin",e);try{if(r.lockAcquired){var n=r.pendingInLock.length?r.pendingInLock[r.pendingInLock.length-1]:Promise.resolve(),o=ee((function*(){return yield n,yield t()}))();return r.pendingInLock.push(ee((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(ee((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 ee((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)}if(se(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}))()}}ue.defaultRetry=2,ue.minRetry=0,ue.maxRetry=5,ue.retryInterval=1e3;var ce=r(689),le=r(616);function de(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 he(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?de(Object(r),!0).forEach((function(t){fe(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):de(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function fe(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)}))}}var ye=(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)}},ge=new ce.CloudbaseEventEmitter,me="resolveCaptchaData",_e="padding:10px 8px;background:#007bff;color:#fff;border:none;border-radius:4px;cursor:pointer;flex:1;white-space:nowrap;margin-left:10px",be="width:100%;padding:10px;background:#007bff;color:#fff;border:none;border-radius:4px;cursor:pointer",we="background:#6c757d;cursor:not-allowed",Se=e=>{var{oauthInstance:t,captchaState:r}=e,n="captcha-image",o=function(){var e=ve((function*(){try{var e=yield t.createCaptchaData({state:r.state});r=he(he({},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",_e,"刷新");l.onclick=ye(ve((function*(){l.textContent="加载中...",l.disabled=!0,l.style.cssText="".concat(_e,";").concat(we);try{yield o()}finally{l.textContent="刷新",l.disabled=!1,l.style.cssText=_e}})),500),u.appendChild(l),a.appendChild(u);var d=i("input","width:100%;padding:14px 16px;margin-bottom:15px;box-sizing:border-box;border:2px solid #e8ecf4;border-radius:10px;font-size:15px");d.type="text",d.placeholder="输入字符",d.maxLength=4,a.appendChild(d);var h=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(h);var f=e=>{h.textContent=e,h.style.display="block"},p=i("button",be,"确定");p.onclick=ye(ve((function*(){var e=d.value.trim();if(e){h.style.display="none",p.textContent="验证中...",p.disabled=!0,p.style.cssText="".concat(be,";").concat(we);try{var n=yield t.verifyCaptchaData({token:r.token,key:e});ge.fire(me,n),console.log("图形验证码校验成功"),document.body.removeChild(s),document.body.removeChild(a)}catch(e){console.error("图形验证码校验失败",e);var i=e.error_description||"图形验证码校验失败";f(i),d.value="",d.focus(),yield o()}finally{p.textContent="确定",p.disabled=!1,p.style.cssText=be}}else f("请输入字符")})),500),a.appendChild(p),document.body.appendChild(s),document.body.appendChild(a)},Ie=function(){var e=ve((function*(e,t){var{captchaData:r,state:n,token:o}=(0,le.parseCaptcha)(e);return Se({oauthInstance:t,captchaState:{captchaData:r,state:n,token:o}}),new Promise((e=>{console.log("等待图形验证码校验结果..."),ge.on(me,(t=>{e(null==t?void 0:t.data)}))}))}));return function(t,r){return e.apply(this,arguments)}}();function Te(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 Ee(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function s(e){Te(i,n,o,s,a,"next",e)}function a(e){Te(i,n,o,s,a,"throw",e)}s(void 0)}))}}class Oe{constructor(e){e.openURIWithCallback||(e.openURIWithCallback=this.getDefaultOpenURIWithCallback()),e.storage||(e.storage=ie),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 Ee((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=>Ie(e,this.config.oauthInstance)}getCaptchaToken(e,t){var r=this;return Ee((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 Ee((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 Ee((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 Ee((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}))()}}const Pe=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("&")}};var Re=["provider_redirect_uri","other_params"];function Ce(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 Ae(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function s(e){Ce(i,n,o,s,a,"next",e)}function a(e){Ce(i,n,o,s,a,"throw",e)}s(void 0)}))}}function Ue(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 ke(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Ue(Object(r),!0).forEach((function(t){Le(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ue(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Le(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 Ne(e,t){try{var n;if(((null==t||null===(n=t.root)||void 0===n?void 0:n.globalThis)||globalThis).IS_MP_BUILD)return}catch(t){if(e)return(()=>{try{return r(171)}catch(e){return}})()}}class De{static parseParamsToSearch(e){return Object.keys(e).forEach((t=>{e[t]||delete e[t]})),new Pe(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 ue(n)}if(!t){var o=r.request.bind(r),i=new Oe(ke({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||ie,adapter:e.adapter}}getParamsByVersion(e,t){var r,i=(0,v.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 Ae((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(ke(ke({},i),{},{version:r})),Promise.resolve(i)}))()}signInAnonymously(){var e=arguments,t=this;return Ae((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 Ae((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 Ae((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 Ae((function*(){yield e.config.request(n.AUTH_REVOKE_ALL_URL,{method:"DELETE",withCredentials:!0})}))()}revokeDevice(e){var t=this;return Ae((function*(){yield t.config.request(n.AUTHORIZED_DEVICES_DELETE_URL+e.device_id,{method:"DELETE",withCredentials:!0})}))()}getVerification(e,t){var r=this;return Ae((function*(){var o=!1;("CUR_USER"===e.target||(yield r.hasLoginState()))&&(o=!0);var i=(0,v.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 Ae((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(ke(ke({},n),{},{version:"v2"}))),n}))()}genProviderRedirectUri(e){var t=this;return Ae((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,Re);r&&!i.redirect_uri&&(i.redirect_uri=r);var s="".concat(n.PROVIDER_URI_URL,"?").concat(De.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 Ae((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 Ae((function*(){return t.config.request(n.PROVIDER_TOKEN_URL,{method:"PATCH",body:e})}))()}signInWithProvider(e){var t=arguments,r=this;return Ae((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(ke(ke({},i),{},{version:(null==e?void 0:e.version)||"v1"})),Promise.resolve(i)}))()}toBindIdentity(e){var t=this;return Ae((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:f.BIND_IDENTITY,provider:e.provider},error:null}}catch(e){r={data:{type:f.BIND_IDENTITY},error:new qe(e)}}return e.fireEvent&&(null===(n=t.config.eventBus)||void 0===n||null===(o=n.fire)||void 0===o||o.call(n,h.AUTH_STATE_CHANGED,{event:d.BIND_IDENTITY,info:r})),r}))()}getInitialSession(){var e=this;return Ae((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 d=a.get("error"),h=a.get("error_description");if(d||h)return{data:t,error:new qe({message:h||d||"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 qe({message:"Provider is required for OAuth verification"})};var v,y,g=location.origin+location.pathname,{provider_token:m}=yield e.grantProviderToken({provider_id:p,provider_redirect_uri:g,provider_code:u}),_=null;if(l.type===f.BIND_IDENTITY)v=yield e.config.credentialsClient.localCredentials.getCredentials(),y=yield e.toBindIdentity({provider:p,provider_token:m,credentials:v});else if(l.type===f.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:m}});try{_=yield e.getUserInfo({credentials:v})}catch(e){console.error("get user info error",e)}y={data:ke(ke({},t),{},{session:v,user:_}),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 qe(e)}}}))()}signInCustom(e){var t=this;return Ae((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 Ae((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 Ae((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 Ae((function*(){return t.getUserInfo(e)}))()}getUserInfo(){var e=arguments,t=this;return Ae((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 Pe(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 Ae((function*(){return yield e.config.request(n.WEDA_USER_URL,{method:"GET",withCredentials:!0})}))()}deleteMe(e){var t=this;return Ae((function*(){var r=t.getParamsByVersion(e,"USER_ME_URL"),n="".concat(r.url,"?").concat(De.parseParamsToSearch(r.params));return t.config.request(n,{method:"DELETE",withCredentials:!0})}))()}hasLoginState(){var e=this;return Ae((function*(){try{return yield e.config.credentialsClient.getAccessToken(),!0}catch(e){return!1}}))()}hasLoginStateSync(){return this.config.credentialsClient.getCredentialsSync()}getLoginState(){var e=this;return Ae((function*(){return e.config.credentialsClient.getCredentialsAsync()}))()}transByProvider(e){var t=this;return Ae((function*(){return t.config.request(n.USER_TRANS_BY_PROVIDER_URL,{method:"PATCH",body:e,withCredentials:!0})}))()}grantToken(e){var t=this;return Ae((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 Ae((function*(){return e.config.request(n.PROVIDER_LIST,{method:"GET",withCredentials:!0})}))()}unbindProvider(e){var t=this;return Ae((function*(){return t.config.request("".concat(n.PROVIDER_UNBIND_URL,"/").concat(e.provider_id),{method:"DELETE",withCredentials:!0})}))()}checkPassword(e){var t=this;return Ae((function*(){return t.config.request("".concat(n.CHECK_PWD_URL),{method:"POST",withCredentials:!0,body:e})}))()}editContact(e){var t=this;return Ae((function*(){return t.config.request("".concat(n.BIND_CONTACT_URL),{method:"PATCH",withCredentials:!0,body:e})}))()}setPassword(e){var t=this;return Ae((function*(){return t.config.request("".concat(n.AUTH_SET_PASSWORD),{method:"PATCH",withCredentials:!0,body:e})}))()}updatePasswordByOld(e){var t=this;return Ae((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 Ae((function*(){return t.config.request("".concat(n.SUDO_URL),{method:"POST",withCredentials:!0,body:e})}))()}sendVerificationCodeToCurrentUser(e){var t=this;return Ae((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 Ae((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 Ae((function*(){return t.config.request(n.USER_PRIFILE_URL,{method:"PATCH",body:e,withCredentials:!0})}))()}updateUserBasicInfo(e){var t=this;return Ae((function*(){return t.config.request(n.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:e})}))()}queryUserProfile(e){var t=this;return Ae((function*(){var r=new Pe(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 Ae((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 Ae((function*(){return t.config.request(n.AUTH_RESET_PASSWORD,{method:"POST",body:e})}))()}authorize(e){var t=this;return Ae((function*(){return t.config.request(n.AUTHORIZE_URL,{method:"POST",withCredentials:!0,body:e})}))()}authorizeDevice(e){var t=this;return Ae((function*(){return t.config.request(n.AUTHORIZE_DEVICE_URL,{method:"POST",withCredentials:!0,body:e})}))()}deviceAuthorize(e){var t=this;return Ae((function*(){return t.config.request(n.AUTH_GET_DEVICE_CODE,{method:"POST",body:e,withCredentials:!0})}))()}authorizeInfo(e){var t=this;return Ae((function*(){var r="".concat(n.AUTHORIZE_INFO_URL,"?").concat(De.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 Ae((function*(){return t.config.request(n.CHECK_USERNAME,{method:"GET",body:e,withCredentials:!0})}))()}checkIfUserExist(e){var t=this;return Ae((function*(){var r=new Pe(e);return t.config.request("".concat(n.CHECK_IF_USER_EXIST,"?").concat(r.toString()),{method:"GET"})}))()}loginScope(){var e=this;return Ae((function*(){return e.config.credentialsClient.getScope()}))()}loginGroups(){var e=this;return Ae((function*(){return e.config.credentialsClient.getGroups()}))()}refreshTokenForce(e){var t=this;return Ae((function*(){var r=yield t.config.credentialsClient.getCredentials();return yield t.config.credentialsClient.refreshToken(ke(ke({},r),{},{version:(null==e?void 0:e.version)||"v1"}))}))()}getCredentials(){var e=this;return Ae((function*(){return e.config.credentialsClient.getCredentials()}))()}getPublicKey(){var e=this;return Ae((function*(){return e.config.request(o.AUTH_PUBLIC_KEY,{method:"POST",body:{}})}))()}getEncryptParams(e){var t=this;return Ae((function*(){var{isEncrypt:r}=e;delete e.isEncrypt;var n=(0,v.I)(e),o=Ne(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 Ae((function*(){return e.config.request(n.GET_PROVIDER_TYPE,{method:"POST",body:{provider_id:"weda"}})}))()}verifyCaptchaData(e){var t=this;return Ae((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 Ae((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 Ae((function*(){return t.config.request(n.GET_MINIPROGRAM_QRCODE,{method:"POST",body:e})}))()}getMiniProgramQrCodeStatus(e){var t=this;return Ae((function*(){return t.config.request(n.GET_MINIPROGRAM_QRCODE_STATUS,{method:"POST",body:e})}))()}getUserBehaviorLog(e){var t=this;return Ae((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 Ae((function*(){var r="",o="",i=Ne(!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 Ae((function*(){var r="",n="",i=Ne(!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())}catch(e){}}}class qe extends Error{constructor(e){super(e.error_description||e.message),this.__isAuthError=!0,this.name="AuthError",this.status=e.error,this.code=e.error_code}}function xe(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 je(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?xe(Object(r),!0).forEach((function(t){Me(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):xe(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Me(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 Be{constructor(e){var{apiOrigin:t,apiPath:r=u,clientId:n,env:o,storage:i,request:s,baseRequest:a,anonymousSignInFunc:c,wxCloud:l,adapter:d,onCredentialsError:h,headers:f,i18n:p,useWxCloud:v,eventBus:y,detectSessionInUrl:g,debug:m}=e;this.detectSessionInUrl=null!=g&&g,this.oauth2client=new ue({apiOrigin:t,apiPath:r,clientId:n,env:o,storage:i,baseRequest:a||s,anonymousSignInFunc:c,wxCloud:l,onCredentialsError:h,headers:f||{},i18n:p,useWxCloud:v,eventBus:y,debug:m}),this.authApi=new De(je(je({credentialsClient:this.oauth2client},e),{},{request:s?this.oauth2client.request.bind(this.oauth2client):void 0,adapter:d})),g&&this.oauth2client.setGetInitialSession(this.authApi.getInitialSession.bind(this.authApi))}initializeSession(e){this.detectSessionInUrl?(this.oauth2client.setOnInitialSessionObtained(e),this.oauth2client.initialize()):this.oauth2client.initialize(Promise.resolve({error:null}))}}var We=r(794),Fe=r(141),He=r(197);function Ve(){}function ze(e){return"object"==typeof e&&null!==e||"function"==typeof e}const Ge=Ve;function Ke(e,t){try{Object.defineProperty(e,"name",{value:t,configurable:!0})}catch(e){}}const Ye=Promise,$e=Promise.resolve.bind(Ye),Qe=Promise.prototype.then,Je=Promise.reject.bind(Ye),Ze=$e;function Xe(e){return new Ye(e)}function et(e){return Xe((t=>t(e)))}function tt(e){return Je(e)}function rt(e,t,r){return Qe.call(e,t,r)}function nt(e,t,r){rt(rt(e,t,r),void 0,Ge)}function ot(e,t){nt(e,t)}function it(e,t){nt(e,void 0,t)}function st(e,t,r){return rt(e,t,r)}function at(e){rt(e,void 0,Ge)}let ut=e=>{if("function"==typeof queueMicrotask)ut=queueMicrotask;else{const e=et(void 0);ut=t=>rt(e,t)}return ut(e)};function ct(e,t,r){if("function"!=typeof e)throw new TypeError("Argument is not a function");return Function.prototype.apply.call(e,t,r)}function lt(e,t,r){try{return et(ct(e,t,r))}catch(e){return tt(e)}}class dt{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 ht=Symbol("[[AbortSteps]]"),ft=Symbol("[[ErrorSteps]]"),pt=Symbol("[[CancelSteps]]"),vt=Symbol("[[PullSteps]]"),yt=Symbol("[[ReleaseSteps]]");function gt(e,t){e._ownerReadableStream=t,t._reader=e,"readable"===t._state?wt(e):"closed"===t._state?function(e){wt(e),Tt(e)}(e):St(e,t._storedError)}function mt(e,t){return Ro(e._ownerReadableStream,t)}function _t(e){const t=e._ownerReadableStream;"readable"===t._state?It(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")):function(e){St(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness"))}(e),t._readableStreamController[yt](),t._reader=void 0,e._ownerReadableStream=void 0}function bt(e){return new TypeError("Cannot "+e+" a stream using a released reader")}function wt(e){e._closedPromise=Xe(((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r}))}function St(e,t){wt(e),It(e,t)}function It(e,t){void 0!==e._closedPromise_reject&&(at(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}function Tt(e){void 0!==e._closedPromise_resolve&&(e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}const Et=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},Ot=Math.trunc||function(e){return e<0?Math.ceil(e):Math.floor(e)};function Pt(e,t){if(void 0!==e&&"object"!=typeof(r=e)&&"function"!=typeof r)throw new TypeError(`${t} is not an object.`);var r}function Rt(e,t){if("function"!=typeof e)throw new TypeError(`${t} is not a function.`)}function Ct(e,t){if(!function(e){return"object"==typeof e&&null!==e||"function"==typeof e}(e))throw new TypeError(`${t} is not an object.`)}function At(e,t,r){if(void 0===e)throw new TypeError(`Parameter ${t} is required in '${r}'.`)}function Ut(e,t,r){if(void 0===e)throw new TypeError(`${t} is required in '${r}'.`)}function kt(e){return Number(e)}function Lt(e){return 0===e?0:e}function Nt(e,t){const r=Number.MAX_SAFE_INTEGER;let n=Number(e);if(n=Lt(n),!Et(n))throw new TypeError(`${t} is not a finite number`);if(n=function(e){return Lt(Ot(e))}(n),n<0||n>r)throw new TypeError(`${t} is outside the accepted range of 0 to ${r}, inclusive`);return Et(n)&&0!==n?n:0}function Dt(e,t){if(!Oo(e))throw new TypeError(`${t} is not a ReadableStream.`)}function qt(e){return new Wt(e)}function xt(e,t){e._reader._readRequests.push(t)}function jt(e,t,r){const n=e._reader._readRequests.shift();r?n._closeSteps():n._chunkSteps(t)}function Mt(e){return e._reader._readRequests.length}function Bt(e){const t=e._reader;return void 0!==t&&!!Ft(t)}class Wt{constructor(e){if(At(e,1,"ReadableStreamDefaultReader"),Dt(e,"First parameter"),Po(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");gt(this,e),this._readRequests=new dt}get closed(){return Ft(this)?this._closedPromise:tt(zt("closed"))}cancel(e=void 0){return Ft(this)?void 0===this._ownerReadableStream?tt(bt("cancel")):mt(this,e):tt(zt("cancel"))}read(){if(!Ft(this))return tt(zt("read"));if(void 0===this._ownerReadableStream)return tt(bt("read from"));let e,t;const r=Xe(((r,n)=>{e=r,t=n}));return Ht(this,{_chunkSteps:t=>e({value:t,done:!1}),_closeSteps:()=>e({value:void 0,done:!0}),_errorSteps:e=>t(e)}),r}releaseLock(){if(!Ft(this))throw zt("releaseLock");void 0!==this._ownerReadableStream&&function(e){_t(e),Vt(e,new TypeError("Reader was released"))}(this)}}function Ft(e){return!!ze(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readRequests")&&e instanceof Wt}function Ht(e,t){const r=e._ownerReadableStream;r._disturbed=!0,"closed"===r._state?t._closeSteps():"errored"===r._state?t._errorSteps(r._storedError):r._readableStreamController[vt](t)}function Vt(e,t){const r=e._readRequests;e._readRequests=new dt,r.forEach((e=>{e._errorSteps(t)}))}function zt(e){return new TypeError(`ReadableStreamDefaultReader.prototype.${e} can only be used on a ReadableStreamDefaultReader`)}var Gt,Kt,Yt;function $t(e){return e.slice()}function Qt(e,t,r,n,o){new Uint8Array(e).set(new Uint8Array(r,n,o),t)}Object.defineProperties(Wt.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),Ke(Wt.prototype.cancel,"cancel"),Ke(Wt.prototype.read,"read"),Ke(Wt.prototype.releaseLock,"releaseLock"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Wt.prototype,Symbol.toStringTag,{value:"ReadableStreamDefaultReader",configurable:!0});let Jt=e=>(Jt="function"==typeof e.transfer?e=>e.transfer():"function"==typeof structuredClone?e=>structuredClone(e,{transfer:[e]}):e=>e,Jt(e)),Zt=e=>(Zt="boolean"==typeof e.detached?e=>e.detached:e=>0===e.byteLength,Zt(e));function Xt(e,t,r){if(e.slice)return e.slice(t,r);const n=r-t,o=new ArrayBuffer(n);return Qt(o,0,e,t,n),o}function er(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 tr(e){try{const t=e.done,r=e.value;return rt(Ze(r),(e=>({done:t,value:e})))}catch(e){return tt(e)}}const rr=null!==(Yt=null!==(Gt=Symbol.asyncIterator)&&void 0!==Gt?Gt:null===(Kt=Symbol.for)||void 0===Kt?void 0:Kt.call(Symbol,"Symbol.asyncIterator"))&&void 0!==Yt?Yt:"@@asyncIterator";function nr(e,t="sync",r){if(void 0===r)if("async"===t){if(void 0===(r=er(e,rr)))return function(e){const t={next(){let t;try{t=or(e)}catch(e){return tt(e)}return tr(t)},return(t){let r;try{const n=er(e.iterator,"return");if(void 0===n)return et({done:!0,value:t});r=ct(n,e.iterator,[t])}catch(e){return tt(e)}return ze(r)?tr(r):tt(new TypeError("The iterator.return() method must return an object"))}};return{iterator:t,nextMethod:t.next,done:!1}}(nr(e,"sync",er(e,Symbol.iterator)))}else r=er(e,Symbol.iterator);if(void 0===r)throw new TypeError("The object is not iterable");const n=ct(r,e,[]);if(!ze(n))throw new TypeError("The iterator method must return an object");return{iterator:n,nextMethod:n.next,done:!1}}function or(e){const t=ct(e.nextMethod,e.iterator,[]);if(!ze(t))throw new TypeError("The iterator.next() method must return an object");return t}class ir{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?st(this._ongoingPromise,e,e):e(),this._ongoingPromise}return(e){const t=()=>this._returnSteps(e);return this._ongoingPromise?st(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=Xe(((e,n)=>{t=e,r=n}));return Ht(e,{_chunkSteps:e=>{this._ongoingPromise=void 0,ut((()=>t({value:e,done:!1})))},_closeSteps:()=>{this._ongoingPromise=void 0,this._isFinished=!0,_t(e),t({value:void 0,done:!0})},_errorSteps:t=>{this._ongoingPromise=void 0,this._isFinished=!0,_t(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=mt(t,e);return _t(t),st(r,(()=>({value:e,done:!0})))}return _t(t),et({value:e,done:!0})}}const sr={next(){return ar(this)?this._asyncIteratorImpl.next():tt(ur("next"))},return(e){return ar(this)?this._asyncIteratorImpl.return(e):tt(ur("return"))},[rr](){return this}};function ar(e){if(!ze(e))return!1;if(!Object.prototype.hasOwnProperty.call(e,"_asyncIteratorImpl"))return!1;try{return e._asyncIteratorImpl instanceof ir}catch(e){return!1}}function ur(e){return new TypeError(`ReadableStreamAsyncIterator.${e} can only be used on a ReadableSteamAsyncIterator`)}Object.defineProperty(sr,rr,{enumerable:!1});const cr=Number.isNaN||function(e){return e!=e};function lr(e){const t=Xt(e.buffer,e.byteOffset,e.byteOffset+e.byteLength);return new Uint8Array(t)}function dr(e){const t=e._queue.shift();return e._queueTotalSize-=t.size,e._queueTotalSize<0&&(e._queueTotalSize=0),t.value}function hr(e,t,r){if("number"!=typeof(n=r)||cr(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 fr(e){e._queue=new dt,e._queueTotalSize=0}function pr(e){return e===DataView}class vr{constructor(){throw new TypeError("Illegal constructor")}get view(){if(!mr(this))throw Hr("view");return this._view}respond(e){if(!mr(this))throw Hr("respond");if(At(e,1,"respond"),e=Nt(e,"First parameter"),void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");if(Zt(this._view.buffer))throw new TypeError("The BYOB request's buffer has been detached and so cannot be used as a response");Br(this._associatedReadableByteStreamController,e)}respondWithNewView(e){if(!mr(this))throw Hr("respondWithNewView");if(At(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(Zt(e.buffer))throw new TypeError("The given view's buffer has been detached and so cannot be used as a response");Wr(this._associatedReadableByteStreamController,e)}}Object.defineProperties(vr.prototype,{respond:{enumerable:!0},respondWithNewView:{enumerable:!0},view:{enumerable:!0}}),Ke(vr.prototype.respond,"respond"),Ke(vr.prototype.respondWithNewView,"respondWithNewView"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(vr.prototype,Symbol.toStringTag,{value:"ReadableStreamBYOBRequest",configurable:!0});class yr{constructor(){throw new TypeError("Illegal constructor")}get byobRequest(){if(!gr(this))throw Vr("byobRequest");return jr(this)}get desiredSize(){if(!gr(this))throw Vr("desiredSize");return Mr(this)}close(){if(!gr(this))throw Vr("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`);Nr(this)}enqueue(e){if(!gr(this))throw Vr("enqueue");if(At(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`);Dr(this,e)}error(e=void 0){if(!gr(this))throw Vr("error");qr(this,e)}[pt](e){br(this),fr(this);const t=this._cancelAlgorithm(e);return Lr(this),t}[vt](e){const t=this._controlledReadableByteStream;if(this._queueTotalSize>0)return void xr(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)}xt(t,e),_r(this)}[yt](){if(this._pendingPullIntos.length>0){const e=this._pendingPullIntos.peek();e.readerType="none",this._pendingPullIntos=new dt,this._pendingPullIntos.push(e)}}}function gr(e){return!!ze(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableByteStream")&&e instanceof yr}function mr(e){return!!ze(e)&&!!Object.prototype.hasOwnProperty.call(e,"_associatedReadableByteStreamController")&&e instanceof vr}function _r(e){const t=function(e){const t=e._controlledReadableByteStream;return"readable"===t._state&&(!e._closeRequested&&(!!e._started&&(!!(Bt(t)&&Mt(t)>0)||(!!($r(t)&&Yr(t)>0)||Mr(e)>0))))}(e);t&&(e._pulling?e._pullAgain=!0:(e._pulling=!0,nt(e._pullAlgorithm(),(()=>(e._pulling=!1,e._pullAgain&&(e._pullAgain=!1,_r(e)),null)),(t=>(qr(e,t),null)))))}function br(e){Cr(e),e._pendingPullIntos=new dt}function wr(e,t){let r=!1;"closed"===e._state&&(r=!0);const n=Sr(t);"default"===t.readerType?jt(e,n,r):function(e,t,r){const n=e._reader._readIntoRequests.shift();r?n._closeSteps(t):n._chunkSteps(t)}(e,n,r)}function Sr(e){const t=e.bytesFilled,r=e.elementSize;return new e.viewConstructor(e.buffer,e.byteOffset,t/r)}function Ir(e,t,r,n){e._queue.push({buffer:t,byteOffset:r,byteLength:n}),e._queueTotalSize+=n}function Tr(e,t,r,n){let o;try{o=Xt(t,r,r+n)}catch(t){throw qr(e,t),t}Ir(e,o,0,n)}function Er(e,t){t.bytesFilled>0&&Tr(e,t.buffer,t.byteOffset,t.bytesFilled),kr(e)}function Or(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;Qt(t.buffer,i,r.buffer,r.byteOffset,n),r.byteLength===n?a.shift():(r.byteOffset+=n,r.byteLength-=n),e._queueTotalSize-=n,Pr(0,n,t),o-=n}return i}function Pr(e,t,r){r.bytesFilled+=t}function Rr(e){0===e._queueTotalSize&&e._closeRequested?(Lr(e),Co(e._controlledReadableByteStream)):_r(e)}function Cr(e){null!==e._byobRequest&&(e._byobRequest._associatedReadableByteStreamController=void 0,e._byobRequest._view=null,e._byobRequest=null)}function Ar(e){for(;e._pendingPullIntos.length>0;){if(0===e._queueTotalSize)return;const t=e._pendingPullIntos.peek();Or(e,t)&&(kr(e),wr(e._controlledReadableByteStream,t))}}function Ur(e,t){const r=e._pendingPullIntos.peek();Cr(e),"closed"===e._controlledReadableByteStream._state?function(e,t){"none"===t.readerType&&kr(e);const r=e._controlledReadableByteStream;if($r(r))for(;Yr(r)>0;)wr(r,kr(e))}(e,r):function(e,t,r){if(Pr(0,t,r),"none"===r.readerType)return Er(e,r),void Ar(e);if(r.bytesFilled<r.minimumFill)return;kr(e);const n=r.bytesFilled%r.elementSize;if(n>0){const t=r.byteOffset+r.bytesFilled;Tr(e,r.buffer,t-n,n)}r.bytesFilled-=n,wr(e._controlledReadableByteStream,r),Ar(e)}(e,t,r),_r(e)}function kr(e){return e._pendingPullIntos.shift()}function Lr(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0}function Nr(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 qr(e,t),t}}Lr(e),Co(t)}}function Dr(e,t){const r=e._controlledReadableByteStream;if(e._closeRequested||"readable"!==r._state)return;const{buffer:n,byteOffset:o,byteLength:i}=t;if(Zt(n))throw new TypeError("chunk's buffer is detached and so cannot be enqueued");const s=Jt(n);if(e._pendingPullIntos.length>0){const t=e._pendingPullIntos.peek();if(Zt(t.buffer))throw new TypeError("The BYOB request's buffer has been detached and so cannot be filled with an enqueued chunk");Cr(e),t.buffer=Jt(t.buffer),"none"===t.readerType&&Er(e,t)}Bt(r)?(function(e){const t=e._controlledReadableByteStream._reader;for(;t._readRequests.length>0;){if(0===e._queueTotalSize)return;xr(e,t._readRequests.shift())}}(e),0===Mt(r)?Ir(e,s,o,i):(e._pendingPullIntos.length>0&&kr(e),jt(r,new Uint8Array(s,o,i),!1))):$r(r)?(Ir(e,s,o,i),Ar(e)):Ir(e,s,o,i),_r(e)}function qr(e,t){const r=e._controlledReadableByteStream;"readable"===r._state&&(br(e),fr(e),Lr(e),Ao(r,t))}function xr(e,t){const r=e._queue.shift();e._queueTotalSize-=r.byteLength,Rr(e);const n=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);t._chunkSteps(n)}function jr(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(vr.prototype);!function(e,t,r){e._associatedReadableByteStreamController=t,e._view=r}(n,e,r),e._byobRequest=n}return e._byobRequest}function Mr(e){const t=e._controlledReadableByteStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function Br(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=Jt(r.buffer),Ur(e,t)}function Wr(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=Jt(t.buffer),Ur(e,n)}function Fr(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,fr(t),t._closeRequested=!1,t._started=!1,t._strategyHWM=i,t._pullAlgorithm=n,t._cancelAlgorithm=o,t._autoAllocateChunkSize=s,t._pendingPullIntos=new dt,e._readableStreamController=t,nt(et(r()),(()=>(t._started=!0,_r(t),null)),(e=>(qr(t,e),null)))}function Hr(e){return new TypeError(`ReadableStreamBYOBRequest.prototype.${e} can only be used on a ReadableStreamBYOBRequest`)}function Vr(e){return new TypeError(`ReadableByteStreamController.prototype.${e} can only be used on a ReadableByteStreamController`)}function zr(e,t){if("byob"!=(e=`${e}`))throw new TypeError(`${t} '${e}' is not a valid enumeration value for ReadableStreamReaderMode`);return e}function Gr(e){return new Qr(e)}function Kr(e,t){e._reader._readIntoRequests.push(t)}function Yr(e){return e._reader._readIntoRequests.length}function $r(e){const t=e._reader;return void 0!==t&&!!Jr(t)}Object.defineProperties(yr.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},byobRequest:{enumerable:!0},desiredSize:{enumerable:!0}}),Ke(yr.prototype.close,"close"),Ke(yr.prototype.enqueue,"enqueue"),Ke(yr.prototype.error,"error"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(yr.prototype,Symbol.toStringTag,{value:"ReadableByteStreamController",configurable:!0});class Qr{constructor(e){if(At(e,1,"ReadableStreamBYOBReader"),Dt(e,"First parameter"),Po(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");if(!gr(e._readableStreamController))throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");gt(this,e),this._readIntoRequests=new dt}get closed(){return Jr(this)?this._closedPromise:tt(en("closed"))}cancel(e=void 0){return Jr(this)?void 0===this._ownerReadableStream?tt(bt("cancel")):mt(this,e):tt(en("cancel"))}read(e,t={}){if(!Jr(this))return tt(en("read"));if(!ArrayBuffer.isView(e))return tt(new TypeError("view must be an array buffer view"));if(0===e.byteLength)return tt(new TypeError("view must have non-zero byteLength"));if(0===e.buffer.byteLength)return tt(new TypeError("view's buffer must have non-zero byteLength"));if(Zt(e.buffer))return tt(new TypeError("view's buffer has been detached"));let r;try{r=function(e,t){var r;return Pt(e,t),{min:Nt(null!==(r=null==e?void 0:e.min)&&void 0!==r?r:1,`${t} has member 'min' that`)}}(t,"options")}catch(e){return tt(e)}const n=r.min;if(0===n)return tt(new TypeError("options.min must be greater than 0"));if(function(e){return pr(e.constructor)}(e)){if(n>e.byteLength)return tt(new RangeError("options.min must be less than or equal to view's byteLength"))}else if(n>e.length)return tt(new RangeError("options.min must be less than or equal to view's length"));if(void 0===this._ownerReadableStream)return tt(bt("read from"));let o,i;const s=Xe(((e,t)=>{o=e,i=t}));return Zr(this,e,n,{_chunkSteps:e=>o({value:e,done:!1}),_closeSteps:e=>o({value:e,done:!0}),_errorSteps:e=>i(e)}),s}releaseLock(){if(!Jr(this))throw en("releaseLock");void 0!==this._ownerReadableStream&&function(e){_t(e),Xr(e,new TypeError("Reader was released"))}(this)}}function Jr(e){return!!ze(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readIntoRequests")&&e instanceof Qr}function Zr(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 pr(e)?1:e.BYTES_PER_ELEMENT}(i),{byteOffset:a,byteLength:u}=t,c=r*s;let l;try{l=Jt(t.buffer)}catch(e){return void n._errorSteps(e)}const d={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(d),void Kr(o,n);if("closed"!==o._state){if(e._queueTotalSize>0){if(Or(e,d)){const t=Sr(d);return Rr(e),void n._chunkSteps(t)}if(e._closeRequested){const t=new TypeError("Insufficient bytes to fill elements in the given buffer");return qr(e,t),void n._errorSteps(t)}}e._pendingPullIntos.push(d),Kr(o,n),_r(e)}else{const e=new i(d.buffer,d.byteOffset,0);n._closeSteps(e)}}(o._readableStreamController,t,r,n)}function Xr(e,t){const r=e._readIntoRequests;e._readIntoRequests=new dt,r.forEach((e=>{e._errorSteps(t)}))}function en(e){return new TypeError(`ReadableStreamBYOBReader.prototype.${e} can only be used on a ReadableStreamBYOBReader`)}function tn(e,t){const{highWaterMark:r}=e;if(void 0===r)return t;if(cr(r)||r<0)throw new RangeError("Invalid highWaterMark");return r}function rn(e){const{size:t}=e;return t||(()=>1)}function nn(e,t){Pt(e,t);const r=null==e?void 0:e.highWaterMark,n=null==e?void 0:e.size;return{highWaterMark:void 0===r?void 0:kt(r),size:void 0===n?void 0:on(n,`${t} has member 'size' that`)}}function on(e,t){return Rt(e,t),t=>kt(e(t))}function sn(e,t,r){return Rt(e,r),r=>lt(e,t,[r])}function an(e,t,r){return Rt(e,r),()=>lt(e,t,[])}function un(e,t,r){return Rt(e,r),r=>ct(e,t,[r])}function cn(e,t,r){return Rt(e,r),(r,n)=>lt(e,t,[r,n])}function ln(e,t){if(!vn(e))throw new TypeError(`${t} is not a WritableStream.`)}Object.defineProperties(Qr.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),Ke(Qr.prototype.cancel,"cancel"),Ke(Qr.prototype.read,"read"),Ke(Qr.prototype.releaseLock,"releaseLock"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Qr.prototype,Symbol.toStringTag,{value:"ReadableStreamBYOBReader",configurable:!0});const dn="function"==typeof AbortController;class hn{constructor(e={},t={}){void 0===e?e=null:Ct(e,"First parameter");const r=nn(t,"Second parameter"),n=function(e,t){Pt(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:sn(r,e,`${t} has member 'abort' that`),close:void 0===n?void 0:an(n,e,`${t} has member 'close' that`),start:void 0===o?void 0:un(o,e,`${t} has member 'start' that`),write:void 0===s?void 0:cn(s,e,`${t} has member 'write' that`),type:i}}(e,"First parameter");if(pn(this),void 0!==n.type)throw new RangeError("Invalid type is specified");const o=rn(r);!function(e,t,r,n){const o=Object.create(kn.prototype);let i,s,a,u;i=void 0!==t.start?()=>t.start(o):()=>{},s=void 0!==t.write?e=>t.write(e,o):()=>et(void 0),a=void 0!==t.close?()=>t.close():()=>et(void 0),u=void 0!==t.abort?e=>t.abort(e):()=>et(void 0),Nn(e,o,i,s,a,u,r,n)}(this,n,tn(r,1),o)}get locked(){if(!vn(this))throw Wn("locked");return yn(this)}abort(e=void 0){return vn(this)?yn(this)?tt(new TypeError("Cannot abort a stream that already has a writer")):gn(this,e):tt(Wn("abort"))}close(){return vn(this)?yn(this)?tt(new TypeError("Cannot close a stream that already has a writer")):Sn(this)?tt(new TypeError("Cannot close an already-closing stream")):mn(this):tt(Wn("close"))}getWriter(){if(!vn(this))throw Wn("getWriter");return fn(this)}}function fn(e){return new En(e)}function pn(e){e._state="writable",e._storedError=void 0,e._writer=void 0,e._writableStreamController=void 0,e._writeRequests=new dt,e._inFlightWriteRequest=void 0,e._closeRequest=void 0,e._inFlightCloseRequest=void 0,e._pendingAbortRequest=void 0,e._backpressure=!1}function vn(e){return!!ze(e)&&!!Object.prototype.hasOwnProperty.call(e,"_writableStreamController")&&e instanceof hn}function yn(e){return void 0!==e._writer}function gn(e,t){var r;if("closed"===e._state||"errored"===e._state)return et(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 et(void 0);if(void 0!==e._pendingAbortRequest)return e._pendingAbortRequest._promise;let o=!1;"erroring"===n&&(o=!0,t=void 0);const i=Xe(((r,n)=>{e._pendingAbortRequest={_promise:void 0,_resolve:r,_reject:n,_reason:t,_wasAlreadyErroring:o}}));return e._pendingAbortRequest._promise=i,o||bn(e,t),i}function mn(e){const t=e._state;if("closed"===t||"errored"===t)return tt(new TypeError(`The stream (in ${t} state) is not in the writable state and cannot be closed`));const r=Xe(((t,r)=>{const n={_resolve:t,_reject:r};e._closeRequest=n})),n=e._writer;var o;return void 0!==n&&e._backpressure&&"writable"===t&&Xn(n),hr(o=e._writableStreamController,Un,0),xn(o),r}function _n(e,t){"writable"!==e._state?wn(e):bn(e,t)}function bn(e,t){const r=e._writableStreamController;e._state="erroring",e._storedError=t;const n=e._writer;void 0!==n&&Rn(n,t),!function(e){return void 0!==e._inFlightWriteRequest||void 0!==e._inFlightCloseRequest}(e)&&r._started&&wn(e)}function wn(e){e._state="errored",e._writableStreamController[ft]();const t=e._storedError;if(e._writeRequests.forEach((e=>{e._reject(t)})),e._writeRequests=new dt,void 0===e._pendingAbortRequest)return void In(e);const r=e._pendingAbortRequest;if(e._pendingAbortRequest=void 0,r._wasAlreadyErroring)return r._reject(t),void In(e);nt(e._writableStreamController[ht](r._reason),(()=>(r._resolve(),In(e),null)),(t=>(r._reject(t),In(e),null)))}function Sn(e){return void 0!==e._closeRequest||void 0!==e._inFlightCloseRequest}function In(e){void 0!==e._closeRequest&&(e._closeRequest._reject(e._storedError),e._closeRequest=void 0);const t=e._writer;void 0!==t&&Kn(t,e._storedError)}function Tn(e,t){const r=e._writer;void 0!==r&&t!==e._backpressure&&(t?function(e){$n(e)}(r):Xn(r)),e._backpressure=t}Object.defineProperties(hn.prototype,{abort:{enumerable:!0},close:{enumerable:!0},getWriter:{enumerable:!0},locked:{enumerable:!0}}),Ke(hn.prototype.abort,"abort"),Ke(hn.prototype.close,"close"),Ke(hn.prototype.getWriter,"getWriter"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(hn.prototype,Symbol.toStringTag,{value:"WritableStream",configurable:!0});class En{constructor(e){if(At(e,1,"WritableStreamDefaultWriter"),ln(e,"First parameter"),yn(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)!Sn(e)&&e._backpressure?$n(this):Jn(this),zn(this);else if("erroring"===t)Qn(this,e._storedError),zn(this);else if("closed"===t)Jn(this),zn(this),Yn(this);else{const t=e._storedError;Qn(this,t),Gn(this,t)}}get closed(){return On(this)?this._closedPromise:tt(Hn("closed"))}get desiredSize(){if(!On(this))throw Hn("desiredSize");if(void 0===this._ownerWritableStream)throw Vn("desiredSize");return function(e){const t=e._ownerWritableStream,r=t._state;return"errored"===r||"erroring"===r?null:"closed"===r?0:qn(t._writableStreamController)}(this)}get ready(){return On(this)?this._readyPromise:tt(Hn("ready"))}abort(e=void 0){return On(this)?void 0===this._ownerWritableStream?tt(Vn("abort")):function(e,t){return gn(e._ownerWritableStream,t)}(this,e):tt(Hn("abort"))}close(){if(!On(this))return tt(Hn("close"));const e=this._ownerWritableStream;return void 0===e?tt(Vn("close")):Sn(e)?tt(new TypeError("Cannot close an already-closing stream")):Pn(this)}releaseLock(){if(!On(this))throw Hn("releaseLock");void 0!==this._ownerWritableStream&&Cn(this)}write(e=void 0){return On(this)?void 0===this._ownerWritableStream?tt(Vn("write to")):An(this,e):tt(Hn("write"))}}function On(e){return!!ze(e)&&!!Object.prototype.hasOwnProperty.call(e,"_ownerWritableStream")&&e instanceof En}function Pn(e){return mn(e._ownerWritableStream)}function Rn(e,t){"pending"===e._readyPromiseState?Zn(e,t):function(e,t){Qn(e,t)}(e,t)}function Cn(e){const t=e._ownerWritableStream,r=new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");Rn(e,r),function(e,t){"pending"===e._closedPromiseState?Kn(e,t):function(e,t){Gn(e,t)}(e,t)}(e,r),t._writer=void 0,e._ownerWritableStream=void 0}function An(e,t){const r=e._ownerWritableStream,n=r._writableStreamController,o=function(e,t){try{return e._strategySizeAlgorithm(t)}catch(t){return jn(e,t),1}}(n,t);if(r!==e._ownerWritableStream)return tt(Vn("write to"));const i=r._state;if("errored"===i)return tt(r._storedError);if(Sn(r)||"closed"===i)return tt(new TypeError("The stream is closing or closed and cannot be written to"));if("erroring"===i)return tt(r._storedError);const s=function(e){return Xe(((t,r)=>{const n={_resolve:t,_reject:r};e._writeRequests.push(n)}))}(r);return function(e,t,r){try{hr(e,t,r)}catch(t){return void jn(e,t)}const n=e._controlledWritableStream;Sn(n)||"writable"!==n._state||Tn(n,Mn(e)),xn(e)}(n,t,o),s}Object.defineProperties(En.prototype,{abort:{enumerable:!0},close:{enumerable:!0},releaseLock:{enumerable:!0},write:{enumerable:!0},closed:{enumerable:!0},desiredSize:{enumerable:!0},ready:{enumerable:!0}}),Ke(En.prototype.abort,"abort"),Ke(En.prototype.close,"close"),Ke(En.prototype.releaseLock,"releaseLock"),Ke(En.prototype.write,"write"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(En.prototype,Symbol.toStringTag,{value:"WritableStreamDefaultWriter",configurable:!0});const Un={};class kn{constructor(){throw new TypeError("Illegal constructor")}get abortReason(){if(!Ln(this))throw Fn("abortReason");return this._abortReason}get signal(){if(!Ln(this))throw Fn("signal");if(void 0===this._abortController)throw new TypeError("WritableStreamDefaultController.prototype.signal is not supported");return this._abortController.signal}error(e=void 0){if(!Ln(this))throw Fn("error");"writable"===this._controlledWritableStream._state&&Bn(this,e)}[ht](e){const t=this._abortAlgorithm(e);return Dn(this),t}[ft](){fr(this)}}function Ln(e){return!!ze(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledWritableStream")&&e instanceof kn}function Nn(e,t,r,n,o,i,s,a){t._controlledWritableStream=e,e._writableStreamController=t,t._queue=void 0,t._queueTotalSize=void 0,fr(t),t._abortReason=void 0,t._abortController=function(){if(dn)return new AbortController}(),t._started=!1,t._strategySizeAlgorithm=a,t._strategyHWM=s,t._writeAlgorithm=n,t._closeAlgorithm=o,t._abortAlgorithm=i;const u=Mn(t);Tn(e,u),nt(et(r()),(()=>(t._started=!0,xn(t),null)),(r=>(t._started=!0,_n(e,r),null)))}function Dn(e){e._writeAlgorithm=void 0,e._closeAlgorithm=void 0,e._abortAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function qn(e){return e._strategyHWM-e._queueTotalSize}function xn(e){const t=e._controlledWritableStream;if(!e._started)return;if(void 0!==t._inFlightWriteRequest)return;if("erroring"===t._state)return void wn(t);if(0===e._queue.length)return;const r=e._queue.peek().value;r===Un?function(e){const t=e._controlledWritableStream;(function(e){e._inFlightCloseRequest=e._closeRequest,e._closeRequest=void 0})(t),dr(e);const r=e._closeAlgorithm();Dn(e),nt(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&&Yn(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),_n(e,t)}(t,e),null)))}(e):function(e,t){const r=e._controlledWritableStream;!function(e){e._inFlightWriteRequest=e._writeRequests.shift()}(r),nt(e._writeAlgorithm(t),(()=>{!function(e){e._inFlightWriteRequest._resolve(void 0),e._inFlightWriteRequest=void 0}(r);const t=r._state;if(dr(e),!Sn(r)&&"writable"===t){const t=Mn(e);Tn(r,t)}return xn(e),null}),(t=>("writable"===r._state&&Dn(e),function(e,t){e._inFlightWriteRequest._reject(t),e._inFlightWriteRequest=void 0,_n(e,t)}(r,t),null)))}(e,r)}function jn(e,t){"writable"===e._controlledWritableStream._state&&Bn(e,t)}function Mn(e){return qn(e)<=0}function Bn(e,t){const r=e._controlledWritableStream;Dn(e),bn(r,t)}function Wn(e){return new TypeError(`WritableStream.prototype.${e} can only be used on a WritableStream`)}function Fn(e){return new TypeError(`WritableStreamDefaultController.prototype.${e} can only be used on a WritableStreamDefaultController`)}function Hn(e){return new TypeError(`WritableStreamDefaultWriter.prototype.${e} can only be used on a WritableStreamDefaultWriter`)}function Vn(e){return new TypeError("Cannot "+e+" a stream using a released writer")}function zn(e){e._closedPromise=Xe(((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r,e._closedPromiseState="pending"}))}function Gn(e,t){zn(e),Kn(e,t)}function Kn(e,t){void 0!==e._closedPromise_reject&&(at(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="rejected")}function Yn(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 $n(e){e._readyPromise=Xe(((t,r)=>{e._readyPromise_resolve=t,e._readyPromise_reject=r})),e._readyPromiseState="pending"}function Qn(e,t){$n(e),Zn(e,t)}function Jn(e){$n(e),Xn(e)}function Zn(e,t){void 0!==e._readyPromise_reject&&(at(e._readyPromise),e._readyPromise_reject(t),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="rejected")}function Xn(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(kn.prototype,{abortReason:{enumerable:!0},signal:{enumerable:!0},error:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(kn.prototype,Symbol.toStringTag,{value:"WritableStreamDefaultController",configurable:!0});const eo="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof global?global:void 0,to=function(){const e=null==eo?void 0:eo.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 Ke(e,"DOMException"),e.prototype=Object.create(Error.prototype),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,configurable:!0}),e}();function ro(e,t,r,n,o,i){const s=qt(e),a=fn(t);e._disturbed=!0;let u=!1,c=et(void 0);return Xe(((l,d)=>{let h;if(void 0!==i){if(h=()=>{const r=void 0!==i.reason?i.reason:new to("Aborted","AbortError"),s=[];n||s.push((()=>"writable"===t._state?gn(t,r):et(void 0))),o||s.push((()=>"readable"===e._state?Ro(e,r):et(void 0))),m((()=>Promise.all(s.map((e=>e())))),!0,r)},i.aborted)return void h();i.addEventListener("abort",h)}var f,p,v;if(g(e,s._closedPromise,(e=>(n?_(!0,e):m((()=>gn(t,e)),!0,e),null))),g(t,a._closedPromise,(t=>(o?_(!0,t):m((()=>Ro(e,t)),!0,t),null))),f=e,p=s._closedPromise,v=()=>(r?_():m((()=>function(e){const t=e._ownerWritableStream,r=t._state;return Sn(t)||"closed"===r?et(void 0):"errored"===r?tt(t._storedError):Pn(e)}(a))),null),"closed"===f._state?v():ot(p,v),Sn(t)||"closed"===t._state){const t=new TypeError("the destination writable stream closed before all data could be piped to it");o?_(!0,t):m((()=>Ro(e,t)),!0,t)}function y(){const e=c;return rt(c,(()=>e!==c?y():void 0))}function g(e,t,r){"errored"===e._state?r(e._storedError):it(t,r)}function m(e,r,n){function o(){return nt(e(),(()=>b(r,n)),(e=>b(!0,e))),null}u||(u=!0,"writable"!==t._state||Sn(t)?o():ot(y(),o))}function _(e,r){u||(u=!0,"writable"!==t._state||Sn(t)?b(e,r):ot(y(),(()=>b(e,r))))}function b(e,t){return Cn(a),_t(s),void 0!==i&&i.removeEventListener("abort",h),e?d(t):l(void 0),null}at(Xe(((e,t)=>{!function r(n){n?e():rt(u?et(!0):rt(a._readyPromise,(()=>Xe(((e,t)=>{Ht(s,{_chunkSteps:t=>{c=rt(An(a,t),void 0,Ve),e(!1)},_closeSteps:()=>e(!0),_errorSteps:t})})))),r,t)}(!1)})))}))}class no{constructor(){throw new TypeError("Illegal constructor")}get desiredSize(){if(!oo(this))throw vo("desiredSize");return ho(this)}close(){if(!oo(this))throw vo("close");if(!fo(this))throw new TypeError("The stream is not in a state that permits close");uo(this)}enqueue(e=void 0){if(!oo(this))throw vo("enqueue");if(!fo(this))throw new TypeError("The stream is not in a state that permits enqueue");return co(this,e)}error(e=void 0){if(!oo(this))throw vo("error");lo(this,e)}[pt](e){fr(this);const t=this._cancelAlgorithm(e);return ao(this),t}[vt](e){const t=this._controlledReadableStream;if(this._queue.length>0){const r=dr(this);this._closeRequested&&0===this._queue.length?(ao(this),Co(t)):io(this),e._chunkSteps(r)}else xt(t,e),io(this)}[yt](){}}function oo(e){return!!ze(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableStream")&&e instanceof no}function io(e){so(e)&&(e._pulling?e._pullAgain=!0:(e._pulling=!0,nt(e._pullAlgorithm(),(()=>(e._pulling=!1,e._pullAgain&&(e._pullAgain=!1,io(e)),null)),(t=>(lo(e,t),null)))))}function so(e){const t=e._controlledReadableStream;return!!fo(e)&&!!e._started&&(!!(Po(t)&&Mt(t)>0)||ho(e)>0)}function ao(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function uo(e){if(!fo(e))return;const t=e._controlledReadableStream;e._closeRequested=!0,0===e._queue.length&&(ao(e),Co(t))}function co(e,t){if(!fo(e))return;const r=e._controlledReadableStream;if(Po(r)&&Mt(r)>0)jt(r,t,!1);else{let r;try{r=e._strategySizeAlgorithm(t)}catch(t){throw lo(e,t),t}try{hr(e,t,r)}catch(t){throw lo(e,t),t}}io(e)}function lo(e,t){const r=e._controlledReadableStream;"readable"===r._state&&(fr(e),ao(e),Ao(r,t))}function ho(e){const t=e._controlledReadableStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function fo(e){const t=e._controlledReadableStream._state;return!e._closeRequested&&"readable"===t}function po(e,t,r,n,o,i,s){t._controlledReadableStream=e,t._queue=void 0,t._queueTotalSize=void 0,fr(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,nt(et(r()),(()=>(t._started=!0,io(t),null)),(e=>(lo(t,e),null)))}function vo(e){return new TypeError(`ReadableStreamDefaultController.prototype.${e} can only be used on a ReadableStreamDefaultController`)}function yo(e){return ze(t=e)&&void 0!==t.getReader?function(e){let t;return t=Io(Ve,(function(){let r;try{r=e.read()}catch(r){return tt(r)}return st(r,(e=>{if(!ze(e))throw new TypeError("The promise returned by the reader.read() method must fulfill with an object");if(e.done)uo(t._readableStreamController);else{const r=e.value;co(t._readableStreamController,r)}}))}),(function(t){try{return et(e.cancel(t))}catch(t){return tt(t)}}),0),t}(e.getReader()):function(e){let t;const r=nr(e,"async");return t=Io(Ve,(function(){let e;try{e=or(r)}catch(e){return tt(e)}return st(et(e),(e=>{if(!ze(e))throw new TypeError("The promise returned by the iterator.next() method must fulfill with an object");if(e.done)uo(t._readableStreamController);else{const r=e.value;co(t._readableStreamController,r)}}))}),(function(e){const t=r.iterator;let n;try{n=er(t,"return")}catch(e){return tt(e)}return void 0===n?et(void 0):st(lt(n,t,[e]),(e=>{if(!ze(e))throw new TypeError("The promise returned by the iterator.return() method must fulfill with an object")}))}),0),t}(e);var t}function go(e,t,r){return Rt(e,r),r=>lt(e,t,[r])}function mo(e,t,r){return Rt(e,r),r=>lt(e,t,[r])}function _o(e,t,r){return Rt(e,r),r=>ct(e,t,[r])}function bo(e,t){if("bytes"!=(e=`${e}`))throw new TypeError(`${t} '${e}' is not a valid enumeration value for ReadableStreamType`);return e}function wo(e,t){Pt(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(no.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},desiredSize:{enumerable:!0}}),Ke(no.prototype.close,"close"),Ke(no.prototype.enqueue,"enqueue"),Ke(no.prototype.error,"error"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(no.prototype,Symbol.toStringTag,{value:"ReadableStreamDefaultController",configurable:!0});class So{constructor(e={},t={}){void 0===e?e=null:Ct(e,"First parameter");const r=nn(t,"Second parameter"),n=function(e,t){Pt(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:Nt(n,`${t} has member 'autoAllocateChunkSize' that`),cancel:void 0===o?void 0:go(o,r,`${t} has member 'cancel' that`),pull:void 0===i?void 0:mo(i,r,`${t} has member 'pull' that`),start:void 0===s?void 0:_o(s,r,`${t} has member 'start' that`),type:void 0===a?void 0:bo(a,`${t} has member 'type' that`)}}(e,"First parameter");if(Eo(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(yr.prototype);let o,i,s;o=void 0!==t.start?()=>t.start(n):()=>{},i=void 0!==t.pull?()=>t.pull(n):()=>et(void 0),s=void 0!==t.cancel?e=>t.cancel(e):()=>et(void 0);const a=t.autoAllocateChunkSize;if(0===a)throw new TypeError("autoAllocateChunkSize must be greater than 0");Fr(e,n,o,i,s,r,a)}(this,n,tn(r,0))}else{const e=rn(r);!function(e,t,r,n){const o=Object.create(no.prototype);let i,s,a;i=void 0!==t.start?()=>t.start(o):()=>{},s=void 0!==t.pull?()=>t.pull(o):()=>et(void 0),a=void 0!==t.cancel?e=>t.cancel(e):()=>et(void 0),po(e,o,i,s,a,r,n)}(this,n,tn(r,1),e)}}get locked(){if(!Oo(this))throw Uo("locked");return Po(this)}cancel(e=void 0){return Oo(this)?Po(this)?tt(new TypeError("Cannot cancel a stream that already has a reader")):Ro(this,e):tt(Uo("cancel"))}getReader(e=void 0){if(!Oo(this))throw Uo("getReader");return void 0===function(e,t){Pt(e,t);const r=null==e?void 0:e.mode;return{mode:void 0===r?void 0:zr(r,`${t} has member 'mode' that`)}}(e,"First parameter").mode?qt(this):Gr(this)}pipeThrough(e,t={}){if(!Oo(this))throw Uo("pipeThrough");At(e,1,"pipeThrough");const r=function(e,t){Pt(e,t);const r=null==e?void 0:e.readable;Ut(r,"readable","ReadableWritablePair"),Dt(r,`${t} has member 'readable' that`);const n=null==e?void 0:e.writable;return Ut(n,"writable","ReadableWritablePair"),ln(n,`${t} has member 'writable' that`),{readable:r,writable:n}}(e,"First parameter"),n=wo(t,"Second parameter");if(Po(this))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream");if(yn(r.writable))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream");return at(ro(this,r.writable,n.preventClose,n.preventAbort,n.preventCancel,n.signal)),r.readable}pipeTo(e,t={}){if(!Oo(this))return tt(Uo("pipeTo"));if(void 0===e)return tt("Parameter 1 is required in 'pipeTo'.");if(!vn(e))return tt(new TypeError("ReadableStream.prototype.pipeTo's first argument must be a WritableStream"));let r;try{r=wo(t,"Second parameter")}catch(e){return tt(e)}return Po(this)?tt(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream")):yn(e)?tt(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream")):ro(this,e,r.preventClose,r.preventAbort,r.preventCancel,r.signal)}tee(){if(!Oo(this))throw Uo("tee");return $t(function(e){return gr(e._readableStreamController)?function(e){let t,r,n,o,i,s=qt(e),a=!1,u=!1,c=!1,l=!1,d=!1;const h=Xe((e=>{i=e}));function f(e){it(e._closedPromise,(t=>(e!==s||(qr(n._readableStreamController,t),qr(o._readableStreamController,t),l&&d||i(void 0)),null)))}function p(){Jr(s)&&(_t(s),s=qt(e),f(s)),Ht(s,{_chunkSteps:t=>{ut((()=>{u=!1,c=!1;const r=t;let s=t;if(!l&&!d)try{s=lr(t)}catch(t){return qr(n._readableStreamController,t),qr(o._readableStreamController,t),void i(Ro(e,t))}l||Dr(n._readableStreamController,r),d||Dr(o._readableStreamController,s),a=!1,u?y():c&&g()}))},_closeSteps:()=>{a=!1,l||Nr(n._readableStreamController),d||Nr(o._readableStreamController),n._readableStreamController._pendingPullIntos.length>0&&Br(n._readableStreamController,0),o._readableStreamController._pendingPullIntos.length>0&&Br(o._readableStreamController,0),l&&d||i(void 0)},_errorSteps:()=>{a=!1}})}function v(t,r){Ft(s)&&(_t(s),s=Gr(e),f(s));const h=r?o:n,p=r?n:o;Zr(s,t,1,{_chunkSteps:t=>{ut((()=>{u=!1,c=!1;const n=r?d:l;if(r?l:d)n||Wr(h._readableStreamController,t);else{let r;try{r=lr(t)}catch(t){return qr(h._readableStreamController,t),qr(p._readableStreamController,t),void i(Ro(e,t))}n||Wr(h._readableStreamController,t),Dr(p._readableStreamController,r)}a=!1,u?y():c&&g()}))},_closeSteps:e=>{a=!1;const t=r?d:l,n=r?l:d;t||Nr(h._readableStreamController),n||Nr(p._readableStreamController),void 0!==e&&(t||Wr(h._readableStreamController,e),!n&&p._readableStreamController._pendingPullIntos.length>0&&Br(p._readableStreamController,0)),t&&n||i(void 0)},_errorSteps:()=>{a=!1}})}function y(){if(a)return u=!0,et(void 0);a=!0;const e=jr(n._readableStreamController);return null===e?p():v(e._view,!1),et(void 0)}function g(){if(a)return c=!0,et(void 0);a=!0;const e=jr(o._readableStreamController);return null===e?p():v(e._view,!0),et(void 0)}function m(){}return n=To(m,y,(function(n){if(l=!0,t=n,d){const n=$t([t,r]),o=Ro(e,n);i(o)}return h})),o=To(m,g,(function(n){if(d=!0,r=n,l){const n=$t([t,r]),o=Ro(e,n);i(o)}return h})),f(s),[n,o]}(e):function(e){const t=qt(e);let r,n,o,i,s,a=!1,u=!1,c=!1,l=!1;const d=Xe((e=>{s=e}));function h(){return a?(u=!0,et(void 0)):(a=!0,Ht(t,{_chunkSteps:e=>{ut((()=>{u=!1;const t=e,r=e;c||co(o._readableStreamController,t),l||co(i._readableStreamController,r),a=!1,u&&h()}))},_closeSteps:()=>{a=!1,c||uo(o._readableStreamController),l||uo(i._readableStreamController),c&&l||s(void 0)},_errorSteps:()=>{a=!1}}),et(void 0))}function f(){}return o=Io(f,h,(function(t){if(c=!0,r=t,l){const t=$t([r,n]),o=Ro(e,t);s(o)}return d})),i=Io(f,h,(function(t){if(l=!0,n=t,c){const t=$t([r,n]),o=Ro(e,t);s(o)}return d})),it(t._closedPromise,(e=>(lo(o._readableStreamController,e),lo(i._readableStreamController,e),c&&l||s(void 0),null))),[o,i]}(e)}(this))}values(e=void 0){if(!Oo(this))throw Uo("values");return function(e,t){const r=qt(e),n=new ir(r,t),o=Object.create(sr);return o._asyncIteratorImpl=n,o}(this,function(e){Pt(e,"First parameter");const t=null==e?void 0:e.preventCancel;return{preventCancel:Boolean(t)}}(e).preventCancel)}[rr](e){return this.values(e)}static from(e){return yo(e)}}function Io(e,t,r,n=1,o=()=>1){const i=Object.create(So.prototype);return Eo(i),po(i,Object.create(no.prototype),e,t,r,n,o),i}function To(e,t,r){const n=Object.create(So.prototype);return Eo(n),Fr(n,Object.create(yr.prototype),e,t,r,0,void 0),n}function Eo(e){e._state="readable",e._reader=void 0,e._storedError=void 0,e._disturbed=!1}function Oo(e){return!!ze(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readableStreamController")&&e instanceof So}function Po(e){return void 0!==e._reader}function Ro(e,t){if(e._disturbed=!0,"closed"===e._state)return et(void 0);if("errored"===e._state)return tt(e._storedError);Co(e);const r=e._reader;if(void 0!==r&&Jr(r)){const e=r._readIntoRequests;r._readIntoRequests=new dt,e.forEach((e=>{e._closeSteps(void 0)}))}return st(e._readableStreamController[pt](t),Ve)}function Co(e){e._state="closed";const t=e._reader;if(void 0!==t&&(Tt(t),Ft(t))){const e=t._readRequests;t._readRequests=new dt,e.forEach((e=>{e._closeSteps()}))}}function Ao(e,t){e._state="errored",e._storedError=t;const r=e._reader;void 0!==r&&(It(r,t),Ft(r)?Vt(r,t):Xr(r,t))}function Uo(e){return new TypeError(`ReadableStream.prototype.${e} can only be used on a ReadableStream`)}function ko(e,t){Pt(e,t);const r=null==e?void 0:e.highWaterMark;return Ut(r,"highWaterMark","QueuingStrategyInit"),{highWaterMark:kt(r)}}Object.defineProperties(So,{from:{enumerable:!0}}),Object.defineProperties(So.prototype,{cancel:{enumerable:!0},getReader:{enumerable:!0},pipeThrough:{enumerable:!0},pipeTo:{enumerable:!0},tee:{enumerable:!0},values:{enumerable:!0},locked:{enumerable:!0}}),Ke(So.from,"from"),Ke(So.prototype.cancel,"cancel"),Ke(So.prototype.getReader,"getReader"),Ke(So.prototype.pipeThrough,"pipeThrough"),Ke(So.prototype.pipeTo,"pipeTo"),Ke(So.prototype.tee,"tee"),Ke(So.prototype.values,"values"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(So.prototype,Symbol.toStringTag,{value:"ReadableStream",configurable:!0}),Object.defineProperty(So.prototype,rr,{value:So.prototype.values,writable:!0,configurable:!0});const Lo=e=>e.byteLength;Ke(Lo,"size");class No{constructor(e){At(e,1,"ByteLengthQueuingStrategy"),e=ko(e,"First parameter"),this._byteLengthQueuingStrategyHighWaterMark=e.highWaterMark}get highWaterMark(){if(!qo(this))throw Do("highWaterMark");return this._byteLengthQueuingStrategyHighWaterMark}get size(){if(!qo(this))throw Do("size");return Lo}}function Do(e){return new TypeError(`ByteLengthQueuingStrategy.prototype.${e} can only be used on a ByteLengthQueuingStrategy`)}function qo(e){return!!ze(e)&&!!Object.prototype.hasOwnProperty.call(e,"_byteLengthQueuingStrategyHighWaterMark")&&e instanceof No}Object.defineProperties(No.prototype,{highWaterMark:{enumerable:!0},size:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(No.prototype,Symbol.toStringTag,{value:"ByteLengthQueuingStrategy",configurable:!0});const xo=()=>1;Ke(xo,"size");class jo{constructor(e){At(e,1,"CountQueuingStrategy"),e=ko(e,"First parameter"),this._countQueuingStrategyHighWaterMark=e.highWaterMark}get highWaterMark(){if(!Bo(this))throw Mo("highWaterMark");return this._countQueuingStrategyHighWaterMark}get size(){if(!Bo(this))throw Mo("size");return xo}}function Mo(e){return new TypeError(`CountQueuingStrategy.prototype.${e} can only be used on a CountQueuingStrategy`)}function Bo(e){return!!ze(e)&&!!Object.prototype.hasOwnProperty.call(e,"_countQueuingStrategyHighWaterMark")&&e instanceof jo}function Wo(e,t,r){return Rt(e,r),r=>lt(e,t,[r])}function Fo(e,t,r){return Rt(e,r),r=>ct(e,t,[r])}function Ho(e,t,r){return Rt(e,r),(r,n)=>lt(e,t,[r,n])}function Vo(e,t,r){return Rt(e,r),r=>lt(e,t,[r])}Object.defineProperties(jo.prototype,{highWaterMark:{enumerable:!0},size:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(jo.prototype,Symbol.toStringTag,{value:"CountQueuingStrategy",configurable:!0});class zo{constructor(e={},t={},r={}){void 0===e&&(e=null);const n=nn(t,"Second parameter"),o=nn(r,"Third parameter"),i=function(e,t){Pt(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:Vo(r,e,`${t} has member 'cancel' that`),flush:void 0===n?void 0:Wo(n,e,`${t} has member 'flush' that`),readableType:o,start:void 0===i?void 0:Fo(i,e,`${t} has member 'start' that`),transform:void 0===s?void 0:Ho(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=tn(o,0),a=rn(o),u=tn(n,1),c=rn(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(hn.prototype);return pn(s),Nn(s,Object.create(kn.prototype),e,t,r,n,o,i),s}(s,(function(t){return function(e,t){const r=e._transformStreamController;return e._backpressure?st(e._backpressureChangePromise,(()=>{const n=e._writable;if("erroring"===n._state)throw n._storedError;return ti(r,t)})):ti(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=Xe(((e,r)=>{t._finishPromise_resolve=e,t._finishPromise_reject=r}));const n=t._flushAlgorithm();return Xo(t),nt(n,(()=>("errored"===r._state?oi(t,r._storedError):(uo(r._readableStreamController),ni(t)),null)),(e=>(lo(r._readableStreamController,e),oi(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=Xe(((e,t)=>{r._finishPromise_resolve=e,r._finishPromise_reject=t}));const o=r._cancelAlgorithm(t);return Xo(r),nt(o,(()=>("errored"===n._state?oi(r,n._storedError):(lo(n._readableStreamController,t),ni(r)),null)),(e=>(lo(n._readableStreamController,e),oi(r,e),null))),r._finishPromise}(e,t)}),r,n),e._readable=Io(s,(function(){return function(e){return Qo(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=Xe(((e,t)=>{r._finishPromise_resolve=e,r._finishPromise_reject=t}));const o=r._cancelAlgorithm(t);return Xo(r),nt(o,(()=>("errored"===n._state?oi(r,n._storedError):(jn(n._writableStreamController,t),$o(e),ni(r)),null)),(t=>(jn(n._writableStreamController,t),$o(e),oi(r,t),null))),r._finishPromise}(e,t)}),o,i),e._backpressure=void 0,e._backpressureChangePromise=void 0,e._backpressureChangePromise_resolve=void 0,Qo(e,!0),e._transformStreamController=void 0}(this,Xe((e=>{l=e})),u,c,s,a),function(e,t){const r=Object.create(Jo.prototype);let n,o,i;n=void 0!==t.transform?e=>t.transform(e,r):e=>{try{return ei(r,e),et(void 0)}catch(e){return tt(e)}},o=void 0!==t.flush?()=>t.flush(r):()=>et(void 0),i=void 0!==t.cancel?e=>t.cancel(e):()=>et(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(!Go(this))throw ii("readable");return this._readable}get writable(){if(!Go(this))throw ii("writable");return this._writable}}function Go(e){return!!ze(e)&&!!Object.prototype.hasOwnProperty.call(e,"_transformStreamController")&&e instanceof zo}function Ko(e,t){lo(e._readable._readableStreamController,t),Yo(e,t)}function Yo(e,t){Xo(e._transformStreamController),jn(e._writable._writableStreamController,t),$o(e)}function $o(e){e._backpressure&&Qo(e,!1)}function Qo(e,t){void 0!==e._backpressureChangePromise&&e._backpressureChangePromise_resolve(),e._backpressureChangePromise=Xe((t=>{e._backpressureChangePromise_resolve=t})),e._backpressure=t}Object.defineProperties(zo.prototype,{readable:{enumerable:!0},writable:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(zo.prototype,Symbol.toStringTag,{value:"TransformStream",configurable:!0});class Jo{constructor(){throw new TypeError("Illegal constructor")}get desiredSize(){if(!Zo(this))throw ri("desiredSize");return ho(this._controlledTransformStream._readable._readableStreamController)}enqueue(e=void 0){if(!Zo(this))throw ri("enqueue");ei(this,e)}error(e=void 0){if(!Zo(this))throw ri("error");var t;t=e,Ko(this._controlledTransformStream,t)}terminate(){if(!Zo(this))throw ri("terminate");!function(e){const t=e._controlledTransformStream;uo(t._readable._readableStreamController),Yo(t,new TypeError("TransformStream terminated"))}(this)}}function Zo(e){return!!ze(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledTransformStream")&&e instanceof Jo}function Xo(e){e._transformAlgorithm=void 0,e._flushAlgorithm=void 0,e._cancelAlgorithm=void 0}function ei(e,t){const r=e._controlledTransformStream,n=r._readable._readableStreamController;if(!fo(n))throw new TypeError("Readable side is not in a state that permits enqueue");try{co(n,t)}catch(e){throw Yo(r,e),r._readable._storedError}const o=function(e){return!so(e)}(n);o!==r._backpressure&&Qo(r,!0)}function ti(e,t){return st(e._transformAlgorithm(t),void 0,(t=>{throw Ko(e._controlledTransformStream,t),t}))}function ri(e){return new TypeError(`TransformStreamDefaultController.prototype.${e} can only be used on a TransformStreamDefaultController`)}function ni(e){void 0!==e._finishPromise_resolve&&(e._finishPromise_resolve(),e._finishPromise_resolve=void 0,e._finishPromise_reject=void 0)}function oi(e,t){void 0!==e._finishPromise_reject&&(at(e._finishPromise),e._finishPromise_reject(t),e._finishPromise_resolve=void 0,e._finishPromise_reject=void 0)}function ii(e){return new TypeError(`TransformStream.prototype.${e} can only be used on a TransformStream`)}Object.defineProperties(Jo.prototype,{enqueue:{enumerable:!0},error:{enumerable:!0},terminate:{enumerable:!0},desiredSize:{enumerable:!0}}),Ke(Jo.prototype.enqueue,"enqueue"),Ke(Jo.prototype.error,"error"),Ke(Jo.prototype.terminate,"terminate"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Jo.prototype,Symbol.toStringTag,{value:"TransformStreamDefaultController",configurable:!0});var si=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)t.hasOwnProperty(r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),ai=function(){return ai=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},ai.apply(this,arguments)},ui="Error when aborting requestTask",ci=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 si(t,e),t.prototype.post=function(e){var t=this;return new Promise((function(r,n){var o=e.url,i=e.data,s=e.headers,a=wx.request({url:(0,A.formatUrl)("https:",o),data:i,timeout:t._timeout,method:"POST",header:s,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{a.abort()}catch(e){}}}})}))},t.prototype.get=function(e){var t=this;return new Promise((function(r,n){var o=e.url,i=e.body,s=e.headers,a=(0,A.formatUrl)("https:",o),u=wx.request({url:a,data:i,timeout:t._timeout,method:"GET",header:s,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{u.abort()}catch(e){console.warn(ui,e)}}}})}))},t.prototype.upload=function(e){var t=this,r=this;return new Promise((function(n){return 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())}))}(t,void 0,void 0,(function(){var t,o,i,s,a,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(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(c){return t=e.url,o=e.file,i=e.data,s=e.headers,a=e.onUploadProgress,u=wx.uploadFile({url:t,filePath:o,name:"file",formData:ai({},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{u.abort()}catch(e){}}}}),a&&u.onProgressUpdate((function(e){a(e)})),[2]}))}))}))},t.prototype.download=function(e){var t=this,r=this;return new Promise((function(n,o){var i=e.url,s=e.headers,a=wx.downloadFile({url:(0,A.formatUrl)("https:",i),header:s,timeout:t._timeout,success:function(e){200===e.statusCode&&e.tempFilePath?n({statusCode:200,tempFilePath:e.tempFilePath}):n(e)},fail:function(e){o(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{a.abort()}catch(e){}}}})}))},t.prototype.fetch=function(e){var t=e.url,r=e.body,n=e.enableAbort,o=e.headers,i=e.method,s=e.stream,a=void 0!==s&&s,u=e.signal,c=e.timeout,l=this,d=null!=c?c:this._timeout,h=null,f=new So({start:function(e){h=e},cancel:function(){h=null}});return new Promise((function(e,s){a&&e({data:f});var c=wx.request({url:(0,A.formatUrl)("https:",t),data:r,timeout:d,method:i.toUpperCase(),header:o,success:function(t){var r;null===(r=h)||void 0===r||r.close(),!a&&e(t)},fail:function(e){var t;if(null===(t=h)||void 0===t||t.close(),s(e),a)throw e},complete:function(e){if(e&&e.errMsg&&d&&-1!==l._restrictedMethods.indexOf("post")&&n&&"request:fail timeout"===e.errMsg){console.warn(l._timeoutMsg);try{c.abort()}catch(e){console.warn(ui,e)}}},enableChunked:a});if(c.onChunkReceived((function(e){var t;null===(t=h)||void 0===t||t.enqueue(new Uint8Array(e.data))})),u){var p=function(){try{c.abort()}catch(e){console.warn(ui,e)}};u.aborted?p():u.addEventListener("abort",(function(){return p()}))}}))},t}(A.AbstractSDKRequest),li={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()}},di=function(e,t){void 0===t&&(t={});var r=wx.connectSocket(ai({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}};const hi=function(e){return{root:{globalThis:{}},reqClass:ci,wsClass:di,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=function(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}(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: "+t}):a?new Promise((function(e){console.log("wait for captcha..."),r.$emit("CAPTCHA_DATA_CHANGE",ai(ai({},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:li,primaryStorage:A.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:""}}},fi=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};var pi=r(182),vi=function(){return vi=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},vi.apply(this,arguments)},yi=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())}))},gi=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])}}},mi=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 yi(this,void 0,void 0,(function(){return gi(this,(function(t){return[2,this.localStorage.getItem(e)]}))}))},e.prototype.removeItem=function(e){return yi(this,void 0,void 0,(function(){return gi(this,(function(t){return this.localStorage.removeItem(e),[2]}))}))},e.prototype.setItem=function(e,t){return yi(this,void 0,void 0,(function(){return gi(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}(),_i=/^[^:]+:\/\/[^/]+(\/[^?#]+)/,bi=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,_i.test(i)?RegExp.$1:i),e):(null==e?void 0:e.data)||{}},wi=function(e){return e.adapter&&"default"!==e.adapter.type?function(e,t){var r=vi({},e);try{if(!(null==e?void 0:e.storage)&&(null==t?void 0:t.localStorage)&&(r.storage=new mi({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=new t.reqClass({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});r.baseRequest=function(e,t){var r,o,i,s,a;return yi(this,void 0,void 0,(function(){var u,c,l,d;return gi(this,(function(h){switch(h.label){case 0:if(u={},c=(null===(r=t.method)||void 0===r?void 0:r.toLocaleLowerCase())||"post","function"!=typeof(l=null===(i=null===(o=null==n?void 0:n[c])||void 0===o?void 0:o.bind)||void 0===i?void 0:i.call(o,n)))throw new Error("invalid 【".concat(c,"】 request method"));h.label=1;case 1:return h.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(vi({url:e},t))];case 2:return u=h.sent(),u=bi(u,vi(vi({},t),{url:e})),[3,4];case 3:throw d=h.sent(),u=vi(vi({},null==d?void 0:d.data),d);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=vi({},e),n={};if((null==t?void 0:t.captchaOptions)&&(r.captchaOptions=t.captchaOptions),!fi()||e.storage&&e.baseRequest)return r;try{var o=hi({}),i=o.localStorage,s=o.reqClass;if(i&&(n.storage=new mi({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 yi(this,void 0,void 0,(function(){return gi(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=bi(e,vi(vi({},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),vi(vi({},r),n)}catch(e){console.error("adapter generate fail:",e)}return r}(e,e.adapter)},Si=function(){return Si=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},Si.apply(this,arguments)},Ii=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())}))},Ti=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])}}},Ei=function(){return"undefined"!=typeof window&&"undefined"!=typeof document},Oi=function(){function e(e){this.listeners=new Map,this.hasListenerSetUp=!1,this.config=e,this.oauthInstance=e.oauthInstance,this.cache=e.cache,this.init()}return Object.defineProperty(e.prototype,"currentUser",{get:function(){var e=this.hasLoginState();return e&&e.user||null},enumerable:!1,configurable:!0}),e.prototype.hasLoginState=function(){throw new Error("Auth.hasLoginState() is not implemented")},e.prototype.setAccessKey=function(){return Ii(this,void 0,void 0,(function(){return Ti(this,(function(e){throw new Error("Auth.setAccessKey() is not implemented")}))}))},e.prototype.signIn=function(e){return Ii(this,void 0,void 0,(function(){return Ti(this,(function(e){throw new Error("Auth.signIn() is not implemented")}))}))},e.prototype.signInWithProvider=function(e){return Ii(this,void 0,void 0,(function(){return Ti(this,(function(e){throw new Error("Auth.signInWithProvider() is not implemented")}))}))},e.prototype.genProviderRedirectUri=function(e){return Ii(this,void 0,void 0,(function(){return Ti(this,(function(e){throw new Error("Auth.genProviderRedirectUri() is not implemented")}))}))},e.prototype.getAccessToken=function(){return Ii(this,void 0,void 0,(function(){return Ti(this,(function(e){throw new Error("Auth.getAccessToken() is not implemented")}))}))},e.prototype.getUserInfo=function(){return Ii(this,void 0,void 0,(function(){return Ti(this,(function(e){throw new Error("Auth.getUserInfo() is not implemented")}))}))},e.prototype.updateUserBasicInfo=function(e){return Ii(this,void 0,void 0,(function(){return Ti(this,(function(e){throw new Error("Auth.updateUserBasicInfo() is not implemented")}))}))},e.prototype.setCustomSignFunc=function(e){throw new Error("Auth.setCustomSignFunc() is not implemented")},e.prototype.grantProviderToken=function(e){return Ii(this,void 0,void 0,(function(){return Ti(this,(function(e){throw new Error("Auth.grantProviderToken() is not implemented")}))}))},e.prototype.bindWithProvider=function(e){return Ii(this,void 0,void 0,(function(){return Ti(this,(function(e){throw new Error("Auth.bindWithProvider() is not implemented")}))}))},e.prototype.signInWithUsername=function(e){return Ii(this,void 0,void 0,(function(){return Ti(this,(function(e){throw new Error("Auth.signInWithUsername() is not implemented")}))}))},e.prototype.getVerification=function(e,t){return Ii(this,void 0,void 0,(function(){return Ti(this,(function(e){throw new Error("Auth.getVerification() is not implemented")}))}))},e.prototype.createLoginState=function(e,t){return Ii(this,void 0,void 0,(function(){return Ti(this,(function(e){throw new Error("Auth.createLoginState() is not implemented")}))}))},e.prototype.verify=function(e){return Ii(this,void 0,void 0,(function(){return Ti(this,(function(e){throw new Error("Auth.verify() is not implemented")}))}))},e.prototype.signInAnonymously=function(e){return Ii(this,void 0,void 0,(function(){var t,r,n,o;return Ti(this,(function(i){switch(i.label){case 0:return i.trys.push([0,4,,5]),[4,this.oauthInstance.authApi.signInAnonymously(e)];case 1:return i.sent(),[4,this.createLoginState()];case 2:return t=i.sent(),[4,this.getSession()];case 3:return r=i.sent().data,n=(void 0===r?{}:r).session,[2,Si(Si({},t),{data:{user:n.user,session:n},error:null})];case 4:return o=i.sent(),[2,{data:{},error:new qe(o)}];case 5:return[2]}}))}))},e.prototype.signUp=function(e){return Ii(this,void 0,void 0,(function(){var t,r,n=this;return Ti(this,(function(o){switch(o.label){case 0:return e.phone_number||e.verification_code||e.verification_token||e.provider_token?[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 Ii(n,void 0,void 0,(function(){var r,n,i,a,u;return Ti(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(Si(Si(Si({},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 qe(u)}];case 9:return[2]}}))}))}},error:null}];case 4:return r=o.sent(),[2,{data:{},error:new qe(r)}];case 5:return[2]}}))}))},e.prototype.signOut=function(e){return Ii(this,void 0,void 0,(function(){var t,r,n;return Ti(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),t=this.cache.keys.userInfoKey,[4,this.oauthInstance.authApi.signOut(e)];case 1:return r=o.sent(),[4,this.cache.removeStoreAsync(t)];case 2:return o.sent(),this.setAccessKey(),Li.fire(h.LOGIN_STATE_CHANGED,{eventType:"sign_out"}),Li.fire(h.AUTH_STATE_CHANGED,{event:d.SIGNED_OUT}),[2,Si(Si({},r),{data:{},error:null})];case 3:return n=o.sent(),[2,{data:{},error:new qe(n)}];case 4:return[2]}}))}))},e.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))}}}}},e.prototype.signInWithPassword=function(e){return Ii(this,void 0,void 0,(function(){var t,r,n;return Ti(this,(function(o){switch(o.label){case 0:return o.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(Si({username:e.username||e.email||this.formatPhone(e.phone),password:e.password},e.is_encrypt?{isEncrypt:!0,version:"v2"}:{}))];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 qe(n)}];case 4:return[2]}}))}))},e.prototype.signInWithIdToken=function(e){return Ii(this,void 0,void 0,(function(){var t,r,n;return Ti(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 qe(n)}];case 4:return[2]}}))}))},e.prototype.signInWithOtp=function(e){return Ii(this,void 0,void 0,(function(){var t,r,n=this;return Ti(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"),[4,this.getVerification(e.email?{email:e.email}:{phone_number:this.formatPhone(e.phone)})];case 1:return t=o.sent(),[2,{data:{user:null,session:null,verifyOtp:function(r){var o=r.token,i=r.messageId,s=void 0===i?t.verification_id:i;return Ii(n,void 0,void 0,(function(){return Ti(this,(function(t){return[2,this.verifyOtp({email:e.email,phone:e.phone,token:o,messageId:s})]}))}))}},error:null}];case 2:return r=o.sent(),[2,{data:{},error:new qe(r)}];case 3:return[2]}}))}))},e.prototype.verifyOAuth=function(e){return Ii(this,void 0,void 0,(function(){var t,r,n,o,i,s,a,u,c;return Ti(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)||U("code"),n=(null==e?void 0:e.state)||U("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)||U("provider"))?[4,this.grantProviderToken({provider_id:i,provider_redirect_uri:location.origin+location.pathname,provider_code:r})]:[2,{data:t,error:new qe({message:"Provider is required"})}]):[2,{data:{},error:new qe({message:"State is required"})}]:[2,{data:{},error:new qe({message:"Code is required"})}];case 2:return s=l.sent().provider_token,a=void 0,o.type!==f.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=Si(Si({},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"),function(e,t){if(void 0!==e){var r=new URL(window.location.href);r.search=e,r.hash=t||r.hash,window.history.replaceState({},"",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 qe(c)}];case 8:return[2]}}))}))},e.prototype.signInWithOAuth=function(e){var t,r,n,o,i;return Ii(this,void 0,void 0,(function(){var s,a,u,c,l,d,h,p,v;return Ti(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,d=decodeURIComponent(l),h=d,(null===(n=e.options)||void 0===n?void 0:n.queryParams)&&(p=new URL(d),Object.entries(e.options.queryParams).forEach((function(e){var t=e[0],r=e[1];p.searchParams.set(t,r)})),h=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)||f.SIGN_IN}),Ei()&&!(null===(i=e.options)||void 0===i?void 0:i.skipBrowserRedirect)&&window.location.assign(h),[2,{data:{url:h,provider:e.provider},error:null}];case 2:return v=y.sent(),[2,{data:{},error:new qe(v)}];case 3:return[2]}}))}))},e.prototype.signInWithSSO=function(){return Ii(this,void 0,void 0,(function(){return Ti(this,(function(e){return[2]}))}))},e.prototype.signInWithWeb3=function(){return Ii(this,void 0,void 0,(function(){return Ti(this,(function(e){return[2]}))}))},e.prototype.getClaims=function(){return Ii(this,void 0,void 0,(function(){var e,t,r;return Ti(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getAccessToken()];case 1:return e=n.sent().accessToken,t=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(S(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 S(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)}}(e),[2,{data:t,error:null}];case 2:return r=n.sent(),[2,{data:{},error:new qe(r)}];case 3:return[2]}}))}))},e.prototype.resetPasswordForEmail=function(e,t){return Ii(this,void 0,void 0,(function(){var r,n,o,i,s,a,u=this;return Ti(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 Ii(u,void 0,void 0,(function(){var o,i,a;return Ti(this,(function(u){switch(u.label){case 0:this.validateParams(t,{nonce:{required:!0,message:"Nonce is required"},password:{required:!0,message:"Password is required"}}),u.label=1;case 1:return u.trys.push([1,5,,6]),[4,this.verify({verification_id:s.verification_id,verification_code:t.nonce})];case 2:return o=u.sent(),[4,this.oauthInstance.authApi.resetPassword({email:n?e:void 0,phone:n?void 0:e,new_password:t.password,verification_token:o.verification_token})];case 3:return u.sent(),Li.fire(h.AUTH_STATE_CHANGED,{event:d.PASSWORD_RECOVERY}),[4,this.signInWithPassword({email:n?e:void 0,phone:n?void 0:e,password:t.password})];case 4:return i=u.sent(),r&&Ei()&&window.location.assign(r),[2,i];case 5:return a=u.sent(),[2,{data:{},error:new qe(a)}];case 6:return[2]}}))}))}},error:null}];case 2:return a=c.sent(),[2,{data:{},error:new qe(a)}];case 3:return[2]}}))}))},e.prototype.resetPasswordForOld=function(e){return Ii(this,void 0,void 0,(function(){var t,r,n;return Ti(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 qe(n)}];case 4:return[2]}}))}))},e.prototype.verifyOtp=function(e){return Ii(this,void 0,void 0,(function(){var t,r,n,o;return Ti(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 qe(o)}];case 7:return[2]}}))}))},e.prototype.getSession=function(){return Ii(this,void 0,void 0,(function(){var e,t,r,n;return Ti(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:Si(Si({},e),{user:r})},error:null}];case 3:return n=o.sent(),[2,{data:{},error:new qe(n)}];case 4:return[2]}}))}))},e.prototype.refreshSession=function(e){return Ii(this,void 0,void 0,(function(){var t,r,n,o,i;return Ti(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:Si(Si({},r),{user:o})},error:null}];case 4:return i=s.sent(),[2,{data:{},error:new qe(i)}];case 5:return[2]}}))}))},e.prototype.getUser=function(){return Ii(this,void 0,void 0,(function(){var e,t;return Ti(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),e=this.convertToUser,[4,this.getUserInfo()];case 1:return[2,{data:{user:e.apply(this,[r.sent()])},error:null}];case 2:return t=r.sent(),[2,{data:{},error:new qe(t)}];case 3:return[2]}}))}))},e.prototype.refreshUser=function(){return Ii(this,void 0,void 0,(function(){var e,t,r;return Ti(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 qe(r)}];case 4:return[2]}}))}))},e.prototype.updateUser=function(e){return Ii(this,void 0,void 0,(function(){var t,r,n,o,i,s,a,u,c,l,f,p,v=this;return Ti(this,(function(y){switch(y.label){case 0:if(y.trys.push([0,8,,9]),!Object.keys(e).some((function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]})))throw new qe({message:"At least one field must be provided for update"});return t=e.email,r=e.phone,n=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"]),i=void 0!==r,s={},(o=void 0!==t)||i?(a=void 0,o?(a={email:e.email},u="email_change"):(c=this.formatPhone(e.phone),a={phone_number:c},u="phone_change"),[4,this.getVerification(a)]):[3,4];case 1:return l=y.sent(),Object.keys(n).length>0?[4,this.updateUserBasicInfo(n)]:[3,3];case 2:y.sent(),y.label=3;case 3:return s={messageId:l.verification_id,verifyOtp:function(t){return Ii(v,void 0,void 0,(function(){var r,n;return Ti(this,(function(i){switch(i.label){case 0:return i.trys.push([0,11,,12]),t.email&&e.email===t.email?[4,this.verifyOtp({type:"email_change",email:e.email,token:t.token,messageId:l.verification_id})]:[3,3];case 1:return i.sent(),[4,this.updateUserBasicInfo({email:e.email})];case 2:return i.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:l.verification_id})]:[3,6];case 4:return i.sent(),[4,this.updateUserBasicInfo({phone:this.formatPhone(e.phone)})];case 5:return i.sent(),[3,9];case 6:return[4,this.verifyOtp({type:u,email:o?e.email:void 0,phone:o?void 0:e.phone,token:t.token,messageId:l.verification_id})];case 7:return i.sent(),[4,this.updateUserBasicInfo(e)];case 8:i.sent(),i.label=9;case 9:return[4,this.getUser()];case 10:return r=i.sent().data.user,Li.fire(h.AUTH_STATE_CHANGED,{event:d.USER_UPDATED}),[2,{data:{user:r},error:null}];case 11:return n=i.sent(),[2,{data:{},error:new qe(n)}];case 12:return[2]}}))}))}},[3,6];case 4:return[4,this.updateUserBasicInfo(e)];case 5:y.sent(),y.label=6;case 6:return[4,this.getUser()];case 7:return f=y.sent().data.user,Li.fire(h.AUTH_STATE_CHANGED,{event:d.USER_UPDATED}),[2,{data:Si({user:f},s),error:null}];case 8:return p=y.sent(),[2,{data:{},error:new qe(p)}];case 9:return[2]}}))}))},e.prototype.getUserIdentities=function(){var e;return Ii(this,void 0,void 0,(function(){var t,r;return Ti(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 qe(r)}];case 3:return[2]}}))}))},e.prototype.linkIdentity=function(e){return Ii(this,void 0,void 0,(function(){var t;return Ti(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:f.BIND_IDENTITY}})];case 1:return r.sent(),[2,{data:{provider:e.provider},error:null}];case 2:return t=r.sent(),[2,{data:{},error:new qe(t)}];case 3:return[2]}}))}))},e.prototype.unlinkIdentity=function(e){return Ii(this,void 0,void 0,(function(){var t;return Ti(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 qe(t)}];case 3:return[2]}}))}))},e.prototype.reauthenticate=function(){return Ii(this,void 0,void 0,(function(){var e,t,r,n,o=this;return Ti(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 Ii(o,void 0,void 0,(function(){var n,o,i,s,a;return Ti(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(Si(Si({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 qe(a)}];case 10:return[2]}}))}))}},error:null}];case 3:return n=i.sent(),[2,{data:{},error:new qe(n)}];case 4:return[2]}}))}))},e.prototype.resend=function(e){return Ii(this,void 0,void 0,(function(){var t,r,n;return Ti(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 qe(n)}];case 3:return[2]}}))}))},e.prototype.setSession=function(e){return Ii(this,void 0,void 0,(function(){var t,r,n;return Ti(this,(function(o){switch(o.label){case 0:return o.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,{throwOnError:!0})];case 1:return o.sent(),[4,this.getSession()];case 2:return t=o.sent().data,r=(void 0===t?{}:t).session,Li.fire(h.AUTH_STATE_CHANGED,{event:d.SIGNED_IN}),[2,{data:{user:r.user,session:r},error:null}];case 3:return n=o.sent(),[2,{data:{},error:new qe(n)}];case 4:return[2]}}))}))},e.prototype.exchangeCodeForSession=function(){return Ii(this,void 0,void 0,(function(){return Ti(this,(function(e){return[2]}))}))},e.prototype.deleteUser=function(e){return Ii(this,void 0,void 0,(function(){var t,r;return Ti(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 qe(r)}];case 4:return[2]}}))}))},e.prototype.toDefaultLoginPage=function(e){return void 0===e&&(e={}),Ii(this,void 0,void 0,(function(){var t,r,n,o,i;return Ti(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("&"),fi()?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 qe(e)}]}return[2]}))}))},e.prototype.signInWithCustomTicket=function(e){return Ii(this,void 0,void 0,(function(){var t,r,n,o;return Ti(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,Si(Si({},t),{data:{user:n.user,session:n},error:null})];case 5:return o=i.sent(),[2,{data:{},error:new qe(o)}];case 6:return[2]}}))}))},e.prototype.signInWithOpenId=function(e){var t=(void 0===e?{}:e).useWxCloud,r=void 0===t||t;return Ii(this,void 0,void 0,(function(){var e,t,n,o,i,s,a=this;return Ti(this,(function(u){switch(u.label){case 0:if(!fi())throw Error("wx api undefined");e=wx.getAccountInfoSync().miniProgram,t=function(t){return Ii(a,void 0,void 0,(function(){var n,o;return Ti(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 Ii(a,void 0,void 0,(function(){var o;return Ti(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,Si(Si({},n),{data:{user:i.user,session:i},error:null})];case 5:return s=u.sent(),[2,{data:{},error:new qe(s)}];case 6:return[2]}}))}))},e.prototype.signInWithPhoneAuth=function(e){var t=e.phoneCode,r=void 0===t?"":t;return Ii(this,void 0,void 0,(function(){var e,t,n,o,i,s,a,u,c;return Ti(this,(function(l){switch(l.label){case 0:return fi()?(e=wx.getAccountInfoSync().miniProgram,t={provider_params:{provider_code_type:"phone"},provider_id:e.appId},[4,wx.login()]):[2,{data:{},error:new qe({message:"wx api undefined"})}];case 1:n=l.sent().code,t.provider_code=n,l.label=2;case 2:return l.trys.push([2,6,,7]),[4,this.oauthInstance.authApi.grantProviderToken(t)];case 3:if((o=l.sent()).error_code)throw o;return[4,this.oauthInstance.authApi.patchProviderToken({provider_token:o.provider_token,provider_id:e.appId,provider_params:{code:r,provider_code_type:"phone"}})];case 4:if((o=l.sent()).error_code)throw o;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:o.provider_token})];case 5:if(null==(i=l.sent())?void 0:i.error_code)throw i;return[3,7];case 6:return s=l.sent(),[2,{data:{},error:new qe(s)}];case 7:return[4,this.createLoginState()];case 8:return a=l.sent(),[4,this.getSession()];case 9:return u=l.sent().data,c=(void 0===u?{}:u).session,[2,Si(Si({},a),{data:{user:c.user,session:c},error:null})]}}))}))},e.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)},e.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)}}))}))},e.prototype.init=function(){return Ii(this,void 0,void 0,(function(){return Ti(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.oauthInstance.oauth2client.localCredentials.getCredentials()];case 1:return e.sent()&&Li.fire(h.AUTH_STATE_CHANGED,{event:d.INITIAL_SESSION}),[3,3];case 2:return e.sent(),[3,3];case 3:return[2,{error:null}]}}))}))},e.prototype.setupListeners=function(){var e=this;Li.on(h.AUTH_STATE_CHANGED,(function(t){return Ii(e,void 0,void 0,(function(){var e,r,n,o,i;return Ti(this,(function(s){switch(s.label){case 0:return e=null===(o=null==t?void 0:t.data)||void 0===o?void 0:o.event,r=null===(i=null==t?void 0:t.data)||void 0===i?void 0:i.info,[4,this.getSession()];case 1:return n=s.sent().data.session,this.notifyListeners(e,n,r),[2]}}))}))}))},e.prototype.convertToUser=function(e){var t,r,n;if(!e)return null;var o=(null==e?void 0:e.email)||(null==e?void 0:e.username),i=null==e?void 0:e.phone_number,s=(null==e?void 0:e.sub)||(null==e?void 0:e.uid)||"";return{id:s,aud:"authenticated",role:e.groups,email:o||"",email_confirmed_at:(null==e||e.email_verified,e.created_at),phone:i,phone_confirmed_at:i?e.created_at:void 0,confirmed_at:e.created_at,last_sign_in_at:e.last_sign_in_at,app_metadata:{provider:(null===(t=e.loginType)||void 0===t?void 0:t.toLowerCase())||"cloudbase",providers:[(null===(r=e.loginType)||void 0===r?void 0:r.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,avatarUrl:e.avatarUrl||e.picture,location:e.location,hasPassword:e.hasPassword},identities:(null===(n=null==e?void 0:e.providers)||void 0===n?void 0:n.map((function(t){return{id:t.id||"",identity_id:t.id||"",user_id:s,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}},e.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 qe({message:s.message})}},e.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 qe({message:r})},e}(),Pi=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)}}(),Ri=function(){return Ri=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},Ri.apply(this,arguments)},Ci=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},Ai=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Ui=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())}))},ki=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])}}},Li=new ce.CloudbaseEventEmitter,Ni=function(e){Li.fire(h.LOGIN_STATE_CHANGED,Ri(Ri({},e),{eventType:l}))},Di=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 Ui(this,void 0,void 0,(function(){return ki(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 Ui(this,void 0,void 0,(function(){var e,t,r,n;return ki(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 Ui(this,void 0,void 0,(function(){var t;return ki(this,(function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.setUserProfile(Ri({},e))];case 1:return t=r.sent(),this.setLocalUserInfo(t),[2]}}))}))},e.prototype.updateUserBasicInfo=function(e){return Ui(this,void 0,void 0,(function(){return ki(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.updateUserBasicInfo(Ri({},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,le.throwError)(We.ERRORS.INVALID_PARAMS,"username must be a string"),this.update({username:e})},e.prototype.refresh=function(e){return Ui(this,void 0,void 0,(function(){var t;return ki(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 Ui(this,void 0,void 0,(function(){var t;return ki(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]}))},Ci([(0,Fe.catchErrorsDecorator)({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[Object]),Ai("design:returntype",Promise)],e.prototype,"update",null),Ci([(0,Fe.catchErrorsDecorator)({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[String,String]),Ai("design:returntype",void 0)],e.prototype,"updatePassword",null),Ci([(0,Fe.catchErrorsDecorator)({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[String]),Ai("design:returntype",void 0)],e.prototype,"updateUsername",null),Ci([(0,Fe.catchErrorsDecorator)({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[Object]),Ai("design:returntype",Promise)],e.prototype,"refresh",null),e}(),qi=function(){function e(e){var t=e.envId,r=e.cache,n=e.oauthInstance;t||(0,le.throwError)(We.ERRORS.INVALID_PARAMS,"envId is not defined"),this.cache=r,this.oauthInstance=n,this.user=new Di({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 Ui(this,void 0,void 0,(function(){return ki(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}(),xi=function(e){function t(t){var r=e.call(this,t)||this;return r.setAccessKey(),r}return Pi(t,e),t.prototype.bindPhoneNumber=function(e){return Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.editContact(e)]}))}))},t.prototype.unbindProvider=function(e){return Ui(this,void 0,void 0,(function(){return ki(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 Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.verify(e)]}))}))},t.prototype.getVerification=function(e,t){return Ui(this,void 0,void 0,(function(){return ki(this,(function(r){return[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,le.printWarn)(We.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrentUser instead")},enumerable:!1,configurable:!0}),t.prototype.getCurrentUser=function(){return Ui(this,void 0,void 0,(function(){var e,t;return ki(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,Ri(Ri({},e.user),t)];case 3:return[2,null]}}))}))},t.prototype.signInAnonymouslyInWx=function(e){var t=(void 0===e?{}:e).useWxCloud;return Ui(this,void 0,void 0,(function(){var e,r,n=this;return ki(this,(function(o){switch(o.label){case 0:if(!fi())throw Error("wx api undefined");return e=wx.getAccountInfoSync().miniProgram,r=function(r){return Ui(n,void 0,void 0,(function(){var n,o;return ki(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 Ui(n,void 0,void 0,(function(){var n;return ki(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 Ui(this,void 0,void 0,(function(){var e,t,r=this;return ki(this,(function(n){switch(n.label){case 0:if(!fi())throw Error("wx api undefined");return e=wx.getAccountInfoSync().miniProgram,t=function(t){return Ui(r,void 0,void 0,(function(){var r;return ki(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 Ui(r,void 0,void 0,(function(){var r;return ki(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 Ui(this,void 0,void 0,(function(){var e=this;return ki(this,(function(t){switch(t.label){case 0:if(!fi())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 Ui(e,void 0,void 0,(function(){var e,i,s,a,u;return ki(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 Ui(this,void 0,void 0,(function(){return ki(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 Ui(this,void 0,void 0,(function(){return ki(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 Ui(this,void 0,void 0,(function(){return ki(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 Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.setPassword(e)]}))}))},t.prototype.isUsernameRegistered=function(e){return Ui(this,void 0,void 0,(function(){return ki(this,(function(t){switch(t.label){case 0:return"string"!=typeof e&&(0,le.throwError)(We.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 qi({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance}):null;(0,le.printWarn)(We.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState insteed")},t.prototype.getLoginState=function(){return Ui(this,void 0,void 0,(function(){var e;return ki(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 qi({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})]:[2,null]}}))}))},t.prototype.getUserInfo=function(){return Ui(this,void 0,void 0,(function(){return ki(this,(function(e){return[2,this.getCurrentUser()]}))}))},t.prototype.getWedaUserInfo=function(){return Ui(this,void 0,void 0,(function(){return ki(this,(function(e){return[2,this.oauthInstance.authApi.getWedaUserInfo()]}))}))},t.prototype.updateUserBasicInfo=function(e){return Ui(this,void 0,void 0,(function(){var t;return ki(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 Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.bindWithProvider(e)]}))}))},t.prototype.queryUser=function(e){return Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.queryUserProfile(e)]}))}))},t.prototype.getAccessToken=function(){return Ui(this,void 0,void 0,(function(){return ki(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 Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.grantProviderToken(e)]}))}))},t.prototype.patchProviderToken=function(e){return Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.patchProviderToken(e)]}))}))},t.prototype.signInWithProvider=function(e){return Ui(this,void 0,void 0,(function(){return ki(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={}),Ui(this,void 0,void 0,(function(){return ki(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 Ui(this,void 0,void 0,(function(){return ki(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 Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.genProviderRedirectUri(e)]}))}))},t.prototype.resetPassword=function(e){return Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.resetPassword(e)]}))}))},t.prototype.deviceAuthorize=function(e){return Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.deviceAuthorize(e)]}))}))},t.prototype.sudo=function(e){return Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.sudo(e)]}))}))},t.prototype.deleteMe=function(e){return Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.deleteMe(e)]}))}))},t.prototype.getProviders=function(){return Ui(this,void 0,void 0,(function(){return ki(this,(function(e){return[2,this.oauthInstance.authApi.getProviders()]}))}))},t.prototype.loginScope=function(){return Ui(this,void 0,void 0,(function(){return ki(this,(function(e){return[2,this.oauthInstance.authApi.loginScope()]}))}))},t.prototype.loginGroups=function(){return Ui(this,void 0,void 0,(function(){return ki(this,(function(e){return[2,this.oauthInstance.authApi.loginGroups()]}))}))},t.prototype.onLoginStateChanged=function(e){return Ui(this,void 0,void 0,(function(){var t,r=this;return ki(this,(function(n){switch(n.label){case 0:return Li.on(h.LOGIN_STATE_CHANGED,(function(t){return Ui(r,void 0,void 0,(function(){var r,n,o;return ki(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,Ri(Ri({},t),r)),[2]}}))}))})),[4,this.getLoginState()];case 1:return t=n.sent(),e.call(this,t),[2]}}))}))},t.prototype.refreshTokenForce=function(e){return Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.refreshTokenForce(e)]}))}))},t.prototype.getCredentials=function(){return Ui(this,void 0,void 0,(function(){return ki(this,(function(e){return[2,this.oauthInstance.authApi.getCredentials()]}))}))},t.prototype.setCredentials=function(e){return Ui(this,void 0,void 0,(function(){return ki(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 Ui(this,void 0,void 0,(function(){return ki(this,(function(e){return[2,this.oauthInstance.authApi.getProviderSubType()]}))}))},t.prototype.createCaptchaData=function(e){return Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.createCaptchaData(e)]}))}))},t.prototype.verifyCaptchaData=function(e){return Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.verifyCaptchaData(e)]}))}))},t.prototype.getMiniProgramQrCode=function(e){return Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.getMiniProgramCode(e)]}))}))},t.prototype.getMiniProgramQrCodeStatus=function(e){return Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.getMiniProgramQrCodeStatus(e)]}))}))},t.prototype.modifyPassword=function(e){return Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.modifyPassword(e)]}))}))},t.prototype.modifyPasswordWithoutLogin=function(e){return Ui(this,void 0,void 0,(function(){return ki(this,(function(t){return[2,this.oauthInstance.authApi.modifyPasswordWithoutLogin(e)]}))}))},t.prototype.getUserBehaviorLog=function(e){return Ui(this,void 0,void 0,(function(){return ki(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 Ui(this,void 0,void 0,(function(){var e,t,n,i,a,c,d;return ki(this,(function(h){switch(h.label){case 0:return h.trys.push([0,8,,9]),[4,this.oauthInstance.authApi.verify({verification_id:r.verification_id,verification_code:o})];case 1:if(null==(e=h.sent())?void 0:e.error_code)throw e;return t=e.verification_token,n=/^\+\d{1,3}\s+/.test(s)?s:"+86 ".concat(s),i={phone_number:n},"email"===l&&(i={email:n=s}),r.is_user?[4,this.oauthInstance.authApi.signIn({username:n,verification_token:t})]:[3,5];case 2:if(null==(a=h.sent())?void 0:a.error_code)throw a;return u?[4,this.oauthInstance.authApi.bindWithProvider({provider_token:null==u?void 0:u.providerToken})]:[3,4];case 3:if(null==(c=h.sent())?void 0:c.error_code)throw c;h.label=4;case 4:return[3,7];case 5:return[4,this.oauthInstance.authApi.signUp(Ri(Ri({},i),{verification_token:t,provider_token:null==u?void 0:u.providerId}))];case 6:if(null==(d=h.sent())?void 0:d.error_code)throw d;h.label=7;case 7:return[2,this.createLoginState()];case 8:throw h.sent();case 9:return[2]}}))}))},t.prototype.createLoginState=function(e,t){return Ui(this,void 0,void 0,(function(){var r;return ki(this,(function(n){switch(n.label){case 0:return[4,(r=new qi({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})).checkLocalStateAsync()];case 1:return n.sent(),(null==t?void 0:t.userInfo)?(r.user.setLocalUserInfo(t.userInfo),[3,5]):[3,2];case 2:return(null==t?void 0:t.asyncRefreshUser)?(r.user.refresh(e),[3,5]):[3,3];case 3:return[4,r.user.refresh(e)];case 4:n.sent(),n.label=5;case 5:return Li.fire(h.LOGIN_STATE_CHANGED,{eventType:"sign_in"}),Li.fire(h.AUTH_STATE_CHANGED,{event:d.SIGNED_IN}),[2,r]}}))}))},t.prototype.setAccessKey=function(){return Ui(this,void 0,void 0,(function(){return ki(this,(function(e){if(this.config.accessKey)try{this.oauthInstance.oauth2client.setAccessKeyCredentials({access_token:this.config.accessKey,token_type:"Bearer",scope:"accessKey",expires_at:new Date(+new Date+ +new Date),expires_in:+new Date+ +new Date})}catch(e){console.warn("accessKey error: ",e)}return[2]}))}))},Ci([(0,Fe.catchErrorsDecorator)({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[Object]),Ai("design:returntype",Promise)],t.prototype,"bindPhoneNumber",null),Ci([(0,Fe.catchErrorsDecorator)({title:"解除三方绑定失败",messages:["请确认以下各项:"," 1 - 调用 auth().unbindProvider() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[Object]),Ai("design:returntype",Promise)],t.prototype,"unbindProvider",null),Ci([(0,Fe.catchErrorsDecorator)({title:"绑定邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[Object]),Ai("design:returntype",void 0)],t.prototype,"bindEmail",null),Ci([(0,Fe.catchErrorsDecorator)({title:"验证码验证失败",messages:["请确认以下各项:"," 1 - 调用 auth().verify() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[Object]),Ai("design:returntype",Promise)],t.prototype,"verify",null),Ci([(0,Fe.catchErrorsDecorator)({title:"获取验证码失败",messages:["请确认以下各项:"," 1 - 调用 auth().getVerification() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[Object,Object]),Ai("design:returntype",Promise)],t.prototype,"getVerification",null),Ci([(0,Fe.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrentUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[]),Ai("design:returntype",Promise)],t.prototype,"getCurrentUser",null),Ci([(0,Fe.catchErrorsDecorator)({title:"小程序匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymouslyInWx() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[Object]),Ai("design:returntype",Promise)],t.prototype,"signInAnonymouslyInWx",null),Ci([(0,Fe.catchErrorsDecorator)({title:"小程序绑定OpenID失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序openId静默登录"," 2 - 调用 auth().bindOpenId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[]),Ai("design:returntype",Promise)],t.prototype,"bindOpenId",null),Ci([(0,Fe.catchErrorsDecorator)({title:"小程序unionId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序unionId静默登录"," 2 - 调用 auth().signInWithUnionId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[]),Ai("design:returntype",Promise)],t.prototype,"signInWithUnionId",null),Ci([(0,Fe.catchErrorsDecorator)({title:"短信验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序短信验证码登陆"," 2 - 调用 auth().signInWithSms() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[Object]),Ai("design:returntype",Promise)],t.prototype,"signInWithSms",null),Ci([(0,Fe.catchErrorsDecorator)({title:"邮箱验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了邮箱登陆"," 2 - 调用 auth().signInWithEmail() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[Object]),Ai("design:returntype",Promise)],t.prototype,"signInWithEmail",null),Ci([(0,Fe.catchErrorsDecorator)({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[String]),Ai("design:returntype",Promise)],t.prototype,"isUsernameRegistered",null),Ci([(0,Fe.catchErrorsDecorator)({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[]),Ai("design:returntype",Promise)],t.prototype,"getLoginState",null),Ci([(0,Fe.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[]),Ai("design:returntype",Promise)],t.prototype,"getUserInfo",null),Ci([(0,Fe.catchErrorsDecorator)({title:"获取微搭插件用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getWedaUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[]),Ai("design:returntype",Promise)],t.prototype,"getWedaUserInfo",null),Ci([(0,Fe.catchErrorsDecorator)({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindWithProvider() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[Object]),Ai("design:returntype",Promise)],t.prototype,"bindWithProvider",null),Ci([(0,Fe.catchErrorsDecorator)({title:"获取身份源类型",messages:["请确认以下各项:"," 1 - 调用 auth().getProviderSubType() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(We.COMMUNITY_SITE_URL)]}),Ai("design:type",Function),Ai("design:paramtypes",[]),Ai("design:returntype",Promise)],t.prototype,"getProviderSubType",null),t}(Oi);function ji(e,t){var r=this,n=e.region,o=void 0===n?"ap-shanghai":n,i=e.i18n,s=e.accessKey,a=e.useWxCloud,c=(null==t?void 0:t.platform)||pi.useDefaultAdapter.bind(t)(),l=c.runtime,p=c.adapter,v=t||{},y=v.env,g=v.clientId,m=v.debug,_=v.cache,b=v.app,w=(t||{}).apiOrigin;w||(w="https://".concat(y,".").concat(o,".tcb-api.tencentcloudapi.com"));var S={env:y,clientId:g,i18n:i,accessKey:s,useWxCloud:a,eventBus:Li},I=new Be(wi(Ri(Ri({},S),{apiOrigin:w,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:p,onCredentialsError:Ni,headers:Ri({"X-SDK-Version":"@cloudbase/js-sdk/".concat(e.sdkVersion)},e.headers||{}),detectSessionInUrl:e.detectSessionInUrl,debug:m}))),T=new xi(Ri(Ri({},S),{region:o,persistence:e.persistence,debug:m,cache:_||new He.CloudbaseCache({persistence:e.persistence,keys:{userInfoKey:"user_info_".concat(y)},platformInfo:c}),runtime:l||"web",_fromApp:b,oauthInstance:I}));return I.initializeSession((function(e,t){return Ui(r,void 0,void 0,(function(){return ki(this,(function(r){return e?(e.type===f.SIGN_IN?t?Li.fire(h.AUTH_STATE_CHANGED,{event:d.SIGNED_IN,info:Ri(Ri({},e),{error:t})}):e.user&&T.createLoginState({},{userInfo:e.user}):e.type===f.BIND_IDENTITY&&Li.fire(h.AUTH_STATE_CHANGED,{event:d.BIND_IDENTITY,info:Ri(Ri({},e),{error:t})}),[2]):[2]}))}))})),{authInstance:T,oauthInstance:I}}var Mi={name:"auth",namespace:"auth",entity: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=ji(Ri(Ri({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}};try{cloudbase.registerComponent(Mi)}catch(Y){}function Bi(e){try{e.registerComponent(Mi)}catch(e){console.warn(e)}}},171:(e,t,r)=>{var n;if(r.r(t),r.d(t,{getEncryptInfo:()=>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 H(e,t){return e^t}function V(e,t){return e&~t}function z(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 K(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 Y(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)}},d=1e13;class ${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)<d?t=0:n-=(t=0|n/d)*d,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+=d,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+=(d+t[n]).toString().substring(1);return r}valueOf(){for(var e=this.buf,t=0,r=e.length-1;r>=0;--r)t=t*d+e[r];return t}simplify(){var e=this.buf;return 1==e.length?e[0]:this}}var h,f=/^(\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 Q(e,t){return e.length>t&&(e=e.substring(0,t)+"…"),e}class J{constructor(e,t){this.hexDigits="0123456789ABCDEF",e instanceof J?(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?f: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 $(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+Q(i,r)}return o+i}parseOctetString(e,t,r){if(this.isASCII(e,t))return Q(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 $,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 $)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 Q(n,r);o=new $,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 Q(this.stream.parseStringUTF(t,t+r),e);case 18:case 19:case 20:case 21:case 22:case 26:return Q(this.stream.parseStringISO(t,t+r),e);case 30:return Q(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 J?e:new J(e,0);var r=new J(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 $;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 m(t):new _(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,H,t),t}andNot(e){var t=te();return this.bitwiseTo(e,V,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+z(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,V)}flipBit(e){return this.changeBit(e,H)}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 m(t):t.isEven()?new b(t):new _(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 d,h,f=e.t-1,p=!0,v=te();for(o=ue(e[f])-1;f>=0;){for(o>=u?d=e[f]>>o-u&c:(d=(e[f]&(1<<o+1)-1)<<u-o,f>0&&(d|=e[f-1]>>this.DB+o-u)),a=r;!(1&d);)d>>=1,--a;if((o-=a)<0&&(o+=this.DB,--f),p)s[d].copyTo(i),p=!1;else{for(;a>1;)n.sqrTo(i,v),n.sqrTo(v,i),a-=2;a>0?n.sqrTo(i,v):(h=i,i=v,v=h),n.mulTo(v,s[d],i)}for(;f>=0&&!(e[f]&1<<o);)n.sqrTo(i,v),h=i,i=v,v=h,--o<0&&(o=this.DB-1,--f)}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 g)}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 d=l*(1<<this.F1)+(c>1?i[c-2]>>this.F2:0),h=this.FV/d,f=(1<<this.F1)/d,p=1<<this.F2,v=r.t,y=v-c,g=null==t?te():t;for(i.dlShiftTo(y,g),r.compareTo(g)>=0&&(r[r.t++]=1,r.subTo(g,r)),ee.ONE.dlShiftTo(c,g),g.subTo(i,i);i.t<c;)i[i.t++]=0;for(;--y>=0;){var m=r[--v]==l?this.DM:Math.floor(r[v]*h+(r[v-1]+p)*f);if((r[v]+=i.am(0,m,r,y,0,c))<m)for(i.dlShiftTo(y,g),r.subTo(g,r);r[v]<--m;)r.subTo(g,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 g=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}(),m=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}(),_=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}(),b=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,h=30):"Netscape"!=(null==o?void 0:o.appName)?(ee.prototype.am=ne,h=26):(ee.prototype.am=ie,h=28),ee.prototype.DB=h,ee.prototype.DM=(1<<h)-1,ee.prototype.DV=1<<h,ee.prototype.FV=Math.pow(2,52),ee.prototype.F1=52-h,ee.prototype.F2=2*h-52;var w,S,I=[];for(w="0".charCodeAt(0),S=0;S<=9;++S)I[w++]=S;for(w="a".charCodeAt(0),S=10;S<36;++S)I[w++]=S;for(w="A".charCodeAt(0),S=10;S<36;++S)I[w++]=S;function se(e,t){var r=I[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 T,E,O=null;if(null==O){var P,R,C,A;O=[],E=0;var U=void 0;if(null!==(P=window)&&void 0!==P&&P.crypto&&null!==(R=window)&&void 0!==R&&R.crypto.getRandomValues){var k,L=new Uint32Array(256);for(null===(k=window)||void 0===k||k.crypto.getRandomValues(L),U=0;U<L.length;++U)O[E++]=255&L[U]}var N,D=function(e){var t,r,n;if(this.count=this.count||0,this.count>=256||E>=256){if(null!==(t=window)&&void 0!==t&&t.removeEventListener)null===(n=window)||void 0===n||n.removeEventListener("mousemove",D,!1);else if(null!==(r=window)&&void 0!==r&&r.detachEvent){var o;null===(o=window)||void 0===o||o.detachEvent("onmousemove",D)}}else try{var i=e.x+e.y;O[E++]=255&i,this.count+=1}catch(e){}};if(null!==(C=window)&&void 0!==C&&C.addEventListener)null===(N=window)||void 0===N||N.addEventListener("mousemove",D,!1);else if(null!==(A=window)&&void 0!==A&&A.attachEvent){var q;null===(q=window)||void 0===q||q.attachEvent("onmousemove",D)}}function le(){if(null==T){for(T=new ce;E<256;){var e=Math.floor(65536*Math.random());O[E++]=255&e}for(T.init(O),E=0;E<O.length;++E)O[E]=0;E=0}return T.next()}class de{constructor(){}nextBytes(e){for(var t=0;t<e.length;++t)e[t]=le()}}function he(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 de,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 fe{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=he(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})),K(n)):K(this.encrypt(e))}catch(e){return!1}}decryptLong(e){var t=this,r=this.n.bitLength()+7>>3;e=Y(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 de,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 de,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 fe{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 d=o.sub[7].getHexStringValue();this.dmq1=re(d,16);var h=o.sub[8].getHexStringValue();this.coeff=re(h,16)}else{if(2!==o.sub.length)return!1;var f=o.sub[1].sub[0];t=f.sub[0].getHexStringValue(),this.n=re(t,16),r=f.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(Y(e))}catch(e){return!1}},n.prototype.encrypt=function(e){try{return K(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"}const x=n;var j=r(655),M=function(){var{publicKey:e="",payload:t={}}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!e)return"";try{var r=(0,j.I)(t),n=new x;return n.setPublicKey(e),n.encryptLong("object"==typeof r?JSON.stringify(r):r)}catch(e){console.error("encrypt error:",e)}return""}},655:(e,t,r)=>{r.d(t,{I:()=>n,y:()=>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]||""}},182:function(e,t,r){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(274)),c=r(616);!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}}},274:function(e,t,r){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(325),c=r(616),l=r(946),d=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,d,h,f,p,v,y,g,m=this;return a(this,(function(_){switch(_.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,d=e.signal,h=e.timeout,f=e.shouldThrowOnError,p=void 0===f||f,v=null!=h?h:this.timeout,d&&(d.aborted&&r.abort(),d.addEventListener("abort",(function(){return r.abort()}))),y=null,u&&v&&(y=setTimeout((function(){console.warn(m.timeoutMsg),r.abort(new Error(m.timeoutMsg))}),v)),[4,fetch(n,i(i({},e),{signal:r.signal})).then((function(e){return s(m,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 g=_.sent(),[2,{data:l?g.body:(null===(t=g.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))?g.json():g.text(),statusCode:g.status,header:g.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,d=void 0===u?{}:u,h=e.data,f=e.responseType,p=e.withCredentials,v=e.body,y=e.onUploadProgress,g=(0,c.formatUrl)((0,l.getProtocol)(),a,"get"===n?h:{}),m=new XMLHttpRequest;m.open(n,g),f&&(m.responseType=f),Object.keys(d).forEach((function(e){m.setRequestHeader(e,d[e])})),y&&m.upload.addEventListener("progress",y),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=(0,c.isFormData)(h)?h:"application/x-www-form-urlencoded"===d["content-type"]?(0,c.toQueryString)(h):v||(h?JSON.stringify(h):void 0),p&&(m.withCredentials=!0),m.send(s)}))},t}(u.AbstractSDKRequest);t.WebRequest=d,t.genAdapter=function(){return{type:"default",root:window,reqClass:d,wsClass:WebSocket,localStorage}}},946:(e,t)=>{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"},205:(e,t)=>{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){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(946),t),o(r(205),t),t.OATUH_LOGINTYPE="constants"},718:function(e,t,r){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(616),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,"\\]")),d=s.findIndex((function(e){return u.test(e)}));if(-1!==d){var h=s.filter((function(e,t){return t>d}));h.unshift(s[d].replace(l,"".concat(r,".").concat(n)).replace(c,o)),(i=new Error).stack="".concat(a?"@debugger":"Error","\n").concat(h.join("\n"))}return i}t.catchErrorsDecorator=function(e){var t=e.mode,r=void 0===t?"async":t,a=e.customInfo,d=void 0===a?{}:a,h=e.title,f=e.messages,p=void 0===f?[]:f;return function(e,t,a){if(s.IS_DEBUG_MODE){var f=d.className||e.constructor.name,v=d.methodName||t,y=a.value,g=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:f,methodName:v,sourceLink:g});try{return y.apply(this,e)}catch(e){var n=e,o=e.message,s=e.error,a=e.error_description,u={title:h||"".concat(f,".").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,d;return o(this,(function(o){switch(o.label){case 0:t=l({err:new Error,className:f,methodName:v,sourceLink:g}),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:h||"".concat(f,".").concat(v," failed"),content:[{type:"error",body:r}]},s&&/^\{.*\}$/.test(s)&&(d=JSON.parse(s),c.subtitle=d,d.code&&(t?(t.code=d.code,t.message=d.msg):(r.code=d.code,r.message=d.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){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(718),t)},197:function(e,t,r){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(325),u=r(616),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),d=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})||void 0===r?void 0:r.tcb_token))return{IS_MP_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})||void 0===r?void 0:r.tcb_token))return[2,{IS_MP_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=d},689:function(e,t,r){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(616),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)}},616:function(e,t,r){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,d=s;l<d.length;l++){var h=d[l],f=h.type,p=h.body;switch(f){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"}}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,r),i.exports}return r.d=(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.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r(760)})()));