@cloudbase/js-sdk
Version:
cloudbase javascript sdk
2 lines • 558 kB
JavaScript
/*! For license information please see index.esm.js.LICENSE.txt */
import*as t from"@cloudbase/adapter-interface";import*as e from"jwt-decode";import*as n from"@cloudbase/adapter-wx_mp";import*as r from"@cloudbase/wx-cloud-client-sdk";import*as o from"web-streams-polyfill";import*as i from"@mattiasbuelens/web-streams-adapter";import*as s from"text-encoding-shim";import*as a from"bson";var u={3171:(t,e,n)=>{var r;if(n.r(e),n.d(e,{getEncryptInfo:()=>q}),!globalThis.IS_MP_BUILD){var o="undefined"!=typeof globalThis?globalThis.navigator:window.globalThis;function M(t){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(t)}function W(t,e){return t&e}function F(t,e){return t|e}function B(t,e){return t^e}function V(t,e){return t&~e}function G(t){if(0==t)return-1;var e=0;return 65535&t||(t>>=16,e+=16),255&t||(t>>=8,e+=8),15&t||(t>>=4,e+=4),3&t||(t>>=2,e+=2),1&t||++e,e}function H(t){for(var e=0;0!=t;)t&=t-1,++e;return e}var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function K(t){var e,n,r="";for(e=0;e+3<=t.length;e+=3)n=parseInt(t.substring(e,e+3),16),r+=i.charAt(n>>6)+i.charAt(63&n);for(e+1==t.length?(n=parseInt(t.substring(e,e+1),16),r+=i.charAt(n<<2)):e+2==t.length&&(n=parseInt(t.substring(e,e+2),16),r+=i.charAt(n>>2)+i.charAt((3&n)<<4));(3&r.length)>0;)r+="=";return r}function J(t){var e,n="",r=0,o=0;for(e=0;e<t.length&&"="!=t.charAt(e);++e){var s=i.indexOf(t.charAt(e));s<0||(0==r?(n+=M(s>>2),o=3&s,r=1):1==r?(n+=M(o<<2|s>>4),o=15&s,r=2):2==r?(n+=M(o),n+=M(s>>2),o=3&s,r=3):(n+=M(o<<2|s>>4),n+=M(15&s),r=0))}return 1==r&&(n+=M(o<<2)),n}var s,a,u={decode:function(t){var e;if(void 0===s){var n="0123456789ABCDEF";for(s={},e=0;e<16;++e)s[n.charAt(e)]=e;for(n=n.toLowerCase(),e=10;e<16;++e)s[n.charAt(e)]=e;for(e=0;e<8;++e)s[" \f\n\r\t \u2028\u2029".charAt(e)]=-1}var r=[],o=0,i=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);o|=a,++i>=2?(r[r.length]=o,o=0,i=0):o<<=4}}if(i)throw new Error("Hex encoding incomplete: 4 bits missing");return r}},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 n=[],r=0,o=0;for(e=0;e<t.length;++e){var i=t.charAt(e);if("="==i)break;if(-1!=(i=a[i])){if(void 0===i)throw new Error("Illegal character at offset "+e);r|=i,++o>=4?(n[n.length]=r>>16,n[n.length]=r>>8&255,n[n.length]=255&r,r=0,o=0):r<<=6}}switch(o){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:n[n.length]=r>>10;break;case 3:n[n.length]=r>>16,n[n.length]=r>>8&255}return n},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)}},l=1e13;class z{constructor(t){this.buf=[+t||0]}mulAdd(t,e){var n,r,o=this.buf,i=o.length;for(n=0;n<i;++n)(r=o[n]*t+e)<l?e=0:r-=(e=0|r/l)*l,o[n]=r;e>0&&(o[n]=e)}sub(t){var e,n,r=this.buf,o=r.length;for(e=0;e<o;++e)(n=r[e]-t)<0?(n+=l,t=1):t=0,r[e]=n;for(;0===r[r.length-1];)r.pop()}toString(t){if(10!=(t||10))throw new Error("only base 10 is supported");for(var e=this.buf,n=e[e.length-1].toString(),r=e.length-2;r>=0;--r)n+=(l+e[r]).toString().substring(1);return n}valueOf(){for(var t=this.buf,e=0,n=t.length-1;n>=0;--n)e=e*l+t[n];return e}simplify(){var t=this.buf;return 1==t.length?t[0]:this}}var h,d=/^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/,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 Y(t,e){return t.length>e&&(t=t.substring(0,e)+"…"),t}class Q{constructor(t,e){this.hexDigits="0123456789ABCDEF",t instanceof Q?(this.enc=t.enc,this.pos=t.pos):(this.enc=t,this.pos=e)}get(t){if(void 0===t&&(t=this.pos++),t>=this.enc.length)throw new Error("Requesting byte offset "+t+" on a stream of length "+this.enc.length);return"string"==typeof this.enc?this.enc.charCodeAt(t):this.enc[t]}hexByte(t){return this.hexDigits.charAt(t>>4&15)+this.hexDigits.charAt(15&t)}hexDump(t,e,n){for(var r="",o=t;o<e;++o)if(r+=this.hexByte(this.get(o)),!0!==n)switch(15&o){case 7:r+=" ";break;case 15:r+="\n";break;default:r+=" "}return r}isASCII(t,e){for(var n=t;n<e;++n){var r=this.get(n);if(r<32||r>176)return!1}return!0}parseStringISO(t,e){for(var n="",r=t;r<e;++r)n+=String.fromCharCode(this.get(r));return n}parseStringUTF(t,e){for(var n="",r=t;r<e;){var o=this.get(r++);n+=o<128?String.fromCharCode(o):o>191&&o<224?String.fromCharCode((31&o)<<6|63&this.get(r++)):String.fromCharCode((15&o)<<12|(63&this.get(r++))<<6|63&this.get(r++))}return n}parseStringBMP(t,e){for(var n,r,o="",i=t;i<e;)n=this.get(i++),r=this.get(i++),o+=String.fromCharCode(n<<8|r);return o}parseTime(t,e,n){var r=this.parseStringISO(t,e),o=(n?d:f).exec(r);return o?(n&&(o[1]=+o[1],o[1]+=+o[1]<70?2e3:1900),r=o[1]+"-"+o[2]+"-"+o[3]+" "+o[4],o[5]&&(r+=":"+o[5],o[6]&&(r+=":"+o[6],o[7]&&(r+="."+o[7]))),o[8]&&(r+=" UTC","Z"!=o[8]&&(r+=o[8],o[9]&&(r+=":"+o[9]))),r):"Unrecognized time: "+r}parseInteger(t,e){for(var n,r=this.get(t),o=r>127,i=o?255:0,s="";r==i&&++t<e;)r=this.get(t);if(0===(n=e-t))return o?-1:0;if(n>4){for(s=r,n<<=3;!(128&(+s^i));)s=+s<<1,--n;s="("+n+" bit)\n"}o&&(r-=256);for(var a=new z(r),u=t+1;u<e;++u)a.mulAdd(256,this.get(u));return s+a.toString()}parseBitString(t,e,n){for(var r=this.get(t),o="("+((e-t-1<<3)-r)+" bit)\n",i="",s=t+1;s<e;++s){for(var a=this.get(s),u=s==e-1?r:0,c=7;c>=u;--c)i+=a>>c&1?"1":"0";if(i.length>n)return o+Y(i,n)}return o+i}parseOctetString(t,e,n){if(this.isASCII(t,e))return Y(this.parseStringISO(t,e),n);var r=e-t,o="("+r+" byte)\n";r>(n/=2)&&(e=t+n);for(var i=t;i<e;++i)o+=this.hexByte(this.get(i));return r>n&&(o+="…"),o}parseOID(t,e,n){for(var r="",o=new z,i=0,s=t;s<e;++s){var a=this.get(s);if(o.mulAdd(128,127&a),i+=7,!(128&a)){if(""===r)if((o=o.simplify())instanceof z)o.sub(80),r="2."+o.toString();else{var u=o<80?o<40?0:1:2;r=u+"."+(o-40*u)}else r+="."+o.toString();if(r.length>n)return Y(r,n);o=new z,i=0}}return i>0&&(r+=".incomplete"),r}}class ${constructor(t,e,n,r,o){if(!(r instanceof X))throw new Error("Invalid tag value.");this.stream=t,this.header=e,this.length=n,this.tag=r,this.sub=o}typeName(){switch(this.tag.tagClass){case 0:switch(this.tag.tagNumber){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER";case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString";case 30:return"BMPString"}return"Universal_"+this.tag.tagNumber.toString();case 1:return"Application_"+this.tag.tagNumber.toString();case 2:return"["+this.tag.tagNumber.toString()+"]";case 3:return"Private_"+this.tag.tagNumber.toString()}}content(t){if(void 0===this.tag)return null;void 0===t&&(t=1/0);var e=this.posContent(),n=Math.abs(this.length);if(!this.tag.isUniversal())return null!==this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+n,t);switch(this.tag.tagNumber){case 1:return 0===this.stream.get(e)?"false":"true";case 2:return this.stream.parseInteger(e,e+n);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(e,e+n,t);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+n,t);case 6:return this.stream.parseOID(e,e+n,t);case 16:case 17:return null!==this.sub?"("+this.sub.length+" elem)":"(no elem)";case 12:return Y(this.stream.parseStringUTF(e,e+n),t);case 18:case 19:case 20:case 21:case 22:case 26:return Y(this.stream.parseStringISO(e,e+n),t);case 30:return Y(this.stream.parseStringBMP(e,e+n),t);case 23:case 24:return this.stream.parseTime(e,e+n,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 n=0,r=this.sub.length;n<r;++n)e+=this.sub[n].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(),n=127&e;if(n==e)return n;if(n>6)throw new Error("Length over 48 bits not supported at position "+(t.pos-1));if(0===n)return null;e=0;for(var r=0;r<n;++r)e=256*e+t.get();return e}getHexStringValue(){var t=this.toHexString(),e=2*this.header,n=2*this.length;return t.substr(e,n)}static decode(t){var e;e=t instanceof Q?t:new Q(t,0);var n=new Q(e),r=new X(e),o=$.decodeLength(e),i=e.pos,s=i-n.pos,a=null,u=function(){var t=[];if(null!==o){for(var n=i+o;e.pos<n;)t[t.length]=$.decode(e);if(e.pos!=n)throw new Error("Content size is not correct for container starting at offset "+i)}else try{for(;;){var r=$.decode(e);if(r.tag.isEOC())break;t[t.length]=r}o=i-e.pos}catch(t){throw new Error("Exception while decoding undefined length content: "+t)}return t};if(r.tagConstructed)a=u();else if(r.isUniversal()&&(3==r.tagNumber||4==r.tagNumber))try{if(3==r.tagNumber&&0!=e.get())throw new Error("BIT STRINGs with unused bits cannot encapsulate.");a=u();for(var c=0;c<a.length;++c)if(a[c].tag.isEOC())throw new Error("EOC is not supposed to be actual content.")}catch(t){a=null}if(null===a){if(null===o)throw new Error("We can't skip over an invalid tag with undefined length at offset "+i);e.pos=i+Math.abs(o)}return new $(n,s,o,r,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 n=new z;do{e=t.get(),n.mulAdd(128,127&e)}while(128&e);this.tagNumber=n.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 Z{constructor(t,e,n){null!=t&&("number"==typeof t?this.fromNumber(t,e,n):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 n,r=(1<<e)-1,o=!1,i="",s=this.t,a=this.DB-s*this.DB%e;if(s-- >0)for(a<this.DB&&(n=this[s]>>a)>0&&(o=!0,i=M(n));s>=0;)a<e?(n=(this[s]&(1<<a)-1)<<e-a,n|=this[--s]>>(a+=this.DB-e)):(n=this[s]>>(a-=e)&r,a<=0&&(a+=this.DB,--s)),n>0&&(o=!0),o&&(i+=M(n));return o?i:"0"}negate(){var t=tt();return Z.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 n=this.t;if(0!=(e=n-t.t))return this.s<0?-e:e;for(;--n>=0;)if(0!=(e=this[n]-t[n]))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(Z.ZERO)>0&&t.subTo(e,e),e}modPowInt(t,e){var n;return n=t<256||e.isEven()?new m(e):new g(e),this.exp(t,n)}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 n,r=this.DB-t*this.DB%8,o=0;if(t-- >0)for(r<this.DB&&(n=this[t]>>r)!=(this.s&this.DM)>>r&&(e[o++]=n|this.s<<this.DB-r);t>=0;)r<8?(n=(this[t]&(1<<r)-1)<<8-r,n|=this[--t]>>(r+=this.DB-8)):(n=this[t]>>(r-=8)&255,r<=0&&(r+=this.DB,--t)),128&n&&(n|=-256),0==o&&(128&this.s)!=(128&n)&&++o,(o>0||n!=this.s)&&(e[o++]=n);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,W,e),e}or(t){var e=tt();return this.bitwiseTo(t,F,e),e}xor(t){var e=tt();return this.bitwiseTo(t,B,e),e}andNot(t){var e=tt();return this.bitwiseTo(t,V,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+G(this[t]);return this.s<0?this.t*this.DB:-1}bitCount(){for(var t=0,e=this.s&this.DM,n=0;n<this.t;++n)t+=H(this[n]^e);return t}testBit(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:!!(this[e]&1<<t%this.DB)}setBit(t){return this.changeBit(t,F)}clearBit(t){return this.changeBit(t,V)}flipBit(t){return this.changeBit(t,B)}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(),n=tt();return this.divRemTo(t,e,n),[e,n]}modPow(t,e){var n,r,o=t.bitLength(),i=st(1);if(o<=0)return i;n=o<18?1:o<48?3:o<144?4:o<768?5:6,r=o<8?new m(e):e.isEven()?new b(e):new g(e);var s=[],a=3,u=n-1,c=(1<<n)-1;if(s[1]=r.convert(this),n>1){var l=tt();for(r.sqrTo(s[1],l);a<=c;)s[a]=tt(),r.mulTo(l,s[a-2],s[a]),a+=2}var h,d,f=t.t-1,p=!0,v=tt();for(o=at(t[f])-1;f>=0;){for(o>=u?h=t[f]>>o-u&c:(h=(t[f]&(1<<o+1)-1)<<u-o,f>0&&(h|=t[f-1]>>this.DB+o-u)),a=n;!(1&h);)h>>=1,--a;if((o-=a)<0&&(o+=this.DB,--f),p)s[h].copyTo(i),p=!1;else{for(;a>1;)r.sqrTo(i,v),r.sqrTo(v,i),a-=2;a>0?r.sqrTo(i,v):(d=i,i=v,v=d),r.mulTo(v,s[h],i)}for(;f>=0&&!(t[f]&1<<o);)r.sqrTo(i,v),d=i,i=v,v=d,--o<0&&(o=this.DB-1,--f)}return r.revert(i)}modInverse(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return Z.ZERO;for(var n=t.clone(),r=this.clone(),o=st(1),i=st(0),s=st(0),a=st(1);0!=n.signum();){for(;n.isEven();)n.rShiftTo(1,n),e?(o.isEven()&&i.isEven()||(o.addTo(this,o),i.subTo(t,i)),o.rShiftTo(1,o)):i.isEven()||i.subTo(t,i),i.rShiftTo(1,i);for(;r.isEven();)r.rShiftTo(1,r),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);n.compareTo(r)>=0?(n.subTo(r,n),e&&o.subTo(s,o),i.subTo(a,i)):(r.subTo(n,r),e&&s.subTo(o,s),a.subTo(i,a))}return 0!=r.compareTo(Z.ONE)?Z.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 y)}gcd(t){var e=this.s<0?this.negate():this.clone(),n=t.s<0?t.negate():t.clone();if(e.compareTo(n)<0){var r=e;e=n,n=r}var o=e.getLowestSetBit(),i=n.getLowestSetBit();if(i<0)return e;for(o<i&&(i=o),i>0&&(e.rShiftTo(i,e),n.rShiftTo(i,n));e.signum()>0;)(o=e.getLowestSetBit())>0&&e.rShiftTo(o,e),(o=n.getLowestSetBit())>0&&n.rShiftTo(o,n),e.compareTo(n)>=0?(e.subTo(n,e),e.rShiftTo(1,e)):(n.subTo(e,n),n.rShiftTo(1,n));return i>0&&n.lShiftTo(i,n),n}isProbablePrime(t){var e,n=this.abs();if(1==n.t&&n[0]<=p[p.length-1]){for(e=0;e<p.length;++e)if(n[0]==p[e])return!0;return!1}if(n.isEven())return!1;for(e=1;e<p.length;){for(var r=p[e],o=e+1;o<p.length&&r<v;)r*=p[o++];for(r=n.modInt(r);e<o;)if(r%p[e++]==0)return!1}return n.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 n;if(16==e)n=4;else if(8==e)n=3;else if(256==e)n=8;else if(2==e)n=1;else if(32==e)n=5;else{if(4!=e)return void this.fromRadix(t,e);n=2}this.t=0,this.s=0;for(var r=t.length,o=!1,i=0;--r>=0;){var s=8==n?255&+t[r]:it(t,r);s<0?"-"==t.charAt(r)&&(o=!0):(o=!1,0==i?this[this.t++]=s:i+n>this.DB?(this[this.t-1]|=(s&(1<<this.DB-i)-1)<<i,this[this.t++]=s>>this.DB-i):this[this.t-1]|=s<<i,(i+=n)>=this.DB&&(i-=this.DB))}8==n&&128&+t[0]&&(this.s=-1,i>0&&(this[this.t-1]|=(1<<this.DB-i)-1<<i)),this.clamp(),o&&Z.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 n;for(n=this.t-1;n>=0;--n)e[n+t]=this[n];for(n=t-1;n>=0;--n)e[n]=0;e.t=this.t+t,e.s=this.s}drShiftTo(t,e){for(var n=t;n<this.t;++n)e[n-t]=this[n];e.t=Math.max(this.t-t,0),e.s=this.s}lShiftTo(t,e){for(var n=t%this.DB,r=this.DB-n,o=(1<<r)-1,i=Math.floor(t/this.DB),s=this.s<<n&this.DM,a=this.t-1;a>=0;--a)e[a+i+1]=this[a]>>r|s,s=(this[a]&o)<<n;for(a=i-1;a>=0;--a)e[a]=0;e[i]=s,e.t=this.t+i+1,e.s=this.s,e.clamp()}rShiftTo(t,e){e.s=this.s;var n=Math.floor(t/this.DB);if(n>=this.t)e.t=0;else{var r=t%this.DB,o=this.DB-r,i=(1<<r)-1;e[0]=this[n]>>r;for(var s=n+1;s<this.t;++s)e[s-n-1]|=(this[s]&i)<<o,e[s-n]=this[s]>>r;r>0&&(e[this.t-n-1]|=(this.s&i)<<o),e.t=this.t-n,e.clamp()}}subTo(t,e){for(var n=0,r=0,o=Math.min(t.t,this.t);n<o;)r+=this[n]-t[n],e[n++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r-=t.s;n<this.t;)r+=this[n],e[n++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;n<t.t;)r-=t[n],e[n++]=r&this.DM,r>>=this.DB;r-=t.s}e.s=r<0?-1:0,r<-1?e[n++]=this.DV+r:r>0&&(e[n++]=r),e.t=n,e.clamp()}multiplyTo(t,e){var n=this.abs(),r=t.abs(),o=n.t;for(e.t=o+r.t;--o>=0;)e[o]=0;for(o=0;o<r.t;++o)e[o+n.t]=n.am(0,r[o],e,o,0,n.t);e.s=0,e.clamp(),this.s!=t.s&&Z.ZERO.subTo(e,e)}squareTo(t){for(var e=this.abs(),n=t.t=2*e.t;--n>=0;)t[n]=0;for(n=0;n<e.t-1;++n){var r=e.am(n,e[n],t,2*n,0,1);(t[n+e.t]+=e.am(n+1,2*e[n],t,2*n+1,r,e.t-n-1))>=e.DV&&(t[n+e.t]-=e.DV,t[n+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(n,e[n],t,2*n,0,1)),t.s=0,t.clamp()}divRemTo(t,e,n){var r=t.abs();if(!(r.t<=0)){var o=this.abs();if(o.t<r.t)return null!=e&&e.fromInt(0),void(null!=n&&this.copyTo(n));null==n&&(n=tt());var i=tt(),s=this.s,a=t.s,u=this.DB-at(r[r.t-1]);u>0?(r.lShiftTo(u,i),o.lShiftTo(u,n)):(r.copyTo(i),o.copyTo(n));var c=i.t,l=i[c-1];if(0!=l){var h=l*(1<<this.F1)+(c>1?i[c-2]>>this.F2:0),d=this.FV/h,f=(1<<this.F1)/h,p=1<<this.F2,v=n.t,y=v-c,m=e??tt();for(i.dlShiftTo(y,m),n.compareTo(m)>=0&&(n[n.t++]=1,n.subTo(m,n)),Z.ONE.dlShiftTo(c,m),m.subTo(i,i);i.t<c;)i[i.t++]=0;for(;--y>=0;){var g=n[--v]==l?this.DM:Math.floor(n[v]*d+(n[v-1]+p)*f);if((n[v]+=i.am(0,g,n,y,0,c))<g)for(i.dlShiftTo(y,m),n.subTo(m,n);n[v]<--g;)n.subTo(m,n)}null!=e&&(n.drShiftTo(c,e),s!=a&&Z.ZERO.subTo(e,e)),n.t=c,n.clamp(),u>0&&n.rShiftTo(u,n),s<0&&Z.ZERO.subTo(n,n)}}}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 Z.ONE;var n=tt(),r=tt(),o=e.convert(this),i=at(t)-1;for(o.copyTo(n);--i>=0;)if(e.sqrTo(n,r),(t&1<<i)>0)e.mulTo(r,o,n);else{var s=n;n=r,r=s}return e.revert(n)}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),n=Math.pow(t,e),r=st(n),o=tt(),i=tt(),s="";for(this.divRemTo(r,o,i);o.signum()>0;)s=(n+i.intValue()).toString(t).substr(1)+s,o.divRemTo(r,o,i);return i.intValue().toString(t)+s}fromRadix(t,e){this.fromInt(0),null==e&&(e=10);for(var n=this.chunkSize(e),r=Math.pow(e,n),o=!1,i=0,s=0,a=0;a<t.length;++a){var u=it(t,a);u<0?"-"==t.charAt(a)&&0==this.signum()&&(o=!0):(s=e*s+u,++i>=n&&(this.dMultiply(r),this.dAddOffset(s,0),i=0,s=0))}i>0&&(this.dMultiply(Math.pow(e,i)),this.dAddOffset(s,0)),o&&Z.ZERO.subTo(this,this)}fromNumber(t,e,n){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,n),this.testBit(t-1)||this.bitwiseTo(Z.ONE.shiftLeft(t-1),F,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(Z.ONE.shiftLeft(t-1),this);else{var r=[],o=7&t;r.length=1+(t>>3),e.nextBytes(r),o>0?r[0]&=(1<<o)-1:r[0]=0,this.fromString(r,256)}}bitwiseTo(t,e,n){var r,o,i=Math.min(t.t,this.t);for(r=0;r<i;++r)n[r]=e(this[r],t[r]);if(t.t<this.t){for(o=t.s&this.DM,r=i;r<this.t;++r)n[r]=e(this[r],o);n.t=this.t}else{for(o=this.s&this.DM,r=i;r<t.t;++r)n[r]=e(o,t[r]);n.t=t.t}n.s=e(this.s,t.s),n.clamp()}changeBit(t,e){var n=Z.ONE.shiftLeft(t);return this.bitwiseTo(n,e,n),n}addTo(t,e){for(var n=0,r=0,o=Math.min(t.t,this.t);n<o;)r+=this[n]+t[n],e[n++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r+=t.s;n<this.t;)r+=this[n],e[n++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;n<t.t;)r+=t[n],e[n++]=r&this.DM,r>>=this.DB;r+=t.s}e.s=r<0?-1:0,r>0?e[n++]=r:r<-1&&(e[n++]=this.DV+r),e.t=n,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,n){var r=Math.min(this.t+t.t,e);for(n.s=0,n.t=r;r>0;)n[--r]=0;for(var o=n.t-this.t;r<o;++r)n[r+this.t]=this.am(0,t[r],n,r,0,this.t);for(o=Math.min(t.t,e);r<o;++r)this.am(0,t[r],n,r,0,e-r);n.clamp()}multiplyUpperTo(t,e,n){--e;var r=n.t=this.t+t.t-e;for(n.s=0;--r>=0;)n[r]=0;for(r=Math.max(e-this.t,0);r<t.t;++r)n[this.t+r-e]=this.am(e-r,t[r],n,0,0,this.t+r-e);n.clamp(),n.drShiftTo(1,n)}modInt(t){if(t<=0)return 0;var e=this.DV%t,n=this.s<0?t-1:0;if(this.t>0)if(0==e)n=this[0]%t;else for(var r=this.t-1;r>=0;--r)n=(e*n+this[r])%t;return n}millerRabin(t){var e=this.subtract(Z.ONE),n=e.getLowestSetBit();if(n<=0)return!1;var r=e.shiftRight(n);(t=t+1>>1)>p.length&&(t=p.length);for(var o=tt(),i=0;i<t;++i){o.fromInt(p[Math.floor(Math.random()*p.length)]);var s=o.modPow(r,this);if(0!=s.compareTo(Z.ONE)&&0!=s.compareTo(e)){for(var a=1;a++<n&&0!=s.compareTo(e);)if(0==(s=s.modPowInt(2,this)).compareTo(Z.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 n=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(n.compareTo(r)<0){var o=n;n=r,r=o}var i=n.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)e(n);else{i<s&&(s=i),s>0&&(n.rShiftTo(s,n),r.rShiftTo(s,r));var a=()=>{(i=n.getLowestSetBit())>0&&n.rShiftTo(i,n),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),n.compareTo(r)>=0?(n.subTo(r,n),n.rShiftTo(1,n)):(r.subTo(n,r),r.rShiftTo(1,r)),n.signum()>0?setTimeout(a,0):(s>0&&r.lShiftTo(s,r),setTimeout(function(){e(r)},0))};setTimeout(a,10)}}fromNumberAsync(t,e,n,r){if("number"==typeof e)if(t<2)this.fromInt(1);else{this.fromNumber(t,n),this.testBit(t-1)||this.bitwiseTo(Z.ONE.shiftLeft(t-1),F,this),this.isEven()&&this.dAddOffset(1,0);var o=this,i=function(){o.dAddOffset(2,0),o.bitLength()>t&&o.subTo(Z.ONE.shiftLeft(t-1),o),o.isProbablePrime(e)?setTimeout(function(){r()},0):setTimeout(i,0)};setTimeout(i,0)}else{var s=[],a=7&t;s.length=1+(t>>3),e.nextBytes(s),a>0?s[0]&=(1<<a)-1:s[0]=0,this.fromString(s,256)}}}var y=function(){function t(){}return t.prototype.convert=function(t){return t},t.prototype.revert=function(t){return t},t.prototype.mulTo=function(t,e,n){t.multiplyTo(e,n)},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,n){t.multiplyTo(e,n),this.reduce(n)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),g=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(Z.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 n=32767&t[e],r=n*this.mpl+((n*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[n=e+this.m.t]+=this.m.am(0,r,t,e,0,this.m.t);t[n]>=t.DV;)t[n]-=t.DV,t[++n]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},t.prototype.mulTo=function(t,e,n){t.multiplyTo(e,n),this.reduce(n)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),b=function(){function t(t){this.m=t,this.r2=tt(),this.q3=tt(),Z.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,n){t.multiplyTo(e,n),this.reduce(n)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}();function tt(){return new Z(null)}function et(t,e){return new Z(t,e)}function nt(t,e,n,r,o,i){for(;--i>=0;){var s=e*this[t++]+n[r]+o;o=Math.floor(s/67108864),n[r++]=67108863&s}return o}function rt(t,e,n,r,o,i){for(var s=32767&e,a=e>>15;--i>=0;){var u=32767&this[t],c=this[t++]>>15,l=a*u+c*s;o=((u=s*u+((32767&l)<<15)+n[r]+(1073741823&o))>>>30)+(l>>>15)+a*c+(o>>>30),n[r++]=1073741823&u}return o}function ot(t,e,n,r,o,i){for(var s=16383&e,a=e>>14;--i>=0;){var u=16383&this[t],c=this[t++]>>14,l=a*u+c*s;o=((u=s*u+((16383&l)<<14)+n[r]+o)>>28)+(l>>14)+a*c,n[r++]=268435455&u}return o}void 0!==o&&"Microsoft Internet Explorer"==(null==o?void 0:o.appName)?(Z.prototype.am=rt,h=30):"Netscape"!=(null==o?void 0:o.appName)?(Z.prototype.am=nt,h=26):(Z.prototype.am=ot,h=28),Z.prototype.DB=h,Z.prototype.DM=(1<<h)-1,Z.prototype.DV=1<<h,Z.prototype.FV=Math.pow(2,52),Z.prototype.F1=52-h,Z.prototype.F2=2*h-52;var w,_,I=[];for(w="0".charCodeAt(0),_=0;_<=9;++_)I[w++]=_;for(w="a".charCodeAt(0),_=10;_<36;++_)I[w++]=_;for(w="A".charCodeAt(0),_=10;_<36;++_)I[w++]=_;function it(t,e){return I[t.charCodeAt(e)]??-1}function st(t){var e=tt();return e.fromInt(t),e}function at(t){var e,n=1;return 0!=(e=t>>>16)&&(t=e,n+=16),0!=(e=t>>8)&&(t=e,n+=8),0!=(e=t>>4)&&(t=e,n+=4),0!=(e=t>>2)&&(t=e,n+=2),0!=(e=t>>1)&&(t=e,n+=1),n}Z.ZERO=st(0),Z.ONE=st(1);class ut{constructor(){this.i=0,this.j=0,this.S=[]}init(t){var e,n,r;for(e=0;e<256;++e)this.S[e]=e;for(n=0,e=0;e<256;++e)n=n+this.S[e]+t[e%t.length]&255,r=this.S[e],this.S[e]=this.S[n],this.S[n]=r;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,O=null;if(null==O){O=[],S=0;var T,P,A=void 0;if("undefined"!=typeof window&&null!==(T=window)&&void 0!==T&&T.crypto&&null!==(P=window)&&void 0!==P&&P.crypto.getRandomValues){var R,C=new Uint32Array(256);for(null===(R=window)||void 0===R||R.crypto.getRandomValues(C),A=0;A<C.length;++A)O[S++]=255&C[A]}var N,x,U,D=function(t){var e,n,r;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===(r=window)||void 0===r||r.removeEventListener("mousemove",D,!1);else if(null!==(n=window)&&void 0!==n&&n.detachEvent){var o;null===(o=window)||void 0===o||o.detachEvent("onmousemove",D)}}else try{var i=t.x+t.y;O[S++]=255&i,this.count+=1}catch(t){}};if("undefined"!=typeof window)if(null!==(N=window)&&void 0!==N&&N.addEventListener)null===(U=window)||void 0===U||U.addEventListener("mousemove",D,!1);else if(null!==(x=window)&&void 0!==x&&x.attachEvent){var L;null===(L=window)||void 0===L||L.attachEvent("onmousemove",D)}}function ct(){if(null==E){for(E=new ut;S<256;){var t=Math.floor(65536*Math.random());O[S++]=255&t}for(E.init(O),S=0;S<O.length;++S)O[S]=0;S=0}return E.next()}class lt{constructor(){}nextBytes(t){for(var e=0;e<t.length;++e)t[e]=ct()}}function ht(t,e){if(e<t.length+11)return console.error("Message too long for RSA"),null;for(var n=[],r=t.length-1;r>=0&&e>0;){var o=t.charCodeAt(r--);o<128?n[--e]=o:o>127&&o<2048?(n[--e]=63&o|128,n[--e]=o>>6|192):(n[--e]=63&o|128,n[--e]=o>>6&63|128,n[--e]=o>>12|224)}n[--e]=0;for(var i=new lt,s=[];e>2;){for(s[0]=0;0==s[0];)i.nextBytes(s);n[--e]=s[0]}return n[--e]=2,n[--e]=0,new Z(n)}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),n=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(n)<0;)e=e.add(this.p);return e.subtract(n).multiply(this.coeff).mod(this.p).multiply(this.q).add(n)}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=ht(t,this.n.bitLength()+7>>3);if(null==e)return null;var n=this.doPublic(e);if(null==n)return null;var r=n.toString(16);return 1&r.length?"0"+r:r}encryptLong(t){var e=this,n=(this.n.bitLength()+7>>3)-11;try{var r="";return t.length>n?(t.match(/.{1,117}/g).forEach(function(t){var n=e.encrypt(t);r+=n}),K(r)):K(this.encrypt(t))}catch(t){return!1}}decryptLong(t){var e=this,n=this.n.bitLength()+7>>3;t=J(t);try{if(t.length>n){var r="";return t.match(/.{1,256}/g).forEach(function(t){var n=e.decrypt(t);r+=n}),r}return this.decrypt(t)}catch(t){return!1}}setPrivate(t,e,n){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=et(t,16),this.e=parseInt(e,16),this.d=et(n,16)):console.error("Invalid RSA private key")}setPrivateEx(t,e,n,r,o,i,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(n,16),this.p=et(r,16),this.q=et(o,16),this.dmp1=et(i,16),this.dmq1=et(s,16),this.coeff=et(a,16)):console.error("Invalid RSA private key")}generate(t,e){var n=new lt,r=t>>1;this.e=parseInt(e,16);for(var o=new Z(e,16);;){for(;this.p=new Z(t-r,1,n),0!=this.p.subtract(Z.ONE).gcd(o).compareTo(Z.ONE)||!this.p.isProbablePrime(10););for(;this.q=new Z(r,1,n),0!=this.q.subtract(Z.ONE).gcd(o).compareTo(Z.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var i=this.p;this.p=this.q,this.q=i}var s=this.p.subtract(Z.ONE),a=this.q.subtract(Z.ONE),u=s.multiply(a);if(0==u.gcd(o).compareTo(Z.ONE)){this.n=this.p.multiply(this.q),this.d=o.modInverse(u),this.dmp1=this.d.mod(s),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}}decrypt(t){var e=et(t,16),n=this.doPrivate(e);return null==n?null:ft(n,this.n.bitLength()+7>>3)}generateAsync(t,e,n){var r=new lt,o=t>>1;this.e=parseInt(e,16);var i=new Z(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(Z.ONE),r=s.q.subtract(Z.ONE),o=e.multiply(r);0==o.gcd(i).compareTo(Z.ONE)?(s.n=s.p.multiply(s.q),s.d=i.modInverse(o),s.dmp1=s.d.mod(e),s.dmq1=s.d.mod(r),s.coeff=s.q.modInverse(s.p),setTimeout(function(){n()},0)):setTimeout(a,0)},u=()=>{s.q=tt(),s.q.fromNumberAsync(o,1,r,function(){s.q.subtract(Z.ONE).gcda(i,function(t){0==t.compareTo(Z.ONE)&&s.q.isProbablePrime(10)?setTimeout(e,0):setTimeout(u,0)})})},c=()=>{s.p=tt(),s.p.fromNumberAsync(t-o,1,r,function(){s.p.subtract(Z.ONE).gcda(i,function(t){0==t.compareTo(Z.ONE)&&s.p.isProbablePrime(10)?setTimeout(u,0):setTimeout(c,0)})})};setTimeout(c,0)};setTimeout(a,0)}}function ft(t,e){for(var n=t.toByteArray(),r=0;r<n.length&&0==n[r];)++r;if(n.length-r!=e-1||2!=n[r])return null;for(++r;0!=n[r];)if(++r>=n.length)return null;for(var o="";++r<n.length;){var i=255&n[r];i<128?o+=String.fromCharCode(i):i>191&&i<224?(o+=String.fromCharCode((31&i)<<6|63&n[r+1]),++r):(o+=String.fromCharCode((15&i)<<12|(63&n[r+1])<<6|63&n[r+2]),r+=2)}return o}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,n=0,r=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(t)?u.decode(t):c.unarmor(t),o=$.decode(r);if(3===o.sub.length&&(o=o.sub[2].sub[0]),9===o.sub.length){e=o.sub[1].getHexStringValue(),this.n=et(e,16),n=o.sub[2].getHexStringValue(),this.e=parseInt(n,16);var i=o.sub[3].getHexStringValue();this.d=et(i,16);var s=o.sub[4].getHexStringValue();this.p=et(s,16);var a=o.sub[5].getHexStringValue();this.q=et(a,16);var l=o.sub[6].getHexStringValue();this.dmp1=et(l,16);var h=o.sub[7].getHexStringValue();this.dmq1=et(h,16);var d=o.sub[8].getHexStringValue();this.coeff=et(d,16)}else{if(2!==o.sub.length)return!1;var f=o.sub[1].sub[0];e=f.sub[0].getHexStringValue(),this.n=et(e,16),n=f.sub[1].getHexStringValue(),this.e=parseInt(n,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)}}(r=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)},r.prototype.setPrivateKey=function(t){this.setKey(t)},r.prototype.setPublicKey=function(t){this.setKey(t)},r.prototype.decrypt=function(t){try{return this.getKey().decrypt(J(t))}catch(t){return!1}},r.prototype.encrypt=function(t){try{return K(this.getKey().encrypt(t))}catch(t){return!1}},r.prototype.encryptLong=function(t){try{for(var e=this.getKey().encryptLong(t)||"",n=this.getKey().decryptLong(e)||"",r=0,o=/null$/g;o.test(n)&&(r++,e=this.getKey().encryptLong(t)||"",n=this.getKey().decryptLong(e)||"",!(r>10)););return e}catch(t){return!1}},r.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},r.version="3.1.4"}const k=r;var j=n(2631),q=function(t){var e=void 0===t?{}:t,n=e.publicKey,r=void 0===n?"":n,o=e.payload,i=void 0===o?{}:o;if(!r)return"";try{var s=(0,j.I)(i),a=new k;return a.setPublicKey(r),a.encryptLong("object"==typeof s?JSON.stringify(s):s)}catch(t){console.error("encrypt error:",t)}return""}},2631:(t,e,n)=>{n.d(e,{I:()=>r,y:()=>o});var r=function(t){var e=function(e){for(var n in t)t.hasOwnProperty(n)&&(e[n]=r(t[n]));return e},n=null==t?"NullOrUndefined":Object.prototype.toString.call(t).slice(8,-1);if(["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"].includes(n))return t.slice();switch(n){case"Object":return e(Object.create(Object.getPrototypeOf(t)));case"Array":return e([]);case"Date":return new Date(t.valueOf());case"RegExp":return new RegExp(t.source,(t.global?"g":"")+(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.sticky?"y":"")+(t.unicode?"u":""));default:return t}},o=function(t){var e=t.match(/^(?:http(s)?:\/\/[^\/]+)?(\/[^\?#]*)/);return e&&e[2]||""}},3388:t=>{t.exports={}},8182:function(t,e,n){var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&o(e,t,n);return i(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.useDefaultAdapter=e.useAdapters=e.RUNTIME=void 0;var a,u=s(n(4274)),c=n(3616);!function(t){t.WEB="web",t.WX_MP="wx_mp"}(a=e.RUNTIME||(e.RUNTIME={})),e.useAdapters=function(t,e){for(var n=0,o=(0,c.isArray)(t)?t:[t];n<o.length;n++){var i=o[n],s=i.isMatch,a=i.genAdapter,u=i.runtime;if(s())return{adapter:r({isMatch:s},a(e)),runtime:u}}},e.useDefaultAdapter=function(){return{adapter:r({},u.genAdapter()),runtime:a.WEB}}},4274:function(t,e,n){var r,o=this&&this.__extends||(r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},r(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__assign||function(){return i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},i.apply(this,arguments)},s=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}u((r=r.apply(t,e||[])).next())})},a=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.WebRequest=e.genAdapter=void 0;var u=n(7149),c=n(3616),l=n(2946),h=function(t){function e(e){var n=t.call(this)||this,r=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return n.timeout=r||0,n.timeoutMsg=o||"请求超时",n.restrictedMethods=i||["get","post","upload","download"],n}return o(e,t),e.prototype.get=function(t){return this.request(i(i({},t),{method:"get"}),this.restrictedMethods.includes("get"))},e.prototype.post=function(t){return this.request(i(i({},t),{method:"post"}),this.restrictedMethods.includes("post"))},e.prototype.put=function(t){return this.request(i(i({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,n=t.file,r=t.name,o=t.method,s=t.headers,a=void 0===s?{}:s,u={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",c=new FormData;return"post"===u?(Object.keys(e).forEach(function(t){c.append(t,e[t])}),c.append("key",r),c.append("file",n),this.request(i(i({},t),{data:c,method:u}),this.restrictedMethods.includes("upload"))):this.request(i(i({},t),{method:"put",headers:a,body:n}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return s(this,void 0,void 0,function(){var e,n,r,o;return a(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.get(i(i({},t),{headers:{},responseType:"blob"}))];case 1:return e=s.sent().data,n=window.URL.createObjectURL(new Blob([e])),r=decodeURIComponent(new URL(t.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=n,o.setAttribute("download",r),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(n),document.body.removeChild(o),[3,3];case 2:return s.sent(),[3,3];case 3:return[2,new Promise(function(e){e({statusCode:200,tempFilePath:t.url})})]}})})},e.prototype.fetch=function(t){var e;return s(this,void 0,void 0,function(){var n,r,o,u,c,l,h,d,f,p,v,y,m,g=this;return a(this,function(b){switch(b.label){case 0:return n=new AbortController,r=t.url,o=t.enableAbort,u=void 0!==o&&o,c=t.stream,l=void 0!==c&&c,h=t.signal,d=t.timeout,f=t.shouldThrowOnError,p=void 0===f||f,v=null!=d?d:this.timeout,h&&(h.aborted&&n.abort(),h.addEventListener("abort",function(){return n.abort()})),y=null,u&&v&&(y=setTimeout(function(){console.warn(g.timeoutMsg),n.abort(new Error(g.timeoutMsg))},v)),[4,fetch(r,i(i({},t),{signal:n.signal})).then(function(t){return s(g,void 0,void 0,function(){var e,n,r;return a(this,function(o){switch(o.label){case 0:return clearTimeout(y),p?t.ok?(e=t,[3,3]):[3,1]:[3,4];case 1:return r=(n=Promise).reject,[4,t.json()];case 2:e=r.apply(n,[o.sent()]),o.label=3;case 3:return[2,e];case 4:return[2,t]}})})}).catch(function(t){return clearTimeout(y),Promise.reject(t)})];case 1:return m=b.sent(),[2,{data:l?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 n=this;void 0===e&&(e=!1);var r=String(t.method).toLowerCase()||"get";return new Promise(function(o){var i=t.url,s=t.headers,a=void 0===s?{}:s,u=t.data,h=t.responseType,d=t.withCredentials,f=t.body,p=t.onUploadProgress,v=(0,c.formatUrl)((0,l.getProtocol)(),i,"get"===r?u:{}),y=new XMLHttpRequest;y.open(r,v),h&&(y.responseType=h);var m,g,b=t.signal;b&&(b.aborted?y.abort():b.addEventListener("abort",function(){return y.abort()},{once:!0})),Object.keys(a).forEach(function(t){y.setRequestHeader(t,a[t])}),p&&y.upload.addEventListener("progress",p),y.onreadystatechange=function(){var t={};if(4===y.readyState){var e=y.getAllResponseHeaders().trim().split(/[\r\n]+/),n={};e.forEach(function(t){var e=t.split(": "),r=e.shift().toLowerCase(),o=e.join(": ");n[r]=o}),t.header=n,t.statusCode=y.status;try{t.data="blob"===h?y.response:JSON.parse(y.responseText)}catch(e){t.data="blob"===h?y.response:y.responseText}clearTimeout(m),o(t)}},e&&n.timeout&&(m=setTimeout(function(){console.warn(n.timeoutMsg),y.abort()},n.timeout)),g=(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&&(y.withCredentials=!0),y.send(g)})},e}(u.AbstractSDKRequest);e.WebRequest=h,e.genAdapter=function(){return{type:"default",root:window,reqClass:h,wsClass:WebSocket,localStorage}}},2946:(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 n="@cloudbase/js-sdk";e.setSdkName=function(t){n=t},e.getSdkName=function(){return n};var r="https:";e.setProtocol=function(t){r=t},e.getProtocol=function(){return r},e.IS_DEBUG_MODE=!1,e.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},6205:(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,n){var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.OATUH_LOGINTYPE=void 0,o(n(2946),e),o(n(6205),e),e.OATUH_LOGINTYPE="constants"},7718:function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}u((r=r.apply(t,e||[])).next())})},o=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.catchErrorsDecorator=void 0;var i=n(3616),s=n(794),a=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(a=-1!==navigator.userAgent.indexOf("Firefox"));var u=a?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,c=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function l(t){var e=t.err,n=t.className,r=t.methodName,o=t.sourceLink;if(!o)return null;var i,s=e.stack.split("\n"),u=a?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(n,"\\.descriptor.value\\s*\\[as\\s").concat(r,"\\]\\s*\\(.*\\)$")),l=a?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(n,"\\.descriptor.value\\s*\\[as\\s").concat(r,"\\]")),h=s.findIndex(function(t){return u.test(t)});if(-1!==h){var d=s.filter(function(t,e){return e>h});d.unshift(s[h].replace(l,"".concat(n,".").concat(r)).replace(c,o)),(i=new Error).stack="".concat(a?"@debugger":"Error","\n").concat(d.join("\n"))}return i}e.catchErrorsDecorator=function(t){var e=t.mode,n=void 0===e?"async":e,a=t.customInfo,h=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=h.className||t.constructor.name,v=h.methodName||e,y=a.value,m=function(){var t="",e=(new Error).stack.split("\n"),n=e.findIndex(function(t){return u.test(t)});if(-1!==n){var r=c.exec(e[n+1]||"");t=r?r[0]:""}return t}();a.value="sync"===n?function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=l({err:new Error,className:f,methodName:v,sourceLink:m});try{return y.apply(this,t)}catch(t){var r=t,o=t.message,s=t.error,a=t.error_description,u={title:d||"".concat(f,".").concat(v," failed"),content:[{type:"error",body:t}]};if(o&&/^\{.*\}$/.test(o)){var c=JSON.parse(o);u.subtitle=o,c.code&&(n?(n.code=c.code,n.msg=c.msg):(t.code=c.code,t.message=c.msg),r=n||t,u.content=p.map(function(t){return{type:"info",body:t}}))}throw s&&a&&(u.subtitle=a,n?(n.code=s,n.msg=a):(t.code=s,t.message=a),r=n||t,u.content=p.map(function(t){return{type:"info",body:t}})),(0,i.printGroupLog)(u),r}}:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return r(this,void 0,void 0,function(){var e,n,r,s,a,u,c,h;return o(this,function(o){switch(o.label){case 0:e=l({err:new Error,className:f,methodName:v,sourceLink:m}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,y.apply(this,t)];case 2:return[2,o.sent()];case 3:throw n=o.sent(),r=n,s=n.message,a=n.error,u=n.error_description,c={title:d||"".concat(f,".").concat(v," failed"),content:[{type: