@cloudbase/js-sdk 3.6.2 → 3.6.3-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  /*! For license information please see index.esm.js.LICENSE.txt */
2
- import*as t from"@cloudbase/adapter-interface";import*as e from"jwt-decode";import*as r from"@cloudbase/adapter-wx_mp";var n={171:(t,e,r)=>{var n;if(r.r(e),r.d(e,{getEncryptInfo:()=>q}),!globalThis.IS_MP_BUILD){var i="undefined"!=typeof globalThis?globalThis.navigator:window.globalThis;function B(t){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(t)}function j(t,e){return t&e}function V(t,e){return t|e}function W(t,e){return t^e}function F(t,e){return t&~e}function H(t){if(0==t)return-1;var e=0;return 65535&t||(t>>=16,e+=16),255&t||(t>>=8,e+=8),15&t||(t>>=4,e+=4),3&t||(t>>=2,e+=2),1&t||++e,e}function G(t){for(var e=0;0!=t;)t&=t-1,++e;return e}var o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function K(t){var e,r,n="";for(e=0;e+3<=t.length;e+=3)r=parseInt(t.substring(e,e+3),16),n+=o.charAt(r>>6)+o.charAt(63&r);for(e+1==t.length?(r=parseInt(t.substring(e,e+1),16),n+=o.charAt(r<<2)):e+2==t.length&&(r=parseInt(t.substring(e,e+2),16),n+=o.charAt(r>>2)+o.charAt((3&r)<<4));(3&n.length)>0;)n+="=";return n}function Y(t){var e,r="",n=0,i=0;for(e=0;e<t.length&&"="!=t.charAt(e);++e){var s=o.indexOf(t.charAt(e));s<0||(0==n?(r+=B(s>>2),i=3&s,n=1):1==n?(r+=B(i<<2|s>>4),i=15&s,n=2):2==n?(r+=B(i),r+=B(s>>2),i=3&s,n=3):(r+=B(i<<2|s>>4),r+=B(15&s),n=0))}return 1==n&&(r+=B(i<<2)),r}var s,a,u={decode:function(t){var e;if(void 0===s){var r="0123456789ABCDEF";for(s={},e=0;e<16;++e)s[r.charAt(e)]=e;for(r=r.toLowerCase(),e=10;e<16;++e)s[r.charAt(e)]=e;for(e=0;e<8;++e)s[" \f\n\r\t \u2028\u2029".charAt(e)]=-1}var n=[],i=0,o=0;for(e=0;e<t.length;++e){var a=t.charAt(e);if("="==a)break;if(-1!=(a=s[a])){if(void 0===a)throw new Error("Illegal character at offset "+e);i|=a,++o>=2?(n[n.length]=i,i=0,o=0):i<<=4}}if(o)throw new Error("Hex encoding incomplete: 4 bits missing");return n}},c={decode:function(t){var e;if(void 0===a){for(a=Object.create(null),e=0;e<64;++e)a["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e)]=e;for(e=0;e<9;++e)a["= \f\n\r\t \u2028\u2029".charAt(e)]=-1}var r=[],n=0,i=0;for(e=0;e<t.length;++e){var o=t.charAt(e);if("="==o)break;if(-1!=(o=a[o])){if(void 0===o)throw new Error("Illegal character at offset "+e);n|=o,++i>=4?(r[r.length]=n>>16,r[r.length]=n>>8&255,r[r.length]=255&n,n=0,i=0):n<<=6}}switch(i){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:r[r.length]=n>>10;break;case 3:r[r.length]=n>>16,r[r.length]=n>>8&255}return r},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(t){var e=c.re.exec(t);if(e)if(e[1])t=e[1];else{if(!e[2])throw new Error("RegExp out of sync");t=e[2]}return c.decode(t)}},h=1e13;class z{constructor(t){this.buf=[+t||0]}mulAdd(t,e){var r,n,i=this.buf,o=i.length;for(r=0;r<o;++r)(n=i[r]*t+e)<h?e=0:n-=(e=0|n/h)*h,i[r]=n;e>0&&(i[r]=e)}sub(t){var e,r,n=this.buf,i=n.length;for(e=0;e<i;++e)(r=n[e]-t)<0?(r+=h,t=1):t=0,n[e]=r;for(;0===n[n.length-1];)n.pop()}toString(t){if(10!=(t||10))throw new Error("only base 10 is supported");for(var e=this.buf,r=e[e.length-1].toString(),n=e.length-2;n>=0;--n)r+=(h+e[n]).toString().substring(1);return r}valueOf(){for(var t=this.buf,e=0,r=t.length-1;r>=0;--r)e=e*h+t[r];return e}simplify(){var t=this.buf;return 1==t.length?t[0]:this}}var l,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)?)?$/,f=/^(\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(t,e){return t.length>e&&(t=t.substring(0,e)+"…"),t}class J{constructor(t,e){this.hexDigits="0123456789ABCDEF",t instanceof J?(this.enc=t.enc,this.pos=t.pos):(this.enc=t,this.pos=e)}get(t){if(void 0===t&&(t=this.pos++),t>=this.enc.length)throw new Error("Requesting byte offset "+t+" on a stream of length "+this.enc.length);return"string"==typeof this.enc?this.enc.charCodeAt(t):this.enc[t]}hexByte(t){return this.hexDigits.charAt(t>>4&15)+this.hexDigits.charAt(15&t)}hexDump(t,e,r){for(var n="",i=t;i<e;++i)if(n+=this.hexByte(this.get(i)),!0!==r)switch(15&i){case 7:n+=" ";break;case 15:n+="\n";break;default:n+=" "}return n}isASCII(t,e){for(var r=t;r<e;++r){var n=this.get(r);if(n<32||n>176)return!1}return!0}parseStringISO(t,e){for(var r="",n=t;n<e;++n)r+=String.fromCharCode(this.get(n));return r}parseStringUTF(t,e){for(var r="",n=t;n<e;){var i=this.get(n++);r+=i<128?String.fromCharCode(i):i>191&&i<224?String.fromCharCode((31&i)<<6|63&this.get(n++)):String.fromCharCode((15&i)<<12|(63&this.get(n++))<<6|63&this.get(n++))}return r}parseStringBMP(t,e){for(var r,n,i="",o=t;o<e;)r=this.get(o++),n=this.get(o++),i+=String.fromCharCode(r<<8|n);return i}parseTime(t,e,r){var n=this.parseStringISO(t,e),i=(r?d:f).exec(n);return i?(r&&(i[1]=+i[1],i[1]+=+i[1]<70?2e3:1900),n=i[1]+"-"+i[2]+"-"+i[3]+" "+i[4],i[5]&&(n+=":"+i[5],i[6]&&(n+=":"+i[6],i[7]&&(n+="."+i[7]))),i[8]&&(n+=" UTC","Z"!=i[8]&&(n+=i[8],i[9]&&(n+=":"+i[9]))),n):"Unrecognized time: "+n}parseInteger(t,e){for(var r,n=this.get(t),i=n>127,o=i?255:0,s="";n==o&&++t<e;)n=this.get(t);if(0===(r=e-t))return i?-1:0;if(r>4){for(s=n,r<<=3;!(128&(+s^o));)s=+s<<1,--r;s="("+r+" bit)\n"}i&&(n-=256);for(var a=new z(n),u=t+1;u<e;++u)a.mulAdd(256,this.get(u));return s+a.toString()}parseBitString(t,e,r){for(var n=this.get(t),i="("+((e-t-1<<3)-n)+" bit)\n",o="",s=t+1;s<e;++s){for(var a=this.get(s),u=s==e-1?n:0,c=7;c>=u;--c)o+=a>>c&1?"1":"0";if(o.length>r)return i+Q(o,r)}return i+o}parseOctetString(t,e,r){if(this.isASCII(t,e))return Q(this.parseStringISO(t,e),r);var n=e-t,i="("+n+" byte)\n";n>(r/=2)&&(e=t+r);for(var o=t;o<e;++o)i+=this.hexByte(this.get(o));return n>r&&(i+="…"),i}parseOID(t,e,r){for(var n="",i=new z,o=0,s=t;s<e;++s){var a=this.get(s);if(i.mulAdd(128,127&a),o+=7,!(128&a)){if(""===n)if((i=i.simplify())instanceof z)i.sub(80),n="2."+i.toString();else{var u=i<80?i<40?0:1:2;n=u+"."+(i-40*u)}else n+="."+i.toString();if(n.length>r)return Q(n,r);i=new z,o=0}}return o>0&&(n+=".incomplete"),n}}class Z{constructor(t,e,r,n,i){if(!(n instanceof X))throw new Error("Invalid tag value.");this.stream=t,this.header=e,this.length=r,this.tag=n,this.sub=i}typeName(){switch(this.tag.tagClass){case 0:switch(this.tag.tagNumber){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER";case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString";case 30:return"BMPString"}return"Universal_"+this.tag.tagNumber.toString();case 1:return"Application_"+this.tag.tagNumber.toString();case 2:return"["+this.tag.tagNumber.toString()+"]";case 3:return"Private_"+this.tag.tagNumber.toString()}}content(t){if(void 0===this.tag)return null;void 0===t&&(t=1/0);var e=this.posContent(),r=Math.abs(this.length);if(!this.tag.isUniversal())return null!==this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+r,t);switch(this.tag.tagNumber){case 1:return 0===this.stream.get(e)?"false":"true";case 2:return this.stream.parseInteger(e,e+r);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(e,e+r,t);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+r,t);case 6:return this.stream.parseOID(e,e+r,t);case 16:case 17:return null!==this.sub?"("+this.sub.length+" elem)":"(no elem)";case 12:return Q(this.stream.parseStringUTF(e,e+r),t);case 18:case 19:case 20:case 21:case 22:case 26:return Q(this.stream.parseStringISO(e,e+r),t);case 30:return Q(this.stream.parseStringBMP(e,e+r),t);case 23:case 24:return this.stream.parseTime(e,e+r,23==this.tag.tagNumber)}return null}toString(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(null===this.sub?"null":this.sub.length)+"]"}toPrettyString(t){void 0===t&&(t="");var e=t+this.typeName()+" @"+this.stream.pos;if(this.length>=0&&(e+="+"),e+=this.length,this.tag.tagConstructed?e+=" (constructed)":!this.tag.isUniversal()||3!=this.tag.tagNumber&&4!=this.tag.tagNumber||null===this.sub||(e+=" (encapsulates)"),e+="\n",null!==this.sub){t+=" ";for(var r=0,n=this.sub.length;r<n;++r)e+=this.sub[r].toPrettyString(t)}return e}posStart(){return this.stream.pos}posContent(){return this.stream.pos+this.header}posEnd(){return this.stream.pos+this.header+Math.abs(this.length)}toHexString(){return this.stream.hexDump(this.posStart(),this.posEnd(),!0)}static decodeLength(t){var e=t.get(),r=127&e;if(r==e)return r;if(r>6)throw new Error("Length over 48 bits not supported at position "+(t.pos-1));if(0===r)return null;e=0;for(var n=0;n<r;++n)e=256*e+t.get();return e}getHexStringValue(){var t=this.toHexString(),e=2*this.header,r=2*this.length;return t.substr(e,r)}static decode(t){var e;e=t instanceof J?t:new J(t,0);var r=new J(e),n=new X(e),i=Z.decodeLength(e),o=e.pos,s=o-r.pos,a=null,u=function(){var t=[];if(null!==i){for(var r=o+i;e.pos<r;)t[t.length]=Z.decode(e);if(e.pos!=r)throw new Error("Content size is not correct for container starting at offset "+o)}else try{for(;;){var n=Z.decode(e);if(n.tag.isEOC())break;t[t.length]=n}i=o-e.pos}catch(t){throw new Error("Exception while decoding undefined length content: "+t)}return t};if(n.tagConstructed)a=u();else if(n.isUniversal()&&(3==n.tagNumber||4==n.tagNumber))try{if(3==n.tagNumber&&0!=e.get())throw new Error("BIT STRINGs with unused bits cannot encapsulate.");a=u();for(var c=0;c<a.length;++c)if(a[c].tag.isEOC())throw new Error("EOC is not supposed to be actual content.")}catch(t){a=null}if(null===a){if(null===i)throw new Error("We can't skip over an invalid tag with undefined length at offset "+o);e.pos=o+Math.abs(i)}return new Z(r,s,i,n,a)}}class X{constructor(t){var e=t.get();if(this.tagClass=e>>6,this.tagConstructed=!!(32&e),this.tagNumber=31&e,31==this.tagNumber){var r=new z;do{e=t.get(),r.mulAdd(128,127&e)}while(128&e);this.tagNumber=r.simplify()}}isUniversal(){return 0===this.tagClass}isEOC(){return 0===this.tagClass&&0===this.tagNumber}}var p=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],v=(1<<26)/p[p.length-1];class ${constructor(t,e,r){null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}toString(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,n=(1<<e)-1,i=!1,o="",s=this.t,a=this.DB-s*this.DB%e;if(s-- >0)for(a<this.DB&&(r=this[s]>>a)>0&&(i=!0,o=B(r));s>=0;)a<e?(r=(this[s]&(1<<a)-1)<<e-a,r|=this[--s]>>(a+=this.DB-e)):(r=this[s]>>(a-=e)&n,a<=0&&(a+=this.DB,--s)),r>0&&(i=!0),i&&(o+=B(r));return i?o:"0"}negate(){var t=tt();return $.ZERO.subTo(this,t),t}abs(){return this.s<0?this.negate():this}compareTo(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0}bitLength(){return this.t<=0?0:this.DB*(this.t-1)+at(this[this.t-1]^this.s&this.DM)}mod(t){var e=tt();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo($.ZERO)>0&&t.subTo(e,e),e}modPowInt(t,e){var r;return r=t<256||e.isEven()?new m(e):new y(e),this.exp(t,r)}clone(){var t=tt();return this.copyTo(t),t}intValue(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]}byteValue(){return 0==this.t?this.s:this[0]<<24>>24}shortValue(){return 0==this.t?this.s:this[0]<<16>>16}signum(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1}toByteArray(){var t=this.t,e=[];e[0]=this.s;var r,n=this.DB-t*this.DB%8,i=0;if(t-- >0)for(n<this.DB&&(r=this[t]>>n)!=(this.s&this.DM)>>n&&(e[i++]=r|this.s<<this.DB-n);t>=0;)n<8?(r=(this[t]&(1<<n)-1)<<8-n,r|=this[--t]>>(n+=this.DB-8)):(r=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),128&r&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(e[i++]=r);return e}equals(t){return 0==this.compareTo(t)}min(t){return this.compareTo(t)<0?this:t}max(t){return this.compareTo(t)>0?this:t}and(t){var e=tt();return this.bitwiseTo(t,j,e),e}or(t){var e=tt();return this.bitwiseTo(t,V,e),e}xor(t){var e=tt();return this.bitwiseTo(t,W,e),e}andNot(t){var e=tt();return this.bitwiseTo(t,F,e),e}not(){for(var t=tt(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t}shiftLeft(t){var e=tt();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e}shiftRight(t){var e=tt();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e}getLowestSetBit(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+H(this[t]);return this.s<0?this.t*this.DB:-1}bitCount(){for(var t=0,e=this.s&this.DM,r=0;r<this.t;++r)t+=G(this[r]^e);return t}testBit(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:!!(this[e]&1<<t%this.DB)}setBit(t){return this.changeBit(t,V)}clearBit(t){return this.changeBit(t,F)}flipBit(t){return this.changeBit(t,W)}add(t){var e=tt();return this.addTo(t,e),e}subtract(t){var e=tt();return this.subTo(t,e),e}multiply(t){var e=tt();return this.multiplyTo(t,e),e}divide(t){var e=tt();return this.divRemTo(t,e,null),e}remainder(t){var e=tt();return this.divRemTo(t,null,e),e}divideAndRemainder(t){var e=tt(),r=tt();return this.divRemTo(t,e,r),[e,r]}modPow(t,e){var r,n,i=t.bitLength(),o=st(1);if(i<=0)return o;r=i<18?1:i<48?3:i<144?4:i<768?5:6,n=i<8?new m(e):e.isEven()?new _(e):new y(e);var s=[],a=3,u=r-1,c=(1<<r)-1;if(s[1]=n.convert(this),r>1){var h=tt();for(n.sqrTo(s[1],h);a<=c;)s[a]=tt(),n.mulTo(h,s[a-2],s[a]),a+=2}var l,d,f=t.t-1,p=!0,v=tt();for(i=at(t[f])-1;f>=0;){for(i>=u?l=t[f]>>i-u&c:(l=(t[f]&(1<<i+1)-1)<<u-i,f>0&&(l|=t[f-1]>>this.DB+i-u)),a=r;!(1&l);)l>>=1,--a;if((i-=a)<0&&(i+=this.DB,--f),p)s[l].copyTo(o),p=!1;else{for(;a>1;)n.sqrTo(o,v),n.sqrTo(v,o),a-=2;a>0?n.sqrTo(o,v):(d=o,o=v,v=d),n.mulTo(v,s[l],o)}for(;f>=0&&!(t[f]&1<<i);)n.sqrTo(o,v),d=o,o=v,v=d,--i<0&&(i=this.DB-1,--f)}return n.revert(o)}modInverse(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return $.ZERO;for(var r=t.clone(),n=this.clone(),i=st(1),o=st(0),s=st(0),a=st(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),e?(i.isEven()&&o.isEven()||(i.addTo(this,i),o.subTo(t,o)),i.rShiftTo(1,i)):o.isEven()||o.subTo(t,o),o.rShiftTo(1,o);for(;n.isEven();)n.rShiftTo(1,n),e?(s.isEven()&&a.isEven()||(s.addTo(this,s),a.subTo(t,a)),s.rShiftTo(1,s)):a.isEven()||a.subTo(t,a),a.rShiftTo(1,a);r.compareTo(n)>=0?(r.subTo(n,r),e&&i.subTo(s,i),o.subTo(a,o)):(n.subTo(r,n),e&&s.subTo(i,s),a.subTo(o,a))}return 0!=n.compareTo($.ONE)?$.ZERO:a.compareTo(t)>=0?a.subtract(t):a.signum()<0?(a.addTo(t,a),a.signum()<0?a.add(t):a):a}pow(t){return this.exp(t,new g)}gcd(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var i=e.getLowestSetBit(),o=r.getLowestSetBit();if(o<0)return e;for(i<o&&(o=i),o>0&&(e.rShiftTo(o,e),r.rShiftTo(o,r));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return o>0&&r.lShiftTo(o,r),r}isProbablePrime(t){var e,r=this.abs();if(1==r.t&&r[0]<=p[p.length-1]){for(e=0;e<p.length;++e)if(r[0]==p[e])return!0;return!1}if(r.isEven())return!1;for(e=1;e<p.length;){for(var n=p[e],i=e+1;i<p.length&&n<v;)n*=p[i++];for(n=r.modInt(n);e<i;)if(n%p[e++]==0)return!1}return r.millerRabin(t)}copyTo(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s}fromInt(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0}fromString(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var n=t.length,i=!1,o=0;--n>=0;){var s=8==r?255&+t[n]:ot(t,n);s<0?"-"==t.charAt(n)&&(i=!0):(i=!1,0==o?this[this.t++]=s:o+r>this.DB?(this[this.t-1]|=(s&(1<<this.DB-o)-1)<<o,this[this.t++]=s>>this.DB-o):this[this.t-1]|=s<<o,(o+=r)>=this.DB&&(o-=this.DB))}8==r&&128&+t[0]&&(this.s=-1,o>0&&(this[this.t-1]|=(1<<this.DB-o)-1<<o)),this.clamp(),i&&$.ZERO.subTo(this,this)}clamp(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t}dlShiftTo(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s}drShiftTo(t,e){for(var r=t;r<this.t;++r)e[r-t]=this[r];e.t=Math.max(this.t-t,0),e.s=this.s}lShiftTo(t,e){for(var r=t%this.DB,n=this.DB-r,i=(1<<n)-1,o=Math.floor(t/this.DB),s=this.s<<r&this.DM,a=this.t-1;a>=0;--a)e[a+o+1]=this[a]>>n|s,s=(this[a]&i)<<r;for(a=o-1;a>=0;--a)e[a]=0;e[o]=s,e.t=this.t+o+1,e.s=this.s,e.clamp()}rShiftTo(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var n=t%this.DB,i=this.DB-n,o=(1<<n)-1;e[0]=this[r]>>n;for(var s=r+1;s<this.t;++s)e[s-r-1]|=(this[s]&o)<<i,e[s-r]=this[s]>>n;n>0&&(e[this.t-r-1]|=(this.s&o)<<i),e.t=this.t-r,e.clamp()}}subTo(t,e){for(var r=0,n=0,i=Math.min(t.t,this.t);r<i;)n+=this[r]-t[r],e[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n-=t.s;r<this.t;)n+=this[r],e[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n-=t[r],e[r++]=n&this.DM,n>>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[r++]=this.DV+n:n>0&&(e[r++]=n),e.t=r,e.clamp()}multiplyTo(t,e){var r=this.abs(),n=t.abs(),i=r.t;for(e.t=i+n.t;--i>=0;)e[i]=0;for(i=0;i<n.t;++i)e[i+r.t]=r.am(0,n[i],e,i,0,r.t);e.s=0,e.clamp(),this.s!=t.s&&$.ZERO.subTo(e,e)}squareTo(t){for(var e=this.abs(),r=t.t=2*e.t;--r>=0;)t[r]=0;for(r=0;r<e.t-1;++r){var n=e.am(r,e[r],t,2*r,0,1);(t[r+e.t]+=e.am(r+1,2*e[r],t,2*r+1,n,e.t-r-1))>=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()}divRemTo(t,e,r){var n=t.abs();if(!(n.t<=0)){var i=this.abs();if(i.t<n.t)return null!=e&&e.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=tt());var o=tt(),s=this.s,a=t.s,u=this.DB-at(n[n.t-1]);u>0?(n.lShiftTo(u,o),i.lShiftTo(u,r)):(n.copyTo(o),i.copyTo(r));var c=o.t,h=o[c-1];if(0!=h){var l=h*(1<<this.F1)+(c>1?o[c-2]>>this.F2:0),d=this.FV/l,f=(1<<this.F1)/l,p=1<<this.F2,v=r.t,g=v-c,m=e??tt();for(o.dlShiftTo(g,m),r.compareTo(m)>=0&&(r[r.t++]=1,r.subTo(m,r)),$.ONE.dlShiftTo(c,m),m.subTo(o,o);o.t<c;)o[o.t++]=0;for(;--g>=0;){var y=r[--v]==h?this.DM:Math.floor(r[v]*d+(r[v-1]+p)*f);if((r[v]+=o.am(0,y,r,g,0,c))<y)for(o.dlShiftTo(g,m),r.subTo(m,r);r[v]<--y;)r.subTo(m,r)}null!=e&&(r.drShiftTo(c,e),s!=a&&$.ZERO.subTo(e,e)),r.t=c,r.clamp(),u>0&&r.rShiftTo(u,r),s<0&&$.ZERO.subTo(r,r)}}}invDigit(){if(this.t<1)return 0;var t=this[0];if(!(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e}isEven(){return 0==(this.t>0?1&this[0]:this.s)}exp(t,e){if(t>4294967295||t<1)return $.ONE;var r=tt(),n=tt(),i=e.convert(this),o=at(t)-1;for(i.copyTo(r);--o>=0;)if(e.sqrTo(r,n),(t&1<<o)>0)e.mulTo(n,i,r);else{var s=r;r=n,n=s}return e.revert(r)}chunkSize(t){return Math.floor(Math.LN2*this.DB/Math.log(t))}toRadix(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),n=st(r),i=tt(),o=tt(),s="";for(this.divRemTo(n,i,o);i.signum()>0;)s=(r+o.intValue()).toString(t).substr(1)+s,i.divRemTo(n,i,o);return o.intValue().toString(t)+s}fromRadix(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),n=Math.pow(e,r),i=!1,o=0,s=0,a=0;a<t.length;++a){var u=ot(t,a);u<0?"-"==t.charAt(a)&&0==this.signum()&&(i=!0):(s=e*s+u,++o>=r&&(this.dMultiply(n),this.dAddOffset(s,0),o=0,s=0))}o>0&&(this.dMultiply(Math.pow(e,o)),this.dAddOffset(s,0)),i&&$.ZERO.subTo(this,this)}fromNumber(t,e,r){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo($.ONE.shiftLeft(t-1),V,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo($.ONE.shiftLeft(t-1),this);else{var n=[],i=7&t;n.length=1+(t>>3),e.nextBytes(n),i>0?n[0]&=(1<<i)-1:n[0]=0,this.fromString(n,256)}}bitwiseTo(t,e,r){var n,i,o=Math.min(t.t,this.t);for(n=0;n<o;++n)r[n]=e(this[n],t[n]);if(t.t<this.t){for(i=t.s&this.DM,n=o;n<this.t;++n)r[n]=e(this[n],i);r.t=this.t}else{for(i=this.s&this.DM,n=o;n<t.t;++n)r[n]=e(i,t[n]);r.t=t.t}r.s=e(this.s,t.s),r.clamp()}changeBit(t,e){var r=$.ONE.shiftLeft(t);return this.bitwiseTo(r,e,r),r}addTo(t,e){for(var r=0,n=0,i=Math.min(t.t,this.t);r<i;)n+=this[r]+t[r],e[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n+=t.s;r<this.t;)n+=this[r],e[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n+=t[r],e[r++]=n&this.DM,n>>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[r++]=n:n<-1&&(e[r++]=this.DV+n),e.t=r,e.clamp()}dMultiply(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()}dAddOffset(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}}multiplyLowerTo(t,e,r){var n=Math.min(this.t+t.t,e);for(r.s=0,r.t=n;n>0;)r[--n]=0;for(var i=r.t-this.t;n<i;++n)r[n+this.t]=this.am(0,t[n],r,n,0,this.t);for(i=Math.min(t.t,e);n<i;++n)this.am(0,t[n],r,n,0,e-n);r.clamp()}multiplyUpperTo(t,e,r){--e;var n=r.t=this.t+t.t-e;for(r.s=0;--n>=0;)r[n]=0;for(n=Math.max(e-this.t,0);n<t.t;++n)r[this.t+n-e]=this.am(e-n,t[n],r,0,0,this.t+n-e);r.clamp(),r.drShiftTo(1,r)}modInt(t){if(t<=0)return 0;var e=this.DV%t,r=this.s<0?t-1:0;if(this.t>0)if(0==e)r=this[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this[n])%t;return r}millerRabin(t){var e=this.subtract($.ONE),r=e.getLowestSetBit();if(r<=0)return!1;var n=e.shiftRight(r);(t=t+1>>1)>p.length&&(t=p.length);for(var i=tt(),o=0;o<t;++o){i.fromInt(p[Math.floor(Math.random()*p.length)]);var s=i.modPow(n,this);if(0!=s.compareTo($.ONE)&&0!=s.compareTo(e)){for(var a=1;a++<r&&0!=s.compareTo(e);)if(0==(s=s.modPowInt(2,this)).compareTo($.ONE))return!1;if(0!=s.compareTo(e))return!1}}return!0}square(){var t=tt();return this.squareTo(t),t}gcda(t,e){var r=this.s<0?this.negate():this.clone(),n=t.s<0?t.negate():t.clone();if(r.compareTo(n)<0){var i=r;r=n,n=i}var o=r.getLowestSetBit(),s=n.getLowestSetBit();if(s<0)e(r);else{o<s&&(s=o),s>0&&(r.rShiftTo(s,r),n.rShiftTo(s,n));var a=()=>{(o=r.getLowestSetBit())>0&&r.rShiftTo(o,r),(o=n.getLowestSetBit())>0&&n.rShiftTo(o,n),r.compareTo(n)>=0?(r.subTo(n,r),r.rShiftTo(1,r)):(n.subTo(r,n),n.rShiftTo(1,n)),r.signum()>0?setTimeout(a,0):(s>0&&n.lShiftTo(s,n),setTimeout(function(){e(n)},0))};setTimeout(a,10)}}fromNumberAsync(t,e,r,n){if("number"==typeof e)if(t<2)this.fromInt(1);else{this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo($.ONE.shiftLeft(t-1),V,this),this.isEven()&&this.dAddOffset(1,0);var i=this,o=function(){i.dAddOffset(2,0),i.bitLength()>t&&i.subTo($.ONE.shiftLeft(t-1),i),i.isProbablePrime(e)?setTimeout(function(){n()},0):setTimeout(o,0)};setTimeout(o,0)}else{var s=[],a=7&t;s.length=1+(t>>3),e.nextBytes(s),a>0?s[0]&=(1<<a)-1:s[0]=0,this.fromString(s,256)}}}var g=function(){function t(){}return t.prototype.convert=function(t){return t},t.prototype.revert=function(t){return t},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},t.prototype.sqrTo=function(t,e){t.squareTo(e)},t}(),m=function(){function t(t){this.m=t}return t.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},t.prototype.revert=function(t){return t},t.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),y=function(){function t(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}return t.prototype.convert=function(t){var e=tt();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo($.ZERO)>0&&this.m.subTo(e,e),e},t.prototype.revert=function(t){var e=tt();return t.copyTo(e),this.reduce(e),e},t.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var r=32767&t[e],n=r*this.mpl+((r*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),_=function(){function t(t){this.m=t,this.r2=tt(),this.q3=tt(),$.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t)}return t.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=tt();return t.copyTo(e),this.reduce(e),e},t.prototype.revert=function(t){return t},t.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}();function tt(){return new $(null)}function et(t,e){return new $(t,e)}function rt(t,e,r,n,i,o){for(;--o>=0;){var s=e*this[t++]+r[n]+i;i=Math.floor(s/67108864),r[n++]=67108863&s}return i}function nt(t,e,r,n,i,o){for(var s=32767&e,a=e>>15;--o>=0;){var u=32767&this[t],c=this[t++]>>15,h=a*u+c*s;i=((u=s*u+((32767&h)<<15)+r[n]+(1073741823&i))>>>30)+(h>>>15)+a*c+(i>>>30),r[n++]=1073741823&u}return i}function it(t,e,r,n,i,o){for(var s=16383&e,a=e>>14;--o>=0;){var u=16383&this[t],c=this[t++]>>14,h=a*u+c*s;i=((u=s*u+((16383&h)<<14)+r[n]+i)>>28)+(h>>14)+a*c,r[n++]=268435455&u}return i}void 0!==i&&"Microsoft Internet Explorer"==(null==i?void 0:i.appName)?($.prototype.am=nt,l=30):"Netscape"!=(null==i?void 0:i.appName)?($.prototype.am=rt,l=26):($.prototype.am=it,l=28),$.prototype.DB=l,$.prototype.DM=(1<<l)-1,$.prototype.DV=1<<l,$.prototype.FV=Math.pow(2,52),$.prototype.F1=52-l,$.prototype.F2=2*l-52;var b,I,w=[];for(b="0".charCodeAt(0),I=0;I<=9;++I)w[b++]=I;for(b="a".charCodeAt(0),I=10;I<36;++I)w[b++]=I;for(b="A".charCodeAt(0),I=10;I<36;++I)w[b++]=I;function ot(t,e){return w[t.charCodeAt(e)]??-1}function st(t){var e=tt();return e.fromInt(t),e}function at(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}$.ZERO=st(0),$.ONE=st(1);class ut{constructor(){this.i=0,this.j=0,this.S=[]}init(t){var e,r,n;for(e=0;e<256;++e)this.S[e]=e;for(r=0,e=0;e<256;++e)r=r+this.S[e]+t[e%t.length]&255,n=this.S[e],this.S[e]=this.S[r],this.S[r]=n;this.i=0,this.j=0}next(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]}}var E,S,A=null;if(null==A){A=[],S=0;var P,O,T=void 0;if("undefined"!=typeof window&&null!==(P=window)&&void 0!==P&&P.crypto&&null!==(O=window)&&void 0!==O&&O.crypto.getRandomValues){var R,C=new Uint32Array(256);for(null===(R=window)||void 0===R||R.crypto.getRandomValues(C),T=0;T<C.length;++T)A[S++]=255&C[T]}var U,N,L,D=function(t){var e,r,n;if(this.count=this.count||0,this.count>=256||S>=256){if("undefined"!=typeof window)if(null!==(e=window)&&void 0!==e&&e.removeEventListener)null===(n=window)||void 0===n||n.removeEventListener("mousemove",D,!1);else if(null!==(r=window)&&void 0!==r&&r.detachEvent){var i;null===(i=window)||void 0===i||i.detachEvent("onmousemove",D)}}else try{var o=t.x+t.y;A[S++]=255&o,this.count+=1}catch(t){}};if("undefined"!=typeof window)if(null!==(U=window)&&void 0!==U&&U.addEventListener)null===(L=window)||void 0===L||L.addEventListener("mousemove",D,!1);else if(null!==(N=window)&&void 0!==N&&N.attachEvent){var k;null===(k=window)||void 0===k||k.attachEvent("onmousemove",D)}}function ct(){if(null==E){for(E=new ut;S<256;){var t=Math.floor(65536*Math.random());A[S++]=255&t}for(E.init(A),S=0;S<A.length;++S)A[S]=0;S=0}return E.next()}class ht{constructor(){}nextBytes(t){for(var e=0;e<t.length;++e)t[e]=ct()}}function lt(t,e){if(e<t.length+11)return console.error("Message too long for RSA"),null;for(var r=[],n=t.length-1;n>=0&&e>0;){var i=t.charCodeAt(n--);i<128?r[--e]=i:i>127&&i<2048?(r[--e]=63&i|128,r[--e]=i>>6|192):(r[--e]=63&i|128,r[--e]=i>>6&63|128,r[--e]=i>>12|224)}r[--e]=0;for(var o=new ht,s=[];e>2;){for(s[0]=0;0==s[0];)o.nextBytes(s);r[--e]=s[0]}return r[--e]=2,r[--e]=0,new $(r)}class dt{constructor(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}doPublic(t){return t.modPowInt(this.e,this.n)}doPrivate(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),r=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(r)<0;)e=e.add(this.p);return e.subtract(r).multiply(this.coeff).mod(this.p).multiply(this.q).add(r)}setPublic(t,e){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=et(t,16),this.e=parseInt(e,16)):console.error("Invalid RSA public key")}encrypt(t){var e=lt(t,this.n.bitLength()+7>>3);if(null==e)return null;var r=this.doPublic(e);if(null==r)return null;var n=r.toString(16);return 1&n.length?"0"+n:n}encryptLong(t){var e=this,r=(this.n.bitLength()+7>>3)-11;try{var n="";return t.length>r?(t.match(/.{1,117}/g).forEach(function(t){var r=e.encrypt(t);n+=r}),K(n)):K(this.encrypt(t))}catch(t){return!1}}decryptLong(t){var e=this,r=this.n.bitLength()+7>>3;t=Y(t);try{if(t.length>r){var n="";return t.match(/.{1,256}/g).forEach(function(t){var r=e.decrypt(t);n+=r}),n}return this.decrypt(t)}catch(t){return!1}}setPrivate(t,e,r){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=et(t,16),this.e=parseInt(e,16),this.d=et(r,16)):console.error("Invalid RSA private key")}setPrivateEx(t,e,r,n,i,o,s,a){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=et(t,16),this.e=parseInt(e,16),this.d=et(r,16),this.p=et(n,16),this.q=et(i,16),this.dmp1=et(o,16),this.dmq1=et(s,16),this.coeff=et(a,16)):console.error("Invalid RSA private key")}generate(t,e){var r=new ht,n=t>>1;this.e=parseInt(e,16);for(var i=new $(e,16);;){for(;this.p=new $(t-n,1,r),0!=this.p.subtract($.ONE).gcd(i).compareTo($.ONE)||!this.p.isProbablePrime(10););for(;this.q=new $(n,1,r),0!=this.q.subtract($.ONE).gcd(i).compareTo($.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var o=this.p;this.p=this.q,this.q=o}var s=this.p.subtract($.ONE),a=this.q.subtract($.ONE),u=s.multiply(a);if(0==u.gcd(i).compareTo($.ONE)){this.n=this.p.multiply(this.q),this.d=i.modInverse(u),this.dmp1=this.d.mod(s),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}}decrypt(t){var e=et(t,16),r=this.doPrivate(e);return null==r?null:ft(r,this.n.bitLength()+7>>3)}generateAsync(t,e,r){var n=new ht,i=t>>1;this.e=parseInt(e,16);var o=new $(e,16),s=this,a=()=>{var e=()=>{if(s.p.compareTo(s.q)<=0){var t=s.p;s.p=s.q,s.q=t}var e=s.p.subtract($.ONE),n=s.q.subtract($.ONE),i=e.multiply(n);0==i.gcd(o).compareTo($.ONE)?(s.n=s.p.multiply(s.q),s.d=o.modInverse(i),s.dmp1=s.d.mod(e),s.dmq1=s.d.mod(n),s.coeff=s.q.modInverse(s.p),setTimeout(function(){r()},0)):setTimeout(a,0)},u=()=>{s.q=tt(),s.q.fromNumberAsync(i,1,n,function(){s.q.subtract($.ONE).gcda(o,function(t){0==t.compareTo($.ONE)&&s.q.isProbablePrime(10)?setTimeout(e,0):setTimeout(u,0)})})},c=()=>{s.p=tt(),s.p.fromNumberAsync(t-i,1,n,function(){s.p.subtract($.ONE).gcda(o,function(t){0==t.compareTo($.ONE)&&s.p.isProbablePrime(10)?setTimeout(u,0):setTimeout(c,0)})})};setTimeout(c,0)};setTimeout(a,0)}}function ft(t,e){for(var r=t.toByteArray(),n=0;n<r.length&&0==r[n];)++n;if(r.length-n!=e-1||2!=r[n])return null;for(++n;0!=r[n];)if(++n>=r.length)return null;for(var i="";++n<r.length;){var o=255&r[n];o<128?i+=String.fromCharCode(o):o>191&&o<224?(i+=String.fromCharCode((31&o)<<6|63&r[n+1]),++n):(i+=String.fromCharCode((15&o)<<12|(63&r[n+1])<<6|63&r[n+2]),n+=2)}return i}class pt extends dt{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";super(),t&&("string"==typeof t?this.parseKey(t):(this.hasPrivateKeyProperty(t)||this.hasPublicKeyProperty(t))&&this.parsePropertiesFrom(t))}parseKey(t){try{var e=0,r=0,n=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(t)?u.decode(t):c.unarmor(t),i=Z.decode(n);if(3===i.sub.length&&(i=i.sub[2].sub[0]),9===i.sub.length){e=i.sub[1].getHexStringValue(),this.n=et(e,16),r=i.sub[2].getHexStringValue(),this.e=parseInt(r,16);var o=i.sub[3].getHexStringValue();this.d=et(o,16);var s=i.sub[4].getHexStringValue();this.p=et(s,16);var a=i.sub[5].getHexStringValue();this.q=et(a,16);var h=i.sub[6].getHexStringValue();this.dmp1=et(h,16);var l=i.sub[7].getHexStringValue();this.dmq1=et(l,16);var d=i.sub[8].getHexStringValue();this.coeff=et(d,16)}else{if(2!==i.sub.length)return!1;var f=i.sub[1].sub[0];e=f.sub[0].getHexStringValue(),this.n=et(e,16),r=f.sub[1].getHexStringValue(),this.e=parseInt(r,16)}return!0}catch(t){return!1}}hasPublicKeyProperty(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")}hasPrivateKeyProperty(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")&&t.hasOwnProperty("d")&&t.hasOwnProperty("p")&&t.hasOwnProperty("q")&&t.hasOwnProperty("dmp1")&&t.hasOwnProperty("dmq1")&&t.hasOwnProperty("coeff")}parsePropertiesFrom(t){this.n=t.n,this.e=t.e,t.hasOwnProperty("d")&&(this.d=t.d,this.p=t.p,this.q=t.q,this.dmp1=t.dmp1,this.dmq1=t.dmq1,this.coeff=t.coeff)}}(n=function(t){t=t||{},this.default_key_size=parseInt(t.default_key_size,10)||1024,this.default_public_exponent=t.default_public_exponent||"010001",this.log=t.log||!1,this.key=null}).prototype.setKey=function(t){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new pt(t)},n.prototype.setPrivateKey=function(t){this.setKey(t)},n.prototype.setPublicKey=function(t){this.setKey(t)},n.prototype.decrypt=function(t){try{return this.getKey().decrypt(Y(t))}catch(t){return!1}},n.prototype.encrypt=function(t){try{return K(this.getKey().encrypt(t))}catch(t){return!1}},n.prototype.encryptLong=function(t){try{for(var e=this.getKey().encryptLong(t)||"",r=this.getKey().decryptLong(e)||"",n=0,i=/null$/g;i.test(r)&&(n++,e=this.getKey().encryptLong(t)||"",r=this.getKey().decryptLong(e)||"",!(n>10)););return e}catch(t){return!1}},n.prototype.getKey=function(t){if(!this.key){if(this.key=new pt,t&&"[object Function]"==={}.toString.call(t))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,t);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},n.version="3.1.4"}const x=n;var M=r(631),q=function(t){var e=void 0===t?{}:t,r=e.publicKey,n=void 0===r?"":r,i=e.payload,o=void 0===i?{}:i;if(!n)return"";try{var s=(0,M.I)(o),a=new x;return a.setPublicKey(n),a.encryptLong("object"==typeof s?JSON.stringify(s):s)}catch(t){console.error("encrypt error:",t)}return""}},631:(t,e,r)=>{r.d(e,{I:()=>n,y:()=>i});var n=function(t){var e=function(e){for(var r in t)t.hasOwnProperty(r)&&(e[r]=n(t[r]));return e},r=null==t?"NullOrUndefined":Object.prototype.toString.call(t).slice(8,-1);if(["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"].includes(r))return t.slice();switch(r){case"Object":return e(Object.create(Object.getPrototypeOf(t)));case"Array":return e([]);case"Date":return new Date(t.valueOf());case"RegExp":return new RegExp(t.source,(t.global?"g":"")+(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.sticky?"y":"")+(t.unicode?"u":""));default:return t}},i=function(t){var e=t.match(/^(?:http(s)?:\/\/[^\/]+)?(\/[^\?#]*)/);return e&&e[2]||""}},182:function(t,e,r){var n=this&&this.__assign||function(){return n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},n.apply(this,arguments)},i=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&i(e,t,r);return o(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.useDefaultAdapter=e.useAdapters=e.RUNTIME=void 0;var a,u=s(r(274)),c=r(616);!function(t){t.WEB="web",t.WX_MP="wx_mp"}(a=e.RUNTIME||(e.RUNTIME={})),e.useAdapters=function(t,e){for(var r=0,i=(0,c.isArray)(t)?t:[t];r<i.length;r++){var o=i[r],s=o.isMatch,a=o.genAdapter,u=o.runtime;if(s())return{adapter:n({isMatch:s},a(e)),runtime:u}}},e.useDefaultAdapter=function(){return{adapter:n({},u.genAdapter()),runtime:a.WEB}}},274:function(t,e,r){var n,i=this&&this.__extends||(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),o=this&&this.__assign||function(){return o=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},o.apply(this,arguments)},s=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))(function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(s,a)}u((n=n.apply(t,e||[])).next())})},a=this&&this.__generator||function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=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(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.WebRequest=e.genAdapter=void 0;var u=r(149),c=r(616),h=r(946),l=function(t){function e(e){var r=t.call(this)||this,n=e.timeout,i=e.timeoutMsg,o=e.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=i||"请求超时",r.restrictedMethods=o||["get","post","upload","download"],r}return i(e,t),e.prototype.get=function(t){return this.request(o(o({},t),{method:"get"}),this.restrictedMethods.includes("get"))},e.prototype.post=function(t){return this.request(o(o({},t),{method:"post"}),this.restrictedMethods.includes("post"))},e.prototype.put=function(t){return this.request(o(o({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,r=t.file,n=t.name,i=t.method,s=t.headers,a=void 0===s?{}:s,u={post:"post",put:"put"}[null==i?void 0:i.toLowerCase()]||"put",c=new FormData;return"post"===u?(Object.keys(e).forEach(function(t){c.append(t,e[t])}),c.append("key",n),c.append("file",r),this.request(o(o({},t),{data:c,method:u}),this.restrictedMethods.includes("upload"))):this.request(o(o({},t),{method:"put",headers:a,body:r}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return s(this,void 0,void 0,function(){var e,r,n,i;return a(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.get(o(o({},t),{headers:{},responseType:"blob"}))];case 1:return e=s.sent().data,r=window.URL.createObjectURL(new Blob([e])),n=decodeURIComponent(new URL(t.url).pathname.split("/").pop()||""),(i=document.createElement("a")).href=r,i.setAttribute("download",n),i.style.display="none",document.body.appendChild(i),i.click(),window.URL.revokeObjectURL(r),document.body.removeChild(i),[3,3];case 2:return s.sent(),[3,3];case 3:return[2,new Promise(function(e){e({statusCode:200,tempFilePath:t.url})})]}})})},e.prototype.fetch=function(t){var e;return s(this,void 0,void 0,function(){var r,n,i,u,c,h,l,d,f,p,v,g,m,y=this;return a(this,function(_){switch(_.label){case 0:return r=new AbortController,n=t.url,i=t.enableAbort,u=void 0!==i&&i,c=t.stream,h=void 0!==c&&c,l=t.signal,d=t.timeout,f=t.shouldThrowOnError,p=void 0===f||f,v=null!=d?d:this.timeout,l&&(l.aborted&&r.abort(),l.addEventListener("abort",function(){return r.abort()})),g=null,u&&v&&(g=setTimeout(function(){console.warn(y.timeoutMsg),r.abort(new Error(y.timeoutMsg))},v)),[4,fetch(n,o(o({},t),{signal:r.signal})).then(function(t){return s(y,void 0,void 0,function(){var e,r,n;return a(this,function(i){switch(i.label){case 0:return clearTimeout(g),p?t.ok?(e=t,[3,3]):[3,1]:[3,4];case 1:return n=(r=Promise).reject,[4,t.json()];case 2:e=n.apply(r,[i.sent()]),i.label=3;case 3:return[2,e];case 4:return[2,t]}})})}).catch(function(t){return clearTimeout(g),Promise.reject(t)})];case 1:return m=_.sent(),[2,{data:h?m.body:(null===(e=m.headers.get("content-type"))||void 0===e?void 0:e.includes("application/json"))?m.json():m.text(),statusCode:m.status,header:m.headers,response:m}]}})})},e.prototype.request=function(t,e){var r=this;void 0===e&&(e=!1);var n=String(t.method).toLowerCase()||"get";return new Promise(function(i){var o=t.url,s=t.headers,a=void 0===s?{}:s,u=t.data,l=t.responseType,d=t.withCredentials,f=t.body,p=t.onUploadProgress,v=(0,c.formatUrl)((0,h.getProtocol)(),o,"get"===n?u:{}),g=new XMLHttpRequest;g.open(n,v),l&&(g.responseType=l);var m,y,_=t.signal;_&&(_.aborted?g.abort():_.addEventListener("abort",function(){return g.abort()},{once:!0})),Object.keys(a).forEach(function(t){g.setRequestHeader(t,a[t])}),p&&g.upload.addEventListener("progress",p),g.onreadystatechange=function(){var t={};if(4===g.readyState){var e=g.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};e.forEach(function(t){var e=t.split(": "),n=e.shift().toLowerCase(),i=e.join(": ");r[n]=i}),t.header=r,t.statusCode=g.status;try{t.data="blob"===l?g.response:JSON.parse(g.responseText)}catch(e){t.data="blob"===l?g.response:g.responseText}clearTimeout(m),i(t)}},e&&r.timeout&&(m=setTimeout(function(){console.warn(r.timeoutMsg),g.abort()},r.timeout)),y=(0,c.isFormData)(u)?u:"application/x-www-form-urlencoded"===a["content-type"]?(0,c.toQueryString)(u):f||(u?JSON.stringify(u):void 0),d&&(g.withCredentials=!0),g.send(y)})},e}(u.AbstractSDKRequest);e.WebRequest=l,e.genAdapter=function(){return{type:"default",root:window,reqClass:l,wsClass:WebSocket,localStorage}}},946:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.COMMUNITY_SITE_URL=e.IS_DEBUG_MODE=e.getProtocol=e.setProtocol=e.getSdkName=e.setSdkName=void 0;var r="@cloudbase/js-sdk";e.setSdkName=function(t){r=t},e.getSdkName=function(){return r};var n="https:";e.setProtocol=function(t){n=t},e.getProtocol=function(){return n},e.IS_DEBUG_MODE=!1,e.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},205:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ERRORS=void 0,e.ERRORS={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"}},794:function(t,e,r){var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.OATUH_LOGINTYPE=void 0,i(r(946),e),i(r(205),e),e.OATUH_LOGINTYPE="constants"},718:function(t,e,r){var n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))(function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(s,a)}u((n=n.apply(t,e||[])).next())})},i=this&&this.__generator||function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=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(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.catchErrorsDecorator=void 0;var o=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 h(t){var e=t.err,r=t.className,n=t.methodName,i=t.sourceLink;if(!i)return null;var o,s=e.stack.split("\n"),u=a?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]\\s*\\(.*\\)$")),h=a?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]")),l=s.findIndex(function(t){return u.test(t)});if(-1!==l){var d=s.filter(function(t,e){return e>l});d.unshift(s[l].replace(h,"".concat(r,".").concat(n)).replace(c,i)),(o=new Error).stack="".concat(a?"@debugger":"Error","\n").concat(d.join("\n"))}return o}e.catchErrorsDecorator=function(t){var e=t.mode,r=void 0===e?"async":e,a=t.customInfo,l=void 0===a?{}:a,d=t.title,f=t.messages,p=void 0===f?[]:f;return function(t,e,a){if(s.IS_DEBUG_MODE){var f=l.className||t.constructor.name,v=l.methodName||e,g=a.value,m=function(){var t="",e=(new Error).stack.split("\n"),r=e.findIndex(function(t){return u.test(t)});if(-1!==r){var n=c.exec(e[r+1]||"");t=n?n[0]:""}return t}();a.value="sync"===r?function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=h({err:new Error,className:f,methodName:v,sourceLink:m});try{return g.apply(this,t)}catch(t){var n=t,i=t.message,s=t.error,a=t.error_description,u={title:d||"".concat(f,".").concat(v," failed"),content:[{type:"error",body:t}]};if(i&&/^\{.*\}$/.test(i)){var c=JSON.parse(i);u.subtitle=i,c.code&&(r?(r.code=c.code,r.msg=c.msg):(t.code=c.code,t.message=c.msg),n=r||t,u.content=p.map(function(t){return{type:"info",body:t}}))}throw s&&a&&(u.subtitle=a,r?(r.code=s,r.msg=a):(t.code=s,t.message=a),n=r||t,u.content=p.map(function(t){return{type:"info",body:t}})),(0,o.printGroupLog)(u),n}}:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n(this,void 0,void 0,function(){var e,r,n,s,a,u,c,l;return i(this,function(i){switch(i.label){case 0:e=h({err:new Error,className:f,methodName:v,sourceLink:m}),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,g.apply(this,t)];case 2:return[2,i.sent()];case 3:throw r=i.sent(),n=r,s=r.message,a=r.error,u=r.error_description,c={title:d||"".concat(f,".").concat(v," failed"),content:[{type:"error",body:r}]},s&&/^\{.*\}$/.test(s)&&(l=JSON.parse(s),c.subtitle=l,l.code&&(e?(e.code=l.code,e.message=l.msg):(r.code=l.code,r.message=l.msg),n=e||r,c.content=p.map(function(t){return{type:"info",body:t}}))),a&&u&&(c.subtitle=u,e?(e.code=a,e.msg=u):(r.code=a,r.message=u),n=e||r,c.content=p.map(function(t){return{type:"info",body:t}})),(0,o.printGroupLog)(c),n;case 4:return[2]}})})}}}}},141:function(t,e,r){var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),i(r(718),e)},197:function(t,e,r){var n,i=this&&this.__extends||(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),o=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))(function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(s,a)}u((n=n.apply(t,e||[])).next())})},s=this&&this.__generator||function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=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(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.CloudbaseCache=void 0;var a=r(149),u=r(616),c=r(794),h=function(t){function e(e){var r=t.call(this)||this;return r.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),r}return i(e,t),e.prototype.setItem=function(t,e){this.root.tcbCacheObject[t]=e},e.prototype.getItem=function(t){return this.root.tcbCacheObject[t]},e.prototype.removeItem=function(t){delete this.root.tcbCacheObject[t]},e.prototype.clear=function(){delete this.root.tcbCacheObject},e}(a.AbstractStorage),l=function(){function t(t){this.keys={};var e=t.persistence,r=t.platformInfo,n=void 0===r?{}:r,i=t.keys,o=void 0===i?{}:i;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||e,this.storage=function(t,e){switch(t){case"local":default:return e.localStorage?e.localStorage:((0,u.printWarn)(c.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new h(e.root));case"none":return new h(e.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=o)}return Object.defineProperty(t.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),t.prototype.setStore=function(t,e,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(n))}catch(t){throw new Error(JSON.stringify({code:c.ERRORS.OPERATION_FAIL,msg:"[".concat((0,c.getSdkName)(),"][").concat(c.ERRORS.OPERATION_FAIL,"]setStore failed"),info:t}))}}else(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,r){return o(this,void 0,void 0,function(){var n;return s(this,function(i){switch(i.label){case 0:if(!this.storage)return[2];i.label=1;case 1:return i.trys.push([1,3,,4]),n={version:r||"localCachev1",content:e},[4,this.storage.setItem(t,JSON.stringify(n))];case 2:return i.sent(),[3,4];case 3:return i.sent(),[2];case 4:return[2]}})})},t.prototype.getStore=function(t,e){var r;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(t){return""}e=e||"localCachev1";var n=this.storage.getItem(t);return n&&n.indexOf(e)>=0?JSON.parse(n).content:""}(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){var r;return o(this,void 0,void 0,function(){var n;return s(this,function(i){switch(i.label){case 0:try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return[2,{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(t){return[2,""]}return e=e||"localCachev1",[4,this.storage.getItem(t)];case 1:return(n=i.sent())&&n.indexOf(e)>=0?[2,JSON.parse(n).content]:[2,""]}})})},t.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},t.prototype.removeStoreAsync=function(t){return o(this,void 0,void 0,function(){return s(this,function(e){switch(e.label){case 0:return[4,this.storage.removeItem(t)];case 1:return e.sent(),[2]}})})},t}();e.CloudbaseCache=l},689:function(t,e,r){var n,i=this&&this.__extends||(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),o=this&&this.__spreadArray||function(t,e,r){if(r||2===arguments.length)for(var n,i=0,o=e.length;i<o;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))};Object.defineProperty(e,"__esModule",{value:!0}),e.removeEventListener=e.activateEvent=e.addEventListener=e.CloudbaseEventEmitter=e.IErrorEvent=e.CloudbaseEvent=void 0;var s=r(616),a=function(t,e){this.data=e||null,this.name=t};e.CloudbaseEvent=a;var u=function(t){function e(e,r){var n=t.call(this,"error",{error:e,data:r})||this;return n.error=e,n}return i(e,t),e}(a);e.IErrorEvent=u;var c=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){return function(t,e,r){r[t]=r[t]||[],r[t].push(e)}(t,e,this.listeners),this},t.prototype.off=function(t,e){return function(t,e,r){if(null==r?void 0:r[t]){var n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if((0,s.isInstanceOf)(t,u))return console.error(t.error),this;var r=(0,s.isString)(t)?new a(t,e||{}):t,n=r.name;if(this.listens(n)){r.target=this;for(var i=0,c=this.listeners[n]?o([],this.listeners[n],!0):[];i<c.length;i++)c[i].call(this,r)}return this},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}();e.CloudbaseEventEmitter=c;var h=new c;e.addEventListener=function(t,e){h.on(t,e)},e.activateEvent=function(t,e){void 0===e&&(e={}),h.fire(t,e)},e.removeEventListener=function(t,e){h.off(t,e)}},616:function(t,e,r){var n=this&&this.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]])}return r};Object.defineProperty(e,"__esModule",{value:!0}),e.parseCaptcha=e.parseQueryString=e.transformPhone=e.sleep=e.printGroupLog=e.throwError=e.printInfo=e.printError=e.printWarn=e.execCallback=e.createPromiseCallback=e.removeParam=e.getHash=e.getQuery=e.toQueryString=e.formatUrl=e.generateRequestId=e.genSeqId=e.isFormData=e.isInstanceOf=e.isNull=e.isPalinObject=e.isUndefined=e.isString=e.isArray=void 0;var i=r(794);e.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},e.isString=function(t){return"string"==typeof t},e.isUndefined=function(t){return void 0===t},e.isPalinObject=function(t){return"[object Object]"===Object.prototype.toString.call(t)},e.isNull=function(t){return"[object Null]"===Object.prototype.toString.call(t)},e.isInstanceOf=function(t,e){return t instanceof e},e.isFormData=function(t){return"[object FormData]"===Object.prototype.toString.call(t)},e.genSeqId=function(){return Math.random().toString(16).slice(2)},e.generateRequestId=function(){var t=(new Date).getTime(),e=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){var n=16*Math.random();return t>0?(n=(t+n)%16|0,t=Math.floor(t/16)):(n=(e+n)%16|0,e=Math.floor(e/16)),("x"===r?n:7&n|8).toString(16)})},e.formatUrl=function(t,e,r){void 0===r&&(r={});var n=/\?/.test(e),i="";return Object.keys(r).forEach(function(t){""===i?!n&&(e+="?"):i+="&",i+="".concat(t,"=").concat(encodeURIComponent(r[t]))}),/^http(s)?:\/\//.test(e+=i)?e:"".concat(t).concat(e)},e.toQueryString=function(t){void 0===t&&(t={});var e=[];return Object.keys(t).forEach(function(r){e.push("".concat(r,"=").concat(encodeURIComponent(t[r])))}),e.join("&")},e.getQuery=function(t,e){if("undefined"==typeof window)return!1;var r=e||decodeURIComponent(window.location.search),n=new RegExp("(^|&)".concat(t,"=([^&]*)(&|$)")),i=r.substr(r.indexOf("?")+1).match(n);return null!=i?i[2]:""},e.getHash=function(t){if("undefined"==typeof window)return"";var e=window.location.hash.match(new RegExp("[#?&/]".concat(t,"=([^&#]*)")));return e?e[1]:""},e.removeParam=function(t,e){var r=e.split("?")[0],n=[],i=-1!==e.indexOf("?")?e.split("?")[1]:"";if(""!==i){for(var o=(n=i.split("&")).length-1;o>=0;o-=1)n[o].split("=")[0]===t&&n.splice(o,1);r="".concat(r,"?").concat(n.join("&"))}return r},e.createPromiseCallback=function(){var t={};if(!Promise){(t=function(){}).promise={};var e=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(t.promise,"then",{get:e}),Object.defineProperty(t.promise,"catch",{get:e}),t}var r=new Promise(function(e,r){t=function(t,n){return t?r(t):e(n)}});return t.promise=r,t},e.execCallback=function(t,e,r){if(void 0===r&&(r=null),t&&"function"==typeof t)return t(e,r);if(e)throw e;return r},e.printWarn=function(t,e){console.warn("[".concat((0,i.getSdkName)(),"][").concat(t,"]:").concat(e))},e.printError=function(t,e){console.error({code:t,msg:"[".concat((0,i.getSdkName)(),"][").concat(t,"]:").concat(e)})},e.printInfo=function(t,e){console.log("[".concat((0,i.getSdkName)(),"][").concat(t,"]:").concat(e))},e.throwError=function(t,e){throw new Error(JSON.stringify({code:t,msg:"[".concat((0,i.getSdkName)(),"][").concat(t,"]:").concat(e)}))},e.printGroupLog=function(t){var e,r=t.title,n=t.subtitle,i=void 0===n?"":n,o=t.content,s=void 0===o?[]:o,a=t.printTrace,u=void 0!==a&&a,c=t.collapsed;void 0!==c&&c?(console.groupCollapsed||console.error)(r,i):(console.group||console.error)(r,i);for(var h=0,l=s;h<l.length;h++){var d=l[h],f=d.type,p=d.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===(e=console.groupEnd)||void 0===e||e.call(console)},e.sleep=function(t){return void 0===t&&(t=0),new Promise(function(e){return setTimeout(e,t)})},e.transformPhone=function(t){return"+86".concat(t)},e.parseQueryString=function(t){t=t.replace(/^\?/,"");var e={};return t.split("&").forEach(function(t){var r=t.split("="),n=r[0],i=r[1];n=decodeURIComponent(n),i=decodeURIComponent(i),n&&(e[n]?Array.isArray(e[n])?e[n].push(i):e[n]=[e[n],i]:e[n]=i)}),e},e.parseCaptcha=function(t){var r={},i=t.match(/^(data:.*?)(\?[^#\s]*)?$/);if(i){t=i[1];var o=i[2];o&&(r=(0,e.parseQueryString)(o))}var s=r.token,a=n(r,["token"]);return/^data:/.test(t)&&!s?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(t)}:s?{state:a.state,token:s,captchaData:t}:{error:"unimplemented",error_description:"need to impl captcha data"}}},149:e=>{e.exports=t}},i={};function o(t){var e=i[t];if(void 0!==e)return e.exports;var r=i[t]={exports:{}};return n[t].call(r.exports,r,r.exports,o),r.exports}o.d=(t,e)=>{for(var r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var s={};(()=>{o.d(s,{W:()=>Ee});var t={};o.r(t);var n,i,a,u,c,h,l="/auth";!function(t){t.AUTH_SIGN_UP_URL="/v1/signup",t.AUTH_TOKEN_URL="/v1/token",t.AUTH_REVOKE_URL="/v1/revoke",t.WEDA_USER_URL="/v1/plugin/weda/userinfo",t.AUTH_RESET_PASSWORD="/v1/reset",t.AUTH_GET_DEVICE_CODE="/v1/device/code",t.CHECK_USERNAME="/v1/checkUsername",t.CHECK_IF_USER_EXIST="/v1/checkIfUserExist",t.GET_PROVIDER_TYPE="/v1/mgr/provider/providerSubType",t.AUTH_SIGN_IN_URL="/v1/signin",t.AUTH_SIGN_IN_ANONYMOUSLY_URL="/v1/signin/anonymously",t.AUTH_SIGN_IN_WITH_PROVIDER_URL="/v1/signin/with/provider",t.AUTH_SIGN_IN_WITH_WECHAT_URL="/v1/signin/wechat/noauth",t.AUTH_SIGN_IN_CUSTOM="/v1/signin/custom",t.PROVIDER_TOKEN_URL="/v1/provider/token",t.PROVIDER_URI_URL="/v1/provider/uri",t.USER_ME_URL="/v1/user/me",t.AUTH_SIGNOUT_URL="/v1/user/signout",t.USER_QUERY_URL="/v1/user/query",t.USER_PRIFILE_URL="/v1/user/profile",t.USER_BASIC_EDIT_URL="/v1/user/basic/edit",t.USER_TRANS_BY_PROVIDER_URL="/v1/user/trans/by/provider",t.PROVIDER_LIST="/v1/user/provider",t.PROVIDER_BIND_URL="/v1/user/provider/bind",t.PROVIDER_UNBIND_URL="/v1/user/provider",t.CHECK_PWD_URL="/v1/user/sudo",t.SUDO_URL="/v1/user/sudo",t.BIND_CONTACT_URL="/v1/user/contact",t.AUTH_SET_PASSWORD="/v1/user/password",t.AUTHORIZE_DEVICE_URL="/v1/user/device/authorize",t.AUTHORIZE_URL="/v1/user/authorize",t.AUTHORIZE_INFO_URL="/v1/user/authorize/info",t.AUTHORIZED_DEVICES_DELETE_URL="/v1/user/authorized/devices/",t.AUTH_REVOKE_ALL_URL="/v1/user/revoke/all",t.GET_USER_BEHAVIOR_LOG="/v1/user/security/history",t.VERIFICATION_URL="/v1/verification",t.VERIFY_URL="/v1/verification/verify",t.CAPTCHA_DATA_URL="/v1/captcha/data",t.VERIFY_CAPTCHA_DATA_URL="/v1/captcha/data/verify",t.GET_CAPTCHA_URL="/v1/captcha/init",t.GET_MINIPROGRAM_QRCODE="/v1/qrcode/generate",t.GET_MINIPROGRAM_QRCODE_STATUS="/v1/qrcode/get/status"}(n||(n={})),function(t){t.AUTH_SIGN_IN_URL="/v2/signin/username",t.AUTH_TOKEN_URL="/v2/token",t.USER_ME_URL="/v2/user/me",t.VERIFY_URL="/v2/signin/verificationcode",t.AUTH_SIGN_IN_WITH_PROVIDER_URL="/v2/signin/with/provider",t.AUTH_PUBLIC_KEY="/v2/signin/publichkey",t.AUTH_RESET_PASSWORD="/v2/signin/password/update"}(i||(i={})),function(t){t.REGISTER="REGISTER",t.SIGN_IN="SIGN_IN",t.PASSWORD_RESET="PASSWORD_RESET",t.EMAIL_ADDRESS_CHANGE="EMAIL_ADDRESS_CHANGE",t.PHONE_NUMBER_CHANGE="PHONE_NUMBER_CHANGE"}(a||(a={})),(h=u||(u={})).UNREACHABLE="unreachable",h.LOCAL="local",h.CANCELLED="cancelled",h.UNKNOWN="unknown",h.UNAUTHENTICATED="unauthenticated",h.RESOURCE_EXHAUSTED="resource_exhausted",h.FAILED_PRECONDITION="failed_precondition",h.INVALID_ARGUMENT="invalid_argument",h.DEADLINE_EXCEEDED="deadline_exceeded",h.NOT_FOUND="not_found",h.ALREADY_EXISTS="already_exists",h.PERMISSION_DENIED="permission_denied",h.ABORTED="aborted",h.OUT_OF_RANGE="out_of_range",h.UNIMPLEMENTED="unimplemented",h.INTERNAL="internal",h.UNAVAILABLE="unavailable",h.DATA_LOSS="data_loss",h.INVALID_PASSWORD="invalid_password",h.PASSWORD_NOT_SET="password_not_set",h.INVALID_STATUS="invalid_status",h.USER_PENDING="user_pending",h.USER_BLOCKED="user_blocked",h.INVALID_VERIFICATION_CODE="invalid_verification_code",h.TWO_FACTOR_REQUIRED="two_factor_required",h.INVALID_TWO_FACTOR="invalid_two_factor",h.INVALID_TWO_FACTOR_RECOVERY="invalid_two_factor_recovery",h.UNDER_REVIEW="under_review",h.INVALID_REQUEST="invalid_request",h.UNAUTHORIZED_CLIENT="unauthorized_client",h.ACCESS_DENIED="access_denied",h.UNSUPPORTED_RESPONSE_TYPE="unsupported_response_type",h.INVALID_SCOPE="invalid_scope",h.INVALID_GRANT="invalid_grant",h.SERVER_ERROR="server_error",h.TEMPORARILY_UNAVAILABLE="temporarily_unavailable",h.INTERACTION_REQUIRED="interaction_required",h.LOGIN_REQUIRED="login_required",h.ACCOUNT_SELECTION_REQUIRED="account_selection_required",h.CONSENT_REQUIRED="consent_required",h.INVALID_REQUEST_URI="invalid_request_uri",h.INVALID_REQUEST_OBJECT="invalid_request_object",h.REQUEST_NOT_SUPPORTED="request_not_supported",h.REQUEST_URI_NOT_SUPPORTED="request_uri_not_supported",h.REGISTRATION_NOT_SUPPORTED="registration_not_supported",h.CAPTCHA_REQUIRED="captcha_required",h.CAPTCHA_INVALID="captcha_invalid",h.PROVIDER_NOT_ENABLED="provider_not_enabled",h.LOGIN_METHOD_DISABLED="login_method_disabled",h.INVALID_USERNAME_OR_PASSWORD="invalid_username_or_password",h.INVALID_CREDENTIALS="invalid_credentials",h.WRONG_PASSWORD="wrong_password",h.USER_NOT_FOUND="user_not_found",h.MFA_PHONE_REQUIRED="mfa_phone_required",h.LOGIN_TYPE_DISABLED="login_type_disabled",h.PROVIDER_ERROR="provider_error",function(t){t[t.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",t[t.NOT_FOUND=5]="NOT_FOUND",t[t.PERMISSION_DENIED=7]="PERMISSION_DENIED",t[t.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",t[t.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",t[t.ABORTED=10]="ABORTED",t[t.UNIMPLEMENTED=12]="UNIMPLEMENTED",t[t.INTERNAL=13]="INTERNAL",t[t.UNAVAILABLE=14]="UNAVAILABLE",t[t.UNAUTHENTICATED=16]="UNAUTHENTICATED",t[t.CAPTCHA_REQUIRED=4001]="CAPTCHA_REQUIRED",t[t.CAPTCHA_INVALID=4002]="CAPTCHA_INVALID",t[t.PROVIDER_ERROR=4019]="PROVIDER_ERROR",t[t.UNAUTHORIZED_CLIENT=4022]="UNAUTHORIZED_CLIENT",t[t.MFA_PHONE_REQUIRED=4042]="MFA_PHONE_REQUIRED",t[t.LOGIN_TYPE_DISABLED=4045]="LOGIN_TYPE_DISABLED"}(c||(c={}));var d,f="credentials_error",p="SIGNED_OUT",v="SIGNED_IN",g="TOKEN_REFRESHED",m="USER_UPDATED",y="BIND_IDENTITY",_="loginStateChanged",b="authStateChanged",I="sign_in",w="bind_identity",E="node-sdk-scope";function S(){return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})}!function(t){t.CLIENT_ID="client_id",t.CLIENT_SECRET="client_secret",t.RESPONSE_TYPE="response_type",t.SCOPE="scope",t.STATE="state",t.REDIRECT_URI="redirect_uri",t.ERROR="error",t.ERROR_DESCRIPTION="error_description",t.ERROR_URI="error_uri",t.GRANT_TYPE="grant_type",t.CODE="code",t.ACCESS_TOKEN="access_token",t.TOKEN_TYPE="token_type",t.EXPIRES_IN="expires_in",t.USERNAME="username",t.PASSWORD="password",t.REFRESH_TOKEN="refresh_token"}(d||(d={}));var A=o(631),P=function(t,e,r,n){return new(r||(r=Promise))(function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(s,a)}u((n=n.apply(t,e||[])).next())})},O=function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=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(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},T=new Map,R=function(){function t(t){this.clientId=(null==t?void 0:t.clientId)||"",T=T||new Map}return t.prototype.run=function(t,e){return P(this,void 0,Promise,function(){var r,n=this;return O(this,function(i){return t="".concat(this.clientId,"_").concat(t),(r=T.get(t))||(r=new Promise(function(r,i){P(n,void 0,void 0,function(){var n,o,s;return O(this,function(a){switch(a.label){case 0:return a.trys.push([0,3,4,5]),[4,this.runIdlePromise()];case 1:return a.sent(),n=e(),o=r,[4,n];case 2:return o.apply(void 0,[a.sent()]),[3,5];case 3:return s=a.sent(),i(s),[3,5];case 4:return T.delete(t),[7];case 5:return[2]}})})}),T.set(t,r)),[2,r]})})},t.prototype.runIdlePromise=function(){return Promise.resolve()},t}(),C="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",U=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/,N=function(t){if(t=String(t).replace(/[\t\n\f\r ]+/g,""),!U.test(t))throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");var e;t+="==".slice(2-(3&t.length));for(var r,n,i="",o=0;o<t.length;)e=C.indexOf(t.charAt(o++))<<18|C.indexOf(t.charAt(o++))<<12|(r=C.indexOf(t.charAt(o++)))<<6|(n=C.indexOf(t.charAt(o++))),i+=64===r?String.fromCharCode(e>>16&255):64===n?String.fromCharCode(e>>16&255,e>>8&255):String.fromCharCode(e>>16&255,e>>8&255,255&e);return i};function L(){if("undefined"==typeof globalThis)return!1;var t=globalThis.wx;if(void 0===t)return!1;if(void 0===globalThis.Page)return!1;if(!t.getDeviceInfo)return!1;if(!t.getStorageSync)return!1;if(!t.setStorageSync)return!1;if(!t.connectSocket)return!1;if(!t.request)return!1;try{if(!t.getDeviceInfo())return!1;if("qq"===t.getDeviceInfo().platform)return!1}catch(t){return!1}return!0}var D=!1;function k(){D=D||void 0!==typeof window&&"miniprogram"===window.__wxjs_environment}try{L()||(D=D||!!navigator.userAgent.match(/miniprogram/i)||"miniprogram"===window.__wxjs_environment,window&&window.WeixinJSBridge&&window.WeixinJSBridge.invoke?k():"undefined"!=typeof document&&document.addEventListener("WeixinJSBridgeReady",k,!1))}catch(t){}var x="INVALID_OPERATION",M="OPERATION_FAIL",q=o(149);function B(t,e){if("undefined"==typeof window)return!1;var r=e||decodeURIComponent(window.location.search),n=new RegExp("(^|&)".concat(t,"=([^&]*)(&|$)")),i=r.substr(r.indexOf("?")+1).match(n);return null!=i?i[2]:""}function j(t,e){console.warn("[".concat("@cloudbase/js-sdk","][").concat(t,"]:").concat(e))}var V,W,F=(V=function(t,e){return V=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},V(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}V(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),H=function(){return H=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},H.apply(this,arguments)},G=function(t,e,r,n){return new(r||(r=Promise))(function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(s,a)}u((n=n.apply(t,e||[])).next())})},K=function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=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(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};!function(t){function e(e){var r=t.call(this)||this,n=e.timeout,i=e.timeoutMsg,o=e.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=i||"请求超时",r.restrictedMethods=o||["get","post","upload","download"],r}F(e,t),e.prototype.get=function(t){return this.request(H(H({},t),{method:"get"}),this.restrictedMethods.includes("get"))},e.prototype.post=function(t){return this.request(H(H({},t),{method:"post"}),this.restrictedMethods.includes("post"))},e.prototype.put=function(t){return this.request(H(H({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,r=t.file,n=t.name,i=t.method,o=t.headers,s=void 0===o?{}:o,a={post:"post",put:"put"}[null==i?void 0:i.toLowerCase()]||"put",u=new FormData;return"post"===a?(Object.keys(e).forEach(function(t){u.append(t,e[t])}),u.append("key",n),u.append("file",r),this.request(H(H({},t),{data:u,method:a}),this.restrictedMethods.includes("upload"))):this.request(H(H({},t),{method:"put",headers:s,body:r}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return G(this,void 0,Promise,function(){var e,r,n,i;return K(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.get(H(H({},t),{headers:{},responseType:"blob"}))];case 1:return e=o.sent().data,r=window.URL.createObjectURL(new Blob([e])),n=decodeURIComponent(new URL(t.url).pathname.split("/").pop()||""),(i=document.createElement("a")).href=r,i.setAttribute("download",n),i.style.display="none",document.body.appendChild(i),i.click(),window.URL.revokeObjectURL(r),document.body.removeChild(i),[3,3];case 2:return o.sent(),[3,3];case 3:return[2,new Promise(function(e){e({statusCode:200,tempFilePath:t.url})})]}})})},e.prototype.fetch=function(t){var e;return G(this,void 0,Promise,function(){var r,n,i,o,s,a,u,c,h,l,d,f,p,v=this;return K(this,function(g){switch(g.label){case 0:return r=new AbortController,n=t.url,i=t.enableAbort,o=void 0!==i&&i,s=t.stream,a=void 0!==s&&s,u=t.signal,c=t.timeout,h=t.shouldThrowOnError,l=void 0===h||h,d=null!=c?c:this.timeout,u&&(u.aborted&&r.abort(),u.addEventListener("abort",function(){return r.abort()})),f=null,o&&d&&(f=setTimeout(function(){console.warn(v.timeoutMsg),r.abort(new Error(v.timeoutMsg))},d)),[4,fetch(n,H(H({},t),{signal:r.signal})).then(function(t){return G(v,void 0,void 0,function(){var e,r,n;return K(this,function(i){switch(i.label){case 0:return clearTimeout(f),l?t.ok?(e=t,[3,3]):[3,1]:[3,4];case 1:return n=(r=Promise).reject,[4,t.json()];case 2:e=n.apply(r,[i.sent()]),i.label=3;case 3:return[2,e];case 4:return[2,t]}})})}).catch(function(t){return clearTimeout(f),Promise.reject(t)})];case 1:return p=g.sent(),[2,{data:a?p.body:(null===(e=p.headers.get("content-type"))||void 0===e?void 0:e.includes("application/json"))?p.json():p.text(),statusCode:p.status,header:p.headers,response:p}]}})})},e.prototype.request=function(t,e){var r=this;void 0===e&&(e=!1);var n=String(t.method).toLowerCase()||"get";return new Promise(function(i){var o=t.url,s=t.headers,a=void 0===s?{}:s,u=t.data,c=t.responseType,h=t.withCredentials,l=t.body,d=t.onUploadProgress,f=function(t,e,r){void 0===r&&(r={});var n=/\?/.test(e),i="";return Object.keys(r).forEach(function(t){""===i?!n&&(e+="?"):i+="&",i+="".concat(t,"=").concat(encodeURIComponent(r[t]))}),/^http(s)?:\/\//.test(e+=i)?e:"".concat(t).concat(e)}("https:",o,"get"===n?u:{}),p=new XMLHttpRequest;p.open(n,f),c&&(p.responseType=c);var v,g,m,y=t.signal;y&&(y.aborted?p.abort():y.addEventListener("abort",function(){return p.abort()},{once:!0})),Object.keys(a).forEach(function(t){p.setRequestHeader(t,a[t])}),d&&p.upload.addEventListener("progress",d),p.onreadystatechange=function(){var t={};if(4===p.readyState){var e=p.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};e.forEach(function(t){var e=t.split(": "),n=e.shift().toLowerCase(),i=e.join(": ");r[n]=i}),t.header=r,t.statusCode=p.status;try{t.data="blob"===c?p.response:JSON.parse(p.responseText)}catch(e){t.data="blob"===c?p.response:p.responseText}clearTimeout(v),i(t)}},e&&r.timeout&&(v=setTimeout(function(){console.warn(r.timeoutMsg),p.abort()},r.timeout)),m=u,g="[object FormData]"===Object.prototype.toString.call(m)?u:"application/x-www-form-urlencoded"===a["content-type"]?function(t){void 0===t&&(t={});var e=[];return Object.keys(t).forEach(function(r){e.push("".concat(r,"=").concat(encodeURIComponent(t[r])))}),e.join("&")}(u):l||(u?JSON.stringify(u):void 0),h&&(p.withCredentials=!0),p.send(g)})}}(q.AbstractSDKRequest),function(t){t.WEB="web",t.WX_MP="wx_mp"}(W||(W={}));var Y=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),z=function(t,e,r,n){return new(r||(r=Promise))(function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(s,a)}u((n=n.apply(t,e||[])).next())})},Q=function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=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(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},J=function(t){function e(e){var r=t.call(this)||this;return r.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),r}return Y(e,t),e.prototype.setItem=function(t,e){this.root.tcbCacheObject[t]=e},e.prototype.getItem=function(t){return this.root.tcbCacheObject[t]},e.prototype.removeItem=function(t){delete this.root.tcbCacheObject[t]},e.prototype.clear=function(){delete this.root.tcbCacheObject},e}(q.AbstractStorage);!function(){function t(t){this.keys={};var e=t.persistence,r=t.platformInfo,n=void 0===r?{}:r,i=t.keys,o=void 0===i?{}:i;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||e,this.storage=function(t,e){switch(t){case"local":default:return e.localStorage?e.localStorage:(j("INVALID_PARAMS","localStorage is not supported on current platform"),new J(e.root));case"none":return new J(e.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=o)}Object.defineProperty(t.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),t.prototype.setStore=function(t,e,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(n))}catch(t){throw new Error(JSON.stringify({code:M,msg:"[".concat("@cloudbase/js-sdk","][").concat(M,"]setStore failed"),info:t}))}}else j(x,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,r){return z(this,void 0,void 0,function(){var n;return Q(this,function(i){switch(i.label){case 0:if(!this.storage)return[2];i.label=1;case 1:return i.trys.push([1,3,,4]),n={version:r||"localCachev1",content:e},[4,this.storage.setItem(t,JSON.stringify(n))];case 2:return i.sent(),[3,4];case 3:return i.sent(),[2];case 4:return[2]}})})},t.prototype.getStore=function(t,e){var r;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(t){return""}e=e||"localCachev1";var n=this.storage.getItem(t);return n&&n.indexOf(e)>=0?JSON.parse(n).content:""}j(x,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){var r;return z(this,void 0,void 0,function(){var n;return Q(this,function(i){switch(i.label){case 0:try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return[2,{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(t){return[2,""]}return e=e||"localCachev1",[4,this.storage.getItem(t)];case 1:return(n=i.sent())&&n.indexOf(e)>=0?[2,JSON.parse(n).content]:[2,""]}})})},t.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):j(x,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},t.prototype.removeStoreAsync=function(t){return z(this,void 0,void 0,function(){return Q(this,function(e){switch(e.label){case 0:return[4,this.storage.removeItem(t)];case 1:return e.sent(),[2]}})})}}();var Z=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),X=function(t,e){this.data=e||null,this.name=t},$=function(t){function e(e,r){var n=t.call(this,"error",{error:e,data:r})||this;return n.error=e,n}return Z(e,t),e}(X),tt=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){return function(t,e,r){r[t]=r[t]||[],r[t].push(e)}(t,e,this.listeners),this},t.prototype.off=function(t,e){return function(t,e,r){if(null==r?void 0:r[t]){var n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if(t instanceof $)return console.error(t.error),this;var r="string"==typeof t?new X(t,e||{}):t,n=r.name;if(this.listens(n)){r.target=this;for(var i=0,o=this.listeners[n]?function(t,e,r){if(r||2===arguments.length)for(var n,i=0,o=e.length;i<o;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))}([],this.listeners[n],!0):[];i<o.length;i++)o[i].call(this,r)}return this},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}();new tt;var et=new tt;"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.indexOf("Firefox");rt={default:()=>e.default},nt={},o.d(nt,rt);var rt,nt,it=function(){return it=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},it.apply(this,arguments)},ot=function(t,e,r,n){return new(r||(r=Promise))(function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(s,a)}u((n=n.apply(t,e||[])).next())})},st=function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=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(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},at=function(t,e,r){if(r||2===arguments.length)for(var n,i=0,o=e.length;i<o;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))},ut="x-request-id",ct="x-device-id",ht="device_id",lt=function(t,e){return ot(this,void 0,Promise,function(){var r,n,i,o,s;return st(this,function(a){switch(a.label){case 0:r=null,n=null,a.label=1;case 1:return a.trys.push([1,4,,5]),(i=Object.assign({},e)).method||(i.method="GET"),i.body&&"string"!=typeof i.body&&(i.body=JSON.stringify(i.body)),[4,fetch(t,i)];case 2:return[4,a.sent().json()];case 3:return(null==(o=a.sent())?void 0:o.error)?(n=o).error_uri=new URL(t).pathname:r=o,[3,5];case 4:return s=a.sent(),n={error:u.UNREACHABLE,error_description:s.message,error_uri:new URL(t).pathname},[3,5];case 5:if(n)throw n;return[2,r]}})})},dt=new(function(){function t(t){this._env=(null==t?void 0:t.env)||""}return t.prototype.getItem=function(t){return ot(this,void 0,Promise,function(){return st(this,function(e){return[2,window.localStorage.getItem("".concat(t).concat(this._env))]})})},t.prototype.removeItem=function(t){return ot(this,void 0,Promise,function(){return st(this,function(e){return window.localStorage.removeItem("".concat(t).concat(this._env)),[2]})})},t.prototype.setItem=function(t,e){return ot(this,void 0,Promise,function(){return st(this,function(r){return window.localStorage.setItem("".concat(t).concat(this._env),e),[2]})})},t.prototype.getItemSync=function(t){return window.localStorage.getItem("".concat(t).concat(this._env))},t.prototype.removeItemSync=function(t){window.localStorage.removeItem("".concat(t).concat(this._env))},t.prototype.setItemSync=function(t,e){window.localStorage.setItem("".concat(t).concat(this._env),e)},t}());function ft(t){var e=!0;return(null==t?void 0:t.expires_at)&&(null==t?void 0:t.access_token)&&(e=t.expires_at<new Date),e}var pt=function(){function t(t){this.credentials=null,this.accessKeyCredentials=null,this.singlePromise=null,this.tokenSectionName=t.tokenSectionName,this.storage=t.storage,this.clientId=t.clientId,this.singlePromise=new R({clientId:this.clientId}),this.credentials=t.credentials||null}return t.prototype.getStorageCredentialsSync=function(){var t=null,e=this.storage.getItemSync(this.tokenSectionName);if(null!=e)try{(null==(t=JSON.parse(e))?void 0:t.expires_at)&&(t.expires_at=new Date(t.expires_at))}catch(e){this.storage.removeItem(this.tokenSectionName),t=null}return t},t.prototype.setCredentials=function(t){return ot(this,void 0,Promise,function(){var e;return st(this,function(r){switch(r.label){case 0:return(null==t?void 0:t.expires_in)?((null==t?void 0:t.expires_at)||(t.expires_at=new Date(Date.now()+1e3*(t.expires_in-30))),this.storage?(e=JSON.stringify(t),[4,this.storage.setItem(this.tokenSectionName,e)]):[3,2]):[3,3];case 1:r.sent(),r.label=2;case 2:return this.credentials=t,[3,6];case 3:return this.storage?[4,this.storage.removeItem(this.tokenSectionName)]:[3,5];case 4:r.sent(),r.label=5;case 5:this.credentials=null,r.label=6;case 6:return[2]}})})},t.prototype.setAccessKeyCredentials=function(t){this.accessKeyCredentials=t,t.scope===E&&(this.credentials=t)},t.prototype.getCredentials=function(){return ot(this,void 0,Promise,function(){var t=this;return st(this,function(e){return[2,this.singlePromise.run("getCredentials",function(){return ot(t,void 0,void 0,function(){var t,e;return st(this,function(r){switch(r.label){case 0:return ft(this.credentials)?[4,this.getStorageCredentials()]:[3,2];case 1:if(t=r.sent(),e=t.credentials,t.isAccessKeyCredentials)return[2,e];this.credentials=e,r.label=2;case 2:return[2,this.credentials]}})})})]})})},t.prototype.getStorageCredentials=function(){return ot(this,void 0,Promise,function(){var t=this;return st(this,function(e){return[2,this.singlePromise.run("_getStorageCredentials",function(){return ot(t,void 0,void 0,function(){var t,e,r;return st(this,function(n){switch(n.label){case 0:return t=null,e=!1,[4,this.storage.getItem(this.tokenSectionName)];case 1:if(!(r=n.sent()))return[3,6];n.label=2;case 2:return n.trys.push([2,3,,5]),(null==(t=JSON.parse(r))?void 0:t.expires_at)&&(t.expires_at=new Date(t.expires_at)),[3,5];case 3:return n.sent(),[4,this.storage.removeItem(this.tokenSectionName)];case 4:return n.sent(),t=null,[3,5];case 5:return[3,7];case 6:t=this.accessKeyCredentials||null,e=!0,n.label=7;case 7:return[2,{credentials:t,isAccessKeyCredentials:e}]}})})})]})})},t}(),vt=function(){function t(e){var r,n=this;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.getApiOriginFunc=e.getApiOrigin,this.apiPath=e.apiPath||l,this.clientId=e.clientId,this.i18n=e.i18n,this.eventBus=e.eventBus,this.singlePromise=new R({clientId:this.clientId}),this.retry=this.formatRetry(e.retry,t.defaultRetry),e.baseRequest?this.baseRequest=e.baseRequest:this.baseRequest=lt,this.tokenInURL=e.tokenInURL,this.headers=e.headers,this.storage=e.storage||dt,this.localCredentials=new pt({tokenSectionName:"credentials_".concat(e.clientId),storage:this.storage,clientId:e.clientId}),this.clientSecret=e.clientSecret,e.clientId&&(this.basicAuth="Basic ".concat(function(t){for(var e,r,n,i,o="",s=0,a=(t=String(t)).length%3;s<t.length;){if((r=t.charCodeAt(s++))>255||(n=t.charCodeAt(s++))>255||(i=t.charCodeAt(s++))>255)throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.");o+=C.charAt((e=r<<16|n<<8|i)>>18&63)+C.charAt(e>>12&63)+C.charAt(e>>6&63)+C.charAt(63&e)}return a?o.slice(0,a-3)+"===".substring(a):o}("".concat(e.clientId,":").concat(this.clientSecret)))),this.wxCloud=e.wxCloud;try{L()&&(this.useWxCloud=e.useWxCloud,void 0===this.wxCloud&&e.env&&(wx.cloud.init({env:e.env}),this.wxCloud=wx.cloud))}catch(t){}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!==(r=e.debug)&&void 0!==r&&r,et.on("lang_change",function(t){var e;n.i18n=(null===(e=t.data)||void 0===e?void 0:e.i18n)||n.i18n})}return t.prototype.setGetInitialSession=function(t){this.getInitialSession=t},t.prototype.setOnInitialSessionObtained=function(t){this.onInitialSessionObtained=t},t.prototype.initialize=function(t){return ot(this,void 0,Promise,function(){var e=this;return st(this,function(r){switch(r.label){case 0:return this.initializePromise?[4,this.initializePromise]:[3,2];case 1:case 3:case 5:return[2,r.sent()];case 2:return void 0===t?[3,4]:(this.initializePromise=t,[4,this.initializePromise]);case 4:return this.initializePromise=ot(e,void 0,void 0,function(){var t=this;return st(this,function(e){switch(e.label){case 0:return[4,this._acquireLock(-1,function(){return ot(t,void 0,void 0,function(){return st(this,function(t){switch(t.label){case 0:return[4,this._initialize()];case 1:return[2,t.sent()]}})})})];case 1:return[2,e.sent()]}})}),[4,this.initializePromise]}})})},t.prototype.setCredentials=function(t){return ot(this,void 0,Promise,function(){var e=this;return st(this,function(r){switch(r.label){case 0:return[4,this.initializePromise];case 1:return r.sent(),[2,this._acquireLock(-1,function(){return ot(e,void 0,void 0,function(){return st(this,function(e){return[2,this.localCredentials.setCredentials(t)]})})})]}})})},t.prototype.setAccessKeyCredentials=function(t){return this.localCredentials.setAccessKeyCredentials(t)},t.prototype.getAccessToken=function(){return ot(this,void 0,Promise,function(){var t,e;return st(this,function(r){switch(r.label){case 0:return[4,this.initializePromise];case 1:return r.sent(),[4,this.getCredentials()];case 2:return(null==(t=r.sent())?void 0:t.scope)===E||(null==t?void 0:t.access_token)?[2,Promise.resolve(t.access_token)]:(e={error:u.UNAUTHENTICATED},[2,Promise.reject(e)])}})})},t.prototype.request=function(e,r){var n,i;return ot(this,void 0,Promise,function(){var o,s,a,c,h,l,d,f,p,v;return st(this,function(g){switch(g.label){case 0:return r||(r={}),o=this.formatRetry(r.retry,this.retry),r.headers=it(it({},r.headers),((v={})[null===(n=this.i18n)||void 0===n?void 0:n.LANG_HEADER_KEY]=null===(i=this.i18n)||void 0===i?void 0:i.lang,v)),this.headers&&(r.headers=it(it({},this.headers),r.headers)),r.headers[ut]||(r.headers[ut]=S()),r.headers[ct]?[3,2]:[4,this.getDeviceId()];case 1:s=g.sent(),r.headers[ct]=s,g.label=2;case 2:return(null==r?void 0:r.withBasicAuth)&&this.basicAuth&&(r.headers.Authorization=this.basicAuth),(null==r?void 0:r.withCredentials)?r.getCredentials?[4,r.getCredentials()]:[3,4]:[3,7];case 3:return c=g.sent(),[3,6];case 4:return[4,this.getCredentials()];case 5:c=g.sent(),g.label=6;case 6:return(a=c)&&(this.tokenInURL?(e.indexOf("?")<0&&(e+="?"),e+="access_token=".concat(a.access_token)):r.headers.Authorization="".concat(a.token_type," ").concat(a.access_token)),[3,8];case 7:this.clientId&&e.indexOf("client_id")<0&&(e+=e.indexOf("?")<0?"?":"&",e+="client_id=".concat(this.clientId)),g.label=8;case 8:e.startsWith("/")&&(h=this.getApiOriginFunc?this.getApiOriginFunc():this.apiOrigin,e="".concat(h).concat(this.apiPath).concat(e)),l=null,d=o+1,f=0,g.label=9;case 9:if(!(f<d))return[3,21];g.label=10;case 10:return g.trys.push([10,15,,18]),r.useWxCloud||this.useWxCloud?[4,this.wxCloudCallFunction(e,r)]:[3,12];case 11:return l=g.sent(),[3,14];case 12:return[4,this.baseRequest(e,r)];case 13:l=g.sent(),g.label=14;case 14:if(null==l?void 0:l.code)throw{error:l.code,error_description:l.message,error_uri:new URL(e).pathname};return[3,21];case 15:p=g.sent();try{p.requestId=p.requestId||r.headers[ut]||""}catch(t){}return r.withCredentials&&p&&p.error===u.UNAUTHENTICATED?[4,this.setCredentials(null)]:[3,17];case 16:return g.sent(),[2,Promise.reject(p)];case 17:return f!==o&&p&&"unreachable"===p.error?[3,18]:[2,Promise.reject(p)];case 18:return[4,this.sleep(t.retryInterval)];case 19:g.sent(),g.label=20;case 20:return f++,[3,9];case 21:return[2,l]}})})},t.prototype.wxCloudCallFunction=function(t,e){var r;return ot(this,void 0,Promise,function(){var n,i,o,s,a;return st(this,function(c){switch(c.label){case 0:n=null,i=null,c.label=1;case 1:c.trys.push([1,7,,8]),o="",c.label=2;case 2:return c.trys.push([2,4,,5]),[4,wx.getRendererUserAgent()];case 3:return o=c.sent(),[3,5];case 4:return c.sent(),[3,5];case 5:return[4,this.wxCloud.callFunction({name:"httpOverCallFunction",data:{url:t,method:e.method,headers:it({origin:"https://servicewechat.com","User-Agent":o},e.headers),body:e.body}})];case 6:return s=c.sent().result,(null===(r=null==s?void 0:s.body)||void 0===r?void 0:r.error_code)?(i=null==s?void 0:s.body).error_uri=(0,A.y)(t):n=null==s?void 0:s.body,[3,8];case 7:return a=c.sent(),i={error:u.UNREACHABLE,error_description:a.message,error_uri:(0,A.y)(t)},[3,8];case 8:if(i)throw i;return[2,n]}})})},t.prototype.getCredentials=function(){return ot(this,void 0,Promise,function(){var t=this;return st(this,function(e){switch(e.label){case 0:return[4,this.initializePromise];case 1:return e.sent(),[2,this._acquireLock(-1,function(){return ot(t,void 0,void 0,function(){return st(this,function(t){return[2,this._getCredentials()]})})})]}})})},t.prototype.getCredentialsSync=function(){return this.localCredentials.getStorageCredentialsSync()},t.prototype.getCredentialsAsync=function(){return this.getCredentials()},t.prototype.getScope=function(){var t;return ot(this,void 0,Promise,function(){var e,r;return st(this,function(n){switch(n.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return(e=n.sent())?[2,e.scope]:(r="credentials not found",null===(t=this.onCredentialsError)||void 0===t||t.call(this,{msg:r}),[2,this.unAuthenticatedError(r)])}})})},t.prototype.getGroups=function(){var t;return ot(this,void 0,Promise,function(){var e,r;return st(this,function(n){switch(n.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return(e=n.sent())?[2,e.groups]:(r="credentials not found",null===(t=this.onCredentialsError)||void 0===t||t.call(this,{msg:r}),[2,this.unAuthenticatedError(r)])}})})},t.prototype.refreshToken=function(t,e){return ot(this,void 0,Promise,function(){var r=this;return st(this,function(n){switch(n.label){case 0:return[4,this.initializePromise];case 1:return n.sent(),[2,this._acquireLock(-1,function(){return ot(r,void 0,void 0,function(){return st(this,function(r){return[2,this._refreshToken(t,e)]})})})]}})})},t.prototype._refreshToken=function(t,e){return ot(this,void 0,Promise,function(){var r=this;return st(this,function(n){return[2,this.singlePromise.run("_refreshToken",function(){return ot(r,void 0,void 0,function(){var r,n,i,o,s,a,c;return st(this,function(h){switch(h.label){case 0:if((null==t?void 0:t.scope)===E)return[2,t];if(!t||!t.refresh_token)return i="no refresh token found in credentials",null===(o=this.onCredentialsError)||void 0===o||o.call(this,{msg:i}),[2,this.unAuthenticatedError(i)];h.label=1;case 1:return h.trys.push([1,4,,7]),[4,this.refreshTokenFunc(t.refresh_token,t)];case 2:return r=h.sent(),[4,this.localCredentials.setCredentials(r)];case 3:return h.sent(),null===(s=this.eventBus)||void 0===s||s.fire(b,{event:g}),[2,r];case 4:if(n=h.sent(),null==e?void 0:e.throwError)throw n;return n.error!==u.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return h.sent(),i=n.error_description,null===(a=this.onCredentialsError)||void 0===a||a.call(this,{msg:i}),[2,this.unAuthenticatedError(i)];case 6:return null===(c=this.onCredentialsError)||void 0===c||c.call(this,{msg:n.error_description}),[2,Promise.reject(n)];case 7:return[2]}})})})]})})},t.prototype.anonymousLogin=function(t){return ot(this,void 0,void 0,function(){var e=this;return st(this,function(r){return[2,this.singlePromise.run("_anonymousLogin",function(){return ot(e,void 0,void 0,function(){var e,r;return st(this,function(n){switch(n.label){case 0:return this.anonymousSignInFunc?[4,this.anonymousSignInFunc(t)]:[3,4];case 1:return e=n.sent(),(r=e)?[3,3]:[4,this.localCredentials.getCredentials()];case 2:r=n.sent(),n.label=3;case 3:return t=r,[3,6];case 4:return[4,this.anonymousSignIn(t)];case 5:t=n.sent(),n.label=6;case 6:return[2,t]}})})})]})})},t.prototype.checkRetry=function(e){var r=null;if(("number"!=typeof e||e<t.minRetry||e>t.maxRetry)&&(r={error:u.UNREACHABLE,error_description:"wrong options param: retry"}),r)throw r;return e},t.prototype.formatRetry=function(t,e){return void 0===t?e:this.checkRetry(t)},t.prototype.sleep=function(t){return ot(this,void 0,Promise,function(){return st(this,function(e){return[2,new Promise(function(e){setTimeout(function(){e()},t)})]})})},t.prototype.anonymousSignIn=function(t){return ot(this,void 0,Promise,function(){var e=this;return st(this,function(r){return[2,this.singlePromise.run("_anonymous",function(){return ot(e,void 0,void 0,function(){var e,r;return st(this,function(i){switch(i.label){case 0:if(!t||"anonymous"!==t.scope)return[2,this.unAuthenticatedError("no anonymous in credentials")];i.label=1;case 1:return i.trys.push([1,4,,7]),[4,this.request(n.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",withBasicAuth:!0,body:{}})];case 2:return e=i.sent(),[4,this.localCredentials.setCredentials(e)];case 3:return i.sent(),[2,e];case 4:return(r=i.sent()).error!==u.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return i.sent(),[2,this.unAuthenticatedError(r.error_description)];case 6:return[2,Promise.reject(r)];case 7:return[2]}})})})]})})},t.prototype.defaultRefreshTokenFunc=function(t,e){var r;return ot(this,void 0,Promise,function(){var o,s,a;return st(this,function(u){switch(u.label){case 0:return void 0===t||""===t?(o="refresh token not found",null===(r=this.onCredentialsError)||void 0===r||r.call(this,{msg:o}),[2,this.unAuthenticatedError(o)]):(s=n.AUTH_TOKEN_URL,"v2"===(null==e?void 0:e.version)&&(s=i.AUTH_TOKEN_URL),[4,this.request(s,{method:"POST",body:{client_id:this.clientId,client_secret:this.clientSecret,grant_type:"refresh_token",refresh_token:t}})]);case 1:return a=u.sent(),[2,it(it({},a),{version:(null==e?void 0:e.version)||"v1"})]}})})},t.prototype.getDeviceId=function(){return ot(this,void 0,Promise,function(){var t;return st(this,function(e){switch(e.label){case 0:return this.deviceID?[2,this.deviceID]:[4,this.storage.getItem(ht)];case 1:return"string"==typeof(t=e.sent())&&t.length>=16&&t.length<=48?[3,3]:(t=S(),[4,this.storage.setItem(ht,t)]);case 2:e.sent(),e.label=3;case 3:return this.deviceID=t,[2,t]}})})},t.prototype.unAuthenticatedError=function(t){var e={error:u.UNAUTHENTICATED,error_description:t};return Promise.reject(e)},t.prototype._debug=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.logDebugMessages&&console.log.apply(console,at(["[OAuth2Client]"],t,!1))},t.prototype._initialize=function(){return ot(this,void 0,Promise,function(){var t,e,r,n,i,o;return st(this,function(s){switch(s.label){case 0:if(s.trys.push([0,11,12,13]),!this.getInitialSession)return this._debug("#_initialize()","no getInitialSession callback set, skipping"),[2,{error:null}];this._debug("#_initialize()","calling getInitialSession callback"),s.label=1;case 1:return s.trys.push([1,9,,10]),[4,this.getInitialSession()];case 2:return o=s.sent(),t=o.data,e=o.error,(null==t?void 0:t.session)?(this._debug("#_initialize()","session obtained from getInitialSession",t.session),[4,this.localCredentials.setCredentials(null==t?void 0:t.session)]):[3,4];case 3:s.sent(),s.label=4;case 4:if(!this.onInitialSessionObtained)return[3,8];this._debug("#_initialize()","calling onInitialSessionObtained callback"),s.label=5;case 5:return s.trys.push([5,7,,8]),[4,this.onInitialSessionObtained(t,e)];case 6:return s.sent(),[3,8];case 7:return r=s.sent(),this._debug("#_initialize()","error in onInitialSessionObtained",r),[3,8];case 8:return e?(this._debug("#_initialize()","error from getInitialSession",e),[2,{error:e}]):[2,{error:null}];case 9:return n=s.sent(),this._debug("#_initialize()","exception during getInitialSession",n),[2,{error:n instanceof Error?n:new Error(String(n))}];case 10:return[3,13];case 11:return i=s.sent(),this._debug("#_initialize()","unexpected error",i),[2,{error:i instanceof Error?i:new Error(String(i))}];case 12:return this._debug("#_initialize()","end"),[7];case 13:return[2]}})})},t.prototype._acquireLock=function(t,e){return ot(this,void 0,Promise,function(){var r,n,i,o,s=this;return st(this,function(a){switch(a.label){case 0:this._debug("#_acquireLock","begin",t),a.label=1;case 1:if(a.trys.push([1,,10,11]),this.lockAcquired)return r=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),n=ot(s,void 0,void 0,function(){return st(this,function(t){switch(t.label){case 0:return[4,r];case 1:return t.sent(),[4,e()];case 2:return[2,t.sent()]}})}),this.pendingInLock.push(ot(s,void 0,void 0,function(){return st(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,n];case 1:case 2:return t.sent(),[3,3];case 3:return[2]}})})),[2,n];this._debug("#_acquireLock","acquiring lock for client",this.clientId),a.label=2;case 2:return a.trys.push([2,,8,9]),this.lockAcquired=!0,i=e(),this.pendingInLock.push(ot(s,void 0,void 0,function(){return st(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,i];case 1:case 2:return t.sent(),[3,3];case 3:return[2]}})})),[4,i];case 3:a.sent(),a.label=4;case 4:return this.pendingInLock.length?(o=at([],this.pendingInLock,!0),[4,Promise.all(o)]):[3,6];case 5:return a.sent(),this.pendingInLock.splice(0,o.length),[3,4];case 6:return[4,i];case 7:return[2,a.sent()];case 8:return this._debug("#_acquireLock","releasing lock for client",this.clientId),this.lockAcquired=!1,[7];case 9:return[3,11];case 10:return this._debug("#_acquireLock","end"),[7];case 11:return[2]}})})},t.prototype._getCredentials=function(){var t,e,r;return ot(this,void 0,Promise,function(){var n,i,o;return st(this,function(s){switch(s.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:if((null==(n=s.sent())?void 0:n.scope)===E)return[2,n];if(!n)return o="credentials not found",null===(t=this.onCredentialsError)||void 0===t||t.call(this,{msg:o}),[2,this.unAuthenticatedError(o)];if(!ft(n))return[3,12];if(!n.refresh_token)return[3,9];s.label=2;case 2:return s.trys.push([2,4,,8]),[4,this._refreshToken(n)];case 3:return n=s.sent(),[3,8];case 4:return i=s.sent(),"anonymous"!==n.scope?[3,6]:[4,this.anonymousLogin(n)];case 5:return n=s.sent(),[3,7];case 6:return null===(e=this.onCredentialsError)||void 0===e||e.call(this,{msg:i.error_description}),[2,Promise.reject(i)];case 7:return[3,8];case 8:return[3,12];case 9:return"anonymous"!==n.scope?[3,11]:[4,this.anonymousLogin(n)];case 10:return n=s.sent(),[3,12];case 11:return o="no refresh token found in credentials",null===(r=this.onCredentialsError)||void 0===r||r.call(this,{msg:o}),[2,this.unAuthenticatedError(o)];case 12:return[2,n]}})})},t.defaultRetry=2,t.minRetry=0,t.maxRetry=5,t.retryInterval=1e3,t}(),gt=o(689),mt=o(616),yt=function(){return yt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},yt.apply(this,arguments)},_t=function(t,e,r,n){return new(r||(r=Promise))(function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(s,a)}u((n=n.apply(t,e||[])).next())})},bt=function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=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(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},It=function(t,e){var r;return function(){for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];clearTimeout(r),r=setTimeout(function(){return t.apply(null,n)},e)}},wt=new gt.CloudbaseEventEmitter,Et="resolveCaptchaData",St="padding:10px 8px;background:#007bff;color:#fff;border:none;border-radius:4px;cursor:pointer;flex:1;white-space:nowrap;margin-left:10px",At="width:100%;padding:10px;background:#007bff;color:#fff;border:none;border-radius:4px;cursor:pointer",Pt="background:#6c757d;cursor:not-allowed",Ot=function(t,e,r,n){return new(r||(r=Promise))(function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(s,a)}u((n=n.apply(t,e||[])).next())})},Tt=function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=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(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},Rt=function(){function t(t){t.openURIWithCallback||(t.openURIWithCallback=this.getDefaultOpenURIWithCallback()),t.storage||(t.storage=dt),this.config=t,this.tokenSectionName="captcha_".concat(t.clientId||t.env)}return t.prototype.isMatch=function(){var t,e,r;return(null===(r=null===(e=null===(t=this.config)||void 0===t?void 0:t.adapter)||void 0===e?void 0:e.isMatch)||void 0===r?void 0:r.call(e))||L()},t.prototype.request=function(t,e){return Ot(this,void 0,Promise,function(){var r,n,i,o;return Tt(this,function(s){switch(s.label){case 0:return e||(e={}),e.method||(e.method="GET"),r="".concat(e.method,":").concat(t),n=t,e.withCaptcha?[4,this.appendCaptchaTokenToURL(t,r,!1)]:[3,2];case 1:n=s.sent(),s.label=2;case 2:return s.trys.push([2,4,,7]),[4,this.config.request(n,e)];case 3:return i=s.sent(),[3,7];case 4:return(o=s.sent()).error!==u.CAPTCHA_REQUIRED&&o.error!==u.CAPTCHA_INVALID?[3,6]:[4,this.appendCaptchaTokenToURL(t,r,o.error===u.CAPTCHA_INVALID)];case 5:return t=s.sent(),[2,this.config.request(t,e)];case 6:return[2,Promise.reject(o)];case 7:return[2,i]}})})},t.prototype.getDefaultOpenURIWithCallback=function(){var t=this;return function(e){return function(t,e){return _t(void 0,void 0,Promise,function(){var r,n,i,o;return bt(this,function(s){return r=(0,mt.parseCaptcha)(t),n=r.captchaData,i=r.state,o=r.token,function(t){var e=t.oauthInstance,r=t.captchaState,n="captcha-image",i=function(){return _t(void 0,void 0,void 0,function(){var t,i;return bt(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,e.createCaptchaData({state:r.state})];case 1:return t=o.sent(),r=yt(yt({},r),{captchaData:t.data,token:t.token}),document.getElementById(n).src=t.data,[3,3];case 2:return i=o.sent(),console.error("刷新图形验证码失败",i),[3,3];case 3:return[2]}})})},o=function(t,e,r){var n=document.createElement(t);return e&&(n.style.cssText=e),r&&(n.textContent=r),n},s=o("div","position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.5);z-index:999"),a=o("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(o("p","margin-bottom:15px","请输入你看到的字符:"));var u=o("div","display:flex;align-items:center;justify-content:space-between;margin-bottom:15px"),c=o("img","width:100%;height:auto;border:1px solid #eee");c.id=n,c.src=r.captchaData,u.appendChild(c);var h=o("button",St,"刷新");h.onclick=It(function(){return _t(void 0,void 0,void 0,function(){return bt(this,function(t){switch(t.label){case 0:h.textContent="加载中...",h.disabled=!0,h.style.cssText="".concat(St,";").concat(Pt),t.label=1;case 1:return t.trys.push([1,,3,4]),[4,i()];case 2:return t.sent(),[3,4];case 3:return h.textContent="刷新",h.disabled=!1,h.style.cssText=St,[7];case 4:return[2]}})})},500),u.appendChild(h),a.appendChild(u);var l=o("input","width:100%;padding:14px 16px;margin-bottom:15px;box-sizing:border-box;border:2px solid #e8ecf4;border-radius:10px;font-size:15px");l.type="text",l.placeholder="输入字符",l.maxLength=4,a.appendChild(l);var d=o("div","color:#dc3545;font-size:12px;margin-bottom:10px;display:none;padding:8px;background:#f8d7da;border:1px solid #f5c6cb;border-radius:4px");a.appendChild(d);var f=function(t){d.textContent=t,d.style.display="block"},p=o("button",At,"确定");p.onclick=It(function(){return _t(void 0,void 0,void 0,function(){var t,n,o,u;return bt(this,function(c){switch(c.label){case 0:if(!(t=l.value.trim()))return f("请输入字符"),[2];d.style.display="none",p.textContent="验证中...",p.disabled=!0,p.style.cssText="".concat(At,";").concat(Pt),c.label=1;case 1:return c.trys.push([1,3,5,6]),[4,e.verifyCaptchaData({token:r.token,key:t})];case 2:return n=c.sent(),wt.fire(Et,n),console.log("图形验证码校验成功"),document.body.removeChild(s),document.body.removeChild(a),[3,6];case 3:return o=c.sent(),console.error("图形验证码校验失败",o),u=o.error_description||"图形验证码校验失败",f(u),l.value="",l.focus(),[4,i()];case 4:return c.sent(),[3,6];case 5:return p.textContent="确定",p.disabled=!1,p.style.cssText=At,[7];case 6:return[2]}})})},500),a.appendChild(p),document.body.appendChild(s),document.body.appendChild(a)}({oauthInstance:e,captchaState:{captchaData:n,state:i,token:o}}),[2,new Promise(function(t){console.log("等待图形验证码校验结果..."),wt.on(Et,function(e){t(null==e?void 0:e.data)})})]})})}(e,t.config.oauthInstance)}},t.prototype.getCaptchaToken=function(t,e){return Ot(this,void 0,Promise,function(){var r,i,o,s;return Tt(this,function(a){switch(a.label){case 0:return t?[3,2]:[4,this.findCaptchaToken()];case 1:if(r=a.sent())return[2,r];a.label=2;case 2:return[4,this.config.request(n.CAPTCHA_DATA_URL,{method:"POST",body:{state:e,redirect_uri:""},withCredentials:!1})];case 3:return i=a.sent(),o="".concat(i.data,"?state=").concat(encodeURIComponent(e),"&token=").concat(encodeURIComponent(i.token)),[4,this.config.openURIWithCallback(o)];case 4:return s=a.sent(),this.saveCaptchaToken(s),[2,s.captcha_token]}})})},t.prototype.appendCaptchaTokenToURL=function(t,e,r){return Ot(this,void 0,Promise,function(){var n;return Tt(this,function(i){switch(i.label){case 0:return[4,this.getCaptchaToken(r,e)];case 1:return n=i.sent(),t.indexOf("?")>0?t+="&captcha_token=".concat(n):t+="?captcha_token=".concat(n),[2,t]}})})},t.prototype.saveCaptchaToken=function(t){return Ot(this,void 0,void 0,function(){var e;return Tt(this,function(r){switch(r.label){case 0:return t.expires_at=new Date(Date.now()+1e3*(t.expires_in-10)),e=JSON.stringify(t),[4,this.config.storage.setItem(this.tokenSectionName,e)];case 1:return r.sent(),[2]}})})},t.prototype.findCaptchaToken=function(){return Ot(this,void 0,Promise,function(){var t,e;return Tt(this,function(r){switch(r.label){case 0:return[4,this.config.storage.getItem(this.tokenSectionName)];case 1:if(null==(t=r.sent()))return[3,5];r.label=2;case 2:return r.trys.push([2,3,,5]),(null==(e=JSON.parse(t))?void 0:e.expires_at)&&(e.expires_at=new Date(e.expires_at)),e.expires_at<new Date?[2,null]:[2,e.captcha_token];case 3:return r.sent(),[4,this.config.storage.removeItem(this.tokenSectionName)];case 4:return r.sent(),[2,null];case 5:return[2,null]}})})},t}();const Ct=function(){function t(t){if(this.params={},"string"==typeof t)this.parse(t);else if(t&&"object"==typeof t)for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&this.append(e,t[e])}return t.prototype.parse=function(t){var e=this;t.split("&").forEach(function(t){var r=t.split("=").map(decodeURIComponent),n=r[0],i=r[1];e.append(n,i)})},t.prototype.append=function(t,e){this.params[t]?this.params[t]=this.params[t].concat([e]):this.params[t]=[e]},t.prototype.get=function(t){return this.params[t]?this.params[t][0]:null},t.prototype.getAll=function(t){return this.params[t]||[]},t.prototype.delete=function(t){delete this.params[t]},t.prototype.has=function(t){return Object.prototype.hasOwnProperty.call(this.params,t)},t.prototype.set=function(t,e){this.params[t]=[e]},t.prototype.toString=function(){var t=[],e=function(e){Object.prototype.hasOwnProperty.call(r.params,e)&&r.params[e].forEach(function(r){t.push("".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(r)))})},r=this;for(var n in this.params)e(n);return t.join("&")},t}();var Ut,Nt=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();!function(t){t.PROVIDER_NOT_ENABLED="PROVIDER_NOT_ENABLED",t.INVALID_CREDENTIALS="INVALID_CREDENTIALS",t.USER_NOT_FOUND="USER_NOT_FOUND",t.USER_STATUS_ABNORMAL="USER_STATUS_ABNORMAL",t.SERVICE_ERROR="SERVICE_ERROR",t.INVALID_PARAMS="INVALID_PARAMS",t.AUTH_METHOD_MISMATCH="AUTH_METHOD_MISMATCH",t.RATE_LIMITED="RATE_LIMITED",t.CAPTCHA_REQUIRED="CAPTCHA_REQUIRED",t.CAPTCHA_INVALID="CAPTCHA_INVALID",t.MFA_REQUIRED="MFA_REQUIRED",t.PRECONDITION_FAILED="PRECONDITION_FAILED",t.VERIFICATION_FAILED="VERIFICATION_FAILED",t.UNKNOWN="UNKNOWN"}(Ut||(Ut={}));var Lt="https://tcb.cloud.tencent.com/dev?envId=#/identity/login-manage",Dt="https://docs.cloudbase.net/api-reference/webv3-next/initialization",kt=function(t){function e(e,r){var n,i=this,o=e.error_description||e.message;return(i=t.call(this,o)||this).__isAuthError=!0,i.name="AuthError",i.status=e.error,i.code=String(e.error||e.error_code||"unknown").toLowerCase(),i.errorCode="number"==typeof e.error_code?e.error_code:"string"==typeof e.error_code&&parseInt(e.error_code,10)||void 0,i.requestId=e.requestId,i.category=function(t,e,r){if(!t&&!e&&!r)return Ut.UNKNOWN;try{var n=(t||"").toLowerCase(),i="string"==typeof r?parseInt(r,10):r;return i===c.CAPTCHA_REQUIRED||e===u.CAPTCHA_REQUIRED?Ut.CAPTCHA_REQUIRED:i===c.CAPTCHA_INVALID||e===u.CAPTCHA_INVALID?Ut.CAPTCHA_INVALID:i===c.MFA_PHONE_REQUIRED||e===u.MFA_PHONE_REQUIRED?Ut.MFA_REQUIRED:i===c.LOGIN_TYPE_DISABLED||e===u.LOGIN_TYPE_DISABLED?Ut.PROVIDER_NOT_ENABLED:i===c.RESOURCE_EXHAUSTED||e===u.RESOURCE_EXHAUSTED?Ut.RATE_LIMITED:i===c.INTERNAL||i===c.UNAVAILABLE||i===c.UNIMPLEMENTED||i===c.ABORTED?Ut.SERVICE_ERROR:i===c.NOT_FOUND?Ut.USER_NOT_FOUND:i===c.UNAUTHENTICATED?Ut.INVALID_CREDENTIALS:i===c.INVALID_ARGUMENT&&(n.includes("验证码")||n.includes("verification")||n.includes("verification_code")||n.includes("verification_id")||n.includes("does not match")||n.includes("token expired")||n.includes("token error")||n.includes("过期"))?Ut.VERIFICATION_FAILED:e===u.PROVIDER_NOT_ENABLED||e===u.LOGIN_METHOD_DISABLED||n.includes("身份源")||n.includes("开启")||n.includes("identity provider")||n.includes("provider not enabled")||n.includes("login method")||n.includes("登录方式")||n.includes("not enabled")||n.includes("未开启")||n.includes("未启用")||n.includes("请联系开发者")||n.includes("anonymous login is not enabled")||n.includes("匿名登录未开启")?Ut.PROVIDER_NOT_ENABLED:e===u.FAILED_PRECONDITION||i===c.FAILED_PRECONDITION&&!n.includes("请联系开发者")?n.includes("不存在")||n.includes("not found")||n.includes("未注册")?Ut.USER_NOT_FOUND:Ut.PRECONDITION_FAILED:e===u.INVALID_PASSWORD||e===u.INVALID_GRANT||e===u.INVALID_VERIFICATION_CODE||e===u.INVALID_USERNAME_OR_PASSWORD||e===u.INVALID_CREDENTIALS||e===u.WRONG_PASSWORD||e===u.UNAUTHENTICATED||e===u.INVALID_TWO_FACTOR||e===u.INVALID_TWO_FACTOR_RECOVERY||e===u.PASSWORD_NOT_SET||n.includes("密码不正确")||n.includes("password")||n.includes("invalid_password")||n.includes("凭据")||n.includes("credentials")||n.includes("验证码")||n.includes("verification")||n.includes("invalid_verification_code")||n.includes("invalid_username_or_password")||n.includes("username or password")||n.includes("用户名或密码")||n.includes("wrong password")||n.includes("incorrect password")?Ut.INVALID_CREDENTIALS:e===u.NOT_FOUND||e===u.USER_NOT_FOUND||n.includes("用户不存在")||n.includes("not found")||n.includes("user not found")||n.includes("no such user")||n.includes("user does not exist")?Ut.USER_NOT_FOUND:e===u.USER_BLOCKED||e===u.USER_PENDING||e===u.UNDER_REVIEW||e===u.INVALID_STATUS||n.includes("被封禁")||n.includes("blocked")||n.includes("pending")||n.includes("审核")||n.includes("review")||n.includes("locked")||n.includes("已锁定")?Ut.USER_STATUS_ABNORMAL:e===u.SERVER_ERROR||e===u.UNAVAILABLE||e===u.TEMPORARILY_UNAVAILABLE||e===u.INTERNAL||e===u.UNREACHABLE||e===u.DEADLINE_EXCEEDED||e===u.DATA_LOSS||e===u.ABORTED||n.includes("network")||n.includes("timeout")||n.includes("timed out")||n.includes("超时")||n.includes("smtp is not set")||n.includes("sms sender does not config")?Ut.SERVICE_ERROR:e===u.INVALID_ARGUMENT||e===u.INVALID_REQUEST||e===u.INVALID_SCOPE||e===u.INVALID_REQUEST_URI||e===u.INVALID_REQUEST_OBJECT||i===c.INVALID_ARGUMENT?Ut.INVALID_PARAMS:e===u.PERMISSION_DENIED||e===u.ACCESS_DENIED||e===u.UNAUTHORIZED_CLIENT?Ut.PROVIDER_NOT_ENABLED:Ut.UNKNOWN}catch(t){return e}}(o,i.status,i.errorCode),i.helpMessage=function(t,e){var r=(null==e?void 0:e.method)||"signIn",n={signInWithPassword:"「用户名密码登录」",signInAnonymously:"「匿名登录」",signInWithOtp:"「短信验证码登录」或「邮箱验证码登录」",signUp:"「短信验证码登录」或「邮箱验证码登录」",signInWithOAuth:"对应的第三方身份源",signInWithIdToken:"对应的第三方身份源",signInWithOpenId:"「微信小程序 OpenID 登录」",signInWithPhoneAuth:"「微信小程序手机号授权登录」",signInWithCustomTicket:"「自定义登录」",getVerification:"「短信验证码登录」或「邮箱验证码登录」",verify:"「短信验证码登录」或「邮箱验证码登录」",verifyOtp:"「短信验证码登录」或「邮箱验证码登录」",resetPasswordForEmail:"「邮箱验证码登录」",reauthenticate:"「短信验证码登录」或「邮箱验证码登录」"}[r]||"对应的登录方式";switch(t){case Ut.PROVIDER_NOT_ENABLED:return"[CloudBase Auth] 登录方式未开启\n\n"+" 当前调用的 ".concat(r,"() 所需的登录方式尚未在云开发控制台启用。\n")+" 需要开启的登录方式:".concat(n,"\n")+"\n 请按以下步骤开启:\n"+" 1. 打开云开发控制台:".concat(Lt,"\n")+" 2. 选择对应的云开发环境\n 3. 进入「登录授权」页面,在「登录方式」或「身份源列表」中开启所需的登录方式\n\n 各登录方法与所需登录方式的对应关系:\n - signInWithPassword → 「用户名密码登录」\n - signInAnonymously → 「匿名登录」\n - signInWithOtp/signUp → 「短信验证码登录」或「邮箱验证码登录」\n - signInWithOAuth/signInWithIdToken → 对应的第三方身份源\n\n 如使用 CLI/MCP 工具,可通过 auth 工具查询和配置身份源状态。\n"+" 更多帮助请参考文档:".concat(Dt);case Ut.INVALID_CREDENTIALS:return"[CloudBase Auth] 凭据验证失败\n\n"+" 调用 ".concat(r,"() 时凭据校验未通过。\n")+"\n 请按优先级逐项排查:\n 1. 确认用户名/邮箱/手机号是否拼写正确、格式完整\n 2. 确认密码是否正确(注意大小写、特殊字符、前后空格)\n 3. 确认用户账号确实存在(可通过 auth.isUsernameRegistered() 检查)\n 4. 确认凭据参数来源可靠(环境变量、配置文件中的值是否已正确设置)\n 5. 如使用加密登录(is_encrypt: true),请确认公钥版本正确\n\n 如忘记密码,可通过 auth.resetPasswordForEmail() 重置密码。\n\n 提示:如果是 AI agent / 自动化测试场景,请确认 ENV_ID、USERNAME、PASSWORD\n 等环境变量已正确传入,且对应用户已在目标环境中注册。";case Ut.USER_NOT_FOUND:return"[CloudBase Auth] 用户不存在\n\n 请检查以下项目:\n 1. 确认用户名/邮箱/手机号是否正确\n 2. 确认是在正确的云开发环境(envId)下操作\n 3. 如果是新用户,请先通过 auth.signUp() 注册\n"+" 4. 也可在云开发控制台手动创建用户:".concat(Lt,"\n")+"\n 提示:不同环境(开发/测试/生产)的用户库是隔离的,请确认 envId 正确。";case Ut.USER_STATUS_ABNORMAL:return"[CloudBase Auth] 用户状态异常\n\n 当前用户账号可能处于以下状态之一:\n - 账号已被封禁\n - 账号正在审核中\n - 账号已被锁定(多次密码错误)\n\n"+" 请联系管理员在云开发控制台检查用户状态:".concat(Lt);case Ut.SERVICE_ERROR:return"[CloudBase Auth] 服务异常\n\n 请检查以下项目:\n 1. 网络连接是否正常\n 2. 云开发环境是否正常运行\n 3. 稍后重试,如持续失败请联系技术支持\n\n 提示:如果是超时错误,请检查网络环境和请求频率。\n 常见服务端错误:smtp 未配置、短信服务未配置、wedaapis 未设置等。";case Ut.INVALID_PARAMS:return"[CloudBase Auth] 参数错误\n\n 请检查传入的参数是否符合要求:\n - 不能同时输入手机号和邮箱\n - 手机号格式需正确(如 +86 开头)\n - 必须提供手机号或邮箱\n\n"+" 参考 API 文档确认各参数的格式和约束:".concat(Dt);case Ut.AUTH_METHOD_MISMATCH:return"[CloudBase Auth] 登录方式不匹配\n\n"+" 调用 ".concat(r,"() 时遇到错误,可能原因:\n")+" - 匿名登录失败后尝试了用户名密码登录,但凭据不正确或用户不存在\n - 应使用匿名登录但传入了密码参数\n - 应使用密码登录但未传入正确的凭据\n\n 建议:\n 1. 明确当前场景需要的登录方式:\n - 无需用户注册 → auth.signInAnonymously()\n - 有用户名和密码 → auth.signInWithPassword({ username, password })\n - 第三方平台 → auth.signInWithOAuth({ provider })\n 2. 不要在同一流程中混合使用不同的登录方式\n 3. 每种登录方式需要在控制台开启对应的身份源\n"+" 4. 控制台地址:".concat(Lt);case Ut.RATE_LIMITED:return"[CloudBase Auth] 发送频率受限\n\n 验证码发送过于频繁,已触发频率限制。\n\n 限制规则:\n - 手机号:每分钟最多 1 条,每天有上限\n - 邮箱:每分钟有上限,每天有上限(默认 50 条)\n\n 建议:\n 1. 检查 error.retryAfter 获取建议等待时间\n 2. 在 UI 中显示倒计时,防止用户重复点击\n 3. 如业务需要更高频率,请联系技术支持调整限额";case Ut.CAPTCHA_REQUIRED:return"[CloudBase Auth] 需要滑块验证码\n\n 当前操作触发了风控策略,需要完成滑块验证。\n\n 处理方式:\n 1. 调用滑块验证码 SDK 展示验证组件\n 2. 用户完成验证后,将 captcha_token 附带到请求中重新发送\n 3. 可通过 getVerification 的 options.withCaptcha 参数自动携带验证码";case Ut.CAPTCHA_INVALID:return"[CloudBase Auth] 滑块验证码校验失败\n\n 提交的验证码 token 校验未通过(可能已过期或 client_id 不匹配)。\n\n 处理方式:\n 1. 刷新滑块验证码,让用户重新验证\n 2. 确认 captcha 组件初始化的 client_id 与认证配置一致";case Ut.MFA_REQUIRED:return"[CloudBase Auth] 需要 MFA 验证\n\n 当前操作要求用户绑定手机号进行多因素认证 (MFA)。\n\n 处理方式:\n 1. 引导用户进入手机号绑定流程\n 2. 绑定完成后重新执行原操作\n 3. error 中可能包含 MFA 详情信息";case Ut.PRECONDITION_FAILED:return"[CloudBase Auth] 前置条件不满足\n\n 当前操作的前置条件不满足,常见原因:\n - 该手机号/邮箱已被其他账号绑定\n - 目标用户不存在或已存在(与 target 参数冲突)\n - 当前邮箱/手机号未注册用户\n\n 请根据 error.message 中的具体描述处理。";case Ut.VERIFICATION_FAILED:return'[CloudBase Auth] 验证码校验失败\n\n 验证码验证未通过,常见原因:\n - 验证码已过期(通常有效期为几分钟)\n - 验证码输入不正确\n - verification_id 无效或已被使用\n - 验证码不属于当前项目(project id does not match)\n\n 处理方式:\n 1. 提示用户"验证码已过期或不正确,请重新获取"\n 2. 调用 getVerification() 重新发送验证码\n 3. 确保 verification_id 与最新发送的验证码对应\n\n 注意:每次重新发送验证码后,之前的 verification_id 即失效。';default:return"[CloudBase Auth] 操作失败\n\n 如果问题持续存在,建议:\n"+" 1. 检查云开发控制台的认证配置:".concat(Lt,"\n")+" 2. 到官方问答社区提问:https://cnb.cool/tencent/cloud/cloudbase/community/-/issues\n"+" 3. 查阅文档:".concat(Dt)}}(i.category,r),i.loginMethodHint=(n=null==r?void 0:r.method)&&{signInWithPassword:"当前使用「用户名密码登录」,需确保:\n ✓ 控制台已开启「用户名密码登录」\n ✓ 用户已注册且凭据正确\n 如果不需要用户系统,建议改用 auth.signInAnonymously()",signInAnonymously:"当前使用「匿名登录」,需确保:\n ✓ 控制台已开启「匿名登录」\n 注意:匿名用户无需用户名密码,适用于快速体验或临时访问场景",signInWithOtp:"当前使用「OTP 验证码登录」,需确保:\n ✓ 控制台已开启「短信验证码登录」或「邮箱验证码登录」",signInWithOAuth:"当前使用「第三方 OAuth 登录」,需确保:\n ✓ 控制台已配置并开启对应的第三方身份源"}[n]||"",i.category===Ut.RATE_LIMITED&&(i.retryAfter=e.retry_after||e.retryAfter||void 0),i}return Nt(e,t),e}(Error),xt=function(){return xt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},xt.apply(this,arguments)},Mt=function(t,e,r,n){return new(r||(r=Promise))(function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(s,a)}u((n=n.apply(t,e||[])).next())})},qt=function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=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(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};function Bt(t,e){var r;return Mt(this,void 0,void 0,function(){var n,i=this;return qt(this,function(s){n=function(){return Mt(i,void 0,void 0,function(){return qt(this,function(t){switch(t.label){case 0:return t.trys.push([0,1,,6]),[2,o(171)];case 1:t.sent(),t.label=2;case 2:return t.trys.push([2,4,,5]),[4,Promise.resolve().then(o.bind(o,171))];case 3:return[2,t.sent()];case 4:return t.sent(),[2];case 5:return[3,6];case 6:return[2]}})})};try{if(((null===(r=null==e?void 0:e.root)||void 0===r?void 0:r.globalThis)||globalThis).IS_MP_BUILD)return[2];if(t)return[2,n()]}catch(e){if(t)return[2,n()]}return[2]})})}var jt=function(){function t(t){var e=t.request,r=t.credentialsClient;if(!r){var n={apiOrigin:t.apiOrigin,apiPath:t.apiPath,clientId:t.clientId,storage:t.storage,env:t.env,baseRequest:t.baseRequest,anonymousSignInFunc:t.anonymousSignInFunc,wxCloud:t.wxCloud,onCredentialsError:t.onCredentialsError,headers:t.headers||{},i18n:t.i18n,debug:t.debug};r=new vt(n)}if(!e){var i=r.request.bind(r),o=new Rt(xt({env:t.env,clientId:t.clientId,request:i,storage:t.storage,adapter:t.adapter,oauthInstance:this},t.captchaOptions));e=o.request.bind(o)}this.config={env:t.env,apiOrigin:t.apiOrigin,apiPath:t.apiPath,clientId:t.clientId,request:e,credentialsClient:r,storage:t.storage||dt,adapter:t.adapter}}return t.parseParamsToSearch=function(t){return Object.keys(t).forEach(function(e){t[e]||delete t[e]}),new Ct(t).toString()},t.prototype.getParamsByVersion=function(t,e){var r,o=(0,A.I)(t),s=(null===(r={v2:i}[null==o?void 0:o.version])||void 0===r?void 0:r[e])||n[e];return o&&delete o.version,{params:o,url:s}},t.prototype.signIn=function(t){return Mt(this,void 0,Promise,function(){var e,r,n,i;return qt(this,function(o){switch(o.label){case 0:return e=t.version||"v1",(r=this.getParamsByVersion(t,"AUTH_SIGN_IN_URL")).params.query&&delete r.params.query,[4,this.getEncryptParams(r.params)];case 1:return n=o.sent(),[4,this.config.request(r.url,{method:"POST",body:n})];case 2:return i=o.sent(),[4,this.config.credentialsClient.setCredentials(xt(xt({},i),{version:e}))];case 3:return o.sent(),[2,Promise.resolve(i)]}})})},t.prototype.signInAnonymously=function(t,e){return void 0===t&&(t={}),void 0===e&&(e=!1),Mt(this,void 0,Promise,function(){var r;return qt(this,function(i){switch(i.label){case 0:return[4,this.config.request(n.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",body:t,useWxCloud:e})];case 1:return r=i.sent(),[4,this.config.credentialsClient.setCredentials(r)];case 2:return i.sent(),[2,Promise.resolve(r)]}})})},t.prototype.signUp=function(t){return Mt(this,void 0,Promise,function(){var e;return qt(this,function(r){switch(r.label){case 0:return[4,this.config.request(n.AUTH_SIGN_UP_URL,{method:"POST",body:t})];case 1:return e=r.sent(),[4,this.config.credentialsClient.setCredentials(e)];case 2:return r.sent(),[2,Promise.resolve(e)]}})})},t.prototype.signOut=function(t){return Mt(this,void 0,Promise,function(){var e,r,i,o;return qt(this,function(s){switch(s.label){case 0:if(e={},!t)return[3,6];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.config.request(n.AUTH_SIGNOUT_URL,{method:"POST",withCredentials:!0,body:t})];case 2:return e=s.sent(),[3,4];case 3:return(r=s.sent()).error!==u.UNAUTHENTICATED&&console.log("sign_out_error",r),[3,4];case 4:return[4,this.config.credentialsClient.setCredentials()];case 5:return s.sent(),[2,e];case 6:return[4,this.config.credentialsClient.getAccessToken()];case 7:return i=s.sent(),[4,this.config.request(n.AUTH_REVOKE_URL,{method:"POST",body:{token:i}})];case 8:return o=s.sent(),[4,this.config.credentialsClient.setCredentials()];case 9:return s.sent(),[2,Promise.resolve(o)]}})})},t.prototype.revokeAllDevices=function(){return Mt(this,void 0,Promise,function(){return qt(this,function(t){switch(t.label){case 0:return[4,this.config.request(n.AUTH_REVOKE_ALL_URL,{method:"DELETE",withCredentials:!0})];case 1:return t.sent(),[2]}})})},t.prototype.revokeDevice=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){switch(e.label){case 0:return[4,this.config.request(n.AUTHORIZED_DEVICES_DELETE_URL+t.device_id,{method:"DELETE",withCredentials:!0})];case 1:return e.sent(),[2]}})})},t.prototype.getVerification=function(t,e){return Mt(this,void 0,Promise,function(){var r,i;return qt(this,function(o){switch(o.label){case 0:return r=!1,"CUR_USER"!==t.target?[3,1]:(r=!0,[3,3]);case 1:return[4,this.hasLoginState()];case 2:o.sent()&&(r=!0),o.label=3;case 3:return(i=(0,A.I)(t)).phone_number&&!/^\+\d{1,3}\s+\d+/.test(i.phone_number)&&(i.phone_number="+86 ".concat(i.phone_number)),[2,this.config.request(n.VERIFICATION_URL,{method:"POST",body:i,withCaptcha:(null==e?void 0:e.withCaptcha)||!1,withCredentials:r})]}})})},t.prototype.verify=function(t){return Mt(this,void 0,Promise,function(){var e,r;return qt(this,function(n){switch(n.label){case 0:return e=this.getParamsByVersion(t,"VERIFY_URL"),[4,this.config.request(e.url,{method:"POST",body:e.params})];case 1:return r=n.sent(),"v2"!==(null==t?void 0:t.version)?[3,3]:[4,this.config.credentialsClient.setCredentials(xt(xt({},r),{version:"v2"}))];case 2:n.sent(),n.label=3;case 3:return[2,r]}})})},t.prototype.genProviderRedirectUri=function(e){return Mt(this,void 0,Promise,function(){var r,i,o,s,a;return qt(this,function(u){return r=e.provider_redirect_uri,i=e.other_params,o=void 0===i?{}:i,s=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]])}return r}(e,["provider_redirect_uri","other_params"]),r&&!s.redirect_uri&&(s.redirect_uri=r),a="".concat(n.PROVIDER_URI_URL,"?").concat(t.parseParamsToSearch(s)),Object.keys(o).forEach(function(t){var e=o[t];("sign_out_uri"!==t||(null==e?void 0:e.length)>0)&&(a+="&other_params[".concat(t,"]=").concat(encodeURIComponent(e)))}),[2,this.config.request(a,{method:"GET"})]})})},t.prototype.grantProviderToken=function(t,e){return void 0===e&&(e=!1),Mt(this,void 0,Promise,function(){return qt(this,function(r){return[2,this.config.request(n.PROVIDER_TOKEN_URL,{method:"POST",body:t,useWxCloud:e})]})})},t.prototype.patchProviderToken=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.config.request(n.PROVIDER_TOKEN_URL,{method:"PATCH",body:t})]})})},t.prototype.signInWithProvider=function(t,e){return void 0===e&&(e=!1),Mt(this,void 0,Promise,function(){var r,n;return qt(this,function(i){switch(i.label){case 0:return r=this.getParamsByVersion(t,"AUTH_SIGN_IN_WITH_PROVIDER_URL"),[4,this.config.request(r.url,{method:"POST",body:r.params,useWxCloud:e})];case 1:return n=i.sent(),[4,this.config.credentialsClient.setCredentials(xt(xt({},n),{version:(null==t?void 0:t.version)||"v1"}))];case 2:return i.sent(),[2,Promise.resolve(n)]}})})},t.prototype.toBindIdentity=function(t){var e,r;return Mt(this,void 0,void 0,function(){var n,i,o,s;return qt(this,function(a){switch(a.label){case 0:return(i=t.credentials)?[3,2]:[4,this.config.credentialsClient.localCredentials.getCredentials()];case 1:i=a.sent(),a.label=2;case 2:n=i,a.label=3;case 3:return a.trys.push([3,5,,6]),[4,this.bindWithProvider({provider_token:t.provider_token},n)];case 4:return a.sent(),o={data:{type:w,provider:t.provider},error:null},[3,6];case 5:return s=a.sent(),o={data:{type:w},error:new kt(s)},[3,6];case 6:return t.fireEvent&&(null===(r=null===(e=this.config.eventBus)||void 0===e?void 0:e.fire)||void 0===r||r.call(e,b,{event:y,info:o})),[2,o]}})})},t.prototype.getInitialSession=function(){return Mt(this,void 0,Promise,function(){var t,e,r,n,i,o,s,a,u,c,h,l,d,f,p;return qt(this,function(v){switch(v.label){case 0:t={},v.label=1;case 1:if(v.trys.push([1,12,,13]),"undefined"==typeof window||"undefined"==typeof document)return[2,{data:null,error:null}];if(e=new URLSearchParams(null===location||void 0===location?void 0:location.search),r=e.get("code"),n=e.get("state"),!r||!n)return[2,{data:null,error:null}];i=null;try{i=JSON.parse(sessionStorage.getItem(n)||"null")}catch(t){}return t={type:null==i?void 0:i.type},o=e.get("error"),s=e.get("error_description"),o||s?[2,{data:t,error:new kt({message:s||o||"Unknown error from OAuth provider"})}]:(a=(null==i?void 0:i.provider)||e.get("provider"))?(u=location.origin+location.pathname,[4,this.grantProviderToken({provider_id:a,provider_redirect_uri:u,provider_code:r})]):[2,{data:t,error:new kt({message:"Provider is required for OAuth verification"})}];case 2:return c=v.sent().provider_token,h=void 0,l=null,d=void 0,i.type!==w?[3,5]:[4,this.config.credentialsClient.localCredentials.getCredentials()];case 3:return h=v.sent(),[4,this.toBindIdentity({provider:a,provider_token:c,credentials:h})];case 4:return d=v.sent(),[3,11];case 5:return i.type!==I?[3,11]:(d=this.getParamsByVersion({provider:a},"AUTH_SIGN_IN_WITH_PROVIDER_URL"),[4,this.config.request(d.url,{method:"POST",body:{provider_token:c}})]);case 6:h=v.sent(),v.label=7;case 7:return v.trys.push([7,9,,10]),[4,this.getUserInfo({credentials:h})];case 8:return l=v.sent(),[3,10];case 9:return f=v.sent(),console.error("get user info error",f),[3,10];case 10:d={data:xt(xt({},t),{session:h,user:l}),error:null},v.label=11;case 11:e.delete("code"),e.delete("state"),e.delete("provider"),this.restoreUrlState(void 0===(null==i?void 0:i.search)?"?".concat(e.toString()):i.search,(null==i?void 0:i.hash)||location.hash);try{sessionStorage.removeItem(n)}catch(t){}return[2,d];case 12:return p=v.sent(),[2,{data:t,error:new kt(p)}];case 13:return[2]}})})},t.prototype.signInCustom=function(t){return Mt(this,void 0,Promise,function(){var e;return qt(this,function(r){switch(r.label){case 0:return[4,this.config.request(n.AUTH_SIGN_IN_CUSTOM,{method:"POST",body:t})];case 1:return e=r.sent(),[4,this.config.credentialsClient.setCredentials(e)];case 2:return r.sent(),[2,Promise.resolve(e)]}})})},t.prototype.signInWithWechat=function(t){return void 0===t&&(t={}),Mt(this,void 0,Promise,function(){var e;return qt(this,function(r){switch(r.label){case 0:return[4,this.config.request(n.AUTH_SIGN_IN_WITH_WECHAT_URL,{method:"POST",body:t})];case 1:return e=r.sent(),[4,this.config.credentialsClient.setCredentials(e)];case 2:return r.sent(),[2,Promise.resolve(e)]}})})},t.prototype.bindWithProvider=function(t,e){return Mt(this,void 0,Promise,function(){return qt(this,function(r){return[2,this.config.request(n.PROVIDER_BIND_URL,{method:"POST",body:t,withCredentials:!0,getCredentials:e?function(){return e}:void 0})]})})},t.prototype.getUserProfile=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.getUserInfo(t)]})})},t.prototype.getUserInfo=function(t){var e,r,n;return void 0===t&&(t={}),Mt(this,void 0,Promise,function(){var i,o,s,a,u;return qt(this,function(c){switch(c.label){case 0:return i=this.getParamsByVersion(t,"USER_ME_URL"),(null===(e=i.params)||void 0===e?void 0:e.query)&&(o=new Ct(i.params.query),i.url+="?".concat(o.toString())),[4,this.config.request(i.url,{method:"GET",withCredentials:!0,getCredentials:t.credentials?function(){return t.credentials}:void 0})];case 1:if((s=c.sent()).sub&&(s.uid=s.sub),null===(r=s.providers)||void 0===r?void 0:r.length)try{"undefined"!=typeof wx&&wx.getAccountInfoSync&&(a=null===(n=wx.getAccountInfoSync().miniProgram)||void 0===n?void 0:n.appId,(null==(u=s.providers.find(function(t){return t.id===a}))?void 0:u.provider_user_id)&&(s.open_id=u.provider_user_id))}catch(t){}return[2,s]}})})},t.prototype.getWedaUserInfo=function(){return Mt(this,void 0,Promise,function(){return qt(this,function(t){switch(t.label){case 0:return[4,this.config.request(n.WEDA_USER_URL,{method:"GET",withCredentials:!0})];case 1:return[2,t.sent()]}})})},t.prototype.deleteMe=function(e){return Mt(this,void 0,Promise,function(){var r,n;return qt(this,function(i){return r=this.getParamsByVersion(e,"USER_ME_URL"),n="".concat(r.url,"?").concat(t.parseParamsToSearch(r.params)),[2,this.config.request(n,{method:"DELETE",withCredentials:!0})]})})},t.prototype.hasLoginState=function(){return Mt(this,void 0,Promise,function(){return qt(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.config.credentialsClient.getAccessToken()];case 1:return t.sent(),[2,!0];case 2:return t.sent(),[2,!1];case 3:return[2]}})})},t.prototype.hasLoginStateSync=function(){return this.config.credentialsClient.getCredentialsSync()},t.prototype.getLoginState=function(){return Mt(this,void 0,Promise,function(){return qt(this,function(t){return[2,this.config.credentialsClient.getCredentialsAsync()]})})},t.prototype.transByProvider=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.config.request(n.USER_TRANS_BY_PROVIDER_URL,{method:"PATCH",body:t,withCredentials:!0})]})})},t.prototype.grantToken=function(t){return Mt(this,void 0,Promise,function(){var e;return qt(this,function(r){return e=this.getParamsByVersion(t,"AUTH_TOKEN_URL"),[2,this.config.request(e.url,{method:"POST",body:e.params})]})})},t.prototype.getProviders=function(){return Mt(this,void 0,Promise,function(){return qt(this,function(t){return[2,this.config.request(n.PROVIDER_LIST,{method:"GET",withCredentials:!0})]})})},t.prototype.unbindProvider=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.config.request("".concat(n.PROVIDER_UNBIND_URL,"/").concat(t.provider_id),{method:"DELETE",withCredentials:!0})]})})},t.prototype.checkPassword=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.config.request("".concat(n.CHECK_PWD_URL),{method:"POST",withCredentials:!0,body:t})]})})},t.prototype.editContact=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.config.request("".concat(n.BIND_CONTACT_URL),{method:"PATCH",withCredentials:!0,body:t})]})})},t.prototype.setPassword=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.config.request("".concat(n.AUTH_SET_PASSWORD),{method:"PATCH",withCredentials:!0,body:t})]})})},t.prototype.updatePasswordByOld=function(t){return Mt(this,void 0,Promise,function(){var e;return qt(this,function(r){switch(r.label){case 0:return[4,this.sudo({password:t.old_password})];case 1:return e=r.sent(),[2,this.setPassword({sudo_token:e.sudo_token,new_password:t.new_password})]}})})},t.prototype.sudo=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.config.request("".concat(n.SUDO_URL),{method:"POST",withCredentials:!0,body:t})]})})},t.prototype.sendVerificationCodeToCurrentUser=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return t.target="CUR_USER",[2,this.config.request(n.VERIFICATION_URL,{method:"POST",body:t,withCredentials:!0,withCaptcha:!0})]})})},t.prototype.changeBoundProvider=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.config.request("".concat(n.PROVIDER_LIST,"/").concat(t.provider_id,"/trans"),{method:"POST",body:{provider_trans_token:t.trans_token},withCredentials:!0})]})})},t.prototype.setUserProfile=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.config.request(n.USER_PRIFILE_URL,{method:"PATCH",body:t,withCredentials:!0})]})})},t.prototype.updateUserBasicInfo=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.config.request(n.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:t})]})})},t.prototype.queryUserProfile=function(t){return Mt(this,void 0,Promise,function(){var e;return qt(this,function(r){return e=new Ct(t),[2,this.config.request("".concat(n.USER_QUERY_URL,"?").concat(e.toString()),{method:"GET",withCredentials:!0})]})})},t.prototype.setCustomSignFunc=function(t){this.getCustomSignTicketFn=t},t.prototype.signInWithCustomTicket=function(){return Mt(this,void 0,Promise,function(){var t,e;return qt(this,function(r){switch(r.label){case 0:return(t=this.getCustomSignTicketFn)?[4,t()]:[2,Promise.reject({error:"failed_precondition",error_description:"please use setCustomSignFunc to set custom sign function"})];case 1:return e=r.sent(),[2,this.signInCustom({provider_id:"custom",ticket:e})]}})})},t.prototype.resetPassword=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.config.request(n.AUTH_RESET_PASSWORD,{method:"POST",body:t})]})})},t.prototype.authorize=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.config.request(n.AUTHORIZE_URL,{method:"POST",withCredentials:!0,body:t})]})})},t.prototype.authorizeDevice=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.config.request(n.AUTHORIZE_DEVICE_URL,{method:"POST",withCredentials:!0,body:t})]})})},t.prototype.deviceAuthorize=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.config.request(n.AUTH_GET_DEVICE_CODE,{method:"POST",body:t})]})})},t.prototype.authorizeInfo=function(e){return Mt(this,void 0,Promise,function(){var r,i,o;return qt(this,function(s){switch(s.label){case 0:return r="".concat(n.AUTHORIZE_INFO_URL,"?").concat(t.parseParamsToSearch(e)),i=!0,o=!1,[4,this.hasLoginState()];case 1:return s.sent()&&(o=!0,i=!1),[2,this.config.request(r,{method:"GET",withBasicAuth:i,withCredentials:o})]}})})},t.prototype.checkUsername=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.config.request(n.CHECK_USERNAME,{method:"GET",body:t,withCredentials:!0})]})})},t.prototype.checkIfUserExist=function(t){return Mt(this,void 0,Promise,function(){var e;return qt(this,function(r){return e=new Ct(t),[2,this.config.request("".concat(n.CHECK_IF_USER_EXIST,"?").concat(e.toString()),{method:"GET"})]})})},t.prototype.loginScope=function(){return Mt(this,void 0,Promise,function(){return qt(this,function(t){return[2,this.config.credentialsClient.getScope()]})})},t.prototype.loginGroups=function(){return Mt(this,void 0,Promise,function(){return qt(this,function(t){return[2,this.config.credentialsClient.getGroups()]})})},t.prototype.refreshTokenForce=function(t){return Mt(this,void 0,void 0,function(){var e;return qt(this,function(r){switch(r.label){case 0:return[4,this.config.credentialsClient.getCredentials()];case 1:return e=r.sent(),[4,this.config.credentialsClient.refreshToken(xt(xt({},e),{version:(null==t?void 0:t.version)||"v1"}))];case 2:return[2,r.sent()]}})})},t.prototype.getCredentials=function(){return Mt(this,void 0,void 0,function(){return qt(this,function(t){return[2,this.config.credentialsClient.getCredentials()]})})},t.prototype.getPublicKey=function(){return Mt(this,void 0,Promise,function(){return qt(this,function(t){return[2,this.config.request(i.AUTH_PUBLIC_KEY,{method:"POST",body:{}})]})})},t.prototype.getEncryptParams=function(t){return Mt(this,void 0,Promise,function(){var e,r,n,i,o,s;return qt(this,function(a){switch(a.label){case 0:return e=t.isEncrypt,delete t.isEncrypt,r=(0,A.I)(t),[4,Bt(e,this.config.adapter)];case 1:if(!(n=a.sent()))return[2,t];i="",o="",a.label=2;case 2:return a.trys.push([2,4,,5]),[4,this.getPublicKey()];case 3:if(s=a.sent(),i=s.public_key,o=s.public_key_thumbprint,!i||!o)throw s;return[3,5];case 4:throw a.sent();case 5:return[2,{params:n.getEncryptInfo({publicKey:i,payload:r}),public_key_thumbprint:o}]}})})},t.prototype.getProviderSubType=function(){return Mt(this,void 0,Promise,function(){return qt(this,function(t){return[2,this.config.request(n.GET_PROVIDER_TYPE,{method:"POST",body:{provider_id:"weda"}})]})})},t.prototype.verifyCaptchaData=function(t){var e=t.token,r=t.key;return Mt(this,void 0,void 0,function(){return qt(this,function(t){return[2,this.config.request(n.VERIFY_CAPTCHA_DATA_URL,{method:"POST",body:{token:e,key:r},withCredentials:!1})]})})},t.prototype.createCaptchaData=function(t){var e=t.state,r=t.redirect_uri,i=void 0===r?void 0:r;return Mt(this,void 0,void 0,function(){return qt(this,function(t){return[2,this.config.request(n.CAPTCHA_DATA_URL,{method:"POST",body:{state:e,redirect_uri:i},withCredentials:!1})]})})},t.prototype.getMiniProgramCode=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.config.request(n.GET_MINIPROGRAM_QRCODE,{method:"POST",body:t})]})})},t.prototype.getMiniProgramQrCodeStatus=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.config.request(n.GET_MINIPROGRAM_QRCODE_STATUS,{method:"POST",body:t})]})})},t.prototype.getUserBehaviorLog=function(t){return Mt(this,void 0,Promise,function(){var e,r;return qt(this,function(i){return e={LOGIN:"query[action]=USER_LOGIN",MODIFY:"ne_query[action]=USER_LOGIN"},r="".concat(n.GET_USER_BEHAVIOR_LOG,"?").concat(e[t.type],"&limit=").concat(t.limit).concat(t.page_token?"&page_token=".concat(t.page_token):""),[2,this.config.request(r,{method:"GET",withCredentials:!0})]})})},t.prototype.modifyPassword=function(t){return Mt(this,void 0,Promise,function(){var e,r,i,o,s,a;return qt(this,function(u){switch(u.label){case 0:return e="",r="",[4,Bt(!0,this.config.adapter)];case 1:if(!(i=u.sent()))throw new Error("do not support encrypt, a encrypt util required.");u.label=2;case 2:return u.trys.push([2,4,,5]),[4,this.getPublicKey()];case 3:if(o=u.sent(),e=o.public_key,r=o.public_key_thumbprint,!e||!r)throw o;return[3,5];case 4:throw u.sent();case 5:return s=t.password?i.getEncryptInfo({publicKey:e,payload:t.password}):"",a=i.getEncryptInfo({publicKey:e,payload:t.new_password}),[2,this.config.request(n.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:{user_id:t.user_id,encrypt_password:s,encrypt_new_password:a,public_key_thumbprint:r}})]}})})},t.prototype.modifyPasswordWithoutLogin=function(t){return Mt(this,void 0,Promise,function(){var e,r,n,o,s,a;return qt(this,function(u){switch(u.label){case 0:return e="",r="",[4,Bt(!0,this.config.adapter)];case 1:if(!(n=u.sent()))throw new Error("do not support encrypt, a encrypt util required.");u.label=2;case 2:return u.trys.push([2,4,,5]),[4,this.getPublicKey()];case 3:if(o=u.sent(),e=o.public_key,r=o.public_key_thumbprint,!e||!r)throw o;return[3,5];case 4:throw u.sent();case 5:return s=t.password?n.getEncryptInfo({publicKey:e,payload:t.password}):"",a=n.getEncryptInfo({publicKey:e,payload:t.new_password}),[2,this.config.request(i.AUTH_RESET_PASSWORD,{method:"POST",body:{username:t.username,password:s,new_password:a,public_key_thumbprint:r}})]}})})},t.prototype.restoreUrlState=function(t,e){if(void 0!==t)try{var r=new URL(window.location.href);r.search=t,r.hash=e||"",window.history.replaceState(null,"",r.toString()),window.location.replace(r.toString())}catch(t){}},t}(),Vt=function(){return Vt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},Vt.apply(this,arguments)},Wt=function(){function t(t){var e=t.apiOrigin,r=t.getApiOrigin,n=t.apiPath,i=void 0===n?l:n,o=t.clientId,s=t.env,a=t.storage,u=t.request,c=t.baseRequest,h=t.anonymousSignInFunc,d=t.wxCloud,f=t.adapter,p=t.onCredentialsError,v=t.headers,g=t.i18n,m=t.useWxCloud,y=t.eventBus,_=t.detectSessionInUrl,b=t.debug;if(this.detectSessionInUrl=null!=_&&_,this.oauth2client=new vt({apiOrigin:e,getApiOrigin:r,apiPath:i,clientId:o,env:s,storage:a,baseRequest:c||u,anonymousSignInFunc:h,wxCloud:d,onCredentialsError:p,headers:v||{},i18n:g,useWxCloud:m,eventBus:y,debug:b}),this.authApi=new jt(Vt(Vt({credentialsClient:this.oauth2client},t),{request:u?this.oauth2client.request.bind(this.oauth2client):void 0,adapter:f})),_)this.oauth2client.setGetInitialSession(this.authApi.getInitialSession.bind(this.authApi));else try{var I=new URL(window.location.href),w=I.searchParams.get("code"),E=I.searchParams.get("state"),S=JSON.parse(sessionStorage.getItem(E)||"null");w&&E&&(null==S?void 0:S.hash)&&(I.hash=S.hash,window.history.replaceState(null,"",I.toString()),window.location.replace(I.toString()))}catch(t){}}return t.prototype.initializeSession=function(t){this.detectSessionInUrl?(this.oauth2client.setOnInitialSessionObtained(t),this.oauth2client.initialize()):this.oauth2client.initialize(Promise.resolve({error:null}))},t}(),Ft=o(794),Ht=o(141),Gt=o(197);const Kt=(t=>{var e={};return o.d(e,t),e})({default:()=>r.default});var Yt,zt=o(182),Qt=function(){return Qt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},Qt.apply(this,arguments)},Jt=function(t,e,r,n){return new(r||(r=Promise))(function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(s,a)}u((n=n.apply(t,e||[])).next())})},Zt=function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=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(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},Xt=function(){function t(t){var e,r;try{this.localStorage=(null==t?void 0:t.localStorage)||((null===(r=null===(e=null==t?void 0:t.adapter)||void 0===e?void 0:e.root)||void 0===r?void 0:r.globalThis)||globalThis).localStorage}catch(e){this.localStorage=(null==t?void 0:t.localStorage)||{}}}return t.prototype.getItem=function(t){return Jt(this,void 0,Promise,function(){return Zt(this,function(e){return[2,this.localStorage.getItem(t)]})})},t.prototype.removeItem=function(t){return Jt(this,void 0,void 0,function(){return Zt(this,function(e){return this.localStorage.removeItem(t),[2]})})},t.prototype.setItem=function(t,e){return Jt(this,void 0,Promise,function(){return Zt(this,function(r){return this.localStorage.setItem(t,e),[2]})})},t.prototype.getItemSync=function(t){return this.localStorage.getItem(t)},t.prototype.setItemSync=function(t,e){this.localStorage.setItem(t,e)},t.prototype.removeItemSync=function(t){this.localStorage.removeItem(t)},t}(),$t=/^[^:]+:\/\/[^/]+(\/[^?#]+)/,te=function(t,e){var r,n,i,o,s=null===(r=null==e?void 0:e.headers)||void 0===r?void 0:r["x-request-id"];return t||(t={}),((null==t?void 0:t.code)||(null===(n=null==t?void 0:t.data)||void 0===n?void 0:n.error_code))&&(t={error:t.code||t.data.error,error_description:t.data.error_description||t.message||t.code||t.data.error_code,request_id:t.requestId,error_code:null===(i=t.data)||void 0===i?void 0:i.error_code}),(null==t?void 0:t.request_id)||(t.request_id=t.request_id||s),(null==t?void 0:t.error)?(t.error_uri=(o=null==e?void 0:e.url,$t.test(o)?RegExp.$1:o),t):(null==t?void 0:t.data)||{}},ee=function(t){return t.adapter&&"default"!==t.adapter.type?function(t,e){var r=Qt({},t);try{if(!(null==t?void 0:t.storage)&&(null==e?void 0:e.localStorage)&&(r.storage=new Xt({localStorage:e.localStorage,adapter:e})),!t.captchaOptions&&(null==e?void 0:e.captchaOptions)&&(r.captchaOptions=e.captchaOptions),!t.baseRequest&&!t.request&&(null==e?void 0:e.reqClass)){var n={timeout:1e4,restrictedMethods:["get","post","upload","download","request"],auth:t.auth},i=new e.reqClass(n);r.baseRequest=function(t,e){var r,n,o,s,a;return Jt(this,void 0,void 0,function(){var u,c,h,l;return Zt(this,function(d){switch(d.label){case 0:if(u={},c=(null===(r=e.method)||void 0===r?void 0:r.toLocaleLowerCase())||"post","function"!=typeof(h=null===(o=null===(n=null==i?void 0:i[c])||void 0===n?void 0:n.bind)||void 0===o?void 0:o.call(n,i)))throw new Error("invalid 【".concat(c,"】 request method"));d.label=1;case 1:return d.trys.push([1,3,,4]),(null===(s=e.headers)||void 0===s?void 0:s["content-type"])&&!(null===(a=e.headers)||void 0===a?void 0:a["content-type"].includes("application/json"))||["string","undefined"].includes(typeof e.body)||(e.data=e.data||e.body,e.body=JSON.stringify(e.body)),[4,h(Qt({url:t},e))];case 2:return u=d.sent(),u=te(u,Qt(Qt({},e),{url:t})),[3,4];case 3:throw l=d.sent(),u=Qt(Qt({},null==l?void 0:l.data),l);case 4:if(null==u?void 0:u.error)throw u;return[2,u]}})})}}}catch(t){console.error("user adapter generate fail:",t)}return r}(t,t.adapter):function(t,e){var r=Qt({},t),n={};if((null==e?void 0:e.captchaOptions)&&(r.captchaOptions=e.captchaOptions),!Kt.default.isMatch()||t.storage&&t.baseRequest)return r;try{var i=Kt.default.genAdapter({}),o=i.localStorage,s=i.reqClass;if(o&&(n.storage=new Xt({localStorage:o,adapter:e})),s){var a=new s({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});n.request=function(t){return function(e,r){return Jt(this,void 0,void 0,function(){return Zt(this,function(n){return[2,new Promise(function(n,i){var o=Object.assign({},r);o.body&&"string"!=typeof o.body&&(o.body=JSON.stringify(o.body));var s=wx.request({url:e,data:o.body,timeout:t._timeout,method:o.method||"GET",header:o.headers,success:function(t){(t=te(t,Qt(Qt({},r),{url:e}))).error&&i(t),n(t)},fail:function(t){i({error:"unreachable",error_description:t.message})},complete:function(e){if(e&&e.errMsg&&t._timeout&&-1!==t._restrictedMethods.indexOf("request")&&"request:fail timeout"===e.errMsg){console.warn(t._timeoutMsg);try{s.abort()}catch(t){}}}})})]})})}}(a)}return r.captchaOptions&&(n.baseRequest=n.request,n.request=void 0),Qt(Qt({},r),n)}catch(t){console.error("adapter generate fail:",t)}return r}(t,t.adapter)},re=function(){return re=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},re.apply(this,arguments)},ne=function(t,e,r,n){return new(r||(r=Promise))(function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(s,a)}u((n=n.apply(t,e||[])).next())})},ie=function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=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(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},oe=function(){function t(t){}return t.prototype.signInWithRedirect=function(){throw new Error("[v1 兼容] WeixinAuthProvider.signInWithRedirect() 在当前版本中无法实现。 建议使用 auth.signInWithOAuth({ provider: 'providerId' }) 替代。")},t.prototype.getRedirectResult=function(t){return ne(this,void 0,Promise,function(){return ie(this,function(t){throw new Error("[v1 兼容] WeixinAuthProvider.getRedirectResult() 在当前版本中无法实现。 建议使用 auth.verifyOAuth({ code, state, provider }) 替代。")})})},t.prototype.getLinkRedirectResult=function(t){return ne(this,void 0,Promise,function(){return ie(this,function(t){throw new Error("[v1 兼容] WeixinAuthProvider.getLinkRedirectResult() 在当前版本中无法实现。 建议使用 auth.linkIdentity({ provider: 'providerId' }) 替代。")})})},t}(),se=function(){function t(t){this.authInstance=t.authInstance}return t.prototype.signIn=function(t){return ne(this,void 0,Promise,function(){return ie(this,function(e){switch(e.label){case 0:return[4,this.authInstance.signInWithCustomTicket(function(){return Promise.resolve(t)})];case 1:return e.sent(),[2]}})})},t}(),ae=function(){function t(t){this.authInstance=t.authInstance}return t.prototype.signIn=function(){return ne(this,void 0,Promise,function(){return ie(this,function(t){switch(t.label){case 0:return[4,this.authInstance.signInAnonymously({})];case 1:return t.sent(),[2]}})})},t}(),ue=function(){function t(){}return t.prototype.weixinAuthProvider=function(t){return new oe({authInstance:this,appid:t.appid,scope:t.scope})},t.prototype.customAuthProvider=function(){return new se({authInstance:this})},t.prototype.anonymousAuthProvider=function(){return new ae({authInstance:this})},t.prototype.signUpWithEmailAndPassword=function(t,e){return ne(this,void 0,Promise,function(){return ie(this,function(r){switch(r.label){case 0:return"string"!=typeof t&&(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"email must be a string"),"string"!=typeof e&&(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signUp({email:t,password:e})];case 1:return[2,r.sent()]}})})},t.prototype.signInWithEmailAndPassword=function(t,e){return ne(this,void 0,Promise,function(){return ie(this,function(r){switch(r.label){case 0:return"string"!=typeof t&&(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"email must be a string"),"string"!=typeof e&&(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signIn({username:t,password:e})];case 1:return r.sent(),[2,this.createLoginState()]}})})},t.prototype.sendPasswordResetEmail=function(t){return ne(this,void 0,Promise,function(){return ie(this,function(e){switch(e.label){case 0:return"string"!=typeof t&&(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"email must be a string"),[4,this.getVerification({email:t})];case 1:return e.sent(),[2]}})})},t.prototype.signInWithUsernameAndPassword=function(t,e){return ne(this,void 0,Promise,function(){return ie(this,function(r){switch(r.label){case 0:return"string"!=typeof t&&(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"username must be a string"),"string"!=typeof e&&(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signIn({username:t,password:e})];case 1:return r.sent(),[2,this.createLoginState()]}})})},t.prototype.sendPhoneCode=function(t){return ne(this,void 0,Promise,function(){var e;return ie(this,function(r){switch(r.label){case 0:return"string"!=typeof t&&(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),e=this.formatPhone(t),[4,this.getVerification({phone_number:e})];case 1:return r.sent(),[2,!0]}})})},t.prototype.signUpWithPhoneCode=function(t,e,r){return ne(this,void 0,Promise,function(){var n;return ie(this,function(i){switch(i.label){case 0:return"string"!=typeof t&&(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),"string"!=typeof e&&(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"phoneCode must be a string"),n=this.formatPhone(t),[4,this.signUp(re({phone_number:n,verification_code:e},r?{password:r}:{}))];case 1:return i.sent(),[2,this.createLoginState()]}})})},t.prototype.signInWithPhoneCodeOrPassword=function(t){return ne(this,void 0,Promise,function(){var e,r,n,i;return ie(this,function(o){switch(o.label){case 0:return e=t.phoneNumber,r=t.phoneCode,n=t.password,"string"!=typeof e&&(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),i=this.formatPhone(e),n?[4,this.signIn({username:i,password:n})]:[3,2];case 1:return o.sent(),[3,5];case 2:return r?[4,this.signIn({username:i,verification_token:r})]:[3,4];case 3:return o.sent(),[3,5];case 4:(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"phoneCode or password must be provided"),o.label=5;case 5:return[2,this.createLoginState()]}})})},t.prototype.forceResetPwdByPhoneCode=function(t){return ne(this,void 0,Promise,function(){var e,r,n,i;return ie(this,function(o){switch(o.label){case 0:return e=t.phoneNumber,r=t.phoneCode,n=t.password,"string"!=typeof e&&(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),"string"!=typeof r&&(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"phoneCode must be a string"),"string"!=typeof n&&(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"password must be a string"),i=this.formatPhone(e),[4,this.resetPassword({phone_number:i,new_password:n,verification_token:r})];case 1:return o.sent(),[4,this.signIn({username:i,password:n})];case 2:return o.sent(),[2,this.createLoginState()]}})})},t.prototype.shouldRefreshAccessToken=function(t){throw new Error("[v1 兼容] shouldRefreshAccessToken() 在当前版本中无法实现。 建议使用 auth.onAuthStateChange(callback) 来监听 TOKEN_REFRESHED 事件替代。")},t.prototype.onLoginStateExpired=function(t){var e=this;this.onLoginStateChanged(function(r){(null==r?void 0:r.eventType)===f&&t.call(e)})},t.prototype.onAccessTokenRefreshed=function(t){var e=this;this.onAuthStateChange(function(r){r===g&&t.call(e)})},t.prototype.onAnonymousConverted=function(t){var e=this;this.onAuthStateChange(function(r){r===v&&t.call(e)})},t.prototype.onLoginTypeChanged=function(t){var e=this;this.onAuthStateChange(function(r){r!==v&&r!==p||t.call(e)})},t}(),ce=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),he=function(){return he=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},he.apply(this,arguments)},le=function(t,e,r,n){var i,o=arguments.length,s=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},de=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},fe=function(t,e,r,n){return new(r||(r=Promise))(function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(s,a)}u((n=n.apply(t,e||[])).next())})},pe=function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=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(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},ve=function(){return"undefined"!=typeof window&&"undefined"!=typeof document},ge=function(t){return function(e){t.fire(_,he(he({},e),{eventType:f}))}},me=function(){function e(t){var e=t.cache,r=t.oauthInstance;this.cache=e,this.oauthInstance=r,this.setUserInfo()}var r,n,i;return e.prototype.checkLocalInfo=function(){return fe(this,void 0,void 0,function(){return pe(this,function(t){return this.uid=this.getLocalUserInfo("uid"),this.gender=this.getLocalUserInfo("gender"),this.picture=this.getLocalUserInfo("picture"),this.email=this.getLocalUserInfo("email"),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),this.username=this.getLocalUserInfo("username"),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]})})},e.prototype.checkLocalInfoAsync=function(){return fe(this,void 0,void 0,function(){var t,e,r,n;return pe(this,function(i){switch(i.label){case 0:return t=this,[4,this.getLocalUserInfoAsync("uid")];case 1:return t.uid=i.sent(),e=this,[4,this.getLocalUserInfoAsync("gender")];case 2:return e.gender=i.sent(),this.picture=this.getLocalUserInfo("picture"),r=this,[4,this.getLocalUserInfoAsync("email")];case 3:return r.email=i.sent(),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),n=this,[4,this.getLocalUserInfoAsync("username")];case 4:return n.username=i.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(t){return fe(this,void 0,Promise,function(){var e;return pe(this,function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.setUserProfile(he({},t))];case 1:return e=r.sent(),this.setLocalUserInfo(e),[2]}})})},e.prototype.updateUserBasicInfo=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.updateUserBasicInfo(he({},t))];case 1:return e.sent(),[4,this.refresh()];case 2:return e.sent(),[2]}})})},e.prototype.updatePassword=function(t,e){return this.oauthInstance.authApi.updatePasswordByOld({old_password:e,new_password:t})},e.prototype.updateUsername=function(t){return"string"!=typeof t&&(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"username must be a string"),this.update({username:t})},e.prototype.refresh=function(t){return fe(this,void 0,Promise,function(){var e;return pe(this,function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.getUserInfo(t)];case 1:if("INVALID_ACCESS_TOKEN"===(e=r.sent()).code)throw this.setLocalUserInfo({}),e;return this.setLocalUserInfo(e),[2,e]}})})},e.prototype.getLocalUserInfo=function(t){var e=this.cache.keys.userInfoKey,r=this.cache.getStore(e);return t?r[t]:r||{}},e.prototype.setLocalUserInfo=function(t){var e=this.cache.keys.userInfoKey;this.cache.setStore(e,t),this.setUserInfo()},e.prototype.getLocalUserInfoAsync=function(t){return fe(this,void 0,Promise,function(){var e;return pe(this,function(r){switch(r.label){case 0:return e=this.cache.keys.userInfoKey,[4,this.cache.getStoreAsync(e)];case 1:return[2,r.sent()[t]]}})})},e.prototype.setUserInfo=function(){var t=this,e=this.cache.keys.userInfoKey,r=this.cache.getStore(e);["uid","email","name","gender","picture","email_verified","phone_number","birthdate","zoneinfo","locale","sub","created_from","providers","username","created_at","open_id"].forEach(function(e){t[e]=r[e]})},le([(0,Ht.catchErrorsDecorator)({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",["function"==typeof(r=t.UserProfile)?r:Object]),de("design:returntype","function"==typeof(n="undefined"!=typeof Promise&&Promise)?n:Object)],e.prototype,"update",null),le([(0,Ht.catchErrorsDecorator)({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",[String,String]),de("design:returntype",void 0)],e.prototype,"updatePassword",null),le([(0,Ht.catchErrorsDecorator)({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",[String]),de("design:returntype",void 0)],e.prototype,"updateUsername",null),le([(0,Ht.catchErrorsDecorator)({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",[Object]),de("design:returntype","function"==typeof(i="undefined"!=typeof Promise&&Promise)?i:Object)],e.prototype,"refresh",null),e}();(Yt=me).prototype.linkWithTicket=function(t){return ne(this,void 0,Promise,function(){return ie(this,function(t){throw new Error("[v1 兼容] User.linkWithTicket() 在当前版本中无法实现。 建议使用 auth.signInWithCustomTicket(() => Promise.resolve(ticket)) 替代。")})})},Yt.prototype.linkWithRedirect=function(t){throw new Error("[v1 兼容] User.linkWithRedirect() 在当前版本中无法实现。 建议使用 auth.linkIdentity({ provider: 'providerId' }) 替代。")},Yt.prototype.updateEmail=function(t,e){return ne(this,void 0,Promise,function(){return ie(this,function(e){switch(e.label){case 0:return"string"!=typeof t&&(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"newEmail must be a string"),[4,this.updateUserBasicInfo({email:t})];case 1:return e.sent(),[2]}})})},Yt.prototype.linkWithPhoneNumber=function(t,e){return ne(this,void 0,Promise,function(){return ie(this,function(t){throw new Error("[v1 兼容] User.linkWithPhoneNumber() 在当前版本中无法实现。 建议使用 auth.bindPhoneNumber({ phone_number, verification_token, sudo_token }) 替代。")})})},Yt.prototype.updatePhoneNumber=function(t,e){return ne(this,void 0,Promise,function(){return ie(this,function(t){throw new Error("[v1 兼容] User.updatePhoneNumber() 在当前版本中无法实现。 建议使用 auth.updateUser({ phone: newPhoneNumber }) 替代。")})})},Yt.prototype.unlink=function(t){return ne(this,void 0,Promise,function(){return ie(this,function(t){throw new Error("[v1 兼容] User.unlink() 在当前版本中无法实现。 建议使用 auth.unlinkIdentity({ provider: loginType }) 替代。")})})};var ye=function(){function t(t){var e=t.envId,r=t.cache,n=t.oauthInstance;e||(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"envId is not defined"),this.cache=r,this.oauthInstance=n,this.user=new me({cache:this.cache,oauthInstance:n})}return t.prototype.checkLocalState=function(){var t;this.oauthLoginState=null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.hasLoginStateSync(),this.user.checkLocalInfo()},t.prototype.checkLocalStateAsync=function(){var t;return fe(this,void 0,void 0,function(){return pe(this,function(e){switch(e.label){case 0:return[4,null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.getLoginState()];case 1:return e.sent(),[4,this.user.checkLocalInfoAsync()];case 2:return e.sent(),[2]}})})},t}(),_e=function(e){function r(t){var r=e.call(this)||this;return r.listeners=new Map,r.hasListenerSetUp=!1,r.config=t,r.oauthInstance=t.oauthInstance,r.cache=t.cache,r.init(),r.setAccessKey(),r}var n,i,o,s,a,u,c,h,l,d,g,y,S,A,P,O,T,R,C,U;return ce(r,e),r.prototype.signInAnonymously=function(t){return fe(this,void 0,Promise,function(){var e,r,n,i,o;return pe(this,function(s){switch(s.label){case 0:return s.trys.push([0,4,,5]),[4,this.oauthInstance.authApi.signInAnonymously(t)];case 1:return s.sent(),[4,this.createLoginState()];case 2:return e=s.sent(),[4,this.getSession()];case 3:return r=s.sent().data,n=(void 0===r?{}:r).session,[2,he(he({},e),{data:{user:n.user,session:n},error:null})];case 4:return i=s.sent(),(o=new kt(i,{method:"signInAnonymously"})).category===Ut.PROVIDER_NOT_ENABLED?(console.error(o.helpMessage),console.error("[CloudBase Auth] 提示:匿名登录需要在控制台开启「匿名登录」。\n 如果您需要使用用户名密码登录,请改用 auth.signInWithPassword({ username, password })。\n 不要在匿名登录失败后自动回退到密码登录,这两种方式的使用场景不同。")):(console.warn("[CloudBase Auth] signInAnonymously 失败 [".concat(o.category,"]: ").concat(o.message)),o.loginMethodHint&&console.warn(o.loginMethodHint)),[2,{data:{user:null,session:null},error:o}];case 5:return[2]}})})},r.prototype.signUp=function(t){return fe(this,void 0,Promise,function(){var e,r,n=this;return pe(this,function(i){switch(i.label){case 0:return t.phone_number||t.verification_code||t.verification_token||t.provider_token?(t.phone_number&&(t.phone_number=this.formatPhone(t.phone_number)),[4,this.oauthInstance.authApi.signUp(t)]):[3,2];case 1:return i.sent(),[2,this.createLoginState()];case 2:return i.trys.push([2,4,,5]),this.validateAtLeastOne(t,[["email"],["phone"]],"You must provide either an email or phone number"),[4,this.getVerification(t.email?{email:t.email}:{phone_number:this.formatPhone(t.phone)})];case 3:return e=i.sent(),[2,{data:{verifyOtp:function(r){var i=r.token,o=r.messageId,s=void 0===o?e.verification_id:o;return fe(n,void 0,Promise,function(){var r,n,o,a,u;return pe(this,function(c){switch(c.label){case 0:return c.trys.push([0,8,,9]),[4,this.verify({verification_id:s||e.verification_id,verification_code:String(i)})];case 1:return r=c.sent(),e.is_user?[4,this.signIn({username:t.email||this.formatPhone(t.phone),verification_token:r.verification_token})]:[3,3];case 2:return c.sent(),[3,6];case 3:return delete(n=JSON.parse(JSON.stringify(t))).email,delete n.phone,[4,this.oauthInstance.authApi.signUp(he(he(he({},n),t.email?{email:t.email}:{phone_number:this.formatPhone(t.phone)}),{verification_token:r.verification_token,verification_code:i}))];case 4:return c.sent(),[4,this.createLoginState()];case 5:c.sent(),c.label=6;case 6:return[4,this.getSession()];case 7:return o=c.sent().data,[2,{data:{user:(a=(void 0===o?{}:o).session).user,session:a},error:null}];case 8:return u=c.sent(),[2,{data:{user:null,session:null},error:new kt(u,{method:"signUp"})}];case 9:return[2]}})})}},error:null}];case 4:return r=i.sent(),[2,{data:{user:null,session:null},error:new kt(r,{method:"signUp"})}];case 5:return[2]}})})},r.prototype.signOut=function(t){var e,r;return fe(this,void 0,Promise,function(){var n,i,o;return pe(this,function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),n=this.cache.keys.userInfoKey,[4,this.oauthInstance.authApi.signOut(t)];case 1:return i=s.sent(),[4,this.cache.removeStoreAsync(n)];case 2:return s.sent(),this.setAccessKey(),null===(e=this.config.eventBus)||void 0===e||e.fire(_,{eventType:"sign_out"}),null===(r=this.config.eventBus)||void 0===r||r.fire(b,{event:p}),[2,he(he({},i),{data:{},error:null})];case 3:return o=s.sent(),[2,{data:{},error:new kt(o,{method:"signOut"})}];case 4:return[2]}})})},r.prototype.onAuthStateChange=function(t){var e=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(t),{data:{subscription:{id:r,callback:t,unsubscribe:function(){var n=e.listeners.get(r);n&&(n.delete(t),0===n.size&&e.listeners.delete(r))}}}}},r.prototype.signInWithPassword=function(t){return fe(this,void 0,Promise,function(){var e,r,n,i;return pe(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),this.validateAtLeastOne(t,[["username"],["email"],["phone"]],"You must provide either username, email, or phone"),this.validateParams(t,{password:{required:!0,message:"Password is required"}}),[4,this.signIn(he({username:t.username||t.email||this.formatPhone(t.phone),password:t.password},t.is_encrypt?{isEncrypt:!0,version:"v2"}:{}))];case 1:return o.sent(),[4,this.getSession()];case 2:return e=o.sent().data,[2,{data:{user:(r=(void 0===e?{}:e).session).user,session:r},error:null}];case 3:return n=o.sent(),(i=new kt(n,{method:"signInWithPassword"})).category===Ut.PROVIDER_NOT_ENABLED?console.error(i.helpMessage):i.category===Ut.INVALID_CREDENTIALS||i.category===Ut.USER_NOT_FOUND?console.warn(i.helpMessage):console.warn("[CloudBase Auth] signInWithPassword 失败 [".concat(i.category,"]: ").concat(i.message)),i.loginMethodHint&&console.info(i.loginMethodHint),[2,{data:{user:null,session:null},error:i}];case 4:return[2]}})})},r.prototype.signInWithIdToken=function(t){return fe(this,void 0,Promise,function(){var e,r,n;return pe(this,function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),this.validateParams(t,{token:{required:!0,message:"Token is required"}}),[4,this.signInWithProvider({provider_token:t.token})];case 1:return i.sent(),[4,this.getSession()];case 2:return e=i.sent().data,[2,{data:{user:(r=(void 0===e?{}:e).session).user,session:r},error:null}];case 3:return n=i.sent(),[2,{data:{user:null,session:null},error:new kt(n,{method:"signInWithIdToken"})}];case 4:return[2]}})})},r.prototype.signInWithOtp=function(t){var e,r,n,i;return fe(this,void 0,Promise,function(){var o,s,a=this;return pe(this,function(u){switch(u.label){case 0:if(!(null===(e=t.options)||void 0===e?void 0:e.emailRedirectTo)&&(void 0===(null===(r=t.options)||void 0===r?void 0:r.shouldCreateUser)||(null===(n=t.options)||void 0===n?void 0:n.shouldCreateUser)))return[2,this.signUp({email:t.email,phone:t.phone})];u.label=1;case 1:return u.trys.push([1,3,,4]),this.validateAtLeastOne(t,[["email"],["phone"]],"You must provide either an email or phone number"),[4,this.getVerification(he(he({email_redirect_to:null===(i=t.options)||void 0===i?void 0:i.emailRedirectTo},t.email?{email:t.email}:{phone_number:this.formatPhone(t.phone)}),{target:"USER"}))];case 2:return o=u.sent(),[2,{data:{user:null,session:null,verifyOtp:function(e){var r=e.token,n=e.messageId,i=void 0===n?o.verification_id:n;return fe(a,void 0,Promise,function(){return pe(this,function(e){return[2,this.verifyOtp({email:t.email,phone:t.phone,token:String(r),messageId:i})]})})}},error:null}];case 3:return s=u.sent(),[2,{data:{user:null,session:null},error:new kt(s,{method:"signInWithOtp"})}];case 4:return[2]}})})},r.prototype.verifyOAuth=function(t){return fe(this,void 0,Promise,function(){var e,r,n,i,o,s,a,u,c;return pe(this,function(h){switch(h.label){case 0:e={},h.label=1;case 1:return h.trys.push([1,7,,8]),r=(null==t?void 0:t.code)||B("code"),n=(null==t?void 0:t.state)||B("state"),r?n?(i=function(t){try{return JSON.parse(sessionStorage.getItem(t))}catch(t){return console.error("Failed to get browser session:",t),null}}(n),e.type=null==i?void 0:i.type,(o=(null==t?void 0:t.provider)||(null==i?void 0:i.provider)||B("provider"))?[4,this.grantProviderToken({provider_id:o,provider_redirect_uri:location.origin+location.pathname,provider_code:r})]:[2,{data:he(he({},e),{user:null,session:null,redirectUrl:null}),error:new kt({message:"Provider is required"})}]):[2,{data:{user:null,session:null,redirectUrl:null},error:new kt({message:"State is required"})}]:[2,{data:{user:null,session:null,redirectUrl:null},error:new kt({message:"Code is required"})}];case 2:return s=h.sent().provider_token,a=void 0,i.type!==w?[3,4]:[4,this.oauthInstance.authApi.toBindIdentity({provider_token:s,provider:o,fireEvent:!0})];case 3:return a=h.sent(),[3,6];case 4:return[4,this.signInWithIdToken({token:s})];case 5:(a=h.sent()).data=he(he({},e),a.data),h.label=6;case 6:return(u=new URLSearchParams(null===location||void 0===location?void 0:location.search)).delete("code"),u.delete("state"),a.data.redirectUrl=function(t,e){if(void 0!==t){var r=new URL(window.location.href);return r.search=t,r.hash=e||r.hash,window.history.replaceState({},"",r.href),r.href}}(void 0===(null==i?void 0:i.search)?"?".concat(u.toString()):null==i?void 0:i.search,(null==i?void 0:i.hash)||location.hash),function(t){try{return sessionStorage.removeItem(t),!0}catch(t){return console.error("Failed to remove browser session:",t),null}}(n),[2,a];case 7:return c=h.sent(),[2,{data:he(he({},e),{user:null,session:null,redirectUrl:null}),error:new kt(c,{method:"verifyOAuth"})}];case 8:return[2]}})})},r.prototype.signInWithOAuth=function(t){var e,r,n,i,o;return fe(this,void 0,Promise,function(){var s,a,u,c,h,l,d,f,p;return pe(this,function(v){switch(v.label){case 0:return v.trys.push([0,2,,3]),this.validateParams(t,{provider:{required:!0,message:"Provider is required"}}),s=(null===(e=t.options)||void 0===e?void 0:e.redirectTo)||location.href,a=new URL(s),u=a.origin+a.pathname,c=(null===(r=t.options)||void 0===r?void 0:r.state)||"prd-".concat(t.provider,"-").concat(Math.random().toString(36).slice(2)),[4,this.genProviderRedirectUri({provider_id:t.provider,provider_redirect_uri:u,state:c})];case 1:return h=v.sent().uri,l=decodeURIComponent(h),d=l,(null===(n=t.options)||void 0===n?void 0:n.queryParams)&&(f=new URL(l),Object.entries(t.options.queryParams).forEach(function(t){var e=t[0],r=t[1];f.searchParams.set(e,r)}),d=f.toString()),function(t,e){try{sessionStorage.setItem(t,JSON.stringify(e))}catch(t){console.error("Failed to save to browser session:",t)}}(c,{provider:t.provider,search:a.search,hash:a.hash,type:(null===(i=t.options)||void 0===i?void 0:i.type)||I}),ve()&&!(null===(o=t.options)||void 0===o?void 0:o.skipBrowserRedirect)&&window.location.assign(d),[2,{data:{url:d,provider:t.provider},error:null}];case 2:return p=v.sent(),[2,{data:{url:null,provider:null},error:new kt(p,{method:"signInWithOAuth"})}];case 3:return[2]}})})},r.prototype.getClaims=function(){return fe(this,void 0,Promise,function(){var t;return pe(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.getAccessToken()];case 1:return[2,{data:function(t){if("string"!=typeof t)throw new Error("Invalid token specified");try{var e=t.split(".").map(function(t,e){return 2===e?t:JSON.parse(function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw new Error("Illegal base64url string!")}try{return function(t){return decodeURIComponent(N(t).replace(/(.)/g,function(t){var e=t.charCodeAt(0).toString(16).toUpperCase();return e.length<2&&(e="0".concat(e)),"%".concat(e)}))}(e)}catch(t){return N(e)}}(t))});return{claims:e[1],header:e[0],signature:e[2]}}catch(t){throw new Error("Invalid token specified: ".concat(t)?t.message:0)}}(e.sent().accessToken),error:null}];case 2:return t=e.sent(),[2,{data:{claims:null,header:null,signature:null},error:new kt(t,{method:"getClaims"})}];case 3:return[2]}})})},r.prototype.resetPasswordForEmail=function(t,e){return fe(this,void 0,Promise,function(){var r,n,i,o,s,a,u=this;return pe(this,function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),this.validateParams({emailOrPhone:t},{emailOrPhone:{required:!0,message:"Email or phone is required"}}),r=(e||{}).redirectTo,n=t.includes("@"),i=void 0,n?i={email:t}:(o=this.formatPhone(t),i={phone_number:o}),[4,this.getVerification(he(he({},i),{target:"USER"}))];case 1:return s=c.sent(),[2,{data:{updateUser:function(e){return fe(u,void 0,Promise,function(){var i,o,a,u;return pe(this,function(c){switch(c.label){case 0:this.validateParams(e,{nonce:{required:!0,message:"Nonce is required"},password:{required:!0,message:"Password is required"}}),c.label=1;case 1:return c.trys.push([1,5,,6]),[4,this.verify({verification_id:s.verification_id,verification_code:e.nonce})];case 2:return i=c.sent(),[4,this.oauthInstance.authApi.resetPassword({email:n?t:void 0,phone_number:n?void 0:t,new_password:e.password,verification_token:i.verification_token})];case 3:return c.sent(),null===(u=this.config.eventBus)||void 0===u||u.fire(b,{event:"PASSWORD_RECOVERY"}),[4,this.signInWithPassword({email:n?t:void 0,phone:n?void 0:t,password:e.password})];case 4:return o=c.sent(),r&&ve()&&window.location.assign(r),[2,o];case 5:return a=c.sent(),[2,{data:{user:null,session:null},error:new kt(a,{method:"resetPasswordForEmail"})}];case 6:return[2]}})})}},error:null}];case 2:return a=c.sent(),[2,{data:{updateUser:null},error:new kt(a,{method:"resetPasswordForEmail"})}];case 3:return[2]}})})},r.prototype.resetPasswordForOld=function(t){return fe(this,void 0,void 0,function(){var e,r,n;return pe(this,function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,this.oauthInstance.authApi.updatePasswordByOld({old_password:t.old_password,new_password:t.new_password})];case 1:return i.sent(),[4,this.getSession()];case 2:return e=i.sent().data,[2,{data:{user:(r=(void 0===e?{}:e).session).user,session:r},error:null}];case 3:return n=i.sent(),[2,{data:{user:null,session:null},error:new kt(n,{method:"resetPasswordForOld"})}];case 4:return[2]}})})},r.prototype.verifyOtp=function(t){return fe(this,void 0,Promise,function(){var e,r,n,i,o;return pe(this,function(s){switch(s.label){case 0:return s.trys.push([0,6,,7]),e=t.type,r=String(t.token),this.validateParams(t,{token:{required:!0,message:"Token is required"},messageId:{required:!0,message:"messageId is required"}}),["phone_change","email_change"].includes(e)?[4,this.verify({verification_id:t.messageId,verification_code:r})]:[3,2];case 1:return s.sent(),[3,4];case 2:return[4,this.signInWithUsername({verificationInfo:{verification_id:t.messageId,is_user:!0},verificationCode:r,username:t.email||this.formatPhone(t.phone)||"",loginType:t.email?"email":"phone"})];case 3:s.sent(),s.label=4;case 4:return[4,this.getSession()];case 5:return n=s.sent().data,[2,{data:{user:(i=(void 0===n?{}:n).session).user,session:i},error:null}];case 6:return o=s.sent(),[2,{data:{user:null,session:null},error:new kt(o,{method:"verifyOtp"})}];case 7:return[2]}})})},r.prototype.getSession=function(){return fe(this,void 0,Promise,function(){var t,e,r,n;return pe(this,function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,this.oauthInstance.oauth2client.getCredentials()];case 1:return(t=i.sent())&&"accessKey"!==t.scope?[4,this.getUser(!1)]:[2,{data:{session:null,user:null},error:null}];case 2:return e=i.sent().data,r=(void 0===e?{}:e).user,[2,{data:{session:he(he({},t),{user:r}),user:r},error:null}];case 3:return n=i.sent(),[2,{data:{session:null,user:null},error:new kt(n,{method:"getSession"})}];case 4:return[2]}})})},r.prototype.refreshSession=function(t){return fe(this,void 0,Promise,function(){var e,r,n,i,o;return pe(this,function(s){switch(s.label){case 0:return s.trys.push([0,4,,5]),[4,this.oauthInstance.oauth2client.localCredentials.getCredentials()];case 1:return(e=s.sent()).refresh_token=t||e.refresh_token,[4,this.oauthInstance.oauth2client.refreshToken(e)];case 2:return r=s.sent(),[4,this.getUser(!1)];case 3:return n=s.sent().data,[2,{data:{user:i=(void 0===n?{}:n).user,session:he(he({},r),{user:i})},error:null}];case 4:return o=s.sent(),[2,{data:{user:null,session:null},error:new kt(o,{method:"refreshSession"})}];case 5:return[2]}})})},r.prototype.getUser=function(t){return void 0===t&&(t=!0),fe(this,void 0,Promise,function(){var e,r,n;return pe(this,function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,this.oauthInstance.oauth2client.getCredentials()];case 1:return(e=i.sent())&&"accessKey"!==e.scope?(r=this.convertToUser,[4,this.getCurrentUser(t)]):[2,{data:{user:null},error:null}];case 2:return[2,{data:{user:r.apply(this,[i.sent()])},error:null}];case 3:return n=i.sent(),[2,{data:{user:null},error:new kt(n,{method:"getUser"})}];case 4:return[2]}})})},r.prototype.refreshUser=function(){return fe(this,void 0,Promise,function(){var t,e,r;return pe(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 t=n.sent().data,[2,{data:{user:(e=(void 0===t?{}:t).session).user,session:e},error:null}];case 3:return r=n.sent(),[2,{data:{user:null,session:null},error:new kt(r,{method:"refreshUser"})}];case 4:return[2]}})})},r.prototype.updateUser=function(t){var e;return fe(this,void 0,Promise,function(){var r,n,i,o,s,a,u,c,h,l,d,f,p=this;return pe(this,function(v){switch(v.label){case 0:if(v.trys.push([0,8,,9]),!Object.keys(t).some(function(e){return void 0!==t[e]&&null!==t[e]&&""!==t[e]}))throw new kt({message:"At least one field must be provided for update"});return r=t.email,n=t.phone,i=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]])}return r}(t,["email","phone"]),s=void 0!==n,a={},(o=void 0!==r)||s?(u=void 0,o?(u={email:t.email},c="email_change"):(h=this.formatPhone(t.phone),u={phone_number:h},c="phone_change"),[4,this.getVerification(he({},u))]):[3,4];case 1:return l=v.sent(),Object.keys(i).length>0?[4,this.updateUserBasicInfo(i)]:[3,3];case 2:v.sent(),v.label=3;case 3:return a={messageId:l.verification_id,verifyOtp:function(e){return fe(p,void 0,Promise,function(){var r,n,i,s;return pe(this,function(a){switch(a.label){case 0:return a.trys.push([0,11,,12]),e.email&&t.email===e.email?[4,this.verifyOtp({type:"email_change",email:t.email,token:e.token,messageId:l.verification_id})]:[3,3];case 1:return(r=a.sent()).error?[2,r]:[4,this.updateUserBasicInfo({email:t.email})];case 2:return a.sent(),[3,9];case 3:return e.phone&&t.phone===e.phone?[4,this.verifyOtp({type:"phone_change",phone:t.phone,token:e.token,messageId:l.verification_id})]:[3,6];case 4:return(r=a.sent()).error?[2,r]:[4,this.updateUserBasicInfo({phone:this.formatPhone(t.phone)})];case 5:return a.sent(),[3,9];case 6:return[4,this.verifyOtp({type:c,email:o?t.email:void 0,phone:o?void 0:t.phone,token:e.token,messageId:l.verification_id})];case 7:return(r=a.sent()).error?[2,r]:[4,this.updateUserBasicInfo(t)];case 8:a.sent(),a.label=9;case 9:return[4,this.getUser(!1)];case 10:return n=a.sent().data.user,null===(s=this.config.eventBus)||void 0===s||s.fire(b,{event:m}),[2,{data:{user:n},error:null}];case 11:return i=a.sent(),[2,{data:{user:null},error:new kt(i,{method:"updateUser"})}];case 12:return[2]}})})}},[3,6];case 4:return[4,this.updateUserBasicInfo(t)];case 5:v.sent(),v.label=6;case 6:return[4,this.getUser(!1)];case 7:return d=v.sent().data.user,Object.keys(i).length>0&&(null===(e=this.config.eventBus)||void 0===e||e.fire(b,{event:m})),[2,{data:he({user:d},a),error:null}];case 8:return f=v.sent(),[2,{data:{user:null},error:new kt(f,{method:"updateUser"})}];case 9:return[2]}})})},r.prototype.getUserIdentities=function(){var t;return fe(this,void 0,Promise,function(){var e,r;return pe(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.oauthInstance.authApi.getProviders()];case 1:return e=n.sent(),[2,{data:{identities:null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.filter(function(t){return!!t.bind})},error:null}];case 2:return r=n.sent(),[2,{data:{identities:null},error:new kt(r,{method:"getUserIdentities"})}];case 3:return[2]}})})},r.prototype.linkIdentity=function(t){return fe(this,void 0,Promise,function(){var e;return pe(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.validateParams(t,{provider:{required:!0,message:"Provider is required"}}),[4,this.signInWithOAuth({provider:t.provider,options:{type:w}})];case 1:return r.sent(),[2,{data:{provider:t.provider},error:null}];case 2:return e=r.sent(),[2,{data:{provider:null},error:new kt(e,{method:"linkIdentity"})}];case 3:return[2]}})})},r.prototype.unlinkIdentity=function(t){return fe(this,void 0,Promise,function(){var e;return pe(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.validateParams(t,{provider:{required:!0,message:"Provider is required"}}),[4,this.oauthInstance.authApi.unbindProvider({provider_id:t.provider})];case 1:return r.sent(),[2,{data:{},error:null}];case 2:return e=r.sent(),[2,{data:{},error:new kt(e,{method:"unlinkIdentity"})}];case 3:return[2]}})})},r.prototype.reauthenticate=function(){return fe(this,void 0,Promise,function(){var t,e,r,n,i=this;return pe(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,this.getUser(!1)];case 1:return t=o.sent().data.user,this.validateAtLeastOne(t,[["email","phone"]],"You must provide either an email or phone number"),e=t.email?{email:t.email}:{phone_number:this.formatPhone(t.phone)},[4,this.getVerification(e)];case 2:return r=o.sent(),[2,{data:{updateUser:function(t){return fe(i,void 0,Promise,function(){var n,i,o,s,a;return pe(this,function(u){switch(u.label){case 0:this.validateParams(t,{nonce:{required:!0,message:"Nonce is required"}}),u.label=1;case 1:return u.trys.push([1,9,,10]),t.password?[4,this.verify({verification_id:r.verification_id,verification_code:t.nonce})]:[3,5];case 2:return n=u.sent(),[4,this.oauthInstance.authApi.sudo({verification_token:n.verification_token})];case 3:return i=u.sent(),[4,this.oauthInstance.authApi.setPassword({new_password:t.password,sudo_token:i.sudo_token})];case 4:return u.sent(),[3,7];case 5:return[4,this.signInWithUsername(he(he({verificationInfo:r,verificationCode:t.nonce},e),{loginType:e.email?"email":"phone"}))];case 6:u.sent(),u.label=7;case 7:return[4,this.getSession()];case 8:return o=u.sent().data,[2,{data:{user:(s=(void 0===o?{}:o).session).user,session:s},error:null}];case 9:return a=u.sent(),[2,{data:{user:null,session:null},error:new kt(a,{method:"reauthenticate"})}];case 10:return[2]}})})}},error:null}];case 3:return n=o.sent(),[2,{data:{updateUser:null},error:new kt(n,{method:"reauthenticate"})}];case 4:return[2]}})})},r.prototype.resend=function(t){return fe(this,void 0,Promise,function(){var e,r,n;return pe(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),this.validateAtLeastOne(t,[["email"],["phone"]],"You must provide either an email or phone number"),e="signup"===t.type?"ANY":"USER",r={target:e},"email"in t&&(r.email=t.email),"phone"in t&&(r.phone_number=this.formatPhone(t.phone)),[4,this.oauthInstance.authApi.getVerification(r)];case 1:return[2,{data:{messageId:i.sent().verification_id},error:null}];case 2:return n=i.sent(),[2,{data:{messageId:null},error:new kt(n,{method:"resend"})}];case 3:return[2]}})})},r.prototype.setSession=function(t){var e;return fe(this,void 0,Promise,function(){var r,n,i;return pe(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),this.validateParams(t,{access_token:{required:!0,message:"Access token is required"},refresh_token:{required:!0,message:"Refresh token is required"}}),[4,this.oauthInstance.oauth2client.refreshToken(t,{throwError:!0})];case 1:return o.sent(),[4,this.getSession()];case 2:return r=o.sent().data,n=(void 0===r?{}:r).session,null===(e=this.config.eventBus)||void 0===e||e.fire(b,{event:v}),[2,{data:{user:n.user,session:n},error:null}];case 3:return i=o.sent(),[2,{data:{user:null,session:null},error:new kt(i,{method:"setSession"})}];case 4:return[2]}})})},r.prototype.exchangeCodeForSession=function(){return fe(this,void 0,void 0,function(){return pe(this,function(t){return[2]})})},r.prototype.deleteUser=function(t){return fe(this,void 0,Promise,function(){var e,r;return pe(this,function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),this.validateParams(t,{password:{required:!0,message:"Password is required"}}),[4,this.oauthInstance.authApi.sudo(t)];case 1:return e=n.sent().sudo_token,[4,this.oauthInstance.authApi.deleteMe({sudo_token:e})];case 2:return n.sent(),[2,{data:{},error:null}];case 3:return r=n.sent(),[2,{data:{},error:new kt(r,{method:"deleteUser"})}];case 4:return[2]}})})},r.prototype.toDefaultLoginPage=function(t){return void 0===t&&(t={}),fe(this,void 0,Promise,function(){var e,r,n,i,o;return pe(this,function(s){try{return e=t.config_version||"env",r=Object.keys(t.query||{}).map(function(e){return"".concat(e,"=").concat(t.query[e])}).join("&"),Kt.default.isMatch()?wx.navigateTo({url:"/packages/$wd_system/pages/login/index".concat(r?"?".concat(r):"")}):(n=t.redirect_uri||window.location.href,i=new URL(n),o="".concat(i.origin,"/__auth/?app_id=").concat(t.app_id||"","&env_id=").concat(this.config.env,"&client_id=").concat(this.config.clientId||this.config.env,"&config_version=").concat(e,"&redirect_uri=").concat(encodeURIComponent(n)).concat(r?"&".concat(r):""),window.location.href=o),[2,{data:{},error:null}]}catch(t){return[2,{data:{},error:new kt(t,{method:"toDefaultLoginPage"})}]}return[2]})})},r.prototype.signInWithCustomTicket=function(t){return fe(this,void 0,Promise,function(){var e,r,n,i;return pe(this,function(o){switch(o.label){case 0:t&&this.setCustomSignFunc(t),o.label=1;case 1:return o.trys.push([1,5,,6]),[4,this.oauthInstance.authApi.signInWithCustomTicket()];case 2:return o.sent(),[4,this.createLoginState()];case 3:return e=o.sent(),[4,this.getSession()];case 4:return r=o.sent().data,n=(void 0===r?{}:r).session,[2,he(he({},e),{data:{user:n.user,session:n},error:null})];case 5:return i=o.sent(),[2,{data:{user:null,session:null},error:new kt(i,{method:"signInWithCustomTicket"})}];case 6:return[2]}})})},r.prototype.signInWithOpenId=function(t){var e=(void 0===t?{}:t).useWxCloud,r=void 0===e||e;return fe(this,void 0,Promise,function(){var t,e,n,i,o,s,a=this;return pe(this,function(u){switch(u.label){case 0:if(!Kt.default.isMatch())throw Error("wx api undefined");t=wx.getAccountInfoSync().miniProgram,e=function(e){return fe(a,void 0,void 0,function(){var n,i;return pe(this,function(o){switch(o.label){case 0:n=void 0,i=void 0,o.label=1;case 1:return o.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==t?void 0:t.appId,provider_code:e,provider_params:{provider_code_type:"open_id",appid:null==t?void 0:t.appId}},r)];case 2:if((null==(n=o.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==(i=o.sent())?void 0:i.error_code)throw i;return[3,5];case 4:throw o.sent();case 5:return[4,this.oauthInstance.oauth2client.setCredentials(i)];case 6:return o.sent(),[2]}})})},u.label=1;case 1:return u.trys.push([1,5,,6]),[4,new Promise(function(t,r){wx.login({success:function(n){return fe(a,void 0,void 0,function(){var i;return pe(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,e(n.code)];case 1:return o.sent(),t(!0),[3,3];case 2:return i=o.sent(),r(i),[3,3];case 3:return[2]}})})},fail:function(t){var e=new Error(null==t?void 0:t.errMsg);e.code=null==t?void 0:t.errno,r(e)}})})];case 2:return u.sent(),[4,this.createLoginState()];case 3:return n=u.sent(),[4,this.getSession()];case 4:return i=u.sent().data,o=(void 0===i?{}:i).session,[2,he(he({},n),{data:{user:o.user,session:o},error:null})];case 5:return s=u.sent(),[2,{data:{user:null,session:null},error:new kt(s,{method:"signInWithOpenId"})}];case 6:return[2]}})})},r.prototype.signInWithPhoneAuth=function(t){var e=t.phoneCode,r=void 0===e?"":e,n=t.useWxCloud,i=void 0!==n&&n;return fe(this,void 0,Promise,function(){var t,e,n,o,s,a,u,c,h;return pe(this,function(l){switch(l.label){case 0:return Kt.default.isMatch()?(t=wx.getAccountInfoSync().miniProgram,e={provider_params:{provider_code_type:"phone",code:r,appid:t.appId},provider_id:t.appId},[4,wx.login()]):[2,{data:{user:null,session:null},error:new kt({message:"wx api undefined"})}];case 1:n=l.sent().code,e.provider_code=n,l.label=2;case 2:return l.trys.push([2,5,,6]),[4,this.oauthInstance.authApi.grantProviderToken(e,i)];case 3:if((o=l.sent()).error_code)throw o;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:o.provider_token},i)];case 4:if(null==(s=l.sent())?void 0:s.error_code)throw s;return[3,6];case 5:return a=l.sent(),[2,{data:{user:null,session:null},error:new kt(a,{method:"signInWithPhoneAuth"})}];case 6:return[4,this.createLoginState()];case 7:return u=l.sent(),[4,this.getSession()];case 8:return c=l.sent().data,h=(void 0===c?{}:c).session,[2,he(he({},u),{data:{user:h.user,session:h},error:null})]}})})},r.prototype.bindPhoneNumber=function(t){return fe(this,void 0,void 0,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.editContact(t)]})})},r.prototype.unbindProvider=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.unbindProvider(t)]})})},r.prototype.bindEmail=function(t){return this.oauthInstance.authApi.editContact(t)},r.prototype.verify=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.verify(t)]})})},r.prototype.getVerification=function(t,e){return fe(this,void 0,Promise,function(){return pe(this,function(r){return t.phone_number&&(t.phone_number=this.formatPhone(t.phone_number)),[2,this.oauthInstance.authApi.getVerification(t,e)]})})},Object.defineProperty(r.prototype,"currentUser",{get:function(){if("async"!==this.cache.mode){var t=this.hasLoginState();return t&&t.user||null}(0,mt.printWarn)(Ft.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrentUser instead")},enumerable:!1,configurable:!0}),r.prototype.getCurrentUser=function(t){return void 0===t&&(t=!0),fe(this,void 0,Promise,function(){var e,r,n;return pe(this,function(i){switch(i.label){case 0:return i.trys.push([0,4,,5]),t?[4,this.getLoginState()]:[3,3];case 1:return(e=i.sent())?[4,e.user.refresh()]:[3,3];case 2:i.sent(),i.label=3;case 3:return[3,5];case 4:return i.sent(),[3,5];case 5:return[4,this.getLoginState()];case 6:return(r=i.sent())?(n=r.user.getLocalUserInfo(),[4,r.user.checkLocalInfoAsync()]):[3,8];case 7:return i.sent(),[2,he(he({},r.user),n)];case 8:return[2,null]}})})},r.prototype.signInAnonymouslyInWx=function(t){var e=(void 0===t?{}:t).useWxCloud;return fe(this,void 0,Promise,function(){var t,r,n=this;return pe(this,function(i){switch(i.label){case 0:if(!Kt.default.isMatch())throw Error("wx api undefined");return t=wx.getAccountInfoSync().miniProgram,r=function(r){return fe(n,void 0,void 0,function(){var n,i;return pe(this,function(o){switch(o.label){case 0:n=void 0,i=void 0,o.label=1;case 1:return o.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==t?void 0:t.appId,provider_code:r,provider_params:{provider_code_type:"open_id",appid:null==t?void 0:t.appId}},e)];case 2:if((null==(n=o.sent())?void 0:n.error_code)||!n.provider_token)throw n;return[4,this.oauthInstance.authApi.signInAnonymously({provider_token:n.provider_token},e)];case 3:if(null==(i=o.sent())?void 0:i.error_code)throw i;return[3,5];case 4:throw o.sent();case 5:return[2]}})})},[4,new Promise(function(t,e){wx.login({success:function(i){return fe(n,void 0,void 0,function(){var n;return pe(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,r(i.code)];case 1:return o.sent(),t(!0),[3,3];case 2:return n=o.sent(),e(n),[3,3];case 3:return[2]}})})},fail:function(t){var r=new Error(null==t?void 0:t.errMsg);r.code=null==t?void 0:t.errno,e(r)}})})];case 1:return i.sent(),[2,this.createLoginState(void 0,{asyncRefreshUser:!0})]}})})},r.prototype.bindOpenId=function(){return fe(this,void 0,Promise,function(){var t,e,r=this;return pe(this,function(n){switch(n.label){case 0:if(!Kt.default.isMatch())throw Error("wx api undefined");return t=wx.getAccountInfoSync().miniProgram,e=function(e){return fe(r,void 0,void 0,function(){var r;return pe(this,function(n){switch(n.label){case 0:r=void 0,n.label=1;case 1:return n.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==t?void 0:t.appId,provider_code:e,provider_params:{provider_code_type:"open_id",appid:null==t?void 0:t.appId}})];case 2:if((null==(r=n.sent())?void 0:r.error_code)||!r.provider_token)throw r;return[4,this.oauthInstance.authApi.bindWithProvider({provider_token:r.provider_token})];case 3:return n.sent(),[3,5];case 4:throw n.sent();case 5:return[2]}})})},[4,new Promise(function(t,n){wx.login({success:function(i){return fe(r,void 0,void 0,function(){var r;return pe(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,e(i.code)];case 1:return o.sent(),t(!0),[3,3];case 2:return r=o.sent(),n(r),[3,3];case 3:return[2]}})})},fail:function(t){var e=new Error(null==t?void 0:t.errMsg);e.code=null==t?void 0:t.errno,n(e)}})})];case 1:return n.sent(),[2]}})})},r.prototype.signInWithUnionId=function(){return fe(this,void 0,Promise,function(){var t=this;return pe(this,function(e){switch(e.label){case 0:if(!Kt.default.isMatch())throw Error("wx api undefined");e.label=1;case 1:return e.trys.push([1,3,,4]),[4,new Promise(function(e,r){var n=wx.getAccountInfoSync().miniProgram;wx.login({success:function(i){return fe(t,void 0,void 0,function(){var t,o,s,a,u;return pe(this,function(c){switch(c.label){case 0:t=null==n?void 0:n.appId,c.label=1;case 1:return c.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_code:i.code,provider_id:t,provider_params:{provider_code_type:"union_id",appid:null==n?void 0:n.appId}})];case 2:return o=c.sent(),(s=o.provider_token)?[4,this.oauthInstance.authApi.signInWithProvider({provider_id:t,provider_token:s})]:(r(o),[2]);case 3:return(null==(a=c.sent())?void 0:a.error_code)?(r(a),[2]):(e(!0),[3,5]);case 4:return u=c.sent(),r(u),[3,5];case 5:return[2]}})})},fail:function(t){var e=new Error(null==t?void 0:t.errMsg);e.code=null==t?void 0:t.errno,r(e)}})})];case 2:return e.sent(),[3,4];case 3:throw e.sent();case 4:return[2,this.createLoginState()]}})})},r.prototype.signInWithSms=function(t){var e=t.verificationInfo,r=void 0===e?{verification_id:"",is_user:!1}:e,n=t.verificationCode,i=void 0===n?"":n,o=t.phoneNum,s=void 0===o?"":o,a=t.bindInfo,u=void 0===a?void 0:a;return fe(this,void 0,Promise,function(){return pe(this,function(t){try{return[2,this.signInWithUsername({verificationInfo:r,verificationCode:i,bindInfo:u,username:s,loginType:"sms"})]}catch(t){throw t}return[2]})})},r.prototype.signInWithEmail=function(t){var e=t.verificationInfo,r=void 0===e?{verification_id:"",is_user:!1}:e,n=t.verificationCode,i=void 0===n?"":n,o=t.bindInfo,s=void 0===o?void 0:o,a=t.email,u=void 0===a?"":a;return fe(this,void 0,Promise,function(){return pe(this,function(t){try{return[2,this.signInWithUsername({verificationInfo:r,verificationCode:i,bindInfo:s,username:u,loginType:"email"})]}catch(t){throw t}return[2]})})},r.prototype.setCustomSignFunc=function(t){this.oauthInstance.authApi.setCustomSignFunc(t)},r.prototype.signIn=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signIn(t)];case 1:return e.sent(),[2,this.createLoginState(t)]}})})},r.prototype.setPassword=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.setPassword(t)]})})},r.prototype.isUsernameRegistered=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){switch(e.label){case 0:return"string"!=typeof t&&(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"username must be a string"),[4,this.oauthInstance.authApi.checkIfUserExist({username:t})];case 1:return[2,e.sent().exist]}})})},r.prototype.hasLoginState=function(){var t;if("async"!==this.cache.mode)return(null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.hasLoginStateSync())?new ye({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance}):null;(0,mt.printWarn)(Ft.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState instead")},r.prototype.getLoginState=function(){return fe(this,void 0,void 0,function(){var t;return pe(this,function(e){switch(e.label){case 0:t=null,e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.oauthInstance.authApi.getLoginState()];case 2:return t=e.sent(),[3,4];case 3:return e.sent(),[2,null];case 4:return t?[2,new ye({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})]:[2,null]}})})},r.prototype.getUserInfo=function(){return fe(this,void 0,Promise,function(){return pe(this,function(t){return[2,this.getCurrentUser()]})})},r.prototype.getWedaUserInfo=function(){return fe(this,void 0,Promise,function(){return pe(this,function(t){return[2,this.oauthInstance.authApi.getWedaUserInfo()]})})},r.prototype.updateUserBasicInfo=function(t){return fe(this,void 0,void 0,function(){var e;return pe(this,function(r){switch(r.label){case 0:return[4,this.getLoginState()];case 1:return(e=r.sent())?[4,e.user.updateUserBasicInfo(t)]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}})})},r.prototype.getAuthHeader=function(){return console.error("Auth.getAuthHeader API 已废弃"),{}},r.prototype.bindWithProvider=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.bindWithProvider(t)]})})},r.prototype.queryUser=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.queryUserProfile(t)]})})},r.prototype.getAccessToken=function(){return fe(this,void 0,void 0,function(){return pe(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.oauth2client.getAccessToken()];case 1:return[2,{accessToken:t.sent(),env:this.config.env}]}})})},r.prototype.grantProviderToken=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.grantProviderToken(t)]})})},r.prototype.patchProviderToken=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.patchProviderToken(t)]})})},r.prototype.signInWithProvider=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInWithProvider(t)];case 1:return e.sent(),[2,this.createLoginState(t)]}})})},r.prototype.signInWithWechat=function(t){return void 0===t&&(t={}),fe(this,void 0,void 0,function(){return pe(this,function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInWithWechat(t)];case 1:return e.sent(),[2,this.createLoginState(t)]}})})},r.prototype.grantToken=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.grantToken(t)];case 1:return e.sent(),[2,this.createLoginState()]}})})},r.prototype.genProviderRedirectUri=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.genProviderRedirectUri(t)]})})},r.prototype.resetPassword=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.resetPassword(t)]})})},r.prototype.deviceAuthorize=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.deviceAuthorize(t)]})})},r.prototype.sudo=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.sudo(t)]})})},r.prototype.deleteMe=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.deleteMe(t)]})})},r.prototype.getProviders=function(){return fe(this,void 0,Promise,function(){return pe(this,function(t){return[2,this.oauthInstance.authApi.getProviders()]})})},r.prototype.loginScope=function(){return fe(this,void 0,Promise,function(){return pe(this,function(t){return[2,this.oauthInstance.authApi.loginScope()]})})},r.prototype.loginGroups=function(){return fe(this,void 0,Promise,function(){return pe(this,function(t){return[2,this.oauthInstance.authApi.loginGroups()]})})},r.prototype.onLoginStateChanged=function(t){var e;return fe(this,void 0,void 0,function(){var r,n=this;return pe(this,function(i){switch(i.label){case 0:return null===(e=this.config.eventBus)||void 0===e||e.on(_,function(e){return fe(n,void 0,void 0,function(){var r,n,i;return pe(this,function(o){switch(o.label){case 0:return(null===(i=null==e?void 0:e.data)||void 0===i?void 0:i.eventType)===f?[3,2]:[4,this.getLoginState()];case 1:return n=o.sent(),[3,3];case 2:n={},o.label=3;case 3:return r=n,t.call(this,he(he({},e),r)),[2]}})})}),[4,this.getLoginState()];case 1:return r=i.sent(),t.call(this,r),[2]}})})},r.prototype.refreshTokenForce=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.refreshTokenForce(t)]})})},r.prototype.getCredentials=function(){return fe(this,void 0,Promise,function(){return pe(this,function(t){return[2,this.oauthInstance.authApi.getCredentials()]})})},r.prototype.setCredentials=function(t){return fe(this,void 0,void 0,function(){return pe(this,function(e){switch(e.label){case 0:return[4,this.oauthInstance.oauth2client.setCredentials(t)];case 1:return e.sent(),[2]}})})},r.prototype.getProviderSubType=function(){return fe(this,void 0,Promise,function(){return pe(this,function(t){return[2,this.oauthInstance.authApi.getProviderSubType()]})})},r.prototype.createCaptchaData=function(t){return fe(this,void 0,void 0,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.createCaptchaData(t)]})})},r.prototype.verifyCaptchaData=function(t){return fe(this,void 0,void 0,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.verifyCaptchaData(t)]})})},r.prototype.getMiniProgramQrCode=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.getMiniProgramCode(t)]})})},r.prototype.getMiniProgramQrCodeStatus=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.getMiniProgramQrCodeStatus(t)]})})},r.prototype.modifyPassword=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.modifyPassword(t)]})})},r.prototype.modifyPasswordWithoutLogin=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.modifyPasswordWithoutLogin(t)]})})},r.prototype.getUserBehaviorLog=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.getUserBehaviorLog(t)]})})},r.prototype.signInWithUsername=function(t){var e=t.verificationInfo,r=void 0===e?{verification_id:"",is_user:!1}:e,n=t.verificationCode,i=void 0===n?"":n,o=t.username,s=void 0===o?"":o,a=t.bindInfo,u=void 0===a?void 0:a,c=t.loginType,h=void 0===c?"":c;return fe(this,void 0,Promise,function(){var t,e,n,o,a,c,l;return pe(this,function(d){switch(d.label){case 0:return d.trys.push([0,8,,9]),[4,this.oauthInstance.authApi.verify({verification_id:r.verification_id,verification_code:i})];case 1:if(null==(t=d.sent())?void 0:t.error_code)throw t;return e=t.verification_token,n=this.formatPhone(s),o={phone_number:n},"email"===h&&(o={email:n=s}),r.is_user?[4,this.oauthInstance.authApi.signIn({username:n,verification_token:e})]:[3,5];case 2:if(null==(a=d.sent())?void 0:a.error_code)throw a;return u?[4,this.oauthInstance.authApi.bindWithProvider({provider_token:null==u?void 0:u.providerToken})]:[3,4];case 3:if(null==(c=d.sent())?void 0:c.error_code)throw c;d.label=4;case 4:return[3,7];case 5:return[4,this.oauthInstance.authApi.signUp(he(he({},o),{verification_token:e,provider_token:null==u?void 0:u.providerId}))];case 6:if(null==(l=d.sent())?void 0:l.error_code)throw l;d.label=7;case 7:return[2,this.createLoginState()];case 8:throw d.sent();case 9:return[2]}})})},r.prototype.createLoginState=function(t,e){var r,n;return fe(this,void 0,Promise,function(){var i;return pe(this,function(o){switch(o.label){case 0:return[4,(i=new ye({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})).checkLocalStateAsync()];case 1:return o.sent(),(null==e?void 0:e.userInfo)?(i.user.setLocalUserInfo(e.userInfo),[3,5]):[3,2];case 2:return(null==e?void 0:e.asyncRefreshUser)?(i.user.refresh(t),[3,5]):[3,3];case 3:return[4,i.user.refresh(t)];case 4:o.sent(),o.label=5;case 5:return null===(r=this.config.eventBus)||void 0===r||r.fire(_,{eventType:"sign_in"}),null===(n=this.config.eventBus)||void 0===n||n.fire(b,{event:v}),[2,i]}})})},r.prototype.setAccessKey=function(){var t,e;return fe(this,void 0,void 0,function(){var r,n;return pe(this,function(i){if(r="",n="",this.config.accessKey?(r=this.config.accessKey,n="accessKey"):(null===(t=this.config.auth)||void 0===t?void 0:t.secretId)&&(null===(e=this.config.auth)||void 0===e?void 0:e.secretKey)&&(r="",n=E),!n)return[2];try{this.oauthInstance.oauth2client.setAccessKeyCredentials({access_token:r,token_type:"Bearer",scope:n,expires_at:new Date(+new Date+ +new Date),expires_in:+new Date+ +new Date})}catch(t){console.warn("accessKey error: ",t)}return[2]})})},r.prototype.formatPhone=function(t){return!/\s+/.test(t)&&/^\+\d{1,3}\d+/.test(t)?t.replace(/^(\+\d{1,2})(\d+)$/,"$1 $2"):/^\+\d{1,3}\s+/.test(t)?t:"+86 ".concat(t)},r.prototype.notifyListeners=function(t,e,r){this.listeners.forEach(function(n){n.forEach(function(n){try{n(t,e,r)}catch(t){console.error("Error in auth state change callback:",t)}})})},r.prototype.setupListeners=function(){var t,e=this;null===(t=this.config.eventBus)||void 0===t||t.on(b,function(t){return fe(e,void 0,void 0,function(){var e,r,n,i,o;return pe(this,function(s){switch(s.label){case 0:return e=null===(i=null==t?void 0:t.data)||void 0===i?void 0:i.event,r=null===(o=null==t?void 0:t.data)||void 0===o?void 0:o.info,[4,this.getSession()];case 1:return n=s.sent().data.session,this.notifyListeners(e,n,r),[2]}})})})},r.prototype.convertToUser=function(t){var e,r,n,i,o,s;if(!t)return null;var a=(null==t?void 0:t.email)||"",u=(null==t?void 0:t.phone_number)||"",c=(null==t?void 0:t.sub)||(null==t?void 0:t.uid)||"";return{id:c,aud:"authenticated",role:null===(r=null===(e=t.groups)||void 0===e?void 0:e.map)||void 0===r?void 0:r.call(e,function(t){return"string"==typeof t?t:t.id}),email:a||"",email_confirmed_at:(null==t||t.email_verified,t.created_at),phone:u,phone_confirmed_at:u?t.created_at:void 0,confirmed_at:t.created_at,last_sign_in_at:t.last_sign_in_at,app_metadata:{provider:(null===(n=t.loginType)||void 0===n?void 0:n.toLowerCase())||"cloudbase",providers:[(null===(i=t.loginType)||void 0===i?void 0:i.toLowerCase())||"cloudbase"]},user_metadata:{name:null==t?void 0:t.name,picture:null==t?void 0:t.picture,username:null==t?void 0:t.username,gender:null==t?void 0:t.gender,locale:null==t?void 0:t.locale,uid:t.uid,nickName:t.nickName||(null==t?void 0:t.name),avatarUrl:t.avatarUrl||t.picture,location:t.location,hasPassword:null!==(o=t.hasPassword)&&void 0!==o?o:"SET"===t.password,open_id:null==t?void 0:t.open_id},identities:(null===(s=null==t?void 0:t.providers)||void 0===s?void 0:s.map(function(e){return{id:e.id||"",identity_id:e.id||"",user_id:c,identity_data:{provider_id:e.id,provider_user_id:e.provider_user_id,name:e.name},provider:e.id||"cloudbase",created_at:t.created_at,updated_at:t.updated_at,last_sign_in_at:t.last_sign_in_at}}))||[],created_at:t.created_at,updated_at:t.updated_at,is_anonymous:"anonymous"===t.name}},r.prototype.validateParams=function(t,e){for(var r=0,n=Object.entries(e);r<n.length;r++){var i=n[r],o=i[0],s=i[1];if(s.required&&(void 0===(null==t?void 0:t[o])||null===(null==t?void 0:t[o])||""===(null==t?void 0:t[o])))throw new kt({message:s.message})}},r.prototype.validateAtLeastOne=function(t,e,r){if(!e.some(function(e){return e.some(function(e){return void 0!==(null==t?void 0:t[e])&&null!==(null==t?void 0:t[e])&&""!==(null==t?void 0:t[e])})}))throw new kt({message:r})},r.prototype.init=function(){var t;return fe(this,void 0,Promise,function(){return pe(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()&&(null===(t=this.config.eventBus)||void 0===t||t.fire(b,{event:"INITIAL_SESSION"})),[3,3];case 2:return e.sent(),[3,3];case 3:return[2,{error:null}]}})})},le([(0,Ht.catchErrorsDecorator)({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",["function"==typeof(n=t.BindPhoneRequest)?n:Object]),de("design:returntype",Promise)],r.prototype,"bindPhoneNumber",null),le([(0,Ht.catchErrorsDecorator)({title:"解除三方绑定失败",messages:["请确认以下各项:"," 1 - 调用 auth().unbindProvider() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",["function"==typeof(i=t.UnbindProviderRequest)?i:Object]),de("design:returntype","function"==typeof(o="undefined"!=typeof Promise&&Promise)?o:Object)],r.prototype,"unbindProvider",null),le([(0,Ht.catchErrorsDecorator)({title:"绑定邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",["function"==typeof(s=t.BindEmailRequest)?s:Object]),de("design:returntype",void 0)],r.prototype,"bindEmail",null),le([(0,Ht.catchErrorsDecorator)({title:"验证码验证失败",messages:["请确认以下各项:"," 1 - 调用 auth().verify() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",["function"==typeof(a=t.VerifyRequest)?a:Object]),de("design:returntype","function"==typeof(u="undefined"!=typeof Promise&&Promise)?u:Object)],r.prototype,"verify",null),le([(0,Ht.catchErrorsDecorator)({title:"获取验证码失败",messages:["请确认以下各项:"," 1 - 调用 auth().getVerification() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",["function"==typeof(c=t.GetVerificationRequest)?c:Object,Object]),de("design:returntype","function"==typeof(h="undefined"!=typeof Promise&&Promise)?h:Object)],r.prototype,"getVerification",null),le([(0,Ht.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrentUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",[Object]),de("design:returntype","function"==typeof(l="undefined"!=typeof Promise&&Promise)?l:Object)],r.prototype,"getCurrentUser",null),le([(0,Ht.catchErrorsDecorator)({title:"小程序匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymouslyInWx() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",[Object]),de("design:returntype","function"==typeof(d="undefined"!=typeof Promise&&Promise)?d:Object)],r.prototype,"signInAnonymouslyInWx",null),le([(0,Ht.catchErrorsDecorator)({title:"小程序绑定OpenID失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序openId静默登录"," 2 - 调用 auth().bindOpenId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",[]),de("design:returntype","function"==typeof(g="undefined"!=typeof Promise&&Promise)?g:Object)],r.prototype,"bindOpenId",null),le([(0,Ht.catchErrorsDecorator)({title:"小程序unionId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序unionId静默登录"," 2 - 调用 auth().signInWithUnionId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",[]),de("design:returntype","function"==typeof(y="undefined"!=typeof Promise&&Promise)?y:Object)],r.prototype,"signInWithUnionId",null),le([(0,Ht.catchErrorsDecorator)({title:"短信验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序短信验证码登陆"," 2 - 调用 auth().signInWithSms() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",[Object]),de("design:returntype","function"==typeof(S="undefined"!=typeof Promise&&Promise)?S:Object)],r.prototype,"signInWithSms",null),le([(0,Ht.catchErrorsDecorator)({title:"邮箱验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了邮箱登陆"," 2 - 调用 auth().signInWithEmail() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",[Object]),de("design:returntype","function"==typeof(A="undefined"!=typeof Promise&&Promise)?A:Object)],r.prototype,"signInWithEmail",null),le([(0,Ht.catchErrorsDecorator)({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",[String]),de("design:returntype","function"==typeof(P="undefined"!=typeof Promise&&Promise)?P:Object)],r.prototype,"isUsernameRegistered",null),le([(0,Ht.catchErrorsDecorator)({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",[]),de("design:returntype",Promise)],r.prototype,"getLoginState",null),le([(0,Ht.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",[]),de("design:returntype","function"==typeof(O="undefined"!=typeof Promise&&Promise)?O:Object)],r.prototype,"getUserInfo",null),le([(0,Ht.catchErrorsDecorator)({title:"获取微搭插件用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getWedaUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",[]),de("design:returntype","function"==typeof(T="undefined"!=typeof Promise&&Promise)?T:Object)],r.prototype,"getWedaUserInfo",null),le([(0,Ht.catchErrorsDecorator)({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindWithProvider() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",["function"==typeof(R=t.BindWithProviderRequest)?R:Object]),de("design:returntype","function"==typeof(C="undefined"!=typeof Promise&&Promise)?C:Object)],r.prototype,"bindWithProvider",null),le([(0,Ht.catchErrorsDecorator)({title:"获取身份源类型",messages:["请确认以下各项:"," 1 - 调用 auth().getProviderSubType() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",[]),de("design:returntype","function"==typeof(U="undefined"!=typeof Promise&&Promise)?U:Object)],r.prototype,"getProviderSubType",null),r}(ue),be="auth";function Ie(t,e){for(var r=[],n=0;n<=t.length;n++)r[n]=[n];for(var i=0;i<=e.length;i++)r[0][i]=i;for(n=1;n<=t.length;n++)for(i=1;i<=e.length;i++){var o=t[n-1].toLowerCase()===e[i-1].toLowerCase()?0:1;r[n][i]=Math.min(r[n-1][i]+1,r[n][i-1]+1,r[n-1][i-1]+o)}return r[t.length][e.length]}var we={name:"auth",namespace:be,entity:function(t){var e=function(t){var e,r=this;if(this.authInstance&&!t)return this.authInstance;t=t||{region:"",persistence:"local",apiPath:l};var n=this.platform.adapter,i=t.persistence||n.primaryStorage;i&&i!==this.config.persistence&&this.updateConfig({persistence:i});var o=function(t,e){var r,n,i,o,s=this,a=t.region,u=void 0===a?"ap-shanghai":a,c=t.i18n,h=t.accessKey,d=t.useWxCloud,f=(null==e?void 0:e.platform)||zt.useDefaultAdapter.bind(e)(),p=f.runtime,g=f.adapter,m=e||{},_=m.env,E=m.clientId,S=m.debug,A=m.cache,P=m.app,O=m.getApiOrigin,T=(e||{}).apiOrigin;T||(T="https://".concat(_,".").concat(u,".tcb-api.tencentcloudapi.com"));var R={env:_,clientId:E,i18n:c,accessKey:h,useWxCloud:d,eventBus:new gt.CloudbaseEventEmitter},C=new Wt(ee(he(he({},R),{apiOrigin:T,getApiOrigin:O,apiPath:(null==t?void 0:t.apiPath)||l,storage:null==t?void 0:t.storage,baseRequest:null==t?void 0:t.baseRequest,request:null==t?void 0:t.request,anonymousSignInFunc:null==t?void 0:t.anonymousSignInFunc,captchaOptions:null==t?void 0:t.captchaOptions,wxCloud:null==t?void 0:t.wxCloud,adapter:g,onCredentialsError:ge(R.eventBus),headers:he({"X-SDK-Version":"@cloudbase/js-sdk/".concat(t.sdkVersion)},t.headers||{}),detectSessionInUrl:t.detectSessionInUrl,debug:S,auth:null===(n=null===(r=e.app)||void 0===r?void 0:r.config)||void 0===n?void 0:n.auth}))),U=new _e(he(he({},R),{region:u,persistence:t.persistence,debug:S,cache:A||new Gt.CloudbaseCache({persistence:t.persistence,keys:{userInfoKey:"user_info_".concat(_)},platformInfo:f}),runtime:p||"web",_fromApp:P,oauthInstance:C,auth:null===(o=null===(i=e.app)||void 0===i?void 0:i.config)||void 0===o?void 0:o.auth}));return C.initializeSession(function(t,e){return fe(s,void 0,void 0,function(){return pe(this,function(r){return t?(t.type===I?e?R.eventBus.fire(b,{event:v,info:he(he({},t),{error:e})}):t.user&&U.createLoginState({},{userInfo:t.user}):t.type===w&&R.eventBus.fire(b,{event:y,info:he(he({},t),{error:e})}),[2]):[2]})})}),{authInstance:U,oauthInstance:C}}(he(he({wxCloud:this.config.wxCloud,storage:this.config.storage},t),{persistence:this.config.persistence,i18n:this.config.i18n,accessKey:this.config.accessKey,useWxCloud:this.config.useWxCloud,sdkVersion:this.version,detectSessionInUrl:null===(e=this.config.auth)||void 0===e?void 0:e.detectSessionInUrl}),{env:this.config.env,clientId:this.config.clientId,getApiOrigin:function(){return r.request.getBaseEndPoint(r.config.endPointMode||"CLOUD_API")},platform:this.platform,cache:this.cache,app:this,debug:this.config.debug}),s=o.authInstance,a=o.oauthInstance;return this.oauthInstance=a,this.authInstance=s,this.authInstance},r=e.call(this,t);Object.assign(e,r),Object.setPrototypeOf(e,Object.getPrototypeOf(r));var n="undefined"!=typeof Proxy?new Proxy(e,{get:function(t,e,r){var n=Reflect.get(t,e,r);if(void 0!==n||"string"!=typeof e)return n;var i=function(t,e){for(var r=null,n=1/0,i=0,o=e;i<o.length;i++){var s=o[i];if(!s.startsWith("_")&&"constructor"!==s){var a=Ie(t,s);a<n&&(n=a,r=s)}}return r}(e,Object.getOwnPropertyNames(Object.getPrototypeOf(t)).concat(Object.keys(t)).filter(function(e){return"function"==typeof t[e]}));return i&&console.warn("[CloudBase Auth] auth.".concat(e," is not a function. Did you mean: auth.").concat(i,"() ?")),n}}):e;return this[be]=n,n}};try{cloudbase.registerComponent(we)}catch(t){}var Ee=function(t){try{t.registerComponent(we)}catch(t){console.warn(t)}};try{window.registerAuth=Ee}catch(t){}})();var a=s.W;export{a as registerAuth};
2
+ import*as t from"@cloudbase/adapter-interface";import*as e from"jwt-decode";import*as r from"@cloudbase/adapter-wx_mp";var n={171:(t,e,r)=>{var n;if(r.r(e),r.d(e,{getEncryptInfo:()=>q}),!globalThis.IS_MP_BUILD){var i="undefined"!=typeof globalThis?globalThis.navigator:window.globalThis;function B(t){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(t)}function j(t,e){return t&e}function V(t,e){return t|e}function W(t,e){return t^e}function F(t,e){return t&~e}function H(t){if(0==t)return-1;var e=0;return 65535&t||(t>>=16,e+=16),255&t||(t>>=8,e+=8),15&t||(t>>=4,e+=4),3&t||(t>>=2,e+=2),1&t||++e,e}function G(t){for(var e=0;0!=t;)t&=t-1,++e;return e}var o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function K(t){var e,r,n="";for(e=0;e+3<=t.length;e+=3)r=parseInt(t.substring(e,e+3),16),n+=o.charAt(r>>6)+o.charAt(63&r);for(e+1==t.length?(r=parseInt(t.substring(e,e+1),16),n+=o.charAt(r<<2)):e+2==t.length&&(r=parseInt(t.substring(e,e+2),16),n+=o.charAt(r>>2)+o.charAt((3&r)<<4));(3&n.length)>0;)n+="=";return n}function Y(t){var e,r="",n=0,i=0;for(e=0;e<t.length&&"="!=t.charAt(e);++e){var s=o.indexOf(t.charAt(e));s<0||(0==n?(r+=B(s>>2),i=3&s,n=1):1==n?(r+=B(i<<2|s>>4),i=15&s,n=2):2==n?(r+=B(i),r+=B(s>>2),i=3&s,n=3):(r+=B(i<<2|s>>4),r+=B(15&s),n=0))}return 1==n&&(r+=B(i<<2)),r}var s,a,u={decode:function(t){var e;if(void 0===s){var r="0123456789ABCDEF";for(s={},e=0;e<16;++e)s[r.charAt(e)]=e;for(r=r.toLowerCase(),e=10;e<16;++e)s[r.charAt(e)]=e;for(e=0;e<8;++e)s[" \f\n\r\t \u2028\u2029".charAt(e)]=-1}var n=[],i=0,o=0;for(e=0;e<t.length;++e){var a=t.charAt(e);if("="==a)break;if(-1!=(a=s[a])){if(void 0===a)throw new Error("Illegal character at offset "+e);i|=a,++o>=2?(n[n.length]=i,i=0,o=0):i<<=4}}if(o)throw new Error("Hex encoding incomplete: 4 bits missing");return n}},c={decode:function(t){var e;if(void 0===a){for(a=Object.create(null),e=0;e<64;++e)a["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e)]=e;for(e=0;e<9;++e)a["= \f\n\r\t \u2028\u2029".charAt(e)]=-1}var r=[],n=0,i=0;for(e=0;e<t.length;++e){var o=t.charAt(e);if("="==o)break;if(-1!=(o=a[o])){if(void 0===o)throw new Error("Illegal character at offset "+e);n|=o,++i>=4?(r[r.length]=n>>16,r[r.length]=n>>8&255,r[r.length]=255&n,n=0,i=0):n<<=6}}switch(i){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:r[r.length]=n>>10;break;case 3:r[r.length]=n>>16,r[r.length]=n>>8&255}return r},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(t){var e=c.re.exec(t);if(e)if(e[1])t=e[1];else{if(!e[2])throw new Error("RegExp out of sync");t=e[2]}return c.decode(t)}},h=1e13;class z{constructor(t){this.buf=[+t||0]}mulAdd(t,e){var r,n,i=this.buf,o=i.length;for(r=0;r<o;++r)(n=i[r]*t+e)<h?e=0:n-=(e=0|n/h)*h,i[r]=n;e>0&&(i[r]=e)}sub(t){var e,r,n=this.buf,i=n.length;for(e=0;e<i;++e)(r=n[e]-t)<0?(r+=h,t=1):t=0,n[e]=r;for(;0===n[n.length-1];)n.pop()}toString(t){if(10!=(t||10))throw new Error("only base 10 is supported");for(var e=this.buf,r=e[e.length-1].toString(),n=e.length-2;n>=0;--n)r+=(h+e[n]).toString().substring(1);return r}valueOf(){for(var t=this.buf,e=0,r=t.length-1;r>=0;--r)e=e*h+t[r];return e}simplify(){var t=this.buf;return 1==t.length?t[0]:this}}var l,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)?)?$/,f=/^(\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(t,e){return t.length>e&&(t=t.substring(0,e)+"…"),t}class J{constructor(t,e){this.hexDigits="0123456789ABCDEF",t instanceof J?(this.enc=t.enc,this.pos=t.pos):(this.enc=t,this.pos=e)}get(t){if(void 0===t&&(t=this.pos++),t>=this.enc.length)throw new Error("Requesting byte offset "+t+" on a stream of length "+this.enc.length);return"string"==typeof this.enc?this.enc.charCodeAt(t):this.enc[t]}hexByte(t){return this.hexDigits.charAt(t>>4&15)+this.hexDigits.charAt(15&t)}hexDump(t,e,r){for(var n="",i=t;i<e;++i)if(n+=this.hexByte(this.get(i)),!0!==r)switch(15&i){case 7:n+=" ";break;case 15:n+="\n";break;default:n+=" "}return n}isASCII(t,e){for(var r=t;r<e;++r){var n=this.get(r);if(n<32||n>176)return!1}return!0}parseStringISO(t,e){for(var r="",n=t;n<e;++n)r+=String.fromCharCode(this.get(n));return r}parseStringUTF(t,e){for(var r="",n=t;n<e;){var i=this.get(n++);r+=i<128?String.fromCharCode(i):i>191&&i<224?String.fromCharCode((31&i)<<6|63&this.get(n++)):String.fromCharCode((15&i)<<12|(63&this.get(n++))<<6|63&this.get(n++))}return r}parseStringBMP(t,e){for(var r,n,i="",o=t;o<e;)r=this.get(o++),n=this.get(o++),i+=String.fromCharCode(r<<8|n);return i}parseTime(t,e,r){var n=this.parseStringISO(t,e),i=(r?d:f).exec(n);return i?(r&&(i[1]=+i[1],i[1]+=+i[1]<70?2e3:1900),n=i[1]+"-"+i[2]+"-"+i[3]+" "+i[4],i[5]&&(n+=":"+i[5],i[6]&&(n+=":"+i[6],i[7]&&(n+="."+i[7]))),i[8]&&(n+=" UTC","Z"!=i[8]&&(n+=i[8],i[9]&&(n+=":"+i[9]))),n):"Unrecognized time: "+n}parseInteger(t,e){for(var r,n=this.get(t),i=n>127,o=i?255:0,s="";n==o&&++t<e;)n=this.get(t);if(0===(r=e-t))return i?-1:0;if(r>4){for(s=n,r<<=3;!(128&(+s^o));)s=+s<<1,--r;s="("+r+" bit)\n"}i&&(n-=256);for(var a=new z(n),u=t+1;u<e;++u)a.mulAdd(256,this.get(u));return s+a.toString()}parseBitString(t,e,r){for(var n=this.get(t),i="("+((e-t-1<<3)-n)+" bit)\n",o="",s=t+1;s<e;++s){for(var a=this.get(s),u=s==e-1?n:0,c=7;c>=u;--c)o+=a>>c&1?"1":"0";if(o.length>r)return i+Q(o,r)}return i+o}parseOctetString(t,e,r){if(this.isASCII(t,e))return Q(this.parseStringISO(t,e),r);var n=e-t,i="("+n+" byte)\n";n>(r/=2)&&(e=t+r);for(var o=t;o<e;++o)i+=this.hexByte(this.get(o));return n>r&&(i+="…"),i}parseOID(t,e,r){for(var n="",i=new z,o=0,s=t;s<e;++s){var a=this.get(s);if(i.mulAdd(128,127&a),o+=7,!(128&a)){if(""===n)if((i=i.simplify())instanceof z)i.sub(80),n="2."+i.toString();else{var u=i<80?i<40?0:1:2;n=u+"."+(i-40*u)}else n+="."+i.toString();if(n.length>r)return Q(n,r);i=new z,o=0}}return o>0&&(n+=".incomplete"),n}}class Z{constructor(t,e,r,n,i){if(!(n instanceof X))throw new Error("Invalid tag value.");this.stream=t,this.header=e,this.length=r,this.tag=n,this.sub=i}typeName(){switch(this.tag.tagClass){case 0:switch(this.tag.tagNumber){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER";case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString";case 30:return"BMPString"}return"Universal_"+this.tag.tagNumber.toString();case 1:return"Application_"+this.tag.tagNumber.toString();case 2:return"["+this.tag.tagNumber.toString()+"]";case 3:return"Private_"+this.tag.tagNumber.toString()}}content(t){if(void 0===this.tag)return null;void 0===t&&(t=1/0);var e=this.posContent(),r=Math.abs(this.length);if(!this.tag.isUniversal())return null!==this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+r,t);switch(this.tag.tagNumber){case 1:return 0===this.stream.get(e)?"false":"true";case 2:return this.stream.parseInteger(e,e+r);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(e,e+r,t);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+r,t);case 6:return this.stream.parseOID(e,e+r,t);case 16:case 17:return null!==this.sub?"("+this.sub.length+" elem)":"(no elem)";case 12:return Q(this.stream.parseStringUTF(e,e+r),t);case 18:case 19:case 20:case 21:case 22:case 26:return Q(this.stream.parseStringISO(e,e+r),t);case 30:return Q(this.stream.parseStringBMP(e,e+r),t);case 23:case 24:return this.stream.parseTime(e,e+r,23==this.tag.tagNumber)}return null}toString(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(null===this.sub?"null":this.sub.length)+"]"}toPrettyString(t){void 0===t&&(t="");var e=t+this.typeName()+" @"+this.stream.pos;if(this.length>=0&&(e+="+"),e+=this.length,this.tag.tagConstructed?e+=" (constructed)":!this.tag.isUniversal()||3!=this.tag.tagNumber&&4!=this.tag.tagNumber||null===this.sub||(e+=" (encapsulates)"),e+="\n",null!==this.sub){t+=" ";for(var r=0,n=this.sub.length;r<n;++r)e+=this.sub[r].toPrettyString(t)}return e}posStart(){return this.stream.pos}posContent(){return this.stream.pos+this.header}posEnd(){return this.stream.pos+this.header+Math.abs(this.length)}toHexString(){return this.stream.hexDump(this.posStart(),this.posEnd(),!0)}static decodeLength(t){var e=t.get(),r=127&e;if(r==e)return r;if(r>6)throw new Error("Length over 48 bits not supported at position "+(t.pos-1));if(0===r)return null;e=0;for(var n=0;n<r;++n)e=256*e+t.get();return e}getHexStringValue(){var t=this.toHexString(),e=2*this.header,r=2*this.length;return t.substr(e,r)}static decode(t){var e;e=t instanceof J?t:new J(t,0);var r=new J(e),n=new X(e),i=Z.decodeLength(e),o=e.pos,s=o-r.pos,a=null,u=function(){var t=[];if(null!==i){for(var r=o+i;e.pos<r;)t[t.length]=Z.decode(e);if(e.pos!=r)throw new Error("Content size is not correct for container starting at offset "+o)}else try{for(;;){var n=Z.decode(e);if(n.tag.isEOC())break;t[t.length]=n}i=o-e.pos}catch(t){throw new Error("Exception while decoding undefined length content: "+t)}return t};if(n.tagConstructed)a=u();else if(n.isUniversal()&&(3==n.tagNumber||4==n.tagNumber))try{if(3==n.tagNumber&&0!=e.get())throw new Error("BIT STRINGs with unused bits cannot encapsulate.");a=u();for(var c=0;c<a.length;++c)if(a[c].tag.isEOC())throw new Error("EOC is not supposed to be actual content.")}catch(t){a=null}if(null===a){if(null===i)throw new Error("We can't skip over an invalid tag with undefined length at offset "+o);e.pos=o+Math.abs(i)}return new Z(r,s,i,n,a)}}class X{constructor(t){var e=t.get();if(this.tagClass=e>>6,this.tagConstructed=!!(32&e),this.tagNumber=31&e,31==this.tagNumber){var r=new z;do{e=t.get(),r.mulAdd(128,127&e)}while(128&e);this.tagNumber=r.simplify()}}isUniversal(){return 0===this.tagClass}isEOC(){return 0===this.tagClass&&0===this.tagNumber}}var p=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],v=(1<<26)/p[p.length-1];class ${constructor(t,e,r){null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}toString(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,n=(1<<e)-1,i=!1,o="",s=this.t,a=this.DB-s*this.DB%e;if(s-- >0)for(a<this.DB&&(r=this[s]>>a)>0&&(i=!0,o=B(r));s>=0;)a<e?(r=(this[s]&(1<<a)-1)<<e-a,r|=this[--s]>>(a+=this.DB-e)):(r=this[s]>>(a-=e)&n,a<=0&&(a+=this.DB,--s)),r>0&&(i=!0),i&&(o+=B(r));return i?o:"0"}negate(){var t=tt();return $.ZERO.subTo(this,t),t}abs(){return this.s<0?this.negate():this}compareTo(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0}bitLength(){return this.t<=0?0:this.DB*(this.t-1)+at(this[this.t-1]^this.s&this.DM)}mod(t){var e=tt();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo($.ZERO)>0&&t.subTo(e,e),e}modPowInt(t,e){var r;return r=t<256||e.isEven()?new m(e):new y(e),this.exp(t,r)}clone(){var t=tt();return this.copyTo(t),t}intValue(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]}byteValue(){return 0==this.t?this.s:this[0]<<24>>24}shortValue(){return 0==this.t?this.s:this[0]<<16>>16}signum(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1}toByteArray(){var t=this.t,e=[];e[0]=this.s;var r,n=this.DB-t*this.DB%8,i=0;if(t-- >0)for(n<this.DB&&(r=this[t]>>n)!=(this.s&this.DM)>>n&&(e[i++]=r|this.s<<this.DB-n);t>=0;)n<8?(r=(this[t]&(1<<n)-1)<<8-n,r|=this[--t]>>(n+=this.DB-8)):(r=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),128&r&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(e[i++]=r);return e}equals(t){return 0==this.compareTo(t)}min(t){return this.compareTo(t)<0?this:t}max(t){return this.compareTo(t)>0?this:t}and(t){var e=tt();return this.bitwiseTo(t,j,e),e}or(t){var e=tt();return this.bitwiseTo(t,V,e),e}xor(t){var e=tt();return this.bitwiseTo(t,W,e),e}andNot(t){var e=tt();return this.bitwiseTo(t,F,e),e}not(){for(var t=tt(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t}shiftLeft(t){var e=tt();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e}shiftRight(t){var e=tt();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e}getLowestSetBit(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+H(this[t]);return this.s<0?this.t*this.DB:-1}bitCount(){for(var t=0,e=this.s&this.DM,r=0;r<this.t;++r)t+=G(this[r]^e);return t}testBit(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:!!(this[e]&1<<t%this.DB)}setBit(t){return this.changeBit(t,V)}clearBit(t){return this.changeBit(t,F)}flipBit(t){return this.changeBit(t,W)}add(t){var e=tt();return this.addTo(t,e),e}subtract(t){var e=tt();return this.subTo(t,e),e}multiply(t){var e=tt();return this.multiplyTo(t,e),e}divide(t){var e=tt();return this.divRemTo(t,e,null),e}remainder(t){var e=tt();return this.divRemTo(t,null,e),e}divideAndRemainder(t){var e=tt(),r=tt();return this.divRemTo(t,e,r),[e,r]}modPow(t,e){var r,n,i=t.bitLength(),o=st(1);if(i<=0)return o;r=i<18?1:i<48?3:i<144?4:i<768?5:6,n=i<8?new m(e):e.isEven()?new _(e):new y(e);var s=[],a=3,u=r-1,c=(1<<r)-1;if(s[1]=n.convert(this),r>1){var h=tt();for(n.sqrTo(s[1],h);a<=c;)s[a]=tt(),n.mulTo(h,s[a-2],s[a]),a+=2}var l,d,f=t.t-1,p=!0,v=tt();for(i=at(t[f])-1;f>=0;){for(i>=u?l=t[f]>>i-u&c:(l=(t[f]&(1<<i+1)-1)<<u-i,f>0&&(l|=t[f-1]>>this.DB+i-u)),a=r;!(1&l);)l>>=1,--a;if((i-=a)<0&&(i+=this.DB,--f),p)s[l].copyTo(o),p=!1;else{for(;a>1;)n.sqrTo(o,v),n.sqrTo(v,o),a-=2;a>0?n.sqrTo(o,v):(d=o,o=v,v=d),n.mulTo(v,s[l],o)}for(;f>=0&&!(t[f]&1<<i);)n.sqrTo(o,v),d=o,o=v,v=d,--i<0&&(i=this.DB-1,--f)}return n.revert(o)}modInverse(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return $.ZERO;for(var r=t.clone(),n=this.clone(),i=st(1),o=st(0),s=st(0),a=st(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),e?(i.isEven()&&o.isEven()||(i.addTo(this,i),o.subTo(t,o)),i.rShiftTo(1,i)):o.isEven()||o.subTo(t,o),o.rShiftTo(1,o);for(;n.isEven();)n.rShiftTo(1,n),e?(s.isEven()&&a.isEven()||(s.addTo(this,s),a.subTo(t,a)),s.rShiftTo(1,s)):a.isEven()||a.subTo(t,a),a.rShiftTo(1,a);r.compareTo(n)>=0?(r.subTo(n,r),e&&i.subTo(s,i),o.subTo(a,o)):(n.subTo(r,n),e&&s.subTo(i,s),a.subTo(o,a))}return 0!=n.compareTo($.ONE)?$.ZERO:a.compareTo(t)>=0?a.subtract(t):a.signum()<0?(a.addTo(t,a),a.signum()<0?a.add(t):a):a}pow(t){return this.exp(t,new g)}gcd(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var i=e.getLowestSetBit(),o=r.getLowestSetBit();if(o<0)return e;for(i<o&&(o=i),o>0&&(e.rShiftTo(o,e),r.rShiftTo(o,r));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return o>0&&r.lShiftTo(o,r),r}isProbablePrime(t){var e,r=this.abs();if(1==r.t&&r[0]<=p[p.length-1]){for(e=0;e<p.length;++e)if(r[0]==p[e])return!0;return!1}if(r.isEven())return!1;for(e=1;e<p.length;){for(var n=p[e],i=e+1;i<p.length&&n<v;)n*=p[i++];for(n=r.modInt(n);e<i;)if(n%p[e++]==0)return!1}return r.millerRabin(t)}copyTo(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s}fromInt(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0}fromString(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var n=t.length,i=!1,o=0;--n>=0;){var s=8==r?255&+t[n]:ot(t,n);s<0?"-"==t.charAt(n)&&(i=!0):(i=!1,0==o?this[this.t++]=s:o+r>this.DB?(this[this.t-1]|=(s&(1<<this.DB-o)-1)<<o,this[this.t++]=s>>this.DB-o):this[this.t-1]|=s<<o,(o+=r)>=this.DB&&(o-=this.DB))}8==r&&128&+t[0]&&(this.s=-1,o>0&&(this[this.t-1]|=(1<<this.DB-o)-1<<o)),this.clamp(),i&&$.ZERO.subTo(this,this)}clamp(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t}dlShiftTo(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s}drShiftTo(t,e){for(var r=t;r<this.t;++r)e[r-t]=this[r];e.t=Math.max(this.t-t,0),e.s=this.s}lShiftTo(t,e){for(var r=t%this.DB,n=this.DB-r,i=(1<<n)-1,o=Math.floor(t/this.DB),s=this.s<<r&this.DM,a=this.t-1;a>=0;--a)e[a+o+1]=this[a]>>n|s,s=(this[a]&i)<<r;for(a=o-1;a>=0;--a)e[a]=0;e[o]=s,e.t=this.t+o+1,e.s=this.s,e.clamp()}rShiftTo(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var n=t%this.DB,i=this.DB-n,o=(1<<n)-1;e[0]=this[r]>>n;for(var s=r+1;s<this.t;++s)e[s-r-1]|=(this[s]&o)<<i,e[s-r]=this[s]>>n;n>0&&(e[this.t-r-1]|=(this.s&o)<<i),e.t=this.t-r,e.clamp()}}subTo(t,e){for(var r=0,n=0,i=Math.min(t.t,this.t);r<i;)n+=this[r]-t[r],e[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n-=t.s;r<this.t;)n+=this[r],e[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n-=t[r],e[r++]=n&this.DM,n>>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[r++]=this.DV+n:n>0&&(e[r++]=n),e.t=r,e.clamp()}multiplyTo(t,e){var r=this.abs(),n=t.abs(),i=r.t;for(e.t=i+n.t;--i>=0;)e[i]=0;for(i=0;i<n.t;++i)e[i+r.t]=r.am(0,n[i],e,i,0,r.t);e.s=0,e.clamp(),this.s!=t.s&&$.ZERO.subTo(e,e)}squareTo(t){for(var e=this.abs(),r=t.t=2*e.t;--r>=0;)t[r]=0;for(r=0;r<e.t-1;++r){var n=e.am(r,e[r],t,2*r,0,1);(t[r+e.t]+=e.am(r+1,2*e[r],t,2*r+1,n,e.t-r-1))>=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()}divRemTo(t,e,r){var n=t.abs();if(!(n.t<=0)){var i=this.abs();if(i.t<n.t)return null!=e&&e.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=tt());var o=tt(),s=this.s,a=t.s,u=this.DB-at(n[n.t-1]);u>0?(n.lShiftTo(u,o),i.lShiftTo(u,r)):(n.copyTo(o),i.copyTo(r));var c=o.t,h=o[c-1];if(0!=h){var l=h*(1<<this.F1)+(c>1?o[c-2]>>this.F2:0),d=this.FV/l,f=(1<<this.F1)/l,p=1<<this.F2,v=r.t,g=v-c,m=e??tt();for(o.dlShiftTo(g,m),r.compareTo(m)>=0&&(r[r.t++]=1,r.subTo(m,r)),$.ONE.dlShiftTo(c,m),m.subTo(o,o);o.t<c;)o[o.t++]=0;for(;--g>=0;){var y=r[--v]==h?this.DM:Math.floor(r[v]*d+(r[v-1]+p)*f);if((r[v]+=o.am(0,y,r,g,0,c))<y)for(o.dlShiftTo(g,m),r.subTo(m,r);r[v]<--y;)r.subTo(m,r)}null!=e&&(r.drShiftTo(c,e),s!=a&&$.ZERO.subTo(e,e)),r.t=c,r.clamp(),u>0&&r.rShiftTo(u,r),s<0&&$.ZERO.subTo(r,r)}}}invDigit(){if(this.t<1)return 0;var t=this[0];if(!(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e}isEven(){return 0==(this.t>0?1&this[0]:this.s)}exp(t,e){if(t>4294967295||t<1)return $.ONE;var r=tt(),n=tt(),i=e.convert(this),o=at(t)-1;for(i.copyTo(r);--o>=0;)if(e.sqrTo(r,n),(t&1<<o)>0)e.mulTo(n,i,r);else{var s=r;r=n,n=s}return e.revert(r)}chunkSize(t){return Math.floor(Math.LN2*this.DB/Math.log(t))}toRadix(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),n=st(r),i=tt(),o=tt(),s="";for(this.divRemTo(n,i,o);i.signum()>0;)s=(r+o.intValue()).toString(t).substr(1)+s,i.divRemTo(n,i,o);return o.intValue().toString(t)+s}fromRadix(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),n=Math.pow(e,r),i=!1,o=0,s=0,a=0;a<t.length;++a){var u=ot(t,a);u<0?"-"==t.charAt(a)&&0==this.signum()&&(i=!0):(s=e*s+u,++o>=r&&(this.dMultiply(n),this.dAddOffset(s,0),o=0,s=0))}o>0&&(this.dMultiply(Math.pow(e,o)),this.dAddOffset(s,0)),i&&$.ZERO.subTo(this,this)}fromNumber(t,e,r){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo($.ONE.shiftLeft(t-1),V,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo($.ONE.shiftLeft(t-1),this);else{var n=[],i=7&t;n.length=1+(t>>3),e.nextBytes(n),i>0?n[0]&=(1<<i)-1:n[0]=0,this.fromString(n,256)}}bitwiseTo(t,e,r){var n,i,o=Math.min(t.t,this.t);for(n=0;n<o;++n)r[n]=e(this[n],t[n]);if(t.t<this.t){for(i=t.s&this.DM,n=o;n<this.t;++n)r[n]=e(this[n],i);r.t=this.t}else{for(i=this.s&this.DM,n=o;n<t.t;++n)r[n]=e(i,t[n]);r.t=t.t}r.s=e(this.s,t.s),r.clamp()}changeBit(t,e){var r=$.ONE.shiftLeft(t);return this.bitwiseTo(r,e,r),r}addTo(t,e){for(var r=0,n=0,i=Math.min(t.t,this.t);r<i;)n+=this[r]+t[r],e[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n+=t.s;r<this.t;)n+=this[r],e[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n+=t[r],e[r++]=n&this.DM,n>>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[r++]=n:n<-1&&(e[r++]=this.DV+n),e.t=r,e.clamp()}dMultiply(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()}dAddOffset(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}}multiplyLowerTo(t,e,r){var n=Math.min(this.t+t.t,e);for(r.s=0,r.t=n;n>0;)r[--n]=0;for(var i=r.t-this.t;n<i;++n)r[n+this.t]=this.am(0,t[n],r,n,0,this.t);for(i=Math.min(t.t,e);n<i;++n)this.am(0,t[n],r,n,0,e-n);r.clamp()}multiplyUpperTo(t,e,r){--e;var n=r.t=this.t+t.t-e;for(r.s=0;--n>=0;)r[n]=0;for(n=Math.max(e-this.t,0);n<t.t;++n)r[this.t+n-e]=this.am(e-n,t[n],r,0,0,this.t+n-e);r.clamp(),r.drShiftTo(1,r)}modInt(t){if(t<=0)return 0;var e=this.DV%t,r=this.s<0?t-1:0;if(this.t>0)if(0==e)r=this[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this[n])%t;return r}millerRabin(t){var e=this.subtract($.ONE),r=e.getLowestSetBit();if(r<=0)return!1;var n=e.shiftRight(r);(t=t+1>>1)>p.length&&(t=p.length);for(var i=tt(),o=0;o<t;++o){i.fromInt(p[Math.floor(Math.random()*p.length)]);var s=i.modPow(n,this);if(0!=s.compareTo($.ONE)&&0!=s.compareTo(e)){for(var a=1;a++<r&&0!=s.compareTo(e);)if(0==(s=s.modPowInt(2,this)).compareTo($.ONE))return!1;if(0!=s.compareTo(e))return!1}}return!0}square(){var t=tt();return this.squareTo(t),t}gcda(t,e){var r=this.s<0?this.negate():this.clone(),n=t.s<0?t.negate():t.clone();if(r.compareTo(n)<0){var i=r;r=n,n=i}var o=r.getLowestSetBit(),s=n.getLowestSetBit();if(s<0)e(r);else{o<s&&(s=o),s>0&&(r.rShiftTo(s,r),n.rShiftTo(s,n));var a=()=>{(o=r.getLowestSetBit())>0&&r.rShiftTo(o,r),(o=n.getLowestSetBit())>0&&n.rShiftTo(o,n),r.compareTo(n)>=0?(r.subTo(n,r),r.rShiftTo(1,r)):(n.subTo(r,n),n.rShiftTo(1,n)),r.signum()>0?setTimeout(a,0):(s>0&&n.lShiftTo(s,n),setTimeout(function(){e(n)},0))};setTimeout(a,10)}}fromNumberAsync(t,e,r,n){if("number"==typeof e)if(t<2)this.fromInt(1);else{this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo($.ONE.shiftLeft(t-1),V,this),this.isEven()&&this.dAddOffset(1,0);var i=this,o=function(){i.dAddOffset(2,0),i.bitLength()>t&&i.subTo($.ONE.shiftLeft(t-1),i),i.isProbablePrime(e)?setTimeout(function(){n()},0):setTimeout(o,0)};setTimeout(o,0)}else{var s=[],a=7&t;s.length=1+(t>>3),e.nextBytes(s),a>0?s[0]&=(1<<a)-1:s[0]=0,this.fromString(s,256)}}}var g=function(){function t(){}return t.prototype.convert=function(t){return t},t.prototype.revert=function(t){return t},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},t.prototype.sqrTo=function(t,e){t.squareTo(e)},t}(),m=function(){function t(t){this.m=t}return t.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},t.prototype.revert=function(t){return t},t.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),y=function(){function t(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}return t.prototype.convert=function(t){var e=tt();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo($.ZERO)>0&&this.m.subTo(e,e),e},t.prototype.revert=function(t){var e=tt();return t.copyTo(e),this.reduce(e),e},t.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var r=32767&t[e],n=r*this.mpl+((r*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),_=function(){function t(t){this.m=t,this.r2=tt(),this.q3=tt(),$.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t)}return t.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=tt();return t.copyTo(e),this.reduce(e),e},t.prototype.revert=function(t){return t},t.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}();function tt(){return new $(null)}function et(t,e){return new $(t,e)}function rt(t,e,r,n,i,o){for(;--o>=0;){var s=e*this[t++]+r[n]+i;i=Math.floor(s/67108864),r[n++]=67108863&s}return i}function nt(t,e,r,n,i,o){for(var s=32767&e,a=e>>15;--o>=0;){var u=32767&this[t],c=this[t++]>>15,h=a*u+c*s;i=((u=s*u+((32767&h)<<15)+r[n]+(1073741823&i))>>>30)+(h>>>15)+a*c+(i>>>30),r[n++]=1073741823&u}return i}function it(t,e,r,n,i,o){for(var s=16383&e,a=e>>14;--o>=0;){var u=16383&this[t],c=this[t++]>>14,h=a*u+c*s;i=((u=s*u+((16383&h)<<14)+r[n]+i)>>28)+(h>>14)+a*c,r[n++]=268435455&u}return i}void 0!==i&&"Microsoft Internet Explorer"==(null==i?void 0:i.appName)?($.prototype.am=nt,l=30):"Netscape"!=(null==i?void 0:i.appName)?($.prototype.am=rt,l=26):($.prototype.am=it,l=28),$.prototype.DB=l,$.prototype.DM=(1<<l)-1,$.prototype.DV=1<<l,$.prototype.FV=Math.pow(2,52),$.prototype.F1=52-l,$.prototype.F2=2*l-52;var I,b,w=[];for(I="0".charCodeAt(0),b=0;b<=9;++b)w[I++]=b;for(I="a".charCodeAt(0),b=10;b<36;++b)w[I++]=b;for(I="A".charCodeAt(0),b=10;b<36;++b)w[I++]=b;function ot(t,e){return w[t.charCodeAt(e)]??-1}function st(t){var e=tt();return e.fromInt(t),e}function at(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}$.ZERO=st(0),$.ONE=st(1);class ut{constructor(){this.i=0,this.j=0,this.S=[]}init(t){var e,r,n;for(e=0;e<256;++e)this.S[e]=e;for(r=0,e=0;e<256;++e)r=r+this.S[e]+t[e%t.length]&255,n=this.S[e],this.S[e]=this.S[r],this.S[r]=n;this.i=0,this.j=0}next(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]}}var E,S,A=null;if(null==A){A=[],S=0;var P,O,T=void 0;if("undefined"!=typeof window&&null!==(P=window)&&void 0!==P&&P.crypto&&null!==(O=window)&&void 0!==O&&O.crypto.getRandomValues){var R,C=new Uint32Array(256);for(null===(R=window)||void 0===R||R.crypto.getRandomValues(C),T=0;T<C.length;++T)A[S++]=255&C[T]}var U,N,L,D=function(t){var e,r,n;if(this.count=this.count||0,this.count>=256||S>=256){if("undefined"!=typeof window)if(null!==(e=window)&&void 0!==e&&e.removeEventListener)null===(n=window)||void 0===n||n.removeEventListener("mousemove",D,!1);else if(null!==(r=window)&&void 0!==r&&r.detachEvent){var i;null===(i=window)||void 0===i||i.detachEvent("onmousemove",D)}}else try{var o=t.x+t.y;A[S++]=255&o,this.count+=1}catch(t){}};if("undefined"!=typeof window)if(null!==(U=window)&&void 0!==U&&U.addEventListener)null===(L=window)||void 0===L||L.addEventListener("mousemove",D,!1);else if(null!==(N=window)&&void 0!==N&&N.attachEvent){var k;null===(k=window)||void 0===k||k.attachEvent("onmousemove",D)}}function ct(){if(null==E){for(E=new ut;S<256;){var t=Math.floor(65536*Math.random());A[S++]=255&t}for(E.init(A),S=0;S<A.length;++S)A[S]=0;S=0}return E.next()}class ht{constructor(){}nextBytes(t){for(var e=0;e<t.length;++e)t[e]=ct()}}function lt(t,e){if(e<t.length+11)return console.error("Message too long for RSA"),null;for(var r=[],n=t.length-1;n>=0&&e>0;){var i=t.charCodeAt(n--);i<128?r[--e]=i:i>127&&i<2048?(r[--e]=63&i|128,r[--e]=i>>6|192):(r[--e]=63&i|128,r[--e]=i>>6&63|128,r[--e]=i>>12|224)}r[--e]=0;for(var o=new ht,s=[];e>2;){for(s[0]=0;0==s[0];)o.nextBytes(s);r[--e]=s[0]}return r[--e]=2,r[--e]=0,new $(r)}class dt{constructor(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}doPublic(t){return t.modPowInt(this.e,this.n)}doPrivate(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),r=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(r)<0;)e=e.add(this.p);return e.subtract(r).multiply(this.coeff).mod(this.p).multiply(this.q).add(r)}setPublic(t,e){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=et(t,16),this.e=parseInt(e,16)):console.error("Invalid RSA public key")}encrypt(t){var e=lt(t,this.n.bitLength()+7>>3);if(null==e)return null;var r=this.doPublic(e);if(null==r)return null;var n=r.toString(16);return 1&n.length?"0"+n:n}encryptLong(t){var e=this,r=(this.n.bitLength()+7>>3)-11;try{var n="";return t.length>r?(t.match(/.{1,117}/g).forEach(function(t){var r=e.encrypt(t);n+=r}),K(n)):K(this.encrypt(t))}catch(t){return!1}}decryptLong(t){var e=this,r=this.n.bitLength()+7>>3;t=Y(t);try{if(t.length>r){var n="";return t.match(/.{1,256}/g).forEach(function(t){var r=e.decrypt(t);n+=r}),n}return this.decrypt(t)}catch(t){return!1}}setPrivate(t,e,r){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=et(t,16),this.e=parseInt(e,16),this.d=et(r,16)):console.error("Invalid RSA private key")}setPrivateEx(t,e,r,n,i,o,s,a){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=et(t,16),this.e=parseInt(e,16),this.d=et(r,16),this.p=et(n,16),this.q=et(i,16),this.dmp1=et(o,16),this.dmq1=et(s,16),this.coeff=et(a,16)):console.error("Invalid RSA private key")}generate(t,e){var r=new ht,n=t>>1;this.e=parseInt(e,16);for(var i=new $(e,16);;){for(;this.p=new $(t-n,1,r),0!=this.p.subtract($.ONE).gcd(i).compareTo($.ONE)||!this.p.isProbablePrime(10););for(;this.q=new $(n,1,r),0!=this.q.subtract($.ONE).gcd(i).compareTo($.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var o=this.p;this.p=this.q,this.q=o}var s=this.p.subtract($.ONE),a=this.q.subtract($.ONE),u=s.multiply(a);if(0==u.gcd(i).compareTo($.ONE)){this.n=this.p.multiply(this.q),this.d=i.modInverse(u),this.dmp1=this.d.mod(s),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}}decrypt(t){var e=et(t,16),r=this.doPrivate(e);return null==r?null:ft(r,this.n.bitLength()+7>>3)}generateAsync(t,e,r){var n=new ht,i=t>>1;this.e=parseInt(e,16);var o=new $(e,16),s=this,a=()=>{var e=()=>{if(s.p.compareTo(s.q)<=0){var t=s.p;s.p=s.q,s.q=t}var e=s.p.subtract($.ONE),n=s.q.subtract($.ONE),i=e.multiply(n);0==i.gcd(o).compareTo($.ONE)?(s.n=s.p.multiply(s.q),s.d=o.modInverse(i),s.dmp1=s.d.mod(e),s.dmq1=s.d.mod(n),s.coeff=s.q.modInverse(s.p),setTimeout(function(){r()},0)):setTimeout(a,0)},u=()=>{s.q=tt(),s.q.fromNumberAsync(i,1,n,function(){s.q.subtract($.ONE).gcda(o,function(t){0==t.compareTo($.ONE)&&s.q.isProbablePrime(10)?setTimeout(e,0):setTimeout(u,0)})})},c=()=>{s.p=tt(),s.p.fromNumberAsync(t-i,1,n,function(){s.p.subtract($.ONE).gcda(o,function(t){0==t.compareTo($.ONE)&&s.p.isProbablePrime(10)?setTimeout(u,0):setTimeout(c,0)})})};setTimeout(c,0)};setTimeout(a,0)}}function ft(t,e){for(var r=t.toByteArray(),n=0;n<r.length&&0==r[n];)++n;if(r.length-n!=e-1||2!=r[n])return null;for(++n;0!=r[n];)if(++n>=r.length)return null;for(var i="";++n<r.length;){var o=255&r[n];o<128?i+=String.fromCharCode(o):o>191&&o<224?(i+=String.fromCharCode((31&o)<<6|63&r[n+1]),++n):(i+=String.fromCharCode((15&o)<<12|(63&r[n+1])<<6|63&r[n+2]),n+=2)}return i}class pt extends dt{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";super(),t&&("string"==typeof t?this.parseKey(t):(this.hasPrivateKeyProperty(t)||this.hasPublicKeyProperty(t))&&this.parsePropertiesFrom(t))}parseKey(t){try{var e=0,r=0,n=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(t)?u.decode(t):c.unarmor(t),i=Z.decode(n);if(3===i.sub.length&&(i=i.sub[2].sub[0]),9===i.sub.length){e=i.sub[1].getHexStringValue(),this.n=et(e,16),r=i.sub[2].getHexStringValue(),this.e=parseInt(r,16);var o=i.sub[3].getHexStringValue();this.d=et(o,16);var s=i.sub[4].getHexStringValue();this.p=et(s,16);var a=i.sub[5].getHexStringValue();this.q=et(a,16);var h=i.sub[6].getHexStringValue();this.dmp1=et(h,16);var l=i.sub[7].getHexStringValue();this.dmq1=et(l,16);var d=i.sub[8].getHexStringValue();this.coeff=et(d,16)}else{if(2!==i.sub.length)return!1;var f=i.sub[1].sub[0];e=f.sub[0].getHexStringValue(),this.n=et(e,16),r=f.sub[1].getHexStringValue(),this.e=parseInt(r,16)}return!0}catch(t){return!1}}hasPublicKeyProperty(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")}hasPrivateKeyProperty(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")&&t.hasOwnProperty("d")&&t.hasOwnProperty("p")&&t.hasOwnProperty("q")&&t.hasOwnProperty("dmp1")&&t.hasOwnProperty("dmq1")&&t.hasOwnProperty("coeff")}parsePropertiesFrom(t){this.n=t.n,this.e=t.e,t.hasOwnProperty("d")&&(this.d=t.d,this.p=t.p,this.q=t.q,this.dmp1=t.dmp1,this.dmq1=t.dmq1,this.coeff=t.coeff)}}(n=function(t){t=t||{},this.default_key_size=parseInt(t.default_key_size,10)||1024,this.default_public_exponent=t.default_public_exponent||"010001",this.log=t.log||!1,this.key=null}).prototype.setKey=function(t){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new pt(t)},n.prototype.setPrivateKey=function(t){this.setKey(t)},n.prototype.setPublicKey=function(t){this.setKey(t)},n.prototype.decrypt=function(t){try{return this.getKey().decrypt(Y(t))}catch(t){return!1}},n.prototype.encrypt=function(t){try{return K(this.getKey().encrypt(t))}catch(t){return!1}},n.prototype.encryptLong=function(t){try{for(var e=this.getKey().encryptLong(t)||"",r=this.getKey().decryptLong(e)||"",n=0,i=/null$/g;i.test(r)&&(n++,e=this.getKey().encryptLong(t)||"",r=this.getKey().decryptLong(e)||"",!(n>10)););return e}catch(t){return!1}},n.prototype.getKey=function(t){if(!this.key){if(this.key=new pt,t&&"[object Function]"==={}.toString.call(t))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,t);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},n.version="3.1.4"}const x=n;var M=r(631),q=function(t){var e=void 0===t?{}:t,r=e.publicKey,n=void 0===r?"":r,i=e.payload,o=void 0===i?{}:i;if(!n)return"";try{var s=(0,M.I)(o),a=new x;return a.setPublicKey(n),a.encryptLong("object"==typeof s?JSON.stringify(s):s)}catch(t){console.error("encrypt error:",t)}return""}},631:(t,e,r)=>{r.d(e,{I:()=>n,y:()=>i});var n=function(t){var e=function(e){for(var r in t)t.hasOwnProperty(r)&&(e[r]=n(t[r]));return e},r=null==t?"NullOrUndefined":Object.prototype.toString.call(t).slice(8,-1);if(["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"].includes(r))return t.slice();switch(r){case"Object":return e(Object.create(Object.getPrototypeOf(t)));case"Array":return e([]);case"Date":return new Date(t.valueOf());case"RegExp":return new RegExp(t.source,(t.global?"g":"")+(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.sticky?"y":"")+(t.unicode?"u":""));default:return t}},i=function(t){var e=t.match(/^(?:http(s)?:\/\/[^\/]+)?(\/[^\?#]*)/);return e&&e[2]||""}},182:function(t,e,r){var n=this&&this.__assign||function(){return n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},n.apply(this,arguments)},i=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&i(e,t,r);return o(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.useDefaultAdapter=e.useAdapters=e.RUNTIME=void 0;var a,u=s(r(274)),c=r(616);!function(t){t.WEB="web",t.WX_MP="wx_mp"}(a=e.RUNTIME||(e.RUNTIME={})),e.useAdapters=function(t,e){for(var r=0,i=(0,c.isArray)(t)?t:[t];r<i.length;r++){var o=i[r],s=o.isMatch,a=o.genAdapter,u=o.runtime;if(s())return{adapter:n({isMatch:s},a(e)),runtime:u}}},e.useDefaultAdapter=function(){return{adapter:n({},u.genAdapter()),runtime:a.WEB}}},274:function(t,e,r){var n,i=this&&this.__extends||(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),o=this&&this.__assign||function(){return o=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},o.apply(this,arguments)},s=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))(function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(s,a)}u((n=n.apply(t,e||[])).next())})},a=this&&this.__generator||function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=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(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.WebRequest=e.genAdapter=void 0;var u=r(149),c=r(616),h=r(946),l=function(t){function e(e){var r=t.call(this)||this,n=e.timeout,i=e.timeoutMsg,o=e.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=i||"请求超时",r.restrictedMethods=o||["get","post","upload","download"],r}return i(e,t),e.prototype.get=function(t){return this.request(o(o({},t),{method:"get"}),this.restrictedMethods.includes("get"))},e.prototype.post=function(t){return this.request(o(o({},t),{method:"post"}),this.restrictedMethods.includes("post"))},e.prototype.put=function(t){return this.request(o(o({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,r=t.file,n=t.name,i=t.method,s=t.headers,a=void 0===s?{}:s,u={post:"post",put:"put"}[null==i?void 0:i.toLowerCase()]||"put",c=new FormData;return"post"===u?(Object.keys(e).forEach(function(t){c.append(t,e[t])}),c.append("key",n),c.append("file",r),this.request(o(o({},t),{data:c,method:u}),this.restrictedMethods.includes("upload"))):this.request(o(o({},t),{method:"put",headers:a,body:r}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return s(this,void 0,void 0,function(){var e,r,n,i;return a(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.get(o(o({},t),{headers:{},responseType:"blob"}))];case 1:return e=s.sent().data,r=window.URL.createObjectURL(new Blob([e])),n=decodeURIComponent(new URL(t.url).pathname.split("/").pop()||""),(i=document.createElement("a")).href=r,i.setAttribute("download",n),i.style.display="none",document.body.appendChild(i),i.click(),window.URL.revokeObjectURL(r),document.body.removeChild(i),[3,3];case 2:return s.sent(),[3,3];case 3:return[2,new Promise(function(e){e({statusCode:200,tempFilePath:t.url})})]}})})},e.prototype.fetch=function(t){var e;return s(this,void 0,void 0,function(){var r,n,i,u,c,h,l,d,f,p,v,g,m,y=this;return a(this,function(_){switch(_.label){case 0:return r=new AbortController,n=t.url,i=t.enableAbort,u=void 0!==i&&i,c=t.stream,h=void 0!==c&&c,l=t.signal,d=t.timeout,f=t.shouldThrowOnError,p=void 0===f||f,v=null!=d?d:this.timeout,l&&(l.aborted&&r.abort(),l.addEventListener("abort",function(){return r.abort()})),g=null,u&&v&&(g=setTimeout(function(){console.warn(y.timeoutMsg),r.abort(new Error(y.timeoutMsg))},v)),[4,fetch(n,o(o({},t),{signal:r.signal})).then(function(t){return s(y,void 0,void 0,function(){var e,r,n;return a(this,function(i){switch(i.label){case 0:return clearTimeout(g),p?t.ok?(e=t,[3,3]):[3,1]:[3,4];case 1:return n=(r=Promise).reject,[4,t.json()];case 2:e=n.apply(r,[i.sent()]),i.label=3;case 3:return[2,e];case 4:return[2,t]}})})}).catch(function(t){return clearTimeout(g),Promise.reject(t)})];case 1:return m=_.sent(),[2,{data:h?m.body:(null===(e=m.headers.get("content-type"))||void 0===e?void 0:e.includes("application/json"))?m.json():m.text(),statusCode:m.status,header:m.headers,response:m}]}})})},e.prototype.request=function(t,e){var r=this;void 0===e&&(e=!1);var n=String(t.method).toLowerCase()||"get";return new Promise(function(i){var o=t.url,s=t.headers,a=void 0===s?{}:s,u=t.data,l=t.responseType,d=t.withCredentials,f=t.body,p=t.onUploadProgress,v=(0,c.formatUrl)((0,h.getProtocol)(),o,"get"===n?u:{}),g=new XMLHttpRequest;g.open(n,v),l&&(g.responseType=l);var m,y,_=t.signal;_&&(_.aborted?g.abort():_.addEventListener("abort",function(){return g.abort()},{once:!0})),Object.keys(a).forEach(function(t){g.setRequestHeader(t,a[t])}),p&&g.upload.addEventListener("progress",p),g.onreadystatechange=function(){var t={};if(4===g.readyState){var e=g.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};e.forEach(function(t){var e=t.split(": "),n=e.shift().toLowerCase(),i=e.join(": ");r[n]=i}),t.header=r,t.statusCode=g.status;try{t.data="blob"===l?g.response:JSON.parse(g.responseText)}catch(e){t.data="blob"===l?g.response:g.responseText}clearTimeout(m),i(t)}},e&&r.timeout&&(m=setTimeout(function(){console.warn(r.timeoutMsg),g.abort()},r.timeout)),y=(0,c.isFormData)(u)?u:"application/x-www-form-urlencoded"===a["content-type"]?(0,c.toQueryString)(u):f||(u?JSON.stringify(u):void 0),d&&(g.withCredentials=!0),g.send(y)})},e}(u.AbstractSDKRequest);e.WebRequest=l,e.genAdapter=function(){return{type:"default",root:window,reqClass:l,wsClass:WebSocket,localStorage}}},946:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.COMMUNITY_SITE_URL=e.IS_DEBUG_MODE=e.getProtocol=e.setProtocol=e.getSdkName=e.setSdkName=void 0;var r="@cloudbase/js-sdk";e.setSdkName=function(t){r=t},e.getSdkName=function(){return r};var n="https:";e.setProtocol=function(t){n=t},e.getProtocol=function(){return n},e.IS_DEBUG_MODE=!1,e.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},205:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ERRORS=void 0,e.ERRORS={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"}},794:function(t,e,r){var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.OATUH_LOGINTYPE=void 0,i(r(946),e),i(r(205),e),e.OATUH_LOGINTYPE="constants"},718:function(t,e,r){var n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))(function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(s,a)}u((n=n.apply(t,e||[])).next())})},i=this&&this.__generator||function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=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(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.catchErrorsDecorator=void 0;var o=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 h(t){var e=t.err,r=t.className,n=t.methodName,i=t.sourceLink;if(!i)return null;var o,s=e.stack.split("\n"),u=a?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]\\s*\\(.*\\)$")),h=a?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]")),l=s.findIndex(function(t){return u.test(t)});if(-1!==l){var d=s.filter(function(t,e){return e>l});d.unshift(s[l].replace(h,"".concat(r,".").concat(n)).replace(c,i)),(o=new Error).stack="".concat(a?"@debugger":"Error","\n").concat(d.join("\n"))}return o}e.catchErrorsDecorator=function(t){var e=t.mode,r=void 0===e?"async":e,a=t.customInfo,l=void 0===a?{}:a,d=t.title,f=t.messages,p=void 0===f?[]:f;return function(t,e,a){if(s.IS_DEBUG_MODE){var f=l.className||t.constructor.name,v=l.methodName||e,g=a.value,m=function(){var t="",e=(new Error).stack.split("\n"),r=e.findIndex(function(t){return u.test(t)});if(-1!==r){var n=c.exec(e[r+1]||"");t=n?n[0]:""}return t}();a.value="sync"===r?function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=h({err:new Error,className:f,methodName:v,sourceLink:m});try{return g.apply(this,t)}catch(t){var n=t,i=t.message,s=t.error,a=t.error_description,u={title:d||"".concat(f,".").concat(v," failed"),content:[{type:"error",body:t}]};if(i&&/^\{.*\}$/.test(i)){var c=JSON.parse(i);u.subtitle=i,c.code&&(r?(r.code=c.code,r.msg=c.msg):(t.code=c.code,t.message=c.msg),n=r||t,u.content=p.map(function(t){return{type:"info",body:t}}))}throw s&&a&&(u.subtitle=a,r?(r.code=s,r.msg=a):(t.code=s,t.message=a),n=r||t,u.content=p.map(function(t){return{type:"info",body:t}})),(0,o.printGroupLog)(u),n}}:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n(this,void 0,void 0,function(){var e,r,n,s,a,u,c,l;return i(this,function(i){switch(i.label){case 0:e=h({err:new Error,className:f,methodName:v,sourceLink:m}),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,g.apply(this,t)];case 2:return[2,i.sent()];case 3:throw r=i.sent(),n=r,s=r.message,a=r.error,u=r.error_description,c={title:d||"".concat(f,".").concat(v," failed"),content:[{type:"error",body:r}]},s&&/^\{.*\}$/.test(s)&&(l=JSON.parse(s),c.subtitle=l,l.code&&(e?(e.code=l.code,e.message=l.msg):(r.code=l.code,r.message=l.msg),n=e||r,c.content=p.map(function(t){return{type:"info",body:t}}))),a&&u&&(c.subtitle=u,e?(e.code=a,e.msg=u):(r.code=a,r.message=u),n=e||r,c.content=p.map(function(t){return{type:"info",body:t}})),(0,o.printGroupLog)(c),n;case 4:return[2]}})})}}}}},141:function(t,e,r){var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),i(r(718),e)},197:function(t,e,r){var n,i=this&&this.__extends||(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),o=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))(function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(s,a)}u((n=n.apply(t,e||[])).next())})},s=this&&this.__generator||function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=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(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.CloudbaseCache=void 0;var a=r(149),u=r(616),c=r(794),h=function(t){function e(e){var r=t.call(this)||this;return r.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),r}return i(e,t),e.prototype.setItem=function(t,e){this.root.tcbCacheObject[t]=e},e.prototype.getItem=function(t){return this.root.tcbCacheObject[t]},e.prototype.removeItem=function(t){delete this.root.tcbCacheObject[t]},e.prototype.clear=function(){delete this.root.tcbCacheObject},e}(a.AbstractStorage),l=function(){function t(t){this.keys={};var e=t.persistence,r=t.platformInfo,n=void 0===r?{}:r,i=t.keys,o=void 0===i?{}:i;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||e,this.storage=function(t,e){switch(t){case"local":default:return e.localStorage?e.localStorage:((0,u.printWarn)(c.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new h(e.root));case"none":return new h(e.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=o)}return Object.defineProperty(t.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),t.prototype.setStore=function(t,e,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(n))}catch(t){throw new Error(JSON.stringify({code:c.ERRORS.OPERATION_FAIL,msg:"[".concat((0,c.getSdkName)(),"][").concat(c.ERRORS.OPERATION_FAIL,"]setStore failed"),info:t}))}}else(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,r){return o(this,void 0,void 0,function(){var n;return s(this,function(i){switch(i.label){case 0:if(!this.storage)return[2];i.label=1;case 1:return i.trys.push([1,3,,4]),n={version:r||"localCachev1",content:e},[4,this.storage.setItem(t,JSON.stringify(n))];case 2:return i.sent(),[3,4];case 3:return i.sent(),[2];case 4:return[2]}})})},t.prototype.getStore=function(t,e){var r;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(t){return""}e=e||"localCachev1";var n=this.storage.getItem(t);return n&&n.indexOf(e)>=0?JSON.parse(n).content:""}(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){var r;return o(this,void 0,void 0,function(){var n;return s(this,function(i){switch(i.label){case 0:try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return[2,{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(t){return[2,""]}return e=e||"localCachev1",[4,this.storage.getItem(t)];case 1:return(n=i.sent())&&n.indexOf(e)>=0?[2,JSON.parse(n).content]:[2,""]}})})},t.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},t.prototype.removeStoreAsync=function(t){return o(this,void 0,void 0,function(){return s(this,function(e){switch(e.label){case 0:return[4,this.storage.removeItem(t)];case 1:return e.sent(),[2]}})})},t}();e.CloudbaseCache=l},689:function(t,e,r){var n,i=this&&this.__extends||(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),o=this&&this.__spreadArray||function(t,e,r){if(r||2===arguments.length)for(var n,i=0,o=e.length;i<o;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))};Object.defineProperty(e,"__esModule",{value:!0}),e.removeEventListener=e.activateEvent=e.addEventListener=e.CloudbaseEventEmitter=e.IErrorEvent=e.CloudbaseEvent=void 0;var s=r(616),a=function(t,e){this.data=e||null,this.name=t};e.CloudbaseEvent=a;var u=function(t){function e(e,r){var n=t.call(this,"error",{error:e,data:r})||this;return n.error=e,n}return i(e,t),e}(a);e.IErrorEvent=u;var c=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){return function(t,e,r){r[t]=r[t]||[],r[t].push(e)}(t,e,this.listeners),this},t.prototype.off=function(t,e){return function(t,e,r){if(null==r?void 0:r[t]){var n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if((0,s.isInstanceOf)(t,u))return console.error(t.error),this;var r=(0,s.isString)(t)?new a(t,e||{}):t,n=r.name;if(this.listens(n)){r.target=this;for(var i=0,c=this.listeners[n]?o([],this.listeners[n],!0):[];i<c.length;i++)c[i].call(this,r)}return this},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}();e.CloudbaseEventEmitter=c;var h=new c;e.addEventListener=function(t,e){h.on(t,e)},e.activateEvent=function(t,e){void 0===e&&(e={}),h.fire(t,e)},e.removeEventListener=function(t,e){h.off(t,e)}},616:function(t,e,r){var n=this&&this.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]])}return r};Object.defineProperty(e,"__esModule",{value:!0}),e.parseCaptcha=e.parseQueryString=e.transformPhone=e.sleep=e.printGroupLog=e.throwError=e.printInfo=e.printError=e.printWarn=e.execCallback=e.createPromiseCallback=e.removeParam=e.getHash=e.getQuery=e.toQueryString=e.formatUrl=e.generateRequestId=e.genSeqId=e.isFormData=e.isInstanceOf=e.isNull=e.isPalinObject=e.isUndefined=e.isString=e.isArray=void 0;var i=r(794);e.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},e.isString=function(t){return"string"==typeof t},e.isUndefined=function(t){return void 0===t},e.isPalinObject=function(t){return"[object Object]"===Object.prototype.toString.call(t)},e.isNull=function(t){return"[object Null]"===Object.prototype.toString.call(t)},e.isInstanceOf=function(t,e){return t instanceof e},e.isFormData=function(t){return"[object FormData]"===Object.prototype.toString.call(t)},e.genSeqId=function(){return Math.random().toString(16).slice(2)},e.generateRequestId=function(){var t=(new Date).getTime(),e=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){var n=16*Math.random();return t>0?(n=(t+n)%16|0,t=Math.floor(t/16)):(n=(e+n)%16|0,e=Math.floor(e/16)),("x"===r?n:7&n|8).toString(16)})},e.formatUrl=function(t,e,r){void 0===r&&(r={});var n=/\?/.test(e),i="";return Object.keys(r).forEach(function(t){""===i?!n&&(e+="?"):i+="&",i+="".concat(t,"=").concat(encodeURIComponent(r[t]))}),/^http(s)?:\/\//.test(e+=i)?e:"".concat(t).concat(e)},e.toQueryString=function(t){void 0===t&&(t={});var e=[];return Object.keys(t).forEach(function(r){e.push("".concat(r,"=").concat(encodeURIComponent(t[r])))}),e.join("&")},e.getQuery=function(t,e){if("undefined"==typeof window)return!1;var r=e||decodeURIComponent(window.location.search),n=new RegExp("(^|&)".concat(t,"=([^&]*)(&|$)")),i=r.substr(r.indexOf("?")+1).match(n);return null!=i?i[2]:""},e.getHash=function(t){if("undefined"==typeof window)return"";var e=window.location.hash.match(new RegExp("[#?&/]".concat(t,"=([^&#]*)")));return e?e[1]:""},e.removeParam=function(t,e){var r=e.split("?")[0],n=[],i=-1!==e.indexOf("?")?e.split("?")[1]:"";if(""!==i){for(var o=(n=i.split("&")).length-1;o>=0;o-=1)n[o].split("=")[0]===t&&n.splice(o,1);r="".concat(r,"?").concat(n.join("&"))}return r},e.createPromiseCallback=function(){var t={};if(!Promise){(t=function(){}).promise={};var e=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(t.promise,"then",{get:e}),Object.defineProperty(t.promise,"catch",{get:e}),t}var r=new Promise(function(e,r){t=function(t,n){return t?r(t):e(n)}});return t.promise=r,t},e.execCallback=function(t,e,r){if(void 0===r&&(r=null),t&&"function"==typeof t)return t(e,r);if(e)throw e;return r},e.printWarn=function(t,e){console.warn("[".concat((0,i.getSdkName)(),"][").concat(t,"]:").concat(e))},e.printError=function(t,e){console.error({code:t,msg:"[".concat((0,i.getSdkName)(),"][").concat(t,"]:").concat(e)})},e.printInfo=function(t,e){console.log("[".concat((0,i.getSdkName)(),"][").concat(t,"]:").concat(e))},e.throwError=function(t,e){throw new Error(JSON.stringify({code:t,msg:"[".concat((0,i.getSdkName)(),"][").concat(t,"]:").concat(e)}))},e.printGroupLog=function(t){var e,r=t.title,n=t.subtitle,i=void 0===n?"":n,o=t.content,s=void 0===o?[]:o,a=t.printTrace,u=void 0!==a&&a,c=t.collapsed;void 0!==c&&c?(console.groupCollapsed||console.error)(r,i):(console.group||console.error)(r,i);for(var h=0,l=s;h<l.length;h++){var d=l[h],f=d.type,p=d.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===(e=console.groupEnd)||void 0===e||e.call(console)},e.sleep=function(t){return void 0===t&&(t=0),new Promise(function(e){return setTimeout(e,t)})},e.transformPhone=function(t){return"+86".concat(t)},e.parseQueryString=function(t){t=t.replace(/^\?/,"");var e={};return t.split("&").forEach(function(t){var r=t.split("="),n=r[0],i=r[1];n=decodeURIComponent(n),i=decodeURIComponent(i),n&&(e[n]?Array.isArray(e[n])?e[n].push(i):e[n]=[e[n],i]:e[n]=i)}),e},e.parseCaptcha=function(t){var r={},i=t.match(/^(data:.*?)(\?[^#\s]*)?$/);if(i){t=i[1];var o=i[2];o&&(r=(0,e.parseQueryString)(o))}var s=r.token,a=n(r,["token"]);return/^data:/.test(t)&&!s?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(t)}:s?{state:a.state,token:s,captchaData:t}:{error:"unimplemented",error_description:"need to impl captcha data"}}},149:e=>{e.exports=t}},i={};function o(t){var e=i[t];if(void 0!==e)return e.exports;var r=i[t]={exports:{}};return n[t].call(r.exports,r,r.exports,o),r.exports}o.d=(t,e)=>{for(var r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var s={};(()=>{o.d(s,{W:()=>Ee});var t={};o.r(t);var n,i,a,u,c,h,l="/auth";!function(t){t.AUTH_SIGN_UP_URL="/v1/signup",t.AUTH_TOKEN_URL="/v1/token",t.AUTH_REVOKE_URL="/v1/revoke",t.WEDA_USER_URL="/v1/plugin/weda/userinfo",t.AUTH_RESET_PASSWORD="/v1/reset",t.AUTH_GET_DEVICE_CODE="/v1/device/code",t.CHECK_USERNAME="/v1/checkUsername",t.CHECK_IF_USER_EXIST="/v1/checkIfUserExist",t.GET_PROVIDER_TYPE="/v1/mgr/provider/providerSubType",t.AUTH_SIGN_IN_URL="/v1/signin",t.AUTH_SIGN_IN_ANONYMOUSLY_URL="/v1/signin/anonymously",t.AUTH_SIGN_IN_WITH_PROVIDER_URL="/v1/signin/with/provider",t.AUTH_SIGN_IN_WITH_WECHAT_URL="/v1/signin/wechat/noauth",t.AUTH_SIGN_IN_CUSTOM="/v1/signin/custom",t.PROVIDER_TOKEN_URL="/v1/provider/token",t.PROVIDER_URI_URL="/v1/provider/uri",t.USER_ME_URL="/v1/user/me",t.AUTH_SIGNOUT_URL="/v1/user/signout",t.USER_QUERY_URL="/v1/user/query",t.USER_PRIFILE_URL="/v1/user/profile",t.USER_BASIC_EDIT_URL="/v1/user/basic/edit",t.USER_TRANS_BY_PROVIDER_URL="/v1/user/trans/by/provider",t.PROVIDER_LIST="/v1/user/provider",t.PROVIDER_BIND_URL="/v1/user/provider/bind",t.PROVIDER_UNBIND_URL="/v1/user/provider",t.CHECK_PWD_URL="/v1/user/sudo",t.SUDO_URL="/v1/user/sudo",t.BIND_CONTACT_URL="/v1/user/contact",t.AUTH_SET_PASSWORD="/v1/user/password",t.AUTHORIZE_DEVICE_URL="/v1/user/device/authorize",t.AUTHORIZE_URL="/v1/user/authorize",t.AUTHORIZE_INFO_URL="/v1/user/authorize/info",t.AUTHORIZED_DEVICES_DELETE_URL="/v1/user/authorized/devices/",t.AUTH_REVOKE_ALL_URL="/v1/user/revoke/all",t.GET_USER_BEHAVIOR_LOG="/v1/user/security/history",t.VERIFICATION_URL="/v1/verification",t.VERIFY_URL="/v1/verification/verify",t.CAPTCHA_DATA_URL="/v1/captcha/data",t.VERIFY_CAPTCHA_DATA_URL="/v1/captcha/data/verify",t.GET_CAPTCHA_URL="/v1/captcha/init",t.GET_MINIPROGRAM_QRCODE="/v1/qrcode/generate",t.GET_MINIPROGRAM_QRCODE_STATUS="/v1/qrcode/get/status"}(n||(n={})),function(t){t.AUTH_SIGN_IN_URL="/v2/signin/username",t.AUTH_TOKEN_URL="/v2/token",t.USER_ME_URL="/v2/user/me",t.VERIFY_URL="/v2/signin/verificationcode",t.AUTH_SIGN_IN_WITH_PROVIDER_URL="/v2/signin/with/provider",t.AUTH_PUBLIC_KEY="/v2/signin/publichkey",t.AUTH_RESET_PASSWORD="/v2/signin/password/update"}(i||(i={})),function(t){t.REGISTER="REGISTER",t.SIGN_IN="SIGN_IN",t.PASSWORD_RESET="PASSWORD_RESET",t.EMAIL_ADDRESS_CHANGE="EMAIL_ADDRESS_CHANGE",t.PHONE_NUMBER_CHANGE="PHONE_NUMBER_CHANGE"}(a||(a={})),(h=u||(u={})).UNREACHABLE="unreachable",h.LOCAL="local",h.CANCELLED="cancelled",h.UNKNOWN="unknown",h.UNAUTHENTICATED="unauthenticated",h.RESOURCE_EXHAUSTED="resource_exhausted",h.FAILED_PRECONDITION="failed_precondition",h.INVALID_ARGUMENT="invalid_argument",h.DEADLINE_EXCEEDED="deadline_exceeded",h.NOT_FOUND="not_found",h.ALREADY_EXISTS="already_exists",h.PERMISSION_DENIED="permission_denied",h.ABORTED="aborted",h.OUT_OF_RANGE="out_of_range",h.UNIMPLEMENTED="unimplemented",h.INTERNAL="internal",h.UNAVAILABLE="unavailable",h.DATA_LOSS="data_loss",h.INVALID_PASSWORD="invalid_password",h.PASSWORD_NOT_SET="password_not_set",h.INVALID_STATUS="invalid_status",h.USER_PENDING="user_pending",h.USER_BLOCKED="user_blocked",h.INVALID_VERIFICATION_CODE="invalid_verification_code",h.TWO_FACTOR_REQUIRED="two_factor_required",h.INVALID_TWO_FACTOR="invalid_two_factor",h.INVALID_TWO_FACTOR_RECOVERY="invalid_two_factor_recovery",h.UNDER_REVIEW="under_review",h.INVALID_REQUEST="invalid_request",h.UNAUTHORIZED_CLIENT="unauthorized_client",h.ACCESS_DENIED="access_denied",h.UNSUPPORTED_RESPONSE_TYPE="unsupported_response_type",h.INVALID_SCOPE="invalid_scope",h.INVALID_GRANT="invalid_grant",h.SERVER_ERROR="server_error",h.TEMPORARILY_UNAVAILABLE="temporarily_unavailable",h.INTERACTION_REQUIRED="interaction_required",h.LOGIN_REQUIRED="login_required",h.ACCOUNT_SELECTION_REQUIRED="account_selection_required",h.CONSENT_REQUIRED="consent_required",h.INVALID_REQUEST_URI="invalid_request_uri",h.INVALID_REQUEST_OBJECT="invalid_request_object",h.REQUEST_NOT_SUPPORTED="request_not_supported",h.REQUEST_URI_NOT_SUPPORTED="request_uri_not_supported",h.REGISTRATION_NOT_SUPPORTED="registration_not_supported",h.CAPTCHA_REQUIRED="captcha_required",h.CAPTCHA_INVALID="captcha_invalid",h.PROVIDER_NOT_ENABLED="provider_not_enabled",h.LOGIN_METHOD_DISABLED="login_method_disabled",h.INVALID_USERNAME_OR_PASSWORD="invalid_username_or_password",h.INVALID_CREDENTIALS="invalid_credentials",h.WRONG_PASSWORD="wrong_password",h.USER_NOT_FOUND="user_not_found",h.MFA_PHONE_REQUIRED="mfa_phone_required",h.LOGIN_TYPE_DISABLED="login_type_disabled",h.PROVIDER_ERROR="provider_error",function(t){t[t.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",t[t.NOT_FOUND=5]="NOT_FOUND",t[t.PERMISSION_DENIED=7]="PERMISSION_DENIED",t[t.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",t[t.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",t[t.ABORTED=10]="ABORTED",t[t.UNIMPLEMENTED=12]="UNIMPLEMENTED",t[t.INTERNAL=13]="INTERNAL",t[t.UNAVAILABLE=14]="UNAVAILABLE",t[t.UNAUTHENTICATED=16]="UNAUTHENTICATED",t[t.CAPTCHA_REQUIRED=4001]="CAPTCHA_REQUIRED",t[t.CAPTCHA_INVALID=4002]="CAPTCHA_INVALID",t[t.PROVIDER_ERROR=4019]="PROVIDER_ERROR",t[t.UNAUTHORIZED_CLIENT=4022]="UNAUTHORIZED_CLIENT",t[t.MFA_PHONE_REQUIRED=4042]="MFA_PHONE_REQUIRED",t[t.LOGIN_TYPE_DISABLED=4045]="LOGIN_TYPE_DISABLED"}(c||(c={}));var d,f="credentials_error",p="SIGNED_OUT",v="SIGNED_IN",g="TOKEN_REFRESHED",m="USER_UPDATED",y="BIND_IDENTITY",_="loginStateChanged",I="authStateChanged",b="sign_in",w="bind_identity",E="node-sdk-scope";function S(){return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})}!function(t){t.CLIENT_ID="client_id",t.CLIENT_SECRET="client_secret",t.RESPONSE_TYPE="response_type",t.SCOPE="scope",t.STATE="state",t.REDIRECT_URI="redirect_uri",t.ERROR="error",t.ERROR_DESCRIPTION="error_description",t.ERROR_URI="error_uri",t.GRANT_TYPE="grant_type",t.CODE="code",t.ACCESS_TOKEN="access_token",t.TOKEN_TYPE="token_type",t.EXPIRES_IN="expires_in",t.USERNAME="username",t.PASSWORD="password",t.REFRESH_TOKEN="refresh_token"}(d||(d={}));var A=o(631),P=function(t,e,r,n){return new(r||(r=Promise))(function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(s,a)}u((n=n.apply(t,e||[])).next())})},O=function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=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(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},T=new Map,R=function(){function t(t){this.clientId=(null==t?void 0:t.clientId)||"",T=T||new Map}return t.prototype.run=function(t,e){return P(this,void 0,Promise,function(){var r,n=this;return O(this,function(i){return t="".concat(this.clientId,"_").concat(t),(r=T.get(t))||(r=new Promise(function(r,i){P(n,void 0,void 0,function(){var n,o,s;return O(this,function(a){switch(a.label){case 0:return a.trys.push([0,3,4,5]),[4,this.runIdlePromise()];case 1:return a.sent(),n=e(),o=r,[4,n];case 2:return o.apply(void 0,[a.sent()]),[3,5];case 3:return s=a.sent(),i(s),[3,5];case 4:return T.delete(t),[7];case 5:return[2]}})})}),T.set(t,r)),[2,r]})})},t.prototype.runIdlePromise=function(){return Promise.resolve()},t}(),C="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",U=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/,N=function(t){if(t=String(t).replace(/[\t\n\f\r ]+/g,""),!U.test(t))throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");var e;t+="==".slice(2-(3&t.length));for(var r,n,i="",o=0;o<t.length;)e=C.indexOf(t.charAt(o++))<<18|C.indexOf(t.charAt(o++))<<12|(r=C.indexOf(t.charAt(o++)))<<6|(n=C.indexOf(t.charAt(o++))),i+=64===r?String.fromCharCode(e>>16&255):64===n?String.fromCharCode(e>>16&255,e>>8&255):String.fromCharCode(e>>16&255,e>>8&255,255&e);return i};function L(){if("undefined"==typeof globalThis)return!1;var t=globalThis.wx;if(void 0===t)return!1;if(void 0===globalThis.Page)return!1;if(!t.getDeviceInfo)return!1;if(!t.getStorageSync)return!1;if(!t.setStorageSync)return!1;if(!t.connectSocket)return!1;if(!t.request)return!1;try{if(!t.getDeviceInfo())return!1;if("qq"===t.getDeviceInfo().platform)return!1}catch(t){return!1}return!0}var D=!1;function k(){D=D||void 0!==typeof window&&"miniprogram"===window.__wxjs_environment}try{L()||(D=D||!!navigator.userAgent.match(/miniprogram/i)||"miniprogram"===window.__wxjs_environment,window&&window.WeixinJSBridge&&window.WeixinJSBridge.invoke?k():"undefined"!=typeof document&&document.addEventListener("WeixinJSBridgeReady",k,!1))}catch(t){}var x="INVALID_OPERATION",M="OPERATION_FAIL",q=o(149);function B(t,e){if("undefined"==typeof window)return!1;var r=e||decodeURIComponent(window.location.search),n=new RegExp("(^|&)".concat(t,"=([^&]*)(&|$)")),i=r.substr(r.indexOf("?")+1).match(n);return null!=i?i[2]:""}function j(t,e){console.warn("[".concat("@cloudbase/js-sdk","][").concat(t,"]:").concat(e))}var V,W,F=(V=function(t,e){return V=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},V(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}V(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),H=function(){return H=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},H.apply(this,arguments)},G=function(t,e,r,n){return new(r||(r=Promise))(function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(s,a)}u((n=n.apply(t,e||[])).next())})},K=function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=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(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};!function(t){function e(e){var r=t.call(this)||this,n=e.timeout,i=e.timeoutMsg,o=e.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=i||"请求超时",r.restrictedMethods=o||["get","post","upload","download"],r}F(e,t),e.prototype.get=function(t){return this.request(H(H({},t),{method:"get"}),this.restrictedMethods.includes("get"))},e.prototype.post=function(t){return this.request(H(H({},t),{method:"post"}),this.restrictedMethods.includes("post"))},e.prototype.put=function(t){return this.request(H(H({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,r=t.file,n=t.name,i=t.method,o=t.headers,s=void 0===o?{}:o,a={post:"post",put:"put"}[null==i?void 0:i.toLowerCase()]||"put",u=new FormData;return"post"===a?(Object.keys(e).forEach(function(t){u.append(t,e[t])}),u.append("key",n),u.append("file",r),this.request(H(H({},t),{data:u,method:a}),this.restrictedMethods.includes("upload"))):this.request(H(H({},t),{method:"put",headers:s,body:r}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return G(this,void 0,Promise,function(){var e,r,n,i;return K(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.get(H(H({},t),{headers:{},responseType:"blob"}))];case 1:return e=o.sent().data,r=window.URL.createObjectURL(new Blob([e])),n=decodeURIComponent(new URL(t.url).pathname.split("/").pop()||""),(i=document.createElement("a")).href=r,i.setAttribute("download",n),i.style.display="none",document.body.appendChild(i),i.click(),window.URL.revokeObjectURL(r),document.body.removeChild(i),[3,3];case 2:return o.sent(),[3,3];case 3:return[2,new Promise(function(e){e({statusCode:200,tempFilePath:t.url})})]}})})},e.prototype.fetch=function(t){var e;return G(this,void 0,Promise,function(){var r,n,i,o,s,a,u,c,h,l,d,f,p,v=this;return K(this,function(g){switch(g.label){case 0:return r=new AbortController,n=t.url,i=t.enableAbort,o=void 0!==i&&i,s=t.stream,a=void 0!==s&&s,u=t.signal,c=t.timeout,h=t.shouldThrowOnError,l=void 0===h||h,d=null!=c?c:this.timeout,u&&(u.aborted&&r.abort(),u.addEventListener("abort",function(){return r.abort()})),f=null,o&&d&&(f=setTimeout(function(){console.warn(v.timeoutMsg),r.abort(new Error(v.timeoutMsg))},d)),[4,fetch(n,H(H({},t),{signal:r.signal})).then(function(t){return G(v,void 0,void 0,function(){var e,r,n;return K(this,function(i){switch(i.label){case 0:return clearTimeout(f),l?t.ok?(e=t,[3,3]):[3,1]:[3,4];case 1:return n=(r=Promise).reject,[4,t.json()];case 2:e=n.apply(r,[i.sent()]),i.label=3;case 3:return[2,e];case 4:return[2,t]}})})}).catch(function(t){return clearTimeout(f),Promise.reject(t)})];case 1:return p=g.sent(),[2,{data:a?p.body:(null===(e=p.headers.get("content-type"))||void 0===e?void 0:e.includes("application/json"))?p.json():p.text(),statusCode:p.status,header:p.headers,response:p}]}})})},e.prototype.request=function(t,e){var r=this;void 0===e&&(e=!1);var n=String(t.method).toLowerCase()||"get";return new Promise(function(i){var o=t.url,s=t.headers,a=void 0===s?{}:s,u=t.data,c=t.responseType,h=t.withCredentials,l=t.body,d=t.onUploadProgress,f=function(t,e,r){void 0===r&&(r={});var n=/\?/.test(e),i="";return Object.keys(r).forEach(function(t){""===i?!n&&(e+="?"):i+="&",i+="".concat(t,"=").concat(encodeURIComponent(r[t]))}),/^http(s)?:\/\//.test(e+=i)?e:"".concat(t).concat(e)}("https:",o,"get"===n?u:{}),p=new XMLHttpRequest;p.open(n,f),c&&(p.responseType=c);var v,g,m,y=t.signal;y&&(y.aborted?p.abort():y.addEventListener("abort",function(){return p.abort()},{once:!0})),Object.keys(a).forEach(function(t){p.setRequestHeader(t,a[t])}),d&&p.upload.addEventListener("progress",d),p.onreadystatechange=function(){var t={};if(4===p.readyState){var e=p.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};e.forEach(function(t){var e=t.split(": "),n=e.shift().toLowerCase(),i=e.join(": ");r[n]=i}),t.header=r,t.statusCode=p.status;try{t.data="blob"===c?p.response:JSON.parse(p.responseText)}catch(e){t.data="blob"===c?p.response:p.responseText}clearTimeout(v),i(t)}},e&&r.timeout&&(v=setTimeout(function(){console.warn(r.timeoutMsg),p.abort()},r.timeout)),m=u,g="[object FormData]"===Object.prototype.toString.call(m)?u:"application/x-www-form-urlencoded"===a["content-type"]?function(t){void 0===t&&(t={});var e=[];return Object.keys(t).forEach(function(r){e.push("".concat(r,"=").concat(encodeURIComponent(t[r])))}),e.join("&")}(u):l||(u?JSON.stringify(u):void 0),h&&(p.withCredentials=!0),p.send(g)})}}(q.AbstractSDKRequest),function(t){t.WEB="web",t.WX_MP="wx_mp"}(W||(W={}));var Y=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),z=function(t,e,r,n){return new(r||(r=Promise))(function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(s,a)}u((n=n.apply(t,e||[])).next())})},Q=function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=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(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},J=function(t){function e(e){var r=t.call(this)||this;return r.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),r}return Y(e,t),e.prototype.setItem=function(t,e){this.root.tcbCacheObject[t]=e},e.prototype.getItem=function(t){return this.root.tcbCacheObject[t]},e.prototype.removeItem=function(t){delete this.root.tcbCacheObject[t]},e.prototype.clear=function(){delete this.root.tcbCacheObject},e}(q.AbstractStorage);!function(){function t(t){this.keys={};var e=t.persistence,r=t.platformInfo,n=void 0===r?{}:r,i=t.keys,o=void 0===i?{}:i;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||e,this.storage=function(t,e){switch(t){case"local":default:return e.localStorage?e.localStorage:(j("INVALID_PARAMS","localStorage is not supported on current platform"),new J(e.root));case"none":return new J(e.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=o)}Object.defineProperty(t.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),t.prototype.setStore=function(t,e,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(n))}catch(t){throw new Error(JSON.stringify({code:M,msg:"[".concat("@cloudbase/js-sdk","][").concat(M,"]setStore failed"),info:t}))}}else j(x,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,r){return z(this,void 0,void 0,function(){var n;return Q(this,function(i){switch(i.label){case 0:if(!this.storage)return[2];i.label=1;case 1:return i.trys.push([1,3,,4]),n={version:r||"localCachev1",content:e},[4,this.storage.setItem(t,JSON.stringify(n))];case 2:return i.sent(),[3,4];case 3:return i.sent(),[2];case 4:return[2]}})})},t.prototype.getStore=function(t,e){var r;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(t){return""}e=e||"localCachev1";var n=this.storage.getItem(t);return n&&n.indexOf(e)>=0?JSON.parse(n).content:""}j(x,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){var r;return z(this,void 0,void 0,function(){var n;return Q(this,function(i){switch(i.label){case 0:try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return[2,{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(t){return[2,""]}return e=e||"localCachev1",[4,this.storage.getItem(t)];case 1:return(n=i.sent())&&n.indexOf(e)>=0?[2,JSON.parse(n).content]:[2,""]}})})},t.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):j(x,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},t.prototype.removeStoreAsync=function(t){return z(this,void 0,void 0,function(){return Q(this,function(e){switch(e.label){case 0:return[4,this.storage.removeItem(t)];case 1:return e.sent(),[2]}})})}}();var Z=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),X=function(t,e){this.data=e||null,this.name=t},$=function(t){function e(e,r){var n=t.call(this,"error",{error:e,data:r})||this;return n.error=e,n}return Z(e,t),e}(X),tt=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){return function(t,e,r){r[t]=r[t]||[],r[t].push(e)}(t,e,this.listeners),this},t.prototype.off=function(t,e){return function(t,e,r){if(null==r?void 0:r[t]){var n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if(t instanceof $)return console.error(t.error),this;var r="string"==typeof t?new X(t,e||{}):t,n=r.name;if(this.listens(n)){r.target=this;for(var i=0,o=this.listeners[n]?function(t,e,r){if(r||2===arguments.length)for(var n,i=0,o=e.length;i<o;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))}([],this.listeners[n],!0):[];i<o.length;i++)o[i].call(this,r)}return this},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}();new tt;var et=new tt;"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.indexOf("Firefox");rt={default:()=>e.default},nt={},o.d(nt,rt);var rt,nt,it=function(){return it=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},it.apply(this,arguments)},ot=function(t,e,r,n){return new(r||(r=Promise))(function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(s,a)}u((n=n.apply(t,e||[])).next())})},st=function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=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(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},at=function(t,e,r){if(r||2===arguments.length)for(var n,i=0,o=e.length;i<o;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))},ut="x-request-id",ct="x-device-id",ht="device_id",lt=function(t,e){return ot(this,void 0,Promise,function(){var r,n,i,o,s;return st(this,function(a){switch(a.label){case 0:r=null,n=null,a.label=1;case 1:return a.trys.push([1,4,,5]),(i=Object.assign({},e)).method||(i.method="GET"),i.body&&"string"!=typeof i.body&&(i.body=JSON.stringify(i.body)),[4,fetch(t,i)];case 2:return[4,a.sent().json()];case 3:return(null==(o=a.sent())?void 0:o.error)?(n=o).error_uri=new URL(t).pathname:r=o,[3,5];case 4:return s=a.sent(),n={error:u.UNREACHABLE,error_description:s.message,error_uri:new URL(t).pathname},[3,5];case 5:if(n)throw n;return[2,r]}})})},dt=new(function(){function t(t){this._env=(null==t?void 0:t.env)||""}return t.prototype.getItem=function(t){return ot(this,void 0,Promise,function(){return st(this,function(e){return[2,window.localStorage.getItem("".concat(t).concat(this._env))]})})},t.prototype.removeItem=function(t){return ot(this,void 0,Promise,function(){return st(this,function(e){return window.localStorage.removeItem("".concat(t).concat(this._env)),[2]})})},t.prototype.setItem=function(t,e){return ot(this,void 0,Promise,function(){return st(this,function(r){return window.localStorage.setItem("".concat(t).concat(this._env),e),[2]})})},t.prototype.getItemSync=function(t){return window.localStorage.getItem("".concat(t).concat(this._env))},t.prototype.removeItemSync=function(t){window.localStorage.removeItem("".concat(t).concat(this._env))},t.prototype.setItemSync=function(t,e){window.localStorage.setItem("".concat(t).concat(this._env),e)},t}());function ft(t){var e=!0;return(null==t?void 0:t.expires_at)&&(null==t?void 0:t.access_token)&&(e=t.expires_at<new Date),e}var pt=function(){function t(t){this.credentials=null,this.accessKeyCredentials=null,this.singlePromise=null,this.tokenSectionName=t.tokenSectionName,this.storage=t.storage,this.clientId=t.clientId,this.singlePromise=new R({clientId:this.clientId}),this.credentials=t.credentials||null}return t.prototype.getStorageCredentialsSync=function(){var t=null,e=this.storage.getItemSync(this.tokenSectionName);if(null!=e)try{(null==(t=JSON.parse(e))?void 0:t.expires_at)&&(t.expires_at=new Date(t.expires_at))}catch(e){this.storage.removeItem(this.tokenSectionName),t=null}return t},t.prototype.setCredentials=function(t){return ot(this,void 0,Promise,function(){var e;return st(this,function(r){switch(r.label){case 0:return(null==t?void 0:t.expires_in)?((null==t?void 0:t.expires_at)||(t.expires_at=new Date(Date.now()+1e3*(t.expires_in-30))),this.storage?(e=JSON.stringify(t),[4,this.storage.setItem(this.tokenSectionName,e)]):[3,2]):[3,3];case 1:r.sent(),r.label=2;case 2:return this.credentials=t,[3,6];case 3:return this.storage?[4,this.storage.removeItem(this.tokenSectionName)]:[3,5];case 4:r.sent(),r.label=5;case 5:this.credentials=null,r.label=6;case 6:return[2]}})})},t.prototype.setAccessKeyCredentials=function(t){this.accessKeyCredentials=t,t.scope===E&&(this.credentials=t)},t.prototype.getCredentials=function(){return ot(this,void 0,Promise,function(){var t=this;return st(this,function(e){return[2,this.singlePromise.run("getCredentials",function(){return ot(t,void 0,void 0,function(){var t,e;return st(this,function(r){switch(r.label){case 0:return ft(this.credentials)?[4,this.getStorageCredentials()]:[3,2];case 1:if(t=r.sent(),e=t.credentials,t.isAccessKeyCredentials)return[2,e];this.credentials=e,r.label=2;case 2:return[2,this.credentials]}})})})]})})},t.prototype.getStorageCredentials=function(){return ot(this,void 0,Promise,function(){var t=this;return st(this,function(e){return[2,this.singlePromise.run("_getStorageCredentials",function(){return ot(t,void 0,void 0,function(){var t,e,r;return st(this,function(n){switch(n.label){case 0:return t=null,e=!1,[4,this.storage.getItem(this.tokenSectionName)];case 1:if(!(r=n.sent()))return[3,6];n.label=2;case 2:return n.trys.push([2,3,,5]),(null==(t=JSON.parse(r))?void 0:t.expires_at)&&(t.expires_at=new Date(t.expires_at)),[3,5];case 3:return n.sent(),[4,this.storage.removeItem(this.tokenSectionName)];case 4:return n.sent(),t=null,[3,5];case 5:return[3,7];case 6:t=this.accessKeyCredentials||null,e=!0,n.label=7;case 7:return[2,{credentials:t,isAccessKeyCredentials:e}]}})})})]})})},t}(),vt=function(){function t(e){var r,n=this;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.getApiOriginFunc=e.getApiOrigin,this.apiPath=e.apiPath||l,this.clientId=e.clientId,this.i18n=e.i18n,this.eventBus=e.eventBus,this.singlePromise=new R({clientId:this.clientId}),this.retry=this.formatRetry(e.retry,t.defaultRetry),e.baseRequest?this.baseRequest=e.baseRequest:this.baseRequest=lt,this.tokenInURL=e.tokenInURL,this.headers=e.headers,this.storage=e.storage||dt,this.localCredentials=new pt({tokenSectionName:"credentials_".concat(e.clientId),storage:this.storage,clientId:e.clientId}),this.clientSecret=e.clientSecret,e.clientId&&(this.basicAuth="Basic ".concat(function(t){for(var e,r,n,i,o="",s=0,a=(t=String(t)).length%3;s<t.length;){if((r=t.charCodeAt(s++))>255||(n=t.charCodeAt(s++))>255||(i=t.charCodeAt(s++))>255)throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.");o+=C.charAt((e=r<<16|n<<8|i)>>18&63)+C.charAt(e>>12&63)+C.charAt(e>>6&63)+C.charAt(63&e)}return a?o.slice(0,a-3)+"===".substring(a):o}("".concat(e.clientId,":").concat(this.clientSecret)))),this.wxCloud=e.wxCloud;try{L()&&(this.useWxCloud=e.useWxCloud,void 0===this.wxCloud&&e.env&&(wx.cloud.init({env:e.env}),this.wxCloud=wx.cloud))}catch(t){}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!==(r=e.debug)&&void 0!==r&&r,et.on("lang_change",function(t){var e;n.i18n=(null===(e=t.data)||void 0===e?void 0:e.i18n)||n.i18n})}return t.prototype.setGetInitialSession=function(t){this.getInitialSession=t},t.prototype.setOnInitialSessionObtained=function(t){this.onInitialSessionObtained=t},t.prototype.initialize=function(t){return ot(this,void 0,Promise,function(){var e=this;return st(this,function(r){switch(r.label){case 0:return this.initializePromise?[4,this.initializePromise]:[3,2];case 1:case 3:case 5:return[2,r.sent()];case 2:return void 0===t?[3,4]:(this.initializePromise=t,[4,this.initializePromise]);case 4:return this.initializePromise=ot(e,void 0,void 0,function(){var t=this;return st(this,function(e){switch(e.label){case 0:return[4,this._acquireLock(-1,function(){return ot(t,void 0,void 0,function(){return st(this,function(t){switch(t.label){case 0:return[4,this._initialize()];case 1:return[2,t.sent()]}})})})];case 1:return[2,e.sent()]}})}),[4,this.initializePromise]}})})},t.prototype.setCredentials=function(t){return ot(this,void 0,Promise,function(){var e=this;return st(this,function(r){switch(r.label){case 0:return[4,this.initializePromise];case 1:return r.sent(),[2,this._acquireLock(-1,function(){return ot(e,void 0,void 0,function(){return st(this,function(e){return[2,this.localCredentials.setCredentials(t)]})})})]}})})},t.prototype.setAccessKeyCredentials=function(t){return this.localCredentials.setAccessKeyCredentials(t)},t.prototype.getAccessToken=function(){return ot(this,void 0,Promise,function(){var t,e;return st(this,function(r){switch(r.label){case 0:return[4,this.initializePromise];case 1:return r.sent(),[4,this.getCredentials()];case 2:return(null==(t=r.sent())?void 0:t.scope)===E||(null==t?void 0:t.access_token)?[2,Promise.resolve(t.access_token)]:(e={error:u.UNAUTHENTICATED},[2,Promise.reject(e)])}})})},t.prototype.request=function(e,r){var n,i;return ot(this,void 0,Promise,function(){var o,s,a,c,h,l,d,f,p,v;return st(this,function(g){switch(g.label){case 0:return r||(r={}),o=this.formatRetry(r.retry,this.retry),r.headers=it(it({},r.headers),((v={})[null===(n=this.i18n)||void 0===n?void 0:n.LANG_HEADER_KEY]=null===(i=this.i18n)||void 0===i?void 0:i.lang,v)),this.headers&&(r.headers=it(it({},this.headers),r.headers)),r.headers[ut]||(r.headers[ut]=S()),r.headers[ct]?[3,2]:[4,this.getDeviceId()];case 1:s=g.sent(),r.headers[ct]=s,g.label=2;case 2:return(null==r?void 0:r.withBasicAuth)&&this.basicAuth&&(r.headers.Authorization=this.basicAuth),(null==r?void 0:r.withCredentials)?r.getCredentials?[4,r.getCredentials()]:[3,4]:[3,7];case 3:return c=g.sent(),[3,6];case 4:return[4,this.getCredentials()];case 5:c=g.sent(),g.label=6;case 6:return(a=c)&&(this.tokenInURL?(e.indexOf("?")<0&&(e+="?"),e+="access_token=".concat(a.access_token)):r.headers.Authorization="".concat(a.token_type," ").concat(a.access_token)),[3,8];case 7:this.clientId&&e.indexOf("client_id")<0&&(e+=e.indexOf("?")<0?"?":"&",e+="client_id=".concat(this.clientId)),g.label=8;case 8:e.startsWith("/")&&(h=this.getApiOriginFunc?this.getApiOriginFunc():this.apiOrigin,e="".concat(h).concat(this.apiPath).concat(e)),l=null,d=o+1,f=0,g.label=9;case 9:if(!(f<d))return[3,21];g.label=10;case 10:return g.trys.push([10,15,,18]),r.useWxCloud||this.useWxCloud?[4,this.wxCloudCallFunction(e,r)]:[3,12];case 11:return l=g.sent(),[3,14];case 12:return[4,this.baseRequest(e,r)];case 13:l=g.sent(),g.label=14;case 14:if(null==l?void 0:l.code)throw{error:l.code,error_description:l.message,error_uri:new URL(e).pathname};return[3,21];case 15:p=g.sent();try{p.requestId=p.requestId||r.headers[ut]||""}catch(t){}return r.withCredentials&&p&&p.error===u.UNAUTHENTICATED?[4,this.setCredentials(null)]:[3,17];case 16:return g.sent(),[2,Promise.reject(p)];case 17:return f!==o&&p&&"unreachable"===p.error?[3,18]:[2,Promise.reject(p)];case 18:return[4,this.sleep(t.retryInterval)];case 19:g.sent(),g.label=20;case 20:return f++,[3,9];case 21:return[2,l]}})})},t.prototype.wxCloudCallFunction=function(t,e){var r;return ot(this,void 0,Promise,function(){var n,i,o,s,a;return st(this,function(c){switch(c.label){case 0:n=null,i=null,c.label=1;case 1:c.trys.push([1,7,,8]),o="",c.label=2;case 2:return c.trys.push([2,4,,5]),[4,wx.getRendererUserAgent()];case 3:return o=c.sent(),[3,5];case 4:return c.sent(),[3,5];case 5:return[4,this.wxCloud.callFunction({name:"httpOverCallFunction",data:{url:t,method:e.method,headers:it({origin:"https://servicewechat.com","User-Agent":o},e.headers),body:e.body}})];case 6:return s=c.sent().result,(null===(r=null==s?void 0:s.body)||void 0===r?void 0:r.error_code)?(i=null==s?void 0:s.body).error_uri=(0,A.y)(t):n=null==s?void 0:s.body,[3,8];case 7:return a=c.sent(),i={error:u.UNREACHABLE,error_description:a.message,error_uri:(0,A.y)(t)},[3,8];case 8:if(i)throw i;return[2,n]}})})},t.prototype.getCredentials=function(){return ot(this,void 0,Promise,function(){var t=this;return st(this,function(e){switch(e.label){case 0:return[4,this.initializePromise];case 1:return e.sent(),[2,this._acquireLock(-1,function(){return ot(t,void 0,void 0,function(){return st(this,function(t){return[2,this._getCredentials()]})})})]}})})},t.prototype.getCredentialsSync=function(){return this.localCredentials.getStorageCredentialsSync()},t.prototype.getCredentialsAsync=function(){return this.getCredentials()},t.prototype.getScope=function(){var t;return ot(this,void 0,Promise,function(){var e,r;return st(this,function(n){switch(n.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return(e=n.sent())?[2,e.scope]:(r="credentials not found",null===(t=this.onCredentialsError)||void 0===t||t.call(this,{msg:r}),[2,this.unAuthenticatedError(r)])}})})},t.prototype.getGroups=function(){var t;return ot(this,void 0,Promise,function(){var e,r;return st(this,function(n){switch(n.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return(e=n.sent())?[2,e.groups]:(r="credentials not found",null===(t=this.onCredentialsError)||void 0===t||t.call(this,{msg:r}),[2,this.unAuthenticatedError(r)])}})})},t.prototype.refreshToken=function(t,e){return ot(this,void 0,Promise,function(){var r=this;return st(this,function(n){switch(n.label){case 0:return[4,this.initializePromise];case 1:return n.sent(),[2,this._acquireLock(-1,function(){return ot(r,void 0,void 0,function(){return st(this,function(r){return[2,this._refreshToken(t,e)]})})})]}})})},t.prototype._refreshToken=function(t,e){return ot(this,void 0,Promise,function(){var r=this;return st(this,function(n){return[2,this.singlePromise.run("_refreshToken",function(){return ot(r,void 0,void 0,function(){var r,n,i,o,s,a,c;return st(this,function(h){switch(h.label){case 0:if((null==t?void 0:t.scope)===E)return[2,t];if(!t||!t.refresh_token)return i="no refresh token found in credentials",null===(o=this.onCredentialsError)||void 0===o||o.call(this,{msg:i}),[2,this.unAuthenticatedError(i)];h.label=1;case 1:return h.trys.push([1,4,,7]),[4,this.refreshTokenFunc(t.refresh_token,t)];case 2:return r=h.sent(),[4,this.localCredentials.setCredentials(r)];case 3:return h.sent(),null===(s=this.eventBus)||void 0===s||s.fire(I,{event:g}),[2,r];case 4:if(n=h.sent(),null==e?void 0:e.throwError)throw n;return n.error!==u.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return h.sent(),i=n.error_description,null===(a=this.onCredentialsError)||void 0===a||a.call(this,{msg:i}),[2,this.unAuthenticatedError(i)];case 6:return null===(c=this.onCredentialsError)||void 0===c||c.call(this,{msg:n.error_description}),[2,Promise.reject(n)];case 7:return[2]}})})})]})})},t.prototype.anonymousLogin=function(t){return ot(this,void 0,void 0,function(){var e=this;return st(this,function(r){return[2,this.singlePromise.run("_anonymousLogin",function(){return ot(e,void 0,void 0,function(){var e,r;return st(this,function(n){switch(n.label){case 0:return this.anonymousSignInFunc?[4,this.anonymousSignInFunc(t)]:[3,4];case 1:return e=n.sent(),(r=e)?[3,3]:[4,this.localCredentials.getCredentials()];case 2:r=n.sent(),n.label=3;case 3:return t=r,[3,6];case 4:return[4,this.anonymousSignIn(t)];case 5:t=n.sent(),n.label=6;case 6:return[2,t]}})})})]})})},t.prototype.checkRetry=function(e){var r=null;if(("number"!=typeof e||e<t.minRetry||e>t.maxRetry)&&(r={error:u.UNREACHABLE,error_description:"wrong options param: retry"}),r)throw r;return e},t.prototype.formatRetry=function(t,e){return void 0===t?e:this.checkRetry(t)},t.prototype.sleep=function(t){return ot(this,void 0,Promise,function(){return st(this,function(e){return[2,new Promise(function(e){setTimeout(function(){e()},t)})]})})},t.prototype.anonymousSignIn=function(t){return ot(this,void 0,Promise,function(){var e=this;return st(this,function(r){return[2,this.singlePromise.run("_anonymous",function(){return ot(e,void 0,void 0,function(){var e,r;return st(this,function(i){switch(i.label){case 0:if(!t||"anonymous"!==t.scope)return[2,this.unAuthenticatedError("no anonymous in credentials")];i.label=1;case 1:return i.trys.push([1,4,,7]),[4,this.request(n.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",withBasicAuth:!0,body:{}})];case 2:return e=i.sent(),[4,this.localCredentials.setCredentials(e)];case 3:return i.sent(),[2,e];case 4:return(r=i.sent()).error!==u.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return i.sent(),[2,this.unAuthenticatedError(r.error_description)];case 6:return[2,Promise.reject(r)];case 7:return[2]}})})})]})})},t.prototype.defaultRefreshTokenFunc=function(t,e){var r;return ot(this,void 0,Promise,function(){var o,s,a;return st(this,function(u){switch(u.label){case 0:return void 0===t||""===t?(o="refresh token not found",null===(r=this.onCredentialsError)||void 0===r||r.call(this,{msg:o}),[2,this.unAuthenticatedError(o)]):(s=n.AUTH_TOKEN_URL,"v2"===(null==e?void 0:e.version)&&(s=i.AUTH_TOKEN_URL),[4,this.request(s,{method:"POST",body:{client_id:this.clientId,client_secret:this.clientSecret,grant_type:"refresh_token",refresh_token:t}})]);case 1:return a=u.sent(),[2,it(it({},a),{version:(null==e?void 0:e.version)||"v1"})]}})})},t.prototype.getDeviceId=function(){return ot(this,void 0,Promise,function(){var t;return st(this,function(e){switch(e.label){case 0:return this.deviceID?[2,this.deviceID]:[4,this.storage.getItem(ht)];case 1:return"string"==typeof(t=e.sent())&&t.length>=16&&t.length<=48?[3,3]:(t=S(),[4,this.storage.setItem(ht,t)]);case 2:e.sent(),e.label=3;case 3:return this.deviceID=t,[2,t]}})})},t.prototype.unAuthenticatedError=function(t){var e={error:u.UNAUTHENTICATED,error_description:t};return Promise.reject(e)},t.prototype._debug=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.logDebugMessages&&console.log.apply(console,at(["[OAuth2Client]"],t,!1))},t.prototype._initialize=function(){return ot(this,void 0,Promise,function(){var t,e,r,n,i,o;return st(this,function(s){switch(s.label){case 0:if(s.trys.push([0,11,12,13]),!this.getInitialSession)return this._debug("#_initialize()","no getInitialSession callback set, skipping"),[2,{error:null}];this._debug("#_initialize()","calling getInitialSession callback"),s.label=1;case 1:return s.trys.push([1,9,,10]),[4,this.getInitialSession()];case 2:return o=s.sent(),t=o.data,e=o.error,(null==t?void 0:t.session)?(this._debug("#_initialize()","session obtained from getInitialSession",t.session),[4,this.localCredentials.setCredentials(null==t?void 0:t.session)]):[3,4];case 3:s.sent(),s.label=4;case 4:if(!this.onInitialSessionObtained)return[3,8];this._debug("#_initialize()","calling onInitialSessionObtained callback"),s.label=5;case 5:return s.trys.push([5,7,,8]),[4,this.onInitialSessionObtained(t,e)];case 6:return s.sent(),[3,8];case 7:return r=s.sent(),this._debug("#_initialize()","error in onInitialSessionObtained",r),[3,8];case 8:return e?(this._debug("#_initialize()","error from getInitialSession",e),[2,{error:e}]):[2,{error:null}];case 9:return n=s.sent(),this._debug("#_initialize()","exception during getInitialSession",n),[2,{error:n instanceof Error?n:new Error(String(n))}];case 10:return[3,13];case 11:return i=s.sent(),this._debug("#_initialize()","unexpected error",i),[2,{error:i instanceof Error?i:new Error(String(i))}];case 12:return this._debug("#_initialize()","end"),[7];case 13:return[2]}})})},t.prototype._acquireLock=function(t,e){return ot(this,void 0,Promise,function(){var r,n,i,o,s=this;return st(this,function(a){switch(a.label){case 0:this._debug("#_acquireLock","begin",t),a.label=1;case 1:if(a.trys.push([1,,10,11]),this.lockAcquired)return r=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),n=ot(s,void 0,void 0,function(){return st(this,function(t){switch(t.label){case 0:return[4,r];case 1:return t.sent(),[4,e()];case 2:return[2,t.sent()]}})}),this.pendingInLock.push(ot(s,void 0,void 0,function(){return st(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,n];case 1:case 2:return t.sent(),[3,3];case 3:return[2]}})})),[2,n];this._debug("#_acquireLock","acquiring lock for client",this.clientId),a.label=2;case 2:return a.trys.push([2,,8,9]),this.lockAcquired=!0,i=e(),this.pendingInLock.push(ot(s,void 0,void 0,function(){return st(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,i];case 1:case 2:return t.sent(),[3,3];case 3:return[2]}})})),[4,i];case 3:a.sent(),a.label=4;case 4:return this.pendingInLock.length?(o=at([],this.pendingInLock,!0),[4,Promise.all(o)]):[3,6];case 5:return a.sent(),this.pendingInLock.splice(0,o.length),[3,4];case 6:return[4,i];case 7:return[2,a.sent()];case 8:return this._debug("#_acquireLock","releasing lock for client",this.clientId),this.lockAcquired=!1,[7];case 9:return[3,11];case 10:return this._debug("#_acquireLock","end"),[7];case 11:return[2]}})})},t.prototype._getCredentials=function(){var t,e,r;return ot(this,void 0,Promise,function(){var n,i,o;return st(this,function(s){switch(s.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:if((null==(n=s.sent())?void 0:n.scope)===E)return[2,n];if(!n)return o="credentials not found",null===(t=this.onCredentialsError)||void 0===t||t.call(this,{msg:o}),[2,this.unAuthenticatedError(o)];if(!ft(n))return[3,12];if(!n.refresh_token)return[3,9];s.label=2;case 2:return s.trys.push([2,4,,8]),[4,this._refreshToken(n)];case 3:return n=s.sent(),[3,8];case 4:return i=s.sent(),"anonymous"!==n.scope?[3,6]:[4,this.anonymousLogin(n)];case 5:return n=s.sent(),[3,7];case 6:return null===(e=this.onCredentialsError)||void 0===e||e.call(this,{msg:i.error_description}),[2,Promise.reject(i)];case 7:return[3,8];case 8:return[3,12];case 9:return"anonymous"!==n.scope?[3,11]:[4,this.anonymousLogin(n)];case 10:return n=s.sent(),[3,12];case 11:return o="no refresh token found in credentials",null===(r=this.onCredentialsError)||void 0===r||r.call(this,{msg:o}),[2,this.unAuthenticatedError(o)];case 12:return[2,n]}})})},t.defaultRetry=2,t.minRetry=0,t.maxRetry=5,t.retryInterval=1e3,t}(),gt=o(689),mt=o(616),yt=function(){return yt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},yt.apply(this,arguments)},_t=function(t,e,r,n){return new(r||(r=Promise))(function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(s,a)}u((n=n.apply(t,e||[])).next())})},It=function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=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(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},bt=function(t,e){var r;return function(){for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];clearTimeout(r),r=setTimeout(function(){return t.apply(null,n)},e)}},wt=new gt.CloudbaseEventEmitter,Et="resolveCaptchaData",St="padding:10px 8px;background:#007bff;color:#fff;border:none;border-radius:4px;cursor:pointer;flex:1;white-space:nowrap;margin-left:10px",At="width:100%;padding:10px;background:#007bff;color:#fff;border:none;border-radius:4px;cursor:pointer",Pt="background:#6c757d;cursor:not-allowed",Ot=function(t,e,r,n){return new(r||(r=Promise))(function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(s,a)}u((n=n.apply(t,e||[])).next())})},Tt=function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=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(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},Rt=function(){function t(t){t.openURIWithCallback||(t.openURIWithCallback=this.getDefaultOpenURIWithCallback()),t.storage||(t.storage=dt),this.config=t,this.tokenSectionName="captcha_".concat(t.clientId||t.env)}return t.prototype.isMatch=function(){var t,e,r;return(null===(r=null===(e=null===(t=this.config)||void 0===t?void 0:t.adapter)||void 0===e?void 0:e.isMatch)||void 0===r?void 0:r.call(e))||L()},t.prototype.request=function(t,e){return Ot(this,void 0,Promise,function(){var r,n,i,o;return Tt(this,function(s){switch(s.label){case 0:return e||(e={}),e.method||(e.method="GET"),r="".concat(e.method,":").concat(t),n=t,e.withCaptcha?[4,this.appendCaptchaTokenToURL(t,r,!1)]:[3,2];case 1:n=s.sent(),s.label=2;case 2:return s.trys.push([2,4,,7]),[4,this.config.request(n,e)];case 3:return i=s.sent(),[3,7];case 4:return(o=s.sent()).error!==u.CAPTCHA_REQUIRED&&o.error!==u.CAPTCHA_INVALID?[3,6]:[4,this.appendCaptchaTokenToURL(t,r,o.error===u.CAPTCHA_INVALID)];case 5:return t=s.sent(),[2,this.config.request(t,e)];case 6:return[2,Promise.reject(o)];case 7:return[2,i]}})})},t.prototype.getDefaultOpenURIWithCallback=function(){var t=this;return function(e){return function(t,e){return _t(void 0,void 0,Promise,function(){var r,n,i,o;return It(this,function(s){return r=(0,mt.parseCaptcha)(t),n=r.captchaData,i=r.state,o=r.token,function(t){var e=t.oauthInstance,r=t.captchaState,n="captcha-image",i=function(){return _t(void 0,void 0,void 0,function(){var t,i;return It(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,e.createCaptchaData({state:r.state})];case 1:return t=o.sent(),r=yt(yt({},r),{captchaData:t.data,token:t.token}),document.getElementById(n).src=t.data,[3,3];case 2:return i=o.sent(),console.error("刷新图形验证码失败",i),[3,3];case 3:return[2]}})})},o=function(t,e,r){var n=document.createElement(t);return e&&(n.style.cssText=e),r&&(n.textContent=r),n},s=o("div","position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.5);z-index:999"),a=o("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(o("p","margin-bottom:15px","请输入你看到的字符:"));var u=o("div","display:flex;align-items:center;justify-content:space-between;margin-bottom:15px"),c=o("img","width:100%;height:auto;border:1px solid #eee");c.id=n,c.src=r.captchaData,u.appendChild(c);var h=o("button",St,"刷新");h.onclick=bt(function(){return _t(void 0,void 0,void 0,function(){return It(this,function(t){switch(t.label){case 0:h.textContent="加载中...",h.disabled=!0,h.style.cssText="".concat(St,";").concat(Pt),t.label=1;case 1:return t.trys.push([1,,3,4]),[4,i()];case 2:return t.sent(),[3,4];case 3:return h.textContent="刷新",h.disabled=!1,h.style.cssText=St,[7];case 4:return[2]}})})},500),u.appendChild(h),a.appendChild(u);var l=o("input","width:100%;padding:14px 16px;margin-bottom:15px;box-sizing:border-box;border:2px solid #e8ecf4;border-radius:10px;font-size:15px");l.type="text",l.placeholder="输入字符",l.maxLength=4,a.appendChild(l);var d=o("div","color:#dc3545;font-size:12px;margin-bottom:10px;display:none;padding:8px;background:#f8d7da;border:1px solid #f5c6cb;border-radius:4px");a.appendChild(d);var f=function(t){d.textContent=t,d.style.display="block"},p=o("button",At,"确定");p.onclick=bt(function(){return _t(void 0,void 0,void 0,function(){var t,n,o,u;return It(this,function(c){switch(c.label){case 0:if(!(t=l.value.trim()))return f("请输入字符"),[2];d.style.display="none",p.textContent="验证中...",p.disabled=!0,p.style.cssText="".concat(At,";").concat(Pt),c.label=1;case 1:return c.trys.push([1,3,5,6]),[4,e.verifyCaptchaData({token:r.token,key:t})];case 2:return n=c.sent(),wt.fire(Et,n),console.log("图形验证码校验成功"),document.body.removeChild(s),document.body.removeChild(a),[3,6];case 3:return o=c.sent(),console.error("图形验证码校验失败",o),u=o.error_description||"图形验证码校验失败",f(u),l.value="",l.focus(),[4,i()];case 4:return c.sent(),[3,6];case 5:return p.textContent="确定",p.disabled=!1,p.style.cssText=At,[7];case 6:return[2]}})})},500),a.appendChild(p),document.body.appendChild(s),document.body.appendChild(a)}({oauthInstance:e,captchaState:{captchaData:n,state:i,token:o}}),[2,new Promise(function(t){console.log("等待图形验证码校验结果..."),wt.on(Et,function(e){t(null==e?void 0:e.data)})})]})})}(e,t.config.oauthInstance)}},t.prototype.getCaptchaToken=function(t,e){return Ot(this,void 0,Promise,function(){var r,i,o,s;return Tt(this,function(a){switch(a.label){case 0:return t?[3,2]:[4,this.findCaptchaToken()];case 1:if(r=a.sent())return[2,r];a.label=2;case 2:return[4,this.config.request(n.CAPTCHA_DATA_URL,{method:"POST",body:{state:e,redirect_uri:""},withCredentials:!1})];case 3:return i=a.sent(),o="".concat(i.data,"?state=").concat(encodeURIComponent(e),"&token=").concat(encodeURIComponent(i.token)),[4,this.config.openURIWithCallback(o)];case 4:return s=a.sent(),this.saveCaptchaToken(s),[2,s.captcha_token]}})})},t.prototype.appendCaptchaTokenToURL=function(t,e,r){return Ot(this,void 0,Promise,function(){var n;return Tt(this,function(i){switch(i.label){case 0:return[4,this.getCaptchaToken(r,e)];case 1:return n=i.sent(),t.indexOf("?")>0?t+="&captcha_token=".concat(n):t+="?captcha_token=".concat(n),[2,t]}})})},t.prototype.saveCaptchaToken=function(t){return Ot(this,void 0,void 0,function(){var e;return Tt(this,function(r){switch(r.label){case 0:return t.expires_at=new Date(Date.now()+1e3*(t.expires_in-10)),e=JSON.stringify(t),[4,this.config.storage.setItem(this.tokenSectionName,e)];case 1:return r.sent(),[2]}})})},t.prototype.findCaptchaToken=function(){return Ot(this,void 0,Promise,function(){var t,e;return Tt(this,function(r){switch(r.label){case 0:return[4,this.config.storage.getItem(this.tokenSectionName)];case 1:if(null==(t=r.sent()))return[3,5];r.label=2;case 2:return r.trys.push([2,3,,5]),(null==(e=JSON.parse(t))?void 0:e.expires_at)&&(e.expires_at=new Date(e.expires_at)),e.expires_at<new Date?[2,null]:[2,e.captcha_token];case 3:return r.sent(),[4,this.config.storage.removeItem(this.tokenSectionName)];case 4:return r.sent(),[2,null];case 5:return[2,null]}})})},t}();const Ct=function(){function t(t){if(this.params={},"string"==typeof t)this.parse(t);else if(t&&"object"==typeof t)for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&this.append(e,t[e])}return t.prototype.parse=function(t){var e=this;t.split("&").forEach(function(t){var r=t.split("=").map(decodeURIComponent),n=r[0],i=r[1];e.append(n,i)})},t.prototype.append=function(t,e){this.params[t]?this.params[t]=this.params[t].concat([e]):this.params[t]=[e]},t.prototype.get=function(t){return this.params[t]?this.params[t][0]:null},t.prototype.getAll=function(t){return this.params[t]||[]},t.prototype.delete=function(t){delete this.params[t]},t.prototype.has=function(t){return Object.prototype.hasOwnProperty.call(this.params,t)},t.prototype.set=function(t,e){this.params[t]=[e]},t.prototype.toString=function(){var t=[],e=function(e){Object.prototype.hasOwnProperty.call(r.params,e)&&r.params[e].forEach(function(r){t.push("".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(r)))})},r=this;for(var n in this.params)e(n);return t.join("&")},t}();var Ut,Nt=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();!function(t){t.PROVIDER_NOT_ENABLED="PROVIDER_NOT_ENABLED",t.INVALID_CREDENTIALS="INVALID_CREDENTIALS",t.USER_NOT_FOUND="USER_NOT_FOUND",t.USER_STATUS_ABNORMAL="USER_STATUS_ABNORMAL",t.SERVICE_ERROR="SERVICE_ERROR",t.INVALID_PARAMS="INVALID_PARAMS",t.AUTH_METHOD_MISMATCH="AUTH_METHOD_MISMATCH",t.RATE_LIMITED="RATE_LIMITED",t.CAPTCHA_REQUIRED="CAPTCHA_REQUIRED",t.CAPTCHA_INVALID="CAPTCHA_INVALID",t.MFA_REQUIRED="MFA_REQUIRED",t.PRECONDITION_FAILED="PRECONDITION_FAILED",t.VERIFICATION_FAILED="VERIFICATION_FAILED",t.UNKNOWN="UNKNOWN"}(Ut||(Ut={}));var Lt="https://tcb.cloud.tencent.com/dev?envId=#/identity/login-manage",Dt="https://docs.cloudbase.net/api-reference/webv3-next/initialization",kt=function(t){function e(e,r){var n,i=this,o=e.error_description||e.message;return(i=t.call(this,o)||this).__isAuthError=!0,i.name="AuthError",i.status=e.error,i.code=String(e.error||e.error_code||"unknown").toLowerCase(),i.errorCode="number"==typeof e.error_code?e.error_code:"string"==typeof e.error_code&&parseInt(e.error_code,10)||void 0,i.requestId=e.requestId,i.category=function(t,e,r){if(!t&&!e&&!r)return Ut.UNKNOWN;try{var n=(t||"").toLowerCase(),i="string"==typeof r?parseInt(r,10):r;return i===c.CAPTCHA_REQUIRED||e===u.CAPTCHA_REQUIRED?Ut.CAPTCHA_REQUIRED:i===c.CAPTCHA_INVALID||e===u.CAPTCHA_INVALID?Ut.CAPTCHA_INVALID:i===c.MFA_PHONE_REQUIRED||e===u.MFA_PHONE_REQUIRED?Ut.MFA_REQUIRED:i===c.LOGIN_TYPE_DISABLED||e===u.LOGIN_TYPE_DISABLED?Ut.PROVIDER_NOT_ENABLED:i===c.RESOURCE_EXHAUSTED||e===u.RESOURCE_EXHAUSTED?Ut.RATE_LIMITED:i===c.INTERNAL||i===c.UNAVAILABLE||i===c.UNIMPLEMENTED||i===c.ABORTED?Ut.SERVICE_ERROR:i===c.NOT_FOUND?Ut.USER_NOT_FOUND:i===c.UNAUTHENTICATED?Ut.INVALID_CREDENTIALS:i===c.INVALID_ARGUMENT&&(n.includes("验证码")||n.includes("verification")||n.includes("verification_code")||n.includes("verification_id")||n.includes("does not match")||n.includes("token expired")||n.includes("token error")||n.includes("过期"))?Ut.VERIFICATION_FAILED:e===u.PROVIDER_NOT_ENABLED||e===u.LOGIN_METHOD_DISABLED||n.includes("身份源")||n.includes("开启")||n.includes("identity provider")||n.includes("provider not enabled")||n.includes("login method")||n.includes("登录方式")||n.includes("not enabled")||n.includes("未开启")||n.includes("未启用")||n.includes("请联系开发者")||n.includes("anonymous login is not enabled")||n.includes("匿名登录未开启")?Ut.PROVIDER_NOT_ENABLED:e===u.FAILED_PRECONDITION||i===c.FAILED_PRECONDITION&&!n.includes("请联系开发者")?n.includes("不存在")||n.includes("not found")||n.includes("未注册")?Ut.USER_NOT_FOUND:Ut.PRECONDITION_FAILED:e===u.INVALID_PASSWORD||e===u.INVALID_GRANT||e===u.INVALID_VERIFICATION_CODE||e===u.INVALID_USERNAME_OR_PASSWORD||e===u.INVALID_CREDENTIALS||e===u.WRONG_PASSWORD||e===u.UNAUTHENTICATED||e===u.INVALID_TWO_FACTOR||e===u.INVALID_TWO_FACTOR_RECOVERY||e===u.PASSWORD_NOT_SET||n.includes("密码不正确")||n.includes("password")||n.includes("invalid_password")||n.includes("凭据")||n.includes("credentials")||n.includes("验证码")||n.includes("verification")||n.includes("invalid_verification_code")||n.includes("invalid_username_or_password")||n.includes("username or password")||n.includes("用户名或密码")||n.includes("wrong password")||n.includes("incorrect password")?Ut.INVALID_CREDENTIALS:e===u.NOT_FOUND||e===u.USER_NOT_FOUND||n.includes("用户不存在")||n.includes("not found")||n.includes("user not found")||n.includes("no such user")||n.includes("user does not exist")?Ut.USER_NOT_FOUND:e===u.USER_BLOCKED||e===u.USER_PENDING||e===u.UNDER_REVIEW||e===u.INVALID_STATUS||n.includes("被封禁")||n.includes("blocked")||n.includes("pending")||n.includes("审核")||n.includes("review")||n.includes("locked")||n.includes("已锁定")?Ut.USER_STATUS_ABNORMAL:e===u.SERVER_ERROR||e===u.UNAVAILABLE||e===u.TEMPORARILY_UNAVAILABLE||e===u.INTERNAL||e===u.UNREACHABLE||e===u.DEADLINE_EXCEEDED||e===u.DATA_LOSS||e===u.ABORTED||n.includes("network")||n.includes("timeout")||n.includes("timed out")||n.includes("超时")||n.includes("smtp is not set")||n.includes("sms sender does not config")?Ut.SERVICE_ERROR:e===u.INVALID_ARGUMENT||e===u.INVALID_REQUEST||e===u.INVALID_SCOPE||e===u.INVALID_REQUEST_URI||e===u.INVALID_REQUEST_OBJECT||i===c.INVALID_ARGUMENT?Ut.INVALID_PARAMS:e===u.PERMISSION_DENIED||e===u.ACCESS_DENIED||e===u.UNAUTHORIZED_CLIENT?Ut.PROVIDER_NOT_ENABLED:Ut.UNKNOWN}catch(t){return e}}(o,i.status,i.errorCode),i.helpMessage=function(t,e){var r=(null==e?void 0:e.method)||"signIn",n={signInWithPassword:"「用户名密码登录」",signInAnonymously:"「匿名登录」",signInWithOtp:"「短信验证码登录」或「邮箱验证码登录」",signUp:"「短信验证码登录」或「邮箱验证码登录」",signInWithOAuth:"对应的第三方身份源",signInWithIdToken:"对应的第三方身份源",signInWithOpenId:"「微信小程序 OpenID 登录」",signInWithPhoneAuth:"「微信小程序手机号授权登录」",signInWithCustomTicket:"「自定义登录」",getVerification:"「短信验证码登录」或「邮箱验证码登录」",verify:"「短信验证码登录」或「邮箱验证码登录」",verifyOtp:"「短信验证码登录」或「邮箱验证码登录」",resetPasswordForEmail:"「邮箱验证码登录」",reauthenticate:"「短信验证码登录」或「邮箱验证码登录」"}[r]||"对应的登录方式";switch(t){case Ut.PROVIDER_NOT_ENABLED:return"[CloudBase Auth] 登录方式未开启\n\n"+" 当前调用的 ".concat(r,"() 所需的登录方式尚未在云开发控制台启用。\n")+" 需要开启的登录方式:".concat(n,"\n")+"\n 请按以下步骤开启:\n"+" 1. 打开云开发控制台:".concat(Lt,"\n")+" 2. 选择对应的云开发环境\n 3. 进入「登录授权」页面,在「登录方式」或「身份源列表」中开启所需的登录方式\n\n 各登录方法与所需登录方式的对应关系:\n - signInWithPassword → 「用户名密码登录」\n - signInAnonymously → 「匿名登录」\n - signInWithOtp/signUp → 「短信验证码登录」或「邮箱验证码登录」\n - signInWithOAuth/signInWithIdToken → 对应的第三方身份源\n\n 如使用 CLI/MCP 工具,可通过 auth 工具查询和配置身份源状态。\n"+" 更多帮助请参考文档:".concat(Dt);case Ut.INVALID_CREDENTIALS:return"[CloudBase Auth] 凭据验证失败\n\n"+" 调用 ".concat(r,"() 时凭据校验未通过。\n")+"\n 请按优先级逐项排查:\n 1. 确认用户名/邮箱/手机号是否拼写正确、格式完整\n 2. 确认密码是否正确(注意大小写、特殊字符、前后空格)\n 3. 确认用户账号确实存在(可通过 auth.isUsernameRegistered() 检查)\n 4. 确认凭据参数来源可靠(环境变量、配置文件中的值是否已正确设置)\n 5. 如使用加密登录(is_encrypt: true),请确认公钥版本正确\n\n 如忘记密码,可通过 auth.resetPasswordForEmail() 重置密码。\n\n 提示:如果是 AI agent / 自动化测试场景,请确认 ENV_ID、USERNAME、PASSWORD\n 等环境变量已正确传入,且对应用户已在目标环境中注册。";case Ut.USER_NOT_FOUND:return"[CloudBase Auth] 用户不存在\n\n 请检查以下项目:\n 1. 确认用户名/邮箱/手机号是否正确\n 2. 确认是在正确的云开发环境(envId)下操作\n 3. 如果是新用户,请先通过 auth.signUp() 注册\n"+" 4. 也可在云开发控制台手动创建用户:".concat(Lt,"\n")+"\n 提示:不同环境(开发/测试/生产)的用户库是隔离的,请确认 envId 正确。";case Ut.USER_STATUS_ABNORMAL:return"[CloudBase Auth] 用户状态异常\n\n 当前用户账号可能处于以下状态之一:\n - 账号已被封禁\n - 账号正在审核中\n - 账号已被锁定(多次密码错误)\n\n"+" 请联系管理员在云开发控制台检查用户状态:".concat(Lt);case Ut.SERVICE_ERROR:return"[CloudBase Auth] 服务异常\n\n 请检查以下项目:\n 1. 网络连接是否正常\n 2. 云开发环境是否正常运行\n 3. 稍后重试,如持续失败请联系技术支持\n\n 提示:如果是超时错误,请检查网络环境和请求频率。\n 常见服务端错误:smtp 未配置、短信服务未配置、wedaapis 未设置等。";case Ut.INVALID_PARAMS:return"[CloudBase Auth] 参数错误\n\n 请检查传入的参数是否符合要求:\n - 不能同时输入手机号和邮箱\n - 手机号格式需正确(如 +86 开头)\n - 必须提供手机号或邮箱\n\n"+" 参考 API 文档确认各参数的格式和约束:".concat(Dt);case Ut.AUTH_METHOD_MISMATCH:return"[CloudBase Auth] 登录方式不匹配\n\n"+" 调用 ".concat(r,"() 时遇到错误,可能原因:\n")+" - 匿名登录失败后尝试了用户名密码登录,但凭据不正确或用户不存在\n - 应使用匿名登录但传入了密码参数\n - 应使用密码登录但未传入正确的凭据\n\n 建议:\n 1. 明确当前场景需要的登录方式:\n - 无需用户注册 → auth.signInAnonymously()\n - 有用户名和密码 → auth.signInWithPassword({ username, password })\n - 第三方平台 → auth.signInWithOAuth({ provider })\n 2. 不要在同一流程中混合使用不同的登录方式\n 3. 每种登录方式需要在控制台开启对应的身份源\n"+" 4. 控制台地址:".concat(Lt);case Ut.RATE_LIMITED:return"[CloudBase Auth] 发送频率受限\n\n 验证码发送过于频繁,已触发频率限制。\n\n 限制规则:\n - 手机号:每分钟最多 1 条,每天有上限\n - 邮箱:每分钟有上限,每天有上限(默认 50 条)\n\n 建议:\n 1. 检查 error.retryAfter 获取建议等待时间\n 2. 在 UI 中显示倒计时,防止用户重复点击\n 3. 如业务需要更高频率,请联系技术支持调整限额";case Ut.CAPTCHA_REQUIRED:return"[CloudBase Auth] 需要滑块验证码\n\n 当前操作触发了风控策略,需要完成滑块验证。\n\n 处理方式:\n 1. 调用滑块验证码 SDK 展示验证组件\n 2. 用户完成验证后,将 captcha_token 附带到请求中重新发送\n 3. 可通过 getVerification 的 options.withCaptcha 参数自动携带验证码";case Ut.CAPTCHA_INVALID:return"[CloudBase Auth] 滑块验证码校验失败\n\n 提交的验证码 token 校验未通过(可能已过期或 client_id 不匹配)。\n\n 处理方式:\n 1. 刷新滑块验证码,让用户重新验证\n 2. 确认 captcha 组件初始化的 client_id 与认证配置一致";case Ut.MFA_REQUIRED:return"[CloudBase Auth] 需要 MFA 验证\n\n 当前操作要求用户绑定手机号进行多因素认证 (MFA)。\n\n 处理方式:\n 1. 引导用户进入手机号绑定流程\n 2. 绑定完成后重新执行原操作\n 3. error 中可能包含 MFA 详情信息";case Ut.PRECONDITION_FAILED:return"[CloudBase Auth] 前置条件不满足\n\n 当前操作的前置条件不满足,常见原因:\n - 该手机号/邮箱已被其他账号绑定\n - 目标用户不存在或已存在(与 target 参数冲突)\n - 当前邮箱/手机号未注册用户\n\n 请根据 error.message 中的具体描述处理。";case Ut.VERIFICATION_FAILED:return'[CloudBase Auth] 验证码校验失败\n\n 验证码验证未通过,常见原因:\n - 验证码已过期(通常有效期为几分钟)\n - 验证码输入不正确\n - verification_id 无效或已被使用\n - 验证码不属于当前项目(project id does not match)\n\n 处理方式:\n 1. 提示用户"验证码已过期或不正确,请重新获取"\n 2. 调用 getVerification() 重新发送验证码\n 3. 确保 verification_id 与最新发送的验证码对应\n\n 注意:每次重新发送验证码后,之前的 verification_id 即失效。';default:return"[CloudBase Auth] 操作失败\n\n 如果问题持续存在,建议:\n"+" 1. 检查云开发控制台的认证配置:".concat(Lt,"\n")+" 2. 到官方问答社区提问:https://cnb.cool/tencent/cloud/cloudbase/community/-/issues\n"+" 3. 查阅文档:".concat(Dt)}}(i.category,r),i.loginMethodHint=(n=null==r?void 0:r.method)&&{signInWithPassword:"当前使用「用户名密码登录」,需确保:\n ✓ 控制台已开启「用户名密码登录」\n ✓ 用户已注册且凭据正确\n 如果不需要用户系统,建议改用 auth.signInAnonymously()",signInAnonymously:"当前使用「匿名登录」,需确保:\n ✓ 控制台已开启「匿名登录」\n 注意:匿名用户无需用户名密码,适用于快速体验或临时访问场景",signInWithOtp:"当前使用「OTP 验证码登录」,需确保:\n ✓ 控制台已开启「短信验证码登录」或「邮箱验证码登录」",signInWithOAuth:"当前使用「第三方 OAuth 登录」,需确保:\n ✓ 控制台已配置并开启对应的第三方身份源"}[n]||"",i.category===Ut.RATE_LIMITED&&(i.retryAfter=e.retry_after||e.retryAfter||void 0),i}return Nt(e,t),e.prototype.toJSON=function(){return{name:this.name,message:this.message,code:this.code,errorCode:this.errorCode,status:this.status,requestId:this.requestId,category:this.category,retryAfter:this.retryAfter}},e}(Error),xt=function(){return xt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},xt.apply(this,arguments)},Mt=function(t,e,r,n){return new(r||(r=Promise))(function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(s,a)}u((n=n.apply(t,e||[])).next())})},qt=function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=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(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};function Bt(t,e){var r;return Mt(this,void 0,void 0,function(){var n,i=this;return qt(this,function(s){n=function(){return Mt(i,void 0,void 0,function(){return qt(this,function(t){switch(t.label){case 0:return t.trys.push([0,1,,6]),[2,o(171)];case 1:t.sent(),t.label=2;case 2:return t.trys.push([2,4,,5]),[4,Promise.resolve().then(o.bind(o,171))];case 3:return[2,t.sent()];case 4:return t.sent(),[2];case 5:return[3,6];case 6:return[2]}})})};try{if(((null===(r=null==e?void 0:e.root)||void 0===r?void 0:r.globalThis)||globalThis).IS_MP_BUILD)return[2];if(t)return[2,n()]}catch(e){if(t)return[2,n()]}return[2]})})}var jt=function(){function t(t){var e=t.request,r=t.credentialsClient;if(!r){var n={apiOrigin:t.apiOrigin,apiPath:t.apiPath,clientId:t.clientId,storage:t.storage,env:t.env,baseRequest:t.baseRequest,anonymousSignInFunc:t.anonymousSignInFunc,wxCloud:t.wxCloud,onCredentialsError:t.onCredentialsError,headers:t.headers||{},i18n:t.i18n,debug:t.debug};r=new vt(n)}if(!e){var i=r.request.bind(r),o=new Rt(xt({env:t.env,clientId:t.clientId,request:i,storage:t.storage,adapter:t.adapter,oauthInstance:this},t.captchaOptions));e=o.request.bind(o)}this.config={env:t.env,apiOrigin:t.apiOrigin,apiPath:t.apiPath,clientId:t.clientId,request:e,credentialsClient:r,storage:t.storage||dt,adapter:t.adapter}}return t.parseParamsToSearch=function(t){return Object.keys(t).forEach(function(e){t[e]||delete t[e]}),new Ct(t).toString()},t.prototype.getParamsByVersion=function(t,e){var r,o=(0,A.I)(t),s=(null===(r={v2:i}[null==o?void 0:o.version])||void 0===r?void 0:r[e])||n[e];return o&&delete o.version,{params:o,url:s}},t.prototype.signIn=function(t){return Mt(this,void 0,Promise,function(){var e,r,n,i;return qt(this,function(o){switch(o.label){case 0:return e=t.version||"v1",(r=this.getParamsByVersion(t,"AUTH_SIGN_IN_URL")).params.query&&delete r.params.query,[4,this.getEncryptParams(r.params)];case 1:return n=o.sent(),[4,this.config.request(r.url,{method:"POST",body:n})];case 2:return i=o.sent(),[4,this.config.credentialsClient.setCredentials(xt(xt({},i),{version:e}))];case 3:return o.sent(),[2,Promise.resolve(i)]}})})},t.prototype.signInAnonymously=function(t,e){return void 0===t&&(t={}),void 0===e&&(e=!1),Mt(this,void 0,Promise,function(){var r;return qt(this,function(i){switch(i.label){case 0:return[4,this.config.request(n.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",body:t,useWxCloud:e})];case 1:return r=i.sent(),[4,this.config.credentialsClient.setCredentials(r)];case 2:return i.sent(),[2,Promise.resolve(r)]}})})},t.prototype.signUp=function(t){return Mt(this,void 0,Promise,function(){var e;return qt(this,function(r){switch(r.label){case 0:return[4,this.config.request(n.AUTH_SIGN_UP_URL,{method:"POST",body:t})];case 1:return e=r.sent(),[4,this.config.credentialsClient.setCredentials(e)];case 2:return r.sent(),[2,Promise.resolve(e)]}})})},t.prototype.signOut=function(t){return Mt(this,void 0,Promise,function(){var e,r,i,o;return qt(this,function(s){switch(s.label){case 0:if(e={},!t)return[3,6];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.config.request(n.AUTH_SIGNOUT_URL,{method:"POST",withCredentials:!0,body:t})];case 2:return e=s.sent(),[3,4];case 3:return(r=s.sent()).error!==u.UNAUTHENTICATED&&console.log("sign_out_error",r),[3,4];case 4:return[4,this.config.credentialsClient.setCredentials()];case 5:return s.sent(),[2,e];case 6:return[4,this.config.credentialsClient.getAccessToken()];case 7:return i=s.sent(),[4,this.config.request(n.AUTH_REVOKE_URL,{method:"POST",body:{token:i}})];case 8:return o=s.sent(),[4,this.config.credentialsClient.setCredentials()];case 9:return s.sent(),[2,Promise.resolve(o)]}})})},t.prototype.revokeAllDevices=function(){return Mt(this,void 0,Promise,function(){return qt(this,function(t){switch(t.label){case 0:return[4,this.config.request(n.AUTH_REVOKE_ALL_URL,{method:"DELETE",withCredentials:!0})];case 1:return t.sent(),[2]}})})},t.prototype.revokeDevice=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){switch(e.label){case 0:return[4,this.config.request(n.AUTHORIZED_DEVICES_DELETE_URL+t.device_id,{method:"DELETE",withCredentials:!0})];case 1:return e.sent(),[2]}})})},t.prototype.getVerification=function(t,e){return Mt(this,void 0,Promise,function(){var r,i;return qt(this,function(o){switch(o.label){case 0:return r=!1,"CUR_USER"!==t.target?[3,1]:(r=!0,[3,3]);case 1:return[4,this.hasLoginState()];case 2:o.sent()&&(r=!0),o.label=3;case 3:return(i=(0,A.I)(t)).phone_number&&!/^\+\d{1,3}\s+\d+/.test(i.phone_number)&&(i.phone_number="+86 ".concat(i.phone_number)),[2,this.config.request(n.VERIFICATION_URL,{method:"POST",body:i,withCaptcha:(null==e?void 0:e.withCaptcha)||!1,withCredentials:r})]}})})},t.prototype.verify=function(t){return Mt(this,void 0,Promise,function(){var e,r;return qt(this,function(n){switch(n.label){case 0:return e=this.getParamsByVersion(t,"VERIFY_URL"),[4,this.config.request(e.url,{method:"POST",body:e.params})];case 1:return r=n.sent(),"v2"!==(null==t?void 0:t.version)?[3,3]:[4,this.config.credentialsClient.setCredentials(xt(xt({},r),{version:"v2"}))];case 2:n.sent(),n.label=3;case 3:return[2,r]}})})},t.prototype.genProviderRedirectUri=function(e){return Mt(this,void 0,Promise,function(){var r,i,o,s,a;return qt(this,function(u){return r=e.provider_redirect_uri,i=e.other_params,o=void 0===i?{}:i,s=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]])}return r}(e,["provider_redirect_uri","other_params"]),r&&!s.redirect_uri&&(s.redirect_uri=r),a="".concat(n.PROVIDER_URI_URL,"?").concat(t.parseParamsToSearch(s)),Object.keys(o).forEach(function(t){var e=o[t];("sign_out_uri"!==t||(null==e?void 0:e.length)>0)&&(a+="&other_params[".concat(t,"]=").concat(encodeURIComponent(e)))}),[2,this.config.request(a,{method:"GET"})]})})},t.prototype.grantProviderToken=function(t,e){return void 0===e&&(e=!1),Mt(this,void 0,Promise,function(){return qt(this,function(r){return[2,this.config.request(n.PROVIDER_TOKEN_URL,{method:"POST",body:t,useWxCloud:e})]})})},t.prototype.patchProviderToken=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.config.request(n.PROVIDER_TOKEN_URL,{method:"PATCH",body:t})]})})},t.prototype.signInWithProvider=function(t,e){return void 0===e&&(e=!1),Mt(this,void 0,Promise,function(){var r,n;return qt(this,function(i){switch(i.label){case 0:return r=this.getParamsByVersion(t,"AUTH_SIGN_IN_WITH_PROVIDER_URL"),[4,this.config.request(r.url,{method:"POST",body:r.params,useWxCloud:e})];case 1:return n=i.sent(),[4,this.config.credentialsClient.setCredentials(xt(xt({},n),{version:(null==t?void 0:t.version)||"v1"}))];case 2:return i.sent(),[2,Promise.resolve(n)]}})})},t.prototype.toBindIdentity=function(t){var e,r;return Mt(this,void 0,void 0,function(){var n,i,o,s;return qt(this,function(a){switch(a.label){case 0:return(i=t.credentials)?[3,2]:[4,this.config.credentialsClient.localCredentials.getCredentials()];case 1:i=a.sent(),a.label=2;case 2:n=i,a.label=3;case 3:return a.trys.push([3,5,,6]),[4,this.bindWithProvider({provider_token:t.provider_token},n)];case 4:return a.sent(),o={data:{type:w,provider:t.provider},error:null},[3,6];case 5:return s=a.sent(),o={data:{type:w},error:new kt(s)},[3,6];case 6:return t.fireEvent&&(null===(r=null===(e=this.config.eventBus)||void 0===e?void 0:e.fire)||void 0===r||r.call(e,I,{event:y,info:o})),[2,o]}})})},t.prototype.getInitialSession=function(){return Mt(this,void 0,Promise,function(){var t,e,r,n,i,o,s,a,u,c,h,l,d,f,p;return qt(this,function(v){switch(v.label){case 0:t={},v.label=1;case 1:if(v.trys.push([1,12,,13]),"undefined"==typeof window||"undefined"==typeof document)return[2,{data:null,error:null}];if(e=new URLSearchParams(null===location||void 0===location?void 0:location.search),r=e.get("code"),n=e.get("state"),!r||!n)return[2,{data:null,error:null}];i=null;try{i=JSON.parse(sessionStorage.getItem(n)||"null")}catch(t){}return t={type:null==i?void 0:i.type},o=e.get("error"),s=e.get("error_description"),o||s?[2,{data:t,error:new kt({message:s||o||"Unknown error from OAuth provider"})}]:(a=(null==i?void 0:i.provider)||e.get("provider"))?(u=location.origin+location.pathname,[4,this.grantProviderToken({provider_id:a,provider_redirect_uri:u,provider_code:r})]):[2,{data:t,error:new kt({message:"Provider is required for OAuth verification"})}];case 2:return c=v.sent().provider_token,h=void 0,l=null,d=void 0,i.type!==w?[3,5]:[4,this.config.credentialsClient.localCredentials.getCredentials()];case 3:return h=v.sent(),[4,this.toBindIdentity({provider:a,provider_token:c,credentials:h})];case 4:return d=v.sent(),[3,11];case 5:return i.type!==b?[3,11]:(d=this.getParamsByVersion({provider:a},"AUTH_SIGN_IN_WITH_PROVIDER_URL"),[4,this.config.request(d.url,{method:"POST",body:{provider_token:c}})]);case 6:h=v.sent(),v.label=7;case 7:return v.trys.push([7,9,,10]),[4,this.getUserInfo({credentials:h})];case 8:return l=v.sent(),[3,10];case 9:return f=v.sent(),console.error("get user info error",f),[3,10];case 10:d={data:xt(xt({},t),{session:h,user:l}),error:null},v.label=11;case 11:e.delete("code"),e.delete("state"),e.delete("provider"),this.restoreUrlState(void 0===(null==i?void 0:i.search)?"?".concat(e.toString()):i.search,(null==i?void 0:i.hash)||location.hash);try{sessionStorage.removeItem(n)}catch(t){}return[2,d];case 12:return p=v.sent(),[2,{data:t,error:new kt(p)}];case 13:return[2]}})})},t.prototype.signInCustom=function(t){return Mt(this,void 0,Promise,function(){var e;return qt(this,function(r){switch(r.label){case 0:return[4,this.config.request(n.AUTH_SIGN_IN_CUSTOM,{method:"POST",body:t})];case 1:return e=r.sent(),[4,this.config.credentialsClient.setCredentials(e)];case 2:return r.sent(),[2,Promise.resolve(e)]}})})},t.prototype.signInWithWechat=function(t){return void 0===t&&(t={}),Mt(this,void 0,Promise,function(){var e;return qt(this,function(r){switch(r.label){case 0:return[4,this.config.request(n.AUTH_SIGN_IN_WITH_WECHAT_URL,{method:"POST",body:t})];case 1:return e=r.sent(),[4,this.config.credentialsClient.setCredentials(e)];case 2:return r.sent(),[2,Promise.resolve(e)]}})})},t.prototype.bindWithProvider=function(t,e){return Mt(this,void 0,Promise,function(){return qt(this,function(r){return[2,this.config.request(n.PROVIDER_BIND_URL,{method:"POST",body:t,withCredentials:!0,getCredentials:e?function(){return e}:void 0})]})})},t.prototype.getUserProfile=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.getUserInfo(t)]})})},t.prototype.getUserInfo=function(t){var e,r,n;return void 0===t&&(t={}),Mt(this,void 0,Promise,function(){var i,o,s,a,u;return qt(this,function(c){switch(c.label){case 0:return i=this.getParamsByVersion(t,"USER_ME_URL"),(null===(e=i.params)||void 0===e?void 0:e.query)&&(o=new Ct(i.params.query),i.url+="?".concat(o.toString())),[4,this.config.request(i.url,{method:"GET",withCredentials:!0,getCredentials:t.credentials?function(){return t.credentials}:void 0})];case 1:if((s=c.sent()).sub&&(s.uid=s.sub),null===(r=s.providers)||void 0===r?void 0:r.length)try{"undefined"!=typeof wx&&wx.getAccountInfoSync&&(a=null===(n=wx.getAccountInfoSync().miniProgram)||void 0===n?void 0:n.appId,(null==(u=s.providers.find(function(t){return t.id===a}))?void 0:u.provider_user_id)&&(s.open_id=u.provider_user_id))}catch(t){}return[2,s]}})})},t.prototype.getWedaUserInfo=function(){return Mt(this,void 0,Promise,function(){return qt(this,function(t){switch(t.label){case 0:return[4,this.config.request(n.WEDA_USER_URL,{method:"GET",withCredentials:!0})];case 1:return[2,t.sent()]}})})},t.prototype.deleteMe=function(e){return Mt(this,void 0,Promise,function(){var r,n;return qt(this,function(i){return r=this.getParamsByVersion(e,"USER_ME_URL"),n="".concat(r.url,"?").concat(t.parseParamsToSearch(r.params)),[2,this.config.request(n,{method:"DELETE",withCredentials:!0})]})})},t.prototype.hasLoginState=function(){return Mt(this,void 0,Promise,function(){return qt(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.config.credentialsClient.getAccessToken()];case 1:return t.sent(),[2,!0];case 2:return t.sent(),[2,!1];case 3:return[2]}})})},t.prototype.hasLoginStateSync=function(){return this.config.credentialsClient.getCredentialsSync()},t.prototype.getLoginState=function(){return Mt(this,void 0,Promise,function(){return qt(this,function(t){return[2,this.config.credentialsClient.getCredentialsAsync()]})})},t.prototype.transByProvider=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.config.request(n.USER_TRANS_BY_PROVIDER_URL,{method:"PATCH",body:t,withCredentials:!0})]})})},t.prototype.grantToken=function(t){return Mt(this,void 0,Promise,function(){var e;return qt(this,function(r){return e=this.getParamsByVersion(t,"AUTH_TOKEN_URL"),[2,this.config.request(e.url,{method:"POST",body:e.params})]})})},t.prototype.getProviders=function(){return Mt(this,void 0,Promise,function(){return qt(this,function(t){return[2,this.config.request(n.PROVIDER_LIST,{method:"GET",withCredentials:!0})]})})},t.prototype.unbindProvider=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.config.request("".concat(n.PROVIDER_UNBIND_URL,"/").concat(t.provider_id),{method:"DELETE",withCredentials:!0})]})})},t.prototype.checkPassword=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.config.request("".concat(n.CHECK_PWD_URL),{method:"POST",withCredentials:!0,body:t})]})})},t.prototype.editContact=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.config.request("".concat(n.BIND_CONTACT_URL),{method:"PATCH",withCredentials:!0,body:t})]})})},t.prototype.setPassword=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.config.request("".concat(n.AUTH_SET_PASSWORD),{method:"PATCH",withCredentials:!0,body:t})]})})},t.prototype.updatePasswordByOld=function(t){return Mt(this,void 0,Promise,function(){var e;return qt(this,function(r){switch(r.label){case 0:return[4,this.sudo({password:t.old_password})];case 1:return e=r.sent(),[2,this.setPassword({sudo_token:e.sudo_token,new_password:t.new_password})]}})})},t.prototype.sudo=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.config.request("".concat(n.SUDO_URL),{method:"POST",withCredentials:!0,body:t})]})})},t.prototype.sendVerificationCodeToCurrentUser=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return t.target="CUR_USER",[2,this.config.request(n.VERIFICATION_URL,{method:"POST",body:t,withCredentials:!0,withCaptcha:!0})]})})},t.prototype.changeBoundProvider=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.config.request("".concat(n.PROVIDER_LIST,"/").concat(t.provider_id,"/trans"),{method:"POST",body:{provider_trans_token:t.trans_token},withCredentials:!0})]})})},t.prototype.setUserProfile=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.config.request(n.USER_PRIFILE_URL,{method:"PATCH",body:t,withCredentials:!0})]})})},t.prototype.updateUserBasicInfo=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.config.request(n.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:t})]})})},t.prototype.queryUserProfile=function(t){return Mt(this,void 0,Promise,function(){var e;return qt(this,function(r){return e=new Ct(t),[2,this.config.request("".concat(n.USER_QUERY_URL,"?").concat(e.toString()),{method:"GET",withCredentials:!0})]})})},t.prototype.setCustomSignFunc=function(t){this.getCustomSignTicketFn=t},t.prototype.signInWithCustomTicket=function(){return Mt(this,void 0,Promise,function(){var t,e;return qt(this,function(r){switch(r.label){case 0:return(t=this.getCustomSignTicketFn)?[4,t()]:[2,Promise.reject({error:"failed_precondition",error_description:"please use setCustomSignFunc to set custom sign function"})];case 1:return e=r.sent(),[2,this.signInCustom({provider_id:"custom",ticket:e})]}})})},t.prototype.resetPassword=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.config.request(n.AUTH_RESET_PASSWORD,{method:"POST",body:t})]})})},t.prototype.authorize=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.config.request(n.AUTHORIZE_URL,{method:"POST",withCredentials:!0,body:t})]})})},t.prototype.authorizeDevice=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.config.request(n.AUTHORIZE_DEVICE_URL,{method:"POST",withCredentials:!0,body:t})]})})},t.prototype.deviceAuthorize=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.config.request(n.AUTH_GET_DEVICE_CODE,{method:"POST",body:t})]})})},t.prototype.authorizeInfo=function(e){return Mt(this,void 0,Promise,function(){var r,i,o;return qt(this,function(s){switch(s.label){case 0:return r="".concat(n.AUTHORIZE_INFO_URL,"?").concat(t.parseParamsToSearch(e)),i=!0,o=!1,[4,this.hasLoginState()];case 1:return s.sent()&&(o=!0,i=!1),[2,this.config.request(r,{method:"GET",withBasicAuth:i,withCredentials:o})]}})})},t.prototype.checkUsername=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.config.request(n.CHECK_USERNAME,{method:"GET",body:t,withCredentials:!0})]})})},t.prototype.checkIfUserExist=function(t){return Mt(this,void 0,Promise,function(){var e;return qt(this,function(r){return e=new Ct(t),[2,this.config.request("".concat(n.CHECK_IF_USER_EXIST,"?").concat(e.toString()),{method:"GET"})]})})},t.prototype.loginScope=function(){return Mt(this,void 0,Promise,function(){return qt(this,function(t){return[2,this.config.credentialsClient.getScope()]})})},t.prototype.loginGroups=function(){return Mt(this,void 0,Promise,function(){return qt(this,function(t){return[2,this.config.credentialsClient.getGroups()]})})},t.prototype.refreshTokenForce=function(t){return Mt(this,void 0,void 0,function(){var e;return qt(this,function(r){switch(r.label){case 0:return[4,this.config.credentialsClient.getCredentials()];case 1:return e=r.sent(),[4,this.config.credentialsClient.refreshToken(xt(xt({},e),{version:(null==t?void 0:t.version)||"v1"}))];case 2:return[2,r.sent()]}})})},t.prototype.getCredentials=function(){return Mt(this,void 0,void 0,function(){return qt(this,function(t){return[2,this.config.credentialsClient.getCredentials()]})})},t.prototype.getPublicKey=function(){return Mt(this,void 0,Promise,function(){return qt(this,function(t){return[2,this.config.request(i.AUTH_PUBLIC_KEY,{method:"POST",body:{}})]})})},t.prototype.getEncryptParams=function(t){return Mt(this,void 0,Promise,function(){var e,r,n,i,o,s;return qt(this,function(a){switch(a.label){case 0:return e=t.isEncrypt,delete t.isEncrypt,r=(0,A.I)(t),[4,Bt(e,this.config.adapter)];case 1:if(!(n=a.sent()))return[2,t];i="",o="",a.label=2;case 2:return a.trys.push([2,4,,5]),[4,this.getPublicKey()];case 3:if(s=a.sent(),i=s.public_key,o=s.public_key_thumbprint,!i||!o)throw s;return[3,5];case 4:throw a.sent();case 5:return[2,{params:n.getEncryptInfo({publicKey:i,payload:r}),public_key_thumbprint:o}]}})})},t.prototype.getProviderSubType=function(){return Mt(this,void 0,Promise,function(){return qt(this,function(t){return[2,this.config.request(n.GET_PROVIDER_TYPE,{method:"POST",body:{provider_id:"weda"}})]})})},t.prototype.verifyCaptchaData=function(t){var e=t.token,r=t.key;return Mt(this,void 0,void 0,function(){return qt(this,function(t){return[2,this.config.request(n.VERIFY_CAPTCHA_DATA_URL,{method:"POST",body:{token:e,key:r},withCredentials:!1})]})})},t.prototype.createCaptchaData=function(t){var e=t.state,r=t.redirect_uri,i=void 0===r?void 0:r;return Mt(this,void 0,void 0,function(){return qt(this,function(t){return[2,this.config.request(n.CAPTCHA_DATA_URL,{method:"POST",body:{state:e,redirect_uri:i},withCredentials:!1})]})})},t.prototype.getMiniProgramCode=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.config.request(n.GET_MINIPROGRAM_QRCODE,{method:"POST",body:t})]})})},t.prototype.getMiniProgramQrCodeStatus=function(t){return Mt(this,void 0,Promise,function(){return qt(this,function(e){return[2,this.config.request(n.GET_MINIPROGRAM_QRCODE_STATUS,{method:"POST",body:t})]})})},t.prototype.getUserBehaviorLog=function(t){return Mt(this,void 0,Promise,function(){var e,r;return qt(this,function(i){return e={LOGIN:"query[action]=USER_LOGIN",MODIFY:"ne_query[action]=USER_LOGIN"},r="".concat(n.GET_USER_BEHAVIOR_LOG,"?").concat(e[t.type],"&limit=").concat(t.limit).concat(t.page_token?"&page_token=".concat(t.page_token):""),[2,this.config.request(r,{method:"GET",withCredentials:!0})]})})},t.prototype.modifyPassword=function(t){return Mt(this,void 0,Promise,function(){var e,r,i,o,s,a;return qt(this,function(u){switch(u.label){case 0:return e="",r="",[4,Bt(!0,this.config.adapter)];case 1:if(!(i=u.sent()))throw new Error("do not support encrypt, a encrypt util required.");u.label=2;case 2:return u.trys.push([2,4,,5]),[4,this.getPublicKey()];case 3:if(o=u.sent(),e=o.public_key,r=o.public_key_thumbprint,!e||!r)throw o;return[3,5];case 4:throw u.sent();case 5:return s=t.password?i.getEncryptInfo({publicKey:e,payload:t.password}):"",a=i.getEncryptInfo({publicKey:e,payload:t.new_password}),[2,this.config.request(n.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:{user_id:t.user_id,encrypt_password:s,encrypt_new_password:a,public_key_thumbprint:r}})]}})})},t.prototype.modifyPasswordWithoutLogin=function(t){return Mt(this,void 0,Promise,function(){var e,r,n,o,s,a;return qt(this,function(u){switch(u.label){case 0:return e="",r="",[4,Bt(!0,this.config.adapter)];case 1:if(!(n=u.sent()))throw new Error("do not support encrypt, a encrypt util required.");u.label=2;case 2:return u.trys.push([2,4,,5]),[4,this.getPublicKey()];case 3:if(o=u.sent(),e=o.public_key,r=o.public_key_thumbprint,!e||!r)throw o;return[3,5];case 4:throw u.sent();case 5:return s=t.password?n.getEncryptInfo({publicKey:e,payload:t.password}):"",a=n.getEncryptInfo({publicKey:e,payload:t.new_password}),[2,this.config.request(i.AUTH_RESET_PASSWORD,{method:"POST",body:{username:t.username,password:s,new_password:a,public_key_thumbprint:r}})]}})})},t.prototype.restoreUrlState=function(t,e){if(void 0!==t)try{var r=new URL(window.location.href);r.search=t,r.hash=e||"",window.history.replaceState(null,"",r.toString()),window.location.replace(r.toString())}catch(t){}},t}(),Vt=function(){return Vt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},Vt.apply(this,arguments)},Wt=function(){function t(t){var e=t.apiOrigin,r=t.getApiOrigin,n=t.apiPath,i=void 0===n?l:n,o=t.clientId,s=t.env,a=t.storage,u=t.request,c=t.baseRequest,h=t.anonymousSignInFunc,d=t.wxCloud,f=t.adapter,p=t.onCredentialsError,v=t.headers,g=t.i18n,m=t.useWxCloud,y=t.eventBus,_=t.detectSessionInUrl,I=t.debug;if(this.detectSessionInUrl=null!=_&&_,this.oauth2client=new vt({apiOrigin:e,getApiOrigin:r,apiPath:i,clientId:o,env:s,storage:a,baseRequest:c||u,anonymousSignInFunc:h,wxCloud:d,onCredentialsError:p,headers:v||{},i18n:g,useWxCloud:m,eventBus:y,debug:I}),this.authApi=new jt(Vt(Vt({credentialsClient:this.oauth2client},t),{request:u?this.oauth2client.request.bind(this.oauth2client):void 0,adapter:f})),_)this.oauth2client.setGetInitialSession(this.authApi.getInitialSession.bind(this.authApi));else try{var b=new URL(window.location.href),w=b.searchParams.get("code"),E=b.searchParams.get("state"),S=JSON.parse(sessionStorage.getItem(E)||"null");w&&E&&(null==S?void 0:S.hash)&&(b.hash=S.hash,window.history.replaceState(null,"",b.toString()),window.location.replace(b.toString()))}catch(t){}}return t.prototype.initializeSession=function(t){this.detectSessionInUrl?(this.oauth2client.setOnInitialSessionObtained(t),this.oauth2client.initialize()):this.oauth2client.initialize(Promise.resolve({error:null}))},t}(),Ft=o(794),Ht=o(141),Gt=o(197);const Kt=(t=>{var e={};return o.d(e,t),e})({default:()=>r.default});var Yt,zt=o(182),Qt=function(){return Qt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},Qt.apply(this,arguments)},Jt=function(t,e,r,n){return new(r||(r=Promise))(function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(s,a)}u((n=n.apply(t,e||[])).next())})},Zt=function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=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(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},Xt=function(){function t(t){var e,r;try{this.localStorage=(null==t?void 0:t.localStorage)||((null===(r=null===(e=null==t?void 0:t.adapter)||void 0===e?void 0:e.root)||void 0===r?void 0:r.globalThis)||globalThis).localStorage}catch(e){this.localStorage=(null==t?void 0:t.localStorage)||{}}}return t.prototype.getItem=function(t){return Jt(this,void 0,Promise,function(){return Zt(this,function(e){return[2,this.localStorage.getItem(t)]})})},t.prototype.removeItem=function(t){return Jt(this,void 0,void 0,function(){return Zt(this,function(e){return this.localStorage.removeItem(t),[2]})})},t.prototype.setItem=function(t,e){return Jt(this,void 0,Promise,function(){return Zt(this,function(r){return this.localStorage.setItem(t,e),[2]})})},t.prototype.getItemSync=function(t){return this.localStorage.getItem(t)},t.prototype.setItemSync=function(t,e){this.localStorage.setItem(t,e)},t.prototype.removeItemSync=function(t){this.localStorage.removeItem(t)},t}(),$t=/^[^:]+:\/\/[^/]+(\/[^?#]+)/,te=function(t,e){var r,n,i,o,s=null===(r=null==e?void 0:e.headers)||void 0===r?void 0:r["x-request-id"];return t||(t={}),((null==t?void 0:t.code)||(null===(n=null==t?void 0:t.data)||void 0===n?void 0:n.error_code))&&(t={error:t.code||t.data.error,error_description:t.data.error_description||t.message||t.code||t.data.error_code,request_id:t.requestId,error_code:null===(i=t.data)||void 0===i?void 0:i.error_code}),(null==t?void 0:t.request_id)||(t.request_id=t.request_id||s),(null==t?void 0:t.error)?(t.error_uri=(o=null==e?void 0:e.url,$t.test(o)?RegExp.$1:o),t):(null==t?void 0:t.data)||{}},ee=function(t){return t.adapter&&"default"!==t.adapter.type?function(t,e){var r=Qt({},t);try{if(!(null==t?void 0:t.storage)&&(null==e?void 0:e.localStorage)&&(r.storage=new Xt({localStorage:e.localStorage,adapter:e})),!t.captchaOptions&&(null==e?void 0:e.captchaOptions)&&(r.captchaOptions=e.captchaOptions),!t.baseRequest&&!t.request&&(null==e?void 0:e.reqClass)){var n={timeout:1e4,restrictedMethods:["get","post","upload","download","request"],auth:t.auth},i=new e.reqClass(n);r.baseRequest=function(t,e){var r,n,o,s,a;return Jt(this,void 0,void 0,function(){var u,c,h,l;return Zt(this,function(d){switch(d.label){case 0:if(u={},c=(null===(r=e.method)||void 0===r?void 0:r.toLocaleLowerCase())||"post","function"!=typeof(h=null===(o=null===(n=null==i?void 0:i[c])||void 0===n?void 0:n.bind)||void 0===o?void 0:o.call(n,i)))throw new Error("invalid 【".concat(c,"】 request method"));d.label=1;case 1:return d.trys.push([1,3,,4]),(null===(s=e.headers)||void 0===s?void 0:s["content-type"])&&!(null===(a=e.headers)||void 0===a?void 0:a["content-type"].includes("application/json"))||["string","undefined"].includes(typeof e.body)||(e.data=e.data||e.body,e.body=JSON.stringify(e.body)),[4,h(Qt({url:t},e))];case 2:return u=d.sent(),u=te(u,Qt(Qt({},e),{url:t})),[3,4];case 3:throw l=d.sent(),u=Qt(Qt({},null==l?void 0:l.data),l);case 4:if(null==u?void 0:u.error)throw u;return[2,u]}})})}}}catch(t){console.error("user adapter generate fail:",t)}return r}(t,t.adapter):function(t,e){var r=Qt({},t),n={};if((null==e?void 0:e.captchaOptions)&&(r.captchaOptions=e.captchaOptions),!Kt.default.isMatch()||t.storage&&t.baseRequest)return r;try{var i=Kt.default.genAdapter({}),o=i.localStorage,s=i.reqClass;if(o&&(n.storage=new Xt({localStorage:o,adapter:e})),s){var a=new s({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});n.request=function(t){return function(e,r){return Jt(this,void 0,void 0,function(){return Zt(this,function(n){return[2,new Promise(function(n,i){var o=Object.assign({},r);o.body&&"string"!=typeof o.body&&(o.body=JSON.stringify(o.body));var s=wx.request({url:e,data:o.body,timeout:t._timeout,method:o.method||"GET",header:o.headers,success:function(t){(t=te(t,Qt(Qt({},r),{url:e}))).error&&i(t),n(t)},fail:function(t){i({error:"unreachable",error_description:t.message})},complete:function(e){if(e&&e.errMsg&&t._timeout&&-1!==t._restrictedMethods.indexOf("request")&&"request:fail timeout"===e.errMsg){console.warn(t._timeoutMsg);try{s.abort()}catch(t){}}}})})]})})}}(a)}return r.captchaOptions&&(n.baseRequest=n.request,n.request=void 0),Qt(Qt({},r),n)}catch(t){console.error("adapter generate fail:",t)}return r}(t,t.adapter)},re=function(){return re=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},re.apply(this,arguments)},ne=function(t,e,r,n){return new(r||(r=Promise))(function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(s,a)}u((n=n.apply(t,e||[])).next())})},ie=function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=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(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},oe=function(){function t(t){}return t.prototype.signInWithRedirect=function(){throw new Error("[v1 兼容] WeixinAuthProvider.signInWithRedirect() 在当前版本中无法实现。 建议使用 auth.signInWithOAuth({ provider: 'providerId' }) 替代。")},t.prototype.getRedirectResult=function(t){return ne(this,void 0,Promise,function(){return ie(this,function(t){throw new Error("[v1 兼容] WeixinAuthProvider.getRedirectResult() 在当前版本中无法实现。 建议使用 auth.verifyOAuth({ code, state, provider }) 替代。")})})},t.prototype.getLinkRedirectResult=function(t){return ne(this,void 0,Promise,function(){return ie(this,function(t){throw new Error("[v1 兼容] WeixinAuthProvider.getLinkRedirectResult() 在当前版本中无法实现。 建议使用 auth.linkIdentity({ provider: 'providerId' }) 替代。")})})},t}(),se=function(){function t(t){this.authInstance=t.authInstance}return t.prototype.signIn=function(t){return ne(this,void 0,Promise,function(){return ie(this,function(e){switch(e.label){case 0:return[4,this.authInstance.signInWithCustomTicket(function(){return Promise.resolve(t)})];case 1:return e.sent(),[2]}})})},t}(),ae=function(){function t(t){this.authInstance=t.authInstance}return t.prototype.signIn=function(){return ne(this,void 0,Promise,function(){return ie(this,function(t){switch(t.label){case 0:return[4,this.authInstance.signInAnonymously({})];case 1:return t.sent(),[2]}})})},t}(),ue=function(){function t(){}return t.prototype.weixinAuthProvider=function(t){return new oe({authInstance:this,appid:t.appid,scope:t.scope})},t.prototype.customAuthProvider=function(){return new se({authInstance:this})},t.prototype.anonymousAuthProvider=function(){return new ae({authInstance:this})},t.prototype.signUpWithEmailAndPassword=function(t,e){return ne(this,void 0,Promise,function(){return ie(this,function(r){switch(r.label){case 0:return"string"!=typeof t&&(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"email must be a string"),"string"!=typeof e&&(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signUp({email:t,password:e})];case 1:return[2,r.sent()]}})})},t.prototype.signInWithEmailAndPassword=function(t,e){return ne(this,void 0,Promise,function(){return ie(this,function(r){switch(r.label){case 0:return"string"!=typeof t&&(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"email must be a string"),"string"!=typeof e&&(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signIn({username:t,password:e})];case 1:return r.sent(),[2,this.createLoginState()]}})})},t.prototype.sendPasswordResetEmail=function(t){return ne(this,void 0,Promise,function(){return ie(this,function(e){switch(e.label){case 0:return"string"!=typeof t&&(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"email must be a string"),[4,this.getVerification({email:t})];case 1:return e.sent(),[2]}})})},t.prototype.signInWithUsernameAndPassword=function(t,e){return ne(this,void 0,Promise,function(){return ie(this,function(r){switch(r.label){case 0:return"string"!=typeof t&&(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"username must be a string"),"string"!=typeof e&&(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signIn({username:t,password:e})];case 1:return r.sent(),[2,this.createLoginState()]}})})},t.prototype.sendPhoneCode=function(t){return ne(this,void 0,Promise,function(){var e;return ie(this,function(r){switch(r.label){case 0:return"string"!=typeof t&&(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),e=this.formatPhone(t),[4,this.getVerification({phone_number:e})];case 1:return r.sent(),[2,!0]}})})},t.prototype.signUpWithPhoneCode=function(t,e,r){return ne(this,void 0,Promise,function(){var n;return ie(this,function(i){switch(i.label){case 0:return"string"!=typeof t&&(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),"string"!=typeof e&&(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"phoneCode must be a string"),n=this.formatPhone(t),[4,this.signUp(re({phone_number:n,verification_code:e},r?{password:r}:{}))];case 1:return i.sent(),[2,this.createLoginState()]}})})},t.prototype.signInWithPhoneCodeOrPassword=function(t){return ne(this,void 0,Promise,function(){var e,r,n,i;return ie(this,function(o){switch(o.label){case 0:return e=t.phoneNumber,r=t.phoneCode,n=t.password,"string"!=typeof e&&(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),i=this.formatPhone(e),n?[4,this.signIn({username:i,password:n})]:[3,2];case 1:return o.sent(),[3,5];case 2:return r?[4,this.signIn({username:i,verification_token:r})]:[3,4];case 3:return o.sent(),[3,5];case 4:(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"phoneCode or password must be provided"),o.label=5;case 5:return[2,this.createLoginState()]}})})},t.prototype.forceResetPwdByPhoneCode=function(t){return ne(this,void 0,Promise,function(){var e,r,n,i;return ie(this,function(o){switch(o.label){case 0:return e=t.phoneNumber,r=t.phoneCode,n=t.password,"string"!=typeof e&&(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),"string"!=typeof r&&(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"phoneCode must be a string"),"string"!=typeof n&&(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"password must be a string"),i=this.formatPhone(e),[4,this.resetPassword({phone_number:i,new_password:n,verification_token:r})];case 1:return o.sent(),[4,this.signIn({username:i,password:n})];case 2:return o.sent(),[2,this.createLoginState()]}})})},t.prototype.shouldRefreshAccessToken=function(t){throw new Error("[v1 兼容] shouldRefreshAccessToken() 在当前版本中无法实现。 建议使用 auth.onAuthStateChange(callback) 来监听 TOKEN_REFRESHED 事件替代。")},t.prototype.onLoginStateExpired=function(t){var e=this;this.onLoginStateChanged(function(r){(null==r?void 0:r.eventType)===f&&t.call(e)})},t.prototype.onAccessTokenRefreshed=function(t){var e=this;this.onAuthStateChange(function(r){r===g&&t.call(e)})},t.prototype.onAnonymousConverted=function(t){var e=this;this.onAuthStateChange(function(r){r===v&&t.call(e)})},t.prototype.onLoginTypeChanged=function(t){var e=this;this.onAuthStateChange(function(r){r!==v&&r!==p||t.call(e)})},t}(),ce=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),he=function(){return he=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},he.apply(this,arguments)},le=function(t,e,r,n){var i,o=arguments.length,s=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},de=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},fe=function(t,e,r,n){return new(r||(r=Promise))(function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(s,a)}u((n=n.apply(t,e||[])).next())})},pe=function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=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(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},ve=function(){return"undefined"!=typeof window&&"undefined"!=typeof document},ge=function(t){return function(e){t.fire(_,he(he({},e),{eventType:f}))}},me=function(){function e(t){var e=t.cache,r=t.oauthInstance;this.cache=e,this.oauthInstance=r,this.setUserInfo()}var r,n,i;return e.prototype.checkLocalInfo=function(){return fe(this,void 0,void 0,function(){return pe(this,function(t){return this.uid=this.getLocalUserInfo("uid"),this.gender=this.getLocalUserInfo("gender"),this.picture=this.getLocalUserInfo("picture"),this.email=this.getLocalUserInfo("email"),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),this.username=this.getLocalUserInfo("username"),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]})})},e.prototype.checkLocalInfoAsync=function(){return fe(this,void 0,void 0,function(){var t,e,r,n;return pe(this,function(i){switch(i.label){case 0:return t=this,[4,this.getLocalUserInfoAsync("uid")];case 1:return t.uid=i.sent(),e=this,[4,this.getLocalUserInfoAsync("gender")];case 2:return e.gender=i.sent(),this.picture=this.getLocalUserInfo("picture"),r=this,[4,this.getLocalUserInfoAsync("email")];case 3:return r.email=i.sent(),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),n=this,[4,this.getLocalUserInfoAsync("username")];case 4:return n.username=i.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(t){return fe(this,void 0,Promise,function(){var e;return pe(this,function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.setUserProfile(he({},t))];case 1:return e=r.sent(),this.setLocalUserInfo(e),[2]}})})},e.prototype.updateUserBasicInfo=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.updateUserBasicInfo(he({},t))];case 1:return e.sent(),[4,this.refresh()];case 2:return e.sent(),[2]}})})},e.prototype.updatePassword=function(t,e){return this.oauthInstance.authApi.updatePasswordByOld({old_password:e,new_password:t})},e.prototype.updateUsername=function(t){return"string"!=typeof t&&(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"username must be a string"),this.update({username:t})},e.prototype.refresh=function(t){return fe(this,void 0,Promise,function(){var e;return pe(this,function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.getUserInfo(t)];case 1:if("INVALID_ACCESS_TOKEN"===(e=r.sent()).code)throw this.setLocalUserInfo({}),e;return this.setLocalUserInfo(e),[2,e]}})})},e.prototype.getLocalUserInfo=function(t){var e=this.cache.keys.userInfoKey,r=this.cache.getStore(e);return t?r[t]:r||{}},e.prototype.setLocalUserInfo=function(t){var e=this.cache.keys.userInfoKey;this.cache.setStore(e,t),this.setUserInfo()},e.prototype.getLocalUserInfoAsync=function(t){return fe(this,void 0,Promise,function(){var e;return pe(this,function(r){switch(r.label){case 0:return e=this.cache.keys.userInfoKey,[4,this.cache.getStoreAsync(e)];case 1:return[2,r.sent()[t]]}})})},e.prototype.setUserInfo=function(){var t=this,e=this.cache.keys.userInfoKey,r=this.cache.getStore(e);["uid","email","name","gender","picture","email_verified","phone_number","birthdate","zoneinfo","locale","sub","created_from","providers","username","created_at","open_id"].forEach(function(e){t[e]=r[e]})},le([(0,Ht.catchErrorsDecorator)({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",["function"==typeof(r=t.UserProfile)?r:Object]),de("design:returntype","function"==typeof(n="undefined"!=typeof Promise&&Promise)?n:Object)],e.prototype,"update",null),le([(0,Ht.catchErrorsDecorator)({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",[String,String]),de("design:returntype",void 0)],e.prototype,"updatePassword",null),le([(0,Ht.catchErrorsDecorator)({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",[String]),de("design:returntype",void 0)],e.prototype,"updateUsername",null),le([(0,Ht.catchErrorsDecorator)({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",[Object]),de("design:returntype","function"==typeof(i="undefined"!=typeof Promise&&Promise)?i:Object)],e.prototype,"refresh",null),e}();(Yt=me).prototype.linkWithTicket=function(t){return ne(this,void 0,Promise,function(){return ie(this,function(t){throw new Error("[v1 兼容] User.linkWithTicket() 在当前版本中无法实现。 建议使用 auth.signInWithCustomTicket(() => Promise.resolve(ticket)) 替代。")})})},Yt.prototype.linkWithRedirect=function(t){throw new Error("[v1 兼容] User.linkWithRedirect() 在当前版本中无法实现。 建议使用 auth.linkIdentity({ provider: 'providerId' }) 替代。")},Yt.prototype.updateEmail=function(t,e){return ne(this,void 0,Promise,function(){return ie(this,function(e){switch(e.label){case 0:return"string"!=typeof t&&(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"newEmail must be a string"),[4,this.updateUserBasicInfo({email:t})];case 1:return e.sent(),[2]}})})},Yt.prototype.linkWithPhoneNumber=function(t,e){return ne(this,void 0,Promise,function(){return ie(this,function(t){throw new Error("[v1 兼容] User.linkWithPhoneNumber() 在当前版本中无法实现。 建议使用 auth.bindPhoneNumber({ phone_number, verification_token, sudo_token }) 替代。")})})},Yt.prototype.updatePhoneNumber=function(t,e){return ne(this,void 0,Promise,function(){return ie(this,function(t){throw new Error("[v1 兼容] User.updatePhoneNumber() 在当前版本中无法实现。 建议使用 auth.updateUser({ phone: newPhoneNumber }) 替代。")})})},Yt.prototype.unlink=function(t){return ne(this,void 0,Promise,function(){return ie(this,function(t){throw new Error("[v1 兼容] User.unlink() 在当前版本中无法实现。 建议使用 auth.unlinkIdentity({ provider: loginType }) 替代。")})})};var ye=function(){function t(t){var e=t.envId,r=t.cache,n=t.oauthInstance;e||(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"envId is not defined"),this.cache=r,this.oauthInstance=n,this.user=new me({cache:this.cache,oauthInstance:n})}return t.prototype.checkLocalState=function(){var t;this.oauthLoginState=null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.hasLoginStateSync(),this.user.checkLocalInfo()},t.prototype.checkLocalStateAsync=function(){var t;return fe(this,void 0,void 0,function(){return pe(this,function(e){switch(e.label){case 0:return[4,null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.getLoginState()];case 1:return e.sent(),[4,this.user.checkLocalInfoAsync()];case 2:return e.sent(),[2]}})})},t}(),_e=function(e){function r(t){var r=e.call(this)||this;return r.listeners=new Map,r.hasListenerSetUp=!1,r.config=t,r.oauthInstance=t.oauthInstance,r.cache=t.cache,r.init(),r.setAccessKey(),r}var n,i,o,s,a,u,c,h,l,d,g,y,S,A,P,O,T,R,C,U,L;return ce(r,e),r.prototype.signInAnonymously=function(t){return fe(this,void 0,Promise,function(){var e,r,n,i,o;return pe(this,function(s){switch(s.label){case 0:return s.trys.push([0,4,,5]),[4,this.oauthInstance.authApi.signInAnonymously(t)];case 1:return s.sent(),[4,this.createLoginState()];case 2:return e=s.sent(),[4,this.getSession()];case 3:return r=s.sent().data,n=(void 0===r?{}:r).session,[2,he(he({},e),{data:{user:n.user,session:n},error:null})];case 4:return i=s.sent(),(o=new kt(i,{method:"signInAnonymously"})).category===Ut.PROVIDER_NOT_ENABLED?(console.error(o.helpMessage),console.error("[CloudBase Auth] 提示:匿名登录需要在控制台开启「匿名登录」。\n 如果您需要使用用户名密码登录,请改用 auth.signInWithPassword({ username, password })。\n 不要在匿名登录失败后自动回退到密码登录,这两种方式的使用场景不同。")):(console.warn("[CloudBase Auth] signInAnonymously 失败 [".concat(o.category,"]: ").concat(o.message)),o.loginMethodHint&&console.warn(o.loginMethodHint)),[2,{data:{user:null,session:null},error:o}];case 5:return[2]}})})},r.prototype.signUp=function(t){return fe(this,void 0,Promise,function(){var e,r,n=this;return pe(this,function(i){switch(i.label){case 0:return t.phone_number||t.verification_code||t.verification_token||t.provider_token?(t.phone_number&&(t.phone_number=this.formatPhone(t.phone_number)),[4,this.oauthInstance.authApi.signUp(t)]):[3,2];case 1:return i.sent(),[2,this.createLoginState()];case 2:return i.trys.push([2,4,,5]),this.validateAtLeastOne(t,[["email"],["phone"]],"You must provide either an email or phone number"),[4,this.getVerification(t.email?{email:t.email}:{phone_number:this.formatPhone(t.phone)})];case 3:return e=i.sent(),[2,{data:{verifyOtp:function(r){var i=r.token,o=r.messageId,s=void 0===o?e.verification_id:o;return fe(n,void 0,Promise,function(){var r,n,o,a,u;return pe(this,function(c){switch(c.label){case 0:return c.trys.push([0,8,,9]),[4,this.verify({verification_id:s||e.verification_id,verification_code:String(i)})];case 1:return r=c.sent(),e.is_user?[4,this.signIn({username:t.email||this.formatPhone(t.phone),verification_token:r.verification_token})]:[3,3];case 2:return c.sent(),[3,6];case 3:return delete(n=JSON.parse(JSON.stringify(t))).email,delete n.phone,[4,this.oauthInstance.authApi.signUp(he(he(he({},n),t.email?{email:t.email}:{phone_number:this.formatPhone(t.phone)}),{verification_token:r.verification_token,verification_code:i}))];case 4:return c.sent(),[4,this.createLoginState()];case 5:c.sent(),c.label=6;case 6:return[4,this.getSession()];case 7:return o=c.sent().data,[2,{data:{user:(a=(void 0===o?{}:o).session).user,session:a},error:null}];case 8:return u=c.sent(),[2,{data:{user:null,session:null},error:new kt(u,{method:"signUp"})}];case 9:return[2]}})})}},error:null}];case 4:return r=i.sent(),[2,{data:{user:null,session:null},error:new kt(r,{method:"signUp"})}];case 5:return[2]}})})},r.prototype.signOut=function(t){var e,r;return fe(this,void 0,Promise,function(){var n,i,o;return pe(this,function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),n=this.cache.keys.userInfoKey,[4,this.oauthInstance.authApi.signOut(t)];case 1:return i=s.sent(),[4,this.cache.removeStoreAsync(n)];case 2:return s.sent(),this.setAccessKey(),null===(e=this.config.eventBus)||void 0===e||e.fire(_,{eventType:"sign_out"}),null===(r=this.config.eventBus)||void 0===r||r.fire(I,{event:p}),[2,he(he({},i),{data:{},error:null})];case 3:return o=s.sent(),[2,{data:{},error:new kt(o,{method:"signOut"})}];case 4:return[2]}})})},r.prototype.onAuthStateChange=function(t){var e=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(t),{data:{subscription:{id:r,callback:t,unsubscribe:function(){var n=e.listeners.get(r);n&&(n.delete(t),0===n.size&&e.listeners.delete(r))}}}}},r.prototype.signInWithPassword=function(t){var e;return fe(this,void 0,Promise,function(){var r,n,i,o,s,a,u;return pe(this,function(c){switch(c.label){case 0:return c.trys.push([0,3,,4]),this.validateAtLeastOne(t,[["username"],["email"],["phone"]],"You must provide either username, email, or phone"),this.validateParams(t,{password:{required:!0,message:"Password is required"}}),r="username"in t?t.username:void 0,n="email"in t?t.email:void 0,i="phone"in t?t.phone:void 0,[4,this.signIn(he({username:r||n||this.formatPhone(i),password:t.password},(null===(e=t.options)||void 0===e?void 0:e.is_encrypt)?{isEncrypt:!0,version:"v2"}:{}))];case 1:return c.sent(),[4,this.getSession()];case 2:return o=c.sent().data,[2,{data:{user:(s=(void 0===o?{}:o).session).user,session:s},error:null}];case 3:return a=c.sent(),(u=new kt(a,{method:"signInWithPassword"})).category===Ut.PROVIDER_NOT_ENABLED?console.error(u.helpMessage):u.category===Ut.INVALID_CREDENTIALS||u.category===Ut.USER_NOT_FOUND?console.warn(u.helpMessage):console.warn("[CloudBase Auth] signInWithPassword 失败 [".concat(u.category,"]: ").concat(u.message)),u.loginMethodHint&&console.info(u.loginMethodHint),[2,{data:{user:null,session:null},error:u}];case 4:return[2]}})})},r.prototype.signInWithIdToken=function(t){return fe(this,void 0,Promise,function(){var e,r,n;return pe(this,function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),this.validateParams(t,{token:{required:!0,message:"Token is required"}}),[4,this.signInWithProvider({provider_token:t.token})];case 1:return i.sent(),[4,this.getSession()];case 2:return e=i.sent().data,[2,{data:{user:(r=(void 0===e?{}:e).session).user,session:r},error:null}];case 3:return n=i.sent(),[2,{data:{user:null,session:null},error:new kt(n,{method:"signInWithIdToken"})}];case 4:return[2]}})})},r.prototype.signInWithOtp=function(t){return fe(this,void 0,Promise,function(){var e,r,n,i,o,s=this;return pe(this,function(a){switch(a.label){case 0:if(e=t.options,r="email"in t?t.email:void 0,n="phone"in t?t.phone:void 0,!(null==e?void 0:e.emailRedirectTo)&&(void 0===(null==e?void 0:e.shouldCreateUser)||(null==e?void 0:e.shouldCreateUser)))return[2,this.signUp(r?{email:r}:{phone:n})];a.label=1;case 1:return a.trys.push([1,3,,4]),this.validateAtLeastOne(t,[["email"],["phone"]],"You must provide either an email or phone number"),[4,this.getVerification(he(he({email_redirect_to:null==e?void 0:e.emailRedirectTo},r?{email:r}:{phone_number:this.formatPhone(n)}),{target:"USER"}))];case 2:return i=a.sent(),[2,{data:{user:null,session:null,verifyOtp:function(t){var e=t.token,o=t.messageId,a=void 0===o?i.verification_id:o;return fe(s,void 0,Promise,function(){return pe(this,function(t){return[2,this.verifyOtp(r?{email:r,token:String(e),messageId:a}:{phone:n,token:String(e),messageId:a})]})})}},error:null}];case 3:return o=a.sent(),[2,{data:{user:null,session:null},error:new kt(o,{method:"signInWithOtp"})}];case 4:return[2]}})})},r.prototype.verifyOAuth=function(t){return fe(this,void 0,Promise,function(){var e,r,n,i,o,s,a,u,c;return pe(this,function(h){switch(h.label){case 0:e={},h.label=1;case 1:return h.trys.push([1,7,,8]),r=(null==t?void 0:t.code)||B("code"),n=(null==t?void 0:t.state)||B("state"),r?n?(i=function(t){try{return JSON.parse(sessionStorage.getItem(t))}catch(t){return console.error("Failed to get browser session:",t),null}}(n),e.type=null==i?void 0:i.type,(o=(null==t?void 0:t.provider)||(null==i?void 0:i.provider)||B("provider"))?[4,this.grantProviderToken({provider_id:o,provider_redirect_uri:location.origin+location.pathname,provider_code:r})]:[2,{data:he(he({},e),{user:null,session:null,redirectUrl:null}),error:new kt({message:"Provider is required"})}]):[2,{data:{user:null,session:null,redirectUrl:null},error:new kt({message:"State is required"})}]:[2,{data:{user:null,session:null,redirectUrl:null},error:new kt({message:"Code is required"})}];case 2:return s=h.sent().provider_token,a=void 0,i.type!==w?[3,4]:[4,this.oauthInstance.authApi.toBindIdentity({provider_token:s,provider:o,fireEvent:!0})];case 3:return a=h.sent(),[3,6];case 4:return[4,this.signInWithIdToken({token:s})];case 5:(a=h.sent()).data=he(he({},e),a.data),h.label=6;case 6:return(u=new URLSearchParams(null===location||void 0===location?void 0:location.search)).delete("code"),u.delete("state"),a.data.redirectUrl=function(t,e){if(void 0!==t){var r=new URL(window.location.href);return r.search=t,r.hash=e||r.hash,window.history.replaceState({},"",r.href),r.href}}(void 0===(null==i?void 0:i.search)?"?".concat(u.toString()):null==i?void 0:i.search,(null==i?void 0:i.hash)||location.hash),function(t){try{return sessionStorage.removeItem(t),!0}catch(t){return console.error("Failed to remove browser session:",t),null}}(n),[2,a];case 7:return c=h.sent(),[2,{data:he(he({},e),{user:null,session:null,redirectUrl:null}),error:new kt(c,{method:"verifyOAuth"})}];case 8:return[2]}})})},r.prototype.signInWithOAuth=function(t){var e,r,n,i,o;return fe(this,void 0,Promise,function(){var s,a,u,c,h,l,d,f,p;return pe(this,function(v){switch(v.label){case 0:return v.trys.push([0,2,,3]),this.validateParams(t,{provider:{required:!0,message:"Provider is required"}}),s=(null===(e=t.options)||void 0===e?void 0:e.redirectTo)||location.href,a=new URL(s),u=a.origin+a.pathname,c=(null===(r=t.options)||void 0===r?void 0:r.state)||"prd-".concat(t.provider,"-").concat(Math.random().toString(36).slice(2)),[4,this.genProviderRedirectUri({provider_id:t.provider,provider_redirect_uri:u,state:c})];case 1:return h=v.sent().uri,l=decodeURIComponent(h),d=l,(null===(n=t.options)||void 0===n?void 0:n.queryParams)&&(f=new URL(l),Object.entries(t.options.queryParams).forEach(function(t){var e=t[0],r=t[1];f.searchParams.set(e,r)}),d=f.toString()),function(t,e){try{sessionStorage.setItem(t,JSON.stringify(e))}catch(t){console.error("Failed to save to browser session:",t)}}(c,{provider:t.provider,search:a.search,hash:a.hash,type:(null===(i=t.options)||void 0===i?void 0:i.type)||b}),ve()&&!(null===(o=t.options)||void 0===o?void 0:o.skipBrowserRedirect)&&window.location.assign(d),[2,{data:{url:d,provider:t.provider},error:null}];case 2:return p=v.sent(),[2,{data:{url:null,provider:null},error:new kt(p,{method:"signInWithOAuth"})}];case 3:return[2]}})})},r.prototype.getClaims=function(){return fe(this,void 0,Promise,function(){var t;return pe(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.getAccessToken()];case 1:return[2,{data:function(t){if("string"!=typeof t)throw new Error("Invalid token specified");try{var e=t.split(".").map(function(t,e){return 2===e?t:JSON.parse(function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw new Error("Illegal base64url string!")}try{return function(t){return decodeURIComponent(N(t).replace(/(.)/g,function(t){var e=t.charCodeAt(0).toString(16).toUpperCase();return e.length<2&&(e="0".concat(e)),"%".concat(e)}))}(e)}catch(t){return N(e)}}(t))});return{claims:e[1],header:e[0],signature:e[2]}}catch(t){throw new Error("Invalid token specified: ".concat(t)?t.message:0)}}(e.sent().accessToken),error:null}];case 2:return t=e.sent(),[2,{data:{claims:null,header:null,signature:null},error:new kt(t,{method:"getClaims"})}];case 3:return[2]}})})},r.prototype.resetPasswordForEmail=function(t,e){return fe(this,void 0,Promise,function(){var r,n,i,o,s,a,u=this;return pe(this,function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),this.validateParams({emailOrPhone:t},{emailOrPhone:{required:!0,message:"Email or phone is required"}}),r=(e||{}).redirectTo,n=t.includes("@"),i=void 0,n?i={email:t}:(o=this.formatPhone(t),i={phone_number:o}),[4,this.getVerification(he(he({},i),{target:"USER"}))];case 1:return s=c.sent(),[2,{data:{updateUser:function(e){return fe(u,void 0,Promise,function(){var i,o,a,u;return pe(this,function(c){switch(c.label){case 0:this.validateParams(e,{nonce:{required:!0,message:"Nonce is required"},password:{required:!0,message:"Password is required"}}),c.label=1;case 1:return c.trys.push([1,5,,6]),[4,this.verify({verification_id:s.verification_id,verification_code:e.nonce})];case 2:return i=c.sent(),[4,this.oauthInstance.authApi.resetPassword({email:n?t:void 0,phone_number:n?void 0:t,new_password:e.password,verification_token:i.verification_token})];case 3:return c.sent(),null===(u=this.config.eventBus)||void 0===u||u.fire(I,{event:"PASSWORD_RECOVERY"}),[4,this.signInWithPassword({email:n?t:void 0,phone:n?void 0:t,password:e.password})];case 4:return o=c.sent(),r&&ve()&&window.location.assign(r),[2,o];case 5:return a=c.sent(),[2,{data:{user:null,session:null},error:new kt(a,{method:"resetPasswordForEmail"})}];case 6:return[2]}})})}},error:null}];case 2:return a=c.sent(),[2,{data:{updateUser:null},error:new kt(a,{method:"resetPasswordForEmail"})}];case 3:return[2]}})})},r.prototype.resetPasswordForOld=function(t){return fe(this,void 0,Promise,function(){var e,r,n;return pe(this,function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,this.oauthInstance.authApi.updatePasswordByOld({old_password:t.old_password,new_password:t.new_password})];case 1:return i.sent(),[4,this.getSession()];case 2:return e=i.sent().data,[2,{data:{user:(r=(void 0===e?{}:e).session).user,session:r},error:null}];case 3:return n=i.sent(),[2,{data:{user:null,session:null},error:new kt(n,{method:"resetPasswordForOld"})}];case 4:return[2]}})})},r.prototype.verifyOtp=function(t){return fe(this,void 0,Promise,function(){var e,r,n,i,o,s,a;return pe(this,function(u){switch(u.label){case 0:return u.trys.push([0,6,,7]),e=t.type,r=String(t.token),n="email"in t?t.email:void 0,i="phone"in t?t.phone:void 0,this.validateParams(t,{token:{required:!0,message:"Token is required"},messageId:{required:!0,message:"messageId is required"}}),["phone_change","email_change"].includes(e)?[4,this.verify({verification_id:t.messageId,verification_code:r})]:[3,2];case 1:return u.sent(),[3,4];case 2:return[4,this.signInWithUsername({verificationInfo:{verification_id:t.messageId,is_user:!0},verificationCode:r,username:n||this.formatPhone(i)||"",loginType:n?"email":"phone"})];case 3:u.sent(),u.label=4;case 4:return[4,this.getSession()];case 5:return o=u.sent().data,[2,{data:{user:(s=(void 0===o?{}:o).session).user,session:s},error:null}];case 6:return a=u.sent(),[2,{data:{user:null,session:null},error:new kt(a,{method:"verifyOtp"})}];case 7:return[2]}})})},r.prototype.getSession=function(){return fe(this,void 0,Promise,function(){var t,e,r,n;return pe(this,function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,this.oauthInstance.oauth2client.getCredentials()];case 1:return(t=i.sent())&&"accessKey"!==t.scope?[4,this.getUser(!1)]:[2,{data:{session:null,user:null},error:null}];case 2:return e=i.sent().data,r=(void 0===e?{}:e).user,[2,{data:{session:he(he({},t),{user:r}),user:r},error:null}];case 3:return n=i.sent(),[2,{data:{session:null,user:null},error:new kt(n,{method:"getSession"})}];case 4:return[2]}})})},r.prototype.refreshSession=function(t){return fe(this,void 0,Promise,function(){var e,r,n,i,o;return pe(this,function(s){switch(s.label){case 0:return s.trys.push([0,4,,5]),[4,this.oauthInstance.oauth2client.localCredentials.getCredentials()];case 1:return(e=s.sent()).refresh_token=t||e.refresh_token,[4,this.oauthInstance.oauth2client.refreshToken(e)];case 2:return r=s.sent(),[4,this.getUser(!1)];case 3:return n=s.sent().data,[2,{data:{user:i=(void 0===n?{}:n).user,session:he(he({},r),{user:i})},error:null}];case 4:return o=s.sent(),[2,{data:{user:null,session:null},error:new kt(o,{method:"refreshSession"})}];case 5:return[2]}})})},r.prototype.getUser=function(t){return void 0===t&&(t=!0),fe(this,void 0,Promise,function(){var e,r,n;return pe(this,function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,this.oauthInstance.oauth2client.getCredentials()];case 1:return(e=i.sent())&&"accessKey"!==e.scope?(r=this.convertToUser,[4,this.getCurrentUser(t)]):[2,{data:{user:null},error:null}];case 2:return[2,{data:{user:r.apply(this,[i.sent()])},error:null}];case 3:return n=i.sent(),[2,{data:{user:null},error:new kt(n,{method:"getUser"})}];case 4:return[2]}})})},r.prototype.refreshUser=function(){return fe(this,void 0,Promise,function(){var t,e,r;return pe(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 t=n.sent().data,[2,{data:{user:(e=(void 0===t?{}:t).session).user,session:e},error:null}];case 3:return r=n.sent(),[2,{data:{user:null,session:null},error:new kt(r,{method:"refreshUser"})}];case 4:return[2]}})})},r.prototype.updateUser=function(t){var e;return fe(this,void 0,Promise,function(){var r,n,i,o,s,a,u,c,h,l,d,f,p=this;return pe(this,function(v){switch(v.label){case 0:if(v.trys.push([0,8,,9]),!Object.keys(t).some(function(e){return void 0!==t[e]&&null!==t[e]&&""!==t[e]}))throw new kt({message:"At least one field must be provided for update"});return r=t.email,n=t.phone,i=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]])}return r}(t,["email","phone"]),s=void 0!==n,a={},(o=void 0!==r)||s?(u=void 0,o?(u={email:t.email},c="email_change"):(h=this.formatPhone(t.phone),u={phone_number:h},c="phone_change"),[4,this.getVerification(he({},u))]):[3,4];case 1:return l=v.sent(),Object.keys(i).length>0?[4,this.updateUserBasicInfo(i)]:[3,3];case 2:v.sent(),v.label=3;case 3:return a={messageId:l.verification_id,verifyOtp:function(e){return fe(p,void 0,Promise,function(){var r,n,i,s;return pe(this,function(a){switch(a.label){case 0:return a.trys.push([0,11,,12]),e.email&&t.email===e.email?[4,this.verifyOtp({type:"email_change",email:t.email,token:e.token,messageId:l.verification_id})]:[3,3];case 1:return(r=a.sent()).error?[2,r]:[4,this.updateUserBasicInfo({email:t.email})];case 2:return a.sent(),[3,9];case 3:return e.phone&&t.phone===e.phone?[4,this.verifyOtp({type:"phone_change",phone:t.phone,token:e.token,messageId:l.verification_id})]:[3,6];case 4:return(r=a.sent()).error?[2,r]:[4,this.updateUserBasicInfo({phone:this.formatPhone(t.phone)})];case 5:return a.sent(),[3,9];case 6:return[4,this.verifyOtp(o?{type:c,email:t.email,token:e.token,messageId:l.verification_id}:{type:c,phone:t.phone,token:e.token,messageId:l.verification_id})];case 7:return(r=a.sent()).error?[2,r]:[4,this.updateUserBasicInfo(t)];case 8:a.sent(),a.label=9;case 9:return[4,this.getUser(!1)];case 10:return n=a.sent().data.user,null===(s=this.config.eventBus)||void 0===s||s.fire(I,{event:m}),[2,{data:{user:n},error:null}];case 11:return i=a.sent(),[2,{data:{user:null},error:new kt(i,{method:"updateUser"})}];case 12:return[2]}})})}},[3,6];case 4:return[4,this.updateUserBasicInfo(t)];case 5:v.sent(),v.label=6;case 6:return[4,this.getUser(!1)];case 7:return d=v.sent().data.user,Object.keys(i).length>0&&(null===(e=this.config.eventBus)||void 0===e||e.fire(I,{event:m})),[2,{data:he({user:d},a),error:null}];case 8:return f=v.sent(),[2,{data:{user:null},error:new kt(f,{method:"updateUser"})}];case 9:return[2]}})})},r.prototype.getUserIdentities=function(){var t;return fe(this,void 0,Promise,function(){var e,r;return pe(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.oauthInstance.authApi.getProviders()];case 1:return e=n.sent(),[2,{data:{identities:null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.filter(function(t){return!!t.bind})},error:null}];case 2:return r=n.sent(),[2,{data:{identities:null},error:new kt(r,{method:"getUserIdentities"})}];case 3:return[2]}})})},r.prototype.linkIdentity=function(t){return fe(this,void 0,Promise,function(){var e;return pe(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.validateParams(t,{provider:{required:!0,message:"Provider is required"}}),[4,this.signInWithOAuth({provider:t.provider,options:{type:w}})];case 1:return r.sent(),[2,{data:{provider:t.provider},error:null}];case 2:return e=r.sent(),[2,{data:{provider:null},error:new kt(e,{method:"linkIdentity"})}];case 3:return[2]}})})},r.prototype.unlinkIdentity=function(t){return fe(this,void 0,Promise,function(){var e;return pe(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.validateParams(t,{provider:{required:!0,message:"Provider is required"}}),[4,this.oauthInstance.authApi.unbindProvider({provider_id:t.provider})];case 1:return r.sent(),[2,{data:{},error:null}];case 2:return e=r.sent(),[2,{data:{},error:new kt(e,{method:"unlinkIdentity"})}];case 3:return[2]}})})},r.prototype.reauthenticate=function(){return fe(this,void 0,Promise,function(){var t,e,r,n,i=this;return pe(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,this.getUser(!1)];case 1:return t=o.sent().data.user,this.validateAtLeastOne(t,[["email","phone"]],"You must provide either an email or phone number"),e=t.email?{email:t.email}:{phone_number:this.formatPhone(t.phone)},[4,this.getVerification(e)];case 2:return r=o.sent(),[2,{data:{updateUser:function(t){return fe(i,void 0,Promise,function(){var n,i,o,s,a;return pe(this,function(u){switch(u.label){case 0:this.validateParams(t,{nonce:{required:!0,message:"Nonce is required"}}),u.label=1;case 1:return u.trys.push([1,9,,10]),t.password?[4,this.verify({verification_id:r.verification_id,verification_code:t.nonce})]:[3,5];case 2:return n=u.sent(),[4,this.oauthInstance.authApi.sudo({verification_token:n.verification_token})];case 3:return i=u.sent(),[4,this.oauthInstance.authApi.setPassword({new_password:t.password,sudo_token:i.sudo_token})];case 4:return u.sent(),[3,7];case 5:return[4,this.signInWithUsername(he(he({verificationInfo:r,verificationCode:t.nonce},e),{loginType:e.email?"email":"phone"}))];case 6:u.sent(),u.label=7;case 7:return[4,this.getSession()];case 8:return o=u.sent().data,[2,{data:{user:(s=(void 0===o?{}:o).session).user,session:s},error:null}];case 9:return a=u.sent(),[2,{data:{user:null,session:null},error:new kt(a,{method:"reauthenticate"})}];case 10:return[2]}})})}},error:null}];case 3:return n=o.sent(),[2,{data:{updateUser:null},error:new kt(n,{method:"reauthenticate"})}];case 4:return[2]}})})},r.prototype.resend=function(t){return fe(this,void 0,Promise,function(){var e,r,n;return pe(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),this.validateAtLeastOne(t,[["email"],["phone"]],"You must provide either an email or phone number"),e="signup"===t.type?"ANY":"USER",r={target:e},"email"in t&&(r.email=t.email),"phone"in t&&(r.phone_number=this.formatPhone(t.phone)),[4,this.oauthInstance.authApi.getVerification(r)];case 1:return[2,{data:{messageId:i.sent().verification_id},error:null}];case 2:return n=i.sent(),[2,{data:{messageId:null},error:new kt(n,{method:"resend"})}];case 3:return[2]}})})},r.prototype.setSession=function(t){var e;return fe(this,void 0,Promise,function(){var r,n,i;return pe(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),this.validateParams(t,{access_token:{required:!0,message:"Access token is required"},refresh_token:{required:!0,message:"Refresh token is required"}}),[4,this.oauthInstance.oauth2client.refreshToken(t,{throwError:!0})];case 1:return o.sent(),[4,this.getSession()];case 2:return r=o.sent().data,n=(void 0===r?{}:r).session,null===(e=this.config.eventBus)||void 0===e||e.fire(I,{event:v}),[2,{data:{user:n.user,session:n},error:null}];case 3:return i=o.sent(),[2,{data:{user:null,session:null},error:new kt(i,{method:"setSession"})}];case 4:return[2]}})})},r.prototype.exchangeCodeForSession=function(){return fe(this,void 0,void 0,function(){return pe(this,function(t){return[2]})})},r.prototype.deleteUser=function(t){return fe(this,void 0,Promise,function(){var e,r;return pe(this,function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),this.validateParams(t,{password:{required:!0,message:"Password is required"}}),[4,this.oauthInstance.authApi.sudo(t)];case 1:return e=n.sent().sudo_token,[4,this.oauthInstance.authApi.deleteMe({sudo_token:e})];case 2:return n.sent(),[2,{data:{},error:null}];case 3:return r=n.sent(),[2,{data:{},error:new kt(r,{method:"deleteUser"})}];case 4:return[2]}})})},r.prototype.toDefaultLoginPage=function(t){return void 0===t&&(t={}),fe(this,void 0,Promise,function(){var e,r,n,i,o;return pe(this,function(s){try{return e=t.config_version||"env",r=Object.keys(t.query||{}).map(function(e){return"".concat(e,"=").concat(t.query[e])}).join("&"),Kt.default.isMatch()?wx.navigateTo({url:"/packages/$wd_system/pages/login/index".concat(r?"?".concat(r):"")}):(n=t.redirect_uri||window.location.href,i=new URL(n),o="".concat(i.origin,"/__auth/?app_id=").concat(t.app_id||"","&env_id=").concat(this.config.env,"&client_id=").concat(this.config.clientId||this.config.env,"&config_version=").concat(e,"&redirect_uri=").concat(encodeURIComponent(n)).concat(r?"&".concat(r):""),window.location.href=o),[2,{data:{},error:null}]}catch(t){return[2,{data:{},error:new kt(t,{method:"toDefaultLoginPage"})}]}return[2]})})},r.prototype.signInWithCustomTicket=function(t){return fe(this,void 0,Promise,function(){var e,r,n,i;return pe(this,function(o){switch(o.label){case 0:t&&this.setCustomSignFunc(t),o.label=1;case 1:return o.trys.push([1,5,,6]),[4,this.oauthInstance.authApi.signInWithCustomTicket()];case 2:return o.sent(),[4,this.createLoginState()];case 3:return e=o.sent(),[4,this.getSession()];case 4:return r=o.sent().data,n=(void 0===r?{}:r).session,[2,he(he({},e),{data:{user:n.user,session:n},error:null})];case 5:return i=o.sent(),[2,{data:{user:null,session:null},error:new kt(i,{method:"signInWithCustomTicket"})}];case 6:return[2]}})})},r.prototype.signInWithOpenId=function(t){var e=(void 0===t?{}:t).useWxCloud,r=void 0===e||e;return fe(this,void 0,Promise,function(){var t,e,n,i,o,s,a=this;return pe(this,function(u){switch(u.label){case 0:if(!Kt.default.isMatch())throw Error("wx api undefined");t=wx.getAccountInfoSync().miniProgram,e=function(e){return fe(a,void 0,void 0,function(){var n,i;return pe(this,function(o){switch(o.label){case 0:n=void 0,i=void 0,o.label=1;case 1:return o.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==t?void 0:t.appId,provider_code:e,provider_params:{provider_code_type:"open_id",appid:null==t?void 0:t.appId}},r)];case 2:if((null==(n=o.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==(i=o.sent())?void 0:i.error_code)throw i;return[3,5];case 4:throw o.sent();case 5:return[4,this.oauthInstance.oauth2client.setCredentials(i)];case 6:return o.sent(),[2]}})})},u.label=1;case 1:return u.trys.push([1,5,,6]),[4,new Promise(function(t,r){wx.login({success:function(n){return fe(a,void 0,void 0,function(){var i;return pe(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,e(n.code)];case 1:return o.sent(),t(!0),[3,3];case 2:return i=o.sent(),r(i),[3,3];case 3:return[2]}})})},fail:function(t){var e=new Error(null==t?void 0:t.errMsg);e.code=null==t?void 0:t.errno,r(e)}})})];case 2:return u.sent(),[4,this.createLoginState()];case 3:return n=u.sent(),[4,this.getSession()];case 4:return i=u.sent().data,o=(void 0===i?{}:i).session,[2,he(he({},n),{data:{user:o.user,session:o},error:null})];case 5:return s=u.sent(),[2,{data:{user:null,session:null},error:new kt(s,{method:"signInWithOpenId"})}];case 6:return[2]}})})},r.prototype.signInWithPhoneAuth=function(t){var e=t.phoneCode,r=void 0===e?"":e,n=t.useWxCloud,i=void 0!==n&&n;return fe(this,void 0,Promise,function(){var t,e,n,o,s,a,u,c,h;return pe(this,function(l){switch(l.label){case 0:return Kt.default.isMatch()?(t=wx.getAccountInfoSync().miniProgram,e={provider_params:{provider_code_type:"phone",code:r,appid:t.appId},provider_id:t.appId},[4,wx.login()]):[2,{data:{user:null,session:null},error:new kt({message:"wx api undefined"})}];case 1:n=l.sent().code,e.provider_code=n,l.label=2;case 2:return l.trys.push([2,5,,6]),[4,this.oauthInstance.authApi.grantProviderToken(e,i)];case 3:if((o=l.sent()).error_code)throw o;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:o.provider_token},i)];case 4:if(null==(s=l.sent())?void 0:s.error_code)throw s;return[3,6];case 5:return a=l.sent(),[2,{data:{user:null,session:null},error:new kt(a,{method:"signInWithPhoneAuth"})}];case 6:return[4,this.createLoginState()];case 7:return u=l.sent(),[4,this.getSession()];case 8:return c=l.sent().data,h=(void 0===c?{}:c).session,[2,he(he({},u),{data:{user:h.user,session:h},error:null})]}})})},r.prototype.bindPhoneNumber=function(t){return fe(this,void 0,void 0,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.editContact(t)]})})},r.prototype.unbindProvider=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.unbindProvider(t)]})})},r.prototype.bindEmail=function(t){return this.oauthInstance.authApi.editContact(t)},r.prototype.verify=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.verify(t)]})})},r.prototype.getVerification=function(t,e){return fe(this,void 0,Promise,function(){return pe(this,function(r){return t.phone_number&&(t.phone_number=this.formatPhone(t.phone_number)),[2,this.oauthInstance.authApi.getVerification(t,e)]})})},Object.defineProperty(r.prototype,"currentUser",{get:function(){if("async"!==this.cache.mode){var t=this.hasLoginState();return t&&t.user||null}(0,mt.printWarn)(Ft.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrentUser instead")},enumerable:!1,configurable:!0}),r.prototype.getCurrentUser=function(t){return void 0===t&&(t=!0),fe(this,void 0,Promise,function(){var e,r,n;return pe(this,function(i){switch(i.label){case 0:return i.trys.push([0,4,,5]),t?[4,this.getLoginState()]:[3,3];case 1:return(e=i.sent())?[4,e.user.refresh()]:[3,3];case 2:i.sent(),i.label=3;case 3:return[3,5];case 4:return i.sent(),[3,5];case 5:return[4,this.getLoginState()];case 6:return(r=i.sent())?(n=r.user.getLocalUserInfo(),[4,r.user.checkLocalInfoAsync()]):[3,8];case 7:return i.sent(),[2,he(he({},r.user),n)];case 8:return[2,null]}})})},r.prototype.signInAnonymouslyInWx=function(t){var e=(void 0===t?{}:t).useWxCloud;return fe(this,void 0,Promise,function(){var t,r,n=this;return pe(this,function(i){switch(i.label){case 0:if(!Kt.default.isMatch())throw Error("wx api undefined");return t=wx.getAccountInfoSync().miniProgram,r=function(r){return fe(n,void 0,void 0,function(){var n,i;return pe(this,function(o){switch(o.label){case 0:n=void 0,i=void 0,o.label=1;case 1:return o.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==t?void 0:t.appId,provider_code:r,provider_params:{provider_code_type:"open_id",appid:null==t?void 0:t.appId}},e)];case 2:if((null==(n=o.sent())?void 0:n.error_code)||!n.provider_token)throw n;return[4,this.oauthInstance.authApi.signInAnonymously({provider_token:n.provider_token},e)];case 3:if(null==(i=o.sent())?void 0:i.error_code)throw i;return[3,5];case 4:throw o.sent();case 5:return[2]}})})},[4,new Promise(function(t,e){wx.login({success:function(i){return fe(n,void 0,void 0,function(){var n;return pe(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,r(i.code)];case 1:return o.sent(),t(!0),[3,3];case 2:return n=o.sent(),e(n),[3,3];case 3:return[2]}})})},fail:function(t){var r=new Error(null==t?void 0:t.errMsg);r.code=null==t?void 0:t.errno,e(r)}})})];case 1:return i.sent(),[2,this.createLoginState(void 0,{asyncRefreshUser:!0})]}})})},r.prototype.bindOpenId=function(){return fe(this,void 0,Promise,function(){var t,e,r=this;return pe(this,function(n){switch(n.label){case 0:if(!Kt.default.isMatch())throw Error("wx api undefined");return t=wx.getAccountInfoSync().miniProgram,e=function(e){return fe(r,void 0,void 0,function(){var r;return pe(this,function(n){switch(n.label){case 0:r=void 0,n.label=1;case 1:return n.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==t?void 0:t.appId,provider_code:e,provider_params:{provider_code_type:"open_id",appid:null==t?void 0:t.appId}})];case 2:if((null==(r=n.sent())?void 0:r.error_code)||!r.provider_token)throw r;return[4,this.oauthInstance.authApi.bindWithProvider({provider_token:r.provider_token})];case 3:return n.sent(),[3,5];case 4:throw n.sent();case 5:return[2]}})})},[4,new Promise(function(t,n){wx.login({success:function(i){return fe(r,void 0,void 0,function(){var r;return pe(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,e(i.code)];case 1:return o.sent(),t(!0),[3,3];case 2:return r=o.sent(),n(r),[3,3];case 3:return[2]}})})},fail:function(t){var e=new Error(null==t?void 0:t.errMsg);e.code=null==t?void 0:t.errno,n(e)}})})];case 1:return n.sent(),[2]}})})},r.prototype.signInWithUnionId=function(){return fe(this,void 0,Promise,function(){var t=this;return pe(this,function(e){switch(e.label){case 0:if(!Kt.default.isMatch())throw Error("wx api undefined");e.label=1;case 1:return e.trys.push([1,3,,4]),[4,new Promise(function(e,r){var n=wx.getAccountInfoSync().miniProgram;wx.login({success:function(i){return fe(t,void 0,void 0,function(){var t,o,s,a,u;return pe(this,function(c){switch(c.label){case 0:t=null==n?void 0:n.appId,c.label=1;case 1:return c.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_code:i.code,provider_id:t,provider_params:{provider_code_type:"union_id",appid:null==n?void 0:n.appId}})];case 2:return o=c.sent(),(s=o.provider_token)?[4,this.oauthInstance.authApi.signInWithProvider({provider_id:t,provider_token:s})]:(r(o),[2]);case 3:return(null==(a=c.sent())?void 0:a.error_code)?(r(a),[2]):(e(!0),[3,5]);case 4:return u=c.sent(),r(u),[3,5];case 5:return[2]}})})},fail:function(t){var e=new Error(null==t?void 0:t.errMsg);e.code=null==t?void 0:t.errno,r(e)}})})];case 2:return e.sent(),[3,4];case 3:throw e.sent();case 4:return[2,this.createLoginState()]}})})},r.prototype.signInWithSms=function(t){var e=t.verificationInfo,r=void 0===e?{verification_id:"",is_user:!1}:e,n=t.verificationCode,i=void 0===n?"":n,o=t.phoneNum,s=void 0===o?"":o,a=t.bindInfo,u=void 0===a?void 0:a;return fe(this,void 0,Promise,function(){return pe(this,function(t){try{return[2,this.signInWithUsername({verificationInfo:r,verificationCode:i,bindInfo:u,username:s,loginType:"sms"})]}catch(t){throw t}return[2]})})},r.prototype.signInWithEmail=function(t){var e=t.verificationInfo,r=void 0===e?{verification_id:"",is_user:!1}:e,n=t.verificationCode,i=void 0===n?"":n,o=t.bindInfo,s=void 0===o?void 0:o,a=t.email,u=void 0===a?"":a;return fe(this,void 0,Promise,function(){return pe(this,function(t){try{return[2,this.signInWithUsername({verificationInfo:r,verificationCode:i,bindInfo:s,username:u,loginType:"email"})]}catch(t){throw t}return[2]})})},r.prototype.setCustomSignFunc=function(t){this.oauthInstance.authApi.setCustomSignFunc(t)},r.prototype.signIn=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signIn(t)];case 1:return e.sent(),[2,this.createLoginState(t)]}})})},r.prototype.setPassword=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.setPassword(t)]})})},r.prototype.isUsernameRegistered=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){switch(e.label){case 0:return"string"!=typeof t&&(0,mt.throwError)(Ft.ERRORS.INVALID_PARAMS,"username must be a string"),[4,this.oauthInstance.authApi.checkIfUserExist({username:t})];case 1:return[2,e.sent().exist]}})})},r.prototype.hasLoginState=function(){var t;if("async"!==this.cache.mode)return(null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.hasLoginStateSync())?new ye({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance}):null;(0,mt.printWarn)(Ft.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState instead")},r.prototype.getLoginState=function(){return fe(this,void 0,Promise,function(){var t;return pe(this,function(e){switch(e.label){case 0:t=null,e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.oauthInstance.authApi.getLoginState()];case 2:return t=e.sent(),[3,4];case 3:return e.sent(),[2,null];case 4:return t?[2,new ye({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})]:[2,null]}})})},r.prototype.getUserInfo=function(){return fe(this,void 0,Promise,function(){return pe(this,function(t){return[2,this.getCurrentUser()]})})},r.prototype.getWedaUserInfo=function(){return fe(this,void 0,Promise,function(){return pe(this,function(t){return[2,this.oauthInstance.authApi.getWedaUserInfo()]})})},r.prototype.updateUserBasicInfo=function(t){return fe(this,void 0,void 0,function(){var e;return pe(this,function(r){switch(r.label){case 0:return[4,this.getLoginState()];case 1:return(e=r.sent())?[4,e.user.updateUserBasicInfo(t)]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}})})},r.prototype.getAuthHeader=function(){return console.error("Auth.getAuthHeader API 已废弃"),{}},r.prototype.bindWithProvider=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.bindWithProvider(t)]})})},r.prototype.queryUser=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.queryUserProfile(t)]})})},r.prototype.getAccessToken=function(){return fe(this,void 0,Promise,function(){return pe(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.oauth2client.getAccessToken()];case 1:return[2,{accessToken:t.sent(),env:this.config.env}]}})})},r.prototype.grantProviderToken=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.grantProviderToken(t)]})})},r.prototype.patchProviderToken=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.patchProviderToken(t)]})})},r.prototype.signInWithProvider=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInWithProvider(t)];case 1:return e.sent(),[2,this.createLoginState(t)]}})})},r.prototype.signInWithWechat=function(t){return void 0===t&&(t={}),fe(this,void 0,void 0,function(){return pe(this,function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInWithWechat(t)];case 1:return e.sent(),[2,this.createLoginState(t)]}})})},r.prototype.grantToken=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.grantToken(t)];case 1:return e.sent(),[2,this.createLoginState()]}})})},r.prototype.genProviderRedirectUri=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.genProviderRedirectUri(t)]})})},r.prototype.resetPassword=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.resetPassword(t)]})})},r.prototype.deviceAuthorize=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.deviceAuthorize(t)]})})},r.prototype.sudo=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.sudo(t)]})})},r.prototype.deleteMe=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.deleteMe(t)]})})},r.prototype.getProviders=function(){return fe(this,void 0,Promise,function(){return pe(this,function(t){return[2,this.oauthInstance.authApi.getProviders()]})})},r.prototype.loginScope=function(){return fe(this,void 0,Promise,function(){return pe(this,function(t){return[2,this.oauthInstance.authApi.loginScope()]})})},r.prototype.loginGroups=function(){return fe(this,void 0,Promise,function(){return pe(this,function(t){return[2,this.oauthInstance.authApi.loginGroups()]})})},r.prototype.onLoginStateChanged=function(t){var e;return fe(this,void 0,void 0,function(){var r,n=this;return pe(this,function(i){switch(i.label){case 0:return null===(e=this.config.eventBus)||void 0===e||e.on(_,function(e){return fe(n,void 0,void 0,function(){var r,n,i;return pe(this,function(o){switch(o.label){case 0:return(null===(i=null==e?void 0:e.data)||void 0===i?void 0:i.eventType)===f?[3,2]:[4,this.getLoginState()];case 1:return n=o.sent(),[3,3];case 2:n={},o.label=3;case 3:return r=n,t.call(this,he(he({},e),r)),[2]}})})}),[4,this.getLoginState()];case 1:return r=i.sent(),t.call(this,r),[2]}})})},r.prototype.refreshTokenForce=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.refreshTokenForce(t)]})})},r.prototype.getCredentials=function(){return fe(this,void 0,Promise,function(){return pe(this,function(t){return[2,this.oauthInstance.authApi.getCredentials()]})})},r.prototype.setCredentials=function(t){return fe(this,void 0,void 0,function(){return pe(this,function(e){switch(e.label){case 0:return[4,this.oauthInstance.oauth2client.setCredentials(t)];case 1:return e.sent(),[2]}})})},r.prototype.getProviderSubType=function(){return fe(this,void 0,Promise,function(){return pe(this,function(t){return[2,this.oauthInstance.authApi.getProviderSubType()]})})},r.prototype.createCaptchaData=function(t){return fe(this,void 0,void 0,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.createCaptchaData(t)]})})},r.prototype.verifyCaptchaData=function(t){return fe(this,void 0,void 0,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.verifyCaptchaData(t)]})})},r.prototype.getMiniProgramQrCode=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.getMiniProgramCode(t)]})})},r.prototype.getMiniProgramQrCodeStatus=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.getMiniProgramQrCodeStatus(t)]})})},r.prototype.modifyPassword=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.modifyPassword(t)]})})},r.prototype.modifyPasswordWithoutLogin=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.modifyPasswordWithoutLogin(t)]})})},r.prototype.getUserBehaviorLog=function(t){return fe(this,void 0,Promise,function(){return pe(this,function(e){return[2,this.oauthInstance.authApi.getUserBehaviorLog(t)]})})},r.prototype.signInWithUsername=function(t){var e=t.verificationInfo,r=void 0===e?{verification_id:"",is_user:!1}:e,n=t.verificationCode,i=void 0===n?"":n,o=t.username,s=void 0===o?"":o,a=t.bindInfo,u=void 0===a?void 0:a,c=t.loginType,h=void 0===c?"":c;return fe(this,void 0,Promise,function(){var t,e,n,o,a,c,l;return pe(this,function(d){switch(d.label){case 0:return d.trys.push([0,8,,9]),[4,this.oauthInstance.authApi.verify({verification_id:r.verification_id,verification_code:i})];case 1:if(null==(t=d.sent())?void 0:t.error_code)throw t;return e=t.verification_token,n=this.formatPhone(s),o={phone_number:n},"email"===h&&(o={email:n=s}),r.is_user?[4,this.oauthInstance.authApi.signIn({username:n,verification_token:e})]:[3,5];case 2:if(null==(a=d.sent())?void 0:a.error_code)throw a;return u?[4,this.oauthInstance.authApi.bindWithProvider({provider_token:null==u?void 0:u.providerToken})]:[3,4];case 3:if(null==(c=d.sent())?void 0:c.error_code)throw c;d.label=4;case 4:return[3,7];case 5:return[4,this.oauthInstance.authApi.signUp(he(he({},o),{verification_token:e,provider_token:null==u?void 0:u.providerId}))];case 6:if(null==(l=d.sent())?void 0:l.error_code)throw l;d.label=7;case 7:return[2,this.createLoginState()];case 8:throw d.sent();case 9:return[2]}})})},r.prototype.createLoginState=function(t,e){var r,n;return fe(this,void 0,Promise,function(){var i;return pe(this,function(o){switch(o.label){case 0:return[4,(i=new ye({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})).checkLocalStateAsync()];case 1:return o.sent(),(null==e?void 0:e.userInfo)?(i.user.setLocalUserInfo(e.userInfo),[3,5]):[3,2];case 2:return(null==e?void 0:e.asyncRefreshUser)?(i.user.refresh(t),[3,5]):[3,3];case 3:return[4,i.user.refresh(t)];case 4:o.sent(),o.label=5;case 5:return null===(r=this.config.eventBus)||void 0===r||r.fire(_,{eventType:"sign_in"}),null===(n=this.config.eventBus)||void 0===n||n.fire(I,{event:v}),[2,i]}})})},r.prototype.setAccessKey=function(){var t,e;return fe(this,void 0,void 0,function(){var r,n;return pe(this,function(i){if(r="",n="",this.config.accessKey?(r=this.config.accessKey,n="accessKey"):(null===(t=this.config.auth)||void 0===t?void 0:t.secretId)&&(null===(e=this.config.auth)||void 0===e?void 0:e.secretKey)&&(r="",n=E),!n)return[2];try{this.oauthInstance.oauth2client.setAccessKeyCredentials({access_token:r,token_type:"Bearer",scope:n,expires_at:new Date(+new Date+ +new Date),expires_in:+new Date+ +new Date})}catch(t){console.warn("accessKey error: ",t)}return[2]})})},r.prototype.formatPhone=function(t){return!/\s+/.test(t)&&/^\+\d{1,3}\d+/.test(t)?t.replace(/^(\+\d{1,2})(\d+)$/,"$1 $2"):/^\+\d{1,3}\s+/.test(t)?t:"+86 ".concat(t)},r.prototype.notifyListeners=function(t,e,r){this.listeners.forEach(function(n){n.forEach(function(n){try{n(t,e,r)}catch(t){console.error("Error in auth state change callback:",t)}})})},r.prototype.setupListeners=function(){var t,e=this;null===(t=this.config.eventBus)||void 0===t||t.on(I,function(t){return fe(e,void 0,void 0,function(){var e,r,n,i,o;return pe(this,function(s){switch(s.label){case 0:return e=null===(i=null==t?void 0:t.data)||void 0===i?void 0:i.event,r=null===(o=null==t?void 0:t.data)||void 0===o?void 0:o.info,[4,this.getSession()];case 1:return n=s.sent().data.session,this.notifyListeners(e,n,r),[2]}})})})},r.prototype.convertToUser=function(t){var e,r,n,i,o,s;if(!t)return null;var a=(null==t?void 0:t.email)||"",u=(null==t?void 0:t.phone_number)||"",c=(null==t?void 0:t.sub)||(null==t?void 0:t.uid)||"";return{id:c,aud:"authenticated",role:null===(r=null===(e=t.groups)||void 0===e?void 0:e.map)||void 0===r?void 0:r.call(e,function(t){return"string"==typeof t?t:t.id}),email:a||"",email_confirmed_at:(null==t||t.email_verified,t.created_at),phone:u,phone_confirmed_at:u?t.created_at:void 0,confirmed_at:t.created_at,last_sign_in_at:t.last_sign_in_at,app_metadata:{provider:(null===(n=t.loginType)||void 0===n?void 0:n.toLowerCase())||"cloudbase",providers:[(null===(i=t.loginType)||void 0===i?void 0:i.toLowerCase())||"cloudbase"]},user_metadata:{name:null==t?void 0:t.name,picture:null==t?void 0:t.picture,username:null==t?void 0:t.username,gender:null==t?void 0:t.gender,locale:null==t?void 0:t.locale,uid:t.uid,nickName:t.nickName||(null==t?void 0:t.name),avatarUrl:t.avatarUrl||t.picture,location:t.location,hasPassword:null!==(o=t.hasPassword)&&void 0!==o?o:"SET"===t.password,open_id:null==t?void 0:t.open_id},identities:(null===(s=null==t?void 0:t.providers)||void 0===s?void 0:s.map(function(e){return{id:e.id||"",identity_id:e.id||"",user_id:c,identity_data:{provider_id:e.id,provider_user_id:e.provider_user_id,name:e.name},provider:e.id||"cloudbase",created_at:t.created_at,updated_at:t.updated_at,last_sign_in_at:t.last_sign_in_at}}))||[],created_at:t.created_at,updated_at:t.updated_at,is_anonymous:"anonymous"===t.name}},r.prototype.validateParams=function(t,e){for(var r=0,n=Object.entries(e);r<n.length;r++){var i=n[r],o=i[0],s=i[1];if(s.required&&(void 0===(null==t?void 0:t[o])||null===(null==t?void 0:t[o])||""===(null==t?void 0:t[o])))throw new kt({message:s.message})}},r.prototype.validateAtLeastOne=function(t,e,r){if(!e.some(function(e){return e.some(function(e){return void 0!==(null==t?void 0:t[e])&&null!==(null==t?void 0:t[e])&&""!==(null==t?void 0:t[e])})}))throw new kt({message:r})},r.prototype.init=function(){var t;return fe(this,void 0,Promise,function(){return pe(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()&&(null===(t=this.config.eventBus)||void 0===t||t.fire(I,{event:"INITIAL_SESSION"})),[3,3];case 2:return e.sent(),[3,3];case 3:return[2,{error:null}]}})})},le([(0,Ht.catchErrorsDecorator)({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",["function"==typeof(n=t.BindPhoneRequest)?n:Object]),de("design:returntype",Promise)],r.prototype,"bindPhoneNumber",null),le([(0,Ht.catchErrorsDecorator)({title:"解除三方绑定失败",messages:["请确认以下各项:"," 1 - 调用 auth().unbindProvider() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",["function"==typeof(i=t.UnbindProviderRequest)?i:Object]),de("design:returntype","function"==typeof(o="undefined"!=typeof Promise&&Promise)?o:Object)],r.prototype,"unbindProvider",null),le([(0,Ht.catchErrorsDecorator)({title:"绑定邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",["function"==typeof(s=t.BindEmailRequest)?s:Object]),de("design:returntype",void 0)],r.prototype,"bindEmail",null),le([(0,Ht.catchErrorsDecorator)({title:"验证码验证失败",messages:["请确认以下各项:"," 1 - 调用 auth().verify() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",["function"==typeof(a=t.VerifyRequest)?a:Object]),de("design:returntype","function"==typeof(u="undefined"!=typeof Promise&&Promise)?u:Object)],r.prototype,"verify",null),le([(0,Ht.catchErrorsDecorator)({title:"获取验证码失败",messages:["请确认以下各项:"," 1 - 调用 auth().getVerification() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",["function"==typeof(c=t.GetVerificationRequest)?c:Object,Object]),de("design:returntype","function"==typeof(h="undefined"!=typeof Promise&&Promise)?h:Object)],r.prototype,"getVerification",null),le([(0,Ht.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrentUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",[Object]),de("design:returntype","function"==typeof(l="undefined"!=typeof Promise&&Promise)?l:Object)],r.prototype,"getCurrentUser",null),le([(0,Ht.catchErrorsDecorator)({title:"小程序匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymouslyInWx() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",[Object]),de("design:returntype","function"==typeof(d="undefined"!=typeof Promise&&Promise)?d:Object)],r.prototype,"signInAnonymouslyInWx",null),le([(0,Ht.catchErrorsDecorator)({title:"小程序绑定OpenID失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序openId静默登录"," 2 - 调用 auth().bindOpenId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",[]),de("design:returntype","function"==typeof(g="undefined"!=typeof Promise&&Promise)?g:Object)],r.prototype,"bindOpenId",null),le([(0,Ht.catchErrorsDecorator)({title:"小程序unionId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序unionId静默登录"," 2 - 调用 auth().signInWithUnionId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",[]),de("design:returntype","function"==typeof(y="undefined"!=typeof Promise&&Promise)?y:Object)],r.prototype,"signInWithUnionId",null),le([(0,Ht.catchErrorsDecorator)({title:"短信验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序短信验证码登陆"," 2 - 调用 auth().signInWithSms() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",[Object]),de("design:returntype","function"==typeof(S="undefined"!=typeof Promise&&Promise)?S:Object)],r.prototype,"signInWithSms",null),le([(0,Ht.catchErrorsDecorator)({title:"邮箱验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了邮箱登陆"," 2 - 调用 auth().signInWithEmail() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",[Object]),de("design:returntype","function"==typeof(A="undefined"!=typeof Promise&&Promise)?A:Object)],r.prototype,"signInWithEmail",null),le([(0,Ht.catchErrorsDecorator)({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",[String]),de("design:returntype","function"==typeof(P="undefined"!=typeof Promise&&Promise)?P:Object)],r.prototype,"isUsernameRegistered",null),le([(0,Ht.catchErrorsDecorator)({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",[]),de("design:returntype","function"==typeof(O="undefined"!=typeof Promise&&Promise)?O:Object)],r.prototype,"getLoginState",null),le([(0,Ht.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",[]),de("design:returntype","function"==typeof(T="undefined"!=typeof Promise&&Promise)?T:Object)],r.prototype,"getUserInfo",null),le([(0,Ht.catchErrorsDecorator)({title:"获取微搭插件用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getWedaUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",[]),de("design:returntype","function"==typeof(R="undefined"!=typeof Promise&&Promise)?R:Object)],r.prototype,"getWedaUserInfo",null),le([(0,Ht.catchErrorsDecorator)({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindWithProvider() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",["function"==typeof(C=t.BindWithProviderRequest)?C:Object]),de("design:returntype","function"==typeof(U="undefined"!=typeof Promise&&Promise)?U:Object)],r.prototype,"bindWithProvider",null),le([(0,Ht.catchErrorsDecorator)({title:"获取身份源类型",messages:["请确认以下各项:"," 1 - 调用 auth().getProviderSubType() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Ft.COMMUNITY_SITE_URL)]}),de("design:type",Function),de("design:paramtypes",[]),de("design:returntype","function"==typeof(L="undefined"!=typeof Promise&&Promise)?L:Object)],r.prototype,"getProviderSubType",null),r}(ue),Ie="auth";function be(t,e){for(var r=[],n=0;n<=t.length;n++)r[n]=[n];for(var i=0;i<=e.length;i++)r[0][i]=i;for(n=1;n<=t.length;n++)for(i=1;i<=e.length;i++){var o=t[n-1].toLowerCase()===e[i-1].toLowerCase()?0:1;r[n][i]=Math.min(r[n-1][i]+1,r[n][i-1]+1,r[n-1][i-1]+o)}return r[t.length][e.length]}var we={name:"auth",namespace:Ie,entity:function(t){var e=function(t){var e,r=this;if(this.authInstance&&!t)return this.authInstance;t=t||{region:"",persistence:"local",apiPath:l};var n=this.platform.adapter,i=t.persistence||n.primaryStorage;i&&i!==this.config.persistence&&this.updateConfig({persistence:i});var o=function(t,e){var r,n,i,o,s=this,a=t.region,u=void 0===a?"ap-shanghai":a,c=t.i18n,h=t.accessKey,d=t.useWxCloud,f=(null==e?void 0:e.platform)||zt.useDefaultAdapter.bind(e)(),p=f.runtime,g=f.adapter,m=e||{},_=m.env,E=m.clientId,S=m.debug,A=m.cache,P=m.app,O=m.getApiOrigin,T=(e||{}).apiOrigin;T||(T="https://".concat(_,".").concat(u,".tcb-api.tencentcloudapi.com"));var R={env:_,clientId:E,i18n:c,accessKey:h,useWxCloud:d,eventBus:new gt.CloudbaseEventEmitter},C=new Wt(ee(he(he({},R),{apiOrigin:T,getApiOrigin:O,apiPath:(null==t?void 0:t.apiPath)||l,storage:null==t?void 0:t.storage,baseRequest:null==t?void 0:t.baseRequest,request:null==t?void 0:t.request,anonymousSignInFunc:null==t?void 0:t.anonymousSignInFunc,captchaOptions:null==t?void 0:t.captchaOptions,wxCloud:null==t?void 0:t.wxCloud,adapter:g,onCredentialsError:ge(R.eventBus),headers:he({"X-SDK-Version":"@cloudbase/js-sdk/".concat(t.sdkVersion)},t.headers||{}),detectSessionInUrl:t.detectSessionInUrl,debug:S,auth:null===(n=null===(r=e.app)||void 0===r?void 0:r.config)||void 0===n?void 0:n.auth}))),U=new _e(he(he({},R),{region:u,persistence:t.persistence,debug:S,cache:A||new Gt.CloudbaseCache({persistence:t.persistence,keys:{userInfoKey:"user_info_".concat(_)},platformInfo:f}),runtime:p||"web",_fromApp:P,oauthInstance:C,auth:null===(o=null===(i=e.app)||void 0===i?void 0:i.config)||void 0===o?void 0:o.auth}));return C.initializeSession(function(t,e){return fe(s,void 0,void 0,function(){return pe(this,function(r){return t?(t.type===b?e?R.eventBus.fire(I,{event:v,info:he(he({},t),{error:e})}):t.user&&U.createLoginState({},{userInfo:t.user}):t.type===w&&R.eventBus.fire(I,{event:y,info:he(he({},t),{error:e})}),[2]):[2]})})}),{authInstance:U,oauthInstance:C}}(he(he({wxCloud:this.config.wxCloud,storage:this.config.storage},t),{persistence:this.config.persistence,i18n:this.config.i18n,accessKey:this.config.accessKey,useWxCloud:this.config.useWxCloud,sdkVersion:this.version,detectSessionInUrl:null===(e=this.config.auth)||void 0===e?void 0:e.detectSessionInUrl}),{env:this.config.env,clientId:this.config.clientId,getApiOrigin:function(){return r.request.getBaseEndPoint(r.config.endPointMode||"CLOUD_API")},platform:this.platform,cache:this.cache,app:this,debug:this.config.debug}),s=o.authInstance,a=o.oauthInstance;return this.oauthInstance=a,this.authInstance=s,this.authInstance},r=e.call(this,t);Object.assign(e,r),Object.setPrototypeOf(e,Object.getPrototypeOf(r));var n="undefined"!=typeof Proxy?new Proxy(e,{get:function(t,e,r){var n=Reflect.get(t,e,r);if(void 0!==n||"string"!=typeof e)return n;var i=function(t,e){for(var r=null,n=1/0,i=0,o=e;i<o.length;i++){var s=o[i];if(!s.startsWith("_")&&"constructor"!==s){var a=be(t,s);a<n&&(n=a,r=s)}}return r}(e,Object.getOwnPropertyNames(Object.getPrototypeOf(t)).concat(Object.keys(t)).filter(function(e){return"function"==typeof t[e]}));return i&&console.warn("[CloudBase Auth] auth.".concat(e," is not a function. Did you mean: auth.").concat(i,"() ?")),n}}):e;return this[Ie]=n,n}};try{cloudbase.registerComponent(we)}catch(t){}var Ee=function(t){try{t.registerComponent(we)}catch(t){console.warn(t)}};try{window.registerAuth=Ee}catch(t){}})();var a=s.W;export{a as registerAuth};
3
3
  //# sourceMappingURL=index.esm.js.map