@junobuild/analytics 0.0.21 → 0.0.22

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,44 +1,43 @@
1
- "use strict";(()=>{var xl=Object.create;var Dn=Object.defineProperty;var _l=Object.getOwnPropertyDescriptor;var El=Object.getOwnPropertyNames;var Bl=Object.getPrototypeOf,vl=Object.prototype.hasOwnProperty;var we=(t,e)=>()=>(t&&(e=t(t=0)),e);var $e=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),fn=(t,e)=>{for(var r in e)Dn(t,r,{get:e[r],enumerable:!0})},Ma=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of El(e))!vl.call(t,i)&&i!==r&&Dn(t,i,{get:()=>e[i],enumerable:!(n=_l(e,i))||n.enumerable});return t};var qr=(t,e,r)=>(r=t!=null?xl(Bl(t)):{},Ma(e||!t||!t.__esModule?Dn(r,"default",{value:t,enumerable:!0}):r,t)),Al=t=>Ma(Dn({},"__esModule",{value:!0}),t);function Ca(t){let e=0,r=0,n="";function i(s){return e<0?r|=s>>-e:r=s<<e&248,e>3?(e-=8,1):(e<4&&(n+=ei[r>>3],e+=5),0)}for(let s=0;s<t.length;)s+=i(t[s]);return n+(e<0?ei[r>>3]:"")}function qa(t){let e=0,r=0,n=new Uint8Array(t.length*4/3|0),i=0;function s(o){let a=Vr[o.toLowerCase()];if(a===void 0)throw new Error(`Invalid character: ${JSON.stringify(o)}`);a<<=3,r|=a>>>e,e+=5,e>=8&&(n[i++]=r,e-=8,e>0?r=a<<5-e&255:r=0)}for(let o of t)s(o);return n.slice(0,i)}var ei,Vr,Va=we(()=>{ei="abcdefghijklmnopqrstuvwxyz234567",Vr=Object.create(null);for(let t=0;t<ei.length;t++)Vr[ei[t]]=t;Vr[0]=Vr.o;Vr[1]=Vr.i});function $a(t){let e=new Uint8Array(t),r=-1;for(let n=0;n<e.length;n++){let s=(e[n]^r)&255;r=Tl[s]^r>>>8}return(r^-1)>>>0}var Tl,Ga=we(()=>{Tl=new Uint32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117])});function Sl(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function ti(t,...e){if(!Sl(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function Rs(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Ha(t,e){ti(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var Is=we(()=>{});var ri,ja=we(()=>{ri=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0});function Os(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Us(t){return typeof t=="string"&&(t=Os(t)),ti(t),t}function Ya(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];ti(i),e+=i.length}let r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let s=t[n];r.set(s,i),i+=s.length}return r}function ln(t){let e=n=>t().update(Us(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function si(t=32){if(ri&&typeof ri.getRandomValues=="function")return ri.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}var ii,Bt,hm,ni,pm,$r=we(()=>{ja();Is();ii=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Bt=(t,e)=>t<<32-e|t>>>e,hm=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;ni=class{clone(){return this._cloneInto()}},pm={}.toString});function Nl(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let i=BigInt(32),s=BigInt(4294967295),o=Number(r>>i&s),a=Number(r&s),c=n?4:0,f=n?0:4;t.setUint32(e+c,o,n),t.setUint32(e+f,a,n)}var za,Ka,Gr,Fs=we(()=>{Is();$r();za=(t,e,r)=>t&e^~t&r,Ka=(t,e,r)=>t&e^t&r^e&r,Gr=class extends ni{constructor(e,r,n,i){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=ii(this.buffer)}update(e){Rs(this);let{view:r,buffer:n,blockLen:i}=this;e=Us(e);let s=e.length;for(let o=0;o<s;){let a=Math.min(i-this.pos,s-o);if(a===i){let c=ii(e);for(;i<=s-o;o+=i)this.process(c,o);continue}n.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Rs(this),Ha(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:s}=this,{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let d=o;d<i;d++)r[d]=0;Nl(n,i-8,BigInt(this.length*8),s),this.process(n,0);let a=ii(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,l=this.get();if(f>l.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<f;d++)a.setUint32(4*d,l[d],s)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:s,destroyed:o,pos:a}=this;return e.length=i,e.pos=a,e.finished=s,e.destroyed=o,i%r&&e.buffer.set(n),e}}});var Rl,er,tr,oi,Ps,dn,Za,ai=we(()=>{Fs();$r();Rl=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),er=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),tr=new Uint32Array(64),oi=class extends Gr{constructor(){super(64,32,8,!1),this.A=er[0]|0,this.B=er[1]|0,this.C=er[2]|0,this.D=er[3]|0,this.E=er[4]|0,this.F=er[5]|0,this.G=er[6]|0,this.H=er[7]|0}get(){let{A:e,B:r,C:n,D:i,E:s,F:o,G:a,H:c}=this;return[e,r,n,i,s,o,a,c]}set(e,r,n,i,s,o,a,c){this.A=e|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,r){for(let d=0;d<16;d++,r+=4)tr[d]=e.getUint32(r,!1);for(let d=16;d<64;d++){let v=tr[d-15],w=tr[d-2],_=Bt(v,7)^Bt(v,18)^v>>>3,E=Bt(w,17)^Bt(w,19)^w>>>10;tr[d]=E+tr[d-7]+_+tr[d-16]|0}let{A:n,B:i,C:s,D:o,E:a,F:c,G:f,H:l}=this;for(let d=0;d<64;d++){let v=Bt(a,6)^Bt(a,11)^Bt(a,25),w=l+v+za(a,c,f)+Rl[d]+tr[d]|0,E=(Bt(n,2)^Bt(n,13)^Bt(n,22))+Ka(n,i,s)|0;l=f,f=c,c=a,a=o+w|0,o=s,s=i,i=n,n=w+E|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,l=l+this.H|0,this.set(n,i,s,o,a,c,f,l)}roundClean(){tr.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},Ps=class extends oi{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}},dn=ln(()=>new oi),Za=ln(()=>new Ps)});function Wa(t){return Za.create().update(new Uint8Array(t)).digest()}var Xa=we(()=>{ai()});var ci,Il,Ja,Ol,Ul,Fl,ae,yt=we(()=>{Va();Ga();Xa();ci="__principal__",Il=2,Ja=4,Ol="aaaaa-aa",Ul=t=>{var e;return new Uint8Array(((e=t.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(r=>parseInt(r,16)))},Fl=t=>t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),""),ae=class t{constructor(e){this._arr=e,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([Ja]))}static managementCanister(){return this.fromHex(Ol)}static selfAuthenticating(e){let r=Wa(e);return new this(new Uint8Array([...r,Il]))}static from(e){if(typeof e=="string")return t.fromText(e);if(Object.getPrototypeOf(e)===Uint8Array.prototype)return new t(e);if(typeof e=="object"&&e!==null&&e._isPrincipal===!0)return new t(e._arr);throw new Error(`Impossible to convert ${JSON.stringify(e)} to Principal.`)}static fromHex(e){return new this(Ul(e))}static fromText(e){let r=e;if(e.includes(ci)){let o=JSON.parse(e);ci in o&&(r=o[ci])}let n=r.toLowerCase().replace(/-/g,""),i=qa(n);i=i.slice(4,i.length);let s=new this(i);if(s.toText()!==r)throw new Error(`Principal "${s.toText()}" does not have a valid checksum (original value "${r}" may not be a valid Principal ID).`);return s}static fromUint8Array(e){return new this(e)}isAnonymous(){return this._arr.byteLength===1&&this._arr[0]===Ja}toUint8Array(){return this._arr}toHex(){return Fl(this._arr).toUpperCase()}toText(){let e=new ArrayBuffer(4);new DataView(e).setUint32(0,$a(this._arr));let n=new Uint8Array(e),i=Uint8Array.from(this._arr),s=new Uint8Array([...n,...i]),a=Ca(s).match(/.{1,5}/g);if(!a)throw new Error;return a.join("-")}toString(){return this.toText()}toJSON(){return{[ci]:this.toText()}}compareTo(e){for(let r=0;r<Math.min(this._arr.length,e._arr.length);r++){if(this._arr[r]<e._arr[r])return"lt";if(this._arr[r]>e._arr[r])return"gt"}return this._arr.length<e._arr.length?"lt":this._arr.length>e._arr.length?"gt":"eq"}ltEq(e){let r=this.compareTo(e);return r=="lt"||r=="eq"}gtEq(e){let r=this.compareTo(e);return r=="gt"||r=="eq"}}});var pc=$e(fi=>{"use strict";fi.byteLength=Zl;fi.toByteArray=Xl;fi.fromByteArray=Ll;var Pt=[],gt=[],Kl=typeof Uint8Array<"u"?Uint8Array:Array,Vs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Er=0,dc=Vs.length;Er<dc;++Er)Pt[Er]=Vs[Er],gt[Vs.charCodeAt(Er)]=Er;var Er,dc;gt[45]=62;gt[95]=63;function hc(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function Zl(t){var e=hc(t),r=e[0],n=e[1];return(r+n)*3/4-n}function Wl(t,e,r){return(e+r)*3/4-r}function Xl(t){var e,r=hc(t),n=r[0],i=r[1],s=new Kl(Wl(t,n,i)),o=0,a=i>0?n-4:n,c;for(c=0;c<a;c+=4)e=gt[t.charCodeAt(c)]<<18|gt[t.charCodeAt(c+1)]<<12|gt[t.charCodeAt(c+2)]<<6|gt[t.charCodeAt(c+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=gt[t.charCodeAt(c)]<<2|gt[t.charCodeAt(c+1)]>>4,s[o++]=e&255),i===1&&(e=gt[t.charCodeAt(c)]<<10|gt[t.charCodeAt(c+1)]<<4|gt[t.charCodeAt(c+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function Jl(t){return Pt[t>>18&63]+Pt[t>>12&63]+Pt[t>>6&63]+Pt[t&63]}function Ql(t,e,r){for(var n,i=[],s=e;s<r;s+=3)n=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(t[s+2]&255),i.push(Jl(n));return i.join("")}function Ll(t){for(var e,r=t.length,n=r%3,i=[],s=16383,o=0,a=r-n;o<a;o+=s)i.push(Ql(t,o,o+s>a?a:o+s));return n===1?(e=t[r-1],i.push(Pt[e>>2]+Pt[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(Pt[e>>10]+Pt[e>>4&63]+Pt[e<<2&63]+"=")),i.join("")}});var Gs=$e($s=>{$s.read=function(t,e,r,n,i){var s,o,a=i*8-n-1,c=(1<<a)-1,f=c>>1,l=-7,d=r?i-1:0,v=r?-1:1,w=t[e+d];for(d+=v,s=w&(1<<-l)-1,w>>=-l,l+=a;l>0;s=s*256+t[e+d],d+=v,l-=8);for(o=s&(1<<-l)-1,s>>=-l,l+=n;l>0;o=o*256+t[e+d],d+=v,l-=8);if(s===0)s=1-f;else{if(s===c)return o?NaN:(w?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-f}return(w?-1:1)*o*Math.pow(2,s-n)};$s.write=function(t,e,r,n,i,s){var o,a,c,f=s*8-i-1,l=(1<<f)-1,d=l>>1,v=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=n?0:s-1,_=n?1:-1,E=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=l):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+d>=1?e+=v/c:e+=v*Math.pow(2,1-d),e*c>=2&&(o++,c/=2),o+d>=l?(a=0,o=l):o+d>=1?(a=(e*c-1)*Math.pow(2,i),o=o+d):(a=e*Math.pow(2,d-1)*Math.pow(2,i),o=0));i>=8;t[r+w]=a&255,w+=_,a/=256,i-=8);for(o=o<<i|a,f+=i;f>0;t[r+w]=o&255,w+=_,o/=256,f-=8);t[r+w-_]|=E*128}});var Oc=$e(Kr=>{"use strict";var Hs=pc(),Yr=Gs(),mc=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Kr.Buffer=P;Kr.SlowBuffer=id;Kr.INSPECT_MAX_BYTES=50;var li=2147483647;Kr.kMaxLength=li;P.TYPED_ARRAY_SUPPORT=Dl();!P.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function Dl(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(P.prototype,"parent",{enumerable:!0,get:function(){if(P.isBuffer(this))return this.buffer}});Object.defineProperty(P.prototype,"offset",{enumerable:!0,get:function(){if(P.isBuffer(this))return this.byteOffset}});function Zt(t){if(t>li)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,P.prototype),e}function P(t,e,r){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Ks(t)}return wc(t,e,r)}P.poolSize=8192;function wc(t,e,r){if(typeof t=="string")return td(t,e);if(ArrayBuffer.isView(t))return rd(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(kt(t,ArrayBuffer)||t&&kt(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(kt(t,SharedArrayBuffer)||t&&kt(t.buffer,SharedArrayBuffer)))return Ys(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=t.valueOf&&t.valueOf();if(n!=null&&n!==t)return P.from(n,e,r);let i=nd(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return P.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}P.from=function(t,e,r){return wc(t,e,r)};Object.setPrototypeOf(P.prototype,Uint8Array.prototype);Object.setPrototypeOf(P,Uint8Array);function xc(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function ed(t,e,r){return xc(t),t<=0?Zt(t):e!==void 0?typeof r=="string"?Zt(t).fill(e,r):Zt(t).fill(e):Zt(t)}P.alloc=function(t,e,r){return ed(t,e,r)};function Ks(t){return xc(t),Zt(t<0?0:Zs(t)|0)}P.allocUnsafe=function(t){return Ks(t)};P.allocUnsafeSlow=function(t){return Ks(t)};function td(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!P.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=_c(t,e)|0,n=Zt(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function js(t){let e=t.length<0?0:Zs(t.length)|0,r=Zt(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function rd(t){if(kt(t,Uint8Array)){let e=new Uint8Array(t);return Ys(e.buffer,e.byteOffset,e.byteLength)}return js(t)}function Ys(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&r===void 0?n=new Uint8Array(t):r===void 0?n=new Uint8Array(t,e):n=new Uint8Array(t,e,r),Object.setPrototypeOf(n,P.prototype),n}function nd(t){if(P.isBuffer(t)){let e=Zs(t.length)|0,r=Zt(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||Xs(t.length)?Zt(0):js(t);if(t.type==="Buffer"&&Array.isArray(t.data))return js(t.data)}function Zs(t){if(t>=li)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+li.toString(16)+" bytes");return t|0}function id(t){return+t!=t&&(t=0),P.alloc(+t)}P.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==P.prototype};P.compare=function(e,r){if(kt(e,Uint8Array)&&(e=P.from(e,e.offset,e.byteLength)),kt(r,Uint8Array)&&(r=P.from(r,r.offset,r.byteLength)),!P.isBuffer(e)||!P.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;let n=e.length,i=r.length;for(let s=0,o=Math.min(n,i);s<o;++s)if(e[s]!==r[s]){n=e[s],i=r[s];break}return n<i?-1:i<n?1:0};P.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};P.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return P.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=P.allocUnsafe(r),s=0;for(n=0;n<e.length;++n){let o=e[n];if(kt(o,Uint8Array))s+o.length>i.length?(P.isBuffer(o)||(o=P.from(o)),o.copy(i,s)):Uint8Array.prototype.set.call(i,o,s);else if(P.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function _c(t,e){if(P.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||kt(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let r=t.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return zs(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Ic(t).length;default:if(i)return n?-1:zs(t).length;e=(""+e).toLowerCase(),i=!0}}P.byteLength=_c;function sd(t,e,r){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return md(this,e,r);case"utf8":case"utf-8":return Bc(this,e,r);case"ascii":return hd(this,e,r);case"latin1":case"binary":return pd(this,e,r);case"base64":return ld(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return yd(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}P.prototype._isBuffer=!0;function Br(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}P.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<e;r+=2)Br(this,r,r+1);return this};P.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<e;r+=4)Br(this,r,r+3),Br(this,r+1,r+2);return this};P.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<e;r+=8)Br(this,r,r+7),Br(this,r+1,r+6),Br(this,r+2,r+5),Br(this,r+3,r+4);return this};P.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?Bc(this,0,e):sd.apply(this,arguments)};P.prototype.toLocaleString=P.prototype.toString;P.prototype.equals=function(e){if(!P.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:P.compare(this,e)===0};P.prototype.inspect=function(){let e="",r=Kr.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};mc&&(P.prototype[mc]=P.prototype.inspect);P.prototype.compare=function(e,r,n,i,s){if(kt(e,Uint8Array)&&(e=P.from(e,e.offset,e.byteLength)),!P.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),r<0||n>e.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&r>=n)return 0;if(i>=s)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,s>>>=0,this===e)return 0;let o=s-i,a=n-r,c=Math.min(o,a),f=this.slice(i,s),l=e.slice(r,n);for(let d=0;d<c;++d)if(f[d]!==l[d]){o=f[d],a=l[d];break}return o<a?-1:a<o?1:0};function Ec(t,e,r,n,i){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Xs(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof e=="string"&&(e=P.from(e,n)),P.isBuffer(e))return e.length===0?-1:yc(t,e,r,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):yc(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function yc(t,e,r,n,i){let s=1,o=t.length,a=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;s=2,o/=2,a/=2,r/=2}function c(l,d){return s===1?l[d]:l.readUInt16BE(d*s)}let f;if(i){let l=-1;for(f=r;f<o;f++)if(c(t,f)===c(e,l===-1?0:f-l)){if(l===-1&&(l=f),f-l+1===a)return l*s}else l!==-1&&(f-=f-l),l=-1}else for(r+a>o&&(r=o-a),f=r;f>=0;f--){let l=!0;for(let d=0;d<a;d++)if(c(t,f+d)!==c(e,d)){l=!1;break}if(l)return f}return-1}P.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};P.prototype.indexOf=function(e,r,n){return Ec(this,e,r,n,!0)};P.prototype.lastIndexOf=function(e,r,n){return Ec(this,e,r,n,!1)};function od(t,e,r,n){r=Number(r)||0;let i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let s=e.length;n>s/2&&(n=s/2);let o;for(o=0;o<n;++o){let a=parseInt(e.substr(o*2,2),16);if(Xs(a))return o;t[r+o]=a}return o}function ad(t,e,r,n){return di(zs(e,t.length-r),t,r,n)}function cd(t,e,r,n){return di(xd(e),t,r,n)}function ud(t,e,r,n){return di(Ic(e),t,r,n)}function fd(t,e,r,n){return di(_d(e,t.length-r),t,r,n)}P.prototype.write=function(e,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let s=this.length-r;if((n===void 0||n>s)&&(n=s),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let o=!1;for(;;)switch(i){case"hex":return od(this,e,r,n);case"utf8":case"utf-8":return ad(this,e,r,n);case"ascii":case"latin1":case"binary":return cd(this,e,r,n);case"base64":return ud(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fd(this,e,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};P.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ld(t,e,r){return e===0&&r===t.length?Hs.fromByteArray(t):Hs.fromByteArray(t.slice(e,r))}function Bc(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i<r;){let s=t[i],o=null,a=s>239?4:s>223?3:s>191?2:1;if(i+a<=r){let c,f,l,d;switch(a){case 1:s<128&&(o=s);break;case 2:c=t[i+1],(c&192)===128&&(d=(s&31)<<6|c&63,d>127&&(o=d));break;case 3:c=t[i+1],f=t[i+2],(c&192)===128&&(f&192)===128&&(d=(s&15)<<12|(c&63)<<6|f&63,d>2047&&(d<55296||d>57343)&&(o=d));break;case 4:c=t[i+1],f=t[i+2],l=t[i+3],(c&192)===128&&(f&192)===128&&(l&192)===128&&(d=(s&15)<<18|(c&63)<<12|(f&63)<<6|l&63,d>65535&&d<1114112&&(o=d))}}o===null?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=a}return dd(n)}var gc=4096;function dd(t){let e=t.length;if(e<=gc)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=gc));return r}function hd(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]&127);return n}function pd(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function md(t,e,r){let n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let s=e;s<r;++s)i+=Ed[t[s]];return i}function yd(t,e,r){let n=t.slice(e,r),i="";for(let s=0;s<n.length-1;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}P.prototype.slice=function(e,r){let n=this.length;e=~~e,r=r===void 0?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);let i=this.subarray(e,r);return Object.setPrototypeOf(i,P.prototype),i};function Xe(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}P.prototype.readUintLE=P.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||Xe(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return i};P.prototype.readUintBE=P.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||Xe(e,r,this.length);let i=this[e+--r],s=1;for(;r>0&&(s*=256);)i+=this[e+--r]*s;return i};P.prototype.readUint8=P.prototype.readUInt8=function(e,r){return e=e>>>0,r||Xe(e,1,this.length),this[e]};P.prototype.readUint16LE=P.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||Xe(e,2,this.length),this[e]|this[e+1]<<8};P.prototype.readUint16BE=P.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||Xe(e,2,this.length),this[e]<<8|this[e+1]};P.prototype.readUint32LE=P.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||Xe(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};P.prototype.readUint32BE=P.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||Xe(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};P.prototype.readBigUInt64LE=ir(function(e){e=e>>>0,zr(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&mn(e,this.length-8);let i=r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,s=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(s)<<BigInt(32))});P.prototype.readBigUInt64BE=ir(function(e){e=e>>>0,zr(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&mn(e,this.length-8);let i=r*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],s=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(s)});P.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||Xe(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*r)),i};P.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||Xe(e,r,this.length);let i=r,s=1,o=this[e+--i];for(;i>0&&(s*=256);)o+=this[e+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*r)),o};P.prototype.readInt8=function(e,r){return e=e>>>0,r||Xe(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};P.prototype.readInt16LE=function(e,r){e=e>>>0,r||Xe(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};P.prototype.readInt16BE=function(e,r){e=e>>>0,r||Xe(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};P.prototype.readInt32LE=function(e,r){return e=e>>>0,r||Xe(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};P.prototype.readInt32BE=function(e,r){return e=e>>>0,r||Xe(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};P.prototype.readBigInt64LE=ir(function(e){e=e>>>0,zr(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&mn(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});P.prototype.readBigInt64BE=ir(function(e){e=e>>>0,zr(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&mn(e,this.length-8);let i=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});P.prototype.readFloatLE=function(e,r){return e=e>>>0,r||Xe(e,4,this.length),Yr.read(this,e,!0,23,4)};P.prototype.readFloatBE=function(e,r){return e=e>>>0,r||Xe(e,4,this.length),Yr.read(this,e,!1,23,4)};P.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||Xe(e,8,this.length),Yr.read(this,e,!0,52,8)};P.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||Xe(e,8,this.length),Yr.read(this,e,!1,52,8)};function ut(t,e,r,n,i,s){if(!P.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}P.prototype.writeUintLE=P.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;ut(this,e,r,n,a,0)}let s=1,o=0;for(this[r]=e&255;++o<n&&(s*=256);)this[r+o]=e/s&255;return r+n};P.prototype.writeUintBE=P.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;ut(this,e,r,n,a,0)}let s=n-1,o=1;for(this[r+s]=e&255;--s>=0&&(o*=256);)this[r+s]=e/o&255;return r+n};P.prototype.writeUint8=P.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||ut(this,e,r,1,255,0),this[r]=e&255,r+1};P.prototype.writeUint16LE=P.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||ut(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};P.prototype.writeUint16BE=P.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||ut(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};P.prototype.writeUint32LE=P.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||ut(this,e,r,4,4294967295,0),this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255,r+4};P.prototype.writeUint32BE=P.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||ut(this,e,r,4,4294967295,0),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};function vc(t,e,r,n,i){Rc(e,n,i,t,r,7);let s=Number(e&BigInt(4294967295));t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,r}function Ac(t,e,r,n,i){Rc(e,n,i,t,r,7);let s=Number(e&BigInt(4294967295));t[r+7]=s,s=s>>8,t[r+6]=s,s=s>>8,t[r+5]=s,s=s>>8,t[r+4]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=o,o=o>>8,t[r+2]=o,o=o>>8,t[r+1]=o,o=o>>8,t[r]=o,r+8}P.prototype.writeBigUInt64LE=ir(function(e,r=0){return vc(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});P.prototype.writeBigUInt64BE=ir(function(e,r=0){return Ac(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});P.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);ut(this,e,r,n,c-1,-c)}let s=0,o=1,a=0;for(this[r]=e&255;++s<n&&(o*=256);)e<0&&a===0&&this[r+s-1]!==0&&(a=1),this[r+s]=(e/o>>0)-a&255;return r+n};P.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);ut(this,e,r,n,c-1,-c)}let s=n-1,o=1,a=0;for(this[r+s]=e&255;--s>=0&&(o*=256);)e<0&&a===0&&this[r+s+1]!==0&&(a=1),this[r+s]=(e/o>>0)-a&255;return r+n};P.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||ut(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};P.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||ut(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};P.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||ut(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};P.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||ut(this,e,r,4,2147483647,-2147483648),this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24,r+4};P.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||ut(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};P.prototype.writeBigInt64LE=ir(function(e,r=0){return vc(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});P.prototype.writeBigInt64BE=ir(function(e,r=0){return Ac(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Tc(t,e,r,n,i,s){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Sc(t,e,r,n,i){return e=+e,r=r>>>0,i||Tc(t,e,r,4,34028234663852886e22,-34028234663852886e22),Yr.write(t,e,r,n,23,4),r+4}P.prototype.writeFloatLE=function(e,r,n){return Sc(this,e,r,!0,n)};P.prototype.writeFloatBE=function(e,r,n){return Sc(this,e,r,!1,n)};function Nc(t,e,r,n,i){return e=+e,r=r>>>0,i||Tc(t,e,r,8,17976931348623157e292,-17976931348623157e292),Yr.write(t,e,r,n,52,8),r+8}P.prototype.writeDoubleLE=function(e,r,n){return Nc(this,e,r,!0,n)};P.prototype.writeDoubleBE=function(e,r,n){return Nc(this,e,r,!1,n)};P.prototype.copy=function(e,r,n,i){if(!P.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r<i-n&&(i=e.length-r+n);let s=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),r),s};P.prototype.fill=function(e,r,n,i){if(typeof e=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!P.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let o=e.charCodeAt(0);(i==="utf8"&&o<128||i==="latin1")&&(e=o)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let s;if(typeof e=="number")for(s=r;s<n;++s)this[s]=e;else{let o=P.isBuffer(e)?e:P.from(e,i),a=o.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(s=0;s<n-r;++s)this[s+r]=o[s%a]}return this};var jr={};function Ws(t,e,r){jr[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}Ws("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Ws("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);Ws("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=bc(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=bc(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function bc(t){let e="",r=t.length,n=t[0]==="-"?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function gd(t,e,r){zr(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&mn(e,t.length-(r+1))}function Rc(t,e,r,n,i,s){if(t>r||t<e){let o=typeof e=="bigint"?"n":"",a;throw s>3?e===0||e===BigInt(0)?a=`>= 0${o} and < 2${o} ** ${(s+1)*8}${o}`:a=`>= -(2${o} ** ${(s+1)*8-1}${o}) and < 2 ** ${(s+1)*8-1}${o}`:a=`>= ${e}${o} and <= ${r}${o}`,new jr.ERR_OUT_OF_RANGE("value",a,t)}gd(n,i,s)}function zr(t,e){if(typeof t!="number")throw new jr.ERR_INVALID_ARG_TYPE(e,"number",t)}function mn(t,e,r){throw Math.floor(t)!==t?(zr(t,r),new jr.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new jr.ERR_BUFFER_OUT_OF_BOUNDS:new jr.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var bd=/[^+/0-9A-Za-z-_]/g;function wd(t){if(t=t.split("=")[0],t=t.trim().replace(bd,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function zs(t,e){e=e||1/0;let r,n=t.length,i=null,s=[];for(let o=0;o<n;++o){if(r=t.charCodeAt(o),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return s}function xd(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function _d(t,e){let r,n,i,s=[];for(let o=0;o<t.length&&!((e-=2)<0);++o)r=t.charCodeAt(o),n=r>>8,i=r%256,s.push(i),s.push(n);return s}function Ic(t){return Hs.toByteArray(wd(t))}function di(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function kt(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function Xs(t){return t!==t}var Ed=function(){let t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function ir(t){return typeof BigInt>"u"?Bd:t}function Bd(){throw new Error("BigInt not supported")}});var tt,Zr=we(()=>{tt=class t extends Error{constructor(e){super(e),this.message=e,Object.setPrototypeOf(this,t.prototype)}}});function Be(...t){let e=new Uint8Array(t.reduce((n,i)=>n+i.byteLength,0)),r=0;for(let n of t)e.set(new Uint8Array(n),r),r+=n.byteLength;return e}function Js(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}function Qs(t){return t instanceof Uint8Array?Js(t):t instanceof ArrayBuffer?t:Array.isArray(t)?Js(new Uint8Array(t)):"buffer"in t?Qs(t.buffer):Js(new Uint8Array(t))}var vt,pi=we(()=>{vt=class{constructor(e,r=e?.byteLength||0){this._buffer=Qs(e||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return Qs(this._view.slice())}get byteLength(){return this._view.byteLength}read(e){let r=this._view.subarray(0,e);return this._view=this._view.subarray(e),r.slice().buffer}readUint8(){let e=this._view[0];return this._view=this._view.subarray(1),e}write(e){let r=new Uint8Array(e),n=this._view.byteLength;this._view.byteOffset+this._view.byteLength+r.byteLength>=this._buffer.byteLength?this.alloc(r.byteLength):this._view=new Uint8Array(this._buffer,this._view.byteOffset,this._view.byteLength+r.byteLength),this._view.set(r,n)}get end(){return this._view.byteLength===0}alloc(e){let r=new ArrayBuffer((this._buffer.byteLength+e)*1.2|0),n=new Uint8Array(r,0,this._view.byteLength+e);n.set(this._view),this._buffer=r,this._view=n}}});function vd(t){let r=new TextEncoder().encode(t),n=0;for(let i of r)n=(n*223+i)%2**32;return n}function At(t){if(/^_\d+_$/.test(t)||/^_0x[0-9a-fA-F]+_$/.test(t)){let e=+t.slice(1,-1);if(Number.isSafeInteger(e)&&e>=0&&e<2**32)return e}return vd(t)}var Ls=we(()=>{});function Uc(){throw new Error("unexpected end of buffer")}function or(t,e){return t.byteLength<e&&Uc(),t.read(e)}function sr(t){let e=t.readUint8();return e===void 0&&Uc(),e}function Ie(t){if(typeof t=="number"&&(t=BigInt(t)),t<BigInt(0))throw new Error("Cannot leb encode negative values.");let e=(t===BigInt(0)?0:Math.ceil(Math.log2(Number(t))))+1,r=new vt(new ArrayBuffer(e),0);for(;;){let n=Number(t&BigInt(127));if(t/=BigInt(128),t===BigInt(0)){r.write(new Uint8Array([n]));break}else r.write(new Uint8Array([n|128]))}return r.buffer}function Ge(t){let e=BigInt(1),r=BigInt(0),n;do n=sr(t),r+=BigInt(n&127).valueOf()*e,e*=BigInt(128);while(n>=128);return r}function He(t){typeof t=="number"&&(t=BigInt(t));let e=t<BigInt(0);e&&(t=-t-BigInt(1));let r=(t===BigInt(0)?0:Math.ceil(Math.log2(Number(t))))+1,n=new vt(new ArrayBuffer(r),0);for(;;){let s=i(t);if(t/=BigInt(128),e&&t===BigInt(0)&&s&64||!e&&t===BigInt(0)&&!(s&64)){n.write(new Uint8Array([s]));break}else n.write(new Uint8Array([s|128]))}function i(s){let o=s%BigInt(128);return Number(e?BigInt(128)-o-BigInt(1):o)}return n.buffer}function Wt(t){let e=new Uint8Array(t.buffer),r=0;for(;r<e.byteLength;r++)if(e[r]<128){if(!(e[r]&64))return Ge(t);break}let n=new Uint8Array(or(t,r+1)),i=BigInt(0);for(let s=n.byteLength-1;s>=0;s--)i=i*BigInt(128)+BigInt(128-(n[s]&127)-1);return-i-BigInt(1)}function Fc(t,e){if(BigInt(t)<BigInt(0))throw new Error("Cannot write negative values.");return Ds(t,e)}function Ds(t,e){t=BigInt(t);let r=new vt(new ArrayBuffer(Math.min(1,e)),0),n=0,i=BigInt(256),s=BigInt(0),o=Number(t%i);for(r.write(new Uint8Array([o]));++n<e;)t<0&&s===BigInt(0)&&o!==0&&(s=BigInt(1)),o=Number((t/i-s)%BigInt(256)),r.write(new Uint8Array([o])),i*=BigInt(256);return r.buffer}function eo(t,e){let r=BigInt(sr(t)),n=BigInt(1),i=0;for(;++i<e;){n*=BigInt(256);let s=BigInt(sr(t));r=r+n*s}return r}function Pc(t,e){let r=eo(t,e),n=BigInt(2)**(BigInt(8)*BigInt(e-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}var to=we(()=>{pi()});function mi(t){let e=BigInt(t);if(t<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<e}var kc=we(()=>{});var cr={};fn(cr,{Bool:()=>Vc,BoolClass:()=>xi,ConstructType:()=>Ct,Empty:()=>Cc,EmptyClass:()=>bi,FixedIntClass:()=>Xt,FixedNatClass:()=>Mt,Float32:()=>Yc,Float64:()=>zc,FloatClass:()=>gn,Func:()=>au,FuncClass:()=>wn,Int:()=>Hc,Int16:()=>Zc,Int32:()=>Wc,Int64:()=>Xc,Int8:()=>Kc,IntClass:()=>Bi,Nat:()=>jc,Nat16:()=>Qc,Nat32:()=>Lc,Nat64:()=>Dc,Nat8:()=>Jc,NatClass:()=>vi,Null:()=>$c,NullClass:()=>_i,Opt:()=>nu,OptClass:()=>Jr,PrimitiveType:()=>ft,Principal:()=>eu,PrincipalClass:()=>Ni,Rec:()=>ou,RecClass:()=>ar,Record:()=>iu,RecordClass:()=>bn,Reserved:()=>qc,ReservedClass:()=>Xr,Service:()=>cu,ServiceClass:()=>Ri,Text:()=>Gc,TextClass:()=>Ei,Tuple:()=>tu,TupleClass:()=>Ti,Type:()=>Wr,Unknown:()=>Sd,UnknownClass:()=>wi,Variant:()=>su,VariantClass:()=>Si,Vec:()=>ru,VecClass:()=>Ai,Visitor:()=>gi,decode:()=>Td,encode:()=>Ad});function yn(t,e,r){return t.map((n,i)=>r(n,e[i]))}function no(t){if(sr(t)!==1)throw new Error("Cannot decode principal");let r=Number(Ge(t));return ae.fromUint8Array(new Uint8Array(or(t,r)))}function Ce(t){let e=JSON.stringify(t,(r,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return e&&e.length>Mc?e.substring(0,Mc-3)+"...":e}function Ad(t,e){if(e.length<t.length)throw Error("Wrong number of message arguments");let r=new ro;t.forEach(c=>c.buildTypeTable(r));let n=new TextEncoder().encode(yi),i=r.encode(),s=Ie(e.length),o=Be(...t.map(c=>c.encodeType(r))),a=Be(...yn(t,e,(c,f)=>{try{c.covariant(f)}catch(l){throw new Error(l.message+`
2
-
3
- `)}return c.encodeValue(f)}));return Be(n,i,s,o,a)}function Td(t,e){let r=new vt(e);if(e.byteLength<yi.length)throw new Error("Message length smaller than magic number");let n=or(r,yi.length),i=new TextDecoder().decode(n);if(i!==yi)throw new Error("Wrong magic number: "+JSON.stringify(i));function s(w){let _=[],E=Number(Ge(w));for(let V=0;V<E;V++){let k=Number(Wt(w));switch(k){case-18:case-19:{let K=Number(Wt(w));_.push([k,K]);break}case-20:case-21:{let K=[],F=Number(Ge(w)),M;for(;F--;){let z=Number(Ge(w));if(z>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof M=="number"&&M>=z)throw new Error("field id collision or not sorted");M=z;let Y=Number(Wt(w));K.push([z,Y])}_.push([k,K]);break}case-22:{let K=[],F=Number(Ge(w));for(;F--;)K.push(Number(Wt(w)));let M=[],z=Number(Ge(w));for(;z--;)M.push(Number(Wt(w)));let Y=[],G=Number(Ge(w));for(;G--;)switch(Number(Ge(w))){case 1:{Y.push("query");break}case 2:{Y.push("oneway");break}case 3:{Y.push("composite_query");break}default:throw new Error("unknown annotation")}_.push([k,[K,M,Y]]);break}case-23:{let K=Number(Ge(w)),F=[];for(;K--;){let M=Number(Ge(w)),z=new TextDecoder().decode(or(w,M)),Y=Wt(w);F.push([z,Y])}_.push([k,F]);break}default:throw new Error("Illegal op_code: "+k)}}let U=[],O=Number(Ge(w));for(let V=0;V<O;V++)U.push(Number(Wt(w)));return[_,U]}let[o,a]=s(r);if(a.length<t.length)throw new Error("Wrong number of return values");let c=o.map(w=>ou());function f(w){if(w<-24)throw new Error("future value not supported");if(w<0)switch(w){case-1:return $c;case-2:return Vc;case-3:return jc;case-4:return Hc;case-5:return Jc;case-6:return Qc;case-7:return Lc;case-8:return Dc;case-9:return Kc;case-10:return Zc;case-11:return Wc;case-12:return Xc;case-13:return Yc;case-14:return zc;case-15:return Gc;case-16:return qc;case-17:return Cc;case-24:return eu;default:throw new Error("Illegal op_code: "+w)}if(w>=o.length)throw new Error("type index out of range");return c[w]}function l(w){switch(w[0]){case-19:{let _=f(w[1]);return ru(_)}case-18:{let _=f(w[1]);return nu(_)}case-20:{let _={};for(let[O,V]of w[1]){let k=`_${O}_`;_[k]=f(V)}let E=iu(_),U=E.tryAsTuple();return Array.isArray(U)?tu(...U):E}case-21:{let _={};for(let[E,U]of w[1]){let O=`_${E}_`;_[O]=f(U)}return su(_)}case-22:{let[_,E,U]=w[1];return au(_.map(O=>f(O)),E.map(O=>f(O)),U)}case-23:{let _={},E=w[1];for(let[U,O]of E){let V=f(O);if(V instanceof ar&&(V=V.getType()),!(V instanceof wn))throw new Error("Illegal service definition: services can only contain functions");_[U]=V}return cu(_)}default:throw new Error("Illegal op_code: "+w[0])}}o.forEach((w,_)=>{if(w[0]===-22){let E=l(w);c[_].fill(E)}}),o.forEach((w,_)=>{if(w[0]!==-22){let E=l(w);c[_].fill(E)}});let d=a.map(w=>f(w)),v=t.map((w,_)=>w.decodeValue(r,d[_]));for(let w=t.length;w<d.length;w++)d[w].decodeValue(r,d[w]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return v}function tu(...t){return new Ti(t)}function ru(t){return new Ai(t)}function nu(t){return new Jr(t)}function iu(t){return new bn(t)}function su(t){return new Si(t)}function ou(){return new ar}function au(t,e,r=[]){return new wn(t,e,r)}function cu(t){return new Ri(t)}var yi,Mc,ro,gi,Wr,ft,Ct,bi,wi,xi,_i,Xr,Ei,Bi,vi,gn,Xt,Mt,Ai,Jr,bn,Ti,Si,ar,Ni,wn,Ri,Cc,qc,Sd,Vc,$c,Gc,Hc,jc,Yc,zc,Kc,Zc,Wc,Xc,Jc,Qc,Lc,Dc,eu,io=we(()=>{yt();pi();Ls();to();kc();yi="DIDL",Mc=400;ro=class{constructor(){this._typs=[],this._idx=new Map}has(e){return this._idx.has(e.name)}add(e,r){let n=this._typs.length;this._idx.set(e.name,n),this._typs.push(r)}merge(e,r){let n=this._idx.get(e.name),i=this._idx.get(r);if(n===void 0)throw new Error("Missing type index for "+e);if(i===void 0)throw new Error("Missing type index for "+r);this._typs[n]=this._typs[i],this._typs.splice(i,1),this._idx.delete(r)}encode(){let e=Ie(this._typs.length),r=Be(...this._typs);return Be(e,r)}indexOf(e){if(!this._idx.has(e))throw new Error("Missing type index for "+e);return He(this._idx.get(e)||0)}},gi=class{visitType(e,r){throw new Error("Not implemented")}visitPrimitive(e,r){return this.visitType(e,r)}visitEmpty(e,r){return this.visitPrimitive(e,r)}visitBool(e,r){return this.visitPrimitive(e,r)}visitNull(e,r){return this.visitPrimitive(e,r)}visitReserved(e,r){return this.visitPrimitive(e,r)}visitText(e,r){return this.visitPrimitive(e,r)}visitNumber(e,r){return this.visitPrimitive(e,r)}visitInt(e,r){return this.visitNumber(e,r)}visitNat(e,r){return this.visitNumber(e,r)}visitFloat(e,r){return this.visitPrimitive(e,r)}visitFixedInt(e,r){return this.visitNumber(e,r)}visitFixedNat(e,r){return this.visitNumber(e,r)}visitPrincipal(e,r){return this.visitPrimitive(e,r)}visitConstruct(e,r){return this.visitType(e,r)}visitVec(e,r,n){return this.visitConstruct(e,n)}visitOpt(e,r,n){return this.visitConstruct(e,n)}visitRecord(e,r,n){return this.visitConstruct(e,n)}visitTuple(e,r,n){let i=r.map((s,o)=>[`_${o}_`,s]);return this.visitRecord(e,i,n)}visitVariant(e,r,n){return this.visitConstruct(e,n)}visitRec(e,r,n){return this.visitConstruct(r,n)}visitFunc(e,r){return this.visitConstruct(e,r)}visitService(e,r){return this.visitConstruct(e,r)}},Wr=class{display(){return this.name}valueToString(e){return Ce(e)}buildTypeTable(e){e.has(this)||this._buildTypeTableImpl(e)}},ft=class extends Wr{checkType(e){if(this.name!==e.name)throw new Error(`type mismatch: type on the wire ${e.name}, expect type ${this.name}`);return e}_buildTypeTableImpl(e){}},Ct=class extends Wr{checkType(e){if(e instanceof ar){let r=e.getType();if(typeof r>"u")throw new Error("type mismatch with uninitialized type");return r}throw new Error(`type mismatch: type on the wire ${e.name}, expect type ${this.name}`)}encodeType(e){return e.indexOf(this.name)}},bi=class extends ft{accept(e,r){return e.visitEmpty(this,r)}covariant(e){throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return He(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}},wi=class extends Wr{checkType(e){throw new Error("Method not implemented for unknown.")}accept(e,r){throw e.visitType(this,r)}covariant(e){throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(){throw new Error("Unknown cannot appear as a function argument")}valueToString(){throw new Error("Unknown cannot appear as a value")}encodeType(){throw new Error("Unknown cannot be serialized")}decodeValue(e,r){let n=r.decodeValue(e,r);Object(n)!==n&&(n=Object(n));let i;return r instanceof ar?i=()=>r.getType():i=()=>r,Object.defineProperty(n,"type",{value:i,writable:!0,enumerable:!1,configurable:!0}),n}_buildTypeTableImpl(){throw new Error("Unknown cannot be serialized")}get name(){return"Unknown"}},xi=class extends ft{accept(e,r){return e.visitBool(this,r)}covariant(e){if(typeof e=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){return new Uint8Array([e?1:0])}encodeType(){return He(-2)}decodeValue(e,r){switch(this.checkType(r),sr(e)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}},_i=class extends ft{accept(e,r){return e.visitNull(this,r)}covariant(e){if(e===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return He(-1)}decodeValue(e,r){return this.checkType(r),null}get name(){return"null"}},Xr=class extends ft{accept(e,r){return e.visitReserved(this,r)}covariant(e){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return He(-16)}decodeValue(e,r){return r.name!==this.name&&r.decodeValue(e,r),null}get name(){return"reserved"}},Ei=class extends ft{accept(e,r){return e.visitText(this,r)}covariant(e){if(typeof e=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){let r=new TextEncoder().encode(e),n=Ie(r.byteLength);return Be(n,r)}encodeType(){return He(-15)}decodeValue(e,r){this.checkType(r);let n=Ge(e),i=or(e,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(i)}get name(){return"text"}valueToString(e){return'"'+e+'"'}},Bi=class extends ft{accept(e,r){return e.visitInt(this,r)}covariant(e){if(typeof e=="bigint"||Number.isInteger(e))return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){return He(e)}encodeType(){return He(-4)}decodeValue(e,r){return this.checkType(r),Wt(e)}get name(){return"int"}valueToString(e){return e.toString()}},vi=class extends ft{accept(e,r){return e.visitNat(this,r)}covariant(e){if(typeof e=="bigint"&&e>=BigInt(0)||Number.isInteger(e)&&e>=0)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){return Ie(e)}encodeType(){return He(-3)}decodeValue(e,r){return this.checkType(r),Ge(e)}get name(){return"nat"}valueToString(e){return e.toString()}},gn=class extends ft{constructor(e){if(super(),this._bits=e,e!==32&&e!==64)throw new Error("not a valid float type")}accept(e,r){return e.visitFloat(this,r)}covariant(e){if(typeof e=="number"||e instanceof Number)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){let r=new ArrayBuffer(this._bits/8),n=new DataView(r);return this._bits===32?n.setFloat32(0,e,!0):n.setFloat64(0,e,!0),r}encodeType(){let e=this._bits===32?-13:-14;return He(e)}decodeValue(e,r){this.checkType(r);let n=or(e,this._bits/8),i=new DataView(n);return this._bits===32?i.getFloat32(0,!0):i.getFloat64(0,!0)}get name(){return"float"+this._bits}valueToString(e){return e.toString()}},Xt=class extends ft{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedInt(this,r)}covariant(e){let r=mi(this._bits-1)*BigInt(-1),n=mi(this._bits-1)-BigInt(1),i=!1;if(typeof e=="bigint")i=e>=r&&e<=n;else if(Number.isInteger(e)){let s=BigInt(e);i=s>=r&&s<=n}else i=!1;if(i)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){return Ds(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return He(-9-e)}decodeValue(e,r){this.checkType(r);let n=Pc(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(e){return e.toString()}},Mt=class extends ft{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedNat(this,r)}covariant(e){let r=mi(this._bits),n=!1;if(typeof e=="bigint"&&e>=BigInt(0)?n=e<r:Number.isInteger(e)&&e>=0?n=BigInt(e)<r:n=!1,n)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){return Fc(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return He(-5-e)}decodeValue(e,r){this.checkType(r);let n=eo(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(e){return e.toString()}},Ai=class t extends Ct{constructor(e){super(),this._type=e,this._blobOptimization=!1,e instanceof Mt&&e._bits===8&&(this._blobOptimization=!0)}accept(e,r){return e.visitVec(this,this._type,r)}covariant(e){let r=this._type instanceof Mt?this._type._bits:this._type instanceof Xt?this._type._bits:0;if(ArrayBuffer.isView(e)&&r==e.BYTES_PER_ELEMENT*8||Array.isArray(e)&&e.every((n,i)=>{try{return this._type.covariant(n)}catch(s){throw new Error(`Invalid ${this.display()} argument:
4
-
5
- index ${i} -> ${s.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){let r=Ie(e.length);if(this._blobOptimization)return Be(r,new Uint8Array(e));if(ArrayBuffer.isView(e))return Be(r,new Uint8Array(e.buffer));let n=new vt(new ArrayBuffer(r.byteLength+e.length),0);n.write(r);for(let i of e){let s=this._type.encodeValue(i);n.write(new Uint8Array(s))}return n.buffer}_buildTypeTableImpl(e){this._type.buildTypeTable(e);let r=He(-19),n=this._type.encodeType(e);e.add(this,Be(r,n))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not a vector type");let i=Number(Ge(e));if(this._type instanceof Mt){if(this._type._bits==8)return new Uint8Array(e.read(i));if(this._type._bits==16)return new Uint16Array(e.read(i*2));if(this._type._bits==32)return new Uint32Array(e.read(i*4));if(this._type._bits==64)return new BigUint64Array(e.read(i*8))}if(this._type instanceof Xt){if(this._type._bits==8)return new Int8Array(e.read(i));if(this._type._bits==16)return new Int16Array(e.read(i*2));if(this._type._bits==32)return new Int32Array(e.read(i*4));if(this._type._bits==64)return new BigInt64Array(e.read(i*8))}let s=[];for(let o=0;o<i;o++)s.push(this._type.decodeValue(e,n._type));return s}get name(){return`vec ${this._type.name}`}display(){return`vec ${this._type.display()}`}valueToString(e){return"vec {"+e.map(n=>this._type.valueToString(n)).join("; ")+"}"}},Jr=class t extends Ct{constructor(e){super(),this._type=e}accept(e,r){return e.visitOpt(this,this._type,r)}covariant(e){try{if(Array.isArray(e)&&(e.length===0||e.length===1&&this._type.covariant(e[0])))return!0}catch(r){throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}
6
-
7
- -> ${r.message}`)}throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){return e.length===0?new Uint8Array([0]):Be(new Uint8Array([1]),this._type.encodeValue(e[0]))}_buildTypeTableImpl(e){this._type.buildTypeTable(e);let r=He(-18),n=this._type.encodeType(e);e.add(this,Be(r,n))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not an option type");switch(sr(e)){case 0:return[];case 1:return[this._type.decodeValue(e,n._type)];default:throw new Error("Not an option value")}}get name(){return`opt ${this._type.name}`}display(){return`opt ${this._type.display()}`}valueToString(e){return e.length===0?"null":`opt ${this._type.valueToString(e[0])}`}},bn=class t extends Ct{constructor(e={}){super(),this._fields=Object.entries(e).sort((r,n)=>At(r[0])-At(n[0]))}accept(e,r){return e.visitRecord(this,this._fields,r)}tryAsTuple(){let e=[];for(let r=0;r<this._fields.length;r++){let[n,i]=this._fields[r];if(n!==`_${r}_`)return null;e.push(i)}return e}covariant(e){if(typeof e=="object"&&this._fields.every(([r,n])=>{if(!e.hasOwnProperty(r))throw new Error(`Record is missing key "${r}".`);try{return n.covariant(e[r])}catch(i){throw new Error(`Invalid ${this.display()} argument:
8
-
9
- field ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){let r=this._fields.map(([i])=>e[i]),n=yn(this._fields,r,([,i],s)=>i.encodeValue(s));return Be(...n)}_buildTypeTableImpl(e){this._fields.forEach(([s,o])=>o.buildTypeTable(e));let r=He(-20),n=Ie(this._fields.length),i=this._fields.map(([s,o])=>Be(Ie(At(s)),o.encodeType(e)));e.add(this,Be(r,n,Be(...i)))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not a record type");let i={},s=0,o=0;for(;o<n._fields.length;){let[a,c]=n._fields[o];if(s>=this._fields.length){c.decodeValue(e,c),o++;continue}let[f,l]=this._fields[s],d=At(this._fields[s][0]),v=At(a);if(d===v)i[f]=l.decodeValue(e,c),s++,o++;else if(v>d)if(l instanceof Jr||l instanceof Xr)i[f]=[],s++;else throw new Error("Cannot find required field "+f);else c.decodeValue(e,c),o++}for(let[a,c]of this._fields.slice(s))if(c instanceof Jr||c instanceof Xr)i[a]=[];else throw new Error("Cannot find required field "+a);return i}get name(){return`record {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`record {${this._fields.map(([r,n])=>r+":"+n.display()).join("; ")}}`}valueToString(e){let r=this._fields.map(([i])=>e[i]);return`record {${yn(this._fields,r,([i,s],o)=>i+"="+s.valueToString(o)).join("; ")}}`}},Ti=class t extends bn{constructor(e){let r={};e.forEach((n,i)=>r["_"+i+"_"]=n),super(r),this._components=e}accept(e,r){return e.visitTuple(this,this._components,r)}covariant(e){if(Array.isArray(e)&&e.length>=this._fields.length&&this._components.every((r,n)=>{try{return r.covariant(e[n])}catch(i){throw new Error(`Invalid ${this.display()} argument:
10
-
11
- index ${n} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){let r=yn(this._components,e,(n,i)=>n.encodeValue(i));return Be(...r)}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("not a tuple type");if(n._components.length<this._components.length)throw new Error("tuple mismatch");let i=[];for(let[s,o]of n._components.entries())s>=this._components.length?o.decodeValue(e,o):i.push(this._components[s].decodeValue(e,o));return i}display(){return`record {${this._components.map(r=>r.display()).join("; ")}}`}valueToString(e){return`record {${yn(this._components,e,(n,i)=>n.valueToString(i)).join("; ")}}`}},Si=class t extends Ct{constructor(e={}){super(),this._fields=Object.entries(e).sort((r,n)=>At(r[0])-At(n[0]))}accept(e,r){return e.visitVariant(this,this._fields,r)}covariant(e){if(typeof e=="object"&&Object.entries(e).length===1&&this._fields.every(([r,n])=>{try{return!e.hasOwnProperty(r)||n.covariant(e[r])}catch(i){throw new Error(`Invalid ${this.display()} argument:
12
-
13
- variant ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){for(let r=0;r<this._fields.length;r++){let[n,i]=this._fields[r];if(e.hasOwnProperty(n)){let s=Ie(r),o=i.encodeValue(e[n]);return Be(s,o)}}throw Error("Variant has no data: "+e)}_buildTypeTableImpl(e){this._fields.forEach(([,s])=>{s.buildTypeTable(e)});let r=He(-21),n=Ie(this._fields.length),i=this._fields.map(([s,o])=>Be(Ie(At(s)),o.encodeType(e)));e.add(this,Be(r,n,...i))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not a variant type");let i=Number(Ge(e));if(i>=n._fields.length)throw Error("Invalid variant index: "+i);let[s,o]=n._fields[i];for(let[a,c]of this._fields)if(At(s)===At(a)){let f=c.decodeValue(e,o);return{[a]:f}}throw new Error("Cannot find field hash "+s)}get name(){return`variant {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`variant {${this._fields.map(([r,n])=>r+(n.name==="null"?"":`:${n.display()}`)).join("; ")}}`}valueToString(e){for(let[r,n]of this._fields)if(e.hasOwnProperty(r)){let i=n.valueToString(e[r]);return i==="null"?`variant {${r}}`:`variant {${r}=${i}}`}throw new Error("Variant has no data: "+e)}},ar=class t extends Ct{constructor(){super(...arguments),this._id=t._counter++,this._type=void 0}accept(e,r){if(!this._type)throw Error("Recursive type uninitialized.");return e.visitRec(this,this._type,r)}fill(e){this._type=e}getType(){return this._type}covariant(e){if(this._type&&this._type.covariant(e))return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.encodeValue(e)}_buildTypeTableImpl(e){if(!this._type)throw Error("Recursive type uninitialized.");e.add(this,new Uint8Array([])),this._type.buildTypeTable(e),e.merge(this,this._type.name)}decodeValue(e,r){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.decodeValue(e,r)}get name(){return`rec_${this._id}`}display(){if(!this._type)throw Error("Recursive type uninitialized.");return`\u03BC${this.name}.${this._type.name}`}valueToString(e){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.valueToString(e)}};ar._counter=0;Ni=class extends ft{accept(e,r){return e.visitPrincipal(this,r)}covariant(e){if(e&&e._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){let r=e.toUint8Array(),n=Ie(r.byteLength);return Be(new Uint8Array([1]),n,r)}encodeType(){return He(-24)}decodeValue(e,r){return this.checkType(r),no(e)}get name(){return"principal"}valueToString(e){return`${this.name} "${e.toText()}"`}},wn=class extends Ct{constructor(e,r,n=[]){super(),this.argTypes=e,this.retTypes=r,this.annotations=n}static argsToString(e,r){if(e.length!==r.length)throw new Error("arity mismatch");return"("+e.map((n,i)=>n.valueToString(r[i])).join(", ")+")"}accept(e,r){return e.visitFunc(this,r)}covariant(e){if(Array.isArray(e)&&e.length===2&&e[0]&&e[0]._isPrincipal&&typeof e[1]=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue([e,r]){let n=e.toUint8Array(),i=Ie(n.byteLength),s=Be(new Uint8Array([1]),i,n),o=new TextEncoder().encode(r),a=Ie(o.byteLength);return Be(new Uint8Array([1]),s,a,o)}_buildTypeTableImpl(e){this.argTypes.forEach(f=>f.buildTypeTable(e)),this.retTypes.forEach(f=>f.buildTypeTable(e));let r=He(-22),n=Ie(this.argTypes.length),i=Be(...this.argTypes.map(f=>f.encodeType(e))),s=Ie(this.retTypes.length),o=Be(...this.retTypes.map(f=>f.encodeType(e))),a=Ie(this.annotations.length),c=Be(...this.annotations.map(f=>this.encodeAnnotation(f)));e.add(this,Be(r,n,i,s,o,a,c))}decodeValue(e){if(sr(e)!==1)throw new Error("Cannot decode function reference");let n=no(e),i=Number(Ge(e)),s=or(e,i),a=new TextDecoder("utf8",{fatal:!0}).decode(s);return[n,a]}get name(){let e=this.argTypes.map(i=>i.name).join(", "),r=this.retTypes.map(i=>i.name).join(", "),n=" "+this.annotations.join(" ");return`(${e}) -> (${r})${n}`}valueToString([e,r]){return`func "${e.toText()}".${r}`}display(){let e=this.argTypes.map(i=>i.display()).join(", "),r=this.retTypes.map(i=>i.display()).join(", "),n=" "+this.annotations.join(" ");return`(${e}) \u2192 (${r})${n}`}encodeAnnotation(e){if(e==="query")return new Uint8Array([1]);if(e==="oneway")return new Uint8Array([2]);if(e==="composite_query")return new Uint8Array([3]);throw new Error("Illegal function annotation")}},Ri=class extends Ct{constructor(e){super(),this._fields=Object.entries(e).sort((r,n)=>r[0]<n[0]?-1:r[0]>n[0]?1:0)}accept(e,r){return e.visitService(this,r)}covariant(e){if(e&&e._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){let r=e.toUint8Array(),n=Ie(r.length);return Be(new Uint8Array([1]),n,r)}_buildTypeTableImpl(e){this._fields.forEach(([s,o])=>o.buildTypeTable(e));let r=He(-23),n=Ie(this._fields.length),i=this._fields.map(([s,o])=>{let a=new TextEncoder().encode(s),c=Ie(a.length);return Be(c,a,o.encodeType(e))});e.add(this,Be(r,n,...i))}decodeValue(e){return no(e)}get name(){return`service {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}valueToString(e){return`service "${e.toText()}"`}};Cc=new bi,qc=new Xr,Sd=new wi,Vc=new xi,$c=new _i,Gc=new Ei,Hc=new Bi,jc=new vi,Yc=new gn(32),zc=new gn(64),Kc=new Xt(8),Zc=new Xt(16),Wc=new Xt(32),Xc=new Xt(64),Jc=new Mt(8),Qc=new Mt(16),Lc=new Mt(32),Dc=new Mt(64),eu=new Ni});var so=we(()=>{});var uu=we(()=>{io();yt();so()});var fu=we(()=>{});var xn=we(()=>{uu();so();io();Ls();to();pi();fu()});var Iu={};fn(Iu,{Buffer:()=>H,INSPECT_MAX_BYTES:()=>gu,SlowBuffer:()=>Vd,isBuffer:()=>Nu,kMaxLength:()=>Pd});function pu(){ao=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0,r=t.length;e<r;++e)qt[e]=t[e],bt[t.charCodeAt(e)]=e;bt[45]=62,bt[95]=63}function Id(t){ao||pu();var e,r,n,i,s,o,a=t.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");s=t[a-2]==="="?2:t[a-1]==="="?1:0,o=new Rd(a*3/4-s),n=s>0?a-4:a;var c=0;for(e=0,r=0;e<n;e+=4,r+=3)i=bt[t.charCodeAt(e)]<<18|bt[t.charCodeAt(e+1)]<<12|bt[t.charCodeAt(e+2)]<<6|bt[t.charCodeAt(e+3)],o[c++]=i>>16&255,o[c++]=i>>8&255,o[c++]=i&255;return s===2?(i=bt[t.charCodeAt(e)]<<2|bt[t.charCodeAt(e+1)]>>4,o[c++]=i&255):s===1&&(i=bt[t.charCodeAt(e)]<<10|bt[t.charCodeAt(e+1)]<<4|bt[t.charCodeAt(e+2)]>>2,o[c++]=i>>8&255,o[c++]=i&255),o}function Od(t){return qt[t>>18&63]+qt[t>>12&63]+qt[t>>6&63]+qt[t&63]}function Ud(t,e,r){for(var n,i=[],s=e;s<r;s+=3)n=(t[s]<<16)+(t[s+1]<<8)+t[s+2],i.push(Od(n));return i.join("")}function lu(t){ao||pu();for(var e,r=t.length,n=r%3,i="",s=[],o=16383,a=0,c=r-n;a<c;a+=o)s.push(Ud(t,a,a+o>c?c:a+o));return n===1?(e=t[r-1],i+=qt[e>>2],i+=qt[e<<4&63],i+="=="):n===2&&(e=(t[r-2]<<8)+t[r-1],i+=qt[e>>10],i+=qt[e>>4&63],i+=qt[e<<2&63],i+="="),s.push(i),s.join("")}function Ui(t,e,r,n,i){var s,o,a=i*8-n-1,c=(1<<a)-1,f=c>>1,l=-7,d=r?i-1:0,v=r?-1:1,w=t[e+d];for(d+=v,s=w&(1<<-l)-1,w>>=-l,l+=a;l>0;s=s*256+t[e+d],d+=v,l-=8);for(o=s&(1<<-l)-1,s>>=-l,l+=n;l>0;o=o*256+t[e+d],d+=v,l-=8);if(s===0)s=1-f;else{if(s===c)return o?NaN:(w?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-f}return(w?-1:1)*o*Math.pow(2,s-n)}function mu(t,e,r,n,i,s){var o,a,c,f=s*8-i-1,l=(1<<f)-1,d=l>>1,v=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=n?0:s-1,_=n?1:-1,E=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=l):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+d>=1?e+=v/c:e+=v*Math.pow(2,1-d),e*c>=2&&(o++,c/=2),o+d>=l?(a=0,o=l):o+d>=1?(a=(e*c-1)*Math.pow(2,i),o=o+d):(a=e*Math.pow(2,d-1)*Math.pow(2,i),o=0));i>=8;t[r+w]=a&255,w+=_,a/=256,i-=8);for(o=o<<i|a,f+=i;f>0;t[r+w]=o&255,w+=_,o/=256,f-=8);t[r+w-_]|=E*128}function Ii(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Jt(t,e){if(Ii()<e)throw new RangeError("Invalid typed array length");return H.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e),t.__proto__=H.prototype):(t===null&&(t=new H(e)),t.length=e),t}function H(t,e,r){if(!H.TYPED_ARRAY_SUPPORT&&!(this instanceof H))return new H(t,e,r);if(typeof t=="number"){if(typeof e=="string")throw new Error("If encoding is specified then the first argument must be a string");return co(this,t)}return bu(this,t,e,r)}function bu(t,e,r,n){if(typeof e=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer?Cd(t,e,r,n):typeof e=="string"?Md(t,e,r):qd(t,e)}function wu(t){if(typeof t!="number")throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function kd(t,e,r,n){return wu(e),e<=0?Jt(t,e):r!==void 0?typeof n=="string"?Jt(t,e).fill(r,n):Jt(t,e).fill(r):Jt(t,e)}function co(t,e){if(wu(e),t=Jt(t,e<0?0:uo(e)|0),!H.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function Md(t,e,r){if((typeof r!="string"||r==="")&&(r="utf8"),!H.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=xu(e,r)|0;t=Jt(t,n);var i=t.write(e,r);return i!==n&&(t=t.slice(0,i)),t}function oo(t,e){var r=e.length<0?0:uo(e.length)|0;t=Jt(t,r);for(var n=0;n<r;n+=1)t[n]=e[n]&255;return t}function Cd(t,e,r,n){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");return r===void 0&&n===void 0?e=new Uint8Array(e):n===void 0?e=new Uint8Array(e,r):e=new Uint8Array(e,r,n),H.TYPED_ARRAY_SUPPORT?(t=e,t.__proto__=H.prototype):t=oo(t,e),t}function qd(t,e){if(Vt(e)){var r=uo(e.length)|0;return t=Jt(t,r),t.length===0||e.copy(t,0,0,r),t}if(e){if(typeof ArrayBuffer<"u"&&e.buffer instanceof ArrayBuffer||"length"in e)return typeof e.length!="number"||ih(e.length)?Jt(t,0):oo(t,e);if(e.type==="Buffer"&&yu(e.data))return oo(t,e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function uo(t){if(t>=Ii())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Ii().toString(16)+" bytes");return t|0}function Vd(t){return+t!=t&&(t=0),H.alloc(+t)}function Vt(t){return!!(t!=null&&t._isBuffer)}function xu(t,e){if(Vt(t))return t.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;typeof t!="string"&&(t=""+t);var r=t.length;if(r===0)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Oi(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Su(t).length;default:if(n)return Oi(t).length;e=(""+e).toLowerCase(),n=!0}}function $d(t,e,r){var n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return Jd(this,e,r);case"utf8":case"utf-8":return Bu(this,e,r);case"ascii":return Wd(this,e,r);case"latin1":case"binary":return Xd(this,e,r);case"base64":return Kd(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Qd(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function vr(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function _u(t,e,r,n,i){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof e=="string"&&(e=H.from(e,n)),Vt(e))return e.length===0?-1:du(t,e,r,n,i);if(typeof e=="number")return e=e&255,H.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):du(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function du(t,e,r,n,i){var s=1,o=t.length,a=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;s=2,o/=2,a/=2,r/=2}function c(w,_){return s===1?w[_]:w.readUInt16BE(_*s)}var f;if(i){var l=-1;for(f=r;f<o;f++)if(c(t,f)===c(e,l===-1?0:f-l)){if(l===-1&&(l=f),f-l+1===a)return l*s}else l!==-1&&(f-=f-l),l=-1}else for(r+a>o&&(r=o-a),f=r;f>=0;f--){for(var d=!0,v=0;v<a;v++)if(c(t,f+v)!==c(e,v)){d=!1;break}if(d)return f}return-1}function Gd(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var s=e.length;if(s%2!==0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o<n;++o){var a=parseInt(e.substr(o*2,2),16);if(isNaN(a))return o;t[r+o]=a}return o}function Hd(t,e,r,n){return ki(Oi(e,t.length-r),t,r,n)}function Eu(t,e,r,n){return ki(rh(e),t,r,n)}function jd(t,e,r,n){return Eu(t,e,r,n)}function Yd(t,e,r,n){return ki(Su(e),t,r,n)}function zd(t,e,r,n){return ki(nh(e,t.length-r),t,r,n)}function Kd(t,e,r){return e===0&&r===t.length?lu(t):lu(t.slice(e,r))}function Bu(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i<r;){var s=t[i],o=null,a=s>239?4:s>223?3:s>191?2:1;if(i+a<=r){var c,f,l,d;switch(a){case 1:s<128&&(o=s);break;case 2:c=t[i+1],(c&192)===128&&(d=(s&31)<<6|c&63,d>127&&(o=d));break;case 3:c=t[i+1],f=t[i+2],(c&192)===128&&(f&192)===128&&(d=(s&15)<<12|(c&63)<<6|f&63,d>2047&&(d<55296||d>57343)&&(o=d));break;case 4:c=t[i+1],f=t[i+2],l=t[i+3],(c&192)===128&&(f&192)===128&&(l&192)===128&&(d=(s&15)<<18|(c&63)<<12|(f&63)<<6|l&63,d>65535&&d<1114112&&(o=d))}}o===null?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=a}return Zd(n)}function Zd(t){var e=t.length;if(e<=hu)return String.fromCharCode.apply(String,t);for(var r="",n=0;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=hu));return r}function Wd(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(t[i]&127);return n}function Xd(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function Jd(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var i="",s=e;s<r;++s)i+=th(t[s]);return i}function Qd(t,e,r){for(var n=t.slice(e,r),i="",s=0;s<n.length;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}function Je(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function lt(t,e,r,n,i,s){if(!Vt(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function Fi(t,e,r,n){e<0&&(e=65535+e+1);for(var i=0,s=Math.min(t.length-r,2);i<s;++i)t[r+i]=(e&255<<8*(n?i:1-i))>>>(n?i:1-i)*8}function Pi(t,e,r,n){e<0&&(e=4294967295+e+1);for(var i=0,s=Math.min(t.length-r,4);i<s;++i)t[r+i]=e>>>(n?i:3-i)*8&255}function vu(t,e,r,n,i,s){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Au(t,e,r,n,i){return i||vu(t,e,r,4),mu(t,e,r,n,23,4),r+4}function Tu(t,e,r,n,i){return i||vu(t,e,r,8),mu(t,e,r,n,52,8),r+8}function Dd(t){if(t=eh(t).replace(Ld,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function eh(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function th(t){return t<16?"0"+t.toString(16):t.toString(16)}function Oi(t,e){e=e||1/0;for(var r,n=t.length,i=null,s=[],o=0;o<n;++o){if(r=t.charCodeAt(o),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return s}function rh(t){for(var e=[],r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function nh(t,e){for(var r,n,i,s=[],o=0;o<t.length&&!((e-=2)<0);++o)r=t.charCodeAt(o),n=r>>8,i=r%256,s.push(i),s.push(n);return s}function Su(t){return Id(Dd(t))}function ki(t,e,r,n){for(var i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function ih(t){return t!==t}function Nu(t){return t!=null&&(!!t._isBuffer||Ru(t)||sh(t))}function Ru(t){return!!t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function sh(t){return typeof t.readFloatLE=="function"&&typeof t.slice=="function"&&Ru(t.slice(0,0))}var qt,bt,Rd,ao,Fd,yu,gu,Pd,hu,Ld,Ou=we(()=>{qt=[],bt=[],Rd=typeof Uint8Array<"u"?Uint8Array:Array,ao=!1;Fd={}.toString,yu=Array.isArray||function(t){return Fd.call(t)=="[object Array]"};gu=50;H.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;Pd=Ii();H.poolSize=8192;H._augment=function(t){return t.__proto__=H.prototype,t};H.from=function(t,e,r){return bu(null,t,e,r)};H.TYPED_ARRAY_SUPPORT&&(H.prototype.__proto__=Uint8Array.prototype,H.__proto__=Uint8Array);H.alloc=function(t,e,r){return kd(null,t,e,r)};H.allocUnsafe=function(t){return co(null,t)};H.allocUnsafeSlow=function(t){return co(null,t)};H.isBuffer=Nu;H.compare=function(e,r){if(!Vt(e)||!Vt(r))throw new TypeError("Arguments must be Buffers");if(e===r)return 0;for(var n=e.length,i=r.length,s=0,o=Math.min(n,i);s<o;++s)if(e[s]!==r[s]){n=e[s],i=r[s];break}return n<i?-1:i<n?1:0};H.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};H.concat=function(e,r){if(!yu(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return H.alloc(0);var n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;var i=H.allocUnsafe(r),s=0;for(n=0;n<e.length;++n){var o=e[n];if(!Vt(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(i,s),s+=o.length}return i};H.byteLength=xu;H.prototype._isBuffer=!0;H.prototype.swap16=function(){var e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var r=0;r<e;r+=2)vr(this,r,r+1);return this};H.prototype.swap32=function(){var e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var r=0;r<e;r+=4)vr(this,r,r+3),vr(this,r+1,r+2);return this};H.prototype.swap64=function(){var e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var r=0;r<e;r+=8)vr(this,r,r+7),vr(this,r+1,r+6),vr(this,r+2,r+5),vr(this,r+3,r+4);return this};H.prototype.toString=function(){var e=this.length|0;return e===0?"":arguments.length===0?Bu(this,0,e):$d.apply(this,arguments)};H.prototype.equals=function(e){if(!Vt(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:H.compare(this,e)===0};H.prototype.inspect=function(){var e="",r=gu;return this.length>0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),"<Buffer "+e+">"};H.prototype.compare=function(e,r,n,i,s){if(!Vt(e))throw new TypeError("Argument must be a Buffer");if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),r<0||n>e.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&r>=n)return 0;if(i>=s)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,s>>>=0,this===e)return 0;for(var o=s-i,a=n-r,c=Math.min(o,a),f=this.slice(i,s),l=e.slice(r,n),d=0;d<c;++d)if(f[d]!==l[d]){o=f[d],a=l[d];break}return o<a?-1:a<o?1:0};H.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};H.prototype.indexOf=function(e,r,n){return _u(this,e,r,n,!0)};H.prototype.lastIndexOf=function(e,r,n){return _u(this,e,r,n,!1)};H.prototype.write=function(e,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r|0,isFinite(n)?(n=n|0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var s=this.length-r;if((n===void 0||n>s)&&(n=s),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var o=!1;;)switch(i){case"hex":return Gd(this,e,r,n);case"utf8":case"utf-8":return Hd(this,e,r,n);case"ascii":return Eu(this,e,r,n);case"latin1":case"binary":return jd(this,e,r,n);case"base64":return Yd(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return zd(this,e,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};H.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};hu=4096;H.prototype.slice=function(e,r){var n=this.length;e=~~e,r=r===void 0?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);var i;if(H.TYPED_ARRAY_SUPPORT)i=this.subarray(e,r),i.__proto__=H.prototype;else{var s=r-e;i=new H(s,void 0);for(var o=0;o<s;++o)i[o]=this[o+e]}return i};H.prototype.readUIntLE=function(e,r,n){e=e|0,r=r|0,n||Je(e,r,this.length);for(var i=this[e],s=1,o=0;++o<r&&(s*=256);)i+=this[e+o]*s;return i};H.prototype.readUIntBE=function(e,r,n){e=e|0,r=r|0,n||Je(e,r,this.length);for(var i=this[e+--r],s=1;r>0&&(s*=256);)i+=this[e+--r]*s;return i};H.prototype.readUInt8=function(e,r){return r||Je(e,1,this.length),this[e]};H.prototype.readUInt16LE=function(e,r){return r||Je(e,2,this.length),this[e]|this[e+1]<<8};H.prototype.readUInt16BE=function(e,r){return r||Je(e,2,this.length),this[e]<<8|this[e+1]};H.prototype.readUInt32LE=function(e,r){return r||Je(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};H.prototype.readUInt32BE=function(e,r){return r||Je(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};H.prototype.readIntLE=function(e,r,n){e=e|0,r=r|0,n||Je(e,r,this.length);for(var i=this[e],s=1,o=0;++o<r&&(s*=256);)i+=this[e+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*r)),i};H.prototype.readIntBE=function(e,r,n){e=e|0,r=r|0,n||Je(e,r,this.length);for(var i=r,s=1,o=this[e+--i];i>0&&(s*=256);)o+=this[e+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*r)),o};H.prototype.readInt8=function(e,r){return r||Je(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};H.prototype.readInt16LE=function(e,r){r||Je(e,2,this.length);var n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};H.prototype.readInt16BE=function(e,r){r||Je(e,2,this.length);var n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};H.prototype.readInt32LE=function(e,r){return r||Je(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};H.prototype.readInt32BE=function(e,r){return r||Je(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};H.prototype.readFloatLE=function(e,r){return r||Je(e,4,this.length),Ui(this,e,!0,23,4)};H.prototype.readFloatBE=function(e,r){return r||Je(e,4,this.length),Ui(this,e,!1,23,4)};H.prototype.readDoubleLE=function(e,r){return r||Je(e,8,this.length),Ui(this,e,!0,52,8)};H.prototype.readDoubleBE=function(e,r){return r||Je(e,8,this.length),Ui(this,e,!1,52,8)};H.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r|0,n=n|0,!i){var s=Math.pow(2,8*n)-1;lt(this,e,r,n,s,0)}var o=1,a=0;for(this[r]=e&255;++a<n&&(o*=256);)this[r+a]=e/o&255;return r+n};H.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r|0,n=n|0,!i){var s=Math.pow(2,8*n)-1;lt(this,e,r,n,s,0)}var o=n-1,a=1;for(this[r+o]=e&255;--o>=0&&(a*=256);)this[r+o]=e/a&255;return r+n};H.prototype.writeUInt8=function(e,r,n){return e=+e,r=r|0,n||lt(this,e,r,1,255,0),H.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[r]=e&255,r+1};H.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r|0,n||lt(this,e,r,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[r]=e&255,this[r+1]=e>>>8):Fi(this,e,r,!0),r+2};H.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r|0,n||lt(this,e,r,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[r]=e>>>8,this[r+1]=e&255):Fi(this,e,r,!1),r+2};H.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r|0,n||lt(this,e,r,4,4294967295,0),H.TYPED_ARRAY_SUPPORT?(this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255):Pi(this,e,r,!0),r+4};H.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r|0,n||lt(this,e,r,4,4294967295,0),H.TYPED_ARRAY_SUPPORT?(this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255):Pi(this,e,r,!1),r+4};H.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r|0,!i){var s=Math.pow(2,8*n-1);lt(this,e,r,n,s-1,-s)}var o=0,a=1,c=0;for(this[r]=e&255;++o<n&&(a*=256);)e<0&&c===0&&this[r+o-1]!==0&&(c=1),this[r+o]=(e/a>>0)-c&255;return r+n};H.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r|0,!i){var s=Math.pow(2,8*n-1);lt(this,e,r,n,s-1,-s)}var o=n-1,a=1,c=0;for(this[r+o]=e&255;--o>=0&&(a*=256);)e<0&&c===0&&this[r+o+1]!==0&&(c=1),this[r+o]=(e/a>>0)-c&255;return r+n};H.prototype.writeInt8=function(e,r,n){return e=+e,r=r|0,n||lt(this,e,r,1,127,-128),H.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[r]=e&255,r+1};H.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r|0,n||lt(this,e,r,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[r]=e&255,this[r+1]=e>>>8):Fi(this,e,r,!0),r+2};H.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r|0,n||lt(this,e,r,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[r]=e>>>8,this[r+1]=e&255):Fi(this,e,r,!1),r+2};H.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r|0,n||lt(this,e,r,4,2147483647,-2147483648),H.TYPED_ARRAY_SUPPORT?(this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24):Pi(this,e,r,!0),r+4};H.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r|0,n||lt(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),H.TYPED_ARRAY_SUPPORT?(this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255):Pi(this,e,r,!1),r+4};H.prototype.writeFloatLE=function(e,r,n){return Au(this,e,r,!0,n)};H.prototype.writeFloatBE=function(e,r,n){return Au(this,e,r,!1,n)};H.prototype.writeDoubleLE=function(e,r,n){return Tu(this,e,r,!0,n)};H.prototype.writeDoubleBE=function(e,r,n){return Tu(this,e,r,!1,n)};H.prototype.copy=function(e,r,n,i){if(n||(n=0),!i&&i!==0&&(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r<i-n&&(i=e.length-r+n);var s=i-n,o;if(this===e&&n<r&&r<i)for(o=s-1;o>=0;--o)e[o+r]=this[o+n];else if(s<1e3||!H.TYPED_ARRAY_SUPPORT)for(o=0;o<s;++o)e[o+r]=this[o+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+s),r);return s};H.prototype.fill=function(e,r,n,i){if(typeof e=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),e.length===1){var s=e.charCodeAt(0);s<256&&(e=s)}if(i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!H.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else typeof e=="number"&&(e=e&255);if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);var o;if(typeof e=="number")for(o=r;o<n;++o)this[o]=e;else{var a=Vt(e)?e:Oi(new H(e,i).toString()),c=a.length;for(o=0;o<n-r;++o)this[o+r]=a[o%c]}return this};Ld=/[^+\/0-9A-Za-z-_]/g});var _n=$e((fy,Mi)=>{var Ar=(Ou(),Al(Iu));if(Ar&&Ar.default){Mi.exports=Ar.default;for(let t in Ar)Mi.exports[t]=Ar[t]}else Ar&&(Mi.exports=Ar)});var En=$e((Uu,Ci)=>{(function(t){"use strict";var e,r=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,i=Math.floor,s="[BigNumber Error] ",o=s+"Number primitive has more than 15 significant digits: ",a=1e14,c=14,f=9007199254740991,l=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],d=1e7,v=1e9;function w(F){var M,z,Y,G=I.prototype={constructor:I,toString:null,valueOf:null},ee=new I(1),L=20,ce=4,le=-7,xe=21,me=-1e7,Z=1e7,ue=!1,j=1,C=0,X={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},D="0123456789abcdefghijklmnopqrstuvwxyz",ne=!0;function I(u,h){var p,T,x,A,N,g,B,R,S=this;if(!(S instanceof I))return new I(u,h);if(h==null){if(u&&u._isBigNumber===!0){S.s=u.s,!u.c||u.e>Z?S.c=S.e=null:u.e<me?S.c=[S.e=0]:(S.e=u.e,S.c=u.c.slice());return}if((g=typeof u=="number")&&u*0==0){if(S.s=1/u<0?(u=-u,-1):1,u===~~u){for(A=0,N=u;N>=10;N/=10,A++);A>Z?S.c=S.e=null:(S.e=A,S.c=[u]);return}R=String(u)}else{if(!r.test(R=String(u)))return Y(S,R,g);S.s=R.charCodeAt(0)==45?(R=R.slice(1),-1):1}(A=R.indexOf("."))>-1&&(R=R.replace(".","")),(N=R.search(/e/i))>0?(A<0&&(A=N),A+=+R.slice(N+1),R=R.substring(0,N)):A<0&&(A=R.length)}else{if(O(h,2,D.length,"Base"),h==10&&ne)return S=new I(u),se(S,L+S.e+1,ce);if(R=String(u),g=typeof u=="number"){if(u*0!=0)return Y(S,R,g,h);if(S.s=1/u<0?(R=R.slice(1),-1):1,I.DEBUG&&R.replace(/^0\.0*|\./,"").length>15)throw Error(o+u)}else S.s=R.charCodeAt(0)===45?(R=R.slice(1),-1):1;for(p=D.slice(0,h),A=N=0,B=R.length;N<B;N++)if(p.indexOf(T=R.charAt(N))<0){if(T=="."){if(N>A){A=B;continue}}else if(!x&&(R==R.toUpperCase()&&(R=R.toLowerCase())||R==R.toLowerCase()&&(R=R.toUpperCase()))){x=!0,N=-1,A=0;continue}return Y(S,String(u),g,h)}g=!1,R=z(R,h,10,S.s),(A=R.indexOf("."))>-1?R=R.replace(".",""):A=R.length}for(N=0;R.charCodeAt(N)===48;N++);for(B=R.length;R.charCodeAt(--B)===48;);if(R=R.slice(N,++B)){if(B-=N,g&&I.DEBUG&&B>15&&(u>f||u!==i(u)))throw Error(o+S.s*u);if((A=A-N-1)>Z)S.c=S.e=null;else if(A<me)S.c=[S.e=0];else{if(S.e=A,S.c=[],N=(A+1)%c,A<0&&(N+=c),N<B){for(N&&S.c.push(+R.slice(0,N)),B-=c;N<B;)S.c.push(+R.slice(N,N+=c));N=c-(R=R.slice(N)).length}else N-=B;for(;N--;R+="0");S.c.push(+R)}}else S.c=[S.e=0]}I.clone=w,I.ROUND_UP=0,I.ROUND_DOWN=1,I.ROUND_CEIL=2,I.ROUND_FLOOR=3,I.ROUND_HALF_UP=4,I.ROUND_HALF_DOWN=5,I.ROUND_HALF_EVEN=6,I.ROUND_HALF_CEIL=7,I.ROUND_HALF_FLOOR=8,I.EUCLID=9,I.config=I.set=function(u){var h,p;if(u!=null)if(typeof u=="object"){if(u.hasOwnProperty(h="DECIMAL_PLACES")&&(p=u[h],O(p,0,v,h),L=p),u.hasOwnProperty(h="ROUNDING_MODE")&&(p=u[h],O(p,0,8,h),ce=p),u.hasOwnProperty(h="EXPONENTIAL_AT")&&(p=u[h],p&&p.pop?(O(p[0],-v,0,h),O(p[1],0,v,h),le=p[0],xe=p[1]):(O(p,-v,v,h),le=-(xe=p<0?-p:p))),u.hasOwnProperty(h="RANGE"))if(p=u[h],p&&p.pop)O(p[0],-v,-1,h),O(p[1],1,v,h),me=p[0],Z=p[1];else if(O(p,-v,v,h),p)me=-(Z=p<0?-p:p);else throw Error(s+h+" cannot be zero: "+p);if(u.hasOwnProperty(h="CRYPTO"))if(p=u[h],p===!!p)if(p)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))ue=p;else throw ue=!p,Error(s+"crypto unavailable");else ue=p;else throw Error(s+h+" not true or false: "+p);if(u.hasOwnProperty(h="MODULO_MODE")&&(p=u[h],O(p,0,9,h),j=p),u.hasOwnProperty(h="POW_PRECISION")&&(p=u[h],O(p,0,v,h),C=p),u.hasOwnProperty(h="FORMAT"))if(p=u[h],typeof p=="object")X=p;else throw Error(s+h+" not an object: "+p);if(u.hasOwnProperty(h="ALPHABET"))if(p=u[h],typeof p=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(p))ne=p.slice(0,10)=="0123456789",D=p;else throw Error(s+h+" invalid: "+p)}else throw Error(s+"Object expected: "+u);return{DECIMAL_PLACES:L,ROUNDING_MODE:ce,EXPONENTIAL_AT:[le,xe],RANGE:[me,Z],CRYPTO:ue,MODULO_MODE:j,POW_PRECISION:C,FORMAT:X,ALPHABET:D}},I.isBigNumber=function(u){if(!u||u._isBigNumber!==!0)return!1;if(!I.DEBUG)return!0;var h,p,T=u.c,x=u.e,A=u.s;e:if({}.toString.call(T)=="[object Array]"){if((A===1||A===-1)&&x>=-v&&x<=v&&x===i(x)){if(T[0]===0){if(x===0&&T.length===1)return!0;break e}if(h=(x+1)%c,h<1&&(h+=c),String(T[0]).length==h){for(h=0;h<T.length;h++)if(p=T[h],p<0||p>=a||p!==i(p))break e;if(p!==0)return!0}}}else if(T===null&&x===null&&(A===null||A===1||A===-1))return!0;throw Error(s+"Invalid BigNumber: "+u)},I.maximum=I.max=function(){return fe(arguments,-1)},I.minimum=I.min=function(){return fe(arguments,1)},I.random=function(){var u=9007199254740992,h=Math.random()*u&2097151?function(){return i(Math.random()*u)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(p){var T,x,A,N,g,B=0,R=[],S=new I(ee);if(p==null?p=L:O(p,0,v),N=n(p/c),ue)if(crypto.getRandomValues){for(T=crypto.getRandomValues(new Uint32Array(N*=2));B<N;)g=T[B]*131072+(T[B+1]>>>11),g>=9e15?(x=crypto.getRandomValues(new Uint32Array(2)),T[B]=x[0],T[B+1]=x[1]):(R.push(g%1e14),B+=2);B=N/2}else if(crypto.randomBytes){for(T=crypto.randomBytes(N*=7);B<N;)g=(T[B]&31)*281474976710656+T[B+1]*1099511627776+T[B+2]*4294967296+T[B+3]*16777216+(T[B+4]<<16)+(T[B+5]<<8)+T[B+6],g>=9e15?crypto.randomBytes(7).copy(T,B):(R.push(g%1e14),B+=7);B=N/7}else throw ue=!1,Error(s+"crypto unavailable");if(!ue)for(;B<N;)g=h(),g<9e15&&(R[B++]=g%1e14);for(N=R[--B],p%=c,N&&p&&(g=l[c-p],R[B]=i(N/g)*g);R[B]===0;R.pop(),B--);if(B<0)R=[A=0];else{for(A=-1;R[0]===0;R.splice(0,1),A-=c);for(B=1,g=R[0];g>=10;g/=10,B++);B<c&&(A-=c-B)}return S.e=A,S.c=R,S}}(),I.sum=function(){for(var u=1,h=arguments,p=new I(h[0]);u<h.length;)p=p.plus(h[u++]);return p},z=function(){var u="0123456789";function h(p,T,x,A){for(var N,g=[0],B,R=0,S=p.length;R<S;){for(B=g.length;B--;g[B]*=T);for(g[0]+=A.indexOf(p.charAt(R++)),N=0;N<g.length;N++)g[N]>x-1&&(g[N+1]==null&&(g[N+1]=0),g[N+1]+=g[N]/x|0,g[N]%=x)}return g.reverse()}return function(p,T,x,A,N){var g,B,R,S,$,W,te,pe,Ee=p.indexOf("."),Te=L,he=ce;for(Ee>=0&&(S=C,C=0,p=p.replace(".",""),pe=new I(T),W=pe.pow(p.length-Ee),C=S,pe.c=h(K(E(W.c),W.e,"0"),10,x,u),pe.e=pe.c.length),te=h(p,T,x,N?(g=D,u):(g=u,D)),R=S=te.length;te[--S]==0;te.pop());if(!te[0])return g.charAt(0);if(Ee<0?--R:(W.c=te,W.e=R,W.s=A,W=M(W,pe,Te,he,x),te=W.c,$=W.r,R=W.e),B=R+Te+1,Ee=te[B],S=x/2,$=$||B<0||te[B+1]!=null,$=he<4?(Ee!=null||$)&&(he==0||he==(W.s<0?3:2)):Ee>S||Ee==S&&(he==4||$||he==6&&te[B-1]&1||he==(W.s<0?8:7)),B<1||!te[0])p=$?K(g.charAt(1),-Te,g.charAt(0)):g.charAt(0);else{if(te.length=B,$)for(--x;++te[--B]>x;)te[B]=0,B||(++R,te=[1].concat(te));for(S=te.length;!te[--S];);for(Ee=0,p="";Ee<=S;p+=g.charAt(te[Ee++]));p=K(p,R,g.charAt(0))}return p}}(),M=function(){function u(T,x,A){var N,g,B,R,S=0,$=T.length,W=x%d,te=x/d|0;for(T=T.slice();$--;)B=T[$]%d,R=T[$]/d|0,N=te*B+R*W,g=W*B+N%d*d+S,S=(g/A|0)+(N/d|0)+te*R,T[$]=g%A;return S&&(T=[S].concat(T)),T}function h(T,x,A,N){var g,B;if(A!=N)B=A>N?1:-1;else for(g=B=0;g<A;g++)if(T[g]!=x[g]){B=T[g]>x[g]?1:-1;break}return B}function p(T,x,A,N){for(var g=0;A--;)T[A]-=g,g=T[A]<x[A]?1:0,T[A]=g*N+T[A]-x[A];for(;!T[0]&&T.length>1;T.splice(0,1));}return function(T,x,A,N,g){var B,R,S,$,W,te,pe,Ee,Te,he,re,Pe,zt,xr,_r,at,_e,ct=T.s==x.s?1:-1,et=T.c,Oe=x.c;if(!et||!et[0]||!Oe||!Oe[0])return new I(!T.s||!x.s||(et?Oe&&et[0]==Oe[0]:!Oe)?NaN:et&&et[0]==0||!Oe?ct*0:ct/0);for(Ee=new I(ct),Te=Ee.c=[],R=T.e-x.e,ct=A+R+1,g||(g=a,R=_(T.e/c)-_(x.e/c),ct=ct/c|0),S=0;Oe[S]==(et[S]||0);S++);if(Oe[S]>(et[S]||0)&&R--,ct<0)Te.push(1),$=!0;else{for(xr=et.length,at=Oe.length,S=0,ct+=2,W=i(g/(Oe[0]+1)),W>1&&(Oe=u(Oe,W,g),et=u(et,W,g),at=Oe.length,xr=et.length),zt=at,he=et.slice(0,at),re=he.length;re<at;he[re++]=0);_e=Oe.slice(),_e=[0].concat(_e),_r=Oe[0],Oe[1]>=g/2&&_r++;do{if(W=0,B=h(Oe,he,at,re),B<0){if(Pe=he[0],at!=re&&(Pe=Pe*g+(he[1]||0)),W=i(Pe/_r),W>1)for(W>=g&&(W=g-1),te=u(Oe,W,g),pe=te.length,re=he.length;h(te,he,pe,re)==1;)W--,p(te,at<pe?_e:Oe,pe,g),pe=te.length,B=1;else W==0&&(B=W=1),te=Oe.slice(),pe=te.length;if(pe<re&&(te=[0].concat(te)),p(he,te,re,g),re=he.length,B==-1)for(;h(Oe,he,at,re)<1;)W++,p(he,at<re?_e:Oe,re,g),re=he.length}else B===0&&(W++,he=[0]);Te[S++]=W,he[0]?he[re++]=et[zt]||0:(he=[et[zt]],re=1)}while((zt++<xr||he[0]!=null)&&ct--);$=he[0]!=null,Te[0]||Te.splice(0,1)}if(g==a){for(S=1,ct=Te[0];ct>=10;ct/=10,S++);se(Ee,A+(Ee.e=S+R*c-1)+1,N,$)}else Ee.e=R,Ee.r=+$;return Ee}}();function m(u,h,p,T){var x,A,N,g,B;if(p==null?p=ce:O(p,0,8),!u.c)return u.toString();if(x=u.c[0],N=u.e,h==null)B=E(u.c),B=T==1||T==2&&(N<=le||N>=xe)?k(B,N):K(B,N,"0");else if(u=se(new I(u),h,p),A=u.e,B=E(u.c),g=B.length,T==1||T==2&&(h<=A||A<=le)){for(;g<h;B+="0",g++);B=k(B,A)}else if(h-=N,B=K(B,A,"0"),A+1>g){if(--h>0)for(B+=".";h--;B+="0");}else if(h+=A-g,h>0)for(A+1==g&&(B+=".");h--;B+="0");return u.s<0&&x?"-"+B:B}function fe(u,h){for(var p,T,x=1,A=new I(u[0]);x<u.length;x++)T=new I(u[x]),(!T.s||(p=U(A,T))===h||p===0&&A.s===h)&&(A=T);return A}function ie(u,h,p){for(var T=1,x=h.length;!h[--x];h.pop());for(x=h[0];x>=10;x/=10,T++);return(p=T+p*c-1)>Z?u.c=u.e=null:p<me?u.c=[u.e=0]:(u.e=p,u.c=h),u}Y=function(){var u=/^(-?)0([xbo])(?=\w[\w.]*$)/i,h=/^([^.]+)\.$/,p=/^\.([^.]+)$/,T=/^-?(Infinity|NaN)$/,x=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(A,N,g,B){var R,S=g?N:N.replace(x,"");if(T.test(S))A.s=isNaN(S)?null:S<0?-1:1;else{if(!g&&(S=S.replace(u,function($,W,te){return R=(te=te.toLowerCase())=="x"?16:te=="b"?2:8,!B||B==R?W:$}),B&&(R=B,S=S.replace(h,"$1").replace(p,"0.$1")),N!=S))return new I(S,R);if(I.DEBUG)throw Error(s+"Not a"+(B?" base "+B:"")+" number: "+N);A.s=null}A.c=A.e=null}}();function se(u,h,p,T){var x,A,N,g,B,R,S,$=u.c,W=l;if($){e:{for(x=1,g=$[0];g>=10;g/=10,x++);if(A=h-x,A<0)A+=c,N=h,B=$[R=0],S=i(B/W[x-N-1]%10);else if(R=n((A+1)/c),R>=$.length)if(T){for(;$.length<=R;$.push(0));B=S=0,x=1,A%=c,N=A-c+1}else break e;else{for(B=g=$[R],x=1;g>=10;g/=10,x++);A%=c,N=A-c+x,S=N<0?0:i(B/W[x-N-1]%10)}if(T=T||h<0||$[R+1]!=null||(N<0?B:B%W[x-N-1]),T=p<4?(S||T)&&(p==0||p==(u.s<0?3:2)):S>5||S==5&&(p==4||T||p==6&&(A>0?N>0?B/W[x-N]:0:$[R-1])%10&1||p==(u.s<0?8:7)),h<1||!$[0])return $.length=0,T?(h-=u.e+1,$[0]=W[(c-h%c)%c],u.e=-h||0):$[0]=u.e=0,u;if(A==0?($.length=R,g=1,R--):($.length=R+1,g=W[c-A],$[R]=N>0?i(B/W[x-N]%W[N])*g:0),T)for(;;)if(R==0){for(A=1,N=$[0];N>=10;N/=10,A++);for(N=$[0]+=g,g=1;N>=10;N/=10,g++);A!=g&&(u.e++,$[0]==a&&($[0]=1));break}else{if($[R]+=g,$[R]!=a)break;$[R--]=0,g=1}for(A=$.length;$[--A]===0;$.pop());}u.e>Z?u.c=u.e=null:u.e<me&&(u.c=[u.e=0])}return u}function Q(u){var h,p=u.e;return p===null?u.toString():(h=E(u.c),h=p<=le||p>=xe?k(h,p):K(h,p,"0"),u.s<0?"-"+h:h)}return G.absoluteValue=G.abs=function(){var u=new I(this);return u.s<0&&(u.s=1),u},G.comparedTo=function(u,h){return U(this,new I(u,h))},G.decimalPlaces=G.dp=function(u,h){var p,T,x,A=this;if(u!=null)return O(u,0,v),h==null?h=ce:O(h,0,8),se(new I(A),u+A.e+1,h);if(!(p=A.c))return null;if(T=((x=p.length-1)-_(this.e/c))*c,x=p[x])for(;x%10==0;x/=10,T--);return T<0&&(T=0),T},G.dividedBy=G.div=function(u,h){return M(this,new I(u,h),L,ce)},G.dividedToIntegerBy=G.idiv=function(u,h){return M(this,new I(u,h),0,1)},G.exponentiatedBy=G.pow=function(u,h){var p,T,x,A,N,g,B,R,S,$=this;if(u=new I(u),u.c&&!u.isInteger())throw Error(s+"Exponent not an integer: "+Q(u));if(h!=null&&(h=new I(h)),g=u.e>14,!$.c||!$.c[0]||$.c[0]==1&&!$.e&&$.c.length==1||!u.c||!u.c[0])return S=new I(Math.pow(+Q($),g?u.s*(2-V(u)):+Q(u))),h?S.mod(h):S;if(B=u.s<0,h){if(h.c?!h.c[0]:!h.s)return new I(NaN);T=!B&&$.isInteger()&&h.isInteger(),T&&($=$.mod(h))}else{if(u.e>9&&($.e>0||$.e<-1||($.e==0?$.c[0]>1||g&&$.c[1]>=24e7:$.c[0]<8e13||g&&$.c[0]<=9999975e7)))return A=$.s<0&&V(u)?-0:0,$.e>-1&&(A=1/A),new I(B?1/A:A);C&&(A=n(C/c+2))}for(g?(p=new I(.5),B&&(u.s=1),R=V(u)):(x=Math.abs(+Q(u)),R=x%2),S=new I(ee);;){if(R){if(S=S.times($),!S.c)break;A?S.c.length>A&&(S.c.length=A):T&&(S=S.mod(h))}if(x){if(x=i(x/2),x===0)break;R=x%2}else if(u=u.times(p),se(u,u.e+1,1),u.e>14)R=V(u);else{if(x=+Q(u),x===0)break;R=x%2}$=$.times($),A?$.c&&$.c.length>A&&($.c.length=A):T&&($=$.mod(h))}return T?S:(B&&(S=ee.div(S)),h?S.mod(h):A?se(S,C,ce,N):S)},G.integerValue=function(u){var h=new I(this);return u==null?u=ce:O(u,0,8),se(h,h.e+1,u)},G.isEqualTo=G.eq=function(u,h){return U(this,new I(u,h))===0},G.isFinite=function(){return!!this.c},G.isGreaterThan=G.gt=function(u,h){return U(this,new I(u,h))>0},G.isGreaterThanOrEqualTo=G.gte=function(u,h){return(h=U(this,new I(u,h)))===1||h===0},G.isInteger=function(){return!!this.c&&_(this.e/c)>this.c.length-2},G.isLessThan=G.lt=function(u,h){return U(this,new I(u,h))<0},G.isLessThanOrEqualTo=G.lte=function(u,h){return(h=U(this,new I(u,h)))===-1||h===0},G.isNaN=function(){return!this.s},G.isNegative=function(){return this.s<0},G.isPositive=function(){return this.s>0},G.isZero=function(){return!!this.c&&this.c[0]==0},G.minus=function(u,h){var p,T,x,A,N=this,g=N.s;if(u=new I(u,h),h=u.s,!g||!h)return new I(NaN);if(g!=h)return u.s=-h,N.plus(u);var B=N.e/c,R=u.e/c,S=N.c,$=u.c;if(!B||!R){if(!S||!$)return S?(u.s=-h,u):new I($?N:NaN);if(!S[0]||!$[0])return $[0]?(u.s=-h,u):new I(S[0]?N:ce==3?-0:0)}if(B=_(B),R=_(R),S=S.slice(),g=B-R){for((A=g<0)?(g=-g,x=S):(R=B,x=$),x.reverse(),h=g;h--;x.push(0));x.reverse()}else for(T=(A=(g=S.length)<(h=$.length))?g:h,g=h=0;h<T;h++)if(S[h]!=$[h]){A=S[h]<$[h];break}if(A&&(x=S,S=$,$=x,u.s=-u.s),h=(T=$.length)-(p=S.length),h>0)for(;h--;S[p++]=0);for(h=a-1;T>g;){if(S[--T]<$[T]){for(p=T;p&&!S[--p];S[p]=h);--S[p],S[T]+=a}S[T]-=$[T]}for(;S[0]==0;S.splice(0,1),--R);return S[0]?ie(u,S,R):(u.s=ce==3?-1:1,u.c=[u.e=0],u)},G.modulo=G.mod=function(u,h){var p,T,x=this;return u=new I(u,h),!x.c||!u.s||u.c&&!u.c[0]?new I(NaN):!u.c||x.c&&!x.c[0]?new I(x):(j==9?(T=u.s,u.s=1,p=M(x,u,0,3),u.s=T,p.s*=T):p=M(x,u,0,j),u=x.minus(p.times(u)),!u.c[0]&&j==1&&(u.s=x.s),u)},G.multipliedBy=G.times=function(u,h){var p,T,x,A,N,g,B,R,S,$,W,te,pe,Ee,Te,he=this,re=he.c,Pe=(u=new I(u,h)).c;if(!re||!Pe||!re[0]||!Pe[0])return!he.s||!u.s||re&&!re[0]&&!Pe||Pe&&!Pe[0]&&!re?u.c=u.e=u.s=null:(u.s*=he.s,!re||!Pe?u.c=u.e=null:(u.c=[0],u.e=0)),u;for(T=_(he.e/c)+_(u.e/c),u.s*=he.s,B=re.length,$=Pe.length,B<$&&(pe=re,re=Pe,Pe=pe,x=B,B=$,$=x),x=B+$,pe=[];x--;pe.push(0));for(Ee=a,Te=d,x=$;--x>=0;){for(p=0,W=Pe[x]%Te,te=Pe[x]/Te|0,N=B,A=x+N;A>x;)R=re[--N]%Te,S=re[N]/Te|0,g=te*R+S*W,R=W*R+g%Te*Te+pe[A]+p,p=(R/Ee|0)+(g/Te|0)+te*S,pe[A--]=R%Ee;pe[A]=p}return p?++T:pe.splice(0,1),ie(u,pe,T)},G.negated=function(){var u=new I(this);return u.s=-u.s||null,u},G.plus=function(u,h){var p,T=this,x=T.s;if(u=new I(u,h),h=u.s,!x||!h)return new I(NaN);if(x!=h)return u.s=-h,T.minus(u);var A=T.e/c,N=u.e/c,g=T.c,B=u.c;if(!A||!N){if(!g||!B)return new I(x/0);if(!g[0]||!B[0])return B[0]?u:new I(g[0]?T:x*0)}if(A=_(A),N=_(N),g=g.slice(),x=A-N){for(x>0?(N=A,p=B):(x=-x,p=g),p.reverse();x--;p.push(0));p.reverse()}for(x=g.length,h=B.length,x-h<0&&(p=B,B=g,g=p,h=x),x=0;h;)x=(g[--h]=g[h]+B[h]+x)/a|0,g[h]=a===g[h]?0:g[h]%a;return x&&(g=[x].concat(g),++N),ie(u,g,N)},G.precision=G.sd=function(u,h){var p,T,x,A=this;if(u!=null&&u!==!!u)return O(u,1,v),h==null?h=ce:O(h,0,8),se(new I(A),u,h);if(!(p=A.c))return null;if(x=p.length-1,T=x*c+1,x=p[x]){for(;x%10==0;x/=10,T--);for(x=p[0];x>=10;x/=10,T++);}return u&&A.e+1>T&&(T=A.e+1),T},G.shiftedBy=function(u){return O(u,-f,f),this.times("1e"+u)},G.squareRoot=G.sqrt=function(){var u,h,p,T,x,A=this,N=A.c,g=A.s,B=A.e,R=L+4,S=new I("0.5");if(g!==1||!N||!N[0])return new I(!g||g<0&&(!N||N[0])?NaN:N?A:1/0);if(g=Math.sqrt(+Q(A)),g==0||g==1/0?(h=E(N),(h.length+B)%2==0&&(h+="0"),g=Math.sqrt(+h),B=_((B+1)/2)-(B<0||B%2),g==1/0?h="5e"+B:(h=g.toExponential(),h=h.slice(0,h.indexOf("e")+1)+B),p=new I(h)):p=new I(g+""),p.c[0]){for(B=p.e,g=B+R,g<3&&(g=0);;)if(x=p,p=S.times(x.plus(M(A,x,R,1))),E(x.c).slice(0,g)===(h=E(p.c)).slice(0,g))if(p.e<B&&--g,h=h.slice(g-3,g+1),h=="9999"||!T&&h=="4999"){if(!T&&(se(x,x.e+L+2,0),x.times(x).eq(A))){p=x;break}R+=4,g+=4,T=1}else{(!+h||!+h.slice(1)&&h.charAt(0)=="5")&&(se(p,p.e+L+2,1),u=!p.times(p).eq(A));break}}return se(p,p.e+L+1,ce,u)},G.toExponential=function(u,h){return u!=null&&(O(u,0,v),u++),m(this,u,h,1)},G.toFixed=function(u,h){return u!=null&&(O(u,0,v),u=u+this.e+1),m(this,u,h)},G.toFormat=function(u,h,p){var T,x=this;if(p==null)u!=null&&h&&typeof h=="object"?(p=h,h=null):u&&typeof u=="object"?(p=u,u=h=null):p=X;else if(typeof p!="object")throw Error(s+"Argument not an object: "+p);if(T=x.toFixed(u,h),x.c){var A,N=T.split("."),g=+p.groupSize,B=+p.secondaryGroupSize,R=p.groupSeparator||"",S=N[0],$=N[1],W=x.s<0,te=W?S.slice(1):S,pe=te.length;if(B&&(A=g,g=B,B=A,pe-=A),g>0&&pe>0){for(A=pe%g||g,S=te.substr(0,A);A<pe;A+=g)S+=R+te.substr(A,g);B>0&&(S+=R+te.slice(A)),W&&(S="-"+S)}T=$?S+(p.decimalSeparator||"")+((B=+p.fractionGroupSize)?$.replace(new RegExp("\\d{"+B+"}\\B","g"),"$&"+(p.fractionGroupSeparator||"")):$):S}return(p.prefix||"")+T+(p.suffix||"")},G.toFraction=function(u){var h,p,T,x,A,N,g,B,R,S,$,W,te=this,pe=te.c;if(u!=null&&(g=new I(u),!g.isInteger()&&(g.c||g.s!==1)||g.lt(ee)))throw Error(s+"Argument "+(g.isInteger()?"out of range: ":"not an integer: ")+Q(g));if(!pe)return new I(te);for(h=new I(ee),R=p=new I(ee),T=B=new I(ee),W=E(pe),A=h.e=W.length-te.e-1,h.c[0]=l[(N=A%c)<0?c+N:N],u=!u||g.comparedTo(h)>0?A>0?h:R:g,N=Z,Z=1/0,g=new I(W),B.c[0]=0;S=M(g,h,0,1),x=p.plus(S.times(T)),x.comparedTo(u)!=1;)p=T,T=x,R=B.plus(S.times(x=R)),B=x,h=g.minus(S.times(x=h)),g=x;return x=M(u.minus(p),T,0,1),B=B.plus(x.times(R)),p=p.plus(x.times(T)),B.s=R.s=te.s,A=A*2,$=M(R,T,A,ce).minus(te).abs().comparedTo(M(B,p,A,ce).minus(te).abs())<1?[R,T]:[B,p],Z=N,$},G.toNumber=function(){return+Q(this)},G.toPrecision=function(u,h){return u!=null&&O(u,1,v),m(this,u,h,2)},G.toString=function(u){var h,p=this,T=p.s,x=p.e;return x===null?T?(h="Infinity",T<0&&(h="-"+h)):h="NaN":(u==null?h=x<=le||x>=xe?k(E(p.c),x):K(E(p.c),x,"0"):u===10&&ne?(p=se(new I(p),L+x+1,ce),h=K(E(p.c),p.e,"0")):(O(u,2,D.length,"Base"),h=z(K(E(p.c),x,"0"),10,u,T,!0)),T<0&&p.c[0]&&(h="-"+h)),h},G.valueOf=G.toJSON=function(){return Q(this)},G._isBigNumber=!0,F!=null&&I.set(F),I}function _(F){var M=F|0;return F>0||F===M?M:M-1}function E(F){for(var M,z,Y=1,G=F.length,ee=F[0]+"";Y<G;){for(M=F[Y++]+"",z=c-M.length;z--;M="0"+M);ee+=M}for(G=ee.length;ee.charCodeAt(--G)===48;);return ee.slice(0,G+1||1)}function U(F,M){var z,Y,G=F.c,ee=M.c,L=F.s,ce=M.s,le=F.e,xe=M.e;if(!L||!ce)return null;if(z=G&&!G[0],Y=ee&&!ee[0],z||Y)return z?Y?0:-ce:L;if(L!=ce)return L;if(z=L<0,Y=le==xe,!G||!ee)return Y?0:!G^z?1:-1;if(!Y)return le>xe^z?1:-1;for(ce=(le=G.length)<(xe=ee.length)?le:xe,L=0;L<ce;L++)if(G[L]!=ee[L])return G[L]>ee[L]^z?1:-1;return le==xe?0:le>xe^z?1:-1}function O(F,M,z,Y){if(F<M||F>z||F!==i(F))throw Error(s+(Y||"Argument")+(typeof F=="number"?F<M||F>z?" out of range: ":" not an integer: ":" not a primitive number: ")+String(F))}function V(F){var M=F.c.length-1;return _(F.e/c)==M&&F.c[M]%2!=0}function k(F,M){return(F.length>1?F.charAt(0)+"."+F.slice(1):F)+(M<0?"e":"e+")+M}function K(F,M,z){var Y,G;if(M<0){for(G=z+".";++M;G+=z);F=G+F}else if(Y=F.length,++M>Y){for(G=z,M-=Y;--M;G+=z);F+=G}else M<Y&&(F=F.slice(0,M)+"."+F.slice(M));return F}e=w(),e.default=e.BigNumber=e,typeof define=="function"&&define.amd?define(function(){return e}):typeof Ci<"u"&&Ci.exports?Ci.exports=e:(t||(t=typeof self<"u"&&self?self:window),t.BigNumber=e)})(Uu)});var Pu=$e((ly,Fu)=>{Fu.exports=function(e,r,n){var i=new e.Uint8Array(n),s=r.pushInt,o=r.pushInt32,a=r.pushInt32Neg,c=r.pushInt64,f=r.pushInt64Neg,l=r.pushFloat,d=r.pushFloatSingle,v=r.pushFloatDouble,w=r.pushTrue,_=r.pushFalse,E=r.pushUndefined,U=r.pushNull,O=r.pushInfinity,V=r.pushInfinityNeg,k=r.pushNaN,K=r.pushNaNNeg,F=r.pushArrayStart,M=r.pushArrayStartFixed,z=r.pushArrayStartFixed32,Y=r.pushArrayStartFixed64,G=r.pushObjectStart,ee=r.pushObjectStartFixed,L=r.pushObjectStartFixed32,ce=r.pushObjectStartFixed64,le=r.pushByteString,xe=r.pushByteStringStart,me=r.pushUtf8String,Z=r.pushUtf8StringStart,ue=r.pushSimpleUnassigned,j=r.pushTagStart,C=r.pushTagStart4,X=r.pushTagStart8,D=r.pushTagUnassigned,ne=r.pushBreak,I=e.Math.pow,m=0,fe=0,ie=0;function se(b){for(b=b|0,m=0,fe=b;(m|0)<(fe|0)&&(ie=wl[i[m]&255](i[m]|0)|0,!((ie|0)>0)););return ie|0}function Q(b){return b=b|0,((m|0)+(b|0)|0)<(fe|0)?0:1}function u(b){return b=b|0,i[b|0]<<8|i[b+1|0]|0}function h(b){return b=b|0,i[b|0]<<24|i[b+1|0]<<16|i[b+2|0]<<8|i[b+3|0]|0}function p(b){return b=b|0,s(b|0),m=m+1|0,0}function T(b){return b=b|0,Q(1)|0?1:(s(i[m+1|0]|0),m=m+2|0,0)}function x(b){return b=b|0,Q(2)|0?1:(s(u(m+1|0)|0),m=m+3|0,0)}function A(b){return b=b|0,Q(4)|0?1:(o(u(m+1|0)|0,u(m+3|0)|0),m=m+5|0,0)}function N(b){return b=b|0,Q(8)|0?1:(c(u(m+1|0)|0,u(m+3|0)|0,u(m+5|0)|0,u(m+7|0)|0),m=m+9|0,0)}function g(b){return b=b|0,s(-1-(b-32|0)|0),m=m+1|0,0}function B(b){return b=b|0,Q(1)|0?1:(s(-1-(i[m+1|0]|0)|0),m=m+2|0,0)}function R(b){b=b|0;var ge=0;return Q(2)|0?1:(ge=u(m+1|0)|0,s(-1-(ge|0)|0),m=m+3|0,0)}function S(b){return b=b|0,Q(4)|0?1:(a(u(m+1|0)|0,u(m+3|0)|0),m=m+5|0,0)}function $(b){return b=b|0,Q(8)|0?1:(f(u(m+1|0)|0,u(m+3|0)|0,u(m+5|0)|0,u(m+7|0)|0),m=m+9|0,0)}function W(b){b=b|0;var ge=0,be=0,ye=0;return ye=b-64|0,Q(ye|0)|0?1:(ge=m+1|0,be=(m+1|0)+(ye|0)|0,le(ge|0,be|0),m=be|0,0)}function te(b){b=b|0;var ge=0,be=0,ye=0;return Q(1)|0||(ye=i[m+1|0]|0,ge=m+2|0,be=(m+2|0)+(ye|0)|0,Q(ye+1|0)|0)?1:(le(ge|0,be|0),m=be|0,0)}function pe(b){b=b|0;var ge=0,be=0,ye=0;return Q(2)|0||(ye=u(m+1|0)|0,ge=m+3|0,be=(m+3|0)+(ye|0)|0,Q(ye+2|0)|0)?1:(le(ge|0,be|0),m=be|0,0)}function Ee(b){b=b|0;var ge=0,be=0,ye=0;return Q(4)|0||(ye=h(m+1|0)|0,ge=m+5|0,be=(m+5|0)+(ye|0)|0,Q(ye+4|0)|0)?1:(le(ge|0,be|0),m=be|0,0)}function Te(b){return b=b|0,1}function he(b){return b=b|0,xe(),m=m+1|0,0}function re(b){b=b|0;var ge=0,be=0,ye=0;return ye=b-96|0,Q(ye|0)|0?1:(ge=m+1|0,be=(m+1|0)+(ye|0)|0,me(ge|0,be|0),m=be|0,0)}function Pe(b){b=b|0;var ge=0,be=0,ye=0;return Q(1)|0||(ye=i[m+1|0]|0,ge=m+2|0,be=(m+2|0)+(ye|0)|0,Q(ye+1|0)|0)?1:(me(ge|0,be|0),m=be|0,0)}function zt(b){b=b|0;var ge=0,be=0,ye=0;return Q(2)|0||(ye=u(m+1|0)|0,ge=m+3|0,be=(m+3|0)+(ye|0)|0,Q(ye+2|0)|0)?1:(me(ge|0,be|0),m=be|0,0)}function xr(b){b=b|0;var ge=0,be=0,ye=0;return Q(4)|0||(ye=h(m+1|0)|0,ge=m+5|0,be=(m+5|0)+(ye|0)|0,Q(ye+4|0)|0)?1:(me(ge|0,be|0),m=be|0,0)}function _r(b){return b=b|0,1}function at(b){return b=b|0,Z(),m=m+1|0,0}function _e(b){return b=b|0,M(b-128|0),m=m+1|0,0}function ct(b){return b=b|0,Q(1)|0?1:(M(i[m+1|0]|0),m=m+2|0,0)}function et(b){return b=b|0,Q(2)|0?1:(M(u(m+1|0)|0),m=m+3|0,0)}function Oe(b){return b=b|0,Q(4)|0?1:(z(u(m+1|0)|0,u(m+3|0)|0),m=m+5|0,0)}function D0(b){return b=b|0,Q(8)|0?1:(Y(u(m+1|0)|0,u(m+3|0)|0,u(m+5|0)|0,u(m+7|0)|0),m=m+9|0,0)}function el(b){return b=b|0,F(),m=m+1|0,0}function Ue(b){b=b|0;var ge=0;return ge=b-160|0,Q(ge|0)|0?1:(ee(ge|0),m=m+1|0,0)}function tl(b){return b=b|0,Q(1)|0?1:(ee(i[m+1|0]|0),m=m+2|0,0)}function rl(b){return b=b|0,Q(2)|0?1:(ee(u(m+1|0)|0),m=m+3|0,0)}function nl(b){return b=b|0,Q(4)|0?1:(L(u(m+1|0)|0,u(m+3|0)|0),m=m+5|0,0)}function il(b){return b=b|0,Q(8)|0?1:(ce(u(m+1|0)|0,u(m+3|0)|0,u(m+5|0)|0,u(m+7|0)|0),m=m+9|0,0)}function sl(b){return b=b|0,G(),m=m+1|0,0}function Cr(b){return b=b|0,j(b-192|0|0),m=m+1|0,0}function L1(b){return b=b|0,j(b|0),m=m+1|0,0}function D1(b){return b=b|0,j(b|0),m=m+1|0,0}function em(b){return b=b|0,j(b|0),m=m+1|0,0}function tm(b){return b=b|0,j(b|0),m=m+1|0,0}function We(b){return b=b|0,j(b-192|0|0),m=m+1|0,0}function rm(b){return b=b|0,j(b|0),m=m+1|0,0}function nm(b){return b=b|0,j(b|0),m=m+1|0,0}function im(b){return b=b|0,j(b|0),m=m+1|0,0}function ol(b){return b=b|0,Q(1)|0?1:(j(i[m+1|0]|0),m=m+2|0,0)}function al(b){return b=b|0,Q(2)|0?1:(j(u(m+1|0)|0),m=m+3|0,0)}function cl(b){return b=b|0,Q(4)|0?1:(C(u(m+1|0)|0,u(m+3|0)|0),m=m+5|0,0)}function ul(b){return b=b|0,Q(8)|0?1:(X(u(m+1|0)|0,u(m+3|0)|0,u(m+5|0)|0,u(m+7|0)|0),m=m+9|0,0)}function Ve(b){return b=b|0,ue((b|0)-224|0),m=m+1|0,0}function fl(b){return b=b|0,_(),m=m+1|0,0}function ll(b){return b=b|0,w(),m=m+1|0,0}function dl(b){return b=b|0,U(),m=m+1|0,0}function hl(b){return b=b|0,E(),m=m+1|0,0}function pl(b){return b=b|0,Q(1)|0?1:(ue(i[m+1|0]|0),m=m+2|0,0)}function ml(b){b=b|0;var ge=0,be=0,ye=1,Ln=0,un=0,sm=0;return Q(2)|0?1:(ge=i[m+1|0]|0,be=i[m+2|0]|0,(ge|0)&128&&(ye=-1),Ln=+(((ge|0)&124)>>2),un=+(((ge|0)&3)<<8|be),+Ln==0?l(+(+ye*5960464477539063e-23*+un)):+Ln==31?+ye==1?+un>0?k():O():+un>0?K():V():l(+(+ye*I(2,+(+Ln-25))*+(1024+un))),m=m+3|0,0)}function yl(b){return b=b|0,Q(4)|0?1:(d(i[m+1|0]|0,i[m+2|0]|0,i[m+3|0]|0,i[m+4|0]|0),m=m+5|0,0)}function gl(b){return b=b|0,Q(8)|0?1:(v(i[m+1|0]|0,i[m+2|0]|0,i[m+3|0]|0,i[m+4|0]|0,i[m+5|0]|0,i[m+6|0]|0,i[m+7|0]|0,i[m+8|0]|0),m=m+9|0,0)}function Ae(b){return b=b|0,1}function bl(b){return b=b|0,ne(),m=m+1|0,0}var wl=[p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,T,x,A,N,Ae,Ae,Ae,Ae,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,B,R,S,$,Ae,Ae,Ae,Ae,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,te,pe,Ee,Te,Ae,Ae,Ae,he,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,Pe,zt,xr,_r,Ae,Ae,Ae,at,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,ct,et,Oe,D0,Ae,Ae,Ae,el,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,tl,rl,nl,il,Ae,Ae,Ae,sl,Cr,Cr,Cr,Cr,Cr,Cr,We,We,We,We,We,We,We,We,We,We,We,We,We,We,We,We,We,We,ol,al,cl,ul,Ae,Ae,Ae,Ae,Ve,Ve,Ve,Ve,Ve,Ve,Ve,Ve,Ve,Ve,Ve,Ve,Ve,Ve,Ve,Ve,Ve,Ve,Ve,Ve,fl,ll,dl,hl,pl,ml,yl,gl,Ae,Ae,Ae,bl];return{parse:se}}});var Bn=$e(dt=>{"use strict";var fo=En().BigNumber;dt.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};dt.TAG={DATE_STRING:0,DATE_EPOCH:1,POS_BIGINT:2,NEG_BIGINT:3,DECIMAL_FRAC:4,BIGFLOAT:5,BASE64URL_EXPECTED:21,BASE64_EXPECTED:22,BASE16_EXPECTED:23,CBOR:24,URI:32,BASE64URL:33,BASE64:34,REGEXP:35,MIME:36};dt.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};dt.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};dt.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};dt.SHIFT32=Math.pow(2,32);dt.SHIFT16=Math.pow(2,16);dt.MAX_SAFE_HIGH=2097151;dt.NEG_ONE=new fo(-1);dt.TEN=new fo(10);dt.TWO=new fo(2);dt.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var qi=$e(wt=>{"use strict";var{Buffer:oh}=_n(),Mu=En().BigNumber,Cu=Bn(),ku=Cu.SHIFT32,ah=Cu.SHIFT16,ch=2097151;wt.parseHalf=function(e){var r,n,i;return i=e[0]&128?-1:1,r=(e[0]&124)>>2,n=(e[0]&3)<<8|e[1],r?r===31?i*(n?NaN:1/0):i*Math.pow(2,r-25)*(1024+n):i*5960464477539063e-23*n};function uh(t){return t<16?"0"+t.toString(16):t.toString(16)}wt.arrayBufferToBignumber=function(t){let e=t.byteLength,r="";for(let n=0;n<e;n++)r+=uh(t[n]);return new Mu(r,16)};wt.buildMap=t=>{let e=new Map,r=Object.keys(t),n=r.length;for(let i=0;i<n;i++)e.set(r[i],t[r[i]]);return e};wt.buildInt32=(t,e)=>t*ah+e;wt.buildInt64=(t,e,r,n)=>{let i=wt.buildInt32(t,e),s=wt.buildInt32(r,n);return i>ch?new Mu(i).times(ku).plus(s):i*ku+s};wt.writeHalf=function(e,r){let n=oh.allocUnsafe(4);n.writeFloatBE(r,0);let i=n.readUInt32BE(0);if(i&8191)return!1;var s=i>>16&32768;let o=i>>23&255,a=i&8388607;if(o>=113&&o<=142)s+=(o-112<<10)+(a>>13);else if(o>=103&&o<113){if(a&(1<<126-o)-1)return!1;s+=a+8388608>>126-o}else return!1;return e.writeUInt16BE(s,0),!0};wt.keySorter=function(t,e){var r=t[0].byteLength,n=e[0].byteLength;return r>n?1:n>r?-1:t[0].compare(e[0])};wt.isNegativeZero=t=>t===0&&1/t<0;wt.nextPowerOf2=t=>{let e=0;if(t&&!(t&t-1))return t;for(;t!==0;)t>>=1,e+=1;return 1<<e}});var mo=$e((py,qu)=>{"use strict";var po=Bn(),fh=po.MT,Vi=po.SIMPLE,lo=po.SYMS,ho=class t{constructor(e){if(typeof e!="number")throw new Error("Invalid Simple type: "+typeof e);if(e<0||e>255||(e|0)!==e)throw new Error("value must be a small positive integer: "+e);this.value=e}toString(){return"simple("+this.value+")"}inspect(){return"simple("+this.value+")"}encodeCBOR(e){return e._pushInt(this.value,fh.SIMPLE_FLOAT)}static isSimple(e){return e instanceof t}static decode(e,r){switch(r==null&&(r=!0),e){case Vi.FALSE:return!1;case Vi.TRUE:return!0;case Vi.NULL:return r?null:lo.NULL;case Vi.UNDEFINED:return r?void 0:lo.UNDEFINED;case-1:if(!r)throw new Error("Invalid BREAK");return lo.BREAK;default:return new t(e)}}};qu.exports=ho});var go=$e((my,Vu)=>{"use strict";var yo=class t{constructor(e,r,n){if(this.tag=e,this.value=r,this.err=n,typeof this.tag!="number")throw new Error("Invalid tag type ("+typeof this.tag+")");if(this.tag<0||(this.tag|0)!==this.tag)throw new Error("Tag must be a positive integer: "+this.tag)}toString(){return`${this.tag}(${JSON.stringify(this.value)})`}encodeCBOR(e){return e._pushTag(this.tag),e.pushAny(this.value)}convert(e){var r,n;if(n=e?.[this.tag],typeof n!="function"&&(n=t["_tag"+this.tag],typeof n!="function"))return this;try{return n.call(t,this.value)}catch(i){return r=i,this.err=r,this}}};Vu.exports=yo});var xo=$e((yy,Gu)=>{"use strict";var $u=self.location?self.location.protocol+"//"+self.location.host:"",bo=self.URL,wo=class{constructor(e="",r=$u){this.super=new bo(e,r),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}get hash(){return this.super.hash}get host(){return this.super.host}get hostname(){return this.super.hostname}get href(){return this.super.href}get origin(){return this.super.origin}get password(){return this.super.password}get pathname(){return this.super.pathname}get port(){return this.super.port}get protocol(){return this.super.protocol}get search(){return this.super.search}get searchParams(){return this.super.searchParams}get username(){return this.super.username}set hash(e){this.super.hash=e}set host(e){this.super.host=e}set hostname(e){this.super.hostname=e}set href(e){this.super.href=e}set origin(e){this.super.origin=e}set password(e){this.super.password=e}set pathname(e){this.super.pathname=e}set port(e){this.super.port=e}set protocol(e){this.super.protocol=e}set search(e){this.super.search=e}set searchParams(e){this.super.searchParams=e}set username(e){this.super.username=e}createObjectURL(e){return this.super.createObjectURL(e)}revokeObjectURL(e){this.super.revokeObjectURL(e)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}};function lh(t){if(typeof t=="string")return new bo(t).toString();if(!(t instanceof bo)){let e=t.username&&t.password?`${t.username}:${t.password}@`:"",r=t.auth?t.auth+"@":"",n=t.port?":"+t.port:"",i=t.protocol?t.protocol+"//":"",s=t.host||"",o=t.hostname||"",a=t.search||(t.query?"?"+t.query:""),c=t.hash||"",f=t.pathname||"",l=t.path||f+a;return`${i}${e||r}${s||o+n}${l}${c}`}}Gu.exports={URLWithLegacySupport:wo,URLSearchParams:self.URLSearchParams,defaultBase:$u,format:lh}});var Yu=$e((gy,ju)=>{"use strict";var{URLWithLegacySupport:Hu,format:dh}=xo();ju.exports=(t,e={},r={},n)=>{let i=e.protocol?e.protocol.replace(":",""):"http";i=(r[i]||n||i)+":";let s;try{s=new Hu(t)}catch{s={}}let o=Object.assign({},e,{protocol:i||s.protocol,host:e.host||s.host});return new Hu(t,dh(o)).toString()}});var _o=$e((by,zu)=>{"use strict";var{URLWithLegacySupport:hh,format:ph,URLSearchParams:mh,defaultBase:yh}=xo(),gh=Yu();zu.exports={URL:hh,URLSearchParams:mh,format:ph,relative:gh,defaultBase:yh}});var Eo=$e((wy,Zu)=>{"use strict";var{Buffer:Qr}=_n(),Ku=Gs(),bh=En().BigNumber,wh=Pu(),it=qi(),ve=Bn(),xh=mo(),_h=go(),{URL:Eh}=_o(),vn=class t{constructor(e){e=e||{},!e.size||e.size<65536?e.size=65536:e.size=it.nextPowerOf2(e.size),this._heap=new ArrayBuffer(e.size),this._heap8=new Uint8Array(this._heap),this._buffer=Qr.from(this._heap),this._reset(),this._knownTags=Object.assign({0:r=>new Date(r),1:r=>new Date(r*1e3),2:r=>it.arrayBufferToBignumber(r),3:r=>ve.NEG_ONE.minus(it.arrayBufferToBignumber(r)),4:r=>ve.TEN.pow(r[0]).times(r[1]),5:r=>ve.TWO.pow(r[0]).times(r[1]),32:r=>new Eh(r),35:r=>new RegExp(r)},e.tags),this.parser=wh(globalThis,{log:console.log.bind(console),pushInt:this.pushInt.bind(this),pushInt32:this.pushInt32.bind(this),pushInt32Neg:this.pushInt32Neg.bind(this),pushInt64:this.pushInt64.bind(this),pushInt64Neg:this.pushInt64Neg.bind(this),pushFloat:this.pushFloat.bind(this),pushFloatSingle:this.pushFloatSingle.bind(this),pushFloatDouble:this.pushFloatDouble.bind(this),pushTrue:this.pushTrue.bind(this),pushFalse:this.pushFalse.bind(this),pushUndefined:this.pushUndefined.bind(this),pushNull:this.pushNull.bind(this),pushInfinity:this.pushInfinity.bind(this),pushInfinityNeg:this.pushInfinityNeg.bind(this),pushNaN:this.pushNaN.bind(this),pushNaNNeg:this.pushNaNNeg.bind(this),pushArrayStart:this.pushArrayStart.bind(this),pushArrayStartFixed:this.pushArrayStartFixed.bind(this),pushArrayStartFixed32:this.pushArrayStartFixed32.bind(this),pushArrayStartFixed64:this.pushArrayStartFixed64.bind(this),pushObjectStart:this.pushObjectStart.bind(this),pushObjectStartFixed:this.pushObjectStartFixed.bind(this),pushObjectStartFixed32:this.pushObjectStartFixed32.bind(this),pushObjectStartFixed64:this.pushObjectStartFixed64.bind(this),pushByteString:this.pushByteString.bind(this),pushByteStringStart:this.pushByteStringStart.bind(this),pushUtf8String:this.pushUtf8String.bind(this),pushUtf8StringStart:this.pushUtf8StringStart.bind(this),pushSimpleUnassigned:this.pushSimpleUnassigned.bind(this),pushTagUnassigned:this.pushTagUnassigned.bind(this),pushTagStart:this.pushTagStart.bind(this),pushTagStart4:this.pushTagStart4.bind(this),pushTagStart8:this.pushTagStart8.bind(this),pushBreak:this.pushBreak.bind(this)},this._heap)}get _depth(){return this._parents.length}get _currentParent(){return this._parents[this._depth-1]}get _ref(){return this._currentParent.ref}_closeParent(){var e=this._parents.pop();if(e.length>0)throw new Error(`Missing ${e.length} elements`);switch(e.type){case ve.PARENT.TAG:this._push(this.createTag(e.ref[0],e.ref[1]));break;case ve.PARENT.BYTE_STRING:this._push(this.createByteString(e.ref,e.length));break;case ve.PARENT.UTF8_STRING:this._push(this.createUtf8String(e.ref,e.length));break;case ve.PARENT.MAP:if(e.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createMap(e.ref,e.length));break;case ve.PARENT.OBJECT:if(e.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createObject(e.ref,e.length));break;case ve.PARENT.ARRAY:this._push(this.createArray(e.ref,e.length));break;default:break}this._currentParent&&this._currentParent.type===ve.PARENT.TAG&&this._dec()}_dec(){let e=this._currentParent;e.length<0||(e.length--,e.length===0&&this._closeParent())}_push(e,r){let n=this._currentParent;switch(n.values++,n.type){case ve.PARENT.ARRAY:case ve.PARENT.BYTE_STRING:case ve.PARENT.UTF8_STRING:n.length>-1?this._ref[this._ref.length-n.length]=e:this._ref.push(e),this._dec();break;case ve.PARENT.OBJECT:n.tmpKey!=null?(this._ref[n.tmpKey]=e,n.tmpKey=null,this._dec()):(n.tmpKey=e,typeof n.tmpKey!="string"&&(n.type=ve.PARENT.MAP,n.ref=it.buildMap(n.ref)));break;case ve.PARENT.MAP:n.tmpKey!=null?(this._ref.set(n.tmpKey,e),n.tmpKey=null,this._dec()):n.tmpKey=e;break;case ve.PARENT.TAG:this._ref.push(e),r||this._dec();break;default:throw new Error("Unknown parent type")}}_createParent(e,r,n){this._parents[this._depth]={type:r,length:n,ref:e,values:0,tmpKey:null}}_reset(){this._res=[],this._parents=[{type:ve.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(e,r){let n=this._knownTags[e];return n?n(r):new _h(e,r)}createMap(e,r){return e}createObject(e,r){return e}createArray(e,r){return e}createByteString(e,r){return Qr.concat(e)}createByteStringFromHeap(e,r){return e===r?Qr.alloc(0):Qr.from(this._heap.slice(e,r))}createInt(e){return e}createInt32(e,r){return it.buildInt32(e,r)}createInt64(e,r,n,i){return it.buildInt64(e,r,n,i)}createFloat(e){return e}createFloatSingle(e,r,n,i){return Ku.read([e,r,n,i],0,!1,23,4)}createFloatDouble(e,r,n,i,s,o,a,c){return Ku.read([e,r,n,i,s,o,a,c],0,!1,52,8)}createInt32Neg(e,r){return-1-it.buildInt32(e,r)}createInt64Neg(e,r,n,i){let s=it.buildInt32(e,r),o=it.buildInt32(n,i);return s>ve.MAX_SAFE_HIGH?ve.NEG_ONE.minus(new bh(s).times(ve.SHIFT32).plus(o)):-1-(s*ve.SHIFT32+o)}createTrue(){return!0}createFalse(){return!1}createNull(){return null}createUndefined(){}createInfinity(){return 1/0}createInfinityNeg(){return-1/0}createNaN(){return NaN}createNaNNeg(){return NaN}createUtf8String(e,r){return e.join("")}createUtf8StringFromHeap(e,r){return e===r?"":this._buffer.toString("utf8",e,r)}createSimpleUnassigned(e){return new xh(e)}pushInt(e){this._push(this.createInt(e))}pushInt32(e,r){this._push(this.createInt32(e,r))}pushInt64(e,r,n,i){this._push(this.createInt64(e,r,n,i))}pushFloat(e){this._push(this.createFloat(e))}pushFloatSingle(e,r,n,i){this._push(this.createFloatSingle(e,r,n,i))}pushFloatDouble(e,r,n,i,s,o,a,c){this._push(this.createFloatDouble(e,r,n,i,s,o,a,c))}pushInt32Neg(e,r){this._push(this.createInt32Neg(e,r))}pushInt64Neg(e,r,n,i){this._push(this.createInt64Neg(e,r,n,i))}pushTrue(){this._push(this.createTrue())}pushFalse(){this._push(this.createFalse())}pushNull(){this._push(this.createNull())}pushUndefined(){this._push(this.createUndefined())}pushInfinity(){this._push(this.createInfinity())}pushInfinityNeg(){this._push(this.createInfinityNeg())}pushNaN(){this._push(this.createNaN())}pushNaNNeg(){this._push(this.createNaNNeg())}pushArrayStart(){this._createParent([],ve.PARENT.ARRAY,-1)}pushArrayStartFixed(e){this._createArrayStartFixed(e)}pushArrayStartFixed32(e,r){let n=it.buildInt32(e,r);this._createArrayStartFixed(n)}pushArrayStartFixed64(e,r,n,i){let s=it.buildInt64(e,r,n,i);this._createArrayStartFixed(s)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(e){this._createObjectStartFixed(e)}pushObjectStartFixed32(e,r){let n=it.buildInt32(e,r);this._createObjectStartFixed(n)}pushObjectStartFixed64(e,r,n,i){let s=it.buildInt64(e,r,n,i);this._createObjectStartFixed(s)}pushByteStringStart(){this._parents[this._depth]={type:ve.PARENT.BYTE_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushByteString(e,r){this._push(this.createByteStringFromHeap(e,r))}pushUtf8StringStart(){this._parents[this._depth]={type:ve.PARENT.UTF8_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushUtf8String(e,r){this._push(this.createUtf8StringFromHeap(e,r))}pushSimpleUnassigned(e){this._push(this.createSimpleUnassigned(e))}pushTagStart(e){this._parents[this._depth]={type:ve.PARENT.TAG,length:1,ref:[e]}}pushTagStart4(e,r){this.pushTagStart(it.buildInt32(e,r))}pushTagStart8(e,r,n,i){this.pushTagStart(it.buildInt64(e,r,n,i))}pushTagUnassigned(e){this._push(this.createTag(e))}pushBreak(){if(this._currentParent.length>-1)throw new Error("Unexpected break");this._closeParent()}_createObjectStartFixed(e){if(e===0){this._push(this.createObject({}));return}this._createParent({},ve.PARENT.OBJECT,e)}_createArrayStartFixed(e){if(e===0){this._push(this.createArray([]));return}this._createParent(new Array(e),ve.PARENT.ARRAY,e)}_decode(e){if(e.byteLength===0)throw new Error("Input too short");this._reset(),this._heap8.set(e);let r=this.parser.parse(e.byteLength);if(this._depth>1){for(;this._currentParent.length===0;)this._closeParent();if(this._depth>1)throw new Error("Undeterminated nesting")}if(r>0)throw new Error("Failed to parse");if(this._res.length===0)throw new Error("No valid result")}decodeFirst(e){return this._decode(e),this._res[0]}decodeAll(e){return this._decode(e),this._res}static decode(e,r){return typeof e=="string"&&(e=Qr.from(e,r||"hex")),new t({size:e.length}).decodeFirst(e)}static decodeAll(e,r){return typeof e=="string"&&(e=Qr.from(e,r||"hex")),new t({size:e.length}).decodeAll(e)}};vn.decodeFirst=vn.decode;Zu.exports=vn});var Ju=$e((xy,Xu)=>{"use strict";var{Buffer:Bo}=_n(),Bh=Eo(),vh=qi(),vo=class t extends Bh{createTag(e,r){return`${e}(${r})`}createInt(e){return super.createInt(e).toString()}createInt32(e,r){return super.createInt32(e,r).toString()}createInt64(e,r,n,i){return super.createInt64(e,r,n,i).toString()}createInt32Neg(e,r){return super.createInt32Neg(e,r).toString()}createInt64Neg(e,r,n,i){return super.createInt64Neg(e,r,n,i).toString()}createTrue(){return"true"}createFalse(){return"false"}createFloat(e){let r=super.createFloat(e);return vh.isNegativeZero(e)?"-0_1":`${r}_1`}createFloatSingle(e,r,n,i){return`${super.createFloatSingle(e,r,n,i)}_2`}createFloatDouble(e,r,n,i,s,o,a,c){return`${super.createFloatDouble(e,r,n,i,s,o,a,c)}_3`}createByteString(e,r){let n=e.join(", ");return r===-1?`(_ ${n})`:`h'${n}`}createByteStringFromHeap(e,r){return`h'${Bo.from(super.createByteStringFromHeap(e,r)).toString("hex")}'`}createInfinity(){return"Infinity_1"}createInfinityNeg(){return"-Infinity_1"}createNaN(){return"NaN_1"}createNaNNeg(){return"-NaN_1"}createNull(){return"null"}createUndefined(){return"undefined"}createSimpleUnassigned(e){return`simple(${e})`}createArray(e,r){let n=super.createArray(e,r);return r===-1?`[_ ${n.join(", ")}]`:`[${n.join(", ")}]`}createMap(e,r){let n=super.createMap(e),i=Array.from(n.keys()).reduce(Wu(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createObject(e,r){let n=super.createObject(e),i=Object.keys(n).reduce(Wu(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createUtf8String(e,r){let n=e.join(", ");return r===-1?`(_ ${n})`:`"${n}"`}createUtf8StringFromHeap(e,r){return`"${Bo.from(super.createUtf8StringFromHeap(e,r)).toString("utf8")}"`}static diagnose(e,r){return typeof e=="string"&&(e=Bo.from(e,r||"hex")),new t().decodeFirst(e)}};Xu.exports=vo;function Wu(t){return(e,r)=>e?`${e}, ${r}: ${t[r]}`:`${r}: ${t[r]}`}});var tf=$e((_y,ef)=>{"use strict";var{Buffer:$t}=_n(),{URL:Ah}=_o(),To=En().BigNumber,Ao=qi(),ze=Bn(),Tt=ze.MT,$i=ze.NUMBYTES,Qu=ze.SHIFT32,Lu=ze.SYMS,Lr=ze.TAG,Th=ze.MT.SIMPLE_FLOAT<<5|ze.NUMBYTES.TWO,Sh=ze.MT.SIMPLE_FLOAT<<5|ze.NUMBYTES.FOUR,Nh=ze.MT.SIMPLE_FLOAT<<5|ze.NUMBYTES.EIGHT,Rh=ze.MT.SIMPLE_FLOAT<<5|ze.SIMPLE.TRUE,Ih=ze.MT.SIMPLE_FLOAT<<5|ze.SIMPLE.FALSE,Oh=ze.MT.SIMPLE_FLOAT<<5|ze.SIMPLE.UNDEFINED,Du=ze.MT.SIMPLE_FLOAT<<5|ze.SIMPLE.NULL,Uh=new To("0x20000000000000"),Fh=$t.from("f97e00","hex"),Ph=$t.from("f9fc00","hex"),kh=$t.from("f97c00","hex");function Mh(t){return{}.toString.call(t).slice(8,-1)}var So=class t{constructor(e){e=e||{},this.streaming=typeof e.stream=="function",this.onData=e.stream,this.semanticTypes=[[Ah,this._pushUrl],[To,this._pushBigNumber]];let r=e.genTypes||[],n=r.length;for(let i=0;i<n;i++)this.addSemanticType(r[i][0],r[i][1]);this._reset()}addSemanticType(e,r){let n=this.semanticTypes.length;for(let i=0;i<n;i++)if(this.semanticTypes[i][0]===e){let o=this.semanticTypes[i][1];return this.semanticTypes[i][1]=r,o}return this.semanticTypes.push([e,r]),null}push(e){return e&&(this.result[this.offset]=e,this.resultMethod[this.offset]=0,this.resultLength[this.offset]=e.length,this.offset++,this.streaming&&this.onData(this.finalize())),!0}pushWrite(e,r,n){return this.result[this.offset]=e,this.resultMethod[this.offset]=r,this.resultLength[this.offset]=n,this.offset++,this.streaming&&this.onData(this.finalize()),!0}_pushUInt8(e){return this.pushWrite(e,1,1)}_pushUInt16BE(e){return this.pushWrite(e,2,2)}_pushUInt32BE(e){return this.pushWrite(e,3,4)}_pushDoubleBE(e){return this.pushWrite(e,4,8)}_pushNaN(){return this.push(Fh)}_pushInfinity(e){let r=e<0?Ph:kh;return this.push(r)}_pushFloat(e){let r=$t.allocUnsafe(2);if(Ao.writeHalf(r,e)&&Ao.parseHalf(r)===e)return this._pushUInt8(Th)&&this.push(r);let n=$t.allocUnsafe(4);return n.writeFloatBE(e,0),n.readFloatBE(0)===e?this._pushUInt8(Sh)&&this.push(n):this._pushUInt8(Nh)&&this._pushDoubleBE(e)}_pushInt(e,r,n){let i=r<<5;return e<24?this._pushUInt8(i|e):e<=255?this._pushUInt8(i|$i.ONE)&&this._pushUInt8(e):e<=65535?this._pushUInt8(i|$i.TWO)&&this._pushUInt16BE(e):e<=4294967295?this._pushUInt8(i|$i.FOUR)&&this._pushUInt32BE(e):e<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|$i.EIGHT)&&this._pushUInt32BE(Math.floor(e/Qu))&&this._pushUInt32BE(e%Qu):r===Tt.NEG_INT?this._pushFloat(n):this._pushFloat(e)}_pushIntNum(e){return e<0?this._pushInt(-e-1,Tt.NEG_INT,e):this._pushInt(e,Tt.POS_INT)}_pushNumber(e){switch(!1){case e===e:return this._pushNaN(e);case isFinite(e):return this._pushInfinity(e);case e%1!==0:return this._pushIntNum(e);default:return this._pushFloat(e)}}_pushString(e){let r=$t.byteLength(e,"utf8");return this._pushInt(r,Tt.UTF8_STRING)&&this.pushWrite(e,5,r)}_pushBoolean(e){return this._pushUInt8(e?Rh:Ih)}_pushUndefined(e){return this._pushUInt8(Oh)}_pushArray(e,r){let n=r.length;if(!e._pushInt(n,Tt.ARRAY))return!1;for(let i=0;i<n;i++)if(!e.pushAny(r[i]))return!1;return!0}_pushTag(e){return this._pushInt(e,Tt.TAG)}_pushDate(e,r){return e._pushTag(Lr.DATE_EPOCH)&&e.pushAny(Math.round(r/1e3))}_pushBuffer(e,r){return e._pushInt(r.length,Tt.BYTE_STRING)&&e.push(r)}_pushNoFilter(e,r){return e._pushBuffer(e,r.slice())}_pushRegexp(e,r){return e._pushTag(Lr.REGEXP)&&e.pushAny(r.source)}_pushSet(e,r){if(!e._pushInt(r.size,Tt.ARRAY))return!1;for(let n of r)if(!e.pushAny(n))return!1;return!0}_pushUrl(e,r){return e._pushTag(Lr.URI)&&e.pushAny(r.format())}_pushBigint(e){let r=Lr.POS_BIGINT;e.isNegative()&&(e=e.negated().minus(1),r=Lr.NEG_BIGINT);let n=e.toString(16);n.length%2&&(n="0"+n);let i=$t.from(n,"hex");return this._pushTag(r)&&this._pushBuffer(this,i)}_pushBigNumber(e,r){if(r.isNaN())return e._pushNaN();if(!r.isFinite())return e._pushInfinity(r.isNegative()?-1/0:1/0);if(r.isInteger())return e._pushBigint(r);if(!(e._pushTag(Lr.DECIMAL_FRAC)&&e._pushInt(2,Tt.ARRAY)))return!1;let n=r.decimalPlaces(),i=r.multipliedBy(new To(10).pow(n));return e._pushIntNum(-n)?i.abs().isLessThan(Uh)?e._pushIntNum(i.toNumber()):e._pushBigint(i):!1}_pushMap(e,r){return e._pushInt(r.size,Tt.MAP)?this._pushRawMap(r.size,Array.from(r)):!1}_pushObject(e){if(!e)return this._pushUInt8(Du);for(var r=this.semanticTypes.length,n=0;n<r;n++)if(e instanceof this.semanticTypes[n][0])return this.semanticTypes[n][1].call(e,this,e);var i=e.encodeCBOR;if(typeof i=="function")return i.call(e,this);var s=Object.keys(e),o=s.length;return this._pushInt(o,Tt.MAP)?this._pushRawMap(o,s.map(a=>[a,e[a]])):!1}_pushRawMap(e,r){r=r.map(function(i){return i[0]=t.encode(i[0]),i}).sort(Ao.keySorter);for(var n=0;n<e;n++)if(!this.push(r[n][0])||!this.pushAny(r[n][1]))return!1;return!0}write(e){return this.pushAny(e)}pushAny(e){var r=Mh(e);switch(r){case"Number":return this._pushNumber(e);case"String":return this._pushString(e);case"Boolean":return this._pushBoolean(e);case"Object":return this._pushObject(e);case"Array":return this._pushArray(this,e);case"Uint8Array":return this._pushBuffer(this,$t.isBuffer(e)?e:$t.from(e));case"Null":return this._pushUInt8(Du);case"Undefined":return this._pushUndefined(e);case"Map":return this._pushMap(this,e);case"Set":return this._pushSet(this,e);case"URL":return this._pushUrl(this,e);case"BigNumber":return this._pushBigNumber(this,e);case"Date":return this._pushDate(this,e);case"RegExp":return this._pushRegexp(this,e);case"Symbol":switch(e){case Lu.NULL:return this._pushObject(null);case Lu.UNDEFINED:return this._pushUndefined(void 0);default:throw new Error("Unknown symbol: "+e.toString())}default:throw new Error("Unknown type: "+typeof e+", "+(e?e.toString():""))}}finalize(){if(this.offset===0)return null;for(var e=this.result,r=this.resultLength,n=this.resultMethod,i=this.offset,s=0,o=0;o<i;o++)s+=r[o];var a=$t.allocUnsafe(s),c=0,f=0;for(o=0;o<i;o++){switch(f=r[o],n[o]){case 0:e[o].copy(a,c);break;case 1:a.writeUInt8(e[o],c,!0);break;case 2:a.writeUInt16BE(e[o],c,!0);break;case 3:a.writeUInt32BE(e[o],c,!0);break;case 4:a.writeDoubleBE(e[o],c,!0);break;case 5:a.write(e[o],c,f,"utf8");break;default:throw new Error("unkown method")}c+=f}var l=a;return this._reset(),l}_reset(){this.result=[],this.resultMethod=[],this.resultLength=[],this.offset=0}static encode(e){let r=new t;if(!r.pushAny(e))throw new Error("Failed to encode input");return r.finalize()}};ef.exports=So});var No=$e(Ke=>{"use strict";Ke.Diagnose=Ju();Ke.Decoder=Eo();Ke.Encoder=tf();Ke.Simple=mo();Ke.Tagged=go();Ke.decodeAll=Ke.Decoder.decodeAll;Ke.decodeFirst=Ke.Decoder.decodeFirst;Ke.diagnose=Ke.Diagnose.diagnose;Ke.encode=Ke.Encoder.encode;Ke.decode=Ke.Decoder.decode;Ke.leveldb={decode:Ke.Decoder.decodeAll,encode:Ke.Encoder.encode,buffer:!0,name:"cbor"}});function st(...t){let e=new Uint8Array(t.reduce((n,i)=>n+i.byteLength,0)),r=0;for(let n of t)e.set(new Uint8Array(n),r),r+=n.byteLength;return e.buffer}function Qe(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}function Tr(t){if(!Ch.test(t))throw new Error("Invalid hexadecimal string.");let e=[...t].reduce((r,n,i)=>(r[i/2|0]=(r[i/2|0]||"")+n,r),[]).map(r=>Number.parseInt(r,16));return new Uint8Array(e).buffer}function Ro(t,e){if(t.byteLength!==e.byteLength)return t.byteLength-e.byteLength;let r=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<r.length;i++)if(r[i]!==n[i])return r[i]-n[i];return 0}function rf(t,e){return Ro(t,e)===0}function An(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}function Io(t){return t instanceof Uint8Array?An(t):t instanceof ArrayBuffer?t:Array.isArray(t)?An(new Uint8Array(t)):"buffer"in t?Io(t.buffer):An(new Uint8Array(t))}var Ch,ht=we(()=>{Ch=new RegExp(/^[0-9a-fA-F]+$/)});function xt(t){return An(dn.create().update(new Uint8Array(t)).digest())}function Gi(t){if(t instanceof nf.default.Tagged)return Gi(t.value);if(typeof t=="string")return sf(t);if(typeof t=="number")return xt(Ie(t));if(t instanceof ArrayBuffer||ArrayBuffer.isView(t))return xt(t);if(Array.isArray(t)){let e=t.map(Gi);return xt(st(...e))}else{if(t&&typeof t=="object"&&t._isPrincipal)return xt(t.toUint8Array());if(typeof t=="object"&&t!==null&&typeof t.toHash=="function")return Gi(t.toHash());if(typeof t=="object")return Tn(t);if(typeof t=="bigint")return xt(Ie(t))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${t}`),{value:t})}function Hi(t){return Tn(t)}function Tn(t){let n=Object.entries(t).filter(([,o])=>o!==void 0).map(([o,a])=>{let c=sf(o),f=Gi(a);return[c,f]}).sort(([o],[a])=>Ro(o,a)),i=st(...n.map(o=>st(...o)));return xt(i)}var nf,sf,Sn=we(()=>{xn();nf=qr(No());ai();ht();sf=t=>{let e=new TextEncoder().encode(t);return xt(e)}});var Fo=$e(Se=>{"use strict";Object.defineProperty(Se,"__esModule",{value:!0});var qh=9007199254740992;function Qt(t,...e){let r=new Uint8Array(t.byteLength+e.reduce((i,s)=>i+s.byteLength,0));r.set(new Uint8Array(t),0);let n=t.byteLength;for(let i of e)r.set(new Uint8Array(i),n),n+=i.byteLength;return r.buffer}function St(t,e,r){r=r.replace(/[^0-9a-fA-F]/g,"");let n=2**(e-24);r=r.slice(-n*2).padStart(n*2,"0");let i=[(t<<5)+e].concat(r.match(/../g).map(s=>parseInt(s,16)));return new Uint8Array(i).buffer}function ji(t,e){if(e<24)return new Uint8Array([(t<<5)+e]).buffer;{let r=e<=255?24:e<=65535?25:e<=4294967295?26:27;return St(t,r,e.toString(16))}}function of(t){let e=[];for(let r=0;r<t.length;r++){let n=t.charCodeAt(r);n<128?e.push(n):n<2048?e.push(192|n>>6,128|n&63):n<55296||n>=57344?e.push(224|n>>12,128|n>>6&63,128|n&63):(r++,n=(n&1023)<<10|t.charCodeAt(r)&1023,e.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|n&63))}return Qt(new Uint8Array(ji(3,t.length)),new Uint8Array(e))}function Vh(t,e){if(t==14277111)return Qt(new Uint8Array([217,217,247]),e);if(t<24)return Qt(new Uint8Array([192+t]),e);{let r=t<=255?24:t<=65535?25:t<=4294967295?26:27,n=2**(r-24),i=t.toString(16).slice(-n*2).padStart(n*2,"0"),s=[192+r].concat(i.match(/../g).map(o=>parseInt(o,16)));return new Uint8Array(s).buffer}}Se.tagged=Vh;function Nn(t){return new Uint8Array(t).buffer}Se.raw=Nn;function Oo(t){if(isNaN(t))throw new RangeError("Invalid number.");t=Math.min(Math.max(0,t),23);let e=[0+t];return new Uint8Array(e).buffer}Se.uSmall=Oo;function af(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),255),t=t.toString(16),St(0,24,t)}Se.u8=af;function cf(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),65535),t=t.toString(16),St(0,25,t)}Se.u16=cf;function uf(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),4294967295),t=t.toString(16),St(0,26,t)}Se.u32=uf;function Uo(t,e){if(typeof t=="string"&&e==16){if(t.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return St(0,27,t)}if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),qh),t=t.toString(16),St(0,27,t)}Se.u64=Uo;function ff(t){if(isNaN(t))throw new RangeError("Invalid number.");if(t===0)return Oo(0);t=Math.min(Math.max(0,-t),24)-1;let e=[32+t];return new Uint8Array(e).buffer}Se.iSmall=ff;function lf(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),255),t=t.toString(16),St(1,24,t)}Se.i8=lf;function df(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),65535),t=t.toString(16),St(1,25,t)}Se.i16=df;function hf(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),4294967295),t=t.toString(16),St(1,26,t)}Se.i32=hf;function pf(t,e){if(typeof t=="string"&&e==16){if(t.startsWith("-")?t=t.slice(1):t="0",t.match(/[^0-9a-fA-F]/)||t.length>16)throw new RangeError("Invalid number.");let r=!1,n=t.split("").reduceRight((i,s)=>{if(r)return s+i;let o=parseInt(s,16)-1;return o>=0?(r=!0,o.toString(16)+i):"f"+i},"");return r?St(1,27,n):Uo(0)}if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),9007199254740992),t=t.toString(16),St(1,27,t)}Se.i64=pf;function $h(t){return t>=0?t<24?Oo(t):t<=255?af(t):t<=65535?cf(t):t<=4294967295?uf(t):Uo(t):t>=-24?ff(t):t>=-255?lf(t):t>=-65535?df(t):t>=-4294967295?hf(t):pf(t)}Se.number=$h;function Gh(t){return Qt(ji(2,t.byteLength),t)}Se.bytes=Gh;function Hh(t){return of(t)}Se.string=Hh;function jh(t){return Qt(ji(4,t.length),...t)}Se.array=jh;function Yh(t,e=!1){t instanceof Map||(t=new Map(Object.entries(t)));let r=Array.from(t.entries());return e&&(r=r.sort(([n],[i])=>n.localeCompare(i))),Qt(ji(5,t.size),...r.map(([n,i])=>Qt(of(n),i)))}Se.map=Yh;function zh(t){let e=new Float32Array([t]);return Qt(new Uint8Array([250]),new Uint8Array(e.buffer))}Se.singleFloat=zh;function Kh(t){let e=new Float64Array([t]);return Qt(new Uint8Array([251]),new Uint8Array(e.buffer))}Se.doubleFloat=Kh;function Zh(t){return t?mf():yf()}Se.bool=Zh;function mf(){return Nn(new Uint8Array([245]))}Se.true_=mf;function yf(){return Nn(new Uint8Array([244]))}Se.false_=yf;function Wh(){return Nn(new Uint8Array([246]))}Se.null_=Wh;function Xh(){return Nn(new Uint8Array([247]))}Se.undefined_=Xh});var gf=$e(ur=>{"use strict";var Jh=ur&&ur.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e};Object.defineProperty(ur,"__esModule",{value:!0});var Nt=Jh(Fo()),Qh=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],Yi=class{constructor(e,r=!1){this._serializer=e,this._stable=r,this.name="jsonDefault",this.priority=-100}match(e){return["undefined","boolean","number","string","object"].indexOf(typeof e)!=-1}encode(e){switch(typeof e){case"undefined":return Nt.undefined_();case"boolean":return Nt.bool(e);case"number":return Math.floor(e)===e?Nt.number(e):Nt.doubleFloat(e);case"string":return Nt.string(e);case"object":if(e===null)return Nt.null_();if(Array.isArray(e))return Nt.array(e.map(r=>this._serializer.serializeValue(r)));if(Qh.find(r=>e instanceof r))return Nt.bytes(e.buffer);if(Object.getOwnPropertyNames(e).indexOf("toJSON")!==-1)return this.encode(e.toJSON());if(e instanceof Map){let r=new Map;for(let[n,i]of e.entries())r.set(n,this._serializer.serializeValue(i));return Nt.map(r,this._stable)}else{let r=new Map;for(let[n,i]of Object.entries(e))r.set(n,this._serializer.serializeValue(i));return Nt.map(r,this._stable)}default:throw new Error("Invalid value.")}}};ur.JsonDefaultCborEncoder=Yi;var zi=class{constructor(){this.name="cborEncoder",this.priority=-90}match(e){return typeof e=="object"&&typeof e.toCBOR=="function"}encode(e){return e.toCBOR()}};ur.ToCborEncoder=zi;var Ki=class{constructor(){this._encoders=new Set}static withDefaultEncoders(e=!1){let r=new this;return r.addEncoder(new Yi(r,e)),r.addEncoder(new zi),r}removeEncoder(e){for(let r of this._encoders.values())r.name==e&&this._encoders.delete(r)}addEncoder(e){this._encoders.add(e)}getEncoderFor(e){let r=null;for(let n of this._encoders)(!r||n.priority>r.priority)&&n.match(e)&&(r=n);if(r===null)throw new Error("Could not find an encoder for value.");return r}serializeValue(e){return this.getEncoderFor(e).encode(e)}serialize(e){return this.serializeValue(e)}};ur.CborSerializer=Ki;var Po=class extends Ki{serialize(e){return Nt.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(e))]))}};ur.SelfDescribeCborSerializer=Po});var Zi=$e(Sr=>{"use strict";function Lh(t){for(var e in t)Sr.hasOwnProperty(e)||(Sr[e]=t[e])}var Dh=Sr&&Sr.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e};Object.defineProperty(Sr,"__esModule",{value:!0});Lh(gf());var ep=Dh(Fo());Sr.value=ep});function Xi(t){return Wi.serialize(t)}function bf(t){let e=t.byteLength,r=BigInt(0);for(let n=0;n<e;n++)r=r*BigInt(256)+BigInt(t[n]);return r}function _t(t){let e=new Uint8Array(t);return new Vo({size:e.byteLength,tags:{2:n=>bf(n),3:n=>-bf(n),[qo.Semantic]:n=>n}}).decodeFirst(e)}var wf,Nr,xf,ko,Mo,Co,Wi,qo,Vo,Rn=we(()=>{wf=qr(No()),Nr=qr(Zi()),xf=qr(Zi());ht();ko=class{get name(){return"Principal"}get priority(){return 0}match(e){return e&&e._isPrincipal===!0}encode(e){return Nr.value.bytes(e.toUint8Array())}},Mo=class{get name(){return"Buffer"}get priority(){return 1}match(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)}encode(e){return Nr.value.bytes(new Uint8Array(e))}},Co=class{get name(){return"BigInt"}get priority(){return 1}match(e){return typeof e=="bigint"}encode(e){return e>BigInt(0)?Nr.value.tagged(2,Nr.value.bytes(Tr(e.toString(16)))):Nr.value.tagged(3,Nr.value.bytes(Tr((BigInt("-1")*e).toString(16))))}},Wi=xf.SelfDescribeCborSerializer.withDefaultEncoders(!0);Wi.addEncoder(new ko);Wi.addEncoder(new Mo);Wi.addEncoder(new Co);(function(t){t[t.Uint64LittleEndian=71]="Uint64LittleEndian",t[t.Semantic=55799]="Semantic"})(qo||(qo={}));Vo=class extends wf.default.Decoder{createByteString(e){return st(...e)}createByteStringFromHeap(e,r){return e===r?new ArrayBuffer(0):new Uint8Array(this._heap.slice(e,r))}}});var Di={};fn(Di,{abytes:()=>Rt,bitGet:()=>rn,bitLen:()=>lr,bitMask:()=>dr,bitSet:()=>ap,bytesToHex:()=>It,bytesToNumberBE:()=>rt,bytesToNumberLE:()=>fr,concatBytes:()=>Ne,createHmacDrbg:()=>Tf,ensureBytes:()=>je,equalBytes:()=>op,hexToBytes:()=>Fn,hexToNumber:()=>Ho,isBytes:()=>tn,numberToBytesBE:()=>qe,numberToBytesLE:()=>Ir,numberToHexUnpadded:()=>Af,numberToVarBytesBE:()=>sp,utf8ToBytes:()=>Pn,validateObject:()=>Ot});function tn(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Rt(t){if(!tn(t))throw new Error("Uint8Array expected")}function It(t){Rt(t);let e="";for(let r=0;r<t.length;r++)e+=ip[t[r]];return e}function Af(t){let e=t.toString(16);return e.length&1?`0${e}`:e}function Ho(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}function Ef(t){if(t>=Lt._0&&t<=Lt._9)return t-Lt._0;if(t>=Lt._A&&t<=Lt._F)return t-(Lt._A-10);if(t>=Lt._a&&t<=Lt._f)return t-(Lt._a-10)}function Fn(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){let o=Ef(t.charCodeAt(s)),a=Ef(t.charCodeAt(s+1));if(o===void 0||a===void 0){let c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=o*16+a}return n}function rt(t){return Ho(It(t))}function fr(t){return Rt(t),Ho(It(Uint8Array.from(t).reverse()))}function qe(t,e){return Fn(t.toString(16).padStart(e*2,"0"))}function Ir(t,e){return qe(t,e).reverse()}function sp(t){return Fn(Af(t))}function je(t,e,r){let n;if(typeof e=="string")try{n=Fn(e)}catch(s){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${s}`)}else if(tn(e))n=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);let i=n.length;if(typeof r=="number"&&i!==r)throw new Error(`${t} expected ${r} bytes, got ${i}`);return n}function Ne(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];Rt(i),e+=i.length}let r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let s=t[n];r.set(s,i),i+=s.length}return r}function op(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}function Pn(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function lr(t){let e;for(e=0;t>vf;t>>=Li,e+=1);return e}function rn(t,e){return t>>BigInt(e)&Li}function ap(t,e,r){return t|(r?Li:vf)<<BigInt(e)}function Tf(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=Go(t),i=Go(t),s=0,o=()=>{n.fill(1),i.fill(0),s=0},a=(...d)=>r(i,n,...d),c=(d=Go())=>{i=a(Bf([0]),d),n=a(),d.length!==0&&(i=a(Bf([1]),d),n=a())},f=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let d=0,v=[];for(;d<e;){n=a();let w=n.slice();v.push(w),d+=n.length}return Ne(...v)};return(d,v)=>{o(),c(d);let w;for(;!(w=v(f()));)c();return o(),w}}function Ot(t,e,r={}){let n=(i,s,o)=>{let a=cp[s];if(typeof a!="function")throw new Error(`Invalid validator "${s}", expected function`);let c=t[i];if(!(o&&c===void 0)&&!a(c,t))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${s}`)};for(let[i,s]of Object.entries(e))n(i,s,!1);for(let[i,s]of Object.entries(r))n(i,s,!0);return t}var vf,Li,np,ip,Lt,dr,Go,Bf,cp,Gt=we(()=>{vf=BigInt(0),Li=BigInt(1),np=BigInt(2);ip=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));Lt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};dr=t=>(np<<BigInt(t-1))-Li,Go=t=>new Uint8Array(t),Bf=t=>Uint8Array.from(t);cp={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||tn(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)}});function Re(t,e){let r=t%e;return r>=Ze?r:e+r}function dp(t,e,r){if(r<=Ze||e<Ze)throw new Error("Expected power/modulo > 0");if(r===Fe)return Ze;let n=Fe;for(;e>Ze;)e&Fe&&(n=n*t%r),t=t*t%r,e>>=Fe;return n}function Ut(t,e,r){let n=t;for(;e-- >Ze;)n*=n,n%=r;return n}function Yo(t,e){if(t===Ze||e<=Ze)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=Re(t,e),n=e,i=Ze,s=Fe,o=Fe,a=Ze;for(;r!==Ze;){let f=n/r,l=n%r,d=i-o*f,v=s-a*f;n=r,r=l,i=o,s=a,o=d,a=v}if(n!==Fe)throw new Error("invert: does not exist");return Re(i,e)}function hp(t){let e=(t-Fe)/Or,r,n,i;for(r=t-Fe,n=0;r%Or===Ze;r/=Or,n++);for(i=Or;i<t&&dp(i,e,t)!==t-Fe;i++);if(n===1){let o=(t+Fe)/jo;return function(c,f){let l=c.pow(f,o);if(!c.eql(c.sqr(l),f))throw new Error("Cannot find square root");return l}}let s=(r+Fe)/Or;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=n,l=a.pow(a.mul(a.ONE,i),r),d=a.pow(c,s),v=a.pow(c,r);for(;!a.eql(v,a.ONE);){if(a.eql(v,a.ZERO))return a.ZERO;let w=1;for(let E=a.sqr(v);w<f&&!a.eql(E,a.ONE);w++)E=a.sqr(E);let _=a.pow(l,Fe<<BigInt(f-w-1));l=a.sqr(_),d=a.mul(d,_),v=a.mul(v,l),f=w}return d}}function pp(t){if(t%jo===up){let e=(t+Fe)/jo;return function(n,i){let s=n.pow(i,e);if(!n.eql(n.sqr(s),i))throw new Error("Cannot find square root");return s}}if(t%Nf===Sf){let e=(t-Sf)/Nf;return function(n,i){let s=n.mul(i,Or),o=n.pow(s,e),a=n.mul(i,o),c=n.mul(n.mul(a,Or),o),f=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(f),i))throw new Error("Cannot find square root");return f}}return t%lp,hp(t)}function es(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=mp.reduce((n,i)=>(n[i]="function",n),e);return Ot(t,r)}function kn(t,e,r){if(r<Ze)throw new Error("Expected power > 0");if(r===Ze)return t.ONE;if(r===Fe)return e;let n=t.ONE,i=e;for(;r>Ze;)r&Fe&&(n=t.mul(n,i)),i=t.sqr(i),r>>=Fe;return n}function Mn(t,e){let r=new Array(e.length),n=e.reduce((s,o,a)=>t.is0(o)?s:(r[a]=s,t.mul(s,o)),t.ONE),i=t.inv(n);return e.reduceRight((s,o,a)=>t.is0(o)?s:(r[a]=t.mul(s,r[a]),t.mul(s,o)),i),r}function zo(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function Cn(t,e,r=!1,n={}){if(t<=Ze)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:s}=zo(t,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=pp(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:s,MASK:dr(i),ZERO:Ze,ONE:Fe,create:c=>Re(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return Ze<=c&&c<t},is0:c=>c===Ze,isOdd:c=>(c&Fe)===Fe,neg:c=>Re(-c,t),eql:(c,f)=>c===f,sqr:c=>Re(c*c,t),add:(c,f)=>Re(c+f,t),sub:(c,f)=>Re(c-f,t),mul:(c,f)=>Re(c*f,t),pow:(c,f)=>kn(a,c,f),div:(c,f)=>Re(c*Yo(f,t),t),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>Yo(c,t),sqrt:n.sqrt||(c=>o(a,c)),invertBatch:c=>Mn(a,c),cmov:(c,f,l)=>l?f:c,toBytes:c=>r?Ir(c,s):qe(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return r?fr(c):rt(c)}});return Object.freeze(a)}function If(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let r=t.sqrt(e);return t.isOdd(r)?t.neg(r):r}function Of(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function ts(t){let e=Of(t);return e+Math.ceil(e/2)}function Ko(t,e,r=!1){let n=t.length,i=Of(e),s=ts(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let o=r?rt(t):fr(t),a=Re(o,e-Fe)+Fe;return r?Ir(a,i):qe(a,i)}var Ze,Fe,Or,up,jo,Sf,Nf,fp,lp,Rf,mp,hr=we(()=>{Gt();Ze=BigInt(0),Fe=BigInt(1),Or=BigInt(2),up=BigInt(3),jo=BigInt(4),Sf=BigInt(5),Nf=BigInt(8),fp=BigInt(9),lp=BigInt(16);Rf=(t,e)=>(Re(t,e)&Fe)===Fe,mp=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"]});function pr(t,e){if(t<0||t>=1<<8*e)throw new Error(`bad I2OSP call: value=${t} length=${e}`);let r=Array.from({length:e}).fill(0);for(let n=e-1;n>=0;n--)r[n]=t&255,t>>>=8;return new Uint8Array(r)}function gp(t,e){let r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t[n]^e[n];return r}function Zo(t){if(!Number.isSafeInteger(t))throw new Error("number expected")}function bp(t,e,r,n){Rt(t),Rt(e),Zo(r),e.length>255&&(e=n(Ne(Pn("H2C-OVERSIZE-DST-"),e)));let{outputLen:i,blockLen:s}=n,o=Math.ceil(r/i);if(o>255)throw new Error("Invalid xmd length");let a=Ne(e,pr(e.length,1)),c=pr(0,s),f=pr(r,2),l=new Array(o),d=n(Ne(c,t,f,pr(0,1),a));l[0]=n(Ne(d,pr(1,1),a));for(let w=1;w<=o;w++){let _=[gp(d,l[w-1]),pr(w+1,1),a];l[w]=n(Ne(..._))}return Ne(...l).slice(0,r)}function wp(t,e,r,n,i){if(Rt(t),Rt(e),Zo(r),e.length>255){let s=Math.ceil(2*n/8);e=i.create({dkLen:s}).update(Pn("H2C-OVERSIZE-DST-")).update(e).digest()}if(r>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:r}).update(t).update(pr(r,2)).update(e).update(pr(e.length,1)).digest()}function Ff(t,e,r){Ot(r,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});let{p:n,k:i,m:s,hash:o,expand:a,DST:c}=r;Rt(t),Zo(e);let f=typeof c=="string"?Pn(c):c,l=n.toString(2).length,d=Math.ceil((l+i)/8),v=e*s*d,w;if(a==="xmd")w=bp(t,f,v,o);else if(a==="xof")w=wp(t,f,v,i,o);else if(a==="_internal_pass")w=t;else throw new Error('expand must be "xmd" or "xof"');let _=new Array(e);for(let E=0;E<e;E++){let U=new Array(s);for(let O=0;O<s;O++){let V=d*(O+E*s),k=w.subarray(V,V+d);U[O]=Re(yp(k),n)}_[E]=U}return _}function Wo(t,e){let r=e.map(n=>Array.from(n).reverse());return(n,i)=>{let[s,o,a,c]=r.map(f=>f.reduce((l,d)=>t.add(t.mul(l,n),d)));return n=t.div(s,o),i=t.mul(i,t.div(a,c)),{x:n,y:i}}}function Xo(t,e,r){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){let s=Ff(n,2,{...r,DST:r.DST,...i}),o=t.fromAffine(e(s[0])),a=t.fromAffine(e(s[1])),c=o.add(a).clearCofactor();return c.assertValidity(),c},encodeToCurve(n,i){let s=Ff(n,1,{...r,DST:r.encodeDST,...i}),o=t.fromAffine(e(s[0])).clearCofactor();return o.assertValidity(),o}}}var yp,Jo=we(()=>{hr();Gt();yp=rt});function rs(t,e){let r=(i,s)=>{let o=s.negate();return i?o:s},n=i=>{let s=Math.ceil(e/i)+1,o=2**(i-1);return{windows:s,windowSize:o}};return{constTimeNegate:r,unsafeLadder(i,s){let o=t.ZERO,a=i;for(;s>xp;)s&Qo&&(o=o.add(a)),a=a.double(),s>>=Qo;return o},precomputeWindow(i,s){let{windows:o,windowSize:a}=n(s),c=[],f=i,l=f;for(let d=0;d<o;d++){l=f,c.push(l);for(let v=1;v<a;v++)l=l.add(f),c.push(l);f=l.double()}return c},wNAF(i,s,o){let{windows:a,windowSize:c}=n(i),f=t.ZERO,l=t.BASE,d=BigInt(2**i-1),v=2**i,w=BigInt(i);for(let _=0;_<a;_++){let E=_*c,U=Number(o&d);o>>=w,U>c&&(U-=v,o+=Qo);let O=E,V=E+Math.abs(U)-1,k=_%2!==0,K=U<0;U===0?l=l.add(r(k,s[O])):f=f.add(r(K,s[V]))}return{p:f,f:l}},wNAFCached(i,s,o,a){let c=i._WINDOW_SIZE||1,f=s.get(i);return f||(f=this.precomputeWindow(i,c),c!==1&&s.set(i,a(f))),this.wNAF(c,f,o)}}}function ns(t){return es(t.Fp),Ot(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...zo(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}var xp,Qo,Lo=we(()=>{hr();Gt();xp=BigInt(0),Qo=BigInt(1)});function _p(t){let e=ns(t);Ot(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:i}=e;if(r){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}function Do(t){let e=_p(t),{Fp:r}=e,n=e.toBytes||((_,E,U)=>{let O=E.toAffine();return Ne(Uint8Array.from([4]),r.toBytes(O.x),r.toBytes(O.y))}),i=e.fromBytes||(_=>{let E=_.subarray(1),U=r.fromBytes(E.subarray(0,r.BYTES)),O=r.fromBytes(E.subarray(r.BYTES,2*r.BYTES));return{x:U,y:O}});function s(_){let{a:E,b:U}=e,O=r.sqr(_),V=r.mul(O,_);return r.add(r.add(V,r.mul(_,E)),U)}if(!r.eql(r.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function o(_){return typeof _=="bigint"&&Ur<_&&_<e.n}function a(_){if(!o(_))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(_){let{allowedPrivateKeyLengths:E,nByteLength:U,wrapPrivateKey:O,n:V}=e;if(E&&typeof _!="bigint"){if(tn(_)&&(_=It(_)),typeof _!="string"||!E.includes(_.length))throw new Error("Invalid key");_=_.padStart(U*2,"0")}let k;try{k=typeof _=="bigint"?_:rt(je("private key",_,U))}catch{throw new Error(`private key must be ${U} bytes, hex or bigint, not ${typeof _}`)}return O&&(k=Re(k,V)),a(k),k}let f=new Map;function l(_){if(!(_ instanceof d))throw new Error("ProjectivePoint expected")}class d{constructor(E,U,O){if(this.px=E,this.py=U,this.pz=O,E==null||!r.isValid(E))throw new Error("x required");if(U==null||!r.isValid(U))throw new Error("y required");if(O==null||!r.isValid(O))throw new Error("z required")}static fromAffine(E){let{x:U,y:O}=E||{};if(!E||!r.isValid(U)||!r.isValid(O))throw new Error("invalid affine point");if(E instanceof d)throw new Error("projective point not allowed");let V=k=>r.eql(k,r.ZERO);return V(U)&&V(O)?d.ZERO:new d(U,O,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(E){let U=r.invertBatch(E.map(O=>O.pz));return E.map((O,V)=>O.toAffine(U[V])).map(d.fromAffine)}static fromHex(E){let U=d.fromAffine(i(je("pointHex",E)));return U.assertValidity(),U}static fromPrivateKey(E){return d.BASE.multiply(c(E))}_setWindowSize(E){this._WINDOW_SIZE=E,f.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:E,y:U}=this.toAffine();if(!r.isValid(E)||!r.isValid(U))throw new Error("bad point: x or y not FE");let O=r.sqr(U),V=s(E);if(!r.eql(O,V))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:E}=this.toAffine();if(r.isOdd)return!r.isOdd(E);throw new Error("Field doesn't support isOdd")}equals(E){l(E);let{px:U,py:O,pz:V}=this,{px:k,py:K,pz:F}=E,M=r.eql(r.mul(U,F),r.mul(k,V)),z=r.eql(r.mul(O,F),r.mul(K,V));return M&&z}negate(){return new d(this.px,r.neg(this.py),this.pz)}double(){let{a:E,b:U}=e,O=r.mul(U,is),{px:V,py:k,pz:K}=this,F=r.ZERO,M=r.ZERO,z=r.ZERO,Y=r.mul(V,V),G=r.mul(k,k),ee=r.mul(K,K),L=r.mul(V,k);return L=r.add(L,L),z=r.mul(V,K),z=r.add(z,z),F=r.mul(E,z),M=r.mul(O,ee),M=r.add(F,M),F=r.sub(G,M),M=r.add(G,M),M=r.mul(F,M),F=r.mul(L,F),z=r.mul(O,z),ee=r.mul(E,ee),L=r.sub(Y,ee),L=r.mul(E,L),L=r.add(L,z),z=r.add(Y,Y),Y=r.add(z,Y),Y=r.add(Y,ee),Y=r.mul(Y,L),M=r.add(M,Y),ee=r.mul(k,K),ee=r.add(ee,ee),Y=r.mul(ee,L),F=r.sub(F,Y),z=r.mul(ee,G),z=r.add(z,z),z=r.add(z,z),new d(F,M,z)}add(E){l(E);let{px:U,py:O,pz:V}=this,{px:k,py:K,pz:F}=E,M=r.ZERO,z=r.ZERO,Y=r.ZERO,G=e.a,ee=r.mul(e.b,is),L=r.mul(U,k),ce=r.mul(O,K),le=r.mul(V,F),xe=r.add(U,O),me=r.add(k,K);xe=r.mul(xe,me),me=r.add(L,ce),xe=r.sub(xe,me),me=r.add(U,V);let Z=r.add(k,F);return me=r.mul(me,Z),Z=r.add(L,le),me=r.sub(me,Z),Z=r.add(O,V),M=r.add(K,F),Z=r.mul(Z,M),M=r.add(ce,le),Z=r.sub(Z,M),Y=r.mul(G,me),M=r.mul(ee,le),Y=r.add(M,Y),M=r.sub(ce,Y),Y=r.add(ce,Y),z=r.mul(M,Y),ce=r.add(L,L),ce=r.add(ce,L),le=r.mul(G,le),me=r.mul(ee,me),ce=r.add(ce,le),le=r.sub(L,le),le=r.mul(G,le),me=r.add(me,le),L=r.mul(ce,me),z=r.add(z,L),L=r.mul(Z,me),M=r.mul(xe,M),M=r.sub(M,L),L=r.mul(xe,ce),Y=r.mul(Z,Y),Y=r.add(Y,L),new d(M,z,Y)}subtract(E){return this.add(E.negate())}is0(){return this.equals(d.ZERO)}wNAF(E){return w.wNAFCached(this,f,E,U=>{let O=r.invertBatch(U.map(V=>V.pz));return U.map((V,k)=>V.toAffine(O[k])).map(d.fromAffine)})}multiplyUnsafe(E){let U=d.ZERO;if(E===Ur)return U;if(a(E),E===Le)return this;let{endo:O}=e;if(!O)return w.unsafeLadder(this,E);let{k1neg:V,k1:k,k2neg:K,k2:F}=O.splitScalar(E),M=U,z=U,Y=this;for(;k>Ur||F>Ur;)k&Le&&(M=M.add(Y)),F&Le&&(z=z.add(Y)),Y=Y.double(),k>>=Le,F>>=Le;return V&&(M=M.negate()),K&&(z=z.negate()),z=new d(r.mul(z.px,O.beta),z.py,z.pz),M.add(z)}multiply(E){a(E);let U=E,O,V,{endo:k}=e;if(k){let{k1neg:K,k1:F,k2neg:M,k2:z}=k.splitScalar(U),{p:Y,f:G}=this.wNAF(F),{p:ee,f:L}=this.wNAF(z);Y=w.constTimeNegate(K,Y),ee=w.constTimeNegate(M,ee),ee=new d(r.mul(ee.px,k.beta),ee.py,ee.pz),O=Y.add(ee),V=G.add(L)}else{let{p:K,f:F}=this.wNAF(U);O=K,V=F}return d.normalizeZ([O,V])[0]}multiplyAndAddUnsafe(E,U,O){let V=d.BASE,k=(F,M)=>M===Ur||M===Le||!F.equals(V)?F.multiplyUnsafe(M):F.multiply(M),K=k(this,U).add(k(E,O));return K.is0()?void 0:K}toAffine(E){let{px:U,py:O,pz:V}=this,k=this.is0();E==null&&(E=k?r.ONE:r.inv(V));let K=r.mul(U,E),F=r.mul(O,E),M=r.mul(V,E);if(k)return{x:r.ZERO,y:r.ZERO};if(!r.eql(M,r.ONE))throw new Error("invZ was invalid");return{x:K,y:F}}isTorsionFree(){let{h:E,isTorsionFree:U}=e;if(E===Le)return!0;if(U)return U(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:E,clearCofactor:U}=e;return E===Le?this:U?U(d,this):this.multiplyUnsafe(e.h)}toRawBytes(E=!0){return this.assertValidity(),n(d,this,E)}toHex(E=!0){return It(this.toRawBytes(E))}}d.BASE=new d(e.Gx,e.Gy,r.ONE),d.ZERO=new d(r.ZERO,r.ONE,r.ZERO);let v=e.nBitLength,w=rs(d,e.endo?Math.ceil(v/2):v);return{CURVE:e,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:o}}function Ep(t,e){let r=t.ORDER,n=Ur;for(let _=r-Le;_%mr===Ur;_/=mr)n+=Le;let i=n,s=mr<<i-Le-Le,o=s*mr,a=(r-Le)/o,c=(a-Le)/mr,f=o-Le,l=s,d=t.pow(e,a),v=t.pow(e,(a+Le)/mr),w=(_,E)=>{let U=d,O=t.pow(E,f),V=t.sqr(O);V=t.mul(V,E);let k=t.mul(_,V);k=t.pow(k,c),k=t.mul(k,O),O=t.mul(k,E),V=t.mul(k,_);let K=t.mul(V,O);k=t.pow(K,l);let F=t.eql(k,t.ONE);O=t.mul(V,v),k=t.mul(K,U),V=t.cmov(O,V,F),K=t.cmov(k,K,F);for(let M=i;M>Le;M--){let z=M-mr;z=mr<<z-Le;let Y=t.pow(K,z),G=t.eql(Y,t.ONE);O=t.mul(V,U),U=t.mul(U,U),Y=t.mul(K,U),V=t.cmov(O,V,G),K=t.cmov(Y,K,G)}return{isValid:F,value:V}};if(t.ORDER%Pf===is){let _=(t.ORDER-is)/Pf,E=t.sqrt(t.neg(e));w=(U,O)=>{let V=t.sqr(O),k=t.mul(U,O);V=t.mul(V,k);let K=t.pow(V,_);K=t.mul(K,k);let F=t.mul(K,E),M=t.mul(t.sqr(K),O),z=t.eql(M,U),Y=t.cmov(F,K,z);return{isValid:z,value:Y}}}return w}function ea(t,e){if(es(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let r=Ep(t,e.Z);if(!t.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,s,o,a,c,f,l,d;i=t.sqr(n),i=t.mul(i,e.Z),s=t.sqr(i),s=t.add(s,i),o=t.add(s,t.ONE),o=t.mul(o,e.B),a=t.cmov(e.Z,t.neg(s),!t.eql(s,t.ZERO)),a=t.mul(a,e.A),s=t.sqr(o),f=t.sqr(a),c=t.mul(f,e.A),s=t.add(s,c),s=t.mul(s,o),f=t.mul(f,a),c=t.mul(f,e.B),s=t.add(s,c),l=t.mul(i,o);let{isValid:v,value:w}=r(s,f);d=t.mul(i,n),d=t.mul(d,w),l=t.cmov(l,o,v),d=t.cmov(d,w,v);let _=t.isOdd(n)===t.isOdd(d);return d=t.cmov(t.neg(d),d,_),l=t.div(l,a),{x:l,y:d}}}var eg,tg,Ur,Le,mr,is,Pf,ta=we(()=>{hr();Gt();Gt();Lo();({bytesToNumberBE:eg,hexToBytes:tg}=Di),Ur=BigInt(0),Le=BigInt(1),mr=BigInt(2),is=BigInt(3),Pf=BigInt(4)});function kf(t){let{Fp:e,Fr:r,Fp2:n,Fp6:i,Fp12:s}=t.fields,o=lr(t.params.x);function a(Z){let{x:ue,y:j}=Z,C=ue,X=j,D=n.ONE,ne=C,I=X,m=D,fe=[];for(let ie=o-2;ie>=0;ie--){let se=n.sqr(I),Q=n.sqr(m),u=n.multiplyByB(n.mul(Q,ss)),h=n.mul(u,ss),p=n.sub(n.sub(n.sqr(n.add(I,m)),Q),se);if(fe.push([n.sub(u,se),n.mul(n.sqr(ne),ss),n.neg(p)]),ne=n.div(n.mul(n.mul(n.sub(se,h),ne),I),ra),I=n.sub(n.sqr(n.div(n.add(se,h),ra)),n.mul(n.sqr(u),ss)),m=n.mul(se,p),rn(t.params.x,ie)){let T=n.sub(I,n.mul(X,m)),x=n.sub(ne,n.mul(C,m));fe.push([n.sub(n.mul(T,C),n.mul(x,X)),n.neg(T),x]);let A=n.sqr(x),N=n.mul(A,x),g=n.mul(A,ne),B=n.add(n.sub(N,n.mul(g,ra)),n.mul(n.sqr(T),m));ne=n.mul(x,B),I=n.sub(n.mul(n.sub(g,B),T),n.mul(N,I)),m=n.mul(m,N)}}return fe}function c(Z,ue){let{x:j}=t.params,C=ue[0],X=ue[1],D=s.ONE;for(let ne=0,I=o-2;I>=0;I--,ne++){let m=Z[ne];if(D=s.multiplyBy014(D,m[0],n.mul(m[1],C),n.mul(m[2],X)),rn(j,I)){ne+=1;let fe=Z[ne];D=s.multiplyBy014(D,fe[0],n.mul(fe[1],C),n.mul(fe[2],X))}I!==0&&(D=s.sqr(D))}return s.conjugate(D)}let f={randomPrivateKey:()=>{let Z=ts(r.ORDER);return Ko(t.randomBytes(Z),r.ORDER)},calcPairingPrecomputes:a},l=Do({n:r.ORDER,...t.G1}),d=Object.assign(l,Xo(l.ProjectivePoint,t.G1.mapToCurve,{...t.htfDefaults,...t.G1.htfDefaults}));function v(Z){let ue=Z;return ue._PPRECOMPUTES||(ue._PPRECOMPUTES=a(Z.toAffine())),ue._PPRECOMPUTES}let w=Do({n:r.ORDER,...t.G2}),_=Object.assign(w,Xo(w.ProjectivePoint,t.G2.mapToCurve,{...t.htfDefaults,...t.G2.htfDefaults})),{ShortSignature:E}=t.G1,{Signature:U}=t.G2;function O(Z,ue,j=!0){if(Z.equals(d.ProjectivePoint.ZERO)||ue.equals(_.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");Z.assertValidity(),ue.assertValidity();let C=Z.toAffine(),X=c(v(ue),[C.x,C.y]);return j?s.finalExponentiate(X):X}function V(Z){return Z instanceof d.ProjectivePoint?Z:d.ProjectivePoint.fromHex(Z)}function k(Z,ue){return Z instanceof d.ProjectivePoint?Z:d.hashToCurve(je("point",Z),ue)}function K(Z){return Z instanceof _.ProjectivePoint?Z:U.fromHex(Z)}function F(Z,ue){return Z instanceof _.ProjectivePoint?Z:_.hashToCurve(je("point",Z),ue)}function M(Z){return d.ProjectivePoint.fromPrivateKey(Z).toRawBytes(!0)}function z(Z){return _.ProjectivePoint.fromPrivateKey(Z).toRawBytes(!0)}function Y(Z,ue,j){let C=F(Z,j);C.assertValidity();let X=C.multiply(d.normPrivateKeyToScalar(ue));return Z instanceof _.ProjectivePoint?X:U.toRawBytes(X)}function G(Z,ue,j){let C=k(Z,j);C.assertValidity();let X=C.multiply(d.normPrivateKeyToScalar(ue));return Z instanceof d.ProjectivePoint?X:E.toRawBytes(X)}function ee(Z,ue,j,C){let X=V(j),D=F(ue,C),ne=d.ProjectivePoint.BASE,I=K(Z),m=O(X.negate(),D,!1),fe=O(ne,I,!1),ie=s.finalExponentiate(s.mul(fe,m));return s.eql(ie,s.ONE)}function L(Z,ue,j,C){let X=K(j),D=k(ue,C),ne=_.ProjectivePoint.BASE,I=V(Z),m=O(D,X,!1),fe=O(I,ne.negate(),!1),ie=s.finalExponentiate(s.mul(fe,m));return s.eql(ie,s.ONE)}function ce(Z){if(!Z.length)throw new Error("Expected non-empty array");let j=Z.map(V).reduce((C,X)=>C.add(X),d.ProjectivePoint.ZERO);return Z[0]instanceof d.ProjectivePoint?(j.assertValidity(),j):j.toRawBytes(!0)}function le(Z){if(!Z.length)throw new Error("Expected non-empty array");let j=Z.map(K).reduce((C,X)=>C.add(X),_.ProjectivePoint.ZERO);return Z[0]instanceof _.ProjectivePoint?(j.assertValidity(),j):U.toRawBytes(j)}function xe(Z){if(!Z.length)throw new Error("Expected non-empty array");let j=Z.map(V).reduce((C,X)=>C.add(X),d.ProjectivePoint.ZERO);return Z[0]instanceof d.ProjectivePoint?(j.assertValidity(),j):E.toRawBytes(j)}function me(Z,ue,j,C){if(!ue.length)throw new Error("Expected non-empty messages array");if(j.length!==ue.length)throw new Error("Pubkey count should equal msg count");let X=K(Z),D=ue.map(I=>F(I,C)),ne=j.map(V);try{let I=[];for(let ie of new Set(D)){let se=D.reduce((Q,u,h)=>u===ie?Q.add(ne[h]):Q,d.ProjectivePoint.ZERO);I.push(O(se,ie,!1))}I.push(O(d.ProjectivePoint.BASE.negate(),X,!1));let m=I.reduce((ie,se)=>s.mul(ie,se),s.ONE),fe=s.finalExponentiate(m);return s.eql(fe,s.ONE)}catch{return!1}}return d.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:M,getPublicKeyForShortSignatures:z,sign:Y,signShortSignature:G,verify:ee,verifyBatch:me,verifyShortSignature:L,aggregatePublicKeys:ce,aggregateSignatures:le,aggregateShortSignatures:xe,millerLoop:c,pairing:O,G1:d,G2:_,Signature:U,ShortSignature:E,fields:{Fr:r,Fp:e,Fp2:n,Fp6:i,Fp12:s},params:{x:t.params.x,r:t.params.r,G1b:t.G1.b,G2b:t.G2.b},utils:f}}var ra,ss,Mf=we(()=>{hr();Gt();Jo();ta();ra=BigInt(2),ss=BigInt(3)});function na(t,e){let r=y.sqr(t),n=y.sqr(e);return{first:y.add(y.mulByNonresidue(n),r),second:y.sub(y.sub(y.sqr(y.add(t,e)),r),n)}}function Cp(t,e){let r=oe.mul(oe.frobeniusMap(oe.multiplyByFp2(kp,t),1),e0).c0.c0,n=oe.mul(oe.frobeniusMap(oe.multiplyByFp2(Mp,e),1),t0).c0.c0;return[r,n]}function Jf(t,e){let r=e.toAffine(),n=Cp(r.x,r.y);return new t(n[0],n[1],y.ONE)}function Vp(t,e){return[y.mul(t,qp),y.neg(e)]}function $p(t,e){let r=e.toAffine(),n=Vp(r.x,r.y);return new t(n[0],n[1],y.ONE)}function cs(t){t=t.slice();let e=t[0]&224,r=!!(e>>7&1),n=!!(e>>6&1),i=!!(e>>5&1);return t[0]&=31,{compressed:r,infinity:n,sort:i,value:t}}function Vn(t,e){if(t[0]&224)throw new Error("setMask: non-empty mask");return e.compressed&&(t[0]|=128),e.infinity&&(t[0]|=64),e.sort&&(t[0]|=32),t}function Qf(t){t.assertValidity();let e=t.equals(De.G1.ProjectivePoint.ZERO),{x:r,y:n}=t.toAffine();if(e)return us.slice();let i=q.ORDER,s=!!(n*Me/i);return Vn(qe(r,q.BYTES),{compressed:!0,sort:s})}function Lf(t){t.assertValidity();let e=q.BYTES;if(t.equals(De.G2.ProjectivePoint.ZERO))return Ne(us,qe(Ye,e));let{x:r,y:n}=t.toAffine(),{re:i,im:s}=y.reim(r),{re:o,im:a}=y.reim(n),f=!!((a>Ye?a*Me:o*Me)/q.ORDER&Fr),l=i;return Ne(Vn(qe(s,e),{sort:f,compressed:!0}),qe(l,e))}var Ye,Fr,Me,os,qn,Bp,vp,sa,q,Cf,qf,Vf,$f,Gf,as,y,Ap,yr,Tp,Hf,jf,Yf,zf,J,Sp,Np,oa,Rp,Kf,Zf,Wf,Xf,oe,Ip,Op,Up,Fp,Pp,Df,e0,t0,kp,Mp,qp,ia,us,De,r0=we(()=>{ai();$r();Mf();hr();Gt();ta();Jo();Ye=BigInt(0),Fr=BigInt(1),Me=BigInt(2),os=BigInt(3),qn=BigInt(4),Bp=BigInt(8),vp=BigInt(16),sa=BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),q=Cn(sa),Cf=Cn(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),qf=({c0:t,c1:e},{c0:r,c1:n})=>({c0:q.add(t,r),c1:q.add(e,n)}),Vf=({c0:t,c1:e},{c0:r,c1:n})=>({c0:q.sub(t,r),c1:q.sub(e,n)}),$f=({c0:t,c1:e},r)=>{if(typeof r=="bigint")return{c0:q.mul(t,r),c1:q.mul(e,r)};let{c0:n,c1:i}=r,s=q.mul(t,n),o=q.mul(e,i),a=q.sub(s,o),c=q.sub(q.mul(q.add(t,e),q.add(n,i)),q.add(s,o));return{c0:a,c1:c}},Gf=({c0:t,c1:e})=>{let r=q.add(t,e),n=q.sub(t,e),i=q.add(t,t);return{c0:q.mul(r,n),c1:q.mul(i,e)}},as=sa*sa,y={ORDER:as,BITS:lr(as),BYTES:Math.ceil(lr(as)/8),MASK:dr(lr(as)),ZERO:{c0:q.ZERO,c1:q.ZERO},ONE:{c0:q.ONE,c1:q.ZERO},create:t=>t,isValid:({c0:t,c1:e})=>typeof t=="bigint"&&typeof e=="bigint",is0:({c0:t,c1:e})=>q.is0(t)&&q.is0(e),eql:({c0:t,c1:e},{c0:r,c1:n})=>q.eql(t,r)&&q.eql(e,n),neg:({c0:t,c1:e})=>({c0:q.neg(t),c1:q.neg(e)}),pow:(t,e)=>kn(y,t,e),invertBatch:t=>Mn(y,t),add:qf,sub:Vf,mul:$f,sqr:Gf,addN:qf,subN:Vf,mulN:$f,sqrN:Gf,div:(t,e)=>y.mul(t,typeof e=="bigint"?q.inv(q.create(e)):y.inv(e)),inv:({c0:t,c1:e})=>{let r=q.inv(q.create(t*t+e*e));return{c0:q.mul(r,q.create(t)),c1:q.mul(r,q.create(-e))}},sqrt:t=>{if(y.eql(t,y.ZERO))return y.ZERO;let e=y.pow(t,(y.ORDER+Bp)/vp),r=y.div(y.sqr(e),t),n=Tp,i=[n[0],n[2],n[4],n[6]].find(w=>y.eql(w,r));if(!i)throw new Error("No root");let s=n.indexOf(i),o=n[s/2];if(!o)throw new Error("Invalid root");let a=y.div(e,o),c=y.neg(a),{re:f,im:l}=y.reim(a),{re:d,im:v}=y.reim(c);return l>v||l===v&&f>d?a:c},isOdd:t=>{let{re:e,im:r}=y.reim(t),n=e%Me,i=e===Ye,s=r%Me;return BigInt(n||i&&s)==Fr},fromBytes(t){if(t.length!==y.BYTES)throw new Error(`fromBytes wrong length=${t.length}`);return{c0:q.fromBytes(t.subarray(0,q.BYTES)),c1:q.fromBytes(t.subarray(q.BYTES))}},toBytes:({c0:t,c1:e})=>Ne(q.toBytes(t),q.toBytes(e)),cmov:({c0:t,c1:e},{c0:r,c1:n},i)=>({c0:q.cmov(t,r,i),c1:q.cmov(e,n,i)}),reim:({c0:t,c1:e})=>({re:t,im:e}),mulByNonresidue:({c0:t,c1:e})=>({c0:q.sub(t,e),c1:q.add(t,e)}),multiplyByB:({c0:t,c1:e})=>{let r=q.mul(t,qn),n=q.mul(e,qn);return{c0:q.sub(r,n),c1:q.add(r,n)}},fromBigTuple:t=>{if(t.length!==2)throw new Error("Invalid tuple");let e=t.map(r=>q.create(r));return{c0:e[0],c1:e[1]}},frobeniusMap:({c0:t,c1:e},r)=>({c0:t,c1:q.mul(e,Ap[r%2])})},Ap=[BigInt("0x1"),BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa")].map(t=>q.create(t)),yr=BigInt("0x6af0e0437ff400b6831e36d6bd17ffe48395dabc2d3435e77f76e17009241c5ee67992f72ec05f4c81084fbede3cc09"),Tp=[[Fr,Ye],[yr,-yr],[Ye,Fr],[yr,yr],[-Fr,Ye],[-yr,yr],[Ye,-Fr],[-yr,-yr]].map(t=>y.fromBigTuple(t)),Hf=({c0:t,c1:e,c2:r},{c0:n,c1:i,c2:s})=>({c0:y.add(t,n),c1:y.add(e,i),c2:y.add(r,s)}),jf=({c0:t,c1:e,c2:r},{c0:n,c1:i,c2:s})=>({c0:y.sub(t,n),c1:y.sub(e,i),c2:y.sub(r,s)}),Yf=({c0:t,c1:e,c2:r},n)=>{if(typeof n=="bigint")return{c0:y.mul(t,n),c1:y.mul(e,n),c2:y.mul(r,n)};let{c0:i,c1:s,c2:o}=n,a=y.mul(t,i),c=y.mul(e,s),f=y.mul(r,o);return{c0:y.add(a,y.mulByNonresidue(y.sub(y.mul(y.add(e,r),y.add(s,o)),y.add(c,f)))),c1:y.add(y.sub(y.mul(y.add(t,e),y.add(i,s)),y.add(a,c)),y.mulByNonresidue(f)),c2:y.sub(y.add(c,y.mul(y.add(t,r),y.add(i,o))),y.add(a,f))}},zf=({c0:t,c1:e,c2:r})=>{let n=y.sqr(t),i=y.mul(y.mul(t,e),Me),s=y.mul(y.mul(e,r),Me),o=y.sqr(r);return{c0:y.add(y.mulByNonresidue(s),n),c1:y.add(y.mulByNonresidue(o),i),c2:y.sub(y.sub(y.add(y.add(i,y.sqr(y.add(y.sub(t,e),r))),s),n),o)}},J={ORDER:y.ORDER,BITS:3*y.BITS,BYTES:3*y.BYTES,MASK:dr(3*y.BITS),ZERO:{c0:y.ZERO,c1:y.ZERO,c2:y.ZERO},ONE:{c0:y.ONE,c1:y.ZERO,c2:y.ZERO},create:t=>t,isValid:({c0:t,c1:e,c2:r})=>y.isValid(t)&&y.isValid(e)&&y.isValid(r),is0:({c0:t,c1:e,c2:r})=>y.is0(t)&&y.is0(e)&&y.is0(r),neg:({c0:t,c1:e,c2:r})=>({c0:y.neg(t),c1:y.neg(e),c2:y.neg(r)}),eql:({c0:t,c1:e,c2:r},{c0:n,c1:i,c2:s})=>y.eql(t,n)&&y.eql(e,i)&&y.eql(r,s),sqrt:()=>{throw new Error("Not implemented")},div:(t,e)=>J.mul(t,typeof e=="bigint"?q.inv(q.create(e)):J.inv(e)),pow:(t,e)=>kn(J,t,e),invertBatch:t=>Mn(J,t),add:Hf,sub:jf,mul:Yf,sqr:zf,addN:Hf,subN:jf,mulN:Yf,sqrN:zf,inv:({c0:t,c1:e,c2:r})=>{let n=y.sub(y.sqr(t),y.mulByNonresidue(y.mul(r,e))),i=y.sub(y.mulByNonresidue(y.sqr(r)),y.mul(t,e)),s=y.sub(y.sqr(e),y.mul(t,r)),o=y.inv(y.add(y.mulByNonresidue(y.add(y.mul(r,i),y.mul(e,s))),y.mul(t,n)));return{c0:y.mul(o,n),c1:y.mul(o,i),c2:y.mul(o,s)}},fromBytes:t=>{if(t.length!==J.BYTES)throw new Error(`fromBytes wrong length=${t.length}`);return{c0:y.fromBytes(t.subarray(0,y.BYTES)),c1:y.fromBytes(t.subarray(y.BYTES,2*y.BYTES)),c2:y.fromBytes(t.subarray(2*y.BYTES))}},toBytes:({c0:t,c1:e,c2:r})=>Ne(y.toBytes(t),y.toBytes(e),y.toBytes(r)),cmov:({c0:t,c1:e,c2:r},{c0:n,c1:i,c2:s},o)=>({c0:y.cmov(t,n,o),c1:y.cmov(e,i,o),c2:y.cmov(r,s,o)}),fromBigSix:t=>{if(!Array.isArray(t)||t.length!==6)throw new Error("Invalid Fp6 usage");return{c0:y.fromBigTuple(t.slice(0,2)),c1:y.fromBigTuple(t.slice(2,4)),c2:y.fromBigTuple(t.slice(4,6))}},frobeniusMap:({c0:t,c1:e,c2:r},n)=>({c0:y.frobeniusMap(t,n),c1:y.mul(y.frobeniusMap(e,n),Sp[n%6]),c2:y.mul(y.frobeniusMap(r,n),Np[n%6])}),mulByNonresidue:({c0:t,c1:e,c2:r})=>({c0:y.mulByNonresidue(r),c1:t,c2:e}),multiplyBy1:({c0:t,c1:e,c2:r},n)=>({c0:y.mulByNonresidue(y.mul(r,n)),c1:y.mul(t,n),c2:y.mul(e,n)}),multiplyBy01({c0:t,c1:e,c2:r},n,i){let s=y.mul(t,n),o=y.mul(e,i);return{c0:y.add(y.mulByNonresidue(y.sub(y.mul(y.add(e,r),i),o)),s),c1:y.sub(y.sub(y.mul(y.add(n,i),y.add(t,e)),s),o),c2:y.add(y.sub(y.mul(y.add(t,r),n),s),o)}},multiplyByFp2:({c0:t,c1:e,c2:r},n)=>({c0:y.mul(t,n),c1:y.mul(e,n),c2:y.mul(r,n)})},Sp=[[BigInt("0x1"),BigInt("0x0")],[BigInt("0x0"),BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac")],[BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),BigInt("0x0")],[BigInt("0x0"),BigInt("0x1")],[BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac"),BigInt("0x0")],[BigInt("0x0"),BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe")]].map(t=>y.fromBigTuple(t)),Np=[[BigInt("0x1"),BigInt("0x0")],[BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaad"),BigInt("0x0")],[BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac"),BigInt("0x0")],[BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa"),BigInt("0x0")],[BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),BigInt("0x0")],[BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffeffff"),BigInt("0x0")]].map(t=>y.fromBigTuple(t)),oa=BigInt("0xd201000000010000"),Rp=lr(oa),Kf=({c0:t,c1:e},{c0:r,c1:n})=>({c0:J.add(t,r),c1:J.add(e,n)}),Zf=({c0:t,c1:e},{c0:r,c1:n})=>({c0:J.sub(t,r),c1:J.sub(e,n)}),Wf=({c0:t,c1:e},r)=>{if(typeof r=="bigint")return{c0:J.mul(t,r),c1:J.mul(e,r)};let{c0:n,c1:i}=r,s=J.mul(t,n),o=J.mul(e,i);return{c0:J.add(s,J.mulByNonresidue(o)),c1:J.sub(J.mul(J.add(t,e),J.add(n,i)),J.add(s,o))}},Xf=({c0:t,c1:e})=>{let r=J.mul(t,e);return{c0:J.sub(J.sub(J.mul(J.add(J.mulByNonresidue(e),t),J.add(t,e)),r),J.mulByNonresidue(r)),c1:J.add(r,r)}};oe={ORDER:y.ORDER,BITS:2*y.BITS,BYTES:2*y.BYTES,MASK:dr(2*y.BITS),ZERO:{c0:J.ZERO,c1:J.ZERO},ONE:{c0:J.ONE,c1:J.ZERO},create:t=>t,isValid:({c0:t,c1:e})=>J.isValid(t)&&J.isValid(e),is0:({c0:t,c1:e})=>J.is0(t)&&J.is0(e),neg:({c0:t,c1:e})=>({c0:J.neg(t),c1:J.neg(e)}),eql:({c0:t,c1:e},{c0:r,c1:n})=>J.eql(t,r)&&J.eql(e,n),sqrt:()=>{throw new Error("Not implemented")},inv:({c0:t,c1:e})=>{let r=J.inv(J.sub(J.sqr(t),J.mulByNonresidue(J.sqr(e))));return{c0:J.mul(t,r),c1:J.neg(J.mul(e,r))}},div:(t,e)=>oe.mul(t,typeof e=="bigint"?q.inv(q.create(e)):oe.inv(e)),pow:(t,e)=>kn(oe,t,e),invertBatch:t=>Mn(oe,t),add:Kf,sub:Zf,mul:Wf,sqr:Xf,addN:Kf,subN:Zf,mulN:Wf,sqrN:Xf,fromBytes:t=>{if(t.length!==oe.BYTES)throw new Error(`fromBytes wrong length=${t.length}`);return{c0:J.fromBytes(t.subarray(0,J.BYTES)),c1:J.fromBytes(t.subarray(J.BYTES))}},toBytes:({c0:t,c1:e})=>Ne(J.toBytes(t),J.toBytes(e)),cmov:({c0:t,c1:e},{c0:r,c1:n},i)=>({c0:J.cmov(t,r,i),c1:J.cmov(e,n,i)}),fromBigTwelve:t=>({c0:J.fromBigSix(t.slice(0,6)),c1:J.fromBigSix(t.slice(6,12))}),frobeniusMap(t,e){let r=J.frobeniusMap(t.c0,e),{c0:n,c1:i,c2:s}=J.frobeniusMap(t.c1,e),o=Ip[e%12];return{c0:r,c1:J.create({c0:y.mul(n,o),c1:y.mul(i,o),c2:y.mul(s,o)})}},multiplyBy014:({c0:t,c1:e},r,n,i)=>{let s=J.multiplyBy01(t,r,n),o=J.multiplyBy1(e,i);return{c0:J.add(J.mulByNonresidue(o),s),c1:J.sub(J.sub(J.multiplyBy01(J.add(e,t),r,y.add(n,i)),s),o)}},multiplyByFp2:({c0:t,c1:e},r)=>({c0:J.multiplyByFp2(t,r),c1:J.multiplyByFp2(e,r)}),conjugate:({c0:t,c1:e})=>({c0:t,c1:J.neg(e)}),_cyclotomicSquare:({c0:t,c1:e})=>{let{c0:r,c1:n,c2:i}=t,{c0:s,c1:o,c2:a}=e,{first:c,second:f}=na(r,o),{first:l,second:d}=na(s,i),{first:v,second:w}=na(n,a),_=y.mulByNonresidue(w);return{c0:J.create({c0:y.add(y.mul(y.sub(c,r),Me),c),c1:y.add(y.mul(y.sub(l,n),Me),l),c2:y.add(y.mul(y.sub(v,i),Me),v)}),c1:J.create({c0:y.add(y.mul(y.add(_,s),Me),_),c1:y.add(y.mul(y.add(f,o),Me),f),c2:y.add(y.mul(y.add(d,a),Me),d)})}},_cyclotomicExp(t,e){let r=oe.ONE;for(let n=Rp-1;n>=0;n--)r=oe._cyclotomicSquare(r),rn(e,n)&&(r=oe.mul(r,t));return r},finalExponentiate:t=>{let e=oa,r=oe.div(oe.frobeniusMap(t,6),t),n=oe.mul(oe.frobeniusMap(r,2),r),i=oe.conjugate(oe._cyclotomicExp(n,e)),s=oe.mul(oe.conjugate(oe._cyclotomicSquare(n)),i),o=oe.conjugate(oe._cyclotomicExp(s,e)),a=oe.conjugate(oe._cyclotomicExp(o,e)),c=oe.mul(oe.conjugate(oe._cyclotomicExp(a,e)),oe._cyclotomicSquare(i)),f=oe.conjugate(oe._cyclotomicExp(c,e)),l=oe.frobeniusMap(oe.mul(i,a),2),d=oe.frobeniusMap(oe.mul(o,n),3),v=oe.frobeniusMap(oe.mul(c,oe.conjugate(n)),1),w=oe.mul(oe.mul(f,oe.conjugate(s)),n);return oe.mul(oe.mul(oe.mul(l,d),v),w)}},Ip=[[BigInt("0x1"),BigInt("0x0")],[BigInt("0x1904d3bf02bb0667c231beb4202c0d1f0fd603fd3cbd5f4f7b2443d784bab9c4f67ea53d63e7813d8d0775ed92235fb8"),BigInt("0x00fc3e2b36c4e03288e9e902231f9fb854a14787b6c7b36fec0c8ec971f63c5f282d5ac14d6c7ec22cf78a126ddc4af3")],[BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffeffff"),BigInt("0x0")],[BigInt("0x135203e60180a68ee2e9c448d77a2cd91c3dedd930b1cf60ef396489f61eb45e304466cf3e67fa0af1ee7b04121bdea2"),BigInt("0x06af0e0437ff400b6831e36d6bd17ffe48395dabc2d3435e77f76e17009241c5ee67992f72ec05f4c81084fbede3cc09")],[BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),BigInt("0x0")],[BigInt("0x144e4211384586c16bd3ad4afa99cc9170df3560e77982d0db45f3536814f0bd5871c1908bd478cd1ee605167ff82995"),BigInt("0x05b2cfd9013a5fd8df47fa6b48b1e045f39816240c0b8fee8beadf4d8e9c0566c63a3e6e257f87329b18fae980078116")],[BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa"),BigInt("0x0")],[BigInt("0x00fc3e2b36c4e03288e9e902231f9fb854a14787b6c7b36fec0c8ec971f63c5f282d5ac14d6c7ec22cf78a126ddc4af3"),BigInt("0x1904d3bf02bb0667c231beb4202c0d1f0fd603fd3cbd5f4f7b2443d784bab9c4f67ea53d63e7813d8d0775ed92235fb8")],[BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac"),BigInt("0x0")],[BigInt("0x06af0e0437ff400b6831e36d6bd17ffe48395dabc2d3435e77f76e17009241c5ee67992f72ec05f4c81084fbede3cc09"),BigInt("0x135203e60180a68ee2e9c448d77a2cd91c3dedd930b1cf60ef396489f61eb45e304466cf3e67fa0af1ee7b04121bdea2")],[BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaad"),BigInt("0x0")],[BigInt("0x05b2cfd9013a5fd8df47fa6b48b1e045f39816240c0b8fee8beadf4d8e9c0566c63a3e6e257f87329b18fae980078116"),BigInt("0x144e4211384586c16bd3ad4afa99cc9170df3560e77982d0db45f3536814f0bd5871c1908bd478cd1ee605167ff82995")]].map(t=>y.fromBigTuple(t)),Op=Wo(y,[[["0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6"],["0x0","0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71a"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71e","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38d"],["0x171d6541fa38ccfaed6dea691f5fb614cb14b4e7f4e810aa22d6108f142b85757098e38d0f671c7188e2aaaaaaaa5ed1","0x0"]],[["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa63"],["0xc","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa9f"],["0x1","0x0"]],[["0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706","0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706"],["0x0","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97be"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71c","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38f"],["0x124c9ad43b6cf79bfbf7043de3811ad0761b0f37a1e26286b0e977c69aa274524e79097a56dc4bd9e1b371c71c718b10","0x0"]],[["0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb"],["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa9d3"],["0x12","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa99"],["0x1","0x0"]]].map(t=>t.map(e=>y.fromBigTuple(e.map(BigInt))))),Up=Wo(q,[["0x11a05f2b1e833340b809101dd99815856b303e88a2d7005ff2627b56cdb4e2c85610c2d5f2e62d6eaeac1662734649b7","0x17294ed3e943ab2f0588bab22147a81c7c17e75b2f6a8417f565e33c70d1e86b4838f2a6f318c356e834eef1b3cb83bb","0xd54005db97678ec1d1048c5d10a9a1bce032473295983e56878e501ec68e25c958c3e3d2a09729fe0179f9dac9edcb0","0x1778e7166fcc6db74e0609d307e55412d7f5e4656a8dbf25f1b33289f1b330835336e25ce3107193c5b388641d9b6861","0xe99726a3199f4436642b4b3e4118e5499db995a1257fb3f086eeb65982fac18985a286f301e77c451154ce9ac8895d9","0x1630c3250d7313ff01d1201bf7a74ab5db3cb17dd952799b9ed3ab9097e68f90a0870d2dcae73d19cd13c1c66f652983","0xd6ed6553fe44d296a3726c38ae652bfb11586264f0f8ce19008e218f9c86b2a8da25128c1052ecaddd7f225a139ed84","0x17b81e7701abdbe2e8743884d1117e53356de5ab275b4db1a682c62ef0f2753339b7c8f8c8f475af9ccb5618e3f0c88e","0x80d3cf1f9a78fc47b90b33563be990dc43b756ce79f5574a2c596c928c5d1de4fa295f296b74e956d71986a8497e317","0x169b1f8e1bcfa7c42e0c37515d138f22dd2ecb803a0c5c99676314baf4bb1b7fa3190b2edc0327797f241067be390c9e","0x10321da079ce07e272d8ec09d2565b0dfa7dccdde6787f96d50af36003b14866f69b771f8c285decca67df3f1605fb7b","0x6e08c248e260e70bd1e962381edee3d31d79d7e22c837bc23c0bf1bc24c6b68c24b1b80b64d391fa9c8ba2e8ba2d229"],["0x8ca8d548cff19ae18b2e62f4bd3fa6f01d5ef4ba35b48ba9c9588617fc8ac62b558d681be343df8993cf9fa40d21b1c","0x12561a5deb559c4348b4711298e536367041e8ca0cf0800c0126c2588c48bf5713daa8846cb026e9e5c8276ec82b3bff","0xb2962fe57a3225e8137e629bff2991f6f89416f5a718cd1fca64e00b11aceacd6a3d0967c94fedcfcc239ba5cb83e19","0x3425581a58ae2fec83aafef7c40eb545b08243f16b1655154cca8abc28d6fd04976d5243eecf5c4130de8938dc62cd8","0x13a8e162022914a80a6f1d5f43e7a07dffdfc759a12062bb8d6b44e833b306da9bd29ba81f35781d539d395b3532a21e","0xe7355f8e4e667b955390f7f0506c6e9395735e9ce9cad4d0a43bcef24b8982f7400d24bc4228f11c02df9a29f6304a5","0x772caacf16936190f3e0c63e0596721570f5799af53a1894e2e073062aede9cea73b3538f0de06cec2574496ee84a3a","0x14a7ac2a9d64a8b230b3f5b074cf01996e7f63c21bca68a81996e1cdf9822c580fa5b9489d11e2d311f7d99bbdcc5a5e","0xa10ecf6ada54f825e920b3dafc7a3cce07f8d1d7161366b74100da67f39883503826692abba43704776ec3a79a1d641","0x95fc13ab9e92ad4476d6e3eb3a56680f682b4ee96f7d03776df533978f31c1593174e4b4b7865002d6384d168ecdd0a","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"],["0x90d97c81ba24ee0259d1f094980dcfa11ad138e48a869522b52af6c956543d3cd0c7aee9b3ba3c2be9845719707bb33","0x134996a104ee5811d51036d776fb46831223e96c254f383d0f906343eb67ad34d6c56711962fa8bfe097e75a2e41c696","0xcc786baa966e66f4a384c86a3b49942552e2d658a31ce2c344be4b91400da7d26d521628b00523b8dfe240c72de1f6","0x1f86376e8981c217898751ad8746757d42aa7b90eeb791c09e4a3ec03251cf9de405aba9ec61deca6355c77b0e5f4cb","0x8cc03fdefe0ff135caf4fe2a21529c4195536fbe3ce50b879833fd221351adc2ee7f8dc099040a841b6daecf2e8fedb","0x16603fca40634b6a2211e11db8f0a6a074a7d0d4afadb7bd76505c3d3ad5544e203f6326c95a807299b23ab13633a5f0","0x4ab0b9bcfac1bbcb2c977d027796b3ce75bb8ca2be184cb5231413c4d634f3747a87ac2460f415ec961f8855fe9d6f2","0x987c8d5333ab86fde9926bd2ca6c674170a05bfe3bdd81ffd038da6c26c842642f64550fedfe935a15e4ca31870fb29","0x9fc4018bd96684be88c9e221e4da1bb8f3abd16679dc26c1e8b6e6a1f20cabe69d65201c78607a360370e577bdba587","0xe1bba7a1186bdb5223abde7ada14a23c42a0ca7915af6fe06985e7ed1e4d43b9b3f7055dd4eba6f2bafaaebca731c30","0x19713e47937cd1be0dfd0b8f1d43fb93cd2fcbcb6caf493fd1183e416389e61031bf3a5cce3fbafce813711ad011c132","0x18b46a908f36f6deb918c143fed2edcc523559b8aaf0c2462e6bfe7f911f643249d9cdf41b44d606ce07c8a4d0074d8e","0xb182cac101b9399d155096004f53f447aa7b12a3426b08ec02710e807b4633f06c851c1919211f20d4c04f00b971ef8","0x245a394ad1eca9b72fc00ae7be315dc757b3b080d4c158013e6632d3c40659cc6cf90ad1c232a6442d9d3f5db980133","0x5c129645e44cf1102a159f748c4a3fc5e673d81d7e86568d9ab0f5d396a7ce46ba1049b6579afb7866b1e715475224b","0x15e6be4e990f03ce4ea50b3b42df2eb5cb181d8f84965a3957add4fa95af01b2b665027efec01c7704b456be69c8b604"],["0x16112c4c3a9c98b252181140fad0eae9601a6de578980be6eec3232b5be72e7a07f3688ef60c206d01479253b03663c1","0x1962d75c2381201e1a0cbd6c43c348b885c84ff731c4d59ca4a10356f453e01f78a4260763529e3532f6102c2e49a03d","0x58df3306640da276faaae7d6e8eb15778c4855551ae7f310c35a5dd279cd2eca6757cd636f96f891e2538b53dbf67f2","0x16b7d288798e5395f20d23bf89edb4d1d115c5dbddbcd30e123da489e726af41727364f2c28297ada8d26d98445f5416","0xbe0e079545f43e4b00cc912f8228ddcc6d19c9f0f69bbb0542eda0fc9dec916a20b15dc0fd2ededda39142311a5001d","0x8d9e5297186db2d9fb266eaac783182b70152c65550d881c5ecd87b6f0f5a6449f38db9dfa9cce202c6477faaf9b7ac","0x166007c08a99db2fc3ba8734ace9824b5eecfdfa8d0cf8ef5dd365bc400a0051d5fa9c01a58b1fb93d1a1399126a775c","0x16a3ef08be3ea7ea03bcddfabba6ff6ee5a4375efa1f4fd7feb34fd206357132b920f5b00801dee460ee415a15812ed9","0x1866c8ed336c61231a1be54fd1d74cc4f9fb0ce4c6af5920abc5750c4bf39b4852cfe2f7bb9248836b233d9d55535d4a","0x167a55cda70a6e1cea820597d94a84903216f763e13d87bb5308592e7ea7d4fbc7385ea3d529b35e346ef48bb8913f55","0x4d2f259eea405bd48f010a01ad2911d9c6dd039bb61a6290e591b36e636a5c871a5c29f4f83060400f8b49cba8f6aa8","0xaccbb67481d033ff5852c1e48c50c477f94ff8aefce42d28c0f9a88cea7913516f968986f7ebbea9684b529e2561092","0xad6b9514c767fe3c3613144b45f1496543346d98adf02267d5ceef9a00d9b8693000763e3b90ac11e99b138573345cc","0x2660400eb2e4f3b628bdd0d53cd76f2bf565b94e72927c1cb748df27942480e420517bd8714cc80d1fadc1326ed06f7","0xe0fa1d816ddc03e6b24255e0d7819c171c40f65e273b853324efcd6356caa205ca2f570f13497804415473a1d634b8f","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"]].map(t=>t.map(e=>BigInt(e)))),Fp=ea(y,{A:y.create({c0:q.create(Ye),c1:q.create(BigInt(240))}),B:y.create({c0:q.create(BigInt(1012)),c1:q.create(BigInt(1012))}),Z:y.create({c0:q.create(BigInt(-2)),c1:q.create(BigInt(-1))})}),Pp=ea(q,{A:q.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:q.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:q.create(BigInt(11))}),Df=J.create({c0:y.ZERO,c1:y.ONE,c2:y.ZERO}),e0=oe.create({c0:Df,c1:J.ZERO}),t0=oe.create({c0:J.ZERO,c1:Df}),[kp,Mp]=oe.invertBatch([e0,t0]);qp=BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac");ia=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:q.ORDER,m:2,k:128,expand:"xmd",hash:dn}),us=Vn(q.toBytes(Ye),{infinity:!0,compressed:!0});De=kf({fields:{Fp:q,Fp2:y,Fp6:J,Fp12:oe,Fr:Cf},G1:{Fp:q,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:q.ZERO,b:qn,htfDefaults:{...ia,m:1,DST:"BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_"},wrapPrivateKey:!0,allowInfinityPoint:!0,isTorsionFree:(t,e)=>{let r=BigInt("0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),n=new t(q.mul(e.px,r),e.py,e.pz);return e.multiplyUnsafe(De.params.x).negate().multiplyUnsafe(De.params.x).equals(n)},clearCofactor:(t,e)=>e.multiplyUnsafe(De.params.x).add(e),mapToCurve:t=>{let{x:e,y:r}=Pp(q.create(t[0]));return Up(e,r)},fromBytes:t=>{let{compressed:e,infinity:r,sort:n,value:i}=cs(t);if(i.length===48&&e){let s=q.ORDER,o=rt(i),a=q.create(o&q.MASK);if(r){if(a!==Ye)throw new Error("G1: non-empty compressed point at infinity");return{x:Ye,y:Ye}}let c=q.add(q.pow(a,os),q.create(De.params.G1b)),f=q.sqrt(c);if(!f)throw new Error("Invalid compressed G1 point");return f*Me/s!==BigInt(n)&&(f=q.neg(f)),{x:q.create(a),y:q.create(f)}}else if(i.length===96&&!e){let s=rt(i.subarray(0,q.BYTES)),o=rt(i.subarray(q.BYTES));if(r){if(s!==Ye||o!==Ye)throw new Error("G1: non-empty point at infinity");return De.G1.ProjectivePoint.ZERO.toAffine()}return{x:q.create(s),y:q.create(o)}}else throw new Error("Invalid point G1, expected 48/96 bytes")},toBytes:(t,e,r)=>{let n=e.equals(t.ZERO),{x:i,y:s}=e.toAffine();if(r){if(n)return us.slice();let o=q.ORDER,a=!!(s*Me/o);return Vn(qe(i,q.BYTES),{compressed:!0,sort:a})}else return n?Ne(new Uint8Array([64]),new Uint8Array(2*q.BYTES-1)):Ne(qe(i,q.BYTES),qe(s,q.BYTES))},ShortSignature:{fromHex(t){let{infinity:e,sort:r,value:n}=cs(je("signatureHex",t,48)),i=q.ORDER,s=rt(n);if(e)return De.G1.ProjectivePoint.ZERO;let o=q.create(s&q.MASK),a=q.add(q.pow(o,os),q.create(De.params.G1b)),c=q.sqrt(a);if(!c)throw new Error("Invalid compressed G1 point");let f=BigInt(r);c*Me/i!==f&&(c=q.neg(c));let l=De.G1.ProjectivePoint.fromAffine({x:o,y:c});return l.assertValidity(),l},toRawBytes(t){return Qf(t)},toHex(t){return It(Qf(t))}}},G2:{Fp:y,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),Gx:y.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:y.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")]),a:y.ZERO,b:y.fromBigTuple([qn,qn]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...ia},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:t=>{let{x:e,y:r}=Fp(y.fromBigTuple(t));return Op(e,r)},isTorsionFree:(t,e)=>e.multiplyUnsafe(De.params.x).negate().equals(Jf(t,e)),clearCofactor:(t,e)=>{let r=De.params.x,n=e.multiplyUnsafe(r).negate(),i=Jf(t,e),s=e.double();return s=$p(t,s),s=s.subtract(i),i=n.add(i),i=i.multiplyUnsafe(r).negate(),s=s.add(i),s=s.subtract(n),s.subtract(e)},fromBytes:t=>{let{compressed:e,infinity:r,sort:n,value:i}=cs(t);if(!e&&!r&&n||!e&&r&&n||n&&r&&e)throw new Error("Invalid encoding flag: "+(t[0]&224));let s=q.BYTES,o=(a,c,f)=>rt(a.slice(c,f));if(i.length===96&&e){let a=De.params.G2b,c=q.ORDER;if(r){if(i.reduce((E,U)=>E!==0?U+1:U,0)>0)throw new Error("Invalid compressed G2 point");return{x:y.ZERO,y:y.ZERO}}let f=o(i,0,s),l=o(i,s,2*s),d=y.create({c0:q.create(l),c1:q.create(f)}),v=y.add(y.pow(d,os),a),w=y.sqrt(v),_=w.c1===Ye?w.c0*Me/c:w.c1*Me/c?Fr:Ye;return w=n&&_>0?w:y.neg(w),{x:d,y:w}}else if(i.length===192&&!e){if(r){if(i.reduce((d,v)=>d!==0?v+1:v,0)>0)throw new Error("Invalid uncompressed G2 point");return{x:y.ZERO,y:y.ZERO}}let a=o(i,0,s),c=o(i,s,2*s),f=o(i,2*s,3*s),l=o(i,3*s,4*s);return{x:y.fromBigTuple([c,a]),y:y.fromBigTuple([l,f])}}else throw new Error("Invalid point G2, expected 96/192 bytes")},toBytes:(t,e,r)=>{let{BYTES:n,ORDER:i}=q,s=e.equals(t.ZERO),{x:o,y:a}=e.toAffine();if(r){if(s)return Ne(us,qe(Ye,n));let c=!!(a.c1===Ye?a.c0*Me/i:a.c1*Me/i);return Ne(Vn(qe(o.c1,n),{compressed:!0,sort:c}),qe(o.c0,n))}else{if(s)return Ne(new Uint8Array([64]),new Uint8Array(4*n-1));let{re:c,im:f}=y.reim(o),{re:l,im:d}=y.reim(a);return Ne(qe(f,n),qe(c,n),qe(d,n),qe(l,n))}},Signature:{fromHex(t){let{infinity:e,sort:r,value:n}=cs(je("signatureHex",t)),i=q.ORDER,s=n.length/2;if(s!==48&&s!==96)throw new Error("Invalid compressed signature length, must be 96 or 192");let o=rt(n.slice(0,s)),a=rt(n.slice(s));if(e)return De.G2.ProjectivePoint.ZERO;let c=q.create(o&q.MASK),f=q.create(a),l=y.create({c0:f,c1:c}),d=y.add(y.pow(l,os),De.params.G2b),v=y.sqrt(d);if(!v)throw new Error("Failed to find a square root");let{re:w,im:_}=y.reim(v),E=BigInt(r),U=_>Ye&&_*Me/i!==E,O=_===Ye&&w*Me/i!==E;(U||O)&&(v=y.neg(v));let V=De.G2.ProjectivePoint.fromAffine({x:l,y:v});return V.assertValidity(),V},toRawBytes(t){return Lf(t)},toHex(t){return It(Lf(t))}}},params:{x:oa,r:Cf.ORDER},htfDefaults:ia,hash:dn,randomBytes:si})});function n0(t,e,r){let n=typeof t=="string"?t:Qe(t),i=typeof e=="string"?e:Qe(e),s=typeof r=="string"?r:Qe(r);return De.verifyShortSignature(i,s,n)}var aa=we(()=>{r0();ht()});var ca,nn,fs=we(()=>{xn();ca=t=>Ge(new vt(t)),nn=t=>{let e=ca(t);return new Date(Number(e)/1e6)}});function i0(t,e){if(t.byteLength!==e.byteLength)return!1;let r=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<r.length;i++)if(r[i]!==n[i])return!1;return!0}function jp(t){let e=$n.byteLength+Hp;if(t.byteLength!==e)throw new TypeError(`BLS DER-encoded public key must be ${e} bytes long`);let r=t.slice(0,$n.byteLength);if(!i0(r,$n))throw new TypeError(`BLS DER-encoded public key is invalid. Expect the following prefix: ${$n}, but get ${r}`);return t.slice($n.byteLength)}function ua(t){if(t instanceof ArrayBuffer)return t;if(t instanceof Uint8Array)return t.buffer}async function ls(t){switch(t[0]){case Ht.Empty:return xt(Gn("ic-hashtree-empty"));case Ht.Pruned:return t[1];case Ht.Leaf:return xt(st(Gn("ic-hashtree-leaf"),t[1]));case Ht.Labeled:return xt(st(Gn("ic-hashtree-labeled"),t[1],await ls(t[2])));case Ht.Fork:return xt(st(Gn("ic-hashtree-fork"),await ls(t[1]),await ls(t[2])));default:throw new Error("unreachable")}}function Gn(t){let e=new Uint8Array([t.length]),r=new TextEncoder().encode(t);return st(e,r)}function gr(t,e){if(t.length===0)switch(e[0]){case Ht.Leaf:{if(!e[1])throw new Error("Invalid tree structure for leaf");return e[1]instanceof ArrayBuffer?e[1]:e[1]instanceof Uint8Array?e[1].buffer:e[1]}case Ht.Fork:return e;default:return e}let r=typeof t[0]=="string"?new TextEncoder().encode(t[0]):t[0],n=Yp(r,Hn(e));if(n)return gr(t.slice(1),n)}function Hn(t){switch(t[0]){case Ht.Empty:return[];case Ht.Fork:return Hn(t[1]).concat(Hn(t[2]));default:return[t]}}function Yp(t,e){if(e.length!==0){for(let r of e)if(r[0]===Ht.Labeled){let n=r[1];if(i0(t,n))return r[2]}}}function fa(t){let{canisterId:e,subnetId:r,tree:n}=t,i=gr(["subnet",r.toUint8Array(),"canister_ranges"],n);if(!i||!(i instanceof ArrayBuffer))throw new Error(`Could not find canister ranges for subnet ${r}`);return _t(i).map(c=>[ae.fromUint8Array(c[0]),ae.fromUint8Array(c[1])]).some(c=>c[0].ltEq(e)&&c[1].gtEq(e))}var pt,Ht,sn,$n,Hp,jn=we(()=>{Rn();Zr();Sn();ht();yt();aa();fs();pt=class extends tt{constructor(e){super(`Invalid certificate: ${e}`)}},Ht={Empty:0,Fork:1,Labeled:2,Leaf:3,Pruned:4};sn=class t{constructor(e,r,n,i,s=5){this._rootKey=r,this._canisterId=n,this._blsVerify=i,this._maxAgeInMinutes=s,this.cert=_t(new Uint8Array(e))}static async create(e){let r=t.createUnverified(e);return await r.verify(),r}static createUnverified(e){let r=e.blsVerify;return r||(r=n0),new t(e.certificate,e.rootKey,e.canisterId,r,e.maxAgeInMinutes)}lookup(e){return ua(gr(e,this.cert.tree))}lookup_label(e){return this.lookup([e])}async verify(){let e=await ls(this.cert.tree),r=await this._checkDelegationAndGetKey(this.cert.delegation),n=this.cert.signature,i=jp(r),s=st(Gn("ic-state-root"),e),o=!1,a=this.lookup(["time"]);if(!a)throw new pt("Certificate does not contain a time");let c=5*60*1e3,f=this._maxAgeInMinutes*60*1e3,l=Date.now(),d=l-f,v=l+c,w=nn(a);if(w.getTime()<d)throw new pt(`Certificate is signed more than ${this._maxAgeInMinutes} minutes in the past. Certificate time: `+w.toISOString()+" Current time: "+new Date(l).toISOString());if(w.getTime()>v)throw new pt("Certificate is signed more than 5 minutes in the future. Certificate time: "+w.toISOString()+" Current time: "+new Date(l).toISOString());try{o=await this._blsVerify(new Uint8Array(i),new Uint8Array(n),new Uint8Array(s))}catch{o=!1}if(!o)throw new pt("Signature verification failed")}async _checkDelegationAndGetKey(e){if(!e)return this._rootKey;let r=await t.createUnverified({certificate:e.certificate,rootKey:this._rootKey,canisterId:this._canisterId,blsVerify:this._blsVerify,maxAgeInMinutes:1/0});if(r.cert.delegation)throw new pt("Delegation certificates cannot be nested");if(await r.verify(),!fa({canisterId:this._canisterId,subnetId:ae.fromUint8Array(new Uint8Array(e.subnet_id)),tree:r.cert.tree}))throw new pt(`Canister ${this._canisterId} not in range of delegations for subnet 0x${Qe(e.subnet_id)}`);let i=r.lookup(["subnet",e.subnet_id,"public_key"]);if(!i)throw new Error(`Could not find subnet key for subnet 0x${Qe(e.subnet_id)}`);return i}},$n=Tr("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"),Hp=96});var hs={};fn(hs,{CustomPath:()=>la,encodePath:()=>da,fetchNodeKeys:()=>o0,request:()=>ds});var la,ds,o0,da,s0,a0,zp,Kp,Yn=we(()=>{yt();Zr();jn();ht();Rn();fs();la=class{constructor(e,r,n){this.key=e,this.path=r,this.decodeStrategy=n}},ds=async t=>{let{agent:e,paths:r}=t,n=ae.from(t.canisterId),i=[...new Set(r)],s=i.map(c=>da(c,n)),o=new Map,a=i.map((c,f)=>(async()=>{var l;try{let d=await e.readState(n,{paths:[s[f]]}),v=await sn.create({certificate:d.certificate,rootKey:e.rootKey,canisterId:n}),w=(U,O)=>{if(O==="subnet"){let V=o0(d.certificate,n,e.rootKey);return{path:O,data:V}}else return{path:O,data:ua(U.lookup(da(O,n)))}},{path:_,data:E}=w(v,i[f]);if(!E)console.warn(`Expected to find result for path ${_}, but instead found nothing.`),typeof _=="string"?o.set(_,null):o.set(_.key,null);else switch(_){case"time":{o.set(_,nn(E));break}case"controllers":{o.set(_,Kp(E));break}case"module_hash":{o.set(_,s0(E));break}case"subnet":{o.set(_,E);break}case"candid":{o.set(_,new TextDecoder().decode(E));break}default:if(typeof _!="string"&&"key"in _&&"path"in _)switch(_.decodeStrategy){case"raw":o.set(_.key,E);break;case"leb128":{o.set(_.key,ca(E));break}case"cbor":{o.set(_.key,a0(E));break}case"hex":{o.set(_.key,s0(E));break}case"utf-8":o.set(_.key,zp(E))}}}catch(d){if(!((l=d?.message)===null||l===void 0)&&l.includes("Invalid certificate"))throw new tt(d.message);typeof c!="string"&&"key"in c&&"path"in c?o.set(c.key,null):o.set(c,null),console.group(),console.warn(`Expected to find result for path ${c}, but instead found nothing.`),console.warn(d),console.groupEnd()}})());return await Promise.all(a),o},o0=(t,e,r)=>{if(!e._isPrincipal)throw new Error("Invalid canisterId");let n=_t(new Uint8Array(t)),i=n.tree,s=n.delegation,o;if(s&&s.subnet_id?o=ae.fromUint8Array(new Uint8Array(s.subnet_id)):!s&&typeof r<"u"?(o=ae.selfAuthenticating(new Uint8Array(r)),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}):(o=ae.selfAuthenticating(ae.fromText("tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe").toUint8Array()),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}),!fa({canisterId:e,subnetId:o,tree:i}))throw new Error("Canister not in range");let c=gr(["subnet",s?.subnet_id,"node"],i),f=Hn(c);f.length;let l=new Map;return f.forEach(d=>{Object.getPrototypeOf(new Uint8Array(d[1]));let v=ae.from(new Uint8Array(d[1])).toText(),w=gr(["public_key"],d[2]);if(w.byteLength!==44)throw new Error("Invalid public key length");l.set(v,w)}),{subnetId:ae.fromUint8Array(new Uint8Array(s.subnet_id)).toText(),nodeKeys:l}},da=(t,e)=>{let r=new TextEncoder,n=s=>new DataView(r.encode(s).buffer).buffer,i=new DataView(e.toUint8Array().buffer).buffer;switch(t){case"time":return[n("time")];case"controllers":return[n("canister"),i,n("controllers")];case"module_hash":return[n("canister"),i,n("module_hash")];case"subnet":return[n("subnet")];case"candid":return[n("canister"),i,n("metadata"),n("candid:service")];default:if("key"in t&&"path"in t)if(typeof t.path=="string"||t.path instanceof ArrayBuffer){let s=t.path,o=typeof s=="string"?n(s):s;return[n("canister"),i,n("metadata"),o]}else return t.path}throw new Error(`An unexpeected error was encountered while encoding your path for canister status. Please ensure that your path, ${t} was formatted correctly.`)},s0=t=>Qe(t),a0=t=>_t(t),zp=t=>new TextDecoder().decode(t),Kp=t=>a0(t).map(r=>ae.fromUint8Array(new Uint8Array(r)))});yt();yt();var ks=(t,e)=>{let r;return(...n)=>{let i=()=>t(...n);r&&clearTimeout(r),r=setTimeout(i,e!==void 0&&e>0?e:300)}},Hr=t=>t==null,rr=t=>!Hr(t),Pl=class extends Error{},Ms=(t,e)=>{if(Hr(t))throw new Pl(e)};function kl(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,i,s,o,a=[],c=!0,f=!1;try{if(s=(r=r.call(t)).next,e===0){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=s.call(r)).done)&&(a.push(n.value),a.length!==e);c=!0);}catch(l){f=!0,i=l}finally{try{if(!c&&r.return!=null&&(o=r.return(),Object(o)!==o))return}finally{if(f)throw i}}return a}}function Ml(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Qa(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ic(n.key),n)}}function Cl(t,e,r){return e&&Qa(t.prototype,e),r&&Qa(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function La(t,e,r){return e=ic(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function nc(t,e){return ql(t)||kl(t,e)||Vl(t,e)||$l()}function ql(t){if(Array.isArray(t))return t}function Vl(t,e){if(t){if(typeof t=="string")return Da(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Da(t,e)}}function Da(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function $l(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
14
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Gl(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function ic(t){var e=Gl(t,"string");return typeof e=="symbol"?e:String(e)}function Kt(t,e){var r=oc(t,e,"get");return Hl(t,r)}function sc(t,e,r){var n=oc(t,e,"set");return jl(t,n,r),r}function oc(t,e,r){if(!e.has(t))throw new TypeError("attempted to "+r+" private field on non-instance");return e.get(t)}function Hl(t,e){return e.get?e.get.call(t):e.value}function jl(t,e,r){if(e.set)e.set.call(t,r);else{if(!e.writable)throw new TypeError("attempted to set read only private field");e.value=r}}function hn(t,e,r){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return r}function ac(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function ec(t,e,r){ac(t,e),e.set(t,r)}function tc(t,e){ac(t,e),e.add(t)}var cc=[" daum[ /]"," deusu/"," yadirectfetcher","(?:^| )site","(?:^|[^g])news","@[a-z]","\\(at\\)[a-z]","\\(github\\.com/","\\[at\\][a-z]","^12345","^<","^[\\w \\.\\-\\(\\)]+(/v?\\d+(\\.\\d+)?(\\.\\d{1,10})?)?$","^[^ ]{50,}$","^active","^ad muncher","^amaya","^anglesharp/","^anonymous","^avsdevicesdk/","^axios/","^bidtellect/","^biglotron","^btwebclient/","^castro","^clamav[ /]","^client/","^cobweb/","^coccoc","^custom","^ddg[_-]android","^discourse","^dispatch/\\d","^downcast/","^duckduckgo","^facebook","^fdm[ /]\\d","^getright/","^gozilla/","^hatena","^hobbit","^hotzonu","^hwcdn/","^jeode/","^jetty/","^jigsaw","^linkdex","^lwp[-: ]","^metauri","^microsoft bits","^movabletype","^mozilla/\\d\\.\\d \\(compatible;?\\)$","^mozilla/\\d\\.\\d \\w*$","^navermailapp","^netsurf","^offline explorer","^php","^postman","^postrank","^python","^read","^reed","^restsharp/","^snapchat","^space bison","^svn","^swcd ","^taringa","^test certificate info","^thumbor/","^tumblr/","^user-agent:mozilla","^valid","^venus/fedoraplanet","^w3c","^webbandit/","^webcopier","^wget","^whatsapp","^xenu link sleuth","^yahoo","^yandex","^zdm/\\d","^zoom marketplace/","^{{.*}}$","adbeat\\.com","appinsights","archive","ask jeeves/teoma","bit\\.ly/","bluecoat drtr","bot","browsex","burpcollaborator","capture","catch","check","chrome-lighthouse","chromeframe","cloud","crawl","cryptoapi","dareboost","datanyze","dataprovider","dejaclick","dmbrowser","download","evc-batch/","feed","firephp","freesafeip","ghost","gomezagent","google","headlesschrome/","http","httrack","hubspot marketing grader","hydra","ibisbrowser","images","iplabel","ips-agent","java","library","mail\\.ru/","manager","monitor","morningscore/","neustar wpm","nutch","offbyone","optimize","pageburst","pagespeed","perl","phantom","pingdom","powermarks","preview","proxy","ptst[ /]\\d","reader","rexx;","rigor","rss","scan","scrape","search","serp ?reputation ?management","server","sogou","sparkler/","speedcurve","spider","splash","statuscake","stumbleupon\\.com","supercleaner","synapse","synthetic","taginspector/","torrent","tracemyfile","transcoder","trendsmapresolver","twingly recon","url","virtuoso","wappalyzer","webglance","webkit2png","websitemetadataretriever","whatcms/","wordpress","zgrab"];function Yl(t){try{new RegExp("(?<! cu)bot").test("dangerbot")}catch{return t}return[["bot","(?<! cu)bot"],["google","(?<! (?:channel/|google/))google(?!(app|/google| pixel))"],["http","(?<!(?:lib))http"],["java","java(?!;)"],["search","(?<! ya(?:yandex)?)search"]].forEach(function(e){var r=nc(e,2),n=r[0],i=r[1],s=t.lastIndexOf(n);~s&&t.splice(s,1,i)}),t}Yl(cc);var uc="i",nr=new WeakMap,pn=new WeakMap,ui=new WeakSet,Cs=new WeakSet,zl=function(){function t(e){var r=this;Ml(this,t),tc(this,Cs),tc(this,ui),ec(this,nr,{writable:!0,value:void 0}),ec(this,pn,{writable:!0,value:void 0}),sc(this,nr,e||cc.slice()),hn(this,ui,qs).call(this);var n=function(s){return r.test(s)};return Object.defineProperties(n,Object.entries(Object.getOwnPropertyDescriptors(t.prototype)).reduce(function(i,s){var o=nc(s,2),a=o[0],c=o[1];return typeof c.value=="function"&&Object.assign(i,La({},a,{value:r[a].bind(r)})),typeof c.get=="function"&&Object.assign(i,La({},a,{get:function(){return r[a]}})),i},{}))}return Cl(t,[{key:"pattern",get:function(){return new RegExp(Kt(this,pn))}},{key:"test",value:function(r){return!!r&&Kt(this,pn).test(r)}},{key:"find",value:function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",n=r.match(Kt(this,pn));return n&&n[0]}},{key:"matches",value:function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";return Kt(this,nr).filter(function(n){return new RegExp(n,uc).test(r)})}},{key:"clear",value:function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";this.exclude(this.matches(r))}},{key:"extend",value:function(){var r=this,n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];[].push.apply(Kt(this,nr),n.filter(function(i){return hn(r,Cs,rc).call(r,i)===-1}).map(function(i){return i.toLowerCase()})),hn(this,ui,qs).call(this)}},{key:"exclude",value:function(){for(var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],n=r.length;n--;){var i=hn(this,Cs,rc).call(this,r[n]);i>-1&&Kt(this,nr).splice(i,1)}hn(this,ui,qs).call(this)}},{key:"spawn",value:function(r){return new t(r||Kt(this,nr))}}]),t}();function qs(){sc(this,pn,new RegExp(Kt(this,nr).join("|"),uc))}function rc(t){return Kt(this,nr).indexOf(t.toLowerCase())}var fc=new zl;var lc=({IDL:t})=>{let e=t.Record({controllers:t.Vec(t.Principal)}),r=t.Variant({Write:t.Null,Admin:t.Null}),n=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:r,expires_at:t.Opt(t.Nat64)}),i=t.Record({updated_at:t.Opt(t.Nat64)}),s=t.Record({cycles:t.Nat,destination_id:t.Principal}),o=t.Record({to:t.Opt(t.Nat64),from:t.Opt(t.Nat64),satellite_id:t.Opt(t.Principal)}),a=t.Record({key:t.Text,collected_at:t.Nat64}),c=t.Record({inner_height:t.Nat16,inner_width:t.Nat16}),f=t.Record({title:t.Text,updated_at:t.Nat64,referrer:t.Opt(t.Text),time_zone:t.Text,session_id:t.Text,href:t.Text,created_at:t.Nat64,satellite_id:t.Principal,device:c,user_agent:t.Opt(t.Text)}),l=t.Record({safari:t.Float64,opera:t.Float64,others:t.Float64,firefox:t.Float64,chrome:t.Float64}),d=t.Record({desktop:t.Float64,others:t.Float64,mobile:t.Float64}),v=t.Record({browsers:l,devices:d}),w=t.Record({day:t.Nat8,month:t.Nat8,year:t.Int32}),_=t.Record({bounce_rate:t.Float64,average_page_views_per_session:t.Float64,daily_total_page_views:t.Vec(t.Tuple(w,t.Nat32)),total_page_views:t.Nat32,unique_page_views:t.Nat64,unique_sessions:t.Nat64}),E=t.Record({referrers:t.Vec(t.Tuple(t.Text,t.Nat32)),pages:t.Vec(t.Tuple(t.Text,t.Nat32))}),U=t.Record({updated_at:t.Nat64,session_id:t.Text,metadata:t.Opt(t.Vec(t.Tuple(t.Text,t.Text))),name:t.Text,created_at:t.Nat64,satellite_id:t.Principal}),O=t.Record({total:t.Vec(t.Tuple(t.Text,t.Nat32))}),V=t.Record({updated_at:t.Nat64,created_at:t.Nat64,enabled:t.Bool}),k=t.Record({stable:t.Nat64,heap:t.Nat64}),K=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:r,expires_at:t.Opt(t.Nat64)}),F=t.Record({controller:K,controllers:t.Vec(t.Principal)}),M=t.Record({title:t.Text,updated_at:t.Opt(t.Nat64),referrer:t.Opt(t.Text),time_zone:t.Text,session_id:t.Text,href:t.Text,satellite_id:t.Principal,device:c,user_agent:t.Opt(t.Text)}),z=t.Variant({Ok:f,Err:t.Text}),Y=t.Variant({Ok:t.Null,Err:t.Vec(t.Tuple(a,t.Text))}),G=t.Record({updated_at:t.Opt(t.Nat64),enabled:t.Bool}),ee=t.Record({updated_at:t.Opt(t.Nat64),session_id:t.Text,metadata:t.Opt(t.Vec(t.Tuple(t.Text,t.Text))),name:t.Text,satellite_id:t.Principal,user_agent:t.Opt(t.Text)}),L=t.Variant({Ok:U,Err:t.Text});return t.Service({del_controllers:t.Func([e],[t.Vec(t.Tuple(t.Principal,n))],[]),del_satellite_config:t.Func([t.Principal,i],[],[]),deposit_cycles:t.Func([s],[],[]),get_page_views:t.Func([o],[t.Vec(t.Tuple(a,f))],["query"]),get_page_views_analytics_clients:t.Func([o],[v],["query"]),get_page_views_analytics_metrics:t.Func([o],[_],["query"]),get_page_views_analytics_top_10:t.Func([o],[E],["query"]),get_track_events:t.Func([o],[t.Vec(t.Tuple(a,U))],["query"]),get_track_events_analytics:t.Func([o],[O],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,n))],["query"]),list_satellite_configs:t.Func([],[t.Vec(t.Tuple(t.Principal,V))],["query"]),memory_size:t.Func([],[k],["query"]),set_controllers:t.Func([F],[t.Vec(t.Tuple(t.Principal,n))],[]),set_page_view:t.Func([a,M],[z],[]),set_page_views:t.Func([t.Vec(t.Tuple(a,M))],[Y],[]),set_satellite_configs:t.Func([t.Vec(t.Tuple(t.Principal,G))],[t.Vec(t.Tuple(t.Principal,V))],[]),set_track_event:t.Func([a,ee],[L],[]),set_track_events:t.Func([t.Vec(t.Tuple(a,ee))],[Y],[]),version:t.Func([],[t.Text],["query"])})};var C0=qr(Oc());var hi;(function(t){t[t.SysFatal=1]="SysFatal",t[t.SysTransient=2]="SysTransient",t[t.DestinationInvalid=3]="DestinationInvalid",t[t.CanisterReject=4]="CanisterReject",t[t.CanisterError=5]="CanisterError"})(hi||(hi={}));yt();Zr();yt();Sn();ht();var Oy=new TextEncoder().encode(`
15
- ic-request`);var Dr=class{getPrincipal(){return ae.anonymous()}async transformRequest(e){return Object.assign(Object.assign({},e),{body:{content:e.body}})}};Rn();Sn();ht();xn();var _f=qr(Zi());var In=()=>{if(typeof window<"u"&&window.crypto&&window.crypto.getRandomValues){let t=new Uint32Array(1);return window.crypto.getRandomValues(t),t[0]}if(typeof crypto<"u"&&crypto.getRandomValues){let t=new Uint32Array(1);return crypto.getRandomValues(t),t[0]}return typeof crypto<"u"&&crypto.randomInt?crypto.randomInt(0,4294967295):Math.floor(Math.random()*4294967295)};var Qi;(function(t){t.Call="call"})(Qi||(Qi={}));function en(){let t=new ArrayBuffer(16),e=new DataView(t),r=In(),n=In(),i=In(),s=In();return e.setUint32(0,r),e.setUint32(4,n),e.setUint32(8,i),e.setUint32(12,s),t}var tp=BigInt(1e6),rp=60*1e3,Rr=class{constructor(e){let s=BigInt(Math.floor(Date.now()+e-rp))*tp/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=s}toCBOR(){return _f.value.u64(this._value.toString(16),16)}toHash(){return Ie(this._value)}};function $o(t=en){return async e=>{let r=e.request.headers;e.request.headers=r,e.endpoint==="call"&&(e.body.nonce=t())}}function On(t){let e=[];return t.forEach((r,n)=>{e.push([n,r])}),e}Zr();var Un=class extends tt{constructor(e,r){super(e),this.response=r,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};Yn();jn();Fs();var ps=BigInt(4294967295),ha=BigInt(32);function c0(t,e=!1){return e?{h:Number(t&ps),l:Number(t>>ha&ps)}:{h:Number(t>>ha&ps)|0,l:Number(t&ps)|0}}function Zp(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){let{h:s,l:o}=c0(t[i],e);[r[i],n[i]]=[s,o]}return[r,n]}var Wp=(t,e)=>BigInt(t>>>0)<<ha|BigInt(e>>>0),Xp=(t,e,r)=>t>>>r,Jp=(t,e,r)=>t<<32-r|e>>>r,Qp=(t,e,r)=>t>>>r|e<<32-r,Lp=(t,e,r)=>t<<32-r|e>>>r,Dp=(t,e,r)=>t<<64-r|e>>>r-32,e1=(t,e,r)=>t>>>r-32|e<<64-r,t1=(t,e)=>e,r1=(t,e)=>t,n1=(t,e,r)=>t<<r|e>>>32-r,i1=(t,e,r)=>e<<r|t>>>32-r,s1=(t,e,r)=>e<<r-32|t>>>64-r,o1=(t,e,r)=>t<<r-32|e>>>64-r;function a1(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}var c1=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),u1=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,f1=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),l1=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,d1=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0),h1=(t,e,r,n,i,s)=>e+r+n+i+s+(t/2**32|0)|0;var p1={fromBig:c0,split:Zp,toBig:Wp,shrSH:Xp,shrSL:Jp,rotrSH:Qp,rotrSL:Lp,rotrBH:Dp,rotrBL:e1,rotr32H:t1,rotr32L:r1,rotlSH:n1,rotlSL:i1,rotlBH:s1,rotlBL:o1,add:a1,add3L:c1,add3H:u1,add4L:f1,add4H:l1,add5H:h1,add5L:d1},de=p1;$r();var[m1,y1]=de.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),br=new Uint32Array(80),wr=new Uint32Array(80),pa=class extends Gr{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:r,Bh:n,Bl:i,Ch:s,Cl:o,Dh:a,Dl:c,Eh:f,El:l,Fh:d,Fl:v,Gh:w,Gl:_,Hh:E,Hl:U}=this;return[e,r,n,i,s,o,a,c,f,l,d,v,w,_,E,U]}set(e,r,n,i,s,o,a,c,f,l,d,v,w,_,E,U){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=l|0,this.Fh=d|0,this.Fl=v|0,this.Gh=w|0,this.Gl=_|0,this.Hh=E|0,this.Hl=U|0}process(e,r){for(let k=0;k<16;k++,r+=4)br[k]=e.getUint32(r),wr[k]=e.getUint32(r+=4);for(let k=16;k<80;k++){let K=br[k-15]|0,F=wr[k-15]|0,M=de.rotrSH(K,F,1)^de.rotrSH(K,F,8)^de.shrSH(K,F,7),z=de.rotrSL(K,F,1)^de.rotrSL(K,F,8)^de.shrSL(K,F,7),Y=br[k-2]|0,G=wr[k-2]|0,ee=de.rotrSH(Y,G,19)^de.rotrBH(Y,G,61)^de.shrSH(Y,G,6),L=de.rotrSL(Y,G,19)^de.rotrBL(Y,G,61)^de.shrSL(Y,G,6),ce=de.add4L(z,L,wr[k-7],wr[k-16]),le=de.add4H(ce,M,ee,br[k-7],br[k-16]);br[k]=le|0,wr[k]=ce|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:a,Cl:c,Dh:f,Dl:l,Eh:d,El:v,Fh:w,Fl:_,Gh:E,Gl:U,Hh:O,Hl:V}=this;for(let k=0;k<80;k++){let K=de.rotrSH(d,v,14)^de.rotrSH(d,v,18)^de.rotrBH(d,v,41),F=de.rotrSL(d,v,14)^de.rotrSL(d,v,18)^de.rotrBL(d,v,41),M=d&w^~d&E,z=v&_^~v&U,Y=de.add5L(V,F,z,y1[k],wr[k]),G=de.add5H(Y,O,K,M,m1[k],br[k]),ee=Y|0,L=de.rotrSH(n,i,28)^de.rotrBH(n,i,34)^de.rotrBH(n,i,39),ce=de.rotrSL(n,i,28)^de.rotrBL(n,i,34)^de.rotrBL(n,i,39),le=n&s^n&a^s&a,xe=i&o^i&c^o&c;O=E|0,V=U|0,E=w|0,U=_|0,w=d|0,_=v|0,{h:d,l:v}=de.add(f|0,l|0,G|0,ee|0),f=a|0,l=c|0,a=s|0,c=o|0,s=n|0,o=i|0;let me=de.add3L(ee,ce,xe);n=de.add3H(me,G,L,le),i=me|0}({h:n,l:i}=de.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=de.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:c}=de.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l}=de.add(this.Dh|0,this.Dl|0,f|0,l|0),{h:d,l:v}=de.add(this.Eh|0,this.El|0,d|0,v|0),{h:w,l:_}=de.add(this.Fh|0,this.Fl|0,w|0,_|0),{h:E,l:U}=de.add(this.Gh|0,this.Gl|0,E|0,U|0),{h:O,l:V}=de.add(this.Hh|0,this.Hl|0,O|0,V|0),this.set(n,i,s,o,a,c,f,l,d,v,w,_,E,U,O,V)}roundClean(){br.fill(0),wr.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var ma=ln(()=>new pa);$r();hr();Gt();Gt();Lo();var Ft=BigInt(0),mt=BigInt(1),ms=BigInt(2),g1=BigInt(8),b1={zip215:!0};function w1(t){let e=ns(t);return Ot(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function ys(t){let e=w1(t),{Fp:r,n,prehash:i,hash:s,randomBytes:o,nByteLength:a,h:c}=e,f=ms<<BigInt(a*8)-mt,l=r.create,d=e.uvRatio||((j,C)=>{try{return{isValid:!0,value:r.sqrt(j*r.inv(C))}}catch{return{isValid:!1,value:Ft}}}),v=e.adjustScalarBytes||(j=>j),w=e.domain||((j,C,X)=>{if(C.length||X)throw new Error("Contexts/pre-hash are not supported");return j}),_=j=>typeof j=="bigint"&&Ft<j,E=(j,C)=>_(j)&&_(C)&&j<C,U=j=>j===Ft||E(j,f);function O(j,C){if(E(j,C))return j;throw new Error(`Expected valid scalar < ${C}, got ${typeof j} ${j}`)}function V(j){return j===Ft?j:O(j,n)}let k=new Map;function K(j){if(!(j instanceof F))throw new Error("ExtendedPoint expected")}class F{constructor(C,X,D,ne){if(this.ex=C,this.ey=X,this.ez=D,this.et=ne,!U(C))throw new Error("x required");if(!U(X))throw new Error("y required");if(!U(D))throw new Error("z required");if(!U(ne))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(C){if(C instanceof F)throw new Error("extended point not allowed");let{x:X,y:D}=C||{};if(!U(X)||!U(D))throw new Error("invalid affine point");return new F(X,D,mt,l(X*D))}static normalizeZ(C){let X=r.invertBatch(C.map(D=>D.ez));return C.map((D,ne)=>D.toAffine(X[ne])).map(F.fromAffine)}_setWindowSize(C){this._WINDOW_SIZE=C,k.delete(this)}assertValidity(){let{a:C,d:X}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:D,ey:ne,ez:I,et:m}=this,fe=l(D*D),ie=l(ne*ne),se=l(I*I),Q=l(se*se),u=l(fe*C),h=l(se*l(u+ie)),p=l(Q+l(X*l(fe*ie)));if(h!==p)throw new Error("bad point: equation left != right (1)");let T=l(D*ne),x=l(I*m);if(T!==x)throw new Error("bad point: equation left != right (2)")}equals(C){K(C);let{ex:X,ey:D,ez:ne}=this,{ex:I,ey:m,ez:fe}=C,ie=l(X*fe),se=l(I*ne),Q=l(D*fe),u=l(m*ne);return ie===se&&Q===u}is0(){return this.equals(F.ZERO)}negate(){return new F(l(-this.ex),this.ey,this.ez,l(-this.et))}double(){let{a:C}=e,{ex:X,ey:D,ez:ne}=this,I=l(X*X),m=l(D*D),fe=l(ms*l(ne*ne)),ie=l(C*I),se=X+D,Q=l(l(se*se)-I-m),u=ie+m,h=u-fe,p=ie-m,T=l(Q*h),x=l(u*p),A=l(Q*p),N=l(h*u);return new F(T,x,N,A)}add(C){K(C);let{a:X,d:D}=e,{ex:ne,ey:I,ez:m,et:fe}=this,{ex:ie,ey:se,ez:Q,et:u}=C;if(X===BigInt(-1)){let te=l((I-ne)*(se+ie)),pe=l((I+ne)*(se-ie)),Ee=l(pe-te);if(Ee===Ft)return this.double();let Te=l(m*ms*u),he=l(fe*ms*Q),re=he+Te,Pe=pe+te,zt=he-Te,xr=l(re*Ee),_r=l(Pe*zt),at=l(re*zt),_e=l(Ee*Pe);return new F(xr,_r,_e,at)}let h=l(ne*ie),p=l(I*se),T=l(fe*D*u),x=l(m*Q),A=l((ne+I)*(ie+se)-h-p),N=x-T,g=x+T,B=l(p-X*h),R=l(A*N),S=l(g*B),$=l(A*B),W=l(N*g);return new F(R,S,W,$)}subtract(C){return this.add(C.negate())}wNAF(C){return Y.wNAFCached(this,k,C,F.normalizeZ)}multiply(C){let{p:X,f:D}=this.wNAF(O(C,n));return F.normalizeZ([X,D])[0]}multiplyUnsafe(C){let X=V(C);return X===Ft?z:this.equals(z)||X===mt?this:this.equals(M)?this.wNAF(X).p:Y.unsafeLadder(this,X)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return Y.unsafeLadder(this,n).is0()}toAffine(C){let{ex:X,ey:D,ez:ne}=this,I=this.is0();C==null&&(C=I?g1:r.inv(ne));let m=l(X*C),fe=l(D*C),ie=l(ne*C);if(I)return{x:Ft,y:mt};if(ie!==mt)throw new Error("invZ was invalid");return{x:m,y:fe}}clearCofactor(){let{h:C}=e;return C===mt?this:this.multiplyUnsafe(C)}static fromHex(C,X=!1){let{d:D,a:ne}=e,I=r.BYTES;C=je("pointHex",C,I);let m=C.slice(),fe=C[I-1];m[I-1]=fe&-129;let ie=fr(m);ie===Ft||(X?O(ie,f):O(ie,r.ORDER));let se=l(ie*ie),Q=l(se-mt),u=l(D*se-ne),{isValid:h,value:p}=d(Q,u);if(!h)throw new Error("Point.fromHex: invalid y coordinate");let T=(p&mt)===mt,x=(fe&128)!==0;if(!X&&p===Ft&&x)throw new Error("Point.fromHex: x=0 and x_0=1");return x!==T&&(p=l(-p)),F.fromAffine({x:p,y:ie})}static fromPrivateKey(C){return L(C).point}toRawBytes(){let{x:C,y:X}=this.toAffine(),D=Ir(X,r.BYTES);return D[D.length-1]|=C&mt?128:0,D}toHex(){return It(this.toRawBytes())}}F.BASE=new F(e.Gx,e.Gy,mt,l(e.Gx*e.Gy)),F.ZERO=new F(Ft,mt,mt,Ft);let{BASE:M,ZERO:z}=F,Y=rs(F,a*8);function G(j){return Re(j,n)}function ee(j){return G(fr(j))}function L(j){let C=a;j=je("private key",j,C);let X=je("hashed private key",s(j),2*C),D=v(X.slice(0,C)),ne=X.slice(C,2*C),I=ee(D),m=M.multiply(I),fe=m.toRawBytes();return{head:D,prefix:ne,scalar:I,point:m,pointBytes:fe}}function ce(j){return L(j).pointBytes}function le(j=new Uint8Array,...C){let X=Ne(...C);return ee(s(w(X,je("context",j),!!i)))}function xe(j,C,X={}){j=je("message",j),i&&(j=i(j));let{prefix:D,scalar:ne,pointBytes:I}=L(C),m=le(X.context,D,j),fe=M.multiply(m).toRawBytes(),ie=le(X.context,fe,I,j),se=G(m+ie*ne);V(se);let Q=Ne(fe,Ir(se,r.BYTES));return je("result",Q,a*2)}let me=b1;function Z(j,C,X,D=me){let{context:ne,zip215:I}=D,m=r.BYTES;j=je("signature",j,2*m),C=je("message",C),i&&(C=i(C));let fe=fr(j.slice(m,2*m)),ie,se,Q;try{ie=F.fromHex(X,I),se=F.fromHex(j.slice(0,m),I),Q=M.multiplyUnsafe(fe)}catch{return!1}if(!I&&ie.isSmallOrder())return!1;let u=le(ne,se.toRawBytes(),ie.toRawBytes(),C);return se.add(ie.multiplyUnsafe(u)).subtract(Q).clearCofactor().equals(F.ZERO)}return M._setWindowSize(8),{CURVE:e,getPublicKey:ce,sign:xe,verify:Z,ExtendedPoint:F,utils:{getExtendedPublicKey:L,randomPrivateKey:()=>o(r.BYTES),precompute(j=8,C=F.BASE){return C._setWindowSize(j),C.multiply(BigInt(3)),C}}}}hr();var ga=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),u0=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),jg=BigInt(0),x1=BigInt(1),ya=BigInt(2),_1=BigInt(5),f0=BigInt(10),E1=BigInt(20),B1=BigInt(40),l0=BigInt(80);function v1(t){let e=ga,n=t*t%e*t%e,i=Ut(n,ya,e)*n%e,s=Ut(i,x1,e)*t%e,o=Ut(s,_1,e)*s%e,a=Ut(o,f0,e)*o%e,c=Ut(a,E1,e)*a%e,f=Ut(c,B1,e)*c%e,l=Ut(f,l0,e)*f%e,d=Ut(l,l0,e)*f%e,v=Ut(d,f0,e)*o%e;return{pow_p_5_8:Ut(v,ya,e)*t%e,b2:n}}function A1(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function T1(t,e){let r=ga,n=Re(e*e*e,r),i=Re(n*n*e,r),s=v1(t*i).pow_p_5_8,o=Re(t*n*s,r),a=Re(e*o*o,r),c=o,f=Re(o*u0,r),l=a===t,d=a===Re(-t,r),v=a===Re(-t*u0,r);return l&&(o=c),(d||v)&&(o=f),Rf(o,r)&&(o=Re(-o,r)),{isValid:l||d,value:o}}var Dt=Cn(ga,void 0,!0),ba={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Dt,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:ma,randomBytes:si,adjustScalarBytes:A1,uvRatio:T1},d0=ys(ba);function h0(t,e,r){if(e.length>255)throw new Error("Context is too big");return Ya(Os("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}var Yg=ys({...ba,domain:h0}),zg=ys({...ba,domain:h0,prehash:ma});var S1=(Dt.ORDER+BigInt(3))/BigInt(8),Kg=Dt.pow(ya,S1),Zg=Dt.sqrt(Dt.neg(Dt.ONE)),Wg=(Dt.ORDER-BigInt(5))/BigInt(8),Xg=BigInt(486662);var Jg=If(Dt,Dt.neg(BigInt(486664)));var Qg=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),Lg=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),Dg=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),eb=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var tb=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var p0=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},ot=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},nt,zn,m0,y0,gs=class{constructor(e={}){nt.set(this,void 0),zn.set(this,void 0),this[m0]=this.entries.bind(this),this[y0]="ExpirableMap";let{source:r=[],expirationTime:n=10*60*1e3}=e,i=Date.now();p0(this,nt,new Map([...r].map(([s,o])=>[s,{value:o,timestamp:i}])),"f"),p0(this,zn,n,"f")}prune(){let e=Date.now();for(let[r,n]of ot(this,nt,"f").entries())e-n.timestamp>ot(this,zn,"f")&&ot(this,nt,"f").delete(r);return this}set(e,r){this.prune();let n={value:r,timestamp:Date.now()};return ot(this,nt,"f").set(e,n),this}get(e){let r=ot(this,nt,"f").get(e);if(r!==void 0){if(Date.now()-r.timestamp>ot(this,zn,"f")){ot(this,nt,"f").delete(e);return}return r.value}}clear(){ot(this,nt,"f").clear()}entries(){let e=ot(this,nt,"f").entries();return function*(){for(let[n,i]of e)yield[n,i.value]}()}values(){let e=ot(this,nt,"f").values();return function*(){for(let n of e)yield n.value}()}keys(){return ot(this,nt,"f").keys()}forEach(e,r){for(let[n,i]of ot(this,nt,"f").entries())e.call(r,i.value,n,this)}has(e){return ot(this,nt,"f").has(e)}delete(e){return ot(this,nt,"f").delete(e)}get size(){return ot(this,nt,"f").size}};nt=new WeakMap,zn=new WeakMap,m0=Symbol.iterator,y0=Symbol.toStringTag;ht();var g0=t=>{if(t<=127)return 1;if(t<=255)return 2;if(t<=65535)return 3;if(t<=16777215)return 4;throw new Error("Length too long (> 4 bytes)")},b0=(t,e,r)=>{if(r<=127)return t[e]=r,1;if(r<=255)return t[e]=129,t[e+1]=r,2;if(r<=65535)return t[e]=130,t[e+1]=r>>8,t[e+2]=r,3;if(r<=16777215)return t[e]=131,t[e+1]=r>>16,t[e+2]=r>>8,t[e+3]=r,4;throw new Error("Length too long (> 4 bytes)")},wa=(t,e)=>{if(t[e]<128)return 1;if(t[e]===128)throw new Error("Invalid length 0");if(t[e]===129)return 2;if(t[e]===130)return 3;if(t[e]===131)return 4;throw new Error("Length too long (> 4 bytes)")},N1=(t,e)=>{let r=wa(t,e);if(r===1)return t[e];if(r===2)return t[e+1];if(r===3)return(t[e+1]<<8)+t[e+2];if(r===4)return(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];throw new Error("Length too long (> 4 bytes)")},sb=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]),xa=Uint8Array.from([48,5,6,3,43,101,112]),ob=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function w0(t,e){let r=2+g0(t.byteLength+1),n=e.byteLength+r+t.byteLength,i=0,s=new Uint8Array(1+g0(n)+n);return s[i++]=48,i+=b0(s,i,n),s.set(e,i),i+=e.byteLength,s[i++]=3,i+=b0(s,i,t.byteLength+1),s[i++]=0,s.set(new Uint8Array(t),i),s}var x0=(t,e)=>{let r=0,n=(a,c)=>{if(i[r++]!==a)throw new Error("Expected: "+c)},i=new Uint8Array(t);if(n(48,"sequence"),r+=wa(i,r),!rf(i.slice(r,r+e.byteLength),e))throw new Error("Not the expected OID.");r+=e.byteLength,n(3,"bit string");let s=N1(i,r)-1;r+=wa(i,r),n(0,"0 padding");let o=i.slice(r);if(s!==o.length)throw new Error(`DER payload mismatch: Expected length ${s} actual length ${o.length}`);return o};var _0=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},E0=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},bs,ws,Kn=class t{constructor(e){if(bs.set(this,void 0),ws.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");_0(this,bs,e,"f"),_0(this,ws,t.derEncode(e),"f")}static from(e){return this.fromDer(e.toDer())}static fromRaw(e){return new t(e)}static fromDer(e){return new t(this.derDecode(e))}static derEncode(e){return w0(e,xa).buffer}static derDecode(e){let r=x0(e,xa);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return E0(this,bs,"f")}get derKey(){return E0(this,ws,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};bs=new WeakMap,ws=new WeakMap;Kn.RAW_KEY_LENGTH=32;fs();var B0=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},_a,v0,Ea,A0,Ba=class extends Function{constructor(){return super(),_a.add(this),this.observers=[],new Proxy(this,{apply:(e,r,n)=>B0(e,_a,"m",v0).call(e,n[0],...n.slice(1))})}subscribe(e){this.observers.push(e)}unsubscribe(e){this.observers=this.observers.filter(r=>r!==e)}notify(e,...r){this.observers.forEach(n=>n(e,...r))}};_a=new WeakSet,v0=function(e,...r){this.notify(e,...r)};var xs=class extends Ba{constructor(){return super(),Ea.add(this),new Proxy(this,{apply:(e,r,n)=>B0(e,Ea,"m",A0).call(e,n[0],...n.slice(1))})}log(e,...r){this.notify({message:e,level:"info"},...r)}warn(e,...r){this.notify({message:e,level:"warn"},...r)}error(e,r,...n){this.notify({message:e,level:"error",error:r},...n)}};Ea=new WeakSet,A0=function(e,...r){this.log(e,...r)};var T0=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},ke=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Zn,Es,on,an,Pr,kr,S0,Bs,jt;(function(t){t.Received="received",t.Processing="processing",t.Replied="replied",t.Rejected="rejected",t.Unknown="unknown",t.Done="done"})(jt||(jt={}));var _s=5*60*1e3,R1="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae";var I1="ic0.app",O1=".ic0.app",U1="icp0.io",F1=".icp0.io",P1="icp-api.io",k1=".icp-api.io",Wn=class extends tt{constructor(e){super(e),this.message=e}},cn=class extends tt{constructor(e){super(e),this.message=e}};function M1(){let t;if(typeof window<"u")if(window.fetch)t=window.fetch.bind(window);else throw new Wn("Fetch implementation was not available. You appear to be in a browser context, but window.fetch was not present.");else if(typeof globalThis<"u")if(globalThis.fetch)t=globalThis.fetch.bind(globalThis);else throw new Wn("Fetch implementation was not available. You appear to be in a Node.js context, but global.fetch was not available.");else typeof self<"u"&&self.fetch&&(t=self.fetch.bind(self));if(t)return t;throw new Wn("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}var Xn=class t{constructor(e={}){var r;if(Zn.add(this),this.rootKey=Tr(R1),this._timeDiffMsecs=0,this._rootKeyFetched=!1,this._isAgent=!0,Es.set(this,0),this.log=new xs,on.set(this,[]),an.set(this,[]),Pr.set(this,new gs({expirationTime:5*60*1e3})),kr.set(this,!0),Bs.set(this,(n,i)=>{if(ke(this,kr,"f")===!1)return n;if(!i)throw new pt("Invalid signature from replica signed query: no matching node key found.");let{status:s,signatures:o=[],requestId:a}=n,c=new TextEncoder().encode("\vic-response");for(let f of o){let{timestamp:l,identity:d}=f,v=ae.fromUint8Array(d).toText(),w;if(s==="replied"){let{reply:V}=n;w=Tn({status:s,reply:V,timestamp:BigInt(l),request_id:a})}else if(s==="rejected"){let{reject_code:V,reject_message:k,error_code:K}=n;w=Tn({status:s,reject_code:V,reject_message:k,error_code:K,timestamp:BigInt(l),request_id:a})}else throw new Error(`Unknown status: ${s}`);let _=st(c,new Uint8Array(w)),E=i?.nodeKeys.get(v);if(!E)throw new pt("Invalid signature from replica signed query: no matching node key found.");let U=Kn.fromDer(E).rawKey;if(d0.verify(f.signature,new Uint8Array(_),new Uint8Array(U)))return n;throw new pt(`Invalid signature from replica ${v} signed query.`)}return n}),e.source){if(!(e.source instanceof t))throw new Error("An Agent's source can only be another HttpAgent");this._identity=e.source._identity,this._fetch=e.source._fetch,this._host=e.source._host,this._credentials=e.source._credentials}else this._fetch=e.fetch||M1()||fetch.bind(globalThis),this._fetchOptions=e.fetchOptions,this._callOptions=e.callOptions;if(e.host!==void 0)!e.host.match(/^[a-z]+:/)&&typeof window<"u"?this._host=new URL(window.location.protocol+"//"+e.host):this._host=new URL(e.host);else if(e.source!==void 0)this._host=e.source._host;else{let n=typeof window<"u"?window.location:void 0;n||(this._host=new URL("https://icp-api.io"),this.log.warn("Could not infer host from window.location, defaulting to mainnet gateway of https://icp-api.io. Please provide a host to the HttpAgent constructor to avoid this warning."));let i=["ic0.app","icp0.io","127.0.0.1","localhost"],s=[".github.dev",".gitpod.io"],o=n?.hostname,a;o&&typeof o=="string"&&(s.some(c=>o.endsWith(c))?a=o:a=i.find(c=>o.endsWith(c))),n&&a?this._host=new URL(`${n.protocol}//${a}${n.port?":"+n.port:""}`):(this._host=new URL("https://icp-api.io"),this.log.warn("Could not infer host from window.location, defaulting to mainnet gateway of https://icp-api.io. Please provide a host to the HttpAgent constructor to avoid this warning."))}if(e.verifyQuerySignatures!==void 0&&T0(this,kr,e.verifyQuerySignatures,"f"),this._retryTimes=(r=e.retryTimes)!==null&&r!==void 0?r:3,this._host.hostname.endsWith(O1)?this._host.hostname=I1:this._host.hostname.endsWith(F1)?this._host.hostname=U1:this._host.hostname.endsWith(k1)&&(this._host.hostname=P1),e.credentials){let{name:n,password:i}=e.credentials;this._credentials=`${n}${i?":"+i:""}`}this._identity=Promise.resolve(e.identity||new Dr),this.addTransform("update",$o(en)),e.useQueryNonces&&this.addTransform("query",$o(en)),e.logToConsole&&this.log.subscribe(n=>{n.level==="error"?console.error(n.message):n.level==="warn"?console.warn(n.message):console.log(n.message)})}get waterMark(){return ke(this,Es,"f")}isLocal(){let e=this._host.hostname;return e==="127.0.0.1"||e.endsWith("127.0.0.1")}addTransform(e,r,n=r.priority||0){if(e==="update"){let i=ke(this,an,"f").findIndex(s=>(s.priority||0)<n);ke(this,an,"f").splice(i>=0?i:ke(this,an,"f").length,0,Object.assign(r,{priority:n}))}else if(e==="query"){let i=ke(this,on,"f").findIndex(s=>(s.priority||0)<n);ke(this,on,"f").splice(i>=0?i:ke(this,on,"f").length,0,Object.assign(r,{priority:n}))}}async getPrincipal(){if(!this._identity)throw new cn("This identity has expired due this application's security policy. Please refresh your authentication.");return(await this._identity).getPrincipal()}async call(e,r,n){let i=await(n!==void 0?await n:await this._identity);if(!i)throw new cn("This identity has expired due this application's security policy. Please refresh your authentication.");let s=ae.from(e),o=r.effectiveCanisterId?ae.from(r.effectiveCanisterId):s,a=i.getPrincipal()||ae.anonymous(),c=new Rr(_s);Math.abs(this._timeDiffMsecs)>1e3*30&&(c=new Rr(_s+this._timeDiffMsecs));let f={request_type:Qi.Call,canister_id:s,method_name:r.methodName,arg:r.arg,sender:a,ingress_expiry:c},l=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{})},endpoint:"call",body:f});l=await i.transformRequest(l);let d=Xi(l.body);this.log(`fetching "/api/v2/canister/${o.toText()}/call" with request:`,l);let v=this._requestAndRetry(()=>this._fetch(""+new URL(`/api/v2/canister/${o.toText()}/call`,this._host),Object.assign(Object.assign(Object.assign({},this._callOptions),l.request),{body:d}))),[w,_]=await Promise.all([v,Hi(f)]),E=await w.arrayBuffer(),U=w.status===200&&E.byteLength>0?_t(E):null;return{requestId:_,response:{ok:w.ok,status:w.status,statusText:w.statusText,body:U,headers:On(w.headers)}}}async _requestAndRetry(e,r=0){let n;try{n=await e()}catch(o){if(this._retryTimes>r)return this.log.warn(`Caught exception while attempting to make request:
16
- ${o}
17
- Retrying request.`),await this._requestAndRetry(e,r+1);throw o}if(n.ok)return n;let i=await n.clone().text(),s=`Server returned an error:
18
- Code: ${n.status} (${n.statusText})
19
- Body: ${i}
20
- `;if(this._retryTimes>r)return this.log.warn(s+" Retrying request."),await this._requestAndRetry(e,r+1);throw new Un(s,{ok:n.ok,status:n.status,statusText:n.statusText,headers:On(n.headers)})}async query(e,r,n){let i=r.effectiveCanisterId?ae.from(r.effectiveCanisterId):ae.from(e);this.log(`ecid ${i.toString()}`),this.log(`canisterId ${e.toString()}`);let s=async()=>{let f=await(n!==void 0?await n:await this._identity);if(!f)throw new cn("This identity has expired due this application's security policy. Please refresh your authentication.");let l=ae.from(e),d=f?.getPrincipal()||ae.anonymous(),v={request_type:"query",canister_id:l,method_name:r.methodName,arg:r.arg,sender:d,ingress_expiry:new Rr(_s)},w=await Hi(v),_=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{})},endpoint:"read",body:v});_=await f?.transformRequest(_);let E=Xi(_.body),U={canister:l.toText(),ecid:i,transformedRequest:_,body:E,requestId:w};return await ke(this,Zn,"m",S0).call(this,U)},o=async()=>{if(!ke(this,kr,"f"))return;let f=ke(this,Pr,"f").get(i.toString());return f||(await this.fetchSubnetKeys(i.toString()),ke(this,Pr,"f").get(i.toString()))},[a,c]=await Promise.all([s(),o()]);if(this.log("Query response:",a),!ke(this,kr,"f"))return a;try{return ke(this,Bs,"f").call(this,a,c)}catch{this.log.warn("Query response verification failed. Retrying with fresh subnet keys."),ke(this,Pr,"f").delete(e.toString()),await this.fetchSubnetKeys(i.toString());let l=ke(this,Pr,"f").get(e.toString());if(!l)throw new pt("Invalid signature from replica signed query: no matching node key found.");return ke(this,Bs,"f").call(this,a,l)}}async createReadStateRequest(e,r){let n=await(r!==void 0?await r:await this._identity);if(!n)throw new cn("This identity has expired due this application's security policy. Please refresh your authentication.");let i=n?.getPrincipal()||ae.anonymous(),s=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{})},endpoint:"read_state",body:{request_type:"read_state",paths:e.paths,sender:i,ingress_expiry:new Rr(_s)}});return n?.transformRequest(s)}async readState(e,r,n,i){let s=typeof e=="string"?ae.fromText(e):e,o=i??await this.createReadStateRequest(r,n),a=Xi(o.body);this.log(`fetching "/api/v2/canister/${s}/read_state" with request:`,o);let c=await this._requestAndRetry(()=>this._fetch(""+new URL(`/api/v2/canister/${s}/read_state`,this._host),Object.assign(Object.assign(Object.assign({},this._fetchOptions),o.request),{body:a})));if(!c.ok)throw new Error(`Server returned an error:
21
- Code: ${c.status} (${c.statusText})
22
- Body: ${await c.text()}
23
- `);let f=_t(await c.arrayBuffer());this.log("Read state response:",f);let l=await this.parseTimeFromResponse(f);return l>0&&(this.log("Read state response time:",l),T0(this,Es,l,"f")),f}async parseTimeFromResponse(e){let r;if(e.certificate){let n=_t(e.certificate);if(n&&"tree"in n)r=n.tree;else throw new Error("Could not decode time from response");let i=gr(["time"],r);if(!i)throw new Error("Time was not found in the response or was not in its expected format.");if(!(i instanceof ArrayBuffer)&&!ArrayBuffer.isView(i))throw new Error("Time was not found in the response or was not in its expected format.");let s=nn(Io(i));return this.log("Time from response:",s),this.log("Time from response in milliseconds:",Number(s)),Number(s)}else this.log.warn("No certificate found in response");return 0}async syncTime(e){let r=await Promise.resolve().then(()=>(Yn(),hs)),n=Date.now();try{e||this.log("Syncing time with the IC. No canisterId provided, so falling back to ryjl3-tyaaa-aaaaa-aaaba-cai");let s=(await r.request({canisterId:e??ae.from("ryjl3-tyaaa-aaaaa-aaaba-cai"),agent:this,paths:["time"]})).get("time");s&&(this._timeDiffMsecs=Number(s)-Number(n))}catch(i){this.log.error("Caught exception while attempting to sync time",i)}}async status(){let e=this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{};this.log('fetching "/api/v2/status"');let r=await this._requestAndRetry(()=>this._fetch(""+new URL("/api/v2/status",this._host),Object.assign({headers:e},this._fetchOptions)));return _t(await r.arrayBuffer())}async fetchRootKey(){return this._rootKeyFetched||(this.rootKey=(await this.status()).root_key,this._rootKeyFetched=!0),this.rootKey}invalidateIdentity(){this._identity=null}replaceIdentity(e){this._identity=Promise.resolve(e)}async fetchSubnetKeys(e){let r=ae.from(e),i=(await ds({canisterId:r,paths:["subnet"],agent:this})).get("subnet");if(i&&typeof i=="object"&&"nodeKeys"in i)return ke(this,Pr,"f").set(r.toText(),i),i}_transform(e){let r=Promise.resolve(e);if(e.endpoint==="call")for(let n of ke(this,an,"f"))r=r.then(i=>n(i).then(s=>s||i));else for(let n of ke(this,on,"f"))r=r.then(i=>n(i).then(s=>s||i));return r}};Es=new WeakMap,on=new WeakMap,an=new WeakMap,Pr=new WeakMap,kr=new WeakMap,Bs=new WeakMap,Zn=new WeakSet,S0=async function t(e,r=0){var n,i;let{ecid:s,transformedRequest:o,body:a,requestId:c}=e,f;try{let v=await this._fetch(""+new URL(`/api/v2/canister/${s.toString()}/query`,this._host),Object.assign(Object.assign(Object.assign({},this._fetchOptions),o.request),{body:a}));if(v.status===200){let w=_t(await v.arrayBuffer());f=Object.assign(Object.assign({},w),{httpDetails:{ok:v.ok,status:v.status,statusText:v.statusText,headers:On(v.headers)},requestId:c})}else throw new Un(`Server returned an error:
24
- Code: ${v.status} (${v.statusText})
25
- Body: ${await v.text()}
26
- `,{ok:v.ok,status:v.status,statusText:v.statusText,headers:On(v.headers)})}catch(v){if(r<this._retryTimes)return this.log.warn(`Caught exception while attempting to make query:
27
- ${v}
28
- Retrying query.`),await ke(this,Zn,"m",t).call(this,e,r+1);throw v}let l=(i=(n=f.signatures)===null||n===void 0?void 0:n[0])===null||i===void 0?void 0:i.timestamp;if(!ke(this,kr,"f"))return f;if(!l)throw new Error("Timestamp not found in query response. This suggests a malformed or malicious response.");let d=Number(BigInt(l)/BigInt(1e6));if(this.log("watermark and timestamp",{waterMark:this.waterMark,timestamp:d}),Number(this.waterMark)>d){let v=new tt("Timestamp is below the watermark. Retrying query.");if(this.log.error("Timestamp is below",v,{timestamp:l,waterMark:this.waterMark}),r<this._retryTimes)return await ke(this,Zn,"m",t).call(this,e,r+1);throw new tt(`Timestamp failed to pass the watermark after retrying the configured ${this._retryTimes} times. We cannot guarantee the integrity of the response since it could be a replay attack.`)}return f};yt();var N0;(function(t){t.Error="err",t.GetPrincipal="gp",t.GetPrincipalResponse="gpr",t.Query="q",t.QueryResponse="qr",t.Call="c",t.CallResponse="cr",t.ReadState="rs",t.ReadStateResponse="rsr",t.Status="s",t.StatusResponse="sr"})(N0||(N0={}));function va(){let t=typeof window>"u"?typeof globalThis>"u"?typeof self>"u"?void 0:self.ic.agent:globalThis.ic.agent:window.ic.agent;if(!t)throw new Error("No Agent could be found.");return t}Zr();xn();jn();ht();var vs={};fn(vs,{backoff:()=>F0,chain:()=>P0,conditionalDelay:()=>O0,defaultStrategy:()=>R0,maxAttempts:()=>q1,once:()=>I0,throttle:()=>V1,timeout:()=>U0});ht();var C1=5*60*1e3;function R0(){return P0(O0(I0(),1e3),F0(1e3,1.2),U0(C1))}function I0(){let t=!0;return async()=>t?(t=!1,!0):!1}function O0(t,e){return async(r,n,i)=>{if(await t(r,n,i))return new Promise(s=>setTimeout(s,e))}}function q1(t){let e=t;return async(r,n,i)=>{if(--e<=0)throw new Error(`Failed to retrieve a reply for request after ${t} attempts:
29
- Request ID: ${Qe(n)}
1
+ "use strict";(()=>{var yl=Object.create;var ni=Object.defineProperty;var gl=Object.getOwnPropertyDescriptor;var wl=Object.getOwnPropertyNames;var bl=Object.getPrototypeOf,xl=Object.prototype.hasOwnProperty;var xe=(t,e)=>()=>(t&&(e=t(t=0)),e);var Ve=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),mn=(t,e)=>{for(var r in e)ni(t,r,{get:e[r],enumerable:!0})},Ka=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of wl(e))!xl.call(t,i)&&i!==r&&ni(t,i,{get:()=>e[i],enumerable:!(n=gl(e,i))||n.enumerable});return t};var Hr=(t,e,r)=>(r=t!=null?yl(bl(t)):{},Ka(e||!t||!t.__esModule?ni(r,"default",{value:t,enumerable:!0}):r,t)),_l=t=>Ka(ni({},"__esModule",{value:!0}),t);function Za(t){let e=0,r=0,n="";function i(s){return e<0?r|=s>>-e:r=s<<e&248,e>3?(e-=8,1):(e<4&&(n+=ii[r>>3],e+=5),0)}for(let s=0;s<t.length;)s+=i(t[s]);return n+(e<0?ii[r>>3]:"")}function Wa(t){let e=0,r=0,n=new Uint8Array(t.length*4/3|0),i=0;function s(o){let c=jr[o.toLowerCase()];if(c===void 0)throw new Error(`Invalid character: ${JSON.stringify(o)}`);c<<=3,r|=c>>>e,e+=5,e>=8&&(n[i++]=r,e-=8,e>0?r=c<<5-e&255:r=0)}for(let o of t)s(o);return n.slice(0,i)}var ii,jr,Xa=xe(()=>{ii="abcdefghijklmnopqrstuvwxyz234567",jr=Object.create(null);for(let t=0;t<ii.length;t++)jr[ii[t]]=t;jr[0]=jr.o;jr[1]=jr.i});function Ja(t){let e=new Uint8Array(t),r=-1;for(let n=0;n<e.length;n++){let s=(e[n]^r)&255;r=El[s]^r>>>8}return(r^-1)>>>0}var El,Qa=xe(()=>{El=new Uint32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117])});function Bl(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function si(t,...e){if(!Bl(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function Gs(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function La(t,e){si(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var Hs=xe(()=>{});var oi,Da=xe(()=>{oi=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0});function js(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Ys(t){return typeof t=="string"&&(t=js(t)),si(t),t}function ec(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];si(i),e+=i.length}let r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let s=t[n];r.set(s,i),i+=s.length}return r}function yn(t){let e=n=>t().update(Ys(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function ui(t=32){if(oi&&typeof oi.getRandomValues=="function")return oi.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}var ci,vt,tm,ai,rm,Yr=xe(()=>{Da();Hs();ci=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),vt=(t,e)=>t<<32-e|t>>>e,tm=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;ai=class{clone(){return this._cloneInto()}},rm={}.toString});function vl(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let i=BigInt(32),s=BigInt(4294967295),o=Number(r>>i&s),c=Number(r&s),a=n?4:0,d=n?0:4;t.setUint32(e+a,o,n),t.setUint32(e+d,c,n)}var tc,rc,zr,zs=xe(()=>{Hs();Yr();tc=(t,e,r)=>t&e^~t&r,rc=(t,e,r)=>t&e^t&r^e&r,zr=class extends ai{constructor(e,r,n,i){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=ci(this.buffer)}update(e){Gs(this);let{view:r,buffer:n,blockLen:i}=this;e=Ys(e);let s=e.length;for(let o=0;o<s;){let c=Math.min(i-this.pos,s-o);if(c===i){let a=ci(e);for(;i<=s-o;o+=i)this.process(a,o);continue}n.set(e.subarray(o,o+c),this.pos),this.pos+=c,o+=c,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Gs(this),La(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:s}=this,{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let f=o;f<i;f++)r[f]=0;vl(n,i-8,BigInt(this.length*8),s),this.process(n,0);let c=ci(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let d=a/4,l=this.get();if(d>l.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<d;f++)c.setUint32(4*f,l[f],s)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:s,destroyed:o,pos:c}=this;return e.length=i,e.pos=c,e.finished=s,e.destroyed=o,i%r&&e.buffer.set(n),e}}});var Al,ir,sr,fi,Ks,gn,nc,li=xe(()=>{zs();Yr();Al=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ir=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),sr=new Uint32Array(64),fi=class extends zr{constructor(){super(64,32,8,!1),this.A=ir[0]|0,this.B=ir[1]|0,this.C=ir[2]|0,this.D=ir[3]|0,this.E=ir[4]|0,this.F=ir[5]|0,this.G=ir[6]|0,this.H=ir[7]|0}get(){let{A:e,B:r,C:n,D:i,E:s,F:o,G:c,H:a}=this;return[e,r,n,i,s,o,c,a]}set(e,r,n,i,s,o,c,a){this.A=e|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=c|0,this.H=a|0}process(e,r){for(let f=0;f<16;f++,r+=4)sr[f]=e.getUint32(r,!1);for(let f=16;f<64;f++){let T=sr[f-15],_=sr[f-2],b=vt(T,7)^vt(T,18)^T>>>3,E=vt(_,17)^vt(_,19)^_>>>10;sr[f]=E+sr[f-7]+b+sr[f-16]|0}let{A:n,B:i,C:s,D:o,E:c,F:a,G:d,H:l}=this;for(let f=0;f<64;f++){let T=vt(c,6)^vt(c,11)^vt(c,25),_=l+T+tc(c,a,d)+Al[f]+sr[f]|0,E=(vt(n,2)^vt(n,13)^vt(n,22))+rc(n,i,s)|0;l=d,d=a,a=c,c=o+_|0,o=s,s=i,i=n,n=_+E|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,c=c+this.E|0,a=a+this.F|0,d=d+this.G|0,l=l+this.H|0,this.set(n,i,s,o,c,a,d,l)}roundClean(){sr.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},Ks=class extends fi{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}},gn=yn(()=>new fi),nc=yn(()=>new Ks)});function ic(t){return nc.create().update(new Uint8Array(t)).digest()}var sc=xe(()=>{li()});var di,Tl,oc,Sl,Nl,Rl,ae,gt=xe(()=>{Xa();Qa();sc();di="__principal__",Tl=2,oc=4,Sl="aaaaa-aa",Nl=t=>{var e;return new Uint8Array(((e=t.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(r=>parseInt(r,16)))},Rl=t=>t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),""),ae=class t{constructor(e){this._arr=e,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([oc]))}static managementCanister(){return this.fromHex(Sl)}static selfAuthenticating(e){let r=ic(e);return new this(new Uint8Array([...r,Tl]))}static from(e){if(typeof e=="string")return t.fromText(e);if(Object.getPrototypeOf(e)===Uint8Array.prototype)return new t(e);if(typeof e=="object"&&e!==null&&e._isPrincipal===!0)return new t(e._arr);throw new Error(`Impossible to convert ${JSON.stringify(e)} to Principal.`)}static fromHex(e){return new this(Nl(e))}static fromText(e){let r=e;if(e.includes(di)){let o=JSON.parse(e);di in o&&(r=o[di])}let n=r.toLowerCase().replace(/-/g,""),i=Wa(n);i=i.slice(4,i.length);let s=new this(i);if(s.toText()!==r)throw new Error(`Principal "${s.toText()}" does not have a valid checksum (original value "${r}" may not be a valid Principal ID).`);return s}static fromUint8Array(e){return new this(e)}isAnonymous(){return this._arr.byteLength===1&&this._arr[0]===oc}toUint8Array(){return this._arr}toHex(){return Rl(this._arr).toUpperCase()}toText(){let e=new ArrayBuffer(4);new DataView(e).setUint32(0,Ja(this._arr));let n=new Uint8Array(e),i=Uint8Array.from(this._arr),s=new Uint8Array([...n,...i]),c=Za(s).match(/.{1,5}/g);if(!c)throw new Error;return c.join("-")}toString(){return this.toText()}toJSON(){return{[di]:this.toText()}}compareTo(e){for(let r=0;r<Math.min(this._arr.length,e._arr.length);r++){if(this._arr[r]<e._arr[r])return"lt";if(this._arr[r]>e._arr[r])return"gt"}return this._arr.length<e._arr.length?"lt":this._arr.length>e._arr.length?"gt":"eq"}ltEq(e){let r=this.compareTo(e);return r=="lt"||r=="eq"}gtEq(e){let r=this.compareTo(e);return r=="gt"||r=="eq"}}});var lc=Ve(hi=>{"use strict";hi.byteLength=Ml;hi.toByteArray=Cl;hi.fromByteArray=Vl;var kt=[],wt=[],Pl=typeof Uint8Array<"u"?Uint8Array:Array,Xs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Ar=0,uc=Xs.length;Ar<uc;++Ar)kt[Ar]=Xs[Ar],wt[Xs.charCodeAt(Ar)]=Ar;var Ar,uc;wt[45]=62;wt[95]=63;function fc(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function Ml(t){var e=fc(t),r=e[0],n=e[1];return(r+n)*3/4-n}function kl(t,e,r){return(e+r)*3/4-r}function Cl(t){var e,r=fc(t),n=r[0],i=r[1],s=new Pl(kl(t,n,i)),o=0,c=i>0?n-4:n,a;for(a=0;a<c;a+=4)e=wt[t.charCodeAt(a)]<<18|wt[t.charCodeAt(a+1)]<<12|wt[t.charCodeAt(a+2)]<<6|wt[t.charCodeAt(a+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=wt[t.charCodeAt(a)]<<2|wt[t.charCodeAt(a+1)]>>4,s[o++]=e&255),i===1&&(e=wt[t.charCodeAt(a)]<<10|wt[t.charCodeAt(a+1)]<<4|wt[t.charCodeAt(a+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function ql(t){return kt[t>>18&63]+kt[t>>12&63]+kt[t>>6&63]+kt[t&63]}function $l(t,e,r){for(var n,i=[],s=e;s<r;s+=3)n=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(t[s+2]&255),i.push(ql(n));return i.join("")}function Vl(t){for(var e,r=t.length,n=r%3,i=[],s=16383,o=0,c=r-n;o<c;o+=s)i.push($l(t,o,o+s>c?c:o+s));return n===1?(e=t[r-1],i.push(kt[e>>2]+kt[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(kt[e>>10]+kt[e>>4&63]+kt[e<<2&63]+"=")),i.join("")}});var Qs=Ve(Js=>{Js.read=function(t,e,r,n,i){var s,o,c=i*8-n-1,a=(1<<c)-1,d=a>>1,l=-7,f=r?i-1:0,T=r?-1:1,_=t[e+f];for(f+=T,s=_&(1<<-l)-1,_>>=-l,l+=c;l>0;s=s*256+t[e+f],f+=T,l-=8);for(o=s&(1<<-l)-1,s>>=-l,l+=n;l>0;o=o*256+t[e+f],f+=T,l-=8);if(s===0)s=1-d;else{if(s===a)return o?NaN:(_?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-d}return(_?-1:1)*o*Math.pow(2,s-n)};Js.write=function(t,e,r,n,i,s){var o,c,a,d=s*8-i-1,l=(1<<d)-1,f=l>>1,T=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,_=n?0:s-1,b=n?1:-1,E=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(c=isNaN(e)?1:0,o=l):(o=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-o))<1&&(o--,a*=2),o+f>=1?e+=T/a:e+=T*Math.pow(2,1-f),e*a>=2&&(o++,a/=2),o+f>=l?(c=0,o=l):o+f>=1?(c=(e*a-1)*Math.pow(2,i),o=o+f):(c=e*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;t[r+_]=c&255,_+=b,c/=256,i-=8);for(o=o<<i|c,d+=i;d>0;t[r+_]=o&255,_+=b,o/=256,d-=8);t[r+_-b]|=E*128}});var Nc=Ve(Jr=>{"use strict";var Ls=lc(),Wr=Qs(),dc=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Jr.Buffer=P;Jr.SlowBuffer=Kl;Jr.INSPECT_MAX_BYTES=50;var pi=2147483647;Jr.kMaxLength=pi;P.TYPED_ARRAY_SUPPORT=Gl();!P.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function Gl(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(P.prototype,"parent",{enumerable:!0,get:function(){if(P.isBuffer(this))return this.buffer}});Object.defineProperty(P.prototype,"offset",{enumerable:!0,get:function(){if(P.isBuffer(this))return this.byteOffset}});function Qt(t){if(t>pi)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,P.prototype),e}function P(t,e,r){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return ro(t)}return yc(t,e,r)}P.poolSize=8192;function yc(t,e,r){if(typeof t=="string")return jl(t,e);if(ArrayBuffer.isView(t))return Yl(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Ct(t,ArrayBuffer)||t&&Ct(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Ct(t,SharedArrayBuffer)||t&&Ct(t.buffer,SharedArrayBuffer)))return eo(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=t.valueOf&&t.valueOf();if(n!=null&&n!==t)return P.from(n,e,r);let i=zl(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return P.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}P.from=function(t,e,r){return yc(t,e,r)};Object.setPrototypeOf(P.prototype,Uint8Array.prototype);Object.setPrototypeOf(P,Uint8Array);function gc(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function Hl(t,e,r){return gc(t),t<=0?Qt(t):e!==void 0?typeof r=="string"?Qt(t).fill(e,r):Qt(t).fill(e):Qt(t)}P.alloc=function(t,e,r){return Hl(t,e,r)};function ro(t){return gc(t),Qt(t<0?0:no(t)|0)}P.allocUnsafe=function(t){return ro(t)};P.allocUnsafeSlow=function(t){return ro(t)};function jl(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!P.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=wc(t,e)|0,n=Qt(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function Ds(t){let e=t.length<0?0:no(t.length)|0,r=Qt(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function Yl(t){if(Ct(t,Uint8Array)){let e=new Uint8Array(t);return eo(e.buffer,e.byteOffset,e.byteLength)}return Ds(t)}function eo(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&r===void 0?n=new Uint8Array(t):r===void 0?n=new Uint8Array(t,e):n=new Uint8Array(t,e,r),Object.setPrototypeOf(n,P.prototype),n}function zl(t){if(P.isBuffer(t)){let e=no(t.length)|0,r=Qt(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||so(t.length)?Qt(0):Ds(t);if(t.type==="Buffer"&&Array.isArray(t.data))return Ds(t.data)}function no(t){if(t>=pi)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+pi.toString(16)+" bytes");return t|0}function Kl(t){return+t!=t&&(t=0),P.alloc(+t)}P.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==P.prototype};P.compare=function(e,r){if(Ct(e,Uint8Array)&&(e=P.from(e,e.offset,e.byteLength)),Ct(r,Uint8Array)&&(r=P.from(r,r.offset,r.byteLength)),!P.isBuffer(e)||!P.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;let n=e.length,i=r.length;for(let s=0,o=Math.min(n,i);s<o;++s)if(e[s]!==r[s]){n=e[s],i=r[s];break}return n<i?-1:i<n?1:0};P.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};P.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return P.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=P.allocUnsafe(r),s=0;for(n=0;n<e.length;++n){let o=e[n];if(Ct(o,Uint8Array))s+o.length>i.length?(P.isBuffer(o)||(o=P.from(o)),o.copy(i,s)):Uint8Array.prototype.set.call(i,o,s);else if(P.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function wc(t,e){if(P.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Ct(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let r=t.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return to(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Sc(t).length;default:if(i)return n?-1:to(t).length;e=(""+e).toLowerCase(),i=!0}}P.byteLength=wc;function Zl(t,e,r){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return nd(this,e,r);case"utf8":case"utf-8":return xc(this,e,r);case"ascii":return td(this,e,r);case"latin1":case"binary":return rd(this,e,r);case"base64":return Dl(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return id(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}P.prototype._isBuffer=!0;function Tr(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}P.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<e;r+=2)Tr(this,r,r+1);return this};P.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<e;r+=4)Tr(this,r,r+3),Tr(this,r+1,r+2);return this};P.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<e;r+=8)Tr(this,r,r+7),Tr(this,r+1,r+6),Tr(this,r+2,r+5),Tr(this,r+3,r+4);return this};P.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?xc(this,0,e):Zl.apply(this,arguments)};P.prototype.toLocaleString=P.prototype.toString;P.prototype.equals=function(e){if(!P.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:P.compare(this,e)===0};P.prototype.inspect=function(){let e="",r=Jr.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};dc&&(P.prototype[dc]=P.prototype.inspect);P.prototype.compare=function(e,r,n,i,s){if(Ct(e,Uint8Array)&&(e=P.from(e,e.offset,e.byteLength)),!P.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),r<0||n>e.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&r>=n)return 0;if(i>=s)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,s>>>=0,this===e)return 0;let o=s-i,c=n-r,a=Math.min(o,c),d=this.slice(i,s),l=e.slice(r,n);for(let f=0;f<a;++f)if(d[f]!==l[f]){o=d[f],c=l[f];break}return o<c?-1:c<o?1:0};function bc(t,e,r,n,i){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,so(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof e=="string"&&(e=P.from(e,n)),P.isBuffer(e))return e.length===0?-1:hc(t,e,r,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):hc(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function hc(t,e,r,n,i){let s=1,o=t.length,c=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;s=2,o/=2,c/=2,r/=2}function a(l,f){return s===1?l[f]:l.readUInt16BE(f*s)}let d;if(i){let l=-1;for(d=r;d<o;d++)if(a(t,d)===a(e,l===-1?0:d-l)){if(l===-1&&(l=d),d-l+1===c)return l*s}else l!==-1&&(d-=d-l),l=-1}else for(r+c>o&&(r=o-c),d=r;d>=0;d--){let l=!0;for(let f=0;f<c;f++)if(a(t,d+f)!==a(e,f)){l=!1;break}if(l)return d}return-1}P.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};P.prototype.indexOf=function(e,r,n){return bc(this,e,r,n,!0)};P.prototype.lastIndexOf=function(e,r,n){return bc(this,e,r,n,!1)};function Wl(t,e,r,n){r=Number(r)||0;let i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let s=e.length;n>s/2&&(n=s/2);let o;for(o=0;o<n;++o){let c=parseInt(e.substr(o*2,2),16);if(so(c))return o;t[r+o]=c}return o}function Xl(t,e,r,n){return mi(to(e,t.length-r),t,r,n)}function Jl(t,e,r,n){return mi(cd(e),t,r,n)}function Ql(t,e,r,n){return mi(Sc(e),t,r,n)}function Ll(t,e,r,n){return mi(ud(e,t.length-r),t,r,n)}P.prototype.write=function(e,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let s=this.length-r;if((n===void 0||n>s)&&(n=s),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let o=!1;for(;;)switch(i){case"hex":return Wl(this,e,r,n);case"utf8":case"utf-8":return Xl(this,e,r,n);case"ascii":case"latin1":case"binary":return Jl(this,e,r,n);case"base64":return Ql(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ll(this,e,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};P.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Dl(t,e,r){return e===0&&r===t.length?Ls.fromByteArray(t):Ls.fromByteArray(t.slice(e,r))}function xc(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i<r;){let s=t[i],o=null,c=s>239?4:s>223?3:s>191?2:1;if(i+c<=r){let a,d,l,f;switch(c){case 1:s<128&&(o=s);break;case 2:a=t[i+1],(a&192)===128&&(f=(s&31)<<6|a&63,f>127&&(o=f));break;case 3:a=t[i+1],d=t[i+2],(a&192)===128&&(d&192)===128&&(f=(s&15)<<12|(a&63)<<6|d&63,f>2047&&(f<55296||f>57343)&&(o=f));break;case 4:a=t[i+1],d=t[i+2],l=t[i+3],(a&192)===128&&(d&192)===128&&(l&192)===128&&(f=(s&15)<<18|(a&63)<<12|(d&63)<<6|l&63,f>65535&&f<1114112&&(o=f))}}o===null?(o=65533,c=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=c}return ed(n)}var pc=4096;function ed(t){let e=t.length;if(e<=pc)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=pc));return r}function td(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]&127);return n}function rd(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function nd(t,e,r){let n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let s=e;s<r;++s)i+=fd[t[s]];return i}function id(t,e,r){let n=t.slice(e,r),i="";for(let s=0;s<n.length-1;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}P.prototype.slice=function(e,r){let n=this.length;e=~~e,r=r===void 0?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);let i=this.subarray(e,r);return Object.setPrototypeOf(i,P.prototype),i};function Qe(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}P.prototype.readUintLE=P.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||Qe(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return i};P.prototype.readUintBE=P.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||Qe(e,r,this.length);let i=this[e+--r],s=1;for(;r>0&&(s*=256);)i+=this[e+--r]*s;return i};P.prototype.readUint8=P.prototype.readUInt8=function(e,r){return e=e>>>0,r||Qe(e,1,this.length),this[e]};P.prototype.readUint16LE=P.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||Qe(e,2,this.length),this[e]|this[e+1]<<8};P.prototype.readUint16BE=P.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||Qe(e,2,this.length),this[e]<<8|this[e+1]};P.prototype.readUint32LE=P.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||Qe(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};P.prototype.readUint32BE=P.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||Qe(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};P.prototype.readBigUInt64LE=ar(function(e){e=e>>>0,Xr(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&bn(e,this.length-8);let i=r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,s=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(s)<<BigInt(32))});P.prototype.readBigUInt64BE=ar(function(e){e=e>>>0,Xr(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&bn(e,this.length-8);let i=r*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],s=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(s)});P.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||Qe(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*r)),i};P.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||Qe(e,r,this.length);let i=r,s=1,o=this[e+--i];for(;i>0&&(s*=256);)o+=this[e+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*r)),o};P.prototype.readInt8=function(e,r){return e=e>>>0,r||Qe(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};P.prototype.readInt16LE=function(e,r){e=e>>>0,r||Qe(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};P.prototype.readInt16BE=function(e,r){e=e>>>0,r||Qe(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};P.prototype.readInt32LE=function(e,r){return e=e>>>0,r||Qe(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};P.prototype.readInt32BE=function(e,r){return e=e>>>0,r||Qe(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};P.prototype.readBigInt64LE=ar(function(e){e=e>>>0,Xr(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&bn(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});P.prototype.readBigInt64BE=ar(function(e){e=e>>>0,Xr(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&bn(e,this.length-8);let i=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});P.prototype.readFloatLE=function(e,r){return e=e>>>0,r||Qe(e,4,this.length),Wr.read(this,e,!0,23,4)};P.prototype.readFloatBE=function(e,r){return e=e>>>0,r||Qe(e,4,this.length),Wr.read(this,e,!1,23,4)};P.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||Qe(e,8,this.length),Wr.read(this,e,!0,52,8)};P.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||Qe(e,8,this.length),Wr.read(this,e,!1,52,8)};function ft(t,e,r,n,i,s){if(!P.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}P.prototype.writeUintLE=P.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;ft(this,e,r,n,c,0)}let s=1,o=0;for(this[r]=e&255;++o<n&&(s*=256);)this[r+o]=e/s&255;return r+n};P.prototype.writeUintBE=P.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;ft(this,e,r,n,c,0)}let s=n-1,o=1;for(this[r+s]=e&255;--s>=0&&(o*=256);)this[r+s]=e/o&255;return r+n};P.prototype.writeUint8=P.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||ft(this,e,r,1,255,0),this[r]=e&255,r+1};P.prototype.writeUint16LE=P.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||ft(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};P.prototype.writeUint16BE=P.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||ft(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};P.prototype.writeUint32LE=P.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||ft(this,e,r,4,4294967295,0),this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255,r+4};P.prototype.writeUint32BE=P.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||ft(this,e,r,4,4294967295,0),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};function _c(t,e,r,n,i){Tc(e,n,i,t,r,7);let s=Number(e&BigInt(4294967295));t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,r}function Ec(t,e,r,n,i){Tc(e,n,i,t,r,7);let s=Number(e&BigInt(4294967295));t[r+7]=s,s=s>>8,t[r+6]=s,s=s>>8,t[r+5]=s,s=s>>8,t[r+4]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=o,o=o>>8,t[r+2]=o,o=o>>8,t[r+1]=o,o=o>>8,t[r]=o,r+8}P.prototype.writeBigUInt64LE=ar(function(e,r=0){return _c(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});P.prototype.writeBigUInt64BE=ar(function(e,r=0){return Ec(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});P.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let a=Math.pow(2,8*n-1);ft(this,e,r,n,a-1,-a)}let s=0,o=1,c=0;for(this[r]=e&255;++s<n&&(o*=256);)e<0&&c===0&&this[r+s-1]!==0&&(c=1),this[r+s]=(e/o>>0)-c&255;return r+n};P.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let a=Math.pow(2,8*n-1);ft(this,e,r,n,a-1,-a)}let s=n-1,o=1,c=0;for(this[r+s]=e&255;--s>=0&&(o*=256);)e<0&&c===0&&this[r+s+1]!==0&&(c=1),this[r+s]=(e/o>>0)-c&255;return r+n};P.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||ft(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};P.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||ft(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};P.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||ft(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};P.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||ft(this,e,r,4,2147483647,-2147483648),this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24,r+4};P.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||ft(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};P.prototype.writeBigInt64LE=ar(function(e,r=0){return _c(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});P.prototype.writeBigInt64BE=ar(function(e,r=0){return Ec(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Bc(t,e,r,n,i,s){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function vc(t,e,r,n,i){return e=+e,r=r>>>0,i||Bc(t,e,r,4,34028234663852886e22,-34028234663852886e22),Wr.write(t,e,r,n,23,4),r+4}P.prototype.writeFloatLE=function(e,r,n){return vc(this,e,r,!0,n)};P.prototype.writeFloatBE=function(e,r,n){return vc(this,e,r,!1,n)};function Ac(t,e,r,n,i){return e=+e,r=r>>>0,i||Bc(t,e,r,8,17976931348623157e292,-17976931348623157e292),Wr.write(t,e,r,n,52,8),r+8}P.prototype.writeDoubleLE=function(e,r,n){return Ac(this,e,r,!0,n)};P.prototype.writeDoubleBE=function(e,r,n){return Ac(this,e,r,!1,n)};P.prototype.copy=function(e,r,n,i){if(!P.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r<i-n&&(i=e.length-r+n);let s=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),r),s};P.prototype.fill=function(e,r,n,i){if(typeof e=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!P.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let o=e.charCodeAt(0);(i==="utf8"&&o<128||i==="latin1")&&(e=o)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let s;if(typeof e=="number")for(s=r;s<n;++s)this[s]=e;else{let o=P.isBuffer(e)?e:P.from(e,i),c=o.length;if(c===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(s=0;s<n-r;++s)this[s+r]=o[s%c]}return this};var Zr={};function io(t,e,r){Zr[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}io("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);io("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);io("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=mc(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=mc(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function mc(t){let e="",r=t.length,n=t[0]==="-"?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function sd(t,e,r){Xr(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&bn(e,t.length-(r+1))}function Tc(t,e,r,n,i,s){if(t>r||t<e){let o=typeof e=="bigint"?"n":"",c;throw s>3?e===0||e===BigInt(0)?c=`>= 0${o} and < 2${o} ** ${(s+1)*8}${o}`:c=`>= -(2${o} ** ${(s+1)*8-1}${o}) and < 2 ** ${(s+1)*8-1}${o}`:c=`>= ${e}${o} and <= ${r}${o}`,new Zr.ERR_OUT_OF_RANGE("value",c,t)}sd(n,i,s)}function Xr(t,e){if(typeof t!="number")throw new Zr.ERR_INVALID_ARG_TYPE(e,"number",t)}function bn(t,e,r){throw Math.floor(t)!==t?(Xr(t,r),new Zr.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new Zr.ERR_BUFFER_OUT_OF_BOUNDS:new Zr.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var od=/[^+/0-9A-Za-z-_]/g;function ad(t){if(t=t.split("=")[0],t=t.trim().replace(od,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function to(t,e){e=e||1/0;let r,n=t.length,i=null,s=[];for(let o=0;o<n;++o){if(r=t.charCodeAt(o),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return s}function cd(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function ud(t,e){let r,n,i,s=[];for(let o=0;o<t.length&&!((e-=2)<0);++o)r=t.charCodeAt(o),n=r>>8,i=r%256,s.push(i),s.push(n);return s}function Sc(t){return Ls.toByteArray(ad(t))}function mi(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function Ct(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function so(t){return t!==t}var fd=function(){let t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function ar(t){return typeof BigInt>"u"?ld:t}function ld(){throw new Error("BigInt not supported")}});var Ke,Qr=xe(()=>{Ke=class t extends Error{constructor(e){super(e),this.message=e,Object.setPrototypeOf(this,t.prototype)}}});function ve(...t){let e=new Uint8Array(t.reduce((n,i)=>n+i.byteLength,0)),r=0;for(let n of t)e.set(new Uint8Array(n),r),r+=n.byteLength;return e}function oo(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}function ao(t){return t instanceof Uint8Array?oo(t):t instanceof ArrayBuffer?t:Array.isArray(t)?oo(new Uint8Array(t)):"buffer"in t?ao(t.buffer):oo(new Uint8Array(t))}var At,gi=xe(()=>{At=class{constructor(e,r=e?.byteLength||0){this._buffer=ao(e||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return ao(this._view.slice())}get byteLength(){return this._view.byteLength}read(e){let r=this._view.subarray(0,e);return this._view=this._view.subarray(e),r.slice().buffer}readUint8(){let e=this._view[0];return this._view=this._view.subarray(1),e}write(e){let r=new Uint8Array(e),n=this._view.byteLength;this._view.byteOffset+this._view.byteLength+r.byteLength>=this._buffer.byteLength?this.alloc(r.byteLength):this._view=new Uint8Array(this._buffer,this._view.byteOffset,this._view.byteLength+r.byteLength),this._view.set(r,n)}get end(){return this._view.byteLength===0}alloc(e){let r=new ArrayBuffer((this._buffer.byteLength+e)*1.2|0),n=new Uint8Array(r,0,this._view.byteLength+e);n.set(this._view),this._buffer=r,this._view=n}}});function dd(t){let r=new TextEncoder().encode(t),n=0;for(let i of r)n=(n*223+i)%2**32;return n}function Tt(t){if(/^_\d+_$/.test(t)||/^_0x[0-9a-fA-F]+_$/.test(t)){let e=+t.slice(1,-1);if(Number.isSafeInteger(e)&&e>=0&&e<2**32)return e}return dd(t)}var co=xe(()=>{});function Rc(){throw new Error("unexpected end of buffer")}function ur(t,e){return t.byteLength<e&&Rc(),t.read(e)}function cr(t){let e=t.readUint8();return e===void 0&&Rc(),e}function Oe(t){if(typeof t=="number"&&(t=BigInt(t)),t<BigInt(0))throw new Error("Cannot leb encode negative values.");let e=(t===BigInt(0)?0:Math.ceil(Math.log2(Number(t))))+1,r=new At(new ArrayBuffer(e),0);for(;;){let n=Number(t&BigInt(127));if(t/=BigInt(128),t===BigInt(0)){r.write(new Uint8Array([n]));break}else r.write(new Uint8Array([n|128]))}return r.buffer}function Ge(t){let e=BigInt(1),r=BigInt(0),n;do n=cr(t),r+=BigInt(n&127).valueOf()*e,e*=BigInt(128);while(n>=128);return r}function He(t){typeof t=="number"&&(t=BigInt(t));let e=t<BigInt(0);e&&(t=-t-BigInt(1));let r=(t===BigInt(0)?0:Math.ceil(Math.log2(Number(t))))+1,n=new At(new ArrayBuffer(r),0);for(;;){let s=i(t);if(t/=BigInt(128),e&&t===BigInt(0)&&s&64||!e&&t===BigInt(0)&&!(s&64)){n.write(new Uint8Array([s]));break}else n.write(new Uint8Array([s|128]))}function i(s){let o=s%BigInt(128);return Number(e?BigInt(128)-o-BigInt(1):o)}return n.buffer}function Lt(t){let e=new Uint8Array(t.buffer),r=0;for(;r<e.byteLength;r++)if(e[r]<128){if(!(e[r]&64))return Ge(t);break}let n=new Uint8Array(ur(t,r+1)),i=BigInt(0);for(let s=n.byteLength-1;s>=0;s--)i=i*BigInt(128)+BigInt(128-(n[s]&127)-1);return-i-BigInt(1)}function Ic(t,e){if(BigInt(t)<BigInt(0))throw new Error("Cannot write negative values.");return uo(t,e)}function uo(t,e){t=BigInt(t);let r=new At(new ArrayBuffer(Math.min(1,e)),0),n=0,i=BigInt(256),s=BigInt(0),o=Number(t%i);for(r.write(new Uint8Array([o]));++n<e;)t<0&&s===BigInt(0)&&o!==0&&(s=BigInt(1)),o=Number((t/i-s)%BigInt(256)),r.write(new Uint8Array([o])),i*=BigInt(256);return r.buffer}function fo(t,e){let r=BigInt(cr(t)),n=BigInt(1),i=0;for(;++i<e;){n*=BigInt(256);let s=BigInt(cr(t));r=r+n*s}return r}function Oc(t,e){let r=fo(t,e),n=BigInt(2)**(BigInt(8)*BigInt(e-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}var lo=xe(()=>{gi()});function wi(t){let e=BigInt(t);if(t<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<e}var Uc=xe(()=>{});var lr={};mn(lr,{Bool:()=>kc,BoolClass:()=>Bi,ConstructType:()=>$t,Empty:()=>Pc,EmptyClass:()=>_i,FixedIntClass:()=>Dt,FixedNatClass:()=>qt,Float32:()=>Gc,Float64:()=>Hc,FloatClass:()=>_n,Func:()=>iu,FuncClass:()=>Bn,Int:()=>$c,Int16:()=>Yc,Int32:()=>zc,Int64:()=>Kc,Int8:()=>jc,IntClass:()=>Ti,Nat:()=>Vc,Nat16:()=>Wc,Nat32:()=>Xc,Nat64:()=>Jc,Nat8:()=>Zc,NatClass:()=>Si,Null:()=>Cc,NullClass:()=>vi,Opt:()=>eu,OptClass:()=>en,PrimitiveType:()=>lt,Principal:()=>Qc,PrincipalClass:()=>Oi,Rec:()=>nu,RecClass:()=>fr,Record:()=>tu,RecordClass:()=>En,Reserved:()=>Mc,ReservedClass:()=>Dr,Service:()=>su,ServiceClass:()=>Ui,Text:()=>qc,TextClass:()=>Ai,Tuple:()=>Lc,TupleClass:()=>Ri,Type:()=>Lr,Unknown:()=>md,UnknownClass:()=>Ei,Variant:()=>ru,VariantClass:()=>Ii,Vec:()=>Dc,VecClass:()=>Ni,Visitor:()=>xi,decode:()=>pd,encode:()=>hd});function xn(t,e,r){return t.map((n,i)=>r(n,e[i]))}function po(t){if(cr(t)!==1)throw new Error("Cannot decode principal");let r=Number(Ge(t));return ae.fromUint8Array(new Uint8Array(ur(t,r)))}function Ce(t){let e=JSON.stringify(t,(r,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return e&&e.length>Fc?e.substring(0,Fc-3)+"...":e}function hd(t,e){if(e.length<t.length)throw Error("Wrong number of message arguments");let r=new ho;t.forEach(a=>a.buildTypeTable(r));let n=new TextEncoder().encode(bi),i=r.encode(),s=Oe(e.length),o=ve(...t.map(a=>a.encodeType(r))),c=ve(...xn(t,e,(a,d)=>{try{a.covariant(d)}catch(l){throw new Error(l.message+`
2
+
3
+ `)}return a.encodeValue(d)}));return ve(n,i,s,o,c)}function pd(t,e){let r=new At(e);if(e.byteLength<bi.length)throw new Error("Message length smaller than magic number");let n=ur(r,bi.length),i=new TextDecoder().decode(n);if(i!==bi)throw new Error("Wrong magic number: "+JSON.stringify(i));function s(_){let b=[],E=Number(Ge(_));for(let $=0;$<E;$++){let M=Number(Lt(_));switch(M){case-18:case-19:{let K=Number(Lt(_));b.push([M,K]);break}case-20:case-21:{let K=[],F=Number(Ge(_)),k;for(;F--;){let z=Number(Ge(_));if(z>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof k=="number"&&k>=z)throw new Error("field id collision or not sorted");k=z;let Y=Number(Lt(_));K.push([z,Y])}b.push([M,K]);break}case-22:{let K=[],F=Number(Ge(_));for(;F--;)K.push(Number(Lt(_)));let k=[],z=Number(Ge(_));for(;z--;)k.push(Number(Lt(_)));let Y=[],G=Number(Ge(_));for(;G--;)switch(Number(Ge(_))){case 1:{Y.push("query");break}case 2:{Y.push("oneway");break}case 3:{Y.push("composite_query");break}default:throw new Error("unknown annotation")}b.push([M,[K,k,Y]]);break}case-23:{let K=Number(Ge(_)),F=[];for(;K--;){let k=Number(Ge(_)),z=new TextDecoder().decode(ur(_,k)),Y=Lt(_);F.push([z,Y])}b.push([M,F]);break}default:throw new Error("Illegal op_code: "+M)}}let U=[],I=Number(Ge(_));for(let $=0;$<I;$++)U.push(Number(Lt(_)));return[b,U]}let[o,c]=s(r);if(c.length<t.length)throw new Error("Wrong number of return values");let a=o.map(_=>nu());function d(_){if(_<-24)throw new Error("future value not supported");if(_<0)switch(_){case-1:return Cc;case-2:return kc;case-3:return Vc;case-4:return $c;case-5:return Zc;case-6:return Wc;case-7:return Xc;case-8:return Jc;case-9:return jc;case-10:return Yc;case-11:return zc;case-12:return Kc;case-13:return Gc;case-14:return Hc;case-15:return qc;case-16:return Mc;case-17:return Pc;case-24:return Qc;default:throw new Error("Illegal op_code: "+_)}if(_>=o.length)throw new Error("type index out of range");return a[_]}function l(_){switch(_[0]){case-19:{let b=d(_[1]);return Dc(b)}case-18:{let b=d(_[1]);return eu(b)}case-20:{let b={};for(let[I,$]of _[1]){let M=`_${I}_`;b[M]=d($)}let E=tu(b),U=E.tryAsTuple();return Array.isArray(U)?Lc(...U):E}case-21:{let b={};for(let[E,U]of _[1]){let I=`_${E}_`;b[I]=d(U)}return ru(b)}case-22:{let[b,E,U]=_[1];return iu(b.map(I=>d(I)),E.map(I=>d(I)),U)}case-23:{let b={},E=_[1];for(let[U,I]of E){let $=d(I);if($ instanceof fr&&($=$.getType()),!($ instanceof Bn))throw new Error("Illegal service definition: services can only contain functions");b[U]=$}return su(b)}default:throw new Error("Illegal op_code: "+_[0])}}o.forEach((_,b)=>{if(_[0]===-22){let E=l(_);a[b].fill(E)}}),o.forEach((_,b)=>{if(_[0]!==-22){let E=l(_);a[b].fill(E)}});let f=c.map(_=>d(_)),T=t.map((_,b)=>_.decodeValue(r,f[b]));for(let _=t.length;_<f.length;_++)f[_].decodeValue(r,f[_]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return T}function Lc(...t){return new Ri(t)}function Dc(t){return new Ni(t)}function eu(t){return new en(t)}function tu(t){return new En(t)}function ru(t){return new Ii(t)}function nu(){return new fr}function iu(t,e,r=[]){return new Bn(t,e,r)}function su(t){return new Ui(t)}var bi,Fc,ho,xi,Lr,lt,$t,_i,Ei,Bi,vi,Dr,Ai,Ti,Si,_n,Dt,qt,Ni,en,En,Ri,Ii,fr,Oi,Bn,Ui,Pc,Mc,md,kc,Cc,qc,$c,Vc,Gc,Hc,jc,Yc,zc,Kc,Zc,Wc,Xc,Jc,Qc,mo=xe(()=>{gt();gi();co();lo();Uc();bi="DIDL",Fc=400;ho=class{constructor(){this._typs=[],this._idx=new Map}has(e){return this._idx.has(e.name)}add(e,r){let n=this._typs.length;this._idx.set(e.name,n),this._typs.push(r)}merge(e,r){let n=this._idx.get(e.name),i=this._idx.get(r);if(n===void 0)throw new Error("Missing type index for "+e);if(i===void 0)throw new Error("Missing type index for "+r);this._typs[n]=this._typs[i],this._typs.splice(i,1),this._idx.delete(r)}encode(){let e=Oe(this._typs.length),r=ve(...this._typs);return ve(e,r)}indexOf(e){if(!this._idx.has(e))throw new Error("Missing type index for "+e);return He(this._idx.get(e)||0)}},xi=class{visitType(e,r){throw new Error("Not implemented")}visitPrimitive(e,r){return this.visitType(e,r)}visitEmpty(e,r){return this.visitPrimitive(e,r)}visitBool(e,r){return this.visitPrimitive(e,r)}visitNull(e,r){return this.visitPrimitive(e,r)}visitReserved(e,r){return this.visitPrimitive(e,r)}visitText(e,r){return this.visitPrimitive(e,r)}visitNumber(e,r){return this.visitPrimitive(e,r)}visitInt(e,r){return this.visitNumber(e,r)}visitNat(e,r){return this.visitNumber(e,r)}visitFloat(e,r){return this.visitPrimitive(e,r)}visitFixedInt(e,r){return this.visitNumber(e,r)}visitFixedNat(e,r){return this.visitNumber(e,r)}visitPrincipal(e,r){return this.visitPrimitive(e,r)}visitConstruct(e,r){return this.visitType(e,r)}visitVec(e,r,n){return this.visitConstruct(e,n)}visitOpt(e,r,n){return this.visitConstruct(e,n)}visitRecord(e,r,n){return this.visitConstruct(e,n)}visitTuple(e,r,n){let i=r.map((s,o)=>[`_${o}_`,s]);return this.visitRecord(e,i,n)}visitVariant(e,r,n){return this.visitConstruct(e,n)}visitRec(e,r,n){return this.visitConstruct(r,n)}visitFunc(e,r){return this.visitConstruct(e,r)}visitService(e,r){return this.visitConstruct(e,r)}},Lr=class{display(){return this.name}valueToString(e){return Ce(e)}buildTypeTable(e){e.has(this)||this._buildTypeTableImpl(e)}},lt=class extends Lr{checkType(e){if(this.name!==e.name)throw new Error(`type mismatch: type on the wire ${e.name}, expect type ${this.name}`);return e}_buildTypeTableImpl(e){}},$t=class extends Lr{checkType(e){if(e instanceof fr){let r=e.getType();if(typeof r>"u")throw new Error("type mismatch with uninitialized type");return r}throw new Error(`type mismatch: type on the wire ${e.name}, expect type ${this.name}`)}encodeType(e){return e.indexOf(this.name)}},_i=class extends lt{accept(e,r){return e.visitEmpty(this,r)}covariant(e){throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return He(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}},Ei=class extends Lr{checkType(e){throw new Error("Method not implemented for unknown.")}accept(e,r){throw e.visitType(this,r)}covariant(e){throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(){throw new Error("Unknown cannot appear as a function argument")}valueToString(){throw new Error("Unknown cannot appear as a value")}encodeType(){throw new Error("Unknown cannot be serialized")}decodeValue(e,r){let n=r.decodeValue(e,r);Object(n)!==n&&(n=Object(n));let i;return r instanceof fr?i=()=>r.getType():i=()=>r,Object.defineProperty(n,"type",{value:i,writable:!0,enumerable:!1,configurable:!0}),n}_buildTypeTableImpl(){throw new Error("Unknown cannot be serialized")}get name(){return"Unknown"}},Bi=class extends lt{accept(e,r){return e.visitBool(this,r)}covariant(e){if(typeof e=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){return new Uint8Array([e?1:0])}encodeType(){return He(-2)}decodeValue(e,r){switch(this.checkType(r),cr(e)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}},vi=class extends lt{accept(e,r){return e.visitNull(this,r)}covariant(e){if(e===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return He(-1)}decodeValue(e,r){return this.checkType(r),null}get name(){return"null"}},Dr=class extends lt{accept(e,r){return e.visitReserved(this,r)}covariant(e){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return He(-16)}decodeValue(e,r){return r.name!==this.name&&r.decodeValue(e,r),null}get name(){return"reserved"}},Ai=class extends lt{accept(e,r){return e.visitText(this,r)}covariant(e){if(typeof e=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){let r=new TextEncoder().encode(e),n=Oe(r.byteLength);return ve(n,r)}encodeType(){return He(-15)}decodeValue(e,r){this.checkType(r);let n=Ge(e),i=ur(e,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(i)}get name(){return"text"}valueToString(e){return'"'+e+'"'}},Ti=class extends lt{accept(e,r){return e.visitInt(this,r)}covariant(e){if(typeof e=="bigint"||Number.isInteger(e))return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){return He(e)}encodeType(){return He(-4)}decodeValue(e,r){return this.checkType(r),Lt(e)}get name(){return"int"}valueToString(e){return e.toString()}},Si=class extends lt{accept(e,r){return e.visitNat(this,r)}covariant(e){if(typeof e=="bigint"&&e>=BigInt(0)||Number.isInteger(e)&&e>=0)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){return Oe(e)}encodeType(){return He(-3)}decodeValue(e,r){return this.checkType(r),Ge(e)}get name(){return"nat"}valueToString(e){return e.toString()}},_n=class extends lt{constructor(e){if(super(),this._bits=e,e!==32&&e!==64)throw new Error("not a valid float type")}accept(e,r){return e.visitFloat(this,r)}covariant(e){if(typeof e=="number"||e instanceof Number)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){let r=new ArrayBuffer(this._bits/8),n=new DataView(r);return this._bits===32?n.setFloat32(0,e,!0):n.setFloat64(0,e,!0),r}encodeType(){let e=this._bits===32?-13:-14;return He(e)}decodeValue(e,r){this.checkType(r);let n=ur(e,this._bits/8),i=new DataView(n);return this._bits===32?i.getFloat32(0,!0):i.getFloat64(0,!0)}get name(){return"float"+this._bits}valueToString(e){return e.toString()}},Dt=class extends lt{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedInt(this,r)}covariant(e){let r=wi(this._bits-1)*BigInt(-1),n=wi(this._bits-1)-BigInt(1),i=!1;if(typeof e=="bigint")i=e>=r&&e<=n;else if(Number.isInteger(e)){let s=BigInt(e);i=s>=r&&s<=n}else i=!1;if(i)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){return uo(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return He(-9-e)}decodeValue(e,r){this.checkType(r);let n=Oc(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(e){return e.toString()}},qt=class extends lt{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedNat(this,r)}covariant(e){let r=wi(this._bits),n=!1;if(typeof e=="bigint"&&e>=BigInt(0)?n=e<r:Number.isInteger(e)&&e>=0?n=BigInt(e)<r:n=!1,n)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){return Ic(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return He(-5-e)}decodeValue(e,r){this.checkType(r);let n=fo(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(e){return e.toString()}},Ni=class t extends $t{constructor(e){super(),this._type=e,this._blobOptimization=!1,e instanceof qt&&e._bits===8&&(this._blobOptimization=!0)}accept(e,r){return e.visitVec(this,this._type,r)}covariant(e){let r=this._type instanceof qt?this._type._bits:this._type instanceof Dt?this._type._bits:0;if(ArrayBuffer.isView(e)&&r==e.BYTES_PER_ELEMENT*8||Array.isArray(e)&&e.every((n,i)=>{try{return this._type.covariant(n)}catch(s){throw new Error(`Invalid ${this.display()} argument:
4
+
5
+ index ${i} -> ${s.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){let r=Oe(e.length);if(this._blobOptimization)return ve(r,new Uint8Array(e));if(ArrayBuffer.isView(e))return ve(r,new Uint8Array(e.buffer));let n=new At(new ArrayBuffer(r.byteLength+e.length),0);n.write(r);for(let i of e){let s=this._type.encodeValue(i);n.write(new Uint8Array(s))}return n.buffer}_buildTypeTableImpl(e){this._type.buildTypeTable(e);let r=He(-19),n=this._type.encodeType(e);e.add(this,ve(r,n))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not a vector type");let i=Number(Ge(e));if(this._type instanceof qt){if(this._type._bits==8)return new Uint8Array(e.read(i));if(this._type._bits==16)return new Uint16Array(e.read(i*2));if(this._type._bits==32)return new Uint32Array(e.read(i*4));if(this._type._bits==64)return new BigUint64Array(e.read(i*8))}if(this._type instanceof Dt){if(this._type._bits==8)return new Int8Array(e.read(i));if(this._type._bits==16)return new Int16Array(e.read(i*2));if(this._type._bits==32)return new Int32Array(e.read(i*4));if(this._type._bits==64)return new BigInt64Array(e.read(i*8))}let s=[];for(let o=0;o<i;o++)s.push(this._type.decodeValue(e,n._type));return s}get name(){return`vec ${this._type.name}`}display(){return`vec ${this._type.display()}`}valueToString(e){return"vec {"+e.map(n=>this._type.valueToString(n)).join("; ")+"}"}},en=class t extends $t{constructor(e){super(),this._type=e}accept(e,r){return e.visitOpt(this,this._type,r)}covariant(e){try{if(Array.isArray(e)&&(e.length===0||e.length===1&&this._type.covariant(e[0])))return!0}catch(r){throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}
6
+
7
+ -> ${r.message}`)}throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){return e.length===0?new Uint8Array([0]):ve(new Uint8Array([1]),this._type.encodeValue(e[0]))}_buildTypeTableImpl(e){this._type.buildTypeTable(e);let r=He(-18),n=this._type.encodeType(e);e.add(this,ve(r,n))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not an option type");switch(cr(e)){case 0:return[];case 1:return[this._type.decodeValue(e,n._type)];default:throw new Error("Not an option value")}}get name(){return`opt ${this._type.name}`}display(){return`opt ${this._type.display()}`}valueToString(e){return e.length===0?"null":`opt ${this._type.valueToString(e[0])}`}},En=class t extends $t{constructor(e={}){super(),this._fields=Object.entries(e).sort((r,n)=>Tt(r[0])-Tt(n[0]))}accept(e,r){return e.visitRecord(this,this._fields,r)}tryAsTuple(){let e=[];for(let r=0;r<this._fields.length;r++){let[n,i]=this._fields[r];if(n!==`_${r}_`)return null;e.push(i)}return e}covariant(e){if(typeof e=="object"&&this._fields.every(([r,n])=>{if(!e.hasOwnProperty(r))throw new Error(`Record is missing key "${r}".`);try{return n.covariant(e[r])}catch(i){throw new Error(`Invalid ${this.display()} argument:
8
+
9
+ field ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){let r=this._fields.map(([i])=>e[i]),n=xn(this._fields,r,([,i],s)=>i.encodeValue(s));return ve(...n)}_buildTypeTableImpl(e){this._fields.forEach(([s,o])=>o.buildTypeTable(e));let r=He(-20),n=Oe(this._fields.length),i=this._fields.map(([s,o])=>ve(Oe(Tt(s)),o.encodeType(e)));e.add(this,ve(r,n,ve(...i)))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not a record type");let i={},s=0,o=0;for(;o<n._fields.length;){let[c,a]=n._fields[o];if(s>=this._fields.length){a.decodeValue(e,a),o++;continue}let[d,l]=this._fields[s],f=Tt(this._fields[s][0]),T=Tt(c);if(f===T)i[d]=l.decodeValue(e,a),s++,o++;else if(T>f)if(l instanceof en||l instanceof Dr)i[d]=[],s++;else throw new Error("Cannot find required field "+d);else a.decodeValue(e,a),o++}for(let[c,a]of this._fields.slice(s))if(a instanceof en||a instanceof Dr)i[c]=[];else throw new Error("Cannot find required field "+c);return i}get name(){return`record {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`record {${this._fields.map(([r,n])=>r+":"+n.display()).join("; ")}}`}valueToString(e){let r=this._fields.map(([i])=>e[i]);return`record {${xn(this._fields,r,([i,s],o)=>i+"="+s.valueToString(o)).join("; ")}}`}},Ri=class t extends En{constructor(e){let r={};e.forEach((n,i)=>r["_"+i+"_"]=n),super(r),this._components=e}accept(e,r){return e.visitTuple(this,this._components,r)}covariant(e){if(Array.isArray(e)&&e.length>=this._fields.length&&this._components.every((r,n)=>{try{return r.covariant(e[n])}catch(i){throw new Error(`Invalid ${this.display()} argument:
10
+
11
+ index ${n} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){let r=xn(this._components,e,(n,i)=>n.encodeValue(i));return ve(...r)}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("not a tuple type");if(n._components.length<this._components.length)throw new Error("tuple mismatch");let i=[];for(let[s,o]of n._components.entries())s>=this._components.length?o.decodeValue(e,o):i.push(this._components[s].decodeValue(e,o));return i}display(){return`record {${this._components.map(r=>r.display()).join("; ")}}`}valueToString(e){return`record {${xn(this._components,e,(n,i)=>n.valueToString(i)).join("; ")}}`}},Ii=class t extends $t{constructor(e={}){super(),this._fields=Object.entries(e).sort((r,n)=>Tt(r[0])-Tt(n[0]))}accept(e,r){return e.visitVariant(this,this._fields,r)}covariant(e){if(typeof e=="object"&&Object.entries(e).length===1&&this._fields.every(([r,n])=>{try{return!e.hasOwnProperty(r)||n.covariant(e[r])}catch(i){throw new Error(`Invalid ${this.display()} argument:
12
+
13
+ variant ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){for(let r=0;r<this._fields.length;r++){let[n,i]=this._fields[r];if(e.hasOwnProperty(n)){let s=Oe(r),o=i.encodeValue(e[n]);return ve(s,o)}}throw Error("Variant has no data: "+e)}_buildTypeTableImpl(e){this._fields.forEach(([,s])=>{s.buildTypeTable(e)});let r=He(-21),n=Oe(this._fields.length),i=this._fields.map(([s,o])=>ve(Oe(Tt(s)),o.encodeType(e)));e.add(this,ve(r,n,...i))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not a variant type");let i=Number(Ge(e));if(i>=n._fields.length)throw Error("Invalid variant index: "+i);let[s,o]=n._fields[i];for(let[c,a]of this._fields)if(Tt(s)===Tt(c)){let d=a.decodeValue(e,o);return{[c]:d}}throw new Error("Cannot find field hash "+s)}get name(){return`variant {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`variant {${this._fields.map(([r,n])=>r+(n.name==="null"?"":`:${n.display()}`)).join("; ")}}`}valueToString(e){for(let[r,n]of this._fields)if(e.hasOwnProperty(r)){let i=n.valueToString(e[r]);return i==="null"?`variant {${r}}`:`variant {${r}=${i}}`}throw new Error("Variant has no data: "+e)}},fr=class t extends $t{constructor(){super(...arguments),this._id=t._counter++,this._type=void 0}accept(e,r){if(!this._type)throw Error("Recursive type uninitialized.");return e.visitRec(this,this._type,r)}fill(e){this._type=e}getType(){return this._type}covariant(e){if(this._type&&this._type.covariant(e))return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.encodeValue(e)}_buildTypeTableImpl(e){if(!this._type)throw Error("Recursive type uninitialized.");e.add(this,new Uint8Array([])),this._type.buildTypeTable(e),e.merge(this,this._type.name)}decodeValue(e,r){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.decodeValue(e,r)}get name(){return`rec_${this._id}`}display(){if(!this._type)throw Error("Recursive type uninitialized.");return`\u03BC${this.name}.${this._type.name}`}valueToString(e){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.valueToString(e)}};fr._counter=0;Oi=class extends lt{accept(e,r){return e.visitPrincipal(this,r)}covariant(e){if(e&&e._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){let r=e.toUint8Array(),n=Oe(r.byteLength);return ve(new Uint8Array([1]),n,r)}encodeType(){return He(-24)}decodeValue(e,r){return this.checkType(r),po(e)}get name(){return"principal"}valueToString(e){return`${this.name} "${e.toText()}"`}},Bn=class extends $t{constructor(e,r,n=[]){super(),this.argTypes=e,this.retTypes=r,this.annotations=n}static argsToString(e,r){if(e.length!==r.length)throw new Error("arity mismatch");return"("+e.map((n,i)=>n.valueToString(r[i])).join(", ")+")"}accept(e,r){return e.visitFunc(this,r)}covariant(e){if(Array.isArray(e)&&e.length===2&&e[0]&&e[0]._isPrincipal&&typeof e[1]=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue([e,r]){let n=e.toUint8Array(),i=Oe(n.byteLength),s=ve(new Uint8Array([1]),i,n),o=new TextEncoder().encode(r),c=Oe(o.byteLength);return ve(new Uint8Array([1]),s,c,o)}_buildTypeTableImpl(e){this.argTypes.forEach(d=>d.buildTypeTable(e)),this.retTypes.forEach(d=>d.buildTypeTable(e));let r=He(-22),n=Oe(this.argTypes.length),i=ve(...this.argTypes.map(d=>d.encodeType(e))),s=Oe(this.retTypes.length),o=ve(...this.retTypes.map(d=>d.encodeType(e))),c=Oe(this.annotations.length),a=ve(...this.annotations.map(d=>this.encodeAnnotation(d)));e.add(this,ve(r,n,i,s,o,c,a))}decodeValue(e){if(cr(e)!==1)throw new Error("Cannot decode function reference");let n=po(e),i=Number(Ge(e)),s=ur(e,i),c=new TextDecoder("utf8",{fatal:!0}).decode(s);return[n,c]}get name(){let e=this.argTypes.map(i=>i.name).join(", "),r=this.retTypes.map(i=>i.name).join(", "),n=" "+this.annotations.join(" ");return`(${e}) -> (${r})${n}`}valueToString([e,r]){return`func "${e.toText()}".${r}`}display(){let e=this.argTypes.map(i=>i.display()).join(", "),r=this.retTypes.map(i=>i.display()).join(", "),n=" "+this.annotations.join(" ");return`(${e}) \u2192 (${r})${n}`}encodeAnnotation(e){if(e==="query")return new Uint8Array([1]);if(e==="oneway")return new Uint8Array([2]);if(e==="composite_query")return new Uint8Array([3]);throw new Error("Illegal function annotation")}},Ui=class extends $t{constructor(e){super(),this._fields=Object.entries(e).sort((r,n)=>r[0]<n[0]?-1:r[0]>n[0]?1:0)}accept(e,r){return e.visitService(this,r)}covariant(e){if(e&&e._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${Ce(e)}`)}encodeValue(e){let r=e.toUint8Array(),n=Oe(r.length);return ve(new Uint8Array([1]),n,r)}_buildTypeTableImpl(e){this._fields.forEach(([s,o])=>o.buildTypeTable(e));let r=He(-23),n=Oe(this._fields.length),i=this._fields.map(([s,o])=>{let c=new TextEncoder().encode(s),a=Oe(c.length);return ve(a,c,o.encodeType(e))});e.add(this,ve(r,n,...i))}decodeValue(e){return po(e)}get name(){return`service {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}valueToString(e){return`service "${e.toText()}"`}};Pc=new _i,Mc=new Dr,md=new Ei,kc=new Bi,Cc=new vi,qc=new Ai,$c=new Ti,Vc=new Si,Gc=new _n(32),Hc=new _n(64),jc=new Dt(8),Yc=new Dt(16),zc=new Dt(32),Kc=new Dt(64),Zc=new qt(8),Wc=new qt(16),Xc=new qt(32),Jc=new qt(64),Qc=new Oi});var yo=xe(()=>{});var ou=xe(()=>{mo();gt();yo()});var au=xe(()=>{});var vn=xe(()=>{ou();yo();mo();co();lo();gi();au()});var Su={};mn(Su,{Buffer:()=>H,INSPECT_MAX_BYTES:()=>pu,SlowBuffer:()=>Sd,isBuffer:()=>Au,kMaxLength:()=>Ed});function lu(){wo=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0,r=t.length;e<r;++e)Vt[e]=t[e],bt[t.charCodeAt(e)]=e;bt[45]=62,bt[95]=63}function wd(t){wo||lu();var e,r,n,i,s,o,c=t.length;if(c%4>0)throw new Error("Invalid string. Length must be a multiple of 4");s=t[c-2]==="="?2:t[c-1]==="="?1:0,o=new gd(c*3/4-s),n=s>0?c-4:c;var a=0;for(e=0,r=0;e<n;e+=4,r+=3)i=bt[t.charCodeAt(e)]<<18|bt[t.charCodeAt(e+1)]<<12|bt[t.charCodeAt(e+2)]<<6|bt[t.charCodeAt(e+3)],o[a++]=i>>16&255,o[a++]=i>>8&255,o[a++]=i&255;return s===2?(i=bt[t.charCodeAt(e)]<<2|bt[t.charCodeAt(e+1)]>>4,o[a++]=i&255):s===1&&(i=bt[t.charCodeAt(e)]<<10|bt[t.charCodeAt(e+1)]<<4|bt[t.charCodeAt(e+2)]>>2,o[a++]=i>>8&255,o[a++]=i&255),o}function bd(t){return Vt[t>>18&63]+Vt[t>>12&63]+Vt[t>>6&63]+Vt[t&63]}function xd(t,e,r){for(var n,i=[],s=e;s<r;s+=3)n=(t[s]<<16)+(t[s+1]<<8)+t[s+2],i.push(bd(n));return i.join("")}function cu(t){wo||lu();for(var e,r=t.length,n=r%3,i="",s=[],o=16383,c=0,a=r-n;c<a;c+=o)s.push(xd(t,c,c+o>a?a:c+o));return n===1?(e=t[r-1],i+=Vt[e>>2],i+=Vt[e<<4&63],i+="=="):n===2&&(e=(t[r-2]<<8)+t[r-1],i+=Vt[e>>10],i+=Vt[e>>4&63],i+=Vt[e<<2&63],i+="="),s.push(i),s.join("")}function Mi(t,e,r,n,i){var s,o,c=i*8-n-1,a=(1<<c)-1,d=a>>1,l=-7,f=r?i-1:0,T=r?-1:1,_=t[e+f];for(f+=T,s=_&(1<<-l)-1,_>>=-l,l+=c;l>0;s=s*256+t[e+f],f+=T,l-=8);for(o=s&(1<<-l)-1,s>>=-l,l+=n;l>0;o=o*256+t[e+f],f+=T,l-=8);if(s===0)s=1-d;else{if(s===a)return o?NaN:(_?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-d}return(_?-1:1)*o*Math.pow(2,s-n)}function du(t,e,r,n,i,s){var o,c,a,d=s*8-i-1,l=(1<<d)-1,f=l>>1,T=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,_=n?0:s-1,b=n?1:-1,E=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(c=isNaN(e)?1:0,o=l):(o=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-o))<1&&(o--,a*=2),o+f>=1?e+=T/a:e+=T*Math.pow(2,1-f),e*a>=2&&(o++,a/=2),o+f>=l?(c=0,o=l):o+f>=1?(c=(e*a-1)*Math.pow(2,i),o=o+f):(c=e*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;t[r+_]=c&255,_+=b,c/=256,i-=8);for(o=o<<i|c,d+=i;d>0;t[r+_]=o&255,_+=b,o/=256,d-=8);t[r+_-b]|=E*128}function Fi(){return H.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function er(t,e){if(Fi()<e)throw new RangeError("Invalid typed array length");return H.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e),t.__proto__=H.prototype):(t===null&&(t=new H(e)),t.length=e),t}function H(t,e,r){if(!H.TYPED_ARRAY_SUPPORT&&!(this instanceof H))return new H(t,e,r);if(typeof t=="number"){if(typeof e=="string")throw new Error("If encoding is specified then the first argument must be a string");return bo(this,t)}return mu(this,t,e,r)}function mu(t,e,r,n){if(typeof e=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer?Ad(t,e,r,n):typeof e=="string"?vd(t,e,r):Td(t,e)}function yu(t){if(typeof t!="number")throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function Bd(t,e,r,n){return yu(e),e<=0?er(t,e):r!==void 0?typeof n=="string"?er(t,e).fill(r,n):er(t,e).fill(r):er(t,e)}function bo(t,e){if(yu(e),t=er(t,e<0?0:xo(e)|0),!H.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function vd(t,e,r){if((typeof r!="string"||r==="")&&(r="utf8"),!H.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=gu(e,r)|0;t=er(t,n);var i=t.write(e,r);return i!==n&&(t=t.slice(0,i)),t}function go(t,e){var r=e.length<0?0:xo(e.length)|0;t=er(t,r);for(var n=0;n<r;n+=1)t[n]=e[n]&255;return t}function Ad(t,e,r,n){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");return r===void 0&&n===void 0?e=new Uint8Array(e):n===void 0?e=new Uint8Array(e,r):e=new Uint8Array(e,r,n),H.TYPED_ARRAY_SUPPORT?(t=e,t.__proto__=H.prototype):t=go(t,e),t}function Td(t,e){if(Gt(e)){var r=xo(e.length)|0;return t=er(t,r),t.length===0||e.copy(t,0,0,r),t}if(e){if(typeof ArrayBuffer<"u"&&e.buffer instanceof ArrayBuffer||"length"in e)return typeof e.length!="number"||Kd(e.length)?er(t,0):go(t,e);if(e.type==="Buffer"&&hu(e.data))return go(t,e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function xo(t){if(t>=Fi())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Fi().toString(16)+" bytes");return t|0}function Sd(t){return+t!=t&&(t=0),H.alloc(+t)}function Gt(t){return!!(t!=null&&t._isBuffer)}function gu(t,e){if(Gt(t))return t.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;typeof t!="string"&&(t=""+t);var r=t.length;if(r===0)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Pi(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return vu(t).length;default:if(n)return Pi(t).length;e=(""+e).toLowerCase(),n=!0}}function Nd(t,e,r){var n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return qd(this,e,r);case"utf8":case"utf-8":return xu(this,e,r);case"ascii":return kd(this,e,r);case"latin1":case"binary":return Cd(this,e,r);case"base64":return Pd(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return $d(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function Sr(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function wu(t,e,r,n,i){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof e=="string"&&(e=H.from(e,n)),Gt(e))return e.length===0?-1:uu(t,e,r,n,i);if(typeof e=="number")return e=e&255,H.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):uu(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function uu(t,e,r,n,i){var s=1,o=t.length,c=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;s=2,o/=2,c/=2,r/=2}function a(_,b){return s===1?_[b]:_.readUInt16BE(b*s)}var d;if(i){var l=-1;for(d=r;d<o;d++)if(a(t,d)===a(e,l===-1?0:d-l)){if(l===-1&&(l=d),d-l+1===c)return l*s}else l!==-1&&(d-=d-l),l=-1}else for(r+c>o&&(r=o-c),d=r;d>=0;d--){for(var f=!0,T=0;T<c;T++)if(a(t,d+T)!==a(e,T)){f=!1;break}if(f)return d}return-1}function Rd(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var s=e.length;if(s%2!==0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o<n;++o){var c=parseInt(e.substr(o*2,2),16);if(isNaN(c))return o;t[r+o]=c}return o}function Id(t,e,r,n){return qi(Pi(e,t.length-r),t,r,n)}function bu(t,e,r,n){return qi(Yd(e),t,r,n)}function Od(t,e,r,n){return bu(t,e,r,n)}function Ud(t,e,r,n){return qi(vu(e),t,r,n)}function Fd(t,e,r,n){return qi(zd(e,t.length-r),t,r,n)}function Pd(t,e,r){return e===0&&r===t.length?cu(t):cu(t.slice(e,r))}function xu(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i<r;){var s=t[i],o=null,c=s>239?4:s>223?3:s>191?2:1;if(i+c<=r){var a,d,l,f;switch(c){case 1:s<128&&(o=s);break;case 2:a=t[i+1],(a&192)===128&&(f=(s&31)<<6|a&63,f>127&&(o=f));break;case 3:a=t[i+1],d=t[i+2],(a&192)===128&&(d&192)===128&&(f=(s&15)<<12|(a&63)<<6|d&63,f>2047&&(f<55296||f>57343)&&(o=f));break;case 4:a=t[i+1],d=t[i+2],l=t[i+3],(a&192)===128&&(d&192)===128&&(l&192)===128&&(f=(s&15)<<18|(a&63)<<12|(d&63)<<6|l&63,f>65535&&f<1114112&&(o=f))}}o===null?(o=65533,c=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=c}return Md(n)}function Md(t){var e=t.length;if(e<=fu)return String.fromCharCode.apply(String,t);for(var r="",n=0;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=fu));return r}function kd(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(t[i]&127);return n}function Cd(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function qd(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var i="",s=e;s<r;++s)i+=jd(t[s]);return i}function $d(t,e,r){for(var n=t.slice(e,r),i="",s=0;s<n.length;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}function Le(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function dt(t,e,r,n,i,s){if(!Gt(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function ki(t,e,r,n){e<0&&(e=65535+e+1);for(var i=0,s=Math.min(t.length-r,2);i<s;++i)t[r+i]=(e&255<<8*(n?i:1-i))>>>(n?i:1-i)*8}function Ci(t,e,r,n){e<0&&(e=4294967295+e+1);for(var i=0,s=Math.min(t.length-r,4);i<s;++i)t[r+i]=e>>>(n?i:3-i)*8&255}function _u(t,e,r,n,i,s){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Eu(t,e,r,n,i){return i||_u(t,e,r,4),du(t,e,r,n,23,4),r+4}function Bu(t,e,r,n,i){return i||_u(t,e,r,8),du(t,e,r,n,52,8),r+8}function Gd(t){if(t=Hd(t).replace(Vd,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function Hd(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function jd(t){return t<16?"0"+t.toString(16):t.toString(16)}function Pi(t,e){e=e||1/0;for(var r,n=t.length,i=null,s=[],o=0;o<n;++o){if(r=t.charCodeAt(o),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return s}function Yd(t){for(var e=[],r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function zd(t,e){for(var r,n,i,s=[],o=0;o<t.length&&!((e-=2)<0);++o)r=t.charCodeAt(o),n=r>>8,i=r%256,s.push(i),s.push(n);return s}function vu(t){return wd(Gd(t))}function qi(t,e,r,n){for(var i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function Kd(t){return t!==t}function Au(t){return t!=null&&(!!t._isBuffer||Tu(t)||Zd(t))}function Tu(t){return!!t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function Zd(t){return typeof t.readFloatLE=="function"&&typeof t.slice=="function"&&Tu(t.slice(0,0))}var Vt,bt,gd,wo,_d,hu,pu,Ed,fu,Vd,Nu=xe(()=>{Vt=[],bt=[],gd=typeof Uint8Array<"u"?Uint8Array:Array,wo=!1;_d={}.toString,hu=Array.isArray||function(t){return _d.call(t)=="[object Array]"};pu=50;H.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;Ed=Fi();H.poolSize=8192;H._augment=function(t){return t.__proto__=H.prototype,t};H.from=function(t,e,r){return mu(null,t,e,r)};H.TYPED_ARRAY_SUPPORT&&(H.prototype.__proto__=Uint8Array.prototype,H.__proto__=Uint8Array);H.alloc=function(t,e,r){return Bd(null,t,e,r)};H.allocUnsafe=function(t){return bo(null,t)};H.allocUnsafeSlow=function(t){return bo(null,t)};H.isBuffer=Au;H.compare=function(e,r){if(!Gt(e)||!Gt(r))throw new TypeError("Arguments must be Buffers");if(e===r)return 0;for(var n=e.length,i=r.length,s=0,o=Math.min(n,i);s<o;++s)if(e[s]!==r[s]){n=e[s],i=r[s];break}return n<i?-1:i<n?1:0};H.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};H.concat=function(e,r){if(!hu(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return H.alloc(0);var n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;var i=H.allocUnsafe(r),s=0;for(n=0;n<e.length;++n){var o=e[n];if(!Gt(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(i,s),s+=o.length}return i};H.byteLength=gu;H.prototype._isBuffer=!0;H.prototype.swap16=function(){var e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var r=0;r<e;r+=2)Sr(this,r,r+1);return this};H.prototype.swap32=function(){var e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var r=0;r<e;r+=4)Sr(this,r,r+3),Sr(this,r+1,r+2);return this};H.prototype.swap64=function(){var e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var r=0;r<e;r+=8)Sr(this,r,r+7),Sr(this,r+1,r+6),Sr(this,r+2,r+5),Sr(this,r+3,r+4);return this};H.prototype.toString=function(){var e=this.length|0;return e===0?"":arguments.length===0?xu(this,0,e):Nd.apply(this,arguments)};H.prototype.equals=function(e){if(!Gt(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:H.compare(this,e)===0};H.prototype.inspect=function(){var e="",r=pu;return this.length>0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),"<Buffer "+e+">"};H.prototype.compare=function(e,r,n,i,s){if(!Gt(e))throw new TypeError("Argument must be a Buffer");if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),r<0||n>e.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&r>=n)return 0;if(i>=s)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,s>>>=0,this===e)return 0;for(var o=s-i,c=n-r,a=Math.min(o,c),d=this.slice(i,s),l=e.slice(r,n),f=0;f<a;++f)if(d[f]!==l[f]){o=d[f],c=l[f];break}return o<c?-1:c<o?1:0};H.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};H.prototype.indexOf=function(e,r,n){return wu(this,e,r,n,!0)};H.prototype.lastIndexOf=function(e,r,n){return wu(this,e,r,n,!1)};H.prototype.write=function(e,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r|0,isFinite(n)?(n=n|0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var s=this.length-r;if((n===void 0||n>s)&&(n=s),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var o=!1;;)switch(i){case"hex":return Rd(this,e,r,n);case"utf8":case"utf-8":return Id(this,e,r,n);case"ascii":return bu(this,e,r,n);case"latin1":case"binary":return Od(this,e,r,n);case"base64":return Ud(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Fd(this,e,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};H.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};fu=4096;H.prototype.slice=function(e,r){var n=this.length;e=~~e,r=r===void 0?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);var i;if(H.TYPED_ARRAY_SUPPORT)i=this.subarray(e,r),i.__proto__=H.prototype;else{var s=r-e;i=new H(s,void 0);for(var o=0;o<s;++o)i[o]=this[o+e]}return i};H.prototype.readUIntLE=function(e,r,n){e=e|0,r=r|0,n||Le(e,r,this.length);for(var i=this[e],s=1,o=0;++o<r&&(s*=256);)i+=this[e+o]*s;return i};H.prototype.readUIntBE=function(e,r,n){e=e|0,r=r|0,n||Le(e,r,this.length);for(var i=this[e+--r],s=1;r>0&&(s*=256);)i+=this[e+--r]*s;return i};H.prototype.readUInt8=function(e,r){return r||Le(e,1,this.length),this[e]};H.prototype.readUInt16LE=function(e,r){return r||Le(e,2,this.length),this[e]|this[e+1]<<8};H.prototype.readUInt16BE=function(e,r){return r||Le(e,2,this.length),this[e]<<8|this[e+1]};H.prototype.readUInt32LE=function(e,r){return r||Le(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};H.prototype.readUInt32BE=function(e,r){return r||Le(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};H.prototype.readIntLE=function(e,r,n){e=e|0,r=r|0,n||Le(e,r,this.length);for(var i=this[e],s=1,o=0;++o<r&&(s*=256);)i+=this[e+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*r)),i};H.prototype.readIntBE=function(e,r,n){e=e|0,r=r|0,n||Le(e,r,this.length);for(var i=r,s=1,o=this[e+--i];i>0&&(s*=256);)o+=this[e+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*r)),o};H.prototype.readInt8=function(e,r){return r||Le(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};H.prototype.readInt16LE=function(e,r){r||Le(e,2,this.length);var n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};H.prototype.readInt16BE=function(e,r){r||Le(e,2,this.length);var n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};H.prototype.readInt32LE=function(e,r){return r||Le(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};H.prototype.readInt32BE=function(e,r){return r||Le(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};H.prototype.readFloatLE=function(e,r){return r||Le(e,4,this.length),Mi(this,e,!0,23,4)};H.prototype.readFloatBE=function(e,r){return r||Le(e,4,this.length),Mi(this,e,!1,23,4)};H.prototype.readDoubleLE=function(e,r){return r||Le(e,8,this.length),Mi(this,e,!0,52,8)};H.prototype.readDoubleBE=function(e,r){return r||Le(e,8,this.length),Mi(this,e,!1,52,8)};H.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r|0,n=n|0,!i){var s=Math.pow(2,8*n)-1;dt(this,e,r,n,s,0)}var o=1,c=0;for(this[r]=e&255;++c<n&&(o*=256);)this[r+c]=e/o&255;return r+n};H.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r|0,n=n|0,!i){var s=Math.pow(2,8*n)-1;dt(this,e,r,n,s,0)}var o=n-1,c=1;for(this[r+o]=e&255;--o>=0&&(c*=256);)this[r+o]=e/c&255;return r+n};H.prototype.writeUInt8=function(e,r,n){return e=+e,r=r|0,n||dt(this,e,r,1,255,0),H.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[r]=e&255,r+1};H.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r|0,n||dt(this,e,r,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[r]=e&255,this[r+1]=e>>>8):ki(this,e,r,!0),r+2};H.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r|0,n||dt(this,e,r,2,65535,0),H.TYPED_ARRAY_SUPPORT?(this[r]=e>>>8,this[r+1]=e&255):ki(this,e,r,!1),r+2};H.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r|0,n||dt(this,e,r,4,4294967295,0),H.TYPED_ARRAY_SUPPORT?(this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255):Ci(this,e,r,!0),r+4};H.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r|0,n||dt(this,e,r,4,4294967295,0),H.TYPED_ARRAY_SUPPORT?(this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255):Ci(this,e,r,!1),r+4};H.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r|0,!i){var s=Math.pow(2,8*n-1);dt(this,e,r,n,s-1,-s)}var o=0,c=1,a=0;for(this[r]=e&255;++o<n&&(c*=256);)e<0&&a===0&&this[r+o-1]!==0&&(a=1),this[r+o]=(e/c>>0)-a&255;return r+n};H.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r|0,!i){var s=Math.pow(2,8*n-1);dt(this,e,r,n,s-1,-s)}var o=n-1,c=1,a=0;for(this[r+o]=e&255;--o>=0&&(c*=256);)e<0&&a===0&&this[r+o+1]!==0&&(a=1),this[r+o]=(e/c>>0)-a&255;return r+n};H.prototype.writeInt8=function(e,r,n){return e=+e,r=r|0,n||dt(this,e,r,1,127,-128),H.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[r]=e&255,r+1};H.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r|0,n||dt(this,e,r,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[r]=e&255,this[r+1]=e>>>8):ki(this,e,r,!0),r+2};H.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r|0,n||dt(this,e,r,2,32767,-32768),H.TYPED_ARRAY_SUPPORT?(this[r]=e>>>8,this[r+1]=e&255):ki(this,e,r,!1),r+2};H.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r|0,n||dt(this,e,r,4,2147483647,-2147483648),H.TYPED_ARRAY_SUPPORT?(this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24):Ci(this,e,r,!0),r+4};H.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r|0,n||dt(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),H.TYPED_ARRAY_SUPPORT?(this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255):Ci(this,e,r,!1),r+4};H.prototype.writeFloatLE=function(e,r,n){return Eu(this,e,r,!0,n)};H.prototype.writeFloatBE=function(e,r,n){return Eu(this,e,r,!1,n)};H.prototype.writeDoubleLE=function(e,r,n){return Bu(this,e,r,!0,n)};H.prototype.writeDoubleBE=function(e,r,n){return Bu(this,e,r,!1,n)};H.prototype.copy=function(e,r,n,i){if(n||(n=0),!i&&i!==0&&(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r<i-n&&(i=e.length-r+n);var s=i-n,o;if(this===e&&n<r&&r<i)for(o=s-1;o>=0;--o)e[o+r]=this[o+n];else if(s<1e3||!H.TYPED_ARRAY_SUPPORT)for(o=0;o<s;++o)e[o+r]=this[o+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+s),r);return s};H.prototype.fill=function(e,r,n,i){if(typeof e=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),e.length===1){var s=e.charCodeAt(0);s<256&&(e=s)}if(i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!H.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else typeof e=="number"&&(e=e&255);if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);var o;if(typeof e=="number")for(o=r;o<n;++o)this[o]=e;else{var c=Gt(e)?e:Pi(new H(e,i).toString()),a=c.length;for(o=0;o<n-r;++o)this[o+r]=c[o%a]}return this};Vd=/[^+\/0-9A-Za-z-_]/g});var An=Ve((Lm,$i)=>{var Nr=(Nu(),_l(Su));if(Nr&&Nr.default){$i.exports=Nr.default;for(let t in Nr)$i.exports[t]=Nr[t]}else Nr&&($i.exports=Nr)});var Tn=Ve((Ru,Vi)=>{(function(t){"use strict";var e,r=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,i=Math.floor,s="[BigNumber Error] ",o=s+"Number primitive has more than 15 significant digits: ",c=1e14,a=14,d=9007199254740991,l=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],f=1e7,T=1e9;function _(F){var k,z,Y,G=O.prototype={constructor:O,toString:null,valueOf:null},ee=new O(1),L=20,ce=4,le=-7,_e=21,ye=-1e7,Z=1e7,ue=!1,j=1,C=0,X={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},D="0123456789abcdefghijklmnopqrstuvwxyz",ne=!0;function O(u,h){var p,A,x,v,N,g,B,R,S=this;if(!(S instanceof O))return new O(u,h);if(h==null){if(u&&u._isBigNumber===!0){S.s=u.s,!u.c||u.e>Z?S.c=S.e=null:u.e<ye?S.c=[S.e=0]:(S.e=u.e,S.c=u.c.slice());return}if((g=typeof u=="number")&&u*0==0){if(S.s=1/u<0?(u=-u,-1):1,u===~~u){for(v=0,N=u;N>=10;N/=10,v++);v>Z?S.c=S.e=null:(S.e=v,S.c=[u]);return}R=String(u)}else{if(!r.test(R=String(u)))return Y(S,R,g);S.s=R.charCodeAt(0)==45?(R=R.slice(1),-1):1}(v=R.indexOf("."))>-1&&(R=R.replace(".","")),(N=R.search(/e/i))>0?(v<0&&(v=N),v+=+R.slice(N+1),R=R.substring(0,N)):v<0&&(v=R.length)}else{if(I(h,2,D.length,"Base"),h==10&&ne)return S=new O(u),se(S,L+S.e+1,ce);if(R=String(u),g=typeof u=="number"){if(u*0!=0)return Y(S,R,g,h);if(S.s=1/u<0?(R=R.slice(1),-1):1,O.DEBUG&&R.replace(/^0\.0*|\./,"").length>15)throw Error(o+u)}else S.s=R.charCodeAt(0)===45?(R=R.slice(1),-1):1;for(p=D.slice(0,h),v=N=0,B=R.length;N<B;N++)if(p.indexOf(A=R.charAt(N))<0){if(A=="."){if(N>v){v=B;continue}}else if(!x&&(R==R.toUpperCase()&&(R=R.toLowerCase())||R==R.toLowerCase()&&(R=R.toUpperCase()))){x=!0,N=-1,v=0;continue}return Y(S,String(u),g,h)}g=!1,R=z(R,h,10,S.s),(v=R.indexOf("."))>-1?R=R.replace(".",""):v=R.length}for(N=0;R.charCodeAt(N)===48;N++);for(B=R.length;R.charCodeAt(--B)===48;);if(R=R.slice(N,++B)){if(B-=N,g&&O.DEBUG&&B>15&&(u>d||u!==i(u)))throw Error(o+S.s*u);if((v=v-N-1)>Z)S.c=S.e=null;else if(v<ye)S.c=[S.e=0];else{if(S.e=v,S.c=[],N=(v+1)%a,v<0&&(N+=a),N<B){for(N&&S.c.push(+R.slice(0,N)),B-=a;N<B;)S.c.push(+R.slice(N,N+=a));N=a-(R=R.slice(N)).length}else N-=B;for(;N--;R+="0");S.c.push(+R)}}else S.c=[S.e=0]}O.clone=_,O.ROUND_UP=0,O.ROUND_DOWN=1,O.ROUND_CEIL=2,O.ROUND_FLOOR=3,O.ROUND_HALF_UP=4,O.ROUND_HALF_DOWN=5,O.ROUND_HALF_EVEN=6,O.ROUND_HALF_CEIL=7,O.ROUND_HALF_FLOOR=8,O.EUCLID=9,O.config=O.set=function(u){var h,p;if(u!=null)if(typeof u=="object"){if(u.hasOwnProperty(h="DECIMAL_PLACES")&&(p=u[h],I(p,0,T,h),L=p),u.hasOwnProperty(h="ROUNDING_MODE")&&(p=u[h],I(p,0,8,h),ce=p),u.hasOwnProperty(h="EXPONENTIAL_AT")&&(p=u[h],p&&p.pop?(I(p[0],-T,0,h),I(p[1],0,T,h),le=p[0],_e=p[1]):(I(p,-T,T,h),le=-(_e=p<0?-p:p))),u.hasOwnProperty(h="RANGE"))if(p=u[h],p&&p.pop)I(p[0],-T,-1,h),I(p[1],1,T,h),ye=p[0],Z=p[1];else if(I(p,-T,T,h),p)ye=-(Z=p<0?-p:p);else throw Error(s+h+" cannot be zero: "+p);if(u.hasOwnProperty(h="CRYPTO"))if(p=u[h],p===!!p)if(p)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))ue=p;else throw ue=!p,Error(s+"crypto unavailable");else ue=p;else throw Error(s+h+" not true or false: "+p);if(u.hasOwnProperty(h="MODULO_MODE")&&(p=u[h],I(p,0,9,h),j=p),u.hasOwnProperty(h="POW_PRECISION")&&(p=u[h],I(p,0,T,h),C=p),u.hasOwnProperty(h="FORMAT"))if(p=u[h],typeof p=="object")X=p;else throw Error(s+h+" not an object: "+p);if(u.hasOwnProperty(h="ALPHABET"))if(p=u[h],typeof p=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(p))ne=p.slice(0,10)=="0123456789",D=p;else throw Error(s+h+" invalid: "+p)}else throw Error(s+"Object expected: "+u);return{DECIMAL_PLACES:L,ROUNDING_MODE:ce,EXPONENTIAL_AT:[le,_e],RANGE:[ye,Z],CRYPTO:ue,MODULO_MODE:j,POW_PRECISION:C,FORMAT:X,ALPHABET:D}},O.isBigNumber=function(u){if(!u||u._isBigNumber!==!0)return!1;if(!O.DEBUG)return!0;var h,p,A=u.c,x=u.e,v=u.s;e:if({}.toString.call(A)=="[object Array]"){if((v===1||v===-1)&&x>=-T&&x<=T&&x===i(x)){if(A[0]===0){if(x===0&&A.length===1)return!0;break e}if(h=(x+1)%a,h<1&&(h+=a),String(A[0]).length==h){for(h=0;h<A.length;h++)if(p=A[h],p<0||p>=c||p!==i(p))break e;if(p!==0)return!0}}}else if(A===null&&x===null&&(v===null||v===1||v===-1))return!0;throw Error(s+"Invalid BigNumber: "+u)},O.maximum=O.max=function(){return fe(arguments,-1)},O.minimum=O.min=function(){return fe(arguments,1)},O.random=function(){var u=9007199254740992,h=Math.random()*u&2097151?function(){return i(Math.random()*u)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(p){var A,x,v,N,g,B=0,R=[],S=new O(ee);if(p==null?p=L:I(p,0,T),N=n(p/a),ue)if(crypto.getRandomValues){for(A=crypto.getRandomValues(new Uint32Array(N*=2));B<N;)g=A[B]*131072+(A[B+1]>>>11),g>=9e15?(x=crypto.getRandomValues(new Uint32Array(2)),A[B]=x[0],A[B+1]=x[1]):(R.push(g%1e14),B+=2);B=N/2}else if(crypto.randomBytes){for(A=crypto.randomBytes(N*=7);B<N;)g=(A[B]&31)*281474976710656+A[B+1]*1099511627776+A[B+2]*4294967296+A[B+3]*16777216+(A[B+4]<<16)+(A[B+5]<<8)+A[B+6],g>=9e15?crypto.randomBytes(7).copy(A,B):(R.push(g%1e14),B+=7);B=N/7}else throw ue=!1,Error(s+"crypto unavailable");if(!ue)for(;B<N;)g=h(),g<9e15&&(R[B++]=g%1e14);for(N=R[--B],p%=a,N&&p&&(g=l[a-p],R[B]=i(N/g)*g);R[B]===0;R.pop(),B--);if(B<0)R=[v=0];else{for(v=-1;R[0]===0;R.splice(0,1),v-=a);for(B=1,g=R[0];g>=10;g/=10,B++);B<a&&(v-=a-B)}return S.e=v,S.c=R,S}}(),O.sum=function(){for(var u=1,h=arguments,p=new O(h[0]);u<h.length;)p=p.plus(h[u++]);return p},z=function(){var u="0123456789";function h(p,A,x,v){for(var N,g=[0],B,R=0,S=p.length;R<S;){for(B=g.length;B--;g[B]*=A);for(g[0]+=v.indexOf(p.charAt(R++)),N=0;N<g.length;N++)g[N]>x-1&&(g[N+1]==null&&(g[N+1]=0),g[N+1]+=g[N]/x|0,g[N]%=x)}return g.reverse()}return function(p,A,x,v,N){var g,B,R,S,V,W,te,me,Be=p.indexOf("."),Se=L,he=ce;for(Be>=0&&(S=C,C=0,p=p.replace(".",""),me=new O(A),W=me.pow(p.length-Be),C=S,me.c=h(K(E(W.c),W.e,"0"),10,x,u),me.e=me.c.length),te=h(p,A,x,N?(g=D,u):(g=u,D)),R=S=te.length;te[--S]==0;te.pop());if(!te[0])return g.charAt(0);if(Be<0?--R:(W.c=te,W.e=R,W.s=v,W=k(W,me,Se,he,x),te=W.c,V=W.r,R=W.e),B=R+Se+1,Be=te[B],S=x/2,V=V||B<0||te[B+1]!=null,V=he<4?(Be!=null||V)&&(he==0||he==(W.s<0?3:2)):Be>S||Be==S&&(he==4||V||he==6&&te[B-1]&1||he==(W.s<0?8:7)),B<1||!te[0])p=V?K(g.charAt(1),-Se,g.charAt(0)):g.charAt(0);else{if(te.length=B,V)for(--x;++te[--B]>x;)te[B]=0,B||(++R,te=[1].concat(te));for(S=te.length;!te[--S];);for(Be=0,p="";Be<=S;p+=g.charAt(te[Be++]));p=K(p,R,g.charAt(0))}return p}}(),k=function(){function u(A,x,v){var N,g,B,R,S=0,V=A.length,W=x%f,te=x/f|0;for(A=A.slice();V--;)B=A[V]%f,R=A[V]/f|0,N=te*B+R*W,g=W*B+N%f*f+S,S=(g/v|0)+(N/f|0)+te*R,A[V]=g%v;return S&&(A=[S].concat(A)),A}function h(A,x,v,N){var g,B;if(v!=N)B=v>N?1:-1;else for(g=B=0;g<v;g++)if(A[g]!=x[g]){B=A[g]>x[g]?1:-1;break}return B}function p(A,x,v,N){for(var g=0;v--;)A[v]-=g,g=A[v]<x[v]?1:0,A[v]=g*N+A[v]-x[v];for(;!A[0]&&A.length>1;A.splice(0,1));}return function(A,x,v,N,g){var B,R,S,V,W,te,me,Be,Se,he,re,Me,Jt,Br,vr,ct,Ee,ut=A.s==x.s?1:-1,tt=A.c,Ue=x.c;if(!tt||!tt[0]||!Ue||!Ue[0])return new O(!A.s||!x.s||(tt?Ue&&tt[0]==Ue[0]:!Ue)?NaN:tt&&tt[0]==0||!Ue?ut*0:ut/0);for(Be=new O(ut),Se=Be.c=[],R=A.e-x.e,ut=v+R+1,g||(g=c,R=b(A.e/a)-b(x.e/a),ut=ut/a|0),S=0;Ue[S]==(tt[S]||0);S++);if(Ue[S]>(tt[S]||0)&&R--,ut<0)Se.push(1),V=!0;else{for(Br=tt.length,ct=Ue.length,S=0,ut+=2,W=i(g/(Ue[0]+1)),W>1&&(Ue=u(Ue,W,g),tt=u(tt,W,g),ct=Ue.length,Br=tt.length),Jt=ct,he=tt.slice(0,ct),re=he.length;re<ct;he[re++]=0);Ee=Ue.slice(),Ee=[0].concat(Ee),vr=Ue[0],Ue[1]>=g/2&&vr++;do{if(W=0,B=h(Ue,he,ct,re),B<0){if(Me=he[0],ct!=re&&(Me=Me*g+(he[1]||0)),W=i(Me/vr),W>1)for(W>=g&&(W=g-1),te=u(Ue,W,g),me=te.length,re=he.length;h(te,he,me,re)==1;)W--,p(te,ct<me?Ee:Ue,me,g),me=te.length,B=1;else W==0&&(B=W=1),te=Ue.slice(),me=te.length;if(me<re&&(te=[0].concat(te)),p(he,te,re,g),re=he.length,B==-1)for(;h(Ue,he,ct,re)<1;)W++,p(he,ct<re?Ee:Ue,re,g),re=he.length}else B===0&&(W++,he=[0]);Se[S++]=W,he[0]?he[re++]=tt[Jt]||0:(he=[tt[Jt]],re=1)}while((Jt++<Br||he[0]!=null)&&ut--);V=he[0]!=null,Se[0]||Se.splice(0,1)}if(g==c){for(S=1,ut=Se[0];ut>=10;ut/=10,S++);se(Be,v+(Be.e=S+R*a-1)+1,N,V)}else Be.e=R,Be.r=+V;return Be}}();function m(u,h,p,A){var x,v,N,g,B;if(p==null?p=ce:I(p,0,8),!u.c)return u.toString();if(x=u.c[0],N=u.e,h==null)B=E(u.c),B=A==1||A==2&&(N<=le||N>=_e)?M(B,N):K(B,N,"0");else if(u=se(new O(u),h,p),v=u.e,B=E(u.c),g=B.length,A==1||A==2&&(h<=v||v<=le)){for(;g<h;B+="0",g++);B=M(B,v)}else if(h-=N,B=K(B,v,"0"),v+1>g){if(--h>0)for(B+=".";h--;B+="0");}else if(h+=v-g,h>0)for(v+1==g&&(B+=".");h--;B+="0");return u.s<0&&x?"-"+B:B}function fe(u,h){for(var p,A,x=1,v=new O(u[0]);x<u.length;x++)A=new O(u[x]),(!A.s||(p=U(v,A))===h||p===0&&v.s===h)&&(v=A);return v}function ie(u,h,p){for(var A=1,x=h.length;!h[--x];h.pop());for(x=h[0];x>=10;x/=10,A++);return(p=A+p*a-1)>Z?u.c=u.e=null:p<ye?u.c=[u.e=0]:(u.e=p,u.c=h),u}Y=function(){var u=/^(-?)0([xbo])(?=\w[\w.]*$)/i,h=/^([^.]+)\.$/,p=/^\.([^.]+)$/,A=/^-?(Infinity|NaN)$/,x=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(v,N,g,B){var R,S=g?N:N.replace(x,"");if(A.test(S))v.s=isNaN(S)?null:S<0?-1:1;else{if(!g&&(S=S.replace(u,function(V,W,te){return R=(te=te.toLowerCase())=="x"?16:te=="b"?2:8,!B||B==R?W:V}),B&&(R=B,S=S.replace(h,"$1").replace(p,"0.$1")),N!=S))return new O(S,R);if(O.DEBUG)throw Error(s+"Not a"+(B?" base "+B:"")+" number: "+N);v.s=null}v.c=v.e=null}}();function se(u,h,p,A){var x,v,N,g,B,R,S,V=u.c,W=l;if(V){e:{for(x=1,g=V[0];g>=10;g/=10,x++);if(v=h-x,v<0)v+=a,N=h,B=V[R=0],S=i(B/W[x-N-1]%10);else if(R=n((v+1)/a),R>=V.length)if(A){for(;V.length<=R;V.push(0));B=S=0,x=1,v%=a,N=v-a+1}else break e;else{for(B=g=V[R],x=1;g>=10;g/=10,x++);v%=a,N=v-a+x,S=N<0?0:i(B/W[x-N-1]%10)}if(A=A||h<0||V[R+1]!=null||(N<0?B:B%W[x-N-1]),A=p<4?(S||A)&&(p==0||p==(u.s<0?3:2)):S>5||S==5&&(p==4||A||p==6&&(v>0?N>0?B/W[x-N]:0:V[R-1])%10&1||p==(u.s<0?8:7)),h<1||!V[0])return V.length=0,A?(h-=u.e+1,V[0]=W[(a-h%a)%a],u.e=-h||0):V[0]=u.e=0,u;if(v==0?(V.length=R,g=1,R--):(V.length=R+1,g=W[a-v],V[R]=N>0?i(B/W[x-N]%W[N])*g:0),A)for(;;)if(R==0){for(v=1,N=V[0];N>=10;N/=10,v++);for(N=V[0]+=g,g=1;N>=10;N/=10,g++);v!=g&&(u.e++,V[0]==c&&(V[0]=1));break}else{if(V[R]+=g,V[R]!=c)break;V[R--]=0,g=1}for(v=V.length;V[--v]===0;V.pop());}u.e>Z?u.c=u.e=null:u.e<ye&&(u.c=[u.e=0])}return u}function Q(u){var h,p=u.e;return p===null?u.toString():(h=E(u.c),h=p<=le||p>=_e?M(h,p):K(h,p,"0"),u.s<0?"-"+h:h)}return G.absoluteValue=G.abs=function(){var u=new O(this);return u.s<0&&(u.s=1),u},G.comparedTo=function(u,h){return U(this,new O(u,h))},G.decimalPlaces=G.dp=function(u,h){var p,A,x,v=this;if(u!=null)return I(u,0,T),h==null?h=ce:I(h,0,8),se(new O(v),u+v.e+1,h);if(!(p=v.c))return null;if(A=((x=p.length-1)-b(this.e/a))*a,x=p[x])for(;x%10==0;x/=10,A--);return A<0&&(A=0),A},G.dividedBy=G.div=function(u,h){return k(this,new O(u,h),L,ce)},G.dividedToIntegerBy=G.idiv=function(u,h){return k(this,new O(u,h),0,1)},G.exponentiatedBy=G.pow=function(u,h){var p,A,x,v,N,g,B,R,S,V=this;if(u=new O(u),u.c&&!u.isInteger())throw Error(s+"Exponent not an integer: "+Q(u));if(h!=null&&(h=new O(h)),g=u.e>14,!V.c||!V.c[0]||V.c[0]==1&&!V.e&&V.c.length==1||!u.c||!u.c[0])return S=new O(Math.pow(+Q(V),g?u.s*(2-$(u)):+Q(u))),h?S.mod(h):S;if(B=u.s<0,h){if(h.c?!h.c[0]:!h.s)return new O(NaN);A=!B&&V.isInteger()&&h.isInteger(),A&&(V=V.mod(h))}else{if(u.e>9&&(V.e>0||V.e<-1||(V.e==0?V.c[0]>1||g&&V.c[1]>=24e7:V.c[0]<8e13||g&&V.c[0]<=9999975e7)))return v=V.s<0&&$(u)?-0:0,V.e>-1&&(v=1/v),new O(B?1/v:v);C&&(v=n(C/a+2))}for(g?(p=new O(.5),B&&(u.s=1),R=$(u)):(x=Math.abs(+Q(u)),R=x%2),S=new O(ee);;){if(R){if(S=S.times(V),!S.c)break;v?S.c.length>v&&(S.c.length=v):A&&(S=S.mod(h))}if(x){if(x=i(x/2),x===0)break;R=x%2}else if(u=u.times(p),se(u,u.e+1,1),u.e>14)R=$(u);else{if(x=+Q(u),x===0)break;R=x%2}V=V.times(V),v?V.c&&V.c.length>v&&(V.c.length=v):A&&(V=V.mod(h))}return A?S:(B&&(S=ee.div(S)),h?S.mod(h):v?se(S,C,ce,N):S)},G.integerValue=function(u){var h=new O(this);return u==null?u=ce:I(u,0,8),se(h,h.e+1,u)},G.isEqualTo=G.eq=function(u,h){return U(this,new O(u,h))===0},G.isFinite=function(){return!!this.c},G.isGreaterThan=G.gt=function(u,h){return U(this,new O(u,h))>0},G.isGreaterThanOrEqualTo=G.gte=function(u,h){return(h=U(this,new O(u,h)))===1||h===0},G.isInteger=function(){return!!this.c&&b(this.e/a)>this.c.length-2},G.isLessThan=G.lt=function(u,h){return U(this,new O(u,h))<0},G.isLessThanOrEqualTo=G.lte=function(u,h){return(h=U(this,new O(u,h)))===-1||h===0},G.isNaN=function(){return!this.s},G.isNegative=function(){return this.s<0},G.isPositive=function(){return this.s>0},G.isZero=function(){return!!this.c&&this.c[0]==0},G.minus=function(u,h){var p,A,x,v,N=this,g=N.s;if(u=new O(u,h),h=u.s,!g||!h)return new O(NaN);if(g!=h)return u.s=-h,N.plus(u);var B=N.e/a,R=u.e/a,S=N.c,V=u.c;if(!B||!R){if(!S||!V)return S?(u.s=-h,u):new O(V?N:NaN);if(!S[0]||!V[0])return V[0]?(u.s=-h,u):new O(S[0]?N:ce==3?-0:0)}if(B=b(B),R=b(R),S=S.slice(),g=B-R){for((v=g<0)?(g=-g,x=S):(R=B,x=V),x.reverse(),h=g;h--;x.push(0));x.reverse()}else for(A=(v=(g=S.length)<(h=V.length))?g:h,g=h=0;h<A;h++)if(S[h]!=V[h]){v=S[h]<V[h];break}if(v&&(x=S,S=V,V=x,u.s=-u.s),h=(A=V.length)-(p=S.length),h>0)for(;h--;S[p++]=0);for(h=c-1;A>g;){if(S[--A]<V[A]){for(p=A;p&&!S[--p];S[p]=h);--S[p],S[A]+=c}S[A]-=V[A]}for(;S[0]==0;S.splice(0,1),--R);return S[0]?ie(u,S,R):(u.s=ce==3?-1:1,u.c=[u.e=0],u)},G.modulo=G.mod=function(u,h){var p,A,x=this;return u=new O(u,h),!x.c||!u.s||u.c&&!u.c[0]?new O(NaN):!u.c||x.c&&!x.c[0]?new O(x):(j==9?(A=u.s,u.s=1,p=k(x,u,0,3),u.s=A,p.s*=A):p=k(x,u,0,j),u=x.minus(p.times(u)),!u.c[0]&&j==1&&(u.s=x.s),u)},G.multipliedBy=G.times=function(u,h){var p,A,x,v,N,g,B,R,S,V,W,te,me,Be,Se,he=this,re=he.c,Me=(u=new O(u,h)).c;if(!re||!Me||!re[0]||!Me[0])return!he.s||!u.s||re&&!re[0]&&!Me||Me&&!Me[0]&&!re?u.c=u.e=u.s=null:(u.s*=he.s,!re||!Me?u.c=u.e=null:(u.c=[0],u.e=0)),u;for(A=b(he.e/a)+b(u.e/a),u.s*=he.s,B=re.length,V=Me.length,B<V&&(me=re,re=Me,Me=me,x=B,B=V,V=x),x=B+V,me=[];x--;me.push(0));for(Be=c,Se=f,x=V;--x>=0;){for(p=0,W=Me[x]%Se,te=Me[x]/Se|0,N=B,v=x+N;v>x;)R=re[--N]%Se,S=re[N]/Se|0,g=te*R+S*W,R=W*R+g%Se*Se+me[v]+p,p=(R/Be|0)+(g/Se|0)+te*S,me[v--]=R%Be;me[v]=p}return p?++A:me.splice(0,1),ie(u,me,A)},G.negated=function(){var u=new O(this);return u.s=-u.s||null,u},G.plus=function(u,h){var p,A=this,x=A.s;if(u=new O(u,h),h=u.s,!x||!h)return new O(NaN);if(x!=h)return u.s=-h,A.minus(u);var v=A.e/a,N=u.e/a,g=A.c,B=u.c;if(!v||!N){if(!g||!B)return new O(x/0);if(!g[0]||!B[0])return B[0]?u:new O(g[0]?A:x*0)}if(v=b(v),N=b(N),g=g.slice(),x=v-N){for(x>0?(N=v,p=B):(x=-x,p=g),p.reverse();x--;p.push(0));p.reverse()}for(x=g.length,h=B.length,x-h<0&&(p=B,B=g,g=p,h=x),x=0;h;)x=(g[--h]=g[h]+B[h]+x)/c|0,g[h]=c===g[h]?0:g[h]%c;return x&&(g=[x].concat(g),++N),ie(u,g,N)},G.precision=G.sd=function(u,h){var p,A,x,v=this;if(u!=null&&u!==!!u)return I(u,1,T),h==null?h=ce:I(h,0,8),se(new O(v),u,h);if(!(p=v.c))return null;if(x=p.length-1,A=x*a+1,x=p[x]){for(;x%10==0;x/=10,A--);for(x=p[0];x>=10;x/=10,A++);}return u&&v.e+1>A&&(A=v.e+1),A},G.shiftedBy=function(u){return I(u,-d,d),this.times("1e"+u)},G.squareRoot=G.sqrt=function(){var u,h,p,A,x,v=this,N=v.c,g=v.s,B=v.e,R=L+4,S=new O("0.5");if(g!==1||!N||!N[0])return new O(!g||g<0&&(!N||N[0])?NaN:N?v:1/0);if(g=Math.sqrt(+Q(v)),g==0||g==1/0?(h=E(N),(h.length+B)%2==0&&(h+="0"),g=Math.sqrt(+h),B=b((B+1)/2)-(B<0||B%2),g==1/0?h="5e"+B:(h=g.toExponential(),h=h.slice(0,h.indexOf("e")+1)+B),p=new O(h)):p=new O(g+""),p.c[0]){for(B=p.e,g=B+R,g<3&&(g=0);;)if(x=p,p=S.times(x.plus(k(v,x,R,1))),E(x.c).slice(0,g)===(h=E(p.c)).slice(0,g))if(p.e<B&&--g,h=h.slice(g-3,g+1),h=="9999"||!A&&h=="4999"){if(!A&&(se(x,x.e+L+2,0),x.times(x).eq(v))){p=x;break}R+=4,g+=4,A=1}else{(!+h||!+h.slice(1)&&h.charAt(0)=="5")&&(se(p,p.e+L+2,1),u=!p.times(p).eq(v));break}}return se(p,p.e+L+1,ce,u)},G.toExponential=function(u,h){return u!=null&&(I(u,0,T),u++),m(this,u,h,1)},G.toFixed=function(u,h){return u!=null&&(I(u,0,T),u=u+this.e+1),m(this,u,h)},G.toFormat=function(u,h,p){var A,x=this;if(p==null)u!=null&&h&&typeof h=="object"?(p=h,h=null):u&&typeof u=="object"?(p=u,u=h=null):p=X;else if(typeof p!="object")throw Error(s+"Argument not an object: "+p);if(A=x.toFixed(u,h),x.c){var v,N=A.split("."),g=+p.groupSize,B=+p.secondaryGroupSize,R=p.groupSeparator||"",S=N[0],V=N[1],W=x.s<0,te=W?S.slice(1):S,me=te.length;if(B&&(v=g,g=B,B=v,me-=v),g>0&&me>0){for(v=me%g||g,S=te.substr(0,v);v<me;v+=g)S+=R+te.substr(v,g);B>0&&(S+=R+te.slice(v)),W&&(S="-"+S)}A=V?S+(p.decimalSeparator||"")+((B=+p.fractionGroupSize)?V.replace(new RegExp("\\d{"+B+"}\\B","g"),"$&"+(p.fractionGroupSeparator||"")):V):S}return(p.prefix||"")+A+(p.suffix||"")},G.toFraction=function(u){var h,p,A,x,v,N,g,B,R,S,V,W,te=this,me=te.c;if(u!=null&&(g=new O(u),!g.isInteger()&&(g.c||g.s!==1)||g.lt(ee)))throw Error(s+"Argument "+(g.isInteger()?"out of range: ":"not an integer: ")+Q(g));if(!me)return new O(te);for(h=new O(ee),R=p=new O(ee),A=B=new O(ee),W=E(me),v=h.e=W.length-te.e-1,h.c[0]=l[(N=v%a)<0?a+N:N],u=!u||g.comparedTo(h)>0?v>0?h:R:g,N=Z,Z=1/0,g=new O(W),B.c[0]=0;S=k(g,h,0,1),x=p.plus(S.times(A)),x.comparedTo(u)!=1;)p=A,A=x,R=B.plus(S.times(x=R)),B=x,h=g.minus(S.times(x=h)),g=x;return x=k(u.minus(p),A,0,1),B=B.plus(x.times(R)),p=p.plus(x.times(A)),B.s=R.s=te.s,v=v*2,V=k(R,A,v,ce).minus(te).abs().comparedTo(k(B,p,v,ce).minus(te).abs())<1?[R,A]:[B,p],Z=N,V},G.toNumber=function(){return+Q(this)},G.toPrecision=function(u,h){return u!=null&&I(u,1,T),m(this,u,h,2)},G.toString=function(u){var h,p=this,A=p.s,x=p.e;return x===null?A?(h="Infinity",A<0&&(h="-"+h)):h="NaN":(u==null?h=x<=le||x>=_e?M(E(p.c),x):K(E(p.c),x,"0"):u===10&&ne?(p=se(new O(p),L+x+1,ce),h=K(E(p.c),p.e,"0")):(I(u,2,D.length,"Base"),h=z(K(E(p.c),x,"0"),10,u,A,!0)),A<0&&p.c[0]&&(h="-"+h)),h},G.valueOf=G.toJSON=function(){return Q(this)},G._isBigNumber=!0,F!=null&&O.set(F),O}function b(F){var k=F|0;return F>0||F===k?k:k-1}function E(F){for(var k,z,Y=1,G=F.length,ee=F[0]+"";Y<G;){for(k=F[Y++]+"",z=a-k.length;z--;k="0"+k);ee+=k}for(G=ee.length;ee.charCodeAt(--G)===48;);return ee.slice(0,G+1||1)}function U(F,k){var z,Y,G=F.c,ee=k.c,L=F.s,ce=k.s,le=F.e,_e=k.e;if(!L||!ce)return null;if(z=G&&!G[0],Y=ee&&!ee[0],z||Y)return z?Y?0:-ce:L;if(L!=ce)return L;if(z=L<0,Y=le==_e,!G||!ee)return Y?0:!G^z?1:-1;if(!Y)return le>_e^z?1:-1;for(ce=(le=G.length)<(_e=ee.length)?le:_e,L=0;L<ce;L++)if(G[L]!=ee[L])return G[L]>ee[L]^z?1:-1;return le==_e?0:le>_e^z?1:-1}function I(F,k,z,Y){if(F<k||F>z||F!==i(F))throw Error(s+(Y||"Argument")+(typeof F=="number"?F<k||F>z?" out of range: ":" not an integer: ":" not a primitive number: ")+String(F))}function $(F){var k=F.c.length-1;return b(F.e/a)==k&&F.c[k]%2!=0}function M(F,k){return(F.length>1?F.charAt(0)+"."+F.slice(1):F)+(k<0?"e":"e+")+k}function K(F,k,z){var Y,G;if(k<0){for(G=z+".";++k;G+=z);F=G+F}else if(Y=F.length,++k>Y){for(G=z,k-=Y;--k;G+=z);F+=G}else k<Y&&(F=F.slice(0,k)+"."+F.slice(k));return F}e=_(),e.default=e.BigNumber=e,typeof define=="function"&&define.amd?define(function(){return e}):typeof Vi<"u"&&Vi.exports?Vi.exports=e:(t||(t=typeof self<"u"&&self?self:window),t.BigNumber=e)})(Ru)});var Ou=Ve((Dm,Iu)=>{Iu.exports=function(e,r,n){var i=new e.Uint8Array(n),s=r.pushInt,o=r.pushInt32,c=r.pushInt32Neg,a=r.pushInt64,d=r.pushInt64Neg,l=r.pushFloat,f=r.pushFloatSingle,T=r.pushFloatDouble,_=r.pushTrue,b=r.pushFalse,E=r.pushUndefined,U=r.pushNull,I=r.pushInfinity,$=r.pushInfinityNeg,M=r.pushNaN,K=r.pushNaNNeg,F=r.pushArrayStart,k=r.pushArrayStartFixed,z=r.pushArrayStartFixed32,Y=r.pushArrayStartFixed64,G=r.pushObjectStart,ee=r.pushObjectStartFixed,L=r.pushObjectStartFixed32,ce=r.pushObjectStartFixed64,le=r.pushByteString,_e=r.pushByteStringStart,ye=r.pushUtf8String,Z=r.pushUtf8StringStart,ue=r.pushSimpleUnassigned,j=r.pushTagStart,C=r.pushTagStart4,X=r.pushTagStart8,D=r.pushTagUnassigned,ne=r.pushBreak,O=e.Math.pow,m=0,fe=0,ie=0;function se(w){for(w=w|0,m=0,fe=w;(m|0)<(fe|0)&&(ie=ml[i[m]&255](i[m]|0)|0,!((ie|0)>0)););return ie|0}function Q(w){return w=w|0,((m|0)+(w|0)|0)<(fe|0)?0:1}function u(w){return w=w|0,i[w|0]<<8|i[w+1|0]|0}function h(w){return w=w|0,i[w|0]<<24|i[w+1|0]<<16|i[w+2|0]<<8|i[w+3|0]|0}function p(w){return w=w|0,s(w|0),m=m+1|0,0}function A(w){return w=w|0,Q(1)|0?1:(s(i[m+1|0]|0),m=m+2|0,0)}function x(w){return w=w|0,Q(2)|0?1:(s(u(m+1|0)|0),m=m+3|0,0)}function v(w){return w=w|0,Q(4)|0?1:(o(u(m+1|0)|0,u(m+3|0)|0),m=m+5|0,0)}function N(w){return w=w|0,Q(8)|0?1:(a(u(m+1|0)|0,u(m+3|0)|0,u(m+5|0)|0,u(m+7|0)|0),m=m+9|0,0)}function g(w){return w=w|0,s(-1-(w-32|0)|0),m=m+1|0,0}function B(w){return w=w|0,Q(1)|0?1:(s(-1-(i[m+1|0]|0)|0),m=m+2|0,0)}function R(w){w=w|0;var we=0;return Q(2)|0?1:(we=u(m+1|0)|0,s(-1-(we|0)|0),m=m+3|0,0)}function S(w){return w=w|0,Q(4)|0?1:(c(u(m+1|0)|0,u(m+3|0)|0),m=m+5|0,0)}function V(w){return w=w|0,Q(8)|0?1:(d(u(m+1|0)|0,u(m+3|0)|0,u(m+5|0)|0,u(m+7|0)|0),m=m+9|0,0)}function W(w){w=w|0;var we=0,be=0,ge=0;return ge=w-64|0,Q(ge|0)|0?1:(we=m+1|0,be=(m+1|0)+(ge|0)|0,le(we|0,be|0),m=be|0,0)}function te(w){w=w|0;var we=0,be=0,ge=0;return Q(1)|0||(ge=i[m+1|0]|0,we=m+2|0,be=(m+2|0)+(ge|0)|0,Q(ge+1|0)|0)?1:(le(we|0,be|0),m=be|0,0)}function me(w){w=w|0;var we=0,be=0,ge=0;return Q(2)|0||(ge=u(m+1|0)|0,we=m+3|0,be=(m+3|0)+(ge|0)|0,Q(ge+2|0)|0)?1:(le(we|0,be|0),m=be|0,0)}function Be(w){w=w|0;var we=0,be=0,ge=0;return Q(4)|0||(ge=h(m+1|0)|0,we=m+5|0,be=(m+5|0)+(ge|0)|0,Q(ge+4|0)|0)?1:(le(we|0,be|0),m=be|0,0)}function Se(w){return w=w|0,1}function he(w){return w=w|0,_e(),m=m+1|0,0}function re(w){w=w|0;var we=0,be=0,ge=0;return ge=w-96|0,Q(ge|0)|0?1:(we=m+1|0,be=(m+1|0)+(ge|0)|0,ye(we|0,be|0),m=be|0,0)}function Me(w){w=w|0;var we=0,be=0,ge=0;return Q(1)|0||(ge=i[m+1|0]|0,we=m+2|0,be=(m+2|0)+(ge|0)|0,Q(ge+1|0)|0)?1:(ye(we|0,be|0),m=be|0,0)}function Jt(w){w=w|0;var we=0,be=0,ge=0;return Q(2)|0||(ge=u(m+1|0)|0,we=m+3|0,be=(m+3|0)+(ge|0)|0,Q(ge+2|0)|0)?1:(ye(we|0,be|0),m=be|0,0)}function Br(w){w=w|0;var we=0,be=0,ge=0;return Q(4)|0||(ge=h(m+1|0)|0,we=m+5|0,be=(m+5|0)+(ge|0)|0,Q(ge+4|0)|0)?1:(ye(we|0,be|0),m=be|0,0)}function vr(w){return w=w|0,1}function ct(w){return w=w|0,Z(),m=m+1|0,0}function Ee(w){return w=w|0,k(w-128|0),m=m+1|0,0}function ut(w){return w=w|0,Q(1)|0?1:(k(i[m+1|0]|0),m=m+2|0,0)}function tt(w){return w=w|0,Q(2)|0?1:(k(u(m+1|0)|0),m=m+3|0,0)}function Ue(w){return w=w|0,Q(4)|0?1:(z(u(m+1|0)|0,u(m+3|0)|0),m=m+5|0,0)}function X0(w){return w=w|0,Q(8)|0?1:(Y(u(m+1|0)|0,u(m+3|0)|0,u(m+5|0)|0,u(m+7|0)|0),m=m+9|0,0)}function J0(w){return w=w|0,F(),m=m+1|0,0}function Fe(w){w=w|0;var we=0;return we=w-160|0,Q(we|0)|0?1:(ee(we|0),m=m+1|0,0)}function Q0(w){return w=w|0,Q(1)|0?1:(ee(i[m+1|0]|0),m=m+2|0,0)}function L0(w){return w=w|0,Q(2)|0?1:(ee(u(m+1|0)|0),m=m+3|0,0)}function D0(w){return w=w|0,Q(4)|0?1:(L(u(m+1|0)|0,u(m+3|0)|0),m=m+5|0,0)}function el(w){return w=w|0,Q(8)|0?1:(ce(u(m+1|0)|0,u(m+3|0)|0,u(m+5|0)|0,u(m+7|0)|0),m=m+9|0,0)}function tl(w){return w=w|0,G(),m=m+1|0,0}function Gr(w){return w=w|0,j(w-192|0|0),m=m+1|0,0}function V1(w){return w=w|0,j(w|0),m=m+1|0,0}function G1(w){return w=w|0,j(w|0),m=m+1|0,0}function H1(w){return w=w|0,j(w|0),m=m+1|0,0}function j1(w){return w=w|0,j(w|0),m=m+1|0,0}function Je(w){return w=w|0,j(w-192|0|0),m=m+1|0,0}function Y1(w){return w=w|0,j(w|0),m=m+1|0,0}function z1(w){return w=w|0,j(w|0),m=m+1|0,0}function K1(w){return w=w|0,j(w|0),m=m+1|0,0}function rl(w){return w=w|0,Q(1)|0?1:(j(i[m+1|0]|0),m=m+2|0,0)}function nl(w){return w=w|0,Q(2)|0?1:(j(u(m+1|0)|0),m=m+3|0,0)}function il(w){return w=w|0,Q(4)|0?1:(C(u(m+1|0)|0,u(m+3|0)|0),m=m+5|0,0)}function sl(w){return w=w|0,Q(8)|0?1:(X(u(m+1|0)|0,u(m+3|0)|0,u(m+5|0)|0,u(m+7|0)|0),m=m+9|0,0)}function $e(w){return w=w|0,ue((w|0)-224|0),m=m+1|0,0}function ol(w){return w=w|0,b(),m=m+1|0,0}function al(w){return w=w|0,_(),m=m+1|0,0}function cl(w){return w=w|0,U(),m=m+1|0,0}function ul(w){return w=w|0,E(),m=m+1|0,0}function fl(w){return w=w|0,Q(1)|0?1:(ue(i[m+1|0]|0),m=m+2|0,0)}function ll(w){w=w|0;var we=0,be=0,ge=1,ri=0,pn=0,Z1=0;return Q(2)|0?1:(we=i[m+1|0]|0,be=i[m+2|0]|0,(we|0)&128&&(ge=-1),ri=+(((we|0)&124)>>2),pn=+(((we|0)&3)<<8|be),+ri==0?l(+(+ge*5960464477539063e-23*+pn)):+ri==31?+ge==1?+pn>0?M():I():+pn>0?K():$():l(+(+ge*O(2,+(+ri-25))*+(1024+pn))),m=m+3|0,0)}function dl(w){return w=w|0,Q(4)|0?1:(f(i[m+1|0]|0,i[m+2|0]|0,i[m+3|0]|0,i[m+4|0]|0),m=m+5|0,0)}function hl(w){return w=w|0,Q(8)|0?1:(T(i[m+1|0]|0,i[m+2|0]|0,i[m+3|0]|0,i[m+4|0]|0,i[m+5|0]|0,i[m+6|0]|0,i[m+7|0]|0,i[m+8|0]|0),m=m+9|0,0)}function Te(w){return w=w|0,1}function pl(w){return w=w|0,ne(),m=m+1|0,0}var ml=[p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,A,x,v,N,Te,Te,Te,Te,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,B,R,S,V,Te,Te,Te,Te,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,te,me,Be,Se,Te,Te,Te,he,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,Me,Jt,Br,vr,Te,Te,Te,ct,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,ut,tt,Ue,X0,Te,Te,Te,J0,Fe,Fe,Fe,Fe,Fe,Fe,Fe,Fe,Fe,Fe,Fe,Fe,Fe,Fe,Fe,Fe,Fe,Fe,Fe,Fe,Fe,Fe,Fe,Fe,Q0,L0,D0,el,Te,Te,Te,tl,Gr,Gr,Gr,Gr,Gr,Gr,Je,Je,Je,Je,Je,Je,Je,Je,Je,Je,Je,Je,Je,Je,Je,Je,Je,Je,rl,nl,il,sl,Te,Te,Te,Te,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,ol,al,cl,ul,fl,ll,dl,hl,Te,Te,Te,pl];return{parse:se}}});var Sn=Ve(ht=>{"use strict";var _o=Tn().BigNumber;ht.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};ht.TAG={DATE_STRING:0,DATE_EPOCH:1,POS_BIGINT:2,NEG_BIGINT:3,DECIMAL_FRAC:4,BIGFLOAT:5,BASE64URL_EXPECTED:21,BASE64_EXPECTED:22,BASE16_EXPECTED:23,CBOR:24,URI:32,BASE64URL:33,BASE64:34,REGEXP:35,MIME:36};ht.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};ht.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};ht.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};ht.SHIFT32=Math.pow(2,32);ht.SHIFT16=Math.pow(2,16);ht.MAX_SAFE_HIGH=2097151;ht.NEG_ONE=new _o(-1);ht.TEN=new _o(10);ht.TWO=new _o(2);ht.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var Gi=Ve(xt=>{"use strict";var{Buffer:Wd}=An(),Fu=Tn().BigNumber,Pu=Sn(),Uu=Pu.SHIFT32,Xd=Pu.SHIFT16,Jd=2097151;xt.parseHalf=function(e){var r,n,i;return i=e[0]&128?-1:1,r=(e[0]&124)>>2,n=(e[0]&3)<<8|e[1],r?r===31?i*(n?NaN:1/0):i*Math.pow(2,r-25)*(1024+n):i*5960464477539063e-23*n};function Qd(t){return t<16?"0"+t.toString(16):t.toString(16)}xt.arrayBufferToBignumber=function(t){let e=t.byteLength,r="";for(let n=0;n<e;n++)r+=Qd(t[n]);return new Fu(r,16)};xt.buildMap=t=>{let e=new Map,r=Object.keys(t),n=r.length;for(let i=0;i<n;i++)e.set(r[i],t[r[i]]);return e};xt.buildInt32=(t,e)=>t*Xd+e;xt.buildInt64=(t,e,r,n)=>{let i=xt.buildInt32(t,e),s=xt.buildInt32(r,n);return i>Jd?new Fu(i).times(Uu).plus(s):i*Uu+s};xt.writeHalf=function(e,r){let n=Wd.allocUnsafe(4);n.writeFloatBE(r,0);let i=n.readUInt32BE(0);if(i&8191)return!1;var s=i>>16&32768;let o=i>>23&255,c=i&8388607;if(o>=113&&o<=142)s+=(o-112<<10)+(c>>13);else if(o>=103&&o<113){if(c&(1<<126-o)-1)return!1;s+=c+8388608>>126-o}else return!1;return e.writeUInt16BE(s,0),!0};xt.keySorter=function(t,e){var r=t[0].byteLength,n=e[0].byteLength;return r>n?1:n>r?-1:t[0].compare(e[0])};xt.isNegativeZero=t=>t===0&&1/t<0;xt.nextPowerOf2=t=>{let e=0;if(t&&!(t&t-1))return t;for(;t!==0;)t>>=1,e+=1;return 1<<e}});var Ao=Ve((ry,Mu)=>{"use strict";var vo=Sn(),Ld=vo.MT,Hi=vo.SIMPLE,Eo=vo.SYMS,Bo=class t{constructor(e){if(typeof e!="number")throw new Error("Invalid Simple type: "+typeof e);if(e<0||e>255||(e|0)!==e)throw new Error("value must be a small positive integer: "+e);this.value=e}toString(){return"simple("+this.value+")"}inspect(){return"simple("+this.value+")"}encodeCBOR(e){return e._pushInt(this.value,Ld.SIMPLE_FLOAT)}static isSimple(e){return e instanceof t}static decode(e,r){switch(r==null&&(r=!0),e){case Hi.FALSE:return!1;case Hi.TRUE:return!0;case Hi.NULL:return r?null:Eo.NULL;case Hi.UNDEFINED:return r?void 0:Eo.UNDEFINED;case-1:if(!r)throw new Error("Invalid BREAK");return Eo.BREAK;default:return new t(e)}}};Mu.exports=Bo});var So=Ve((ny,ku)=>{"use strict";var To=class t{constructor(e,r,n){if(this.tag=e,this.value=r,this.err=n,typeof this.tag!="number")throw new Error("Invalid tag type ("+typeof this.tag+")");if(this.tag<0||(this.tag|0)!==this.tag)throw new Error("Tag must be a positive integer: "+this.tag)}toString(){return`${this.tag}(${JSON.stringify(this.value)})`}encodeCBOR(e){return e._pushTag(this.tag),e.pushAny(this.value)}convert(e){var r,n;if(n=e?.[this.tag],typeof n!="function"&&(n=t["_tag"+this.tag],typeof n!="function"))return this;try{return n.call(t,this.value)}catch(i){return r=i,this.err=r,this}}};ku.exports=To});var Io=Ve((iy,qu)=>{"use strict";var Cu=self.location?self.location.protocol+"//"+self.location.host:"",No=self.URL,Ro=class{constructor(e="",r=Cu){this.super=new No(e,r),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}get hash(){return this.super.hash}get host(){return this.super.host}get hostname(){return this.super.hostname}get href(){return this.super.href}get origin(){return this.super.origin}get password(){return this.super.password}get pathname(){return this.super.pathname}get port(){return this.super.port}get protocol(){return this.super.protocol}get search(){return this.super.search}get searchParams(){return this.super.searchParams}get username(){return this.super.username}set hash(e){this.super.hash=e}set host(e){this.super.host=e}set hostname(e){this.super.hostname=e}set href(e){this.super.href=e}set origin(e){this.super.origin=e}set password(e){this.super.password=e}set pathname(e){this.super.pathname=e}set port(e){this.super.port=e}set protocol(e){this.super.protocol=e}set search(e){this.super.search=e}set searchParams(e){this.super.searchParams=e}set username(e){this.super.username=e}createObjectURL(e){return this.super.createObjectURL(e)}revokeObjectURL(e){this.super.revokeObjectURL(e)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}};function Dd(t){if(typeof t=="string")return new No(t).toString();if(!(t instanceof No)){let e=t.username&&t.password?`${t.username}:${t.password}@`:"",r=t.auth?t.auth+"@":"",n=t.port?":"+t.port:"",i=t.protocol?t.protocol+"//":"",s=t.host||"",o=t.hostname||"",c=t.search||(t.query?"?"+t.query:""),a=t.hash||"",d=t.pathname||"",l=t.path||d+c;return`${i}${e||r}${s||o+n}${l}${a}`}}qu.exports={URLWithLegacySupport:Ro,URLSearchParams:self.URLSearchParams,defaultBase:Cu,format:Dd}});var Gu=Ve((sy,Vu)=>{"use strict";var{URLWithLegacySupport:$u,format:eh}=Io();Vu.exports=(t,e={},r={},n)=>{let i=e.protocol?e.protocol.replace(":",""):"http";i=(r[i]||n||i)+":";let s;try{s=new $u(t)}catch{s={}}let o=Object.assign({},e,{protocol:i||s.protocol,host:e.host||s.host});return new $u(t,eh(o)).toString()}});var Oo=Ve((oy,Hu)=>{"use strict";var{URLWithLegacySupport:th,format:rh,URLSearchParams:nh,defaultBase:ih}=Io(),sh=Gu();Hu.exports={URL:th,URLSearchParams:nh,format:rh,relative:sh,defaultBase:ih}});var Uo=Ve((ay,Yu)=>{"use strict";var{Buffer:tn}=An(),ju=Qs(),oh=Tn().BigNumber,ah=Ou(),st=Gi(),Ae=Sn(),ch=Ao(),uh=So(),{URL:fh}=Oo(),Nn=class t{constructor(e){e=e||{},!e.size||e.size<65536?e.size=65536:e.size=st.nextPowerOf2(e.size),this._heap=new ArrayBuffer(e.size),this._heap8=new Uint8Array(this._heap),this._buffer=tn.from(this._heap),this._reset(),this._knownTags=Object.assign({0:r=>new Date(r),1:r=>new Date(r*1e3),2:r=>st.arrayBufferToBignumber(r),3:r=>Ae.NEG_ONE.minus(st.arrayBufferToBignumber(r)),4:r=>Ae.TEN.pow(r[0]).times(r[1]),5:r=>Ae.TWO.pow(r[0]).times(r[1]),32:r=>new fh(r),35:r=>new RegExp(r)},e.tags),this.parser=ah(globalThis,{log:console.log.bind(console),pushInt:this.pushInt.bind(this),pushInt32:this.pushInt32.bind(this),pushInt32Neg:this.pushInt32Neg.bind(this),pushInt64:this.pushInt64.bind(this),pushInt64Neg:this.pushInt64Neg.bind(this),pushFloat:this.pushFloat.bind(this),pushFloatSingle:this.pushFloatSingle.bind(this),pushFloatDouble:this.pushFloatDouble.bind(this),pushTrue:this.pushTrue.bind(this),pushFalse:this.pushFalse.bind(this),pushUndefined:this.pushUndefined.bind(this),pushNull:this.pushNull.bind(this),pushInfinity:this.pushInfinity.bind(this),pushInfinityNeg:this.pushInfinityNeg.bind(this),pushNaN:this.pushNaN.bind(this),pushNaNNeg:this.pushNaNNeg.bind(this),pushArrayStart:this.pushArrayStart.bind(this),pushArrayStartFixed:this.pushArrayStartFixed.bind(this),pushArrayStartFixed32:this.pushArrayStartFixed32.bind(this),pushArrayStartFixed64:this.pushArrayStartFixed64.bind(this),pushObjectStart:this.pushObjectStart.bind(this),pushObjectStartFixed:this.pushObjectStartFixed.bind(this),pushObjectStartFixed32:this.pushObjectStartFixed32.bind(this),pushObjectStartFixed64:this.pushObjectStartFixed64.bind(this),pushByteString:this.pushByteString.bind(this),pushByteStringStart:this.pushByteStringStart.bind(this),pushUtf8String:this.pushUtf8String.bind(this),pushUtf8StringStart:this.pushUtf8StringStart.bind(this),pushSimpleUnassigned:this.pushSimpleUnassigned.bind(this),pushTagUnassigned:this.pushTagUnassigned.bind(this),pushTagStart:this.pushTagStart.bind(this),pushTagStart4:this.pushTagStart4.bind(this),pushTagStart8:this.pushTagStart8.bind(this),pushBreak:this.pushBreak.bind(this)},this._heap)}get _depth(){return this._parents.length}get _currentParent(){return this._parents[this._depth-1]}get _ref(){return this._currentParent.ref}_closeParent(){var e=this._parents.pop();if(e.length>0)throw new Error(`Missing ${e.length} elements`);switch(e.type){case Ae.PARENT.TAG:this._push(this.createTag(e.ref[0],e.ref[1]));break;case Ae.PARENT.BYTE_STRING:this._push(this.createByteString(e.ref,e.length));break;case Ae.PARENT.UTF8_STRING:this._push(this.createUtf8String(e.ref,e.length));break;case Ae.PARENT.MAP:if(e.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createMap(e.ref,e.length));break;case Ae.PARENT.OBJECT:if(e.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createObject(e.ref,e.length));break;case Ae.PARENT.ARRAY:this._push(this.createArray(e.ref,e.length));break;default:break}this._currentParent&&this._currentParent.type===Ae.PARENT.TAG&&this._dec()}_dec(){let e=this._currentParent;e.length<0||(e.length--,e.length===0&&this._closeParent())}_push(e,r){let n=this._currentParent;switch(n.values++,n.type){case Ae.PARENT.ARRAY:case Ae.PARENT.BYTE_STRING:case Ae.PARENT.UTF8_STRING:n.length>-1?this._ref[this._ref.length-n.length]=e:this._ref.push(e),this._dec();break;case Ae.PARENT.OBJECT:n.tmpKey!=null?(this._ref[n.tmpKey]=e,n.tmpKey=null,this._dec()):(n.tmpKey=e,typeof n.tmpKey!="string"&&(n.type=Ae.PARENT.MAP,n.ref=st.buildMap(n.ref)));break;case Ae.PARENT.MAP:n.tmpKey!=null?(this._ref.set(n.tmpKey,e),n.tmpKey=null,this._dec()):n.tmpKey=e;break;case Ae.PARENT.TAG:this._ref.push(e),r||this._dec();break;default:throw new Error("Unknown parent type")}}_createParent(e,r,n){this._parents[this._depth]={type:r,length:n,ref:e,values:0,tmpKey:null}}_reset(){this._res=[],this._parents=[{type:Ae.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(e,r){let n=this._knownTags[e];return n?n(r):new uh(e,r)}createMap(e,r){return e}createObject(e,r){return e}createArray(e,r){return e}createByteString(e,r){return tn.concat(e)}createByteStringFromHeap(e,r){return e===r?tn.alloc(0):tn.from(this._heap.slice(e,r))}createInt(e){return e}createInt32(e,r){return st.buildInt32(e,r)}createInt64(e,r,n,i){return st.buildInt64(e,r,n,i)}createFloat(e){return e}createFloatSingle(e,r,n,i){return ju.read([e,r,n,i],0,!1,23,4)}createFloatDouble(e,r,n,i,s,o,c,a){return ju.read([e,r,n,i,s,o,c,a],0,!1,52,8)}createInt32Neg(e,r){return-1-st.buildInt32(e,r)}createInt64Neg(e,r,n,i){let s=st.buildInt32(e,r),o=st.buildInt32(n,i);return s>Ae.MAX_SAFE_HIGH?Ae.NEG_ONE.minus(new oh(s).times(Ae.SHIFT32).plus(o)):-1-(s*Ae.SHIFT32+o)}createTrue(){return!0}createFalse(){return!1}createNull(){return null}createUndefined(){}createInfinity(){return 1/0}createInfinityNeg(){return-1/0}createNaN(){return NaN}createNaNNeg(){return NaN}createUtf8String(e,r){return e.join("")}createUtf8StringFromHeap(e,r){return e===r?"":this._buffer.toString("utf8",e,r)}createSimpleUnassigned(e){return new ch(e)}pushInt(e){this._push(this.createInt(e))}pushInt32(e,r){this._push(this.createInt32(e,r))}pushInt64(e,r,n,i){this._push(this.createInt64(e,r,n,i))}pushFloat(e){this._push(this.createFloat(e))}pushFloatSingle(e,r,n,i){this._push(this.createFloatSingle(e,r,n,i))}pushFloatDouble(e,r,n,i,s,o,c,a){this._push(this.createFloatDouble(e,r,n,i,s,o,c,a))}pushInt32Neg(e,r){this._push(this.createInt32Neg(e,r))}pushInt64Neg(e,r,n,i){this._push(this.createInt64Neg(e,r,n,i))}pushTrue(){this._push(this.createTrue())}pushFalse(){this._push(this.createFalse())}pushNull(){this._push(this.createNull())}pushUndefined(){this._push(this.createUndefined())}pushInfinity(){this._push(this.createInfinity())}pushInfinityNeg(){this._push(this.createInfinityNeg())}pushNaN(){this._push(this.createNaN())}pushNaNNeg(){this._push(this.createNaNNeg())}pushArrayStart(){this._createParent([],Ae.PARENT.ARRAY,-1)}pushArrayStartFixed(e){this._createArrayStartFixed(e)}pushArrayStartFixed32(e,r){let n=st.buildInt32(e,r);this._createArrayStartFixed(n)}pushArrayStartFixed64(e,r,n,i){let s=st.buildInt64(e,r,n,i);this._createArrayStartFixed(s)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(e){this._createObjectStartFixed(e)}pushObjectStartFixed32(e,r){let n=st.buildInt32(e,r);this._createObjectStartFixed(n)}pushObjectStartFixed64(e,r,n,i){let s=st.buildInt64(e,r,n,i);this._createObjectStartFixed(s)}pushByteStringStart(){this._parents[this._depth]={type:Ae.PARENT.BYTE_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushByteString(e,r){this._push(this.createByteStringFromHeap(e,r))}pushUtf8StringStart(){this._parents[this._depth]={type:Ae.PARENT.UTF8_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushUtf8String(e,r){this._push(this.createUtf8StringFromHeap(e,r))}pushSimpleUnassigned(e){this._push(this.createSimpleUnassigned(e))}pushTagStart(e){this._parents[this._depth]={type:Ae.PARENT.TAG,length:1,ref:[e]}}pushTagStart4(e,r){this.pushTagStart(st.buildInt32(e,r))}pushTagStart8(e,r,n,i){this.pushTagStart(st.buildInt64(e,r,n,i))}pushTagUnassigned(e){this._push(this.createTag(e))}pushBreak(){if(this._currentParent.length>-1)throw new Error("Unexpected break");this._closeParent()}_createObjectStartFixed(e){if(e===0){this._push(this.createObject({}));return}this._createParent({},Ae.PARENT.OBJECT,e)}_createArrayStartFixed(e){if(e===0){this._push(this.createArray([]));return}this._createParent(new Array(e),Ae.PARENT.ARRAY,e)}_decode(e){if(e.byteLength===0)throw new Error("Input too short");this._reset(),this._heap8.set(e);let r=this.parser.parse(e.byteLength);if(this._depth>1){for(;this._currentParent.length===0;)this._closeParent();if(this._depth>1)throw new Error("Undeterminated nesting")}if(r>0)throw new Error("Failed to parse");if(this._res.length===0)throw new Error("No valid result")}decodeFirst(e){return this._decode(e),this._res[0]}decodeAll(e){return this._decode(e),this._res}static decode(e,r){return typeof e=="string"&&(e=tn.from(e,r||"hex")),new t({size:e.length}).decodeFirst(e)}static decodeAll(e,r){return typeof e=="string"&&(e=tn.from(e,r||"hex")),new t({size:e.length}).decodeAll(e)}};Nn.decodeFirst=Nn.decode;Yu.exports=Nn});var Zu=Ve((cy,Ku)=>{"use strict";var{Buffer:Fo}=An(),lh=Uo(),dh=Gi(),Po=class t extends lh{createTag(e,r){return`${e}(${r})`}createInt(e){return super.createInt(e).toString()}createInt32(e,r){return super.createInt32(e,r).toString()}createInt64(e,r,n,i){return super.createInt64(e,r,n,i).toString()}createInt32Neg(e,r){return super.createInt32Neg(e,r).toString()}createInt64Neg(e,r,n,i){return super.createInt64Neg(e,r,n,i).toString()}createTrue(){return"true"}createFalse(){return"false"}createFloat(e){let r=super.createFloat(e);return dh.isNegativeZero(e)?"-0_1":`${r}_1`}createFloatSingle(e,r,n,i){return`${super.createFloatSingle(e,r,n,i)}_2`}createFloatDouble(e,r,n,i,s,o,c,a){return`${super.createFloatDouble(e,r,n,i,s,o,c,a)}_3`}createByteString(e,r){let n=e.join(", ");return r===-1?`(_ ${n})`:`h'${n}`}createByteStringFromHeap(e,r){return`h'${Fo.from(super.createByteStringFromHeap(e,r)).toString("hex")}'`}createInfinity(){return"Infinity_1"}createInfinityNeg(){return"-Infinity_1"}createNaN(){return"NaN_1"}createNaNNeg(){return"-NaN_1"}createNull(){return"null"}createUndefined(){return"undefined"}createSimpleUnassigned(e){return`simple(${e})`}createArray(e,r){let n=super.createArray(e,r);return r===-1?`[_ ${n.join(", ")}]`:`[${n.join(", ")}]`}createMap(e,r){let n=super.createMap(e),i=Array.from(n.keys()).reduce(zu(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createObject(e,r){let n=super.createObject(e),i=Object.keys(n).reduce(zu(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createUtf8String(e,r){let n=e.join(", ");return r===-1?`(_ ${n})`:`"${n}"`}createUtf8StringFromHeap(e,r){return`"${Fo.from(super.createUtf8StringFromHeap(e,r)).toString("utf8")}"`}static diagnose(e,r){return typeof e=="string"&&(e=Fo.from(e,r||"hex")),new t().decodeFirst(e)}};Ku.exports=Po;function zu(t){return(e,r)=>e?`${e}, ${r}: ${t[r]}`:`${r}: ${t[r]}`}});var Lu=Ve((uy,Qu)=>{"use strict";var{Buffer:Ht}=An(),{URL:hh}=Oo(),ko=Tn().BigNumber,Mo=Gi(),Ze=Sn(),St=Ze.MT,ji=Ze.NUMBYTES,Wu=Ze.SHIFT32,Xu=Ze.SYMS,rn=Ze.TAG,ph=Ze.MT.SIMPLE_FLOAT<<5|Ze.NUMBYTES.TWO,mh=Ze.MT.SIMPLE_FLOAT<<5|Ze.NUMBYTES.FOUR,yh=Ze.MT.SIMPLE_FLOAT<<5|Ze.NUMBYTES.EIGHT,gh=Ze.MT.SIMPLE_FLOAT<<5|Ze.SIMPLE.TRUE,wh=Ze.MT.SIMPLE_FLOAT<<5|Ze.SIMPLE.FALSE,bh=Ze.MT.SIMPLE_FLOAT<<5|Ze.SIMPLE.UNDEFINED,Ju=Ze.MT.SIMPLE_FLOAT<<5|Ze.SIMPLE.NULL,xh=new ko("0x20000000000000"),_h=Ht.from("f97e00","hex"),Eh=Ht.from("f9fc00","hex"),Bh=Ht.from("f97c00","hex");function vh(t){return{}.toString.call(t).slice(8,-1)}var Co=class t{constructor(e){e=e||{},this.streaming=typeof e.stream=="function",this.onData=e.stream,this.semanticTypes=[[hh,this._pushUrl],[ko,this._pushBigNumber]];let r=e.genTypes||[],n=r.length;for(let i=0;i<n;i++)this.addSemanticType(r[i][0],r[i][1]);this._reset()}addSemanticType(e,r){let n=this.semanticTypes.length;for(let i=0;i<n;i++)if(this.semanticTypes[i][0]===e){let o=this.semanticTypes[i][1];return this.semanticTypes[i][1]=r,o}return this.semanticTypes.push([e,r]),null}push(e){return e&&(this.result[this.offset]=e,this.resultMethod[this.offset]=0,this.resultLength[this.offset]=e.length,this.offset++,this.streaming&&this.onData(this.finalize())),!0}pushWrite(e,r,n){return this.result[this.offset]=e,this.resultMethod[this.offset]=r,this.resultLength[this.offset]=n,this.offset++,this.streaming&&this.onData(this.finalize()),!0}_pushUInt8(e){return this.pushWrite(e,1,1)}_pushUInt16BE(e){return this.pushWrite(e,2,2)}_pushUInt32BE(e){return this.pushWrite(e,3,4)}_pushDoubleBE(e){return this.pushWrite(e,4,8)}_pushNaN(){return this.push(_h)}_pushInfinity(e){let r=e<0?Eh:Bh;return this.push(r)}_pushFloat(e){let r=Ht.allocUnsafe(2);if(Mo.writeHalf(r,e)&&Mo.parseHalf(r)===e)return this._pushUInt8(ph)&&this.push(r);let n=Ht.allocUnsafe(4);return n.writeFloatBE(e,0),n.readFloatBE(0)===e?this._pushUInt8(mh)&&this.push(n):this._pushUInt8(yh)&&this._pushDoubleBE(e)}_pushInt(e,r,n){let i=r<<5;return e<24?this._pushUInt8(i|e):e<=255?this._pushUInt8(i|ji.ONE)&&this._pushUInt8(e):e<=65535?this._pushUInt8(i|ji.TWO)&&this._pushUInt16BE(e):e<=4294967295?this._pushUInt8(i|ji.FOUR)&&this._pushUInt32BE(e):e<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|ji.EIGHT)&&this._pushUInt32BE(Math.floor(e/Wu))&&this._pushUInt32BE(e%Wu):r===St.NEG_INT?this._pushFloat(n):this._pushFloat(e)}_pushIntNum(e){return e<0?this._pushInt(-e-1,St.NEG_INT,e):this._pushInt(e,St.POS_INT)}_pushNumber(e){switch(!1){case e===e:return this._pushNaN(e);case isFinite(e):return this._pushInfinity(e);case e%1!==0:return this._pushIntNum(e);default:return this._pushFloat(e)}}_pushString(e){let r=Ht.byteLength(e,"utf8");return this._pushInt(r,St.UTF8_STRING)&&this.pushWrite(e,5,r)}_pushBoolean(e){return this._pushUInt8(e?gh:wh)}_pushUndefined(e){return this._pushUInt8(bh)}_pushArray(e,r){let n=r.length;if(!e._pushInt(n,St.ARRAY))return!1;for(let i=0;i<n;i++)if(!e.pushAny(r[i]))return!1;return!0}_pushTag(e){return this._pushInt(e,St.TAG)}_pushDate(e,r){return e._pushTag(rn.DATE_EPOCH)&&e.pushAny(Math.round(r/1e3))}_pushBuffer(e,r){return e._pushInt(r.length,St.BYTE_STRING)&&e.push(r)}_pushNoFilter(e,r){return e._pushBuffer(e,r.slice())}_pushRegexp(e,r){return e._pushTag(rn.REGEXP)&&e.pushAny(r.source)}_pushSet(e,r){if(!e._pushInt(r.size,St.ARRAY))return!1;for(let n of r)if(!e.pushAny(n))return!1;return!0}_pushUrl(e,r){return e._pushTag(rn.URI)&&e.pushAny(r.format())}_pushBigint(e){let r=rn.POS_BIGINT;e.isNegative()&&(e=e.negated().minus(1),r=rn.NEG_BIGINT);let n=e.toString(16);n.length%2&&(n="0"+n);let i=Ht.from(n,"hex");return this._pushTag(r)&&this._pushBuffer(this,i)}_pushBigNumber(e,r){if(r.isNaN())return e._pushNaN();if(!r.isFinite())return e._pushInfinity(r.isNegative()?-1/0:1/0);if(r.isInteger())return e._pushBigint(r);if(!(e._pushTag(rn.DECIMAL_FRAC)&&e._pushInt(2,St.ARRAY)))return!1;let n=r.decimalPlaces(),i=r.multipliedBy(new ko(10).pow(n));return e._pushIntNum(-n)?i.abs().isLessThan(xh)?e._pushIntNum(i.toNumber()):e._pushBigint(i):!1}_pushMap(e,r){return e._pushInt(r.size,St.MAP)?this._pushRawMap(r.size,Array.from(r)):!1}_pushObject(e){if(!e)return this._pushUInt8(Ju);for(var r=this.semanticTypes.length,n=0;n<r;n++)if(e instanceof this.semanticTypes[n][0])return this.semanticTypes[n][1].call(e,this,e);var i=e.encodeCBOR;if(typeof i=="function")return i.call(e,this);var s=Object.keys(e),o=s.length;return this._pushInt(o,St.MAP)?this._pushRawMap(o,s.map(c=>[c,e[c]])):!1}_pushRawMap(e,r){r=r.map(function(i){return i[0]=t.encode(i[0]),i}).sort(Mo.keySorter);for(var n=0;n<e;n++)if(!this.push(r[n][0])||!this.pushAny(r[n][1]))return!1;return!0}write(e){return this.pushAny(e)}pushAny(e){var r=vh(e);switch(r){case"Number":return this._pushNumber(e);case"String":return this._pushString(e);case"Boolean":return this._pushBoolean(e);case"Object":return this._pushObject(e);case"Array":return this._pushArray(this,e);case"Uint8Array":return this._pushBuffer(this,Ht.isBuffer(e)?e:Ht.from(e));case"Null":return this._pushUInt8(Ju);case"Undefined":return this._pushUndefined(e);case"Map":return this._pushMap(this,e);case"Set":return this._pushSet(this,e);case"URL":return this._pushUrl(this,e);case"BigNumber":return this._pushBigNumber(this,e);case"Date":return this._pushDate(this,e);case"RegExp":return this._pushRegexp(this,e);case"Symbol":switch(e){case Xu.NULL:return this._pushObject(null);case Xu.UNDEFINED:return this._pushUndefined(void 0);default:throw new Error("Unknown symbol: "+e.toString())}default:throw new Error("Unknown type: "+typeof e+", "+(e?e.toString():""))}}finalize(){if(this.offset===0)return null;for(var e=this.result,r=this.resultLength,n=this.resultMethod,i=this.offset,s=0,o=0;o<i;o++)s+=r[o];var c=Ht.allocUnsafe(s),a=0,d=0;for(o=0;o<i;o++){switch(d=r[o],n[o]){case 0:e[o].copy(c,a);break;case 1:c.writeUInt8(e[o],a,!0);break;case 2:c.writeUInt16BE(e[o],a,!0);break;case 3:c.writeUInt32BE(e[o],a,!0);break;case 4:c.writeDoubleBE(e[o],a,!0);break;case 5:c.write(e[o],a,d,"utf8");break;default:throw new Error("unkown method")}a+=d}var l=c;return this._reset(),l}_reset(){this.result=[],this.resultMethod=[],this.resultLength=[],this.offset=0}static encode(e){let r=new t;if(!r.pushAny(e))throw new Error("Failed to encode input");return r.finalize()}};Qu.exports=Co});var qo=Ve(We=>{"use strict";We.Diagnose=Zu();We.Decoder=Uo();We.Encoder=Lu();We.Simple=Ao();We.Tagged=So();We.decodeAll=We.Decoder.decodeAll;We.decodeFirst=We.Decoder.decodeFirst;We.diagnose=We.Diagnose.diagnose;We.encode=We.Encoder.encode;We.decode=We.Decoder.decode;We.leveldb={decode:We.Decoder.decodeAll,encode:We.Encoder.encode,buffer:!0,name:"cbor"}});function ot(...t){let e=new Uint8Array(t.reduce((n,i)=>n+i.byteLength,0)),r=0;for(let n of t)e.set(new Uint8Array(n),r),r+=n.byteLength;return e.buffer}function je(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}function Rr(t){if(!Ah.test(t))throw new Error("Invalid hexadecimal string.");let e=[...t].reduce((r,n,i)=>(r[i/2|0]=(r[i/2|0]||"")+n,r),[]).map(r=>Number.parseInt(r,16));return new Uint8Array(e).buffer}function $o(t,e){if(t.byteLength!==e.byteLength)return t.byteLength-e.byteLength;let r=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<r.length;i++)if(r[i]!==n[i])return r[i]-n[i];return 0}function Du(t,e){return $o(t,e)===0}function Rn(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}function Vo(t){return t instanceof Uint8Array?Rn(t):t instanceof ArrayBuffer?t:Array.isArray(t)?Rn(new Uint8Array(t)):"buffer"in t?Vo(t.buffer):Rn(new Uint8Array(t))}var Ah,pt=xe(()=>{Ah=new RegExp(/^[0-9a-fA-F]+$/)});function _t(t){return Rn(gn.create().update(new Uint8Array(t)).digest())}function Yi(t){if(t instanceof ef.default.Tagged)return Yi(t.value);if(typeof t=="string")return tf(t);if(typeof t=="number")return _t(Oe(t));if(t instanceof ArrayBuffer||ArrayBuffer.isView(t))return _t(t);if(Array.isArray(t)){let e=t.map(Yi);return _t(ot(...e))}else{if(t&&typeof t=="object"&&t._isPrincipal)return _t(t.toUint8Array());if(typeof t=="object"&&t!==null&&typeof t.toHash=="function")return Yi(t.toHash());if(typeof t=="object")return In(t);if(typeof t=="bigint")return _t(Oe(t))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${t}`),{value:t})}function zi(t){return In(t)}function In(t){let n=Object.entries(t).filter(([,o])=>o!==void 0).map(([o,c])=>{let a=tf(o),d=Yi(c);return[a,d]}).sort(([o],[c])=>$o(o,c)),i=ot(...n.map(o=>ot(...o)));return _t(i)}var ef,tf,On=xe(()=>{vn();ef=Hr(qo());li();pt();tf=t=>{let e=new TextEncoder().encode(t);return _t(e)}});var jo=Ve(Ne=>{"use strict";Object.defineProperty(Ne,"__esModule",{value:!0});var Th=9007199254740992;function tr(t,...e){let r=new Uint8Array(t.byteLength+e.reduce((i,s)=>i+s.byteLength,0));r.set(new Uint8Array(t),0);let n=t.byteLength;for(let i of e)r.set(new Uint8Array(i),n),n+=i.byteLength;return r.buffer}function Nt(t,e,r){r=r.replace(/[^0-9a-fA-F]/g,"");let n=2**(e-24);r=r.slice(-n*2).padStart(n*2,"0");let i=[(t<<5)+e].concat(r.match(/../g).map(s=>parseInt(s,16)));return new Uint8Array(i).buffer}function Ki(t,e){if(e<24)return new Uint8Array([(t<<5)+e]).buffer;{let r=e<=255?24:e<=65535?25:e<=4294967295?26:27;return Nt(t,r,e.toString(16))}}function rf(t){let e=[];for(let r=0;r<t.length;r++){let n=t.charCodeAt(r);n<128?e.push(n):n<2048?e.push(192|n>>6,128|n&63):n<55296||n>=57344?e.push(224|n>>12,128|n>>6&63,128|n&63):(r++,n=(n&1023)<<10|t.charCodeAt(r)&1023,e.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|n&63))}return tr(new Uint8Array(Ki(3,t.length)),new Uint8Array(e))}function Sh(t,e){if(t==14277111)return tr(new Uint8Array([217,217,247]),e);if(t<24)return tr(new Uint8Array([192+t]),e);{let r=t<=255?24:t<=65535?25:t<=4294967295?26:27,n=2**(r-24),i=t.toString(16).slice(-n*2).padStart(n*2,"0"),s=[192+r].concat(i.match(/../g).map(o=>parseInt(o,16)));return new Uint8Array(s).buffer}}Ne.tagged=Sh;function Un(t){return new Uint8Array(t).buffer}Ne.raw=Un;function Go(t){if(isNaN(t))throw new RangeError("Invalid number.");t=Math.min(Math.max(0,t),23);let e=[0+t];return new Uint8Array(e).buffer}Ne.uSmall=Go;function nf(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),255),t=t.toString(16),Nt(0,24,t)}Ne.u8=nf;function sf(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),65535),t=t.toString(16),Nt(0,25,t)}Ne.u16=sf;function of(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),4294967295),t=t.toString(16),Nt(0,26,t)}Ne.u32=of;function Ho(t,e){if(typeof t=="string"&&e==16){if(t.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return Nt(0,27,t)}if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),Th),t=t.toString(16),Nt(0,27,t)}Ne.u64=Ho;function af(t){if(isNaN(t))throw new RangeError("Invalid number.");if(t===0)return Go(0);t=Math.min(Math.max(0,-t),24)-1;let e=[32+t];return new Uint8Array(e).buffer}Ne.iSmall=af;function cf(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),255),t=t.toString(16),Nt(1,24,t)}Ne.i8=cf;function uf(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),65535),t=t.toString(16),Nt(1,25,t)}Ne.i16=uf;function ff(t,e){if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),4294967295),t=t.toString(16),Nt(1,26,t)}Ne.i32=ff;function lf(t,e){if(typeof t=="string"&&e==16){if(t.startsWith("-")?t=t.slice(1):t="0",t.match(/[^0-9a-fA-F]/)||t.length>16)throw new RangeError("Invalid number.");let r=!1,n=t.split("").reduceRight((i,s)=>{if(r)return s+i;let o=parseInt(s,16)-1;return o>=0?(r=!0,o.toString(16)+i):"f"+i},"");return r?Nt(1,27,n):Ho(0)}if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,-t-1),9007199254740992),t=t.toString(16),Nt(1,27,t)}Ne.i64=lf;function Nh(t){return t>=0?t<24?Go(t):t<=255?nf(t):t<=65535?sf(t):t<=4294967295?of(t):Ho(t):t>=-24?af(t):t>=-255?cf(t):t>=-65535?uf(t):t>=-4294967295?ff(t):lf(t)}Ne.number=Nh;function Rh(t){return tr(Ki(2,t.byteLength),t)}Ne.bytes=Rh;function Ih(t){return rf(t)}Ne.string=Ih;function Oh(t){return tr(Ki(4,t.length),...t)}Ne.array=Oh;function Uh(t,e=!1){t instanceof Map||(t=new Map(Object.entries(t)));let r=Array.from(t.entries());return e&&(r=r.sort(([n],[i])=>n.localeCompare(i))),tr(Ki(5,t.size),...r.map(([n,i])=>tr(rf(n),i)))}Ne.map=Uh;function Fh(t){let e=new Float32Array([t]);return tr(new Uint8Array([250]),new Uint8Array(e.buffer))}Ne.singleFloat=Fh;function Ph(t){let e=new Float64Array([t]);return tr(new Uint8Array([251]),new Uint8Array(e.buffer))}Ne.doubleFloat=Ph;function Mh(t){return t?df():hf()}Ne.bool=Mh;function df(){return Un(new Uint8Array([245]))}Ne.true_=df;function hf(){return Un(new Uint8Array([244]))}Ne.false_=hf;function kh(){return Un(new Uint8Array([246]))}Ne.null_=kh;function Ch(){return Un(new Uint8Array([247]))}Ne.undefined_=Ch});var pf=Ve(dr=>{"use strict";var qh=dr&&dr.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e};Object.defineProperty(dr,"__esModule",{value:!0});var Rt=qh(jo()),$h=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],Zi=class{constructor(e,r=!1){this._serializer=e,this._stable=r,this.name="jsonDefault",this.priority=-100}match(e){return["undefined","boolean","number","string","object"].indexOf(typeof e)!=-1}encode(e){switch(typeof e){case"undefined":return Rt.undefined_();case"boolean":return Rt.bool(e);case"number":return Math.floor(e)===e?Rt.number(e):Rt.doubleFloat(e);case"string":return Rt.string(e);case"object":if(e===null)return Rt.null_();if(Array.isArray(e))return Rt.array(e.map(r=>this._serializer.serializeValue(r)));if($h.find(r=>e instanceof r))return Rt.bytes(e.buffer);if(Object.getOwnPropertyNames(e).indexOf("toJSON")!==-1)return this.encode(e.toJSON());if(e instanceof Map){let r=new Map;for(let[n,i]of e.entries())r.set(n,this._serializer.serializeValue(i));return Rt.map(r,this._stable)}else{let r=new Map;for(let[n,i]of Object.entries(e))r.set(n,this._serializer.serializeValue(i));return Rt.map(r,this._stable)}default:throw new Error("Invalid value.")}}};dr.JsonDefaultCborEncoder=Zi;var Wi=class{constructor(){this.name="cborEncoder",this.priority=-90}match(e){return typeof e=="object"&&typeof e.toCBOR=="function"}encode(e){return e.toCBOR()}};dr.ToCborEncoder=Wi;var Xi=class{constructor(){this._encoders=new Set}static withDefaultEncoders(e=!1){let r=new this;return r.addEncoder(new Zi(r,e)),r.addEncoder(new Wi),r}removeEncoder(e){for(let r of this._encoders.values())r.name==e&&this._encoders.delete(r)}addEncoder(e){this._encoders.add(e)}getEncoderFor(e){let r=null;for(let n of this._encoders)(!r||n.priority>r.priority)&&n.match(e)&&(r=n);if(r===null)throw new Error("Could not find an encoder for value.");return r}serializeValue(e){return this.getEncoderFor(e).encode(e)}serialize(e){return this.serializeValue(e)}};dr.CborSerializer=Xi;var Yo=class extends Xi{serialize(e){return Rt.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(e))]))}};dr.SelfDescribeCborSerializer=Yo});var Ji=Ve(Ir=>{"use strict";function Vh(t){for(var e in t)Ir.hasOwnProperty(e)||(Ir[e]=t[e])}var Gh=Ir&&Ir.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e};Object.defineProperty(Ir,"__esModule",{value:!0});Vh(pf());var Hh=Gh(jo());Ir.value=Hh});function Li(t){return Qi.serialize(t)}function mf(t){let e=t.byteLength,r=BigInt(0);for(let n=0;n<e;n++)r=r*BigInt(256)+BigInt(t[n]);return r}function Et(t){let e=new Uint8Array(t),r=new Xo({size:e.byteLength,tags:{2:n=>mf(n),3:n=>-mf(n),[Wo.Semantic]:n=>n}});try{return r.decodeFirst(e)}catch(n){throw new Error(`Failed to decode CBOR: ${n}, input: ${je(e)}`)}}var yf,Or,gf,zo,Ko,Zo,Qi,Wo,Xo,Fn=xe(()=>{yf=Hr(qo()),Or=Hr(Ji()),gf=Hr(Ji());pt();zo=class{get name(){return"Principal"}get priority(){return 0}match(e){return e&&e._isPrincipal===!0}encode(e){return Or.value.bytes(e.toUint8Array())}},Ko=class{get name(){return"Buffer"}get priority(){return 1}match(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)}encode(e){return Or.value.bytes(new Uint8Array(e))}},Zo=class{get name(){return"BigInt"}get priority(){return 1}match(e){return typeof e=="bigint"}encode(e){return e>BigInt(0)?Or.value.tagged(2,Or.value.bytes(Rr(e.toString(16)))):Or.value.tagged(3,Or.value.bytes(Rr((BigInt("-1")*e).toString(16))))}},Qi=gf.SelfDescribeCborSerializer.withDefaultEncoders(!0);Qi.addEncoder(new zo);Qi.addEncoder(new Ko);Qi.addEncoder(new Zo);(function(t){t[t.Uint64LittleEndian=71]="Uint64LittleEndian",t[t.Semantic=55799]="Semantic"})(Wo||(Wo={}));Xo=class extends yf.default.Decoder{createByteString(e){return ot(...e)}createByteStringFromHeap(e,r){return e===r?new ArrayBuffer(0):new Uint8Array(this._heap.slice(e,r))}}});var rs={};mn(rs,{abytes:()=>It,bitGet:()=>an,bitLen:()=>pr,bitMask:()=>mr,bitSet:()=>Xh,bytesToHex:()=>Ot,bytesToNumberBE:()=>rt,bytesToNumberLE:()=>hr,concatBytes:()=>Re,createHmacDrbg:()=>Bf,ensureBytes:()=>Ye,equalBytes:()=>Wh,hexToBytes:()=>Cn,hexToNumber:()=>Lo,isBytes:()=>on,numberToBytesBE:()=>qe,numberToBytesLE:()=>Fr,numberToHexUnpadded:()=>Ef,numberToVarBytesBE:()=>Zh,utf8ToBytes:()=>qn,validateObject:()=>Ut});function on(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function It(t){if(!on(t))throw new Error("Uint8Array expected")}function Ot(t){It(t);let e="";for(let r=0;r<t.length;r++)e+=Kh[t[r]];return e}function Ef(t){let e=t.toString(16);return e.length&1?`0${e}`:e}function Lo(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}function bf(t){if(t>=rr._0&&t<=rr._9)return t-rr._0;if(t>=rr._A&&t<=rr._F)return t-(rr._A-10);if(t>=rr._a&&t<=rr._f)return t-(rr._a-10)}function Cn(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){let o=bf(t.charCodeAt(s)),c=bf(t.charCodeAt(s+1));if(o===void 0||c===void 0){let a=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+s)}n[i]=o*16+c}return n}function rt(t){return Lo(Ot(t))}function hr(t){return It(t),Lo(Ot(Uint8Array.from(t).reverse()))}function qe(t,e){return Cn(t.toString(16).padStart(e*2,"0"))}function Fr(t,e){return qe(t,e).reverse()}function Zh(t){return Cn(Ef(t))}function Ye(t,e,r){let n;if(typeof e=="string")try{n=Cn(e)}catch(s){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${s}`)}else if(on(e))n=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);let i=n.length;if(typeof r=="number"&&i!==r)throw new Error(`${t} expected ${r} bytes, got ${i}`);return n}function Re(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];It(i),e+=i.length}let r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let s=t[n];r.set(s,i),i+=s.length}return r}function Wh(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}function qn(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function pr(t){let e;for(e=0;t>_f;t>>=ts,e+=1);return e}function an(t,e){return t>>BigInt(e)&ts}function Xh(t,e,r){return t|(r?ts:_f)<<BigInt(e)}function Bf(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=Qo(t),i=Qo(t),s=0,o=()=>{n.fill(1),i.fill(0),s=0},c=(...f)=>r(i,n,...f),a=(f=Qo())=>{i=c(xf([0]),f),n=c(),f.length!==0&&(i=c(xf([1]),f),n=c())},d=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let f=0,T=[];for(;f<e;){n=c();let _=n.slice();T.push(_),f+=n.length}return Re(...T)};return(f,T)=>{o(),a(f);let _;for(;!(_=T(d()));)a();return o(),_}}function Ut(t,e,r={}){let n=(i,s,o)=>{let c=Jh[s];if(typeof c!="function")throw new Error(`Invalid validator "${s}", expected function`);let a=t[i];if(!(o&&a===void 0)&&!c(a,t))throw new Error(`Invalid param ${String(i)}=${a} (${typeof a}), expected ${s}`)};for(let[i,s]of Object.entries(e))n(i,s,!1);for(let[i,s]of Object.entries(r))n(i,s,!0);return t}var _f,ts,zh,Kh,rr,mr,Qo,xf,Jh,jt=xe(()=>{_f=BigInt(0),ts=BigInt(1),zh=BigInt(2);Kh=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));rr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};mr=t=>(zh<<BigInt(t-1))-ts,Qo=t=>new Uint8Array(t),xf=t=>Uint8Array.from(t);Jh={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||on(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)}});function Ie(t,e){let r=t%e;return r>=Xe?r:e+r}function ep(t,e,r){if(r<=Xe||e<Xe)throw new Error("Expected power/modulo > 0");if(r===Pe)return Xe;let n=Pe;for(;e>Xe;)e&Pe&&(n=n*t%r),t=t*t%r,e>>=Pe;return n}function Ft(t,e,r){let n=t;for(;e-- >Xe;)n*=n,n%=r;return n}function ea(t,e){if(t===Xe||e<=Xe)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=Ie(t,e),n=e,i=Xe,s=Pe,o=Pe,c=Xe;for(;r!==Xe;){let d=n/r,l=n%r,f=i-o*d,T=s-c*d;n=r,r=l,i=o,s=c,o=f,c=T}if(n!==Pe)throw new Error("invert: does not exist");return Ie(i,e)}function tp(t){let e=(t-Pe)/Pr,r,n,i;for(r=t-Pe,n=0;r%Pr===Xe;r/=Pr,n++);for(i=Pr;i<t&&ep(i,e,t)!==t-Pe;i++);if(n===1){let o=(t+Pe)/Do;return function(a,d){let l=a.pow(d,o);if(!a.eql(a.sqr(l),d))throw new Error("Cannot find square root");return l}}let s=(r+Pe)/Pr;return function(c,a){if(c.pow(a,e)===c.neg(c.ONE))throw new Error("Cannot find square root");let d=n,l=c.pow(c.mul(c.ONE,i),r),f=c.pow(a,s),T=c.pow(a,r);for(;!c.eql(T,c.ONE);){if(c.eql(T,c.ZERO))return c.ZERO;let _=1;for(let E=c.sqr(T);_<d&&!c.eql(E,c.ONE);_++)E=c.sqr(E);let b=c.pow(l,Pe<<BigInt(d-_-1));l=c.sqr(b),f=c.mul(f,b),T=c.mul(T,l),d=_}return f}}function rp(t){if(t%Do===Qh){let e=(t+Pe)/Do;return function(n,i){let s=n.pow(i,e);if(!n.eql(n.sqr(s),i))throw new Error("Cannot find square root");return s}}if(t%Af===vf){let e=(t-vf)/Af;return function(n,i){let s=n.mul(i,Pr),o=n.pow(s,e),c=n.mul(i,o),a=n.mul(n.mul(c,Pr),o),d=n.mul(c,n.sub(a,n.ONE));if(!n.eql(n.sqr(d),i))throw new Error("Cannot find square root");return d}}return t%Dh,tp(t)}function ns(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=np.reduce((n,i)=>(n[i]="function",n),e);return Ut(t,r)}function $n(t,e,r){if(r<Xe)throw new Error("Expected power > 0");if(r===Xe)return t.ONE;if(r===Pe)return e;let n=t.ONE,i=e;for(;r>Xe;)r&Pe&&(n=t.mul(n,i)),i=t.sqr(i),r>>=Pe;return n}function Vn(t,e){let r=new Array(e.length),n=e.reduce((s,o,c)=>t.is0(o)?s:(r[c]=s,t.mul(s,o)),t.ONE),i=t.inv(n);return e.reduceRight((s,o,c)=>t.is0(o)?s:(r[c]=t.mul(s,r[c]),t.mul(s,o)),i),r}function ta(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function Gn(t,e,r=!1,n={}){if(t<=Xe)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:s}=ta(t,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=rp(t),c=Object.freeze({ORDER:t,BITS:i,BYTES:s,MASK:mr(i),ZERO:Xe,ONE:Pe,create:a=>Ie(a,t),isValid:a=>{if(typeof a!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof a}`);return Xe<=a&&a<t},is0:a=>a===Xe,isOdd:a=>(a&Pe)===Pe,neg:a=>Ie(-a,t),eql:(a,d)=>a===d,sqr:a=>Ie(a*a,t),add:(a,d)=>Ie(a+d,t),sub:(a,d)=>Ie(a-d,t),mul:(a,d)=>Ie(a*d,t),pow:(a,d)=>$n(c,a,d),div:(a,d)=>Ie(a*ea(d,t),t),sqrN:a=>a*a,addN:(a,d)=>a+d,subN:(a,d)=>a-d,mulN:(a,d)=>a*d,inv:a=>ea(a,t),sqrt:n.sqrt||(a=>o(c,a)),invertBatch:a=>Vn(c,a),cmov:(a,d,l)=>l?d:a,toBytes:a=>r?Fr(a,s):qe(a,s),fromBytes:a=>{if(a.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${a.length}`);return r?hr(a):rt(a)}});return Object.freeze(c)}function Sf(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let r=t.sqrt(e);return t.isOdd(r)?t.neg(r):r}function Nf(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function is(t){let e=Nf(t);return e+Math.ceil(e/2)}function ra(t,e,r=!1){let n=t.length,i=Nf(e),s=is(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let o=r?rt(t):hr(t),c=Ie(o,e-Pe)+Pe;return r?Fr(c,i):qe(c,i)}var Xe,Pe,Pr,Qh,Do,vf,Af,Lh,Dh,Tf,np,yr=xe(()=>{jt();Xe=BigInt(0),Pe=BigInt(1),Pr=BigInt(2),Qh=BigInt(3),Do=BigInt(4),vf=BigInt(5),Af=BigInt(8),Lh=BigInt(9),Dh=BigInt(16);Tf=(t,e)=>(Ie(t,e)&Pe)===Pe,np=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"]});function gr(t,e){if(t<0||t>=1<<8*e)throw new Error(`bad I2OSP call: value=${t} length=${e}`);let r=Array.from({length:e}).fill(0);for(let n=e-1;n>=0;n--)r[n]=t&255,t>>>=8;return new Uint8Array(r)}function sp(t,e){let r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t[n]^e[n];return r}function na(t){if(!Number.isSafeInteger(t))throw new Error("number expected")}function op(t,e,r,n){It(t),It(e),na(r),e.length>255&&(e=n(Re(qn("H2C-OVERSIZE-DST-"),e)));let{outputLen:i,blockLen:s}=n,o=Math.ceil(r/i);if(o>255)throw new Error("Invalid xmd length");let c=Re(e,gr(e.length,1)),a=gr(0,s),d=gr(r,2),l=new Array(o),f=n(Re(a,t,d,gr(0,1),c));l[0]=n(Re(f,gr(1,1),c));for(let _=1;_<=o;_++){let b=[sp(f,l[_-1]),gr(_+1,1),c];l[_]=n(Re(...b))}return Re(...l).slice(0,r)}function ap(t,e,r,n,i){if(It(t),It(e),na(r),e.length>255){let s=Math.ceil(2*n/8);e=i.create({dkLen:s}).update(qn("H2C-OVERSIZE-DST-")).update(e).digest()}if(r>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:r}).update(t).update(gr(r,2)).update(e).update(gr(e.length,1)).digest()}function If(t,e,r){Ut(r,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});let{p:n,k:i,m:s,hash:o,expand:c,DST:a}=r;It(t),na(e);let d=typeof a=="string"?qn(a):a,l=n.toString(2).length,f=Math.ceil((l+i)/8),T=e*s*f,_;if(c==="xmd")_=op(t,d,T,o);else if(c==="xof")_=ap(t,d,T,i,o);else if(c==="_internal_pass")_=t;else throw new Error('expand must be "xmd" or "xof"');let b=new Array(e);for(let E=0;E<e;E++){let U=new Array(s);for(let I=0;I<s;I++){let $=f*(I+E*s),M=_.subarray($,$+f);U[I]=Ie(ip(M),n)}b[E]=U}return b}function ia(t,e){let r=e.map(n=>Array.from(n).reverse());return(n,i)=>{let[s,o,c,a]=r.map(d=>d.reduce((l,f)=>t.add(t.mul(l,n),f)));return n=t.div(s,o),i=t.mul(i,t.div(c,a)),{x:n,y:i}}}function sa(t,e,r){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){let s=If(n,2,{...r,DST:r.DST,...i}),o=t.fromAffine(e(s[0])),c=t.fromAffine(e(s[1])),a=o.add(c).clearCofactor();return a.assertValidity(),a},encodeToCurve(n,i){let s=If(n,1,{...r,DST:r.encodeDST,...i}),o=t.fromAffine(e(s[0])).clearCofactor();return o.assertValidity(),o}}}var ip,oa=xe(()=>{yr();jt();ip=rt});function ss(t,e){let r=(i,s)=>{let o=s.negate();return i?o:s},n=i=>{let s=Math.ceil(e/i)+1,o=2**(i-1);return{windows:s,windowSize:o}};return{constTimeNegate:r,unsafeLadder(i,s){let o=t.ZERO,c=i;for(;s>cp;)s&aa&&(o=o.add(c)),c=c.double(),s>>=aa;return o},precomputeWindow(i,s){let{windows:o,windowSize:c}=n(s),a=[],d=i,l=d;for(let f=0;f<o;f++){l=d,a.push(l);for(let T=1;T<c;T++)l=l.add(d),a.push(l);d=l.double()}return a},wNAF(i,s,o){let{windows:c,windowSize:a}=n(i),d=t.ZERO,l=t.BASE,f=BigInt(2**i-1),T=2**i,_=BigInt(i);for(let b=0;b<c;b++){let E=b*a,U=Number(o&f);o>>=_,U>a&&(U-=T,o+=aa);let I=E,$=E+Math.abs(U)-1,M=b%2!==0,K=U<0;U===0?l=l.add(r(M,s[I])):d=d.add(r(K,s[$]))}return{p:d,f:l}},wNAFCached(i,s,o,c){let a=i._WINDOW_SIZE||1,d=s.get(i);return d||(d=this.precomputeWindow(i,a),a!==1&&s.set(i,c(d))),this.wNAF(a,d,o)}}}function os(t){return ns(t.Fp),Ut(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...ta(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}var cp,aa,ca=xe(()=>{yr();jt();cp=BigInt(0),aa=BigInt(1)});function up(t){let e=os(t);Ut(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:i}=e;if(r){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}function ua(t){let e=up(t),{Fp:r}=e,n=e.toBytes||((b,E,U)=>{let I=E.toAffine();return Re(Uint8Array.from([4]),r.toBytes(I.x),r.toBytes(I.y))}),i=e.fromBytes||(b=>{let E=b.subarray(1),U=r.fromBytes(E.subarray(0,r.BYTES)),I=r.fromBytes(E.subarray(r.BYTES,2*r.BYTES));return{x:U,y:I}});function s(b){let{a:E,b:U}=e,I=r.sqr(b),$=r.mul(I,b);return r.add(r.add($,r.mul(b,E)),U)}if(!r.eql(r.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function o(b){return typeof b=="bigint"&&Mr<b&&b<e.n}function c(b){if(!o(b))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function a(b){let{allowedPrivateKeyLengths:E,nByteLength:U,wrapPrivateKey:I,n:$}=e;if(E&&typeof b!="bigint"){if(on(b)&&(b=Ot(b)),typeof b!="string"||!E.includes(b.length))throw new Error("Invalid key");b=b.padStart(U*2,"0")}let M;try{M=typeof b=="bigint"?b:rt(Ye("private key",b,U))}catch{throw new Error(`private key must be ${U} bytes, hex or bigint, not ${typeof b}`)}return I&&(M=Ie(M,$)),c(M),M}let d=new Map;function l(b){if(!(b instanceof f))throw new Error("ProjectivePoint expected")}class f{constructor(E,U,I){if(this.px=E,this.py=U,this.pz=I,E==null||!r.isValid(E))throw new Error("x required");if(U==null||!r.isValid(U))throw new Error("y required");if(I==null||!r.isValid(I))throw new Error("z required")}static fromAffine(E){let{x:U,y:I}=E||{};if(!E||!r.isValid(U)||!r.isValid(I))throw new Error("invalid affine point");if(E instanceof f)throw new Error("projective point not allowed");let $=M=>r.eql(M,r.ZERO);return $(U)&&$(I)?f.ZERO:new f(U,I,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(E){let U=r.invertBatch(E.map(I=>I.pz));return E.map((I,$)=>I.toAffine(U[$])).map(f.fromAffine)}static fromHex(E){let U=f.fromAffine(i(Ye("pointHex",E)));return U.assertValidity(),U}static fromPrivateKey(E){return f.BASE.multiply(a(E))}_setWindowSize(E){this._WINDOW_SIZE=E,d.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:E,y:U}=this.toAffine();if(!r.isValid(E)||!r.isValid(U))throw new Error("bad point: x or y not FE");let I=r.sqr(U),$=s(E);if(!r.eql(I,$))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:E}=this.toAffine();if(r.isOdd)return!r.isOdd(E);throw new Error("Field doesn't support isOdd")}equals(E){l(E);let{px:U,py:I,pz:$}=this,{px:M,py:K,pz:F}=E,k=r.eql(r.mul(U,F),r.mul(M,$)),z=r.eql(r.mul(I,F),r.mul(K,$));return k&&z}negate(){return new f(this.px,r.neg(this.py),this.pz)}double(){let{a:E,b:U}=e,I=r.mul(U,as),{px:$,py:M,pz:K}=this,F=r.ZERO,k=r.ZERO,z=r.ZERO,Y=r.mul($,$),G=r.mul(M,M),ee=r.mul(K,K),L=r.mul($,M);return L=r.add(L,L),z=r.mul($,K),z=r.add(z,z),F=r.mul(E,z),k=r.mul(I,ee),k=r.add(F,k),F=r.sub(G,k),k=r.add(G,k),k=r.mul(F,k),F=r.mul(L,F),z=r.mul(I,z),ee=r.mul(E,ee),L=r.sub(Y,ee),L=r.mul(E,L),L=r.add(L,z),z=r.add(Y,Y),Y=r.add(z,Y),Y=r.add(Y,ee),Y=r.mul(Y,L),k=r.add(k,Y),ee=r.mul(M,K),ee=r.add(ee,ee),Y=r.mul(ee,L),F=r.sub(F,Y),z=r.mul(ee,G),z=r.add(z,z),z=r.add(z,z),new f(F,k,z)}add(E){l(E);let{px:U,py:I,pz:$}=this,{px:M,py:K,pz:F}=E,k=r.ZERO,z=r.ZERO,Y=r.ZERO,G=e.a,ee=r.mul(e.b,as),L=r.mul(U,M),ce=r.mul(I,K),le=r.mul($,F),_e=r.add(U,I),ye=r.add(M,K);_e=r.mul(_e,ye),ye=r.add(L,ce),_e=r.sub(_e,ye),ye=r.add(U,$);let Z=r.add(M,F);return ye=r.mul(ye,Z),Z=r.add(L,le),ye=r.sub(ye,Z),Z=r.add(I,$),k=r.add(K,F),Z=r.mul(Z,k),k=r.add(ce,le),Z=r.sub(Z,k),Y=r.mul(G,ye),k=r.mul(ee,le),Y=r.add(k,Y),k=r.sub(ce,Y),Y=r.add(ce,Y),z=r.mul(k,Y),ce=r.add(L,L),ce=r.add(ce,L),le=r.mul(G,le),ye=r.mul(ee,ye),ce=r.add(ce,le),le=r.sub(L,le),le=r.mul(G,le),ye=r.add(ye,le),L=r.mul(ce,ye),z=r.add(z,L),L=r.mul(Z,ye),k=r.mul(_e,k),k=r.sub(k,L),L=r.mul(_e,ce),Y=r.mul(Z,Y),Y=r.add(Y,L),new f(k,z,Y)}subtract(E){return this.add(E.negate())}is0(){return this.equals(f.ZERO)}wNAF(E){return _.wNAFCached(this,d,E,U=>{let I=r.invertBatch(U.map($=>$.pz));return U.map(($,M)=>$.toAffine(I[M])).map(f.fromAffine)})}multiplyUnsafe(E){let U=f.ZERO;if(E===Mr)return U;if(c(E),E===De)return this;let{endo:I}=e;if(!I)return _.unsafeLadder(this,E);let{k1neg:$,k1:M,k2neg:K,k2:F}=I.splitScalar(E),k=U,z=U,Y=this;for(;M>Mr||F>Mr;)M&De&&(k=k.add(Y)),F&De&&(z=z.add(Y)),Y=Y.double(),M>>=De,F>>=De;return $&&(k=k.negate()),K&&(z=z.negate()),z=new f(r.mul(z.px,I.beta),z.py,z.pz),k.add(z)}multiply(E){c(E);let U=E,I,$,{endo:M}=e;if(M){let{k1neg:K,k1:F,k2neg:k,k2:z}=M.splitScalar(U),{p:Y,f:G}=this.wNAF(F),{p:ee,f:L}=this.wNAF(z);Y=_.constTimeNegate(K,Y),ee=_.constTimeNegate(k,ee),ee=new f(r.mul(ee.px,M.beta),ee.py,ee.pz),I=Y.add(ee),$=G.add(L)}else{let{p:K,f:F}=this.wNAF(U);I=K,$=F}return f.normalizeZ([I,$])[0]}multiplyAndAddUnsafe(E,U,I){let $=f.BASE,M=(F,k)=>k===Mr||k===De||!F.equals($)?F.multiplyUnsafe(k):F.multiply(k),K=M(this,U).add(M(E,I));return K.is0()?void 0:K}toAffine(E){let{px:U,py:I,pz:$}=this,M=this.is0();E==null&&(E=M?r.ONE:r.inv($));let K=r.mul(U,E),F=r.mul(I,E),k=r.mul($,E);if(M)return{x:r.ZERO,y:r.ZERO};if(!r.eql(k,r.ONE))throw new Error("invZ was invalid");return{x:K,y:F}}isTorsionFree(){let{h:E,isTorsionFree:U}=e;if(E===De)return!0;if(U)return U(f,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:E,clearCofactor:U}=e;return E===De?this:U?U(f,this):this.multiplyUnsafe(e.h)}toRawBytes(E=!0){return this.assertValidity(),n(f,this,E)}toHex(E=!0){return Ot(this.toRawBytes(E))}}f.BASE=new f(e.Gx,e.Gy,r.ONE),f.ZERO=new f(r.ZERO,r.ONE,r.ZERO);let T=e.nBitLength,_=ss(f,e.endo?Math.ceil(T/2):T);return{CURVE:e,ProjectivePoint:f,normPrivateKeyToScalar:a,weierstrassEquation:s,isWithinCurveOrder:o}}function fp(t,e){let r=t.ORDER,n=Mr;for(let b=r-De;b%wr===Mr;b/=wr)n+=De;let i=n,s=wr<<i-De-De,o=s*wr,c=(r-De)/o,a=(c-De)/wr,d=o-De,l=s,f=t.pow(e,c),T=t.pow(e,(c+De)/wr),_=(b,E)=>{let U=f,I=t.pow(E,d),$=t.sqr(I);$=t.mul($,E);let M=t.mul(b,$);M=t.pow(M,a),M=t.mul(M,I),I=t.mul(M,E),$=t.mul(M,b);let K=t.mul($,I);M=t.pow(K,l);let F=t.eql(M,t.ONE);I=t.mul($,T),M=t.mul(K,U),$=t.cmov(I,$,F),K=t.cmov(M,K,F);for(let k=i;k>De;k--){let z=k-wr;z=wr<<z-De;let Y=t.pow(K,z),G=t.eql(Y,t.ONE);I=t.mul($,U),U=t.mul(U,U),Y=t.mul(K,U),$=t.cmov(I,$,G),K=t.cmov(Y,K,G)}return{isValid:F,value:$}};if(t.ORDER%Of===as){let b=(t.ORDER-as)/Of,E=t.sqrt(t.neg(e));_=(U,I)=>{let $=t.sqr(I),M=t.mul(U,I);$=t.mul($,M);let K=t.pow($,b);K=t.mul(K,M);let F=t.mul(K,E),k=t.mul(t.sqr(K),I),z=t.eql(k,U),Y=t.cmov(F,K,z);return{isValid:z,value:Y}}}return _}function fa(t,e){if(ns(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let r=fp(t,e.Z);if(!t.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,s,o,c,a,d,l,f;i=t.sqr(n),i=t.mul(i,e.Z),s=t.sqr(i),s=t.add(s,i),o=t.add(s,t.ONE),o=t.mul(o,e.B),c=t.cmov(e.Z,t.neg(s),!t.eql(s,t.ZERO)),c=t.mul(c,e.A),s=t.sqr(o),d=t.sqr(c),a=t.mul(d,e.A),s=t.add(s,a),s=t.mul(s,o),d=t.mul(d,c),a=t.mul(d,e.B),s=t.add(s,a),l=t.mul(i,o);let{isValid:T,value:_}=r(s,d);f=t.mul(i,n),f=t.mul(f,_),l=t.cmov(l,o,T),f=t.cmov(f,_,T);let b=t.isOdd(n)===t.isOdd(f);return f=t.cmov(t.neg(f),f,b),l=t.div(l,c),{x:l,y:f}}}var Hy,jy,Mr,De,wr,as,Of,la=xe(()=>{yr();jt();jt();ca();({bytesToNumberBE:Hy,hexToBytes:jy}=rs),Mr=BigInt(0),De=BigInt(1),wr=BigInt(2),as=BigInt(3),Of=BigInt(4)});function Uf(t){let{Fp:e,Fr:r,Fp2:n,Fp6:i,Fp12:s}=t.fields,o=pr(t.params.x);function c(Z){let{x:ue,y:j}=Z,C=ue,X=j,D=n.ONE,ne=C,O=X,m=D,fe=[];for(let ie=o-2;ie>=0;ie--){let se=n.sqr(O),Q=n.sqr(m),u=n.multiplyByB(n.mul(Q,cs)),h=n.mul(u,cs),p=n.sub(n.sub(n.sqr(n.add(O,m)),Q),se);if(fe.push([n.sub(u,se),n.mul(n.sqr(ne),cs),n.neg(p)]),ne=n.div(n.mul(n.mul(n.sub(se,h),ne),O),da),O=n.sub(n.sqr(n.div(n.add(se,h),da)),n.mul(n.sqr(u),cs)),m=n.mul(se,p),an(t.params.x,ie)){let A=n.sub(O,n.mul(X,m)),x=n.sub(ne,n.mul(C,m));fe.push([n.sub(n.mul(A,C),n.mul(x,X)),n.neg(A),x]);let v=n.sqr(x),N=n.mul(v,x),g=n.mul(v,ne),B=n.add(n.sub(N,n.mul(g,da)),n.mul(n.sqr(A),m));ne=n.mul(x,B),O=n.sub(n.mul(n.sub(g,B),A),n.mul(N,O)),m=n.mul(m,N)}}return fe}function a(Z,ue){let{x:j}=t.params,C=ue[0],X=ue[1],D=s.ONE;for(let ne=0,O=o-2;O>=0;O--,ne++){let m=Z[ne];if(D=s.multiplyBy014(D,m[0],n.mul(m[1],C),n.mul(m[2],X)),an(j,O)){ne+=1;let fe=Z[ne];D=s.multiplyBy014(D,fe[0],n.mul(fe[1],C),n.mul(fe[2],X))}O!==0&&(D=s.sqr(D))}return s.conjugate(D)}let d={randomPrivateKey:()=>{let Z=is(r.ORDER);return ra(t.randomBytes(Z),r.ORDER)},calcPairingPrecomputes:c},l=ua({n:r.ORDER,...t.G1}),f=Object.assign(l,sa(l.ProjectivePoint,t.G1.mapToCurve,{...t.htfDefaults,...t.G1.htfDefaults}));function T(Z){let ue=Z;return ue._PPRECOMPUTES||(ue._PPRECOMPUTES=c(Z.toAffine())),ue._PPRECOMPUTES}let _=ua({n:r.ORDER,...t.G2}),b=Object.assign(_,sa(_.ProjectivePoint,t.G2.mapToCurve,{...t.htfDefaults,...t.G2.htfDefaults})),{ShortSignature:E}=t.G1,{Signature:U}=t.G2;function I(Z,ue,j=!0){if(Z.equals(f.ProjectivePoint.ZERO)||ue.equals(b.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");Z.assertValidity(),ue.assertValidity();let C=Z.toAffine(),X=a(T(ue),[C.x,C.y]);return j?s.finalExponentiate(X):X}function $(Z){return Z instanceof f.ProjectivePoint?Z:f.ProjectivePoint.fromHex(Z)}function M(Z,ue){return Z instanceof f.ProjectivePoint?Z:f.hashToCurve(Ye("point",Z),ue)}function K(Z){return Z instanceof b.ProjectivePoint?Z:U.fromHex(Z)}function F(Z,ue){return Z instanceof b.ProjectivePoint?Z:b.hashToCurve(Ye("point",Z),ue)}function k(Z){return f.ProjectivePoint.fromPrivateKey(Z).toRawBytes(!0)}function z(Z){return b.ProjectivePoint.fromPrivateKey(Z).toRawBytes(!0)}function Y(Z,ue,j){let C=F(Z,j);C.assertValidity();let X=C.multiply(f.normPrivateKeyToScalar(ue));return Z instanceof b.ProjectivePoint?X:U.toRawBytes(X)}function G(Z,ue,j){let C=M(Z,j);C.assertValidity();let X=C.multiply(f.normPrivateKeyToScalar(ue));return Z instanceof f.ProjectivePoint?X:E.toRawBytes(X)}function ee(Z,ue,j,C){let X=$(j),D=F(ue,C),ne=f.ProjectivePoint.BASE,O=K(Z),m=I(X.negate(),D,!1),fe=I(ne,O,!1),ie=s.finalExponentiate(s.mul(fe,m));return s.eql(ie,s.ONE)}function L(Z,ue,j,C){let X=K(j),D=M(ue,C),ne=b.ProjectivePoint.BASE,O=$(Z),m=I(D,X,!1),fe=I(O,ne.negate(),!1),ie=s.finalExponentiate(s.mul(fe,m));return s.eql(ie,s.ONE)}function ce(Z){if(!Z.length)throw new Error("Expected non-empty array");let j=Z.map($).reduce((C,X)=>C.add(X),f.ProjectivePoint.ZERO);return Z[0]instanceof f.ProjectivePoint?(j.assertValidity(),j):j.toRawBytes(!0)}function le(Z){if(!Z.length)throw new Error("Expected non-empty array");let j=Z.map(K).reduce((C,X)=>C.add(X),b.ProjectivePoint.ZERO);return Z[0]instanceof b.ProjectivePoint?(j.assertValidity(),j):U.toRawBytes(j)}function _e(Z){if(!Z.length)throw new Error("Expected non-empty array");let j=Z.map($).reduce((C,X)=>C.add(X),f.ProjectivePoint.ZERO);return Z[0]instanceof f.ProjectivePoint?(j.assertValidity(),j):E.toRawBytes(j)}function ye(Z,ue,j,C){if(!ue.length)throw new Error("Expected non-empty messages array");if(j.length!==ue.length)throw new Error("Pubkey count should equal msg count");let X=K(Z),D=ue.map(O=>F(O,C)),ne=j.map($);try{let O=[];for(let ie of new Set(D)){let se=D.reduce((Q,u,h)=>u===ie?Q.add(ne[h]):Q,f.ProjectivePoint.ZERO);O.push(I(se,ie,!1))}O.push(I(f.ProjectivePoint.BASE.negate(),X,!1));let m=O.reduce((ie,se)=>s.mul(ie,se),s.ONE),fe=s.finalExponentiate(m);return s.eql(fe,s.ONE)}catch{return!1}}return f.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:k,getPublicKeyForShortSignatures:z,sign:Y,signShortSignature:G,verify:ee,verifyBatch:ye,verifyShortSignature:L,aggregatePublicKeys:ce,aggregateSignatures:le,aggregateShortSignatures:_e,millerLoop:a,pairing:I,G1:f,G2:b,Signature:U,ShortSignature:E,fields:{Fr:r,Fp:e,Fp2:n,Fp6:i,Fp12:s},params:{x:t.params.x,r:t.params.r,G1b:t.G1.b,G2b:t.G2.b},utils:d}}var da,cs,Ff=xe(()=>{yr();jt();oa();la();da=BigInt(2),cs=BigInt(3)});function ha(t,e){let r=y.sqr(t),n=y.sqr(e);return{first:y.add(y.mulByNonresidue(n),r),second:y.sub(y.sub(y.sqr(y.add(t,e)),r),n)}}function Ap(t,e){let r=oe.mul(oe.frobeniusMap(oe.multiplyByFp2(Bp,t),1),Qf).c0.c0,n=oe.mul(oe.frobeniusMap(oe.multiplyByFp2(vp,e),1),Lf).c0.c0;return[r,n]}function Zf(t,e){let r=e.toAffine(),n=Ap(r.x,r.y);return new t(n[0],n[1],y.ONE)}function Sp(t,e){return[y.mul(t,Tp),y.neg(e)]}function Np(t,e){let r=e.toAffine(),n=Sp(r.x,r.y);return new t(n[0],n[1],y.ONE)}function ls(t){t=t.slice();let e=t[0]&224,r=!!(e>>7&1),n=!!(e>>6&1),i=!!(e>>5&1);return t[0]&=31,{compressed:r,infinity:n,sort:i,value:t}}function jn(t,e){if(t[0]&224)throw new Error("setMask: non-empty mask");return e.compressed&&(t[0]|=128),e.infinity&&(t[0]|=64),e.sort&&(t[0]|=32),t}function Wf(t){t.assertValidity();let e=t.equals(et.G1.ProjectivePoint.ZERO),{x:r,y:n}=t.toAffine();if(e)return ds.slice();let i=q.ORDER,s=!!(n*ke/i);return jn(qe(r,q.BYTES),{compressed:!0,sort:s})}function Xf(t){t.assertValidity();let e=q.BYTES;if(t.equals(et.G2.ProjectivePoint.ZERO))return Re(ds,qe(ze,e));let{x:r,y:n}=t.toAffine(),{re:i,im:s}=y.reim(r),{re:o,im:c}=y.reim(n),d=!!((c>ze?c*ke:o*ke)/q.ORDER&kr),l=i;return Re(jn(qe(s,e),{sort:d,compressed:!0}),qe(l,e))}var ze,kr,ke,us,Hn,lp,dp,ma,q,Pf,Mf,kf,Cf,qf,fs,y,hp,br,pp,$f,Vf,Gf,Hf,J,mp,yp,ya,gp,jf,Yf,zf,Kf,oe,wp,bp,xp,_p,Ep,Jf,Qf,Lf,Bp,vp,Tp,pa,ds,et,Df=xe(()=>{li();Yr();Ff();yr();jt();la();oa();ze=BigInt(0),kr=BigInt(1),ke=BigInt(2),us=BigInt(3),Hn=BigInt(4),lp=BigInt(8),dp=BigInt(16),ma=BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),q=Gn(ma),Pf=Gn(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),Mf=({c0:t,c1:e},{c0:r,c1:n})=>({c0:q.add(t,r),c1:q.add(e,n)}),kf=({c0:t,c1:e},{c0:r,c1:n})=>({c0:q.sub(t,r),c1:q.sub(e,n)}),Cf=({c0:t,c1:e},r)=>{if(typeof r=="bigint")return{c0:q.mul(t,r),c1:q.mul(e,r)};let{c0:n,c1:i}=r,s=q.mul(t,n),o=q.mul(e,i),c=q.sub(s,o),a=q.sub(q.mul(q.add(t,e),q.add(n,i)),q.add(s,o));return{c0:c,c1:a}},qf=({c0:t,c1:e})=>{let r=q.add(t,e),n=q.sub(t,e),i=q.add(t,t);return{c0:q.mul(r,n),c1:q.mul(i,e)}},fs=ma*ma,y={ORDER:fs,BITS:pr(fs),BYTES:Math.ceil(pr(fs)/8),MASK:mr(pr(fs)),ZERO:{c0:q.ZERO,c1:q.ZERO},ONE:{c0:q.ONE,c1:q.ZERO},create:t=>t,isValid:({c0:t,c1:e})=>typeof t=="bigint"&&typeof e=="bigint",is0:({c0:t,c1:e})=>q.is0(t)&&q.is0(e),eql:({c0:t,c1:e},{c0:r,c1:n})=>q.eql(t,r)&&q.eql(e,n),neg:({c0:t,c1:e})=>({c0:q.neg(t),c1:q.neg(e)}),pow:(t,e)=>$n(y,t,e),invertBatch:t=>Vn(y,t),add:Mf,sub:kf,mul:Cf,sqr:qf,addN:Mf,subN:kf,mulN:Cf,sqrN:qf,div:(t,e)=>y.mul(t,typeof e=="bigint"?q.inv(q.create(e)):y.inv(e)),inv:({c0:t,c1:e})=>{let r=q.inv(q.create(t*t+e*e));return{c0:q.mul(r,q.create(t)),c1:q.mul(r,q.create(-e))}},sqrt:t=>{if(y.eql(t,y.ZERO))return y.ZERO;let e=y.pow(t,(y.ORDER+lp)/dp),r=y.div(y.sqr(e),t),n=pp,i=[n[0],n[2],n[4],n[6]].find(_=>y.eql(_,r));if(!i)throw new Error("No root");let s=n.indexOf(i),o=n[s/2];if(!o)throw new Error("Invalid root");let c=y.div(e,o),a=y.neg(c),{re:d,im:l}=y.reim(c),{re:f,im:T}=y.reim(a);return l>T||l===T&&d>f?c:a},isOdd:t=>{let{re:e,im:r}=y.reim(t),n=e%ke,i=e===ze,s=r%ke;return BigInt(n||i&&s)==kr},fromBytes(t){if(t.length!==y.BYTES)throw new Error(`fromBytes wrong length=${t.length}`);return{c0:q.fromBytes(t.subarray(0,q.BYTES)),c1:q.fromBytes(t.subarray(q.BYTES))}},toBytes:({c0:t,c1:e})=>Re(q.toBytes(t),q.toBytes(e)),cmov:({c0:t,c1:e},{c0:r,c1:n},i)=>({c0:q.cmov(t,r,i),c1:q.cmov(e,n,i)}),reim:({c0:t,c1:e})=>({re:t,im:e}),mulByNonresidue:({c0:t,c1:e})=>({c0:q.sub(t,e),c1:q.add(t,e)}),multiplyByB:({c0:t,c1:e})=>{let r=q.mul(t,Hn),n=q.mul(e,Hn);return{c0:q.sub(r,n),c1:q.add(r,n)}},fromBigTuple:t=>{if(t.length!==2)throw new Error("Invalid tuple");let e=t.map(r=>q.create(r));return{c0:e[0],c1:e[1]}},frobeniusMap:({c0:t,c1:e},r)=>({c0:t,c1:q.mul(e,hp[r%2])})},hp=[BigInt("0x1"),BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa")].map(t=>q.create(t)),br=BigInt("0x6af0e0437ff400b6831e36d6bd17ffe48395dabc2d3435e77f76e17009241c5ee67992f72ec05f4c81084fbede3cc09"),pp=[[kr,ze],[br,-br],[ze,kr],[br,br],[-kr,ze],[-br,br],[ze,-kr],[-br,-br]].map(t=>y.fromBigTuple(t)),$f=({c0:t,c1:e,c2:r},{c0:n,c1:i,c2:s})=>({c0:y.add(t,n),c1:y.add(e,i),c2:y.add(r,s)}),Vf=({c0:t,c1:e,c2:r},{c0:n,c1:i,c2:s})=>({c0:y.sub(t,n),c1:y.sub(e,i),c2:y.sub(r,s)}),Gf=({c0:t,c1:e,c2:r},n)=>{if(typeof n=="bigint")return{c0:y.mul(t,n),c1:y.mul(e,n),c2:y.mul(r,n)};let{c0:i,c1:s,c2:o}=n,c=y.mul(t,i),a=y.mul(e,s),d=y.mul(r,o);return{c0:y.add(c,y.mulByNonresidue(y.sub(y.mul(y.add(e,r),y.add(s,o)),y.add(a,d)))),c1:y.add(y.sub(y.mul(y.add(t,e),y.add(i,s)),y.add(c,a)),y.mulByNonresidue(d)),c2:y.sub(y.add(a,y.mul(y.add(t,r),y.add(i,o))),y.add(c,d))}},Hf=({c0:t,c1:e,c2:r})=>{let n=y.sqr(t),i=y.mul(y.mul(t,e),ke),s=y.mul(y.mul(e,r),ke),o=y.sqr(r);return{c0:y.add(y.mulByNonresidue(s),n),c1:y.add(y.mulByNonresidue(o),i),c2:y.sub(y.sub(y.add(y.add(i,y.sqr(y.add(y.sub(t,e),r))),s),n),o)}},J={ORDER:y.ORDER,BITS:3*y.BITS,BYTES:3*y.BYTES,MASK:mr(3*y.BITS),ZERO:{c0:y.ZERO,c1:y.ZERO,c2:y.ZERO},ONE:{c0:y.ONE,c1:y.ZERO,c2:y.ZERO},create:t=>t,isValid:({c0:t,c1:e,c2:r})=>y.isValid(t)&&y.isValid(e)&&y.isValid(r),is0:({c0:t,c1:e,c2:r})=>y.is0(t)&&y.is0(e)&&y.is0(r),neg:({c0:t,c1:e,c2:r})=>({c0:y.neg(t),c1:y.neg(e),c2:y.neg(r)}),eql:({c0:t,c1:e,c2:r},{c0:n,c1:i,c2:s})=>y.eql(t,n)&&y.eql(e,i)&&y.eql(r,s),sqrt:()=>{throw new Error("Not implemented")},div:(t,e)=>J.mul(t,typeof e=="bigint"?q.inv(q.create(e)):J.inv(e)),pow:(t,e)=>$n(J,t,e),invertBatch:t=>Vn(J,t),add:$f,sub:Vf,mul:Gf,sqr:Hf,addN:$f,subN:Vf,mulN:Gf,sqrN:Hf,inv:({c0:t,c1:e,c2:r})=>{let n=y.sub(y.sqr(t),y.mulByNonresidue(y.mul(r,e))),i=y.sub(y.mulByNonresidue(y.sqr(r)),y.mul(t,e)),s=y.sub(y.sqr(e),y.mul(t,r)),o=y.inv(y.add(y.mulByNonresidue(y.add(y.mul(r,i),y.mul(e,s))),y.mul(t,n)));return{c0:y.mul(o,n),c1:y.mul(o,i),c2:y.mul(o,s)}},fromBytes:t=>{if(t.length!==J.BYTES)throw new Error(`fromBytes wrong length=${t.length}`);return{c0:y.fromBytes(t.subarray(0,y.BYTES)),c1:y.fromBytes(t.subarray(y.BYTES,2*y.BYTES)),c2:y.fromBytes(t.subarray(2*y.BYTES))}},toBytes:({c0:t,c1:e,c2:r})=>Re(y.toBytes(t),y.toBytes(e),y.toBytes(r)),cmov:({c0:t,c1:e,c2:r},{c0:n,c1:i,c2:s},o)=>({c0:y.cmov(t,n,o),c1:y.cmov(e,i,o),c2:y.cmov(r,s,o)}),fromBigSix:t=>{if(!Array.isArray(t)||t.length!==6)throw new Error("Invalid Fp6 usage");return{c0:y.fromBigTuple(t.slice(0,2)),c1:y.fromBigTuple(t.slice(2,4)),c2:y.fromBigTuple(t.slice(4,6))}},frobeniusMap:({c0:t,c1:e,c2:r},n)=>({c0:y.frobeniusMap(t,n),c1:y.mul(y.frobeniusMap(e,n),mp[n%6]),c2:y.mul(y.frobeniusMap(r,n),yp[n%6])}),mulByNonresidue:({c0:t,c1:e,c2:r})=>({c0:y.mulByNonresidue(r),c1:t,c2:e}),multiplyBy1:({c0:t,c1:e,c2:r},n)=>({c0:y.mulByNonresidue(y.mul(r,n)),c1:y.mul(t,n),c2:y.mul(e,n)}),multiplyBy01({c0:t,c1:e,c2:r},n,i){let s=y.mul(t,n),o=y.mul(e,i);return{c0:y.add(y.mulByNonresidue(y.sub(y.mul(y.add(e,r),i),o)),s),c1:y.sub(y.sub(y.mul(y.add(n,i),y.add(t,e)),s),o),c2:y.add(y.sub(y.mul(y.add(t,r),n),s),o)}},multiplyByFp2:({c0:t,c1:e,c2:r},n)=>({c0:y.mul(t,n),c1:y.mul(e,n),c2:y.mul(r,n)})},mp=[[BigInt("0x1"),BigInt("0x0")],[BigInt("0x0"),BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac")],[BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),BigInt("0x0")],[BigInt("0x0"),BigInt("0x1")],[BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac"),BigInt("0x0")],[BigInt("0x0"),BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe")]].map(t=>y.fromBigTuple(t)),yp=[[BigInt("0x1"),BigInt("0x0")],[BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaad"),BigInt("0x0")],[BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac"),BigInt("0x0")],[BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa"),BigInt("0x0")],[BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),BigInt("0x0")],[BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffeffff"),BigInt("0x0")]].map(t=>y.fromBigTuple(t)),ya=BigInt("0xd201000000010000"),gp=pr(ya),jf=({c0:t,c1:e},{c0:r,c1:n})=>({c0:J.add(t,r),c1:J.add(e,n)}),Yf=({c0:t,c1:e},{c0:r,c1:n})=>({c0:J.sub(t,r),c1:J.sub(e,n)}),zf=({c0:t,c1:e},r)=>{if(typeof r=="bigint")return{c0:J.mul(t,r),c1:J.mul(e,r)};let{c0:n,c1:i}=r,s=J.mul(t,n),o=J.mul(e,i);return{c0:J.add(s,J.mulByNonresidue(o)),c1:J.sub(J.mul(J.add(t,e),J.add(n,i)),J.add(s,o))}},Kf=({c0:t,c1:e})=>{let r=J.mul(t,e);return{c0:J.sub(J.sub(J.mul(J.add(J.mulByNonresidue(e),t),J.add(t,e)),r),J.mulByNonresidue(r)),c1:J.add(r,r)}};oe={ORDER:y.ORDER,BITS:2*y.BITS,BYTES:2*y.BYTES,MASK:mr(2*y.BITS),ZERO:{c0:J.ZERO,c1:J.ZERO},ONE:{c0:J.ONE,c1:J.ZERO},create:t=>t,isValid:({c0:t,c1:e})=>J.isValid(t)&&J.isValid(e),is0:({c0:t,c1:e})=>J.is0(t)&&J.is0(e),neg:({c0:t,c1:e})=>({c0:J.neg(t),c1:J.neg(e)}),eql:({c0:t,c1:e},{c0:r,c1:n})=>J.eql(t,r)&&J.eql(e,n),sqrt:()=>{throw new Error("Not implemented")},inv:({c0:t,c1:e})=>{let r=J.inv(J.sub(J.sqr(t),J.mulByNonresidue(J.sqr(e))));return{c0:J.mul(t,r),c1:J.neg(J.mul(e,r))}},div:(t,e)=>oe.mul(t,typeof e=="bigint"?q.inv(q.create(e)):oe.inv(e)),pow:(t,e)=>$n(oe,t,e),invertBatch:t=>Vn(oe,t),add:jf,sub:Yf,mul:zf,sqr:Kf,addN:jf,subN:Yf,mulN:zf,sqrN:Kf,fromBytes:t=>{if(t.length!==oe.BYTES)throw new Error(`fromBytes wrong length=${t.length}`);return{c0:J.fromBytes(t.subarray(0,J.BYTES)),c1:J.fromBytes(t.subarray(J.BYTES))}},toBytes:({c0:t,c1:e})=>Re(J.toBytes(t),J.toBytes(e)),cmov:({c0:t,c1:e},{c0:r,c1:n},i)=>({c0:J.cmov(t,r,i),c1:J.cmov(e,n,i)}),fromBigTwelve:t=>({c0:J.fromBigSix(t.slice(0,6)),c1:J.fromBigSix(t.slice(6,12))}),frobeniusMap(t,e){let r=J.frobeniusMap(t.c0,e),{c0:n,c1:i,c2:s}=J.frobeniusMap(t.c1,e),o=wp[e%12];return{c0:r,c1:J.create({c0:y.mul(n,o),c1:y.mul(i,o),c2:y.mul(s,o)})}},multiplyBy014:({c0:t,c1:e},r,n,i)=>{let s=J.multiplyBy01(t,r,n),o=J.multiplyBy1(e,i);return{c0:J.add(J.mulByNonresidue(o),s),c1:J.sub(J.sub(J.multiplyBy01(J.add(e,t),r,y.add(n,i)),s),o)}},multiplyByFp2:({c0:t,c1:e},r)=>({c0:J.multiplyByFp2(t,r),c1:J.multiplyByFp2(e,r)}),conjugate:({c0:t,c1:e})=>({c0:t,c1:J.neg(e)}),_cyclotomicSquare:({c0:t,c1:e})=>{let{c0:r,c1:n,c2:i}=t,{c0:s,c1:o,c2:c}=e,{first:a,second:d}=ha(r,o),{first:l,second:f}=ha(s,i),{first:T,second:_}=ha(n,c),b=y.mulByNonresidue(_);return{c0:J.create({c0:y.add(y.mul(y.sub(a,r),ke),a),c1:y.add(y.mul(y.sub(l,n),ke),l),c2:y.add(y.mul(y.sub(T,i),ke),T)}),c1:J.create({c0:y.add(y.mul(y.add(b,s),ke),b),c1:y.add(y.mul(y.add(d,o),ke),d),c2:y.add(y.mul(y.add(f,c),ke),f)})}},_cyclotomicExp(t,e){let r=oe.ONE;for(let n=gp-1;n>=0;n--)r=oe._cyclotomicSquare(r),an(e,n)&&(r=oe.mul(r,t));return r},finalExponentiate:t=>{let e=ya,r=oe.div(oe.frobeniusMap(t,6),t),n=oe.mul(oe.frobeniusMap(r,2),r),i=oe.conjugate(oe._cyclotomicExp(n,e)),s=oe.mul(oe.conjugate(oe._cyclotomicSquare(n)),i),o=oe.conjugate(oe._cyclotomicExp(s,e)),c=oe.conjugate(oe._cyclotomicExp(o,e)),a=oe.mul(oe.conjugate(oe._cyclotomicExp(c,e)),oe._cyclotomicSquare(i)),d=oe.conjugate(oe._cyclotomicExp(a,e)),l=oe.frobeniusMap(oe.mul(i,c),2),f=oe.frobeniusMap(oe.mul(o,n),3),T=oe.frobeniusMap(oe.mul(a,oe.conjugate(n)),1),_=oe.mul(oe.mul(d,oe.conjugate(s)),n);return oe.mul(oe.mul(oe.mul(l,f),T),_)}},wp=[[BigInt("0x1"),BigInt("0x0")],[BigInt("0x1904d3bf02bb0667c231beb4202c0d1f0fd603fd3cbd5f4f7b2443d784bab9c4f67ea53d63e7813d8d0775ed92235fb8"),BigInt("0x00fc3e2b36c4e03288e9e902231f9fb854a14787b6c7b36fec0c8ec971f63c5f282d5ac14d6c7ec22cf78a126ddc4af3")],[BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffeffff"),BigInt("0x0")],[BigInt("0x135203e60180a68ee2e9c448d77a2cd91c3dedd930b1cf60ef396489f61eb45e304466cf3e67fa0af1ee7b04121bdea2"),BigInt("0x06af0e0437ff400b6831e36d6bd17ffe48395dabc2d3435e77f76e17009241c5ee67992f72ec05f4c81084fbede3cc09")],[BigInt("0x00000000000000005f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),BigInt("0x0")],[BigInt("0x144e4211384586c16bd3ad4afa99cc9170df3560e77982d0db45f3536814f0bd5871c1908bd478cd1ee605167ff82995"),BigInt("0x05b2cfd9013a5fd8df47fa6b48b1e045f39816240c0b8fee8beadf4d8e9c0566c63a3e6e257f87329b18fae980078116")],[BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa"),BigInt("0x0")],[BigInt("0x00fc3e2b36c4e03288e9e902231f9fb854a14787b6c7b36fec0c8ec971f63c5f282d5ac14d6c7ec22cf78a126ddc4af3"),BigInt("0x1904d3bf02bb0667c231beb4202c0d1f0fd603fd3cbd5f4f7b2443d784bab9c4f67ea53d63e7813d8d0775ed92235fb8")],[BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac"),BigInt("0x0")],[BigInt("0x06af0e0437ff400b6831e36d6bd17ffe48395dabc2d3435e77f76e17009241c5ee67992f72ec05f4c81084fbede3cc09"),BigInt("0x135203e60180a68ee2e9c448d77a2cd91c3dedd930b1cf60ef396489f61eb45e304466cf3e67fa0af1ee7b04121bdea2")],[BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaad"),BigInt("0x0")],[BigInt("0x05b2cfd9013a5fd8df47fa6b48b1e045f39816240c0b8fee8beadf4d8e9c0566c63a3e6e257f87329b18fae980078116"),BigInt("0x144e4211384586c16bd3ad4afa99cc9170df3560e77982d0db45f3536814f0bd5871c1908bd478cd1ee605167ff82995")]].map(t=>y.fromBigTuple(t)),bp=ia(y,[[["0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6"],["0x0","0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71a"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71e","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38d"],["0x171d6541fa38ccfaed6dea691f5fb614cb14b4e7f4e810aa22d6108f142b85757098e38d0f671c7188e2aaaaaaaa5ed1","0x0"]],[["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa63"],["0xc","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa9f"],["0x1","0x0"]],[["0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706","0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706"],["0x0","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97be"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71c","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38f"],["0x124c9ad43b6cf79bfbf7043de3811ad0761b0f37a1e26286b0e977c69aa274524e79097a56dc4bd9e1b371c71c718b10","0x0"]],[["0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb"],["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa9d3"],["0x12","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa99"],["0x1","0x0"]]].map(t=>t.map(e=>y.fromBigTuple(e.map(BigInt))))),xp=ia(q,[["0x11a05f2b1e833340b809101dd99815856b303e88a2d7005ff2627b56cdb4e2c85610c2d5f2e62d6eaeac1662734649b7","0x17294ed3e943ab2f0588bab22147a81c7c17e75b2f6a8417f565e33c70d1e86b4838f2a6f318c356e834eef1b3cb83bb","0xd54005db97678ec1d1048c5d10a9a1bce032473295983e56878e501ec68e25c958c3e3d2a09729fe0179f9dac9edcb0","0x1778e7166fcc6db74e0609d307e55412d7f5e4656a8dbf25f1b33289f1b330835336e25ce3107193c5b388641d9b6861","0xe99726a3199f4436642b4b3e4118e5499db995a1257fb3f086eeb65982fac18985a286f301e77c451154ce9ac8895d9","0x1630c3250d7313ff01d1201bf7a74ab5db3cb17dd952799b9ed3ab9097e68f90a0870d2dcae73d19cd13c1c66f652983","0xd6ed6553fe44d296a3726c38ae652bfb11586264f0f8ce19008e218f9c86b2a8da25128c1052ecaddd7f225a139ed84","0x17b81e7701abdbe2e8743884d1117e53356de5ab275b4db1a682c62ef0f2753339b7c8f8c8f475af9ccb5618e3f0c88e","0x80d3cf1f9a78fc47b90b33563be990dc43b756ce79f5574a2c596c928c5d1de4fa295f296b74e956d71986a8497e317","0x169b1f8e1bcfa7c42e0c37515d138f22dd2ecb803a0c5c99676314baf4bb1b7fa3190b2edc0327797f241067be390c9e","0x10321da079ce07e272d8ec09d2565b0dfa7dccdde6787f96d50af36003b14866f69b771f8c285decca67df3f1605fb7b","0x6e08c248e260e70bd1e962381edee3d31d79d7e22c837bc23c0bf1bc24c6b68c24b1b80b64d391fa9c8ba2e8ba2d229"],["0x8ca8d548cff19ae18b2e62f4bd3fa6f01d5ef4ba35b48ba9c9588617fc8ac62b558d681be343df8993cf9fa40d21b1c","0x12561a5deb559c4348b4711298e536367041e8ca0cf0800c0126c2588c48bf5713daa8846cb026e9e5c8276ec82b3bff","0xb2962fe57a3225e8137e629bff2991f6f89416f5a718cd1fca64e00b11aceacd6a3d0967c94fedcfcc239ba5cb83e19","0x3425581a58ae2fec83aafef7c40eb545b08243f16b1655154cca8abc28d6fd04976d5243eecf5c4130de8938dc62cd8","0x13a8e162022914a80a6f1d5f43e7a07dffdfc759a12062bb8d6b44e833b306da9bd29ba81f35781d539d395b3532a21e","0xe7355f8e4e667b955390f7f0506c6e9395735e9ce9cad4d0a43bcef24b8982f7400d24bc4228f11c02df9a29f6304a5","0x772caacf16936190f3e0c63e0596721570f5799af53a1894e2e073062aede9cea73b3538f0de06cec2574496ee84a3a","0x14a7ac2a9d64a8b230b3f5b074cf01996e7f63c21bca68a81996e1cdf9822c580fa5b9489d11e2d311f7d99bbdcc5a5e","0xa10ecf6ada54f825e920b3dafc7a3cce07f8d1d7161366b74100da67f39883503826692abba43704776ec3a79a1d641","0x95fc13ab9e92ad4476d6e3eb3a56680f682b4ee96f7d03776df533978f31c1593174e4b4b7865002d6384d168ecdd0a","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"],["0x90d97c81ba24ee0259d1f094980dcfa11ad138e48a869522b52af6c956543d3cd0c7aee9b3ba3c2be9845719707bb33","0x134996a104ee5811d51036d776fb46831223e96c254f383d0f906343eb67ad34d6c56711962fa8bfe097e75a2e41c696","0xcc786baa966e66f4a384c86a3b49942552e2d658a31ce2c344be4b91400da7d26d521628b00523b8dfe240c72de1f6","0x1f86376e8981c217898751ad8746757d42aa7b90eeb791c09e4a3ec03251cf9de405aba9ec61deca6355c77b0e5f4cb","0x8cc03fdefe0ff135caf4fe2a21529c4195536fbe3ce50b879833fd221351adc2ee7f8dc099040a841b6daecf2e8fedb","0x16603fca40634b6a2211e11db8f0a6a074a7d0d4afadb7bd76505c3d3ad5544e203f6326c95a807299b23ab13633a5f0","0x4ab0b9bcfac1bbcb2c977d027796b3ce75bb8ca2be184cb5231413c4d634f3747a87ac2460f415ec961f8855fe9d6f2","0x987c8d5333ab86fde9926bd2ca6c674170a05bfe3bdd81ffd038da6c26c842642f64550fedfe935a15e4ca31870fb29","0x9fc4018bd96684be88c9e221e4da1bb8f3abd16679dc26c1e8b6e6a1f20cabe69d65201c78607a360370e577bdba587","0xe1bba7a1186bdb5223abde7ada14a23c42a0ca7915af6fe06985e7ed1e4d43b9b3f7055dd4eba6f2bafaaebca731c30","0x19713e47937cd1be0dfd0b8f1d43fb93cd2fcbcb6caf493fd1183e416389e61031bf3a5cce3fbafce813711ad011c132","0x18b46a908f36f6deb918c143fed2edcc523559b8aaf0c2462e6bfe7f911f643249d9cdf41b44d606ce07c8a4d0074d8e","0xb182cac101b9399d155096004f53f447aa7b12a3426b08ec02710e807b4633f06c851c1919211f20d4c04f00b971ef8","0x245a394ad1eca9b72fc00ae7be315dc757b3b080d4c158013e6632d3c40659cc6cf90ad1c232a6442d9d3f5db980133","0x5c129645e44cf1102a159f748c4a3fc5e673d81d7e86568d9ab0f5d396a7ce46ba1049b6579afb7866b1e715475224b","0x15e6be4e990f03ce4ea50b3b42df2eb5cb181d8f84965a3957add4fa95af01b2b665027efec01c7704b456be69c8b604"],["0x16112c4c3a9c98b252181140fad0eae9601a6de578980be6eec3232b5be72e7a07f3688ef60c206d01479253b03663c1","0x1962d75c2381201e1a0cbd6c43c348b885c84ff731c4d59ca4a10356f453e01f78a4260763529e3532f6102c2e49a03d","0x58df3306640da276faaae7d6e8eb15778c4855551ae7f310c35a5dd279cd2eca6757cd636f96f891e2538b53dbf67f2","0x16b7d288798e5395f20d23bf89edb4d1d115c5dbddbcd30e123da489e726af41727364f2c28297ada8d26d98445f5416","0xbe0e079545f43e4b00cc912f8228ddcc6d19c9f0f69bbb0542eda0fc9dec916a20b15dc0fd2ededda39142311a5001d","0x8d9e5297186db2d9fb266eaac783182b70152c65550d881c5ecd87b6f0f5a6449f38db9dfa9cce202c6477faaf9b7ac","0x166007c08a99db2fc3ba8734ace9824b5eecfdfa8d0cf8ef5dd365bc400a0051d5fa9c01a58b1fb93d1a1399126a775c","0x16a3ef08be3ea7ea03bcddfabba6ff6ee5a4375efa1f4fd7feb34fd206357132b920f5b00801dee460ee415a15812ed9","0x1866c8ed336c61231a1be54fd1d74cc4f9fb0ce4c6af5920abc5750c4bf39b4852cfe2f7bb9248836b233d9d55535d4a","0x167a55cda70a6e1cea820597d94a84903216f763e13d87bb5308592e7ea7d4fbc7385ea3d529b35e346ef48bb8913f55","0x4d2f259eea405bd48f010a01ad2911d9c6dd039bb61a6290e591b36e636a5c871a5c29f4f83060400f8b49cba8f6aa8","0xaccbb67481d033ff5852c1e48c50c477f94ff8aefce42d28c0f9a88cea7913516f968986f7ebbea9684b529e2561092","0xad6b9514c767fe3c3613144b45f1496543346d98adf02267d5ceef9a00d9b8693000763e3b90ac11e99b138573345cc","0x2660400eb2e4f3b628bdd0d53cd76f2bf565b94e72927c1cb748df27942480e420517bd8714cc80d1fadc1326ed06f7","0xe0fa1d816ddc03e6b24255e0d7819c171c40f65e273b853324efcd6356caa205ca2f570f13497804415473a1d634b8f","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"]].map(t=>t.map(e=>BigInt(e)))),_p=fa(y,{A:y.create({c0:q.create(ze),c1:q.create(BigInt(240))}),B:y.create({c0:q.create(BigInt(1012)),c1:q.create(BigInt(1012))}),Z:y.create({c0:q.create(BigInt(-2)),c1:q.create(BigInt(-1))})}),Ep=fa(q,{A:q.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:q.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:q.create(BigInt(11))}),Jf=J.create({c0:y.ZERO,c1:y.ONE,c2:y.ZERO}),Qf=oe.create({c0:Jf,c1:J.ZERO}),Lf=oe.create({c0:J.ZERO,c1:Jf}),[Bp,vp]=oe.invertBatch([Qf,Lf]);Tp=BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac");pa=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:q.ORDER,m:2,k:128,expand:"xmd",hash:gn}),ds=jn(q.toBytes(ze),{infinity:!0,compressed:!0});et=Uf({fields:{Fp:q,Fp2:y,Fp6:J,Fp12:oe,Fr:Pf},G1:{Fp:q,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:q.ZERO,b:Hn,htfDefaults:{...pa,m:1,DST:"BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_"},wrapPrivateKey:!0,allowInfinityPoint:!0,isTorsionFree:(t,e)=>{let r=BigInt("0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),n=new t(q.mul(e.px,r),e.py,e.pz);return e.multiplyUnsafe(et.params.x).negate().multiplyUnsafe(et.params.x).equals(n)},clearCofactor:(t,e)=>e.multiplyUnsafe(et.params.x).add(e),mapToCurve:t=>{let{x:e,y:r}=Ep(q.create(t[0]));return xp(e,r)},fromBytes:t=>{let{compressed:e,infinity:r,sort:n,value:i}=ls(t);if(i.length===48&&e){let s=q.ORDER,o=rt(i),c=q.create(o&q.MASK);if(r){if(c!==ze)throw new Error("G1: non-empty compressed point at infinity");return{x:ze,y:ze}}let a=q.add(q.pow(c,us),q.create(et.params.G1b)),d=q.sqrt(a);if(!d)throw new Error("Invalid compressed G1 point");return d*ke/s!==BigInt(n)&&(d=q.neg(d)),{x:q.create(c),y:q.create(d)}}else if(i.length===96&&!e){let s=rt(i.subarray(0,q.BYTES)),o=rt(i.subarray(q.BYTES));if(r){if(s!==ze||o!==ze)throw new Error("G1: non-empty point at infinity");return et.G1.ProjectivePoint.ZERO.toAffine()}return{x:q.create(s),y:q.create(o)}}else throw new Error("Invalid point G1, expected 48/96 bytes")},toBytes:(t,e,r)=>{let n=e.equals(t.ZERO),{x:i,y:s}=e.toAffine();if(r){if(n)return ds.slice();let o=q.ORDER,c=!!(s*ke/o);return jn(qe(i,q.BYTES),{compressed:!0,sort:c})}else return n?Re(new Uint8Array([64]),new Uint8Array(2*q.BYTES-1)):Re(qe(i,q.BYTES),qe(s,q.BYTES))},ShortSignature:{fromHex(t){let{infinity:e,sort:r,value:n}=ls(Ye("signatureHex",t,48)),i=q.ORDER,s=rt(n);if(e)return et.G1.ProjectivePoint.ZERO;let o=q.create(s&q.MASK),c=q.add(q.pow(o,us),q.create(et.params.G1b)),a=q.sqrt(c);if(!a)throw new Error("Invalid compressed G1 point");let d=BigInt(r);a*ke/i!==d&&(a=q.neg(a));let l=et.G1.ProjectivePoint.fromAffine({x:o,y:a});return l.assertValidity(),l},toRawBytes(t){return Wf(t)},toHex(t){return Ot(Wf(t))}}},G2:{Fp:y,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),Gx:y.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:y.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")]),a:y.ZERO,b:y.fromBigTuple([Hn,Hn]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...pa},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:t=>{let{x:e,y:r}=_p(y.fromBigTuple(t));return bp(e,r)},isTorsionFree:(t,e)=>e.multiplyUnsafe(et.params.x).negate().equals(Zf(t,e)),clearCofactor:(t,e)=>{let r=et.params.x,n=e.multiplyUnsafe(r).negate(),i=Zf(t,e),s=e.double();return s=Np(t,s),s=s.subtract(i),i=n.add(i),i=i.multiplyUnsafe(r).negate(),s=s.add(i),s=s.subtract(n),s.subtract(e)},fromBytes:t=>{let{compressed:e,infinity:r,sort:n,value:i}=ls(t);if(!e&&!r&&n||!e&&r&&n||n&&r&&e)throw new Error("Invalid encoding flag: "+(t[0]&224));let s=q.BYTES,o=(c,a,d)=>rt(c.slice(a,d));if(i.length===96&&e){let c=et.params.G2b,a=q.ORDER;if(r){if(i.reduce((E,U)=>E!==0?U+1:U,0)>0)throw new Error("Invalid compressed G2 point");return{x:y.ZERO,y:y.ZERO}}let d=o(i,0,s),l=o(i,s,2*s),f=y.create({c0:q.create(l),c1:q.create(d)}),T=y.add(y.pow(f,us),c),_=y.sqrt(T),b=_.c1===ze?_.c0*ke/a:_.c1*ke/a?kr:ze;return _=n&&b>0?_:y.neg(_),{x:f,y:_}}else if(i.length===192&&!e){if(r){if(i.reduce((f,T)=>f!==0?T+1:T,0)>0)throw new Error("Invalid uncompressed G2 point");return{x:y.ZERO,y:y.ZERO}}let c=o(i,0,s),a=o(i,s,2*s),d=o(i,2*s,3*s),l=o(i,3*s,4*s);return{x:y.fromBigTuple([a,c]),y:y.fromBigTuple([l,d])}}else throw new Error("Invalid point G2, expected 96/192 bytes")},toBytes:(t,e,r)=>{let{BYTES:n,ORDER:i}=q,s=e.equals(t.ZERO),{x:o,y:c}=e.toAffine();if(r){if(s)return Re(ds,qe(ze,n));let a=!!(c.c1===ze?c.c0*ke/i:c.c1*ke/i);return Re(jn(qe(o.c1,n),{compressed:!0,sort:a}),qe(o.c0,n))}else{if(s)return Re(new Uint8Array([64]),new Uint8Array(4*n-1));let{re:a,im:d}=y.reim(o),{re:l,im:f}=y.reim(c);return Re(qe(d,n),qe(a,n),qe(f,n),qe(l,n))}},Signature:{fromHex(t){let{infinity:e,sort:r,value:n}=ls(Ye("signatureHex",t)),i=q.ORDER,s=n.length/2;if(s!==48&&s!==96)throw new Error("Invalid compressed signature length, must be 96 or 192");let o=rt(n.slice(0,s)),c=rt(n.slice(s));if(e)return et.G2.ProjectivePoint.ZERO;let a=q.create(o&q.MASK),d=q.create(c),l=y.create({c0:d,c1:a}),f=y.add(y.pow(l,us),et.params.G2b),T=y.sqrt(f);if(!T)throw new Error("Failed to find a square root");let{re:_,im:b}=y.reim(T),E=BigInt(r),U=b>ze&&b*ke/i!==E,I=b===ze&&_*ke/i!==E;(U||I)&&(T=y.neg(T));let $=et.G2.ProjectivePoint.fromAffine({x:l,y:T});return $.assertValidity(),$},toRawBytes(t){return Xf(t)},toHex(t){return Ot(Xf(t))}}},params:{x:ya,r:Pf.ORDER},htfDefaults:pa,hash:gn,randomBytes:ui})});function e0(t,e,r){let n=typeof t=="string"?t:je(t),i=typeof e=="string"?e:je(e),s=typeof r=="string"?r:je(r);return et.verifyShortSignature(i,s,n)}var ga=xe(()=>{Df();pt()});var wa,cn,hs=xe(()=>{vn();wa=t=>Ge(new At(t)),cn=t=>{let e=wa(t);return new Date(Number(e)/1e6)}});function t0(t,e){if(t.byteLength!==e.byteLength)return!1;let r=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<r.length;i++)if(r[i]!==n[i])return!1;return!0}function Op(t){let e=Yn.byteLength+Ip;if(t.byteLength!==e)throw new TypeError(`BLS DER-encoded public key must be ${e} bytes long`);let r=t.slice(0,Yn.byteLength);if(!t0(r,Yn))throw new TypeError(`BLS DER-encoded public key is invalid. Expect the following prefix: ${Yn}, but get ${r}`);return t.slice(Yn.byteLength)}function ba(t){if(t instanceof ArrayBuffer)return t;if(t instanceof Uint8Array)return t.buffer}async function ps(t){switch(t[0]){case Yt.Empty:return _t(zn("ic-hashtree-empty"));case Yt.Pruned:return t[1];case Yt.Leaf:return _t(ot(zn("ic-hashtree-leaf"),t[1]));case Yt.Labeled:return _t(ot(zn("ic-hashtree-labeled"),t[1],await ps(t[2])));case Yt.Fork:return _t(ot(zn("ic-hashtree-fork"),await ps(t[1]),await ps(t[2])));default:throw new Error("unreachable")}}function zn(t){let e=new Uint8Array([t.length]),r=new TextEncoder().encode(t);return ot(e,r)}function xr(t,e){if(t.length===0)switch(e[0]){case Yt.Leaf:{if(!e[1])throw new Error("Invalid tree structure for leaf");return e[1]instanceof ArrayBuffer?e[1]:e[1]instanceof Uint8Array?e[1].buffer:e[1]}case Yt.Fork:return e;default:return e}let r=typeof t[0]=="string"?new TextEncoder().encode(t[0]):t[0],n=Up(r,Kn(e));if(n)return xr(t.slice(1),n)}function Kn(t){switch(t[0]){case Yt.Empty:return[];case Yt.Fork:return Kn(t[1]).concat(Kn(t[2]));default:return[t]}}function Up(t,e){if(e.length!==0){for(let r of e)if(r[0]===Yt.Labeled){let n=r[1];if(t0(t,n))return r[2]}}}function xa(t){let{canisterId:e,subnetId:r,tree:n}=t,i=xr(["subnet",r.toUint8Array(),"canister_ranges"],n);if(!i||!(i instanceof ArrayBuffer))throw new Error(`Could not find canister ranges for subnet ${r}`);return Et(i).map(a=>[ae.fromUint8Array(a[0]),ae.fromUint8Array(a[1])]).some(a=>a[0].ltEq(e)&&a[1].gtEq(e))}var mt,Yt,un,Yn,Ip,Zn=xe(()=>{Fn();Qr();On();pt();gt();ga();hs();mt=class extends Ke{constructor(e){super(`Invalid certificate: ${e}`)}},Yt={Empty:0,Fork:1,Labeled:2,Leaf:3,Pruned:4};un=class t{constructor(e,r,n,i,s=5){this._rootKey=r,this._canisterId=n,this._blsVerify=i,this._maxAgeInMinutes=s,this.cert=Et(new Uint8Array(e))}static async create(e){let r=t.createUnverified(e);return await r.verify(),r}static createUnverified(e){let r=e.blsVerify;return r||(r=e0),new t(e.certificate,e.rootKey,e.canisterId,r,e.maxAgeInMinutes)}lookup(e){return ba(xr(e,this.cert.tree))}lookup_label(e){return this.lookup([e])}async verify(){let e=await ps(this.cert.tree),r=await this._checkDelegationAndGetKey(this.cert.delegation),n=this.cert.signature,i=Op(r),s=ot(zn("ic-state-root"),e),o=!1,c=this.lookup(["time"]);if(!c)throw new mt("Certificate does not contain a time");let a=5*60*1e3,d=this._maxAgeInMinutes*60*1e3,l=Date.now(),f=l-d,T=l+a,_=cn(c);if(_.getTime()<f)throw new mt(`Certificate is signed more than ${this._maxAgeInMinutes} minutes in the past. Certificate time: `+_.toISOString()+" Current time: "+new Date(l).toISOString());if(_.getTime()>T)throw new mt("Certificate is signed more than 5 minutes in the future. Certificate time: "+_.toISOString()+" Current time: "+new Date(l).toISOString());try{o=await this._blsVerify(new Uint8Array(i),new Uint8Array(n),new Uint8Array(s))}catch{o=!1}if(!o)throw new mt("Signature verification failed")}async _checkDelegationAndGetKey(e){if(!e)return this._rootKey;let r=await t.createUnverified({certificate:e.certificate,rootKey:this._rootKey,canisterId:this._canisterId,blsVerify:this._blsVerify,maxAgeInMinutes:1/0});if(r.cert.delegation)throw new mt("Delegation certificates cannot be nested");if(await r.verify(),!xa({canisterId:this._canisterId,subnetId:ae.fromUint8Array(new Uint8Array(e.subnet_id)),tree:r.cert.tree}))throw new mt(`Canister ${this._canisterId} not in range of delegations for subnet 0x${je(e.subnet_id)}`);let i=r.lookup(["subnet",e.subnet_id,"public_key"]);if(!i)throw new Error(`Could not find subnet key for subnet 0x${je(e.subnet_id)}`);return i}},Yn=Rr("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"),Ip=96});var ys={};mn(ys,{CustomPath:()=>_a,encodePath:()=>Ea,fetchNodeKeys:()=>n0,request:()=>ms});var _a,ms,n0,Ea,r0,i0,Fp,Pp,Wn=xe(()=>{gt();Qr();Zn();pt();Fn();hs();_a=class{constructor(e,r,n){this.key=e,this.path=r,this.decodeStrategy=n}},ms=async t=>{let{agent:e,paths:r}=t,n=ae.from(t.canisterId),i=[...new Set(r)],s=i.map(a=>Ea(a,n)),o=new Map,c=i.map((a,d)=>(async()=>{var l;try{let f=await e.readState(n,{paths:[s[d]]}),T=await un.create({certificate:f.certificate,rootKey:e.rootKey,canisterId:n}),_=(U,I)=>{if(I==="subnet"){let $=n0(f.certificate,n,e.rootKey);return{path:I,data:$}}else return{path:I,data:ba(U.lookup(Ea(I,n)))}},{path:b,data:E}=_(T,i[d]);if(!E)console.warn(`Expected to find result for path ${b}, but instead found nothing.`),typeof b=="string"?o.set(b,null):o.set(b.key,null);else switch(b){case"time":{o.set(b,cn(E));break}case"controllers":{o.set(b,Pp(E));break}case"module_hash":{o.set(b,r0(E));break}case"subnet":{o.set(b,E);break}case"candid":{o.set(b,new TextDecoder().decode(E));break}default:if(typeof b!="string"&&"key"in b&&"path"in b)switch(b.decodeStrategy){case"raw":o.set(b.key,E);break;case"leb128":{o.set(b.key,wa(E));break}case"cbor":{o.set(b.key,i0(E));break}case"hex":{o.set(b.key,r0(E));break}case"utf-8":o.set(b.key,Fp(E))}}}catch(f){if(!((l=f?.message)===null||l===void 0)&&l.includes("Invalid certificate"))throw new Ke(f.message);typeof a!="string"&&"key"in a&&"path"in a?o.set(a.key,null):o.set(a,null),console.group(),console.warn(`Expected to find result for path ${a}, but instead found nothing.`),console.warn(f),console.groupEnd()}})());return await Promise.all(c),o},n0=(t,e,r)=>{if(!e._isPrincipal)throw new Error("Invalid canisterId");let n=Et(new Uint8Array(t)),i=n.tree,s=n.delegation,o;if(s&&s.subnet_id?o=ae.fromUint8Array(new Uint8Array(s.subnet_id)):!s&&typeof r<"u"?(o=ae.selfAuthenticating(new Uint8Array(r)),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}):(o=ae.selfAuthenticating(ae.fromText("tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe").toUint8Array()),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}),!xa({canisterId:e,subnetId:o,tree:i}))throw new Error("Canister not in range");let a=xr(["subnet",s?.subnet_id,"node"],i),d=Kn(a);d.length;let l=new Map;return d.forEach(f=>{Object.getPrototypeOf(new Uint8Array(f[1]));let T=ae.from(new Uint8Array(f[1])).toText(),_=xr(["public_key"],f[2]);if(_.byteLength!==44)throw new Error("Invalid public key length");l.set(T,_)}),{subnetId:ae.fromUint8Array(new Uint8Array(s.subnet_id)).toText(),nodeKeys:l}},Ea=(t,e)=>{let r=new TextEncoder,n=s=>new DataView(r.encode(s).buffer).buffer,i=new DataView(e.toUint8Array().buffer).buffer;switch(t){case"time":return[n("time")];case"controllers":return[n("canister"),i,n("controllers")];case"module_hash":return[n("canister"),i,n("module_hash")];case"subnet":return[n("subnet")];case"candid":return[n("canister"),i,n("metadata"),n("candid:service")];default:if("key"in t&&"path"in t)if(typeof t.path=="string"||t.path instanceof ArrayBuffer){let s=t.path,o=typeof s=="string"?n(s):s;return[n("canister"),i,n("metadata"),o]}else return t.path}throw new Error(`An unexpeected error was encountered while encoding your path for canister status. Please ensure that your path, ${t} was formatted correctly.`)},r0=t=>je(t),i0=t=>Et(t),Fp=t=>new TextDecoder().decode(t),Pp=t=>i0(t).map(r=>ae.fromUint8Array(new Uint8Array(r)))});gt();gt();var Zs=(t,e)=>{let r;return(...n)=>{let i=()=>t(...n);r&&clearTimeout(r),r=setTimeout(i,e!==void 0&&e>0?e:300)}},Kr=t=>t==null,or=t=>!Kr(t),Il=class extends Error{},Ws=(t,e)=>{if(Kr(t))throw new Il(e)};var Ol=" daum[ /]| deusu/| yadirectfetcher|(?:^|[^g])news|(?<! (?:channel/|google/))google(?!(app|/google| pixel))|(?<! cu)bot(?:[^\\w]|_|$)|(?<!(?: ya| yandex|^job|inapp;) ?)search|(?<!(?:lib))http|(?<![hg]m)score|(?<!android|ios)@|\\(\\)|\\.com|^12345|^<|^[\\w \\.\\-\\(?:\\):]+(?:/v?\\d+(?:\\.\\d+)?(?:\\.\\d{1,10})*?)?(?:,|$)|^[^ ]{50,}$|^\\w+/[\\w\\(\\)]*$|^active|^ad muncher|^amaya|^avsdevicesdk/|^biglotron|^bot|^bw/|^clamav[ /]|^client/|^cobweb/|^custom|^ddg[_-]android|^discourse|^dispatch/\\d|^downcast/|^duckduckgo|^facebook|^getright/|^gozilla/|^hobbit|^hotzonu|^hwcdn/|^jeode/|^jetty/|^jigsaw|^microsoft bits|^movabletype|^mozilla/\\d\\.\\d \\(compatible;?\\)$|^mozilla/\\d\\.\\d \\w*$|^navermailapp|^netsurf|^offline explorer|^postman|^python|^rank|^read|^reed|^rest|^serf|^snapchat|^space bison|^svn|^swcd |^taringa|^thumbor/|^track|^valid|^w3c|^webbandit/|^webcopier|^wget|^whatsapp|^wordpress|^xenu link sleuth|^yahoo|^yandex|^zdm/\\d|^zoom marketplace/|^{{.*}}$|analyzer|archive|ask jeeves/teoma|bit\\.ly/|bluecoat drtr|browsex|burpcollaborator|capture|catch|check|chrome-lighthouse|chromeframe|classifier|cloud|crawl|cypress/|dareboost|datanyze|dejaclick|detect|dmbrowser|download|evc-batch/|feed|firephp|gomezagent|headless|httrack|hubspot marketing grader|hydra|ibisbrowser|images|insight|inspect|iplabel|ips-agent|java(?!;)|library|mail\\.ru/|manager|measure|neustar wpm|node|nutch|offbyone|optimize|pageburst|parser|perl|phantomjs|pingdom|powermarks|preview|proxy|ptst[ /]\\d|reputation|resolver|retriever|rexx;|rigor|robot|rss|scan|scrape|server|sogou|sparkler/|speedcurve|spider|splash|statuscake|supercleaner|synapse|synthetic|tools|torrent|trace|transcoder|url|virtuoso|wappalyzer|watch|webglance|webkit2png|whatcms/|zgrab",Ul=/bot|spider|crawl|http|lighthouse/i,wn;function Fl(){if(wn instanceof RegExp)return wn;try{wn=new RegExp(Ol,"i")}catch{wn=Ul}return wn}function ac(t){return!!t&&Fl().test(t)}var cc=({IDL:t})=>{let e=t.Record({controllers:t.Vec(t.Principal)}),r=t.Variant({Write:t.Null,Admin:t.Null}),n=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:r,expires_at:t.Opt(t.Nat64)}),i=t.Record({version:t.Opt(t.Nat64)}),s=t.Record({cycles:t.Nat,destination_id:t.Principal}),o=t.Record({to:t.Opt(t.Nat64),from:t.Opt(t.Nat64),satellite_id:t.Opt(t.Principal)}),c=t.Record({key:t.Text,collected_at:t.Nat64}),a=t.Record({inner_height:t.Nat16,inner_width:t.Nat16}),d=t.Record({title:t.Text,updated_at:t.Nat64,referrer:t.Opt(t.Text),time_zone:t.Text,session_id:t.Text,href:t.Text,created_at:t.Nat64,satellite_id:t.Principal,device:a,version:t.Opt(t.Nat64),user_agent:t.Opt(t.Text)}),l=t.Record({safari:t.Float64,opera:t.Float64,others:t.Float64,firefox:t.Float64,chrome:t.Float64}),f=t.Record({desktop:t.Float64,others:t.Float64,mobile:t.Float64}),T=t.Record({browsers:l,devices:f}),_=t.Record({day:t.Nat8,month:t.Nat8,year:t.Int32}),b=t.Record({bounce_rate:t.Float64,average_page_views_per_session:t.Float64,daily_total_page_views:t.Vec(t.Tuple(_,t.Nat32)),total_page_views:t.Nat32,unique_page_views:t.Nat64,unique_sessions:t.Nat64}),E=t.Record({referrers:t.Vec(t.Tuple(t.Text,t.Nat32)),pages:t.Vec(t.Tuple(t.Text,t.Nat32))}),U=t.Record({updated_at:t.Nat64,session_id:t.Text,metadata:t.Opt(t.Vec(t.Tuple(t.Text,t.Text))),name:t.Text,created_at:t.Nat64,satellite_id:t.Principal,version:t.Opt(t.Nat64)}),I=t.Record({total:t.Vec(t.Tuple(t.Text,t.Nat32))}),$=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),enabled:t.Bool}),M=t.Record({stable:t.Nat64,heap:t.Nat64}),K=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:r,expires_at:t.Opt(t.Nat64)}),F=t.Record({controller:K,controllers:t.Vec(t.Principal)}),k=t.Record({title:t.Text,updated_at:t.Opt(t.Nat64),referrer:t.Opt(t.Text),time_zone:t.Text,session_id:t.Text,href:t.Text,satellite_id:t.Principal,device:a,version:t.Opt(t.Nat64),user_agent:t.Opt(t.Text)}),z=t.Variant({Ok:d,Err:t.Text}),Y=t.Variant({Ok:t.Null,Err:t.Vec(t.Tuple(c,t.Text))}),G=t.Record({version:t.Opt(t.Nat64),enabled:t.Bool}),ee=t.Record({updated_at:t.Opt(t.Nat64),session_id:t.Text,metadata:t.Opt(t.Vec(t.Tuple(t.Text,t.Text))),name:t.Text,satellite_id:t.Principal,version:t.Opt(t.Nat64),user_agent:t.Opt(t.Text)}),L=t.Variant({Ok:U,Err:t.Text});return t.Service({del_controllers:t.Func([e],[t.Vec(t.Tuple(t.Principal,n))],[]),del_satellite_config:t.Func([t.Principal,i],[],[]),deposit_cycles:t.Func([s],[],[]),get_page_views:t.Func([o],[t.Vec(t.Tuple(c,d))],["query"]),get_page_views_analytics_clients:t.Func([o],[T],["query"]),get_page_views_analytics_metrics:t.Func([o],[b],["query"]),get_page_views_analytics_top_10:t.Func([o],[E],["query"]),get_track_events:t.Func([o],[t.Vec(t.Tuple(c,U))],["query"]),get_track_events_analytics:t.Func([o],[I],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,n))],["query"]),list_satellite_configs:t.Func([],[t.Vec(t.Tuple(t.Principal,$))],["query"]),memory_size:t.Func([],[M],["query"]),set_controllers:t.Func([F],[t.Vec(t.Tuple(t.Principal,n))],[]),set_page_view:t.Func([c,k],[z],[]),set_page_views:t.Func([t.Vec(t.Tuple(c,k))],[Y],[]),set_satellite_configs:t.Func([t.Vec(t.Tuple(t.Principal,G))],[t.Vec(t.Tuple(t.Principal,$))],[]),set_track_event:t.Func([c,ee],[L],[]),set_track_events:t.Func([t.Vec(t.Tuple(c,ee))],[Y],[]),version:t.Func([],[t.Text],["query"])})};var F0=Hr(Nc());var yi;(function(t){t[t.SysFatal=1]="SysFatal",t[t.SysTransient=2]="SysTransient",t[t.DestinationInvalid=3]="DestinationInvalid",t[t.CanisterReject=4]="CanisterReject",t[t.CanisterError=5]="CanisterError"})(yi||(yi={}));gt();Qr();gt();On();pt();var by=new TextEncoder().encode(`
14
+ ic-request`);var nn=class{getPrincipal(){return ae.anonymous()}async transformRequest(e){return Object.assign(Object.assign({},e),{body:{content:e.body}})}};Fn();On();pt();vn();var wf=Hr(Ji());var Pn=()=>{if(typeof window<"u"&&window.crypto&&window.crypto.getRandomValues){let t=new Uint32Array(1);return window.crypto.getRandomValues(t),t[0]}if(typeof crypto<"u"&&crypto.getRandomValues){let t=new Uint32Array(1);return crypto.getRandomValues(t),t[0]}return typeof crypto<"u"&&crypto.randomInt?crypto.randomInt(0,4294967295):Math.floor(Math.random()*4294967295)};var es;(function(t){t.Call="call"})(es||(es={}));function sn(){let t=new ArrayBuffer(16),e=new DataView(t),r=Pn(),n=Pn(),i=Pn(),s=Pn();return e.setUint32(0,r),e.setUint32(4,n),e.setUint32(8,i),e.setUint32(12,s),t}var jh=BigInt(1e6),Yh=60*1e3,Ur=class{constructor(e){let s=BigInt(Math.floor(Date.now()+e-Yh))*jh/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=s}toCBOR(){return wf.value.u64(this._value.toString(16),16)}toHash(){return Oe(this._value)}};function Jo(t=sn){return async e=>{let r=e.request.headers;e.request.headers=r,e.endpoint==="call"&&(e.body.nonce=t())}}function Mn(t){let e=[];return t.forEach((r,n)=>{e.push([n,r])}),e}Qr();var kn=class extends Ke{constructor(e,r){super(e),this.response=r,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};Wn();Zn();zs();var gs=BigInt(4294967295),Ba=BigInt(32);function s0(t,e=!1){return e?{h:Number(t&gs),l:Number(t>>Ba&gs)}:{h:Number(t>>Ba&gs)|0,l:Number(t&gs)|0}}function Mp(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){let{h:s,l:o}=s0(t[i],e);[r[i],n[i]]=[s,o]}return[r,n]}var kp=(t,e)=>BigInt(t>>>0)<<Ba|BigInt(e>>>0),Cp=(t,e,r)=>t>>>r,qp=(t,e,r)=>t<<32-r|e>>>r,$p=(t,e,r)=>t>>>r|e<<32-r,Vp=(t,e,r)=>t<<32-r|e>>>r,Gp=(t,e,r)=>t<<64-r|e>>>r-32,Hp=(t,e,r)=>t>>>r-32|e<<64-r,jp=(t,e)=>e,Yp=(t,e)=>t,zp=(t,e,r)=>t<<r|e>>>32-r,Kp=(t,e,r)=>e<<r|t>>>32-r,Zp=(t,e,r)=>e<<r-32|t>>>64-r,Wp=(t,e,r)=>t<<r-32|e>>>64-r;function Xp(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}var Jp=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),Qp=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,Lp=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),Dp=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,e1=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0),t1=(t,e,r,n,i,s)=>e+r+n+i+s+(t/2**32|0)|0;var r1={fromBig:s0,split:Mp,toBig:kp,shrSH:Cp,shrSL:qp,rotrSH:$p,rotrSL:Vp,rotrBH:Gp,rotrBL:Hp,rotr32H:jp,rotr32L:Yp,rotlSH:zp,rotlSL:Kp,rotlBH:Zp,rotlBL:Wp,add:Xp,add3L:Jp,add3H:Qp,add4L:Lp,add4H:Dp,add5H:t1,add5L:e1},de=r1;Yr();var[n1,i1]=de.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),_r=new Uint32Array(80),Er=new Uint32Array(80),va=class extends zr{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:r,Bh:n,Bl:i,Ch:s,Cl:o,Dh:c,Dl:a,Eh:d,El:l,Fh:f,Fl:T,Gh:_,Gl:b,Hh:E,Hl:U}=this;return[e,r,n,i,s,o,c,a,d,l,f,T,_,b,E,U]}set(e,r,n,i,s,o,c,a,d,l,f,T,_,b,E,U){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=c|0,this.Dl=a|0,this.Eh=d|0,this.El=l|0,this.Fh=f|0,this.Fl=T|0,this.Gh=_|0,this.Gl=b|0,this.Hh=E|0,this.Hl=U|0}process(e,r){for(let M=0;M<16;M++,r+=4)_r[M]=e.getUint32(r),Er[M]=e.getUint32(r+=4);for(let M=16;M<80;M++){let K=_r[M-15]|0,F=Er[M-15]|0,k=de.rotrSH(K,F,1)^de.rotrSH(K,F,8)^de.shrSH(K,F,7),z=de.rotrSL(K,F,1)^de.rotrSL(K,F,8)^de.shrSL(K,F,7),Y=_r[M-2]|0,G=Er[M-2]|0,ee=de.rotrSH(Y,G,19)^de.rotrBH(Y,G,61)^de.shrSH(Y,G,6),L=de.rotrSL(Y,G,19)^de.rotrBL(Y,G,61)^de.shrSL(Y,G,6),ce=de.add4L(z,L,Er[M-7],Er[M-16]),le=de.add4H(ce,k,ee,_r[M-7],_r[M-16]);_r[M]=le|0,Er[M]=ce|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:c,Cl:a,Dh:d,Dl:l,Eh:f,El:T,Fh:_,Fl:b,Gh:E,Gl:U,Hh:I,Hl:$}=this;for(let M=0;M<80;M++){let K=de.rotrSH(f,T,14)^de.rotrSH(f,T,18)^de.rotrBH(f,T,41),F=de.rotrSL(f,T,14)^de.rotrSL(f,T,18)^de.rotrBL(f,T,41),k=f&_^~f&E,z=T&b^~T&U,Y=de.add5L($,F,z,i1[M],Er[M]),G=de.add5H(Y,I,K,k,n1[M],_r[M]),ee=Y|0,L=de.rotrSH(n,i,28)^de.rotrBH(n,i,34)^de.rotrBH(n,i,39),ce=de.rotrSL(n,i,28)^de.rotrBL(n,i,34)^de.rotrBL(n,i,39),le=n&s^n&c^s&c,_e=i&o^i&a^o&a;I=E|0,$=U|0,E=_|0,U=b|0,_=f|0,b=T|0,{h:f,l:T}=de.add(d|0,l|0,G|0,ee|0),d=c|0,l=a|0,c=s|0,a=o|0,s=n|0,o=i|0;let ye=de.add3L(ee,ce,_e);n=de.add3H(ye,G,L,le),i=ye|0}({h:n,l:i}=de.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=de.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:c,l:a}=de.add(this.Ch|0,this.Cl|0,c|0,a|0),{h:d,l}=de.add(this.Dh|0,this.Dl|0,d|0,l|0),{h:f,l:T}=de.add(this.Eh|0,this.El|0,f|0,T|0),{h:_,l:b}=de.add(this.Fh|0,this.Fl|0,_|0,b|0),{h:E,l:U}=de.add(this.Gh|0,this.Gl|0,E|0,U|0),{h:I,l:$}=de.add(this.Hh|0,this.Hl|0,I|0,$|0),this.set(n,i,s,o,c,a,d,l,f,T,_,b,E,U,I,$)}roundClean(){_r.fill(0),Er.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var Aa=yn(()=>new va);Yr();yr();jt();jt();ca();var Pt=BigInt(0),yt=BigInt(1),ws=BigInt(2),s1=BigInt(8),o1={zip215:!0};function a1(t){let e=os(t);return Ut(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function bs(t){let e=a1(t),{Fp:r,n,prehash:i,hash:s,randomBytes:o,nByteLength:c,h:a}=e,d=ws<<BigInt(c*8)-yt,l=r.create,f=e.uvRatio||((j,C)=>{try{return{isValid:!0,value:r.sqrt(j*r.inv(C))}}catch{return{isValid:!1,value:Pt}}}),T=e.adjustScalarBytes||(j=>j),_=e.domain||((j,C,X)=>{if(C.length||X)throw new Error("Contexts/pre-hash are not supported");return j}),b=j=>typeof j=="bigint"&&Pt<j,E=(j,C)=>b(j)&&b(C)&&j<C,U=j=>j===Pt||E(j,d);function I(j,C){if(E(j,C))return j;throw new Error(`Expected valid scalar < ${C}, got ${typeof j} ${j}`)}function $(j){return j===Pt?j:I(j,n)}let M=new Map;function K(j){if(!(j instanceof F))throw new Error("ExtendedPoint expected")}class F{constructor(C,X,D,ne){if(this.ex=C,this.ey=X,this.ez=D,this.et=ne,!U(C))throw new Error("x required");if(!U(X))throw new Error("y required");if(!U(D))throw new Error("z required");if(!U(ne))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(C){if(C instanceof F)throw new Error("extended point not allowed");let{x:X,y:D}=C||{};if(!U(X)||!U(D))throw new Error("invalid affine point");return new F(X,D,yt,l(X*D))}static normalizeZ(C){let X=r.invertBatch(C.map(D=>D.ez));return C.map((D,ne)=>D.toAffine(X[ne])).map(F.fromAffine)}_setWindowSize(C){this._WINDOW_SIZE=C,M.delete(this)}assertValidity(){let{a:C,d:X}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:D,ey:ne,ez:O,et:m}=this,fe=l(D*D),ie=l(ne*ne),se=l(O*O),Q=l(se*se),u=l(fe*C),h=l(se*l(u+ie)),p=l(Q+l(X*l(fe*ie)));if(h!==p)throw new Error("bad point: equation left != right (1)");let A=l(D*ne),x=l(O*m);if(A!==x)throw new Error("bad point: equation left != right (2)")}equals(C){K(C);let{ex:X,ey:D,ez:ne}=this,{ex:O,ey:m,ez:fe}=C,ie=l(X*fe),se=l(O*ne),Q=l(D*fe),u=l(m*ne);return ie===se&&Q===u}is0(){return this.equals(F.ZERO)}negate(){return new F(l(-this.ex),this.ey,this.ez,l(-this.et))}double(){let{a:C}=e,{ex:X,ey:D,ez:ne}=this,O=l(X*X),m=l(D*D),fe=l(ws*l(ne*ne)),ie=l(C*O),se=X+D,Q=l(l(se*se)-O-m),u=ie+m,h=u-fe,p=ie-m,A=l(Q*h),x=l(u*p),v=l(Q*p),N=l(h*u);return new F(A,x,N,v)}add(C){K(C);let{a:X,d:D}=e,{ex:ne,ey:O,ez:m,et:fe}=this,{ex:ie,ey:se,ez:Q,et:u}=C;if(X===BigInt(-1)){let te=l((O-ne)*(se+ie)),me=l((O+ne)*(se-ie)),Be=l(me-te);if(Be===Pt)return this.double();let Se=l(m*ws*u),he=l(fe*ws*Q),re=he+Se,Me=me+te,Jt=he-Se,Br=l(re*Be),vr=l(Me*Jt),ct=l(re*Jt),Ee=l(Be*Me);return new F(Br,vr,Ee,ct)}let h=l(ne*ie),p=l(O*se),A=l(fe*D*u),x=l(m*Q),v=l((ne+O)*(ie+se)-h-p),N=x-A,g=x+A,B=l(p-X*h),R=l(v*N),S=l(g*B),V=l(v*B),W=l(N*g);return new F(R,S,W,V)}subtract(C){return this.add(C.negate())}wNAF(C){return Y.wNAFCached(this,M,C,F.normalizeZ)}multiply(C){let{p:X,f:D}=this.wNAF(I(C,n));return F.normalizeZ([X,D])[0]}multiplyUnsafe(C){let X=$(C);return X===Pt?z:this.equals(z)||X===yt?this:this.equals(k)?this.wNAF(X).p:Y.unsafeLadder(this,X)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return Y.unsafeLadder(this,n).is0()}toAffine(C){let{ex:X,ey:D,ez:ne}=this,O=this.is0();C==null&&(C=O?s1:r.inv(ne));let m=l(X*C),fe=l(D*C),ie=l(ne*C);if(O)return{x:Pt,y:yt};if(ie!==yt)throw new Error("invZ was invalid");return{x:m,y:fe}}clearCofactor(){let{h:C}=e;return C===yt?this:this.multiplyUnsafe(C)}static fromHex(C,X=!1){let{d:D,a:ne}=e,O=r.BYTES;C=Ye("pointHex",C,O);let m=C.slice(),fe=C[O-1];m[O-1]=fe&-129;let ie=hr(m);ie===Pt||(X?I(ie,d):I(ie,r.ORDER));let se=l(ie*ie),Q=l(se-yt),u=l(D*se-ne),{isValid:h,value:p}=f(Q,u);if(!h)throw new Error("Point.fromHex: invalid y coordinate");let A=(p&yt)===yt,x=(fe&128)!==0;if(!X&&p===Pt&&x)throw new Error("Point.fromHex: x=0 and x_0=1");return x!==A&&(p=l(-p)),F.fromAffine({x:p,y:ie})}static fromPrivateKey(C){return L(C).point}toRawBytes(){let{x:C,y:X}=this.toAffine(),D=Fr(X,r.BYTES);return D[D.length-1]|=C&yt?128:0,D}toHex(){return Ot(this.toRawBytes())}}F.BASE=new F(e.Gx,e.Gy,yt,l(e.Gx*e.Gy)),F.ZERO=new F(Pt,yt,yt,Pt);let{BASE:k,ZERO:z}=F,Y=ss(F,c*8);function G(j){return Ie(j,n)}function ee(j){return G(hr(j))}function L(j){let C=c;j=Ye("private key",j,C);let X=Ye("hashed private key",s(j),2*C),D=T(X.slice(0,C)),ne=X.slice(C,2*C),O=ee(D),m=k.multiply(O),fe=m.toRawBytes();return{head:D,prefix:ne,scalar:O,point:m,pointBytes:fe}}function ce(j){return L(j).pointBytes}function le(j=new Uint8Array,...C){let X=Re(...C);return ee(s(_(X,Ye("context",j),!!i)))}function _e(j,C,X={}){j=Ye("message",j),i&&(j=i(j));let{prefix:D,scalar:ne,pointBytes:O}=L(C),m=le(X.context,D,j),fe=k.multiply(m).toRawBytes(),ie=le(X.context,fe,O,j),se=G(m+ie*ne);$(se);let Q=Re(fe,Fr(se,r.BYTES));return Ye("result",Q,c*2)}let ye=o1;function Z(j,C,X,D=ye){let{context:ne,zip215:O}=D,m=r.BYTES;j=Ye("signature",j,2*m),C=Ye("message",C),i&&(C=i(C));let fe=hr(j.slice(m,2*m)),ie,se,Q;try{ie=F.fromHex(X,O),se=F.fromHex(j.slice(0,m),O),Q=k.multiplyUnsafe(fe)}catch{return!1}if(!O&&ie.isSmallOrder())return!1;let u=le(ne,se.toRawBytes(),ie.toRawBytes(),C);return se.add(ie.multiplyUnsafe(u)).subtract(Q).clearCofactor().equals(F.ZERO)}return k._setWindowSize(8),{CURVE:e,getPublicKey:ce,sign:_e,verify:Z,ExtendedPoint:F,utils:{getExtendedPublicKey:L,randomPrivateKey:()=>o(r.BYTES),precompute(j=8,C=F.BASE){return C._setWindowSize(j),C.multiply(BigInt(3)),C}}}}yr();var Sa=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),o0=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Og=BigInt(0),c1=BigInt(1),Ta=BigInt(2),u1=BigInt(5),a0=BigInt(10),f1=BigInt(20),l1=BigInt(40),c0=BigInt(80);function d1(t){let e=Sa,n=t*t%e*t%e,i=Ft(n,Ta,e)*n%e,s=Ft(i,c1,e)*t%e,o=Ft(s,u1,e)*s%e,c=Ft(o,a0,e)*o%e,a=Ft(c,f1,e)*c%e,d=Ft(a,l1,e)*a%e,l=Ft(d,c0,e)*d%e,f=Ft(l,c0,e)*d%e,T=Ft(f,a0,e)*o%e;return{pow_p_5_8:Ft(T,Ta,e)*t%e,b2:n}}function h1(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function p1(t,e){let r=Sa,n=Ie(e*e*e,r),i=Ie(n*n*e,r),s=d1(t*i).pow_p_5_8,o=Ie(t*n*s,r),c=Ie(e*o*o,r),a=o,d=Ie(o*o0,r),l=c===t,f=c===Ie(-t,r),T=c===Ie(-t*o0,r);return l&&(o=a),(f||T)&&(o=d),Tf(o,r)&&(o=Ie(-o,r)),{isValid:l||f,value:o}}var nr=Gn(Sa,void 0,!0),Na={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:nr,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Aa,randomBytes:ui,adjustScalarBytes:h1,uvRatio:p1},u0=bs(Na);function f0(t,e,r){if(e.length>255)throw new Error("Context is too big");return ec(js("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}var Ug=bs({...Na,domain:f0}),Fg=bs({...Na,domain:f0,prehash:Aa});var m1=(nr.ORDER+BigInt(3))/BigInt(8),Pg=nr.pow(Ta,m1),Mg=nr.sqrt(nr.neg(nr.ONE)),kg=(nr.ORDER-BigInt(5))/BigInt(8),Cg=BigInt(486662);var qg=Sf(nr,nr.neg(BigInt(486664)));var $g=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),Vg=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),Gg=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Hg=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var jg=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var l0=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},at=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},nt,Xn,d0,h0,xs=class{constructor(e={}){nt.set(this,void 0),Xn.set(this,void 0),this[d0]=this.entries.bind(this),this[h0]="ExpirableMap";let{source:r=[],expirationTime:n=10*60*1e3}=e,i=Date.now();l0(this,nt,new Map([...r].map(([s,o])=>[s,{value:o,timestamp:i}])),"f"),l0(this,Xn,n,"f")}prune(){let e=Date.now();for(let[r,n]of at(this,nt,"f").entries())e-n.timestamp>at(this,Xn,"f")&&at(this,nt,"f").delete(r);return this}set(e,r){this.prune();let n={value:r,timestamp:Date.now()};return at(this,nt,"f").set(e,n),this}get(e){let r=at(this,nt,"f").get(e);if(r!==void 0){if(Date.now()-r.timestamp>at(this,Xn,"f")){at(this,nt,"f").delete(e);return}return r.value}}clear(){at(this,nt,"f").clear()}entries(){let e=at(this,nt,"f").entries();return function*(){for(let[n,i]of e)yield[n,i.value]}()}values(){let e=at(this,nt,"f").values();return function*(){for(let n of e)yield n.value}()}keys(){return at(this,nt,"f").keys()}forEach(e,r){for(let[n,i]of at(this,nt,"f").entries())e.call(r,i.value,n,this)}has(e){return at(this,nt,"f").has(e)}delete(e){return at(this,nt,"f").delete(e)}get size(){return at(this,nt,"f").size}};nt=new WeakMap,Xn=new WeakMap,d0=Symbol.iterator,h0=Symbol.toStringTag;pt();var p0=t=>{if(t<=127)return 1;if(t<=255)return 2;if(t<=65535)return 3;if(t<=16777215)return 4;throw new Error("Length too long (> 4 bytes)")},m0=(t,e,r)=>{if(r<=127)return t[e]=r,1;if(r<=255)return t[e]=129,t[e+1]=r,2;if(r<=65535)return t[e]=130,t[e+1]=r>>8,t[e+2]=r,3;if(r<=16777215)return t[e]=131,t[e+1]=r>>16,t[e+2]=r>>8,t[e+3]=r,4;throw new Error("Length too long (> 4 bytes)")},Ra=(t,e)=>{if(t[e]<128)return 1;if(t[e]===128)throw new Error("Invalid length 0");if(t[e]===129)return 2;if(t[e]===130)return 3;if(t[e]===131)return 4;throw new Error("Length too long (> 4 bytes)")},y1=(t,e)=>{let r=Ra(t,e);if(r===1)return t[e];if(r===2)return t[e+1];if(r===3)return(t[e+1]<<8)+t[e+2];if(r===4)return(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];throw new Error("Length too long (> 4 bytes)")},Zg=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]),Ia=Uint8Array.from([48,5,6,3,43,101,112]),Wg=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function y0(t,e){let r=2+p0(t.byteLength+1),n=e.byteLength+r+t.byteLength,i=0,s=new Uint8Array(1+p0(n)+n);return s[i++]=48,i+=m0(s,i,n),s.set(e,i),i+=e.byteLength,s[i++]=3,i+=m0(s,i,t.byteLength+1),s[i++]=0,s.set(new Uint8Array(t),i),s}var g0=(t,e)=>{let r=0,n=(c,a)=>{if(i[r++]!==c)throw new Error("Expected: "+a)},i=new Uint8Array(t);if(n(48,"sequence"),r+=Ra(i,r),!Du(i.slice(r,r+e.byteLength),e))throw new Error("Not the expected OID.");r+=e.byteLength,n(3,"bit string");let s=y1(i,r)-1;r+=Ra(i,r),n(0,"0 padding");let o=i.slice(r);if(s!==o.length)throw new Error(`DER payload mismatch: Expected length ${s} actual length ${o.length}`);return o};var w0=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},b0=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},_s,Es,Jn=class t{constructor(e){if(_s.set(this,void 0),Es.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");w0(this,_s,e,"f"),w0(this,Es,t.derEncode(e),"f")}static from(e){return this.fromDer(e.toDer())}static fromRaw(e){return new t(e)}static fromDer(e){return new t(this.derDecode(e))}static derEncode(e){return y0(e,Ia).buffer}static derDecode(e){let r=g0(e,Ia);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return b0(this,_s,"f")}get derKey(){return b0(this,Es,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};_s=new WeakMap,Es=new WeakMap;Jn.RAW_KEY_LENGTH=32;hs();var x0=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Oa,_0,Ua,E0,Fa=class extends Function{constructor(){return super(),Oa.add(this),this.observers=[],new Proxy(this,{apply:(e,r,n)=>x0(e,Oa,"m",_0).call(e,n[0],...n.slice(1))})}subscribe(e){this.observers.push(e)}unsubscribe(e){this.observers=this.observers.filter(r=>r!==e)}notify(e,...r){this.observers.forEach(n=>n(e,...r))}};Oa=new WeakSet,_0=function(e,...r){this.notify(e,...r)};var Bs=class extends Fa{constructor(){return super(),Ua.add(this),new Proxy(this,{apply:(e,r,n)=>x0(e,Ua,"m",E0).call(e,n[0],...n.slice(1))})}log(e,...r){this.notify({message:e,level:"info"},...r)}warn(e,...r){this.notify({message:e,level:"warn"},...r)}error(e,r,...n){this.notify({message:e,level:"error",error:r},...n)}};Ua=new WeakSet,E0=function(e,...r){this.log(e,...r)};var zt=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},it=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Kt,vs,As,Ts,Ss,Ns,Rs,Is,fn;var Qn=class t{constructor(e=t.default){Kt.set(this,void 0),vs.set(this,void 0),As.set(this,void 0),Ts.set(this,void 0),Ss.set(this,void 0),Ns.set(this,void 0),Rs.set(this,void 0),Is.set(this,void 0),fn.set(this,0);let{initialInterval:r=500,randomizationFactor:n=.5,multiplier:i=1.5,maxInterval:s=6e4,maxElapsedTime:o=9e5,maxIterations:c=10,date:a=Date}=e;zt(this,Kt,r,"f"),zt(this,vs,n,"f"),zt(this,As,i,"f"),zt(this,Ts,s,"f"),zt(this,Is,a,"f"),zt(this,Ss,a.now(),"f"),zt(this,Ns,o,"f"),zt(this,Rs,c,"f")}get ellapsedTimeInMsec(){return it(this,Is,"f").now()-it(this,Ss,"f")}get currentInterval(){return it(this,Kt,"f")}get count(){return it(this,fn,"f")}get randomValueFromInterval(){let e=it(this,vs,"f")*it(this,Kt,"f"),r=it(this,Kt,"f")-e,n=it(this,Kt,"f")+e;return Math.random()*(n-r)+r}incrementCurrentInterval(){var e;return zt(this,Kt,Math.min(it(this,Kt,"f")*it(this,As,"f"),it(this,Ts,"f")),"f"),zt(this,fn,(e=it(this,fn,"f"),e++,e),"f"),it(this,Kt,"f")}next(){return this.ellapsedTimeInMsec>=it(this,Ns,"f")||it(this,fn,"f")>=it(this,Rs,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};Kt=new WeakMap,vs=new WeakMap,As=new WeakMap,Ts=new WeakMap,Ss=new WeakMap,Ns=new WeakMap,Rs=new WeakMap,Is=new WeakMap,fn=new WeakMap;Qn.default={initialInterval:500,randomizationFactor:.5,multiplier:1.5,maxInterval:6e4,maxElapsedTime:9e5,maxIterations:10,date:Date};var Os=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},pe=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Zt,Mt,Cr,Fs,ln,dn,qr,$r,B0,Ps,Ms,Wt;(function(t){t.Received="received",t.Processing="processing",t.Replied="replied",t.Rejected="rejected",t.Unknown="unknown",t.Done="done"})(Wt||(Wt={}));var Us=5*60*1e3,g1="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae";var w1="ic0.app",b1=".ic0.app",x1="icp0.io",_1=".icp0.io",E1="icp-api.io",B1=".icp-api.io",Ln=class extends Ke{constructor(e){super(e),this.message=e}},hn=class extends Ke{constructor(e){super(e),this.message=e}};function v1(){let t;if(typeof window<"u")if(window.fetch)t=window.fetch.bind(window);else throw new Ln("Fetch implementation was not available. You appear to be in a browser context, but window.fetch was not present.");else if(typeof globalThis<"u")if(globalThis.fetch)t=globalThis.fetch.bind(globalThis);else throw new Ln("Fetch implementation was not available. You appear to be in a Node.js context, but global.fetch was not available.");else typeof self<"u"&&self.fetch&&(t=self.fetch.bind(self));if(t)return t;throw new Ln("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}var Dn=class t{constructor(e={}){var r;if(Zt.add(this),this.rootKey=Rr(g1),this._timeDiffMsecs=0,this._rootKeyFetched=!1,Mt.set(this,void 0),Cr.set(this,void 0),this._isAgent=!0,Fs.set(this,0),this.log=new Bs,ln.set(this,[]),dn.set(this,[]),qr.set(this,new xs({expirationTime:5*60*1e3})),$r.set(this,!0),Ms.set(this,(i,s)=>{if(pe(this,$r,"f")===!1)return i;if(!s)throw new mt("Invalid signature from replica signed query: no matching node key found.");let{status:o,signatures:c=[],requestId:a}=i,d=new TextEncoder().encode("\vic-response");for(let l of c){let{timestamp:f,identity:T}=l,_=ae.fromUint8Array(T).toText(),b;if(o==="replied"){let{reply:M}=i;b=In({status:o,reply:M,timestamp:BigInt(f),request_id:a})}else if(o==="rejected"){let{reject_code:M,reject_message:K,error_code:F}=i;b=In({status:o,reject_code:M,reject_message:K,error_code:F,timestamp:BigInt(f),request_id:a})}else throw new Error(`Unknown status: ${o}`);let E=ot(d,new Uint8Array(b)),U=s?.nodeKeys.get(_);if(!U)throw new mt("Invalid signature from replica signed query: no matching node key found.");let I=Jn.fromDer(U).rawKey;if(u0.verify(l.signature,new Uint8Array(E),new Uint8Array(I)))return i;throw new mt(`Invalid signature from replica ${_} signed query.`)}return i}),e.source){if(!(e.source instanceof t))throw new Error("An Agent's source can only be another HttpAgent");this._identity=e.source._identity,this._fetch=e.source._fetch,this._host=e.source._host,this._credentials=e.source._credentials}else this._fetch=e.fetch||v1()||fetch.bind(globalThis),this._fetchOptions=e.fetchOptions,this._callOptions=e.callOptions;if(e.host!==void 0)!e.host.match(/^[a-z]+:/)&&typeof window<"u"?this._host=new URL(window.location.protocol+"//"+e.host):this._host=new URL(e.host);else if(e.source!==void 0)this._host=e.source._host;else{let i=typeof window<"u"?window.location:void 0;i||(this._host=new URL("https://icp-api.io"),this.log.warn("Could not infer host from window.location, defaulting to mainnet gateway of https://icp-api.io. Please provide a host to the HttpAgent constructor to avoid this warning."));let s=["ic0.app","icp0.io","127.0.0.1","localhost"],o=[".github.dev",".gitpod.io"],c=i?.hostname,a;c&&typeof c=="string"&&(o.some(d=>c.endsWith(d))?a=c:a=s.find(d=>c.endsWith(d))),i&&a?this._host=new URL(`${i.protocol}//${a}${i.port?":"+i.port:""}`):(this._host=new URL("https://icp-api.io"),this.log.warn("Could not infer host from window.location, defaulting to mainnet gateway of https://icp-api.io. Please provide a host to the HttpAgent constructor to avoid this warning."))}e.verifyQuerySignatures!==void 0&&Os(this,$r,e.verifyQuerySignatures,"f"),Os(this,Mt,(r=e.retryTimes)!==null&&r!==void 0?r:3,"f");let n=()=>new Qn({maxIterations:pe(this,Mt,"f")});if(Os(this,Cr,e.backoffStrategy||n,"f"),this._host.hostname.endsWith(b1)?this._host.hostname=w1:this._host.hostname.endsWith(_1)?this._host.hostname=x1:this._host.hostname.endsWith(B1)&&(this._host.hostname=E1),e.credentials){let{name:i,password:s}=e.credentials;this._credentials=`${i}${s?":"+s:""}`}this._identity=Promise.resolve(e.identity||new nn),this.addTransform("update",Jo(sn)),e.useQueryNonces&&this.addTransform("query",Jo(sn)),e.logToConsole&&this.log.subscribe(i=>{i.level==="error"?console.error(i.message):i.level==="warn"?console.warn(i.message):console.log(i.message)})}get waterMark(){return pe(this,Fs,"f")}isLocal(){let e=this._host.hostname;return e==="127.0.0.1"||e.endsWith("127.0.0.1")}addTransform(e,r,n=r.priority||0){if(e==="update"){let i=pe(this,dn,"f").findIndex(s=>(s.priority||0)<n);pe(this,dn,"f").splice(i>=0?i:pe(this,dn,"f").length,0,Object.assign(r,{priority:n}))}else if(e==="query"){let i=pe(this,ln,"f").findIndex(s=>(s.priority||0)<n);pe(this,ln,"f").splice(i>=0?i:pe(this,ln,"f").length,0,Object.assign(r,{priority:n}))}}async getPrincipal(){if(!this._identity)throw new hn("This identity has expired due this application's security policy. Please refresh your authentication.");return(await this._identity).getPrincipal()}async call(e,r,n){let i=await(n!==void 0?await n:await this._identity);if(!i)throw new hn("This identity has expired due this application's security policy. Please refresh your authentication.");let s=ae.from(e),o=r.effectiveCanisterId?ae.from(r.effectiveCanisterId):s,c=i.getPrincipal()||ae.anonymous(),a=new Ur(Us);Math.abs(this._timeDiffMsecs)>1e3*30&&(a=new Ur(Us+this._timeDiffMsecs));let d={request_type:es.Call,canister_id:s,method_name:r.methodName,arg:r.arg,sender:c,ingress_expiry:a},l=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{})},endpoint:"call",body:d});l=await i.transformRequest(l);let f=Li(l.body);this.log(`fetching "/api/v2/canister/${o.toText()}/call" with request:`,l);let T=pe(this,Cr,"f").call(this),_=pe(this,Zt,"m",Ps).call(this,{request:()=>this._fetch(""+new URL(`/api/v2/canister/${o.toText()}/call`,this._host),Object.assign(Object.assign(Object.assign({},this._callOptions),l.request),{body:f})),backoff:T,tries:0}),[b,E]=await Promise.all([_,zi(d)]),U=await b.arrayBuffer(),I=b.status===200&&U.byteLength>0?Et(U):null;return{requestId:E,response:{ok:b.ok,status:b.status,statusText:b.statusText,body:I,headers:Mn(b.headers)}}}async query(e,r,n){let i=pe(this,Cr,"f").call(this),s=r.effectiveCanisterId?ae.from(r.effectiveCanisterId):ae.from(e);this.log(`ecid ${s.toString()}`),this.log(`canisterId ${e.toString()}`);let o=async()=>{let l=await(n!==void 0?await n:await this._identity);if(!l)throw new hn("This identity has expired due this application's security policy. Please refresh your authentication.");let f=ae.from(e),T=l?.getPrincipal()||ae.anonymous(),_={request_type:"query",canister_id:f,method_name:r.methodName,arg:r.arg,sender:T,ingress_expiry:new Ur(Us)},b=await zi(_),E=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{})},endpoint:"read",body:_});E=await l?.transformRequest(E);let U=Li(E.body),I={canister:f.toText(),ecid:s,transformedRequest:E,body:U,requestId:b,backoff:i,tries:0};return await pe(this,Zt,"m",B0).call(this,I)},c=async()=>{if(!pe(this,$r,"f"))return;let l=pe(this,qr,"f").get(s.toString());return l||(await this.fetchSubnetKeys(s.toString()),pe(this,qr,"f").get(s.toString()))},[a,d]=await Promise.all([o(),c()]);if(this.log("Query response:",a),!pe(this,$r,"f"))return a;try{return pe(this,Ms,"f").call(this,a,d)}catch{this.log.warn("Query response verification failed. Retrying with fresh subnet keys."),pe(this,qr,"f").delete(e.toString()),await this.fetchSubnetKeys(s.toString());let f=pe(this,qr,"f").get(e.toString());if(!f)throw new mt("Invalid signature from replica signed query: no matching node key found.");return pe(this,Ms,"f").call(this,a,f)}}async createReadStateRequest(e,r){let n=await(r!==void 0?await r:await this._identity);if(!n)throw new hn("This identity has expired due this application's security policy. Please refresh your authentication.");let i=n?.getPrincipal()||ae.anonymous(),s=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{})},endpoint:"read_state",body:{request_type:"read_state",paths:e.paths,sender:i,ingress_expiry:new Ur(Us)}});return n?.transformRequest(s)}async readState(e,r,n,i){let s=typeof e=="string"?ae.fromText(e):e,o=i??await this.createReadStateRequest(r,n),c=Li(o.body);this.log(`fetching "/api/v2/canister/${s}/read_state" with request:`,o);let a=pe(this,Cr,"f").call(this),d=await pe(this,Zt,"m",Ps).call(this,{request:()=>this._fetch(""+new URL(`/api/v2/canister/${s.toString()}/read_state`,this._host),Object.assign(Object.assign(Object.assign({},this._fetchOptions),o.request),{body:c})),backoff:a,tries:0});if(!d.ok)throw new Error(`Server returned an error:
15
+ Code: ${d.status} (${d.statusText})
16
+ Body: ${await d.text()}
17
+ `);let l=Et(await d.arrayBuffer());this.log("Read state response:",l);let f=await this.parseTimeFromResponse(l);return f>0&&(this.log("Read state response time:",f),Os(this,Fs,f,"f")),l}async parseTimeFromResponse(e){let r;if(e.certificate){let n=Et(e.certificate);if(n&&"tree"in n)r=n.tree;else throw new Error("Could not decode time from response");let i=xr(["time"],r);if(!i)throw new Error("Time was not found in the response or was not in its expected format.");if(!(i instanceof ArrayBuffer)&&!ArrayBuffer.isView(i))throw new Error("Time was not found in the response or was not in its expected format.");let s=cn(Vo(i));return this.log("Time from response:",s),this.log("Time from response in milliseconds:",Number(s)),Number(s)}else this.log.warn("No certificate found in response");return 0}async syncTime(e){let r=await Promise.resolve().then(()=>(Wn(),ys)),n=Date.now();try{e||this.log("Syncing time with the IC. No canisterId provided, so falling back to ryjl3-tyaaa-aaaaa-aaaba-cai");let s=(await r.request({canisterId:e??ae.from("ryjl3-tyaaa-aaaaa-aaaba-cai"),agent:this,paths:["time"]})).get("time");s&&(this._timeDiffMsecs=Number(s)-Number(n))}catch(i){this.log.error("Caught exception while attempting to sync time",i)}}async status(){let e=this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{};this.log('fetching "/api/v2/status"');let r=pe(this,Cr,"f").call(this),n=await pe(this,Zt,"m",Ps).call(this,{backoff:r,request:()=>this._fetch(""+new URL("/api/v2/status",this._host),Object.assign({headers:e},this._fetchOptions)),tries:0});return Et(await n.arrayBuffer())}async fetchRootKey(){return this._rootKeyFetched||(this.rootKey=(await this.status()).root_key,this._rootKeyFetched=!0),this.rootKey}invalidateIdentity(){this._identity=null}replaceIdentity(e){this._identity=Promise.resolve(e)}async fetchSubnetKeys(e){let r=ae.from(e),i=(await ms({canisterId:r,paths:["subnet"],agent:this})).get("subnet");if(i&&typeof i=="object"&&"nodeKeys"in i)return pe(this,qr,"f").set(r.toText(),i),i}_transform(e){let r=Promise.resolve(e);if(e.endpoint==="call")for(let n of pe(this,dn,"f"))r=r.then(i=>n(i).then(s=>s||i));else for(let n of pe(this,ln,"f"))r=r.then(i=>n(i).then(s=>s||i));return r}};Mt=new WeakMap,Cr=new WeakMap,Fs=new WeakMap,ln=new WeakMap,dn=new WeakMap,qr=new WeakMap,$r=new WeakMap,Ms=new WeakMap,Zt=new WeakSet,B0=async function t(e){var r,n;let{ecid:i,transformedRequest:s,body:o,requestId:c,backoff:a,tries:d}=e,l=d===0?0:a.next();if(this.log(`fetching "/api/v2/canister/${i.toString()}/query" with tries:`,{tries:d,backoff:a,delay:l}),l===null)throw new Ke(`Timestamp failed to pass the watermark after retrying the configured ${pe(this,Mt,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);l>0&&await new Promise(b=>setTimeout(b,l));let f;try{this.log(`fetching "/api/v2/canister/${i.toString()}/query" with request:`,s);let b=await this._fetch(""+new URL(`/api/v2/canister/${i.toString()}/query`,this._host),Object.assign(Object.assign(Object.assign({},this._fetchOptions),s.request),{body:o}));if(b.status===200){let E=Et(await b.arrayBuffer());f=Object.assign(Object.assign({},E),{httpDetails:{ok:b.ok,status:b.status,statusText:b.statusText,headers:Mn(b.headers)},requestId:c})}else throw new kn(`Server returned an error:
18
+ Code: ${b.status} (${b.statusText})
19
+ Body: ${await b.text()}
20
+ `,{ok:b.ok,status:b.status,statusText:b.statusText,headers:Mn(b.headers)})}catch(b){if(d<pe(this,Mt,"f"))return this.log.warn(`Caught exception while attempting to make query:
21
+ ${b}
22
+ Retrying query.`),await pe(this,Zt,"m",t).call(this,Object.assign(Object.assign({},e),{tries:d+1}));throw b}let T=(n=(r=f.signatures)===null||r===void 0?void 0:r[0])===null||n===void 0?void 0:n.timestamp;if(!pe(this,$r,"f"))return f;if(!T)throw new Error("Timestamp not found in query response. This suggests a malformed or malicious response.");let _=Number(BigInt(T)/BigInt(1e6));if(this.log("watermark and timestamp",{waterMark:this.waterMark,timestamp:_}),Number(this.waterMark)>_){let b=new Ke("Timestamp is below the watermark. Retrying query.");if(this.log.error("Timestamp is below",b,{timestamp:T,waterMark:this.waterMark}),d<pe(this,Mt,"f"))return await pe(this,Zt,"m",t).call(this,Object.assign(Object.assign({},e),{tries:d+1}));throw new Ke(`Timestamp failed to pass the watermark after retrying the configured ${pe(this,Mt,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`)}return f},Ps=async function t(e){let{request:r,backoff:n,tries:i}=e,s=i===0?0:n.next();if(s===null)throw new Ke(`Timestamp failed to pass the watermark after retrying the configured ${pe(this,Mt,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);s>0&&await new Promise(d=>setTimeout(d,s));let o;try{o=await r()}catch(d){if(pe(this,Mt,"f")>i)return this.log.warn(`Caught exception while attempting to make request:
23
+ ${d}
24
+ Retrying request.`),await pe(this,Zt,"m",t).call(this,{request:r,backoff:n,tries:i+1});throw d}if(o.ok)return o;let c=await o.clone().text(),a=`Server returned an error:
25
+ Code: ${o.status} (${o.statusText})
26
+ Body: ${c}
27
+ `;if(i<pe(this,Mt,"f"))return await pe(this,Zt,"m",t).call(this,{request:r,backoff:n,tries:i+1});throw new kn(a,{ok:o.ok,status:o.status,statusText:o.statusText,headers:Mn(o.headers)})};gt();var v0;(function(t){t.Error="err",t.GetPrincipal="gp",t.GetPrincipalResponse="gpr",t.Query="q",t.QueryResponse="qr",t.Call="c",t.CallResponse="cr",t.ReadState="rs",t.ReadStateResponse="rsr",t.Status="s",t.StatusResponse="sr"})(v0||(v0={}));function Pa(){let t=typeof window>"u"?typeof globalThis>"u"?typeof self>"u"?void 0:self.ic.agent:globalThis.ic.agent:window.ic.agent;if(!t)throw new Error("No Agent could be found.");return t}Qr();vn();Zn();pt();var ks={};mn(ks,{backoff:()=>R0,chain:()=>I0,conditionalDelay:()=>S0,defaultStrategy:()=>A0,maxAttempts:()=>T1,once:()=>T0,throttle:()=>S1,timeout:()=>N0});pt();var A1=5*60*1e3;function A0(){return I0(S0(T0(),1e3),R0(1e3,1.2),N0(A1))}function T0(){let t=!0;return async()=>t?(t=!1,!0):!1}function S0(t,e){return async(r,n,i)=>{if(await t(r,n,i))return new Promise(s=>setTimeout(s,e))}}function T1(t){let e=t;return async(r,n,i)=>{if(--e<=0)throw new Error(`Failed to retrieve a reply for request after ${t} attempts:
28
+ Request ID: ${je(n)}
30
29
  Request status: ${i}
31
- `)}}function V1(t){return()=>new Promise(e=>setTimeout(e,t))}function U0(t){let e=Date.now()+t;return async(r,n,i)=>{if(Date.now()>e)throw new Error(`Request timed out after ${t} msec:
32
- Request ID: ${Qe(n)}
30
+ `)}}function S1(t){return()=>new Promise(e=>setTimeout(e,t))}function N0(t){let e=Date.now()+t;return async(r,n,i)=>{if(Date.now()>e)throw new Error(`Request timed out after ${t} msec:
31
+ Request ID: ${je(n)}
33
32
  Request status: ${i}
34
- `)}}function F0(t,e){let r=t;return()=>new Promise(n=>setTimeout(()=>{r*=e,n()},r))}function P0(...t){return async(e,r,n)=>{for(let i of t)await i(e,r,n)}}async function Aa(t,e,r,n,i,s){var o;let a=[new TextEncoder().encode("request_status"),r],c=i??await((o=t.createReadStateRequest)===null||o===void 0?void 0:o.call(t,{paths:[a]})),f=await t.readState(e,{paths:[a]},void 0,c);if(t.rootKey==null)throw new Error("Agent root key not initialized before polling");let l=await sn.create({certificate:f.certificate,rootKey:t.rootKey,canisterId:e,blsVerify:s}),d=l.lookup([...a,new TextEncoder().encode("status")]),v;switch(typeof d>"u"?v=jt.Unknown:v=new TextDecoder().decode(d),v){case jt.Replied:return l.lookup([...a,"reply"]);case jt.Received:case jt.Unknown:case jt.Processing:return await n(e,r,v),Aa(t,e,r,n,c);case jt.Rejected:{let w=new Uint8Array(l.lookup([...a,"reject_code"]))[0],_=new TextDecoder().decode(l.lookup([...a,"reject_message"]));throw new Error(`Call was rejected:
35
- Request ID: ${Qe(r)}
36
- Reject code: ${w}
37
- Reject text: ${_}
38
- `)}case jt.Done:throw new Error(`Call was marked as done but we never saw the reply:
39
- Request ID: ${Qe(r)}
40
- `)}throw new Error("unreachable")}yt();ht();var k0=({IDL:t})=>{let e=t.Variant({mainnet:t.Null,testnet:t.Null}),r=t.Text,n=t.Record({network:e,address:r,min_confirmations:t.Opt(t.Nat32)}),i=t.Nat64,s=i,o=t.Record({network:e,address:r,min_confirmations:t.Opt(t.Nat32)}),a=i,c=t.Record({network:e}),f=t.Nat64,l=t.Vec(f),d=t.Record({network:e,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:r}),v=t.Vec(t.Nat8),w=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),_=t.Record({height:t.Nat32,value:i,outpoint:w}),E=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:t.Nat32,tip_block_hash:v,utxos:t.Vec(_)}),U=t.Record({network:e,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:r}),O=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:t.Nat32,tip_block_hash:v,utxos:t.Vec(_)}),V=t.Record({transaction:t.Vec(t.Nat8),network:e}),k=t.Principal,K=t.Record({canister_id:k,num_requested_changes:t.Opt(t.Nat64)}),F=t.Variant({from_user:t.Record({user_id:t.Principal}),from_canister:t.Record({canister_version:t.Opt(t.Nat64),canister_id:t.Principal})}),M=t.Variant({creation:t.Record({controllers:t.Vec(t.Principal)}),code_deployment:t.Record({mode:t.Variant({reinstall:t.Null,upgrade:t.Null,install:t.Null}),module_hash:t.Vec(t.Nat8)}),controllers_change:t.Record({controllers:t.Vec(t.Principal)}),code_uninstall:t.Null}),z=t.Record({timestamp_nanos:t.Nat64,canister_version:t.Nat64,origin:F,details:M}),Y=t.Record({controllers:t.Vec(t.Principal),module_hash:t.Opt(t.Vec(t.Nat8)),recent_changes:t.Vec(z),total_num_changes:t.Nat64}),G=t.Record({canister_id:k}),ee=t.Variant({controllers:t.Null,public:t.Null}),L=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,log_visibility:ee,memory_allocation:t.Nat,compute_allocation:t.Nat}),ce=t.Record({status:t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),memory_size:t.Nat,cycles:t.Nat,settings:L,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8)),reserved_cycles:t.Nat}),le=t.Record({canister_id:k}),xe=t.Record({freezing_threshold:t.Opt(t.Nat),controllers:t.Opt(t.Vec(t.Principal)),reserved_cycles_limit:t.Opt(t.Nat),log_visibility:t.Opt(ee),memory_allocation:t.Opt(t.Nat),compute_allocation:t.Opt(t.Nat)}),me=t.Record({settings:t.Opt(xe),sender_canister_version:t.Opt(t.Nat64)}),Z=t.Record({canister_id:k}),ue=t.Record({canister_id:k}),j=t.Record({canister_id:k}),C=t.Variant({secp256k1:t.Null}),X=t.Record({key_id:t.Record({name:t.Text,curve:C}),canister_id:t.Opt(k),derivation_path:t.Vec(t.Vec(t.Nat8))}),D=t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)}),ne=t.Record({canister_id:k}),I=t.Record({idx:t.Nat64,timestamp_nanos:t.Nat64,content:t.Vec(t.Nat8)}),m=t.Record({canister_log_records:t.Vec(I)}),fe=t.Record({value:t.Text,name:t.Text}),ie=t.Record({status:t.Nat,body:t.Vec(t.Nat8),headers:t.Vec(fe)}),se=t.Record({url:t.Text,method:t.Variant({get:t.Null,head:t.Null,post:t.Null}),max_response_bytes:t.Opt(t.Nat64),body:t.Opt(t.Vec(t.Nat8)),transform:t.Opt(t.Record({function:t.Func([t.Record({context:t.Vec(t.Nat8),response:ie})],[ie],["query"]),context:t.Vec(t.Nat8)})),headers:t.Vec(fe)}),Q=t.Vec(t.Nat8),u=t.Record({arg:t.Vec(t.Nat8),wasm_module_hash:t.Vec(t.Nat8),mode:t.Variant({reinstall:t.Null,upgrade:t.Opt(t.Record({skip_pre_upgrade:t.Opt(t.Bool)})),install:t.Null}),chunk_hashes_list:t.Vec(Q),target_canister:k,sender_canister_version:t.Opt(t.Nat64),storage_canister:t.Opt(k)}),h=t.Vec(t.Nat8),p=t.Record({arg:t.Vec(t.Nat8),wasm_module:h,mode:t.Variant({reinstall:t.Null,upgrade:t.Opt(t.Record({skip_pre_upgrade:t.Opt(t.Bool)})),install:t.Null}),canister_id:k,sender_canister_version:t.Opt(t.Nat64)}),T=t.Record({start_at_timestamp_nanos:t.Nat64,subnet_id:t.Principal}),x=t.Record({num_block_failures_total:t.Nat64,node_id:t.Principal,num_blocks_total:t.Nat64}),A=t.Vec(t.Record({timestamp_nanos:t.Nat64,node_metrics:t.Vec(x)})),N=t.Record({settings:t.Opt(xe),specified_id:t.Opt(k),amount:t.Opt(t.Nat),sender_canister_version:t.Opt(t.Nat64)}),g=t.Record({canister_id:k}),B=t.Record({canister_id:k,amount:t.Nat}),R=t.Vec(t.Nat8),S=t.Record({key_id:t.Record({name:t.Text,curve:C}),derivation_path:t.Vec(t.Vec(t.Nat8)),message_hash:t.Vec(t.Nat8)}),$=t.Record({signature:t.Vec(t.Nat8)}),W=t.Record({canister_id:k}),te=t.Record({canister_id:k}),pe=t.Record({canister_id:k}),Ee=t.Vec(Q),Te=t.Record({canister_id:k,sender_canister_version:t.Opt(t.Nat64)}),he=t.Record({canister_id:t.Principal,settings:xe,sender_canister_version:t.Opt(t.Nat64)}),re=t.Record({chunk:t.Vec(t.Nat8),canister_id:t.Principal}),Pe=Q;return t.Service({bitcoin_get_balance:t.Func([n],[s],[]),bitcoin_get_balance_query:t.Func([o],[a],["query"]),bitcoin_get_current_fee_percentiles:t.Func([c],[l],[]),bitcoin_get_utxos:t.Func([d],[E],[]),bitcoin_get_utxos_query:t.Func([U],[O],["query"]),bitcoin_send_transaction:t.Func([V],[],[]),canister_info:t.Func([K],[Y],[]),canister_status:t.Func([G],[ce],[]),clear_chunk_store:t.Func([le],[],[]),create_canister:t.Func([me],[Z],[]),delete_canister:t.Func([ue],[],[]),deposit_cycles:t.Func([j],[],[]),ecdsa_public_key:t.Func([X],[D],[]),fetch_canister_logs:t.Func([ne],[m],["query"]),http_request:t.Func([se],[ie],[]),install_chunked_code:t.Func([u],[],[]),install_code:t.Func([p],[],[]),node_metrics_history:t.Func([T],[A],[]),provisional_create_canister_with_cycles:t.Func([N],[g],[]),provisional_top_up_canister:t.Func([B],[],[]),raw_rand:t.Func([],[R],[]),sign_with_ecdsa:t.Func([S],[$],[]),start_canister:t.Func([W],[],[]),stop_canister:t.Func([te],[],[]),stored_chunks:t.Func([pe],[Ee],[]),uninstall_code:t.Func([Te],[],[]),update_settings:t.Func([he],[],[]),upload_chunk:t.Func([re],[Pe],[])})};var Ts=class extends tt{constructor(e,r,n,i){super(["Call failed:",` Canister: ${e.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(i).map(s=>` "${s}": ${JSON.stringify(i[s])}`)].join(`
41
- `)),this.canisterId=e,this.methodName=r,this.type=n,this.props=i}},Ta=class extends Ts{constructor(e,r,n){var i;super(e,r,"query",{Status:n.status,Code:(i=hi[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}},Sa=class extends Ts{constructor(e,r,n,i){super(e,r,"update",Object.assign({"Request ID":Qe(n)},i.body?Object.assign(Object.assign({},i.body.error_code?{"Error code":i.body.error_code}:{}),{"Reject code":String(i.body.reject_code),"Reject message":i.body.reject_message}):{"HTTP status code":i.status.toString(),"HTTP status text":i.statusText})),this.requestId=n,this.response=i}},Et=Symbol.for("ic-agent-metadata"),Mr=class t{constructor(e){this[Et]=Object.freeze(e)}static agentOf(e){return e[Et].config.agent}static interfaceOf(e){return e[Et].service}static canisterIdOf(e){return ae.from(e[Et].config.canisterId)}static async install(e,r){let n=e.mode===void 0?{install:null}:e.mode,i=e.arg?[...new Uint8Array(e.arg)]:[],s=[...new Uint8Array(e.module)],o=typeof r.canisterId=="string"?ae.fromText(r.canisterId):r.canisterId;await M0(r).install_code({mode:n,arg:i,wasm_module:s,canister_id:o,sender_canister_version:[]})}static async createCanister(e,r){function n(s){return[{controllers:s.controllers?[s.controllers]:[],compute_allocation:s.compute_allocation?[s.compute_allocation]:[],freezing_threshold:s.freezing_threshold?[s.freezing_threshold]:[],memory_allocation:s.memory_allocation?[s.memory_allocation]:[],reserved_cycles_limit:[],log_visibility:[]}]}let{canister_id:i}=await M0(e||{}).provisional_create_canister_with_cycles({amount:[],settings:n(r||{}),specified_id:[],sender_canister_version:[]});return i}static async createAndInstallCanister(e,r,n){let i=await this.createCanister(n);return await this.install(Object.assign({},r),Object.assign(Object.assign({},n),{canisterId:i})),this.createActor(e,Object.assign(Object.assign({},n),{canisterId:i}))}static createActorClass(e,r){let n=e({IDL:cr});class i extends t{constructor(o){if(!o.canisterId)throw new tt(`Canister ID is required, but received ${typeof o.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);let a=typeof o.canisterId=="string"?ae.fromText(o.canisterId):o.canisterId;super({config:Object.assign(Object.assign(Object.assign({},q0),o),{canisterId:a}),service:n});for(let[c,f]of n._fields)r?.httpDetails&&f.annotations.push(Na),this[c]=G1(this,c,f,o.blsVerify)}}return i}static createActor(e,r){if(!r.canisterId)throw new tt(`Canister ID is required, but received ${typeof r.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);return new(this.createActorClass(e))(r)}static createActorWithHttpDetails(e,r){return new(this.createActorClass(e,{httpDetails:!0}))(r)}};function As(t,e){let r=cr.decode(t,C0.Buffer.from(e));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var q0={pollingStrategyFactory:vs.defaultStrategy},Na="http-details";function G1(t,e,r,n){let i;r.annotations.includes("query")||r.annotations.includes("composite_query")?i=async(o,...a)=>{var c,f;o=Object.assign(Object.assign({},o),(f=(c=t[Et].config).queryTransform)===null||f===void 0?void 0:f.call(c,e,a,Object.assign(Object.assign({},t[Et].config),o)));let l=o.agent||t[Et].config.agent||va(),d=ae.from(o.canisterId||t[Et].config.canisterId),v=cr.encode(r.argTypes,a),w=await l.query(d,{methodName:e,arg:v,effectiveCanisterId:o.effectiveCanisterId});switch(w.status){case"rejected":throw new Ta(d,e,w);case"replied":return r.annotations.includes(Na)?{httpDetails:w.httpDetails,result:As(r.retTypes,w.reply.arg)}:As(r.retTypes,w.reply.arg)}}:i=async(o,...a)=>{var c,f;o=Object.assign(Object.assign({},o),(f=(c=t[Et].config).callTransform)===null||f===void 0?void 0:f.call(c,e,a,Object.assign(Object.assign({},t[Et].config),o)));let l=o.agent||t[Et].config.agent||va(),{canisterId:d,effectiveCanisterId:v,pollingStrategyFactory:w}=Object.assign(Object.assign(Object.assign({},q0),t[Et].config),o),_=ae.from(d),E=v!==void 0?ae.from(v):_,U=cr.encode(r.argTypes,a),{requestId:O,response:V}=await l.call(_,{methodName:e,arg:U,effectiveCanisterId:E});if(!V.ok||V.body)throw new Sa(_,e,O,V);let k=w(),K=await Aa(l,E,O,k,n),F=r.annotations.includes(Na);if(K!==void 0)return F?{httpDetails:V,result:As(r.retTypes,K)}:As(r.retTypes,K);if(r.retTypes.length===0)return F?{httpDetails:V,result:void 0}:void 0;throw new Error(`Call was returned undefined, but type [${r.retTypes.join(",")}].`)};let s=(...o)=>i({},...o);return s.withOptions=o=>(...a)=>i(o,...a),s}function M0(t){function e(r,n){if(t.effectiveCanisterId)return{effectiveCanisterId:ae.from(t.effectiveCanisterId)};let i=n[0],s=ae.fromHex("");return i&&typeof i=="object"&&i.canister_id&&(s=ae.from(i.canister_id)),{effectiveCanisterId:s}}return Mr.createActor(k0,Object.assign(Object.assign(Object.assign({},t),{canisterId:ae.fromHex("")}),{callTransform:e,queryTransform:e}))}jn();yt();Yn();Sn();aa();ht();Yn();Rn();var V0=async({orbiterId:t,idlFactory:e,container:r})=>{let n=rr(r)&&r!==!1,i=n?r===!0?"http://127.0.0.1:5987":r:"https://icp-api.io",s=new Xn({identity:new Dr,host:i});return n&&await s.fetchRootKey(),Mr.createActor(e,{agent:s,canisterId:t})};var Ra=async t=>V0({idlFactory:lc,...t});function Jn(t){return new Promise((e,r)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>r(t.error)})}function Ss(t,e){let r=indexedDB.open(t);r.onupgradeneeded=()=>r.result.createObjectStore(e);let n=Jn(r);return(i,s)=>n.then(o=>s(o.transaction(e,i).objectStore(e)))}var Ia;function $0(){return Ia||(Ia=Ss("keyval-store","keyval")),Ia}function Oa(t,e=$0()){return e("readwrite",r=>(t.forEach(n=>r.delete(n)),Jn(r.transaction)))}function H1(t,e){return t.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},Jn(t.transaction)}function Ua(t=$0()){return t("readonly",e=>{if(e.getAll&&e.getAllKeys)return Promise.all([Jn(e.getAllKeys()),Jn(e.getAll())]).then(([n,i])=>n.map((s,o)=>[s,i[o]]));let r=[];return t("readonly",n=>H1(n,i=>r.push([i.key,i.value])).then(()=>r))})}var G0=Ss("juno-views","views"),H0=Ss("juno-events","events");var j0=()=>Ua(G0),Y0=t=>Oa(t,G0);var z0=()=>Ua(H0),K0=t=>Oa(t,H0);onmessage=async({data:t})=>{let{msg:e,data:r}=t;switch(e){case"junoInitEnvironment":await z1(r);return;case"junoTrackPageView":J1();return;case"junoTrackEvent":Q1();return;case"junoStartTrackTimer":await Z1();return;case"junoStopTracker":await K1();return}};var j1="Analytics worker not initialized. Did you set `satelliteId`?",Y1="Analytics worker not initialized. Did you set `orbiterId`?",Yt,z1=async t=>{let{orbiterId:e,satelliteId:r}=t;Ms(e,Y1),Ms(r,j1),Yt=t},Qn,ka=async()=>await Promise.all([Z0(),W0()]),K1=async()=>{await ka(),rr(Qn)&&(clearInterval(Qn),Qn=void 0),self.close()},Z1=async()=>{rr(Qn)||(await ka(),Qn=setInterval(ka,Yt?.worker?.timerInterval??1e3))},Fa=!1,Pa=!1,Z0=async()=>{if(!Ns(Yt)||Fa)return;let t=await j0();if(!(Hr(t)||t.length===0)){Fa=!0;try{let r=await(await Ra(Yt)).set_page_views(t.map(([n,{collected_at:i,...s}])=>[X0({key:n,collected_at:i}),{...s,...J0(Yt)}]));await Y0(t.map(([n,i])=>n)),L0(r)}catch(e){console.error(e)}Fa=!1}},W1=ks(async()=>await Z0(),100),W0=async()=>{if(!Ns(Yt)||Pa)return;let t=await z0();if(!(Hr(t)||t.length===0)){Pa=!0;try{let e=await Ra(Yt),r=({metadata:i,...s})=>({metadata:Hr(i)?[]:[Object.entries(i??{})],...s,...J0(Yt)}),n=await e.set_track_events(t.map(([i,{collected_at:s,...o}])=>[X0({key:i,collected_at:s}),r(o)]));await K0(t.map(([i,s])=>i)),L0(n)}catch(e){console.error(e)}Pa=!1}},X1=ks(async()=>await W0(),250),J1=()=>{Ns(Yt)&&(Q0()||W1())},Q1=()=>{Ns(Yt)&&(Q0()||X1())},X0=({key:t,collected_at:e})=>({collected_at:e,key:t}),J0=t=>({satellite_id:ae.fromText(t.satelliteId)}),Q0=()=>{let{userAgent:t}=navigator;return rr(t)?fc(t):!1},Ns=t=>t!=null&&rr(t.orbiterId)&&rr(t.satelliteId),L0=t=>{"Ok"in t||t.Err.forEach(([e,r])=>console.warn(`${r} [Key: ${e.key}]`))};})();
33
+ `)}}function R0(t,e){let r=t;return()=>new Promise(n=>setTimeout(()=>{r*=e,n()},r))}function I0(...t){return async(e,r,n)=>{for(let i of t)await i(e,r,n)}}async function Ma(t,e,r,n,i,s){var o;let c=[new TextEncoder().encode("request_status"),r],a=i??await((o=t.createReadStateRequest)===null||o===void 0?void 0:o.call(t,{paths:[c]})),d=await t.readState(e,{paths:[c]},void 0,a);if(t.rootKey==null)throw new Error("Agent root key not initialized before polling");let l=await un.create({certificate:d.certificate,rootKey:t.rootKey,canisterId:e,blsVerify:s}),f=l.lookup([...c,new TextEncoder().encode("status")]),T;switch(typeof f>"u"?T=Wt.Unknown:T=new TextDecoder().decode(f),T){case Wt.Replied:return l.lookup([...c,"reply"]);case Wt.Received:case Wt.Unknown:case Wt.Processing:return await n(e,r,T),Ma(t,e,r,n,a);case Wt.Rejected:{let _=new Uint8Array(l.lookup([...c,"reject_code"]))[0],b=new TextDecoder().decode(l.lookup([...c,"reject_message"]));throw new Error(`Call was rejected:
34
+ Request ID: ${je(r)}
35
+ Reject code: ${_}
36
+ Reject text: ${b}
37
+ `)}case Wt.Done:throw new Error(`Call was marked as done but we never saw the reply:
38
+ Request ID: ${je(r)}
39
+ `)}throw new Error("unreachable")}gt();pt();var O0=({IDL:t})=>{let e=t.Variant({mainnet:t.Null,testnet:t.Null}),r=t.Text,n=t.Record({network:e,address:r,min_confirmations:t.Opt(t.Nat32)}),i=t.Nat64,s=i,o=t.Record({network:e,address:r,min_confirmations:t.Opt(t.Nat32)}),c=i,a=t.Record({network:e}),d=t.Nat64,l=t.Vec(d),f=t.Record({network:e,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:r}),T=t.Vec(t.Nat8),_=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),b=t.Record({height:t.Nat32,value:i,outpoint:_}),E=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:t.Nat32,tip_block_hash:T,utxos:t.Vec(b)}),U=t.Record({network:e,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:r}),I=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:t.Nat32,tip_block_hash:T,utxos:t.Vec(b)}),$=t.Record({transaction:t.Vec(t.Nat8),network:e}),M=t.Principal,K=t.Record({canister_id:M,num_requested_changes:t.Opt(t.Nat64)}),F=t.Variant({from_user:t.Record({user_id:t.Principal}),from_canister:t.Record({canister_version:t.Opt(t.Nat64),canister_id:t.Principal})}),k=t.Variant({creation:t.Record({controllers:t.Vec(t.Principal)}),code_deployment:t.Record({mode:t.Variant({reinstall:t.Null,upgrade:t.Null,install:t.Null}),module_hash:t.Vec(t.Nat8)}),controllers_change:t.Record({controllers:t.Vec(t.Principal)}),code_uninstall:t.Null}),z=t.Record({timestamp_nanos:t.Nat64,canister_version:t.Nat64,origin:F,details:k}),Y=t.Record({controllers:t.Vec(t.Principal),module_hash:t.Opt(t.Vec(t.Nat8)),recent_changes:t.Vec(z),total_num_changes:t.Nat64}),G=t.Record({canister_id:M}),ee=t.Variant({controllers:t.Null,public:t.Null}),L=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,log_visibility:ee,memory_allocation:t.Nat,compute_allocation:t.Nat}),ce=t.Record({status:t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),memory_size:t.Nat,cycles:t.Nat,settings:L,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8)),reserved_cycles:t.Nat}),le=t.Record({canister_id:M}),_e=t.Record({freezing_threshold:t.Opt(t.Nat),controllers:t.Opt(t.Vec(t.Principal)),reserved_cycles_limit:t.Opt(t.Nat),log_visibility:t.Opt(ee),memory_allocation:t.Opt(t.Nat),compute_allocation:t.Opt(t.Nat)}),ye=t.Record({settings:t.Opt(_e),sender_canister_version:t.Opt(t.Nat64)}),Z=t.Record({canister_id:M}),ue=t.Record({canister_id:M}),j=t.Record({canister_id:M}),C=t.Variant({secp256k1:t.Null}),X=t.Record({key_id:t.Record({name:t.Text,curve:C}),canister_id:t.Opt(M),derivation_path:t.Vec(t.Vec(t.Nat8))}),D=t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)}),ne=t.Record({canister_id:M}),O=t.Record({idx:t.Nat64,timestamp_nanos:t.Nat64,content:t.Vec(t.Nat8)}),m=t.Record({canister_log_records:t.Vec(O)}),fe=t.Record({value:t.Text,name:t.Text}),ie=t.Record({status:t.Nat,body:t.Vec(t.Nat8),headers:t.Vec(fe)}),se=t.Record({url:t.Text,method:t.Variant({get:t.Null,head:t.Null,post:t.Null}),max_response_bytes:t.Opt(t.Nat64),body:t.Opt(t.Vec(t.Nat8)),transform:t.Opt(t.Record({function:t.Func([t.Record({context:t.Vec(t.Nat8),response:ie})],[ie],["query"]),context:t.Vec(t.Nat8)})),headers:t.Vec(fe)}),Q=t.Vec(t.Nat8),u=t.Record({arg:t.Vec(t.Nat8),wasm_module_hash:t.Vec(t.Nat8),mode:t.Variant({reinstall:t.Null,upgrade:t.Opt(t.Record({skip_pre_upgrade:t.Opt(t.Bool)})),install:t.Null}),chunk_hashes_list:t.Vec(Q),target_canister:M,sender_canister_version:t.Opt(t.Nat64),storage_canister:t.Opt(M)}),h=t.Vec(t.Nat8),p=t.Record({arg:t.Vec(t.Nat8),wasm_module:h,mode:t.Variant({reinstall:t.Null,upgrade:t.Opt(t.Record({skip_pre_upgrade:t.Opt(t.Bool)})),install:t.Null}),canister_id:M,sender_canister_version:t.Opt(t.Nat64)}),A=t.Record({start_at_timestamp_nanos:t.Nat64,subnet_id:t.Principal}),x=t.Record({num_block_failures_total:t.Nat64,node_id:t.Principal,num_blocks_total:t.Nat64}),v=t.Vec(t.Record({timestamp_nanos:t.Nat64,node_metrics:t.Vec(x)})),N=t.Record({settings:t.Opt(_e),specified_id:t.Opt(M),amount:t.Opt(t.Nat),sender_canister_version:t.Opt(t.Nat64)}),g=t.Record({canister_id:M}),B=t.Record({canister_id:M,amount:t.Nat}),R=t.Vec(t.Nat8),S=t.Record({key_id:t.Record({name:t.Text,curve:C}),derivation_path:t.Vec(t.Vec(t.Nat8)),message_hash:t.Vec(t.Nat8)}),V=t.Record({signature:t.Vec(t.Nat8)}),W=t.Record({canister_id:M}),te=t.Record({canister_id:M}),me=t.Record({canister_id:M}),Be=t.Vec(Q),Se=t.Record({canister_id:M,sender_canister_version:t.Opt(t.Nat64)}),he=t.Record({canister_id:t.Principal,settings:_e,sender_canister_version:t.Opt(t.Nat64)}),re=t.Record({chunk:t.Vec(t.Nat8),canister_id:t.Principal}),Me=Q;return t.Service({bitcoin_get_balance:t.Func([n],[s],[]),bitcoin_get_balance_query:t.Func([o],[c],["query"]),bitcoin_get_current_fee_percentiles:t.Func([a],[l],[]),bitcoin_get_utxos:t.Func([f],[E],[]),bitcoin_get_utxos_query:t.Func([U],[I],["query"]),bitcoin_send_transaction:t.Func([$],[],[]),canister_info:t.Func([K],[Y],[]),canister_status:t.Func([G],[ce],[]),clear_chunk_store:t.Func([le],[],[]),create_canister:t.Func([ye],[Z],[]),delete_canister:t.Func([ue],[],[]),deposit_cycles:t.Func([j],[],[]),ecdsa_public_key:t.Func([X],[D],[]),fetch_canister_logs:t.Func([ne],[m],["query"]),http_request:t.Func([se],[ie],[]),install_chunked_code:t.Func([u],[],[]),install_code:t.Func([p],[],[]),node_metrics_history:t.Func([A],[v],[]),provisional_create_canister_with_cycles:t.Func([N],[g],[]),provisional_top_up_canister:t.Func([B],[],[]),raw_rand:t.Func([],[R],[]),sign_with_ecdsa:t.Func([S],[V],[]),start_canister:t.Func([W],[],[]),stop_canister:t.Func([te],[],[]),stored_chunks:t.Func([me],[Be],[]),uninstall_code:t.Func([Se],[],[]),update_settings:t.Func([he],[],[]),upload_chunk:t.Func([re],[Me],[])})};var qs=class extends Ke{constructor(e,r,n,i){super(["Call failed:",` Canister: ${e.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(i).map(s=>` "${s}": ${JSON.stringify(i[s])}`)].join(`
40
+ `)),this.canisterId=e,this.methodName=r,this.type=n,this.props=i}},ka=class extends qs{constructor(e,r,n){var i;super(e,r,"query",{Status:n.status,Code:(i=yi[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}},Ca=class extends qs{constructor(e,r,n,i){super(e,r,"update",Object.assign({"Request ID":je(n)},i.body?Object.assign(Object.assign({},i.body.error_code?{"Error code":i.body.error_code}:{}),{"Reject code":String(i.body.reject_code),"Reject message":i.body.reject_message}):{"HTTP status code":i.status.toString(),"HTTP status text":i.statusText})),this.requestId=n,this.response=i}},Bt=Symbol.for("ic-agent-metadata"),Vr=class t{constructor(e){this[Bt]=Object.freeze(e)}static agentOf(e){return e[Bt].config.agent}static interfaceOf(e){return e[Bt].service}static canisterIdOf(e){return ae.from(e[Bt].config.canisterId)}static async install(e,r){let n=e.mode===void 0?{install:null}:e.mode,i=e.arg?[...new Uint8Array(e.arg)]:[],s=[...new Uint8Array(e.module)],o=typeof r.canisterId=="string"?ae.fromText(r.canisterId):r.canisterId;await U0(r).install_code({mode:n,arg:i,wasm_module:s,canister_id:o,sender_canister_version:[]})}static async createCanister(e,r){function n(s){return[{controllers:s.controllers?[s.controllers]:[],compute_allocation:s.compute_allocation?[s.compute_allocation]:[],freezing_threshold:s.freezing_threshold?[s.freezing_threshold]:[],memory_allocation:s.memory_allocation?[s.memory_allocation]:[],reserved_cycles_limit:[],log_visibility:[]}]}let{canister_id:i}=await U0(e||{}).provisional_create_canister_with_cycles({amount:[],settings:n(r||{}),specified_id:[],sender_canister_version:[]});return i}static async createAndInstallCanister(e,r,n){let i=await this.createCanister(n);return await this.install(Object.assign({},r),Object.assign(Object.assign({},n),{canisterId:i})),this.createActor(e,Object.assign(Object.assign({},n),{canisterId:i}))}static createActorClass(e,r){let n=e({IDL:lr});class i extends t{constructor(o){if(!o.canisterId)throw new Ke(`Canister ID is required, but received ${typeof o.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);let c=typeof o.canisterId=="string"?ae.fromText(o.canisterId):o.canisterId;super({config:Object.assign(Object.assign(Object.assign({},P0),o),{canisterId:c}),service:n});for(let[a,d]of n._fields)r?.httpDetails&&d.annotations.push(qa),this[a]=R1(this,a,d,o.blsVerify)}}return i}static createActor(e,r){if(!r.canisterId)throw new Ke(`Canister ID is required, but received ${typeof r.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);return new(this.createActorClass(e))(r)}static createActorWithHttpDetails(e,r){return new(this.createActorClass(e,{httpDetails:!0}))(r)}};function Cs(t,e){let r=lr.decode(t,F0.Buffer.from(e));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var P0={pollingStrategyFactory:ks.defaultStrategy},qa="http-details";function R1(t,e,r,n){let i;r.annotations.includes("query")||r.annotations.includes("composite_query")?i=async(o,...c)=>{var a,d;o=Object.assign(Object.assign({},o),(d=(a=t[Bt].config).queryTransform)===null||d===void 0?void 0:d.call(a,e,c,Object.assign(Object.assign({},t[Bt].config),o)));let l=o.agent||t[Bt].config.agent||Pa(),f=ae.from(o.canisterId||t[Bt].config.canisterId),T=lr.encode(r.argTypes,c),_=await l.query(f,{methodName:e,arg:T,effectiveCanisterId:o.effectiveCanisterId});switch(_.status){case"rejected":throw new ka(f,e,_);case"replied":return r.annotations.includes(qa)?{httpDetails:_.httpDetails,result:Cs(r.retTypes,_.reply.arg)}:Cs(r.retTypes,_.reply.arg)}}:i=async(o,...c)=>{var a,d;o=Object.assign(Object.assign({},o),(d=(a=t[Bt].config).callTransform)===null||d===void 0?void 0:d.call(a,e,c,Object.assign(Object.assign({},t[Bt].config),o)));let l=o.agent||t[Bt].config.agent||Pa(),{canisterId:f,effectiveCanisterId:T,pollingStrategyFactory:_}=Object.assign(Object.assign(Object.assign({},P0),t[Bt].config),o),b=ae.from(f),E=T!==void 0?ae.from(T):b,U=lr.encode(r.argTypes,c),{requestId:I,response:$}=await l.call(b,{methodName:e,arg:U,effectiveCanisterId:E});if(!$.ok||$.body)throw new Ca(b,e,I,$);let M=_(),K=await Ma(l,E,I,M,n),F=r.annotations.includes(qa);if(K!==void 0)return F?{httpDetails:$,result:Cs(r.retTypes,K)}:Cs(r.retTypes,K);if(r.retTypes.length===0)return F?{httpDetails:$,result:void 0}:void 0;throw new Error(`Call was returned undefined, but type [${r.retTypes.join(",")}].`)};let s=(...o)=>i({},...o);return s.withOptions=o=>(...c)=>i(o,...c),s}function U0(t){function e(r,n){if(t.effectiveCanisterId)return{effectiveCanisterId:ae.from(t.effectiveCanisterId)};let i=n[0],s=ae.fromHex("");return i&&typeof i=="object"&&i.canister_id&&(s=ae.from(i.canister_id)),{effectiveCanisterId:s}}return Vr.createActor(O0,Object.assign(Object.assign(Object.assign({},t),{canisterId:ae.fromHex("")}),{callTransform:e,queryTransform:e}))}Zn();gt();Wn();On();ga();pt();Wn();Fn();var M0=async({orbiterId:t,idlFactory:e,container:r})=>{let n=or(r)&&r!==!1,i=n?r===!0?"http://127.0.0.1:5987":r:"https://icp-api.io",s=new Dn({identity:new nn,host:i});return n&&await s.fetchRootKey(),Vr.createActor(e,{agent:s,canisterId:t})};var $a=async t=>M0({idlFactory:cc,...t});function ei(t){return new Promise((e,r)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>r(t.error)})}function $s(t,e){let r=indexedDB.open(t);r.onupgradeneeded=()=>r.result.createObjectStore(e);let n=ei(r);return(i,s)=>n.then(o=>s(o.transaction(e,i).objectStore(e)))}var Va;function k0(){return Va||(Va=$s("keyval-store","keyval")),Va}function Ga(t,e=k0()){return e("readwrite",r=>(t.forEach(n=>r.delete(n)),ei(r.transaction)))}function I1(t,e){return t.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},ei(t.transaction)}function Ha(t=k0()){return t("readonly",e=>{if(e.getAll&&e.getAllKeys)return Promise.all([ei(e.getAllKeys()),ei(e.getAll())]).then(([n,i])=>n.map((s,o)=>[s,i[o]]));let r=[];return t("readonly",n=>I1(n,i=>r.push([i.key,i.value])).then(()=>r))})}var C0=$s("juno-views","views"),q0=$s("juno-events","events");var $0=()=>Ha(C0),V0=t=>Ga(t,C0);var G0=()=>Ha(q0),H0=t=>Ga(t,q0);onmessage=async({data:t})=>{let{msg:e,data:r}=t;switch(e){case"junoInitEnvironment":await F1(r);return;case"junoTrackPageView":q1();return;case"junoTrackEvent":$1();return;case"junoStartTrackTimer":await M1();return;case"junoStopTracker":await P1();return}};var O1="Analytics worker not initialized. Did you set `satelliteId`?",U1="Analytics worker not initialized. Did you set `orbiterId`?",Xt,F1=async t=>{let{orbiterId:e,satelliteId:r}=t;Ws(e,U1),Ws(r,O1),Xt=t},ti,za=async()=>await Promise.all([j0(),Y0()]),P1=async()=>{await za(),or(ti)&&(clearInterval(ti),ti=void 0),self.close()},M1=async()=>{or(ti)||(await za(),ti=setInterval(za,Xt?.worker?.timerInterval??1e3))},ja=!1,Ya=!1,j0=async()=>{if(!Vs(Xt)||ja)return;let t=await $0();if(!(Kr(t)||t.length===0)){ja=!0;try{let r=await(await $a(Xt)).set_page_views(t.map(([n,{collected_at:i,...s}])=>[z0({key:n,collected_at:i}),{...s,...K0(Xt)}]));await V0(t.map(([n,i])=>n)),W0(r)}catch(e){console.error(e)}ja=!1}},k1=Zs(async()=>await j0(),100),Y0=async()=>{if(!Vs(Xt)||Ya)return;let t=await G0();if(!(Kr(t)||t.length===0)){Ya=!0;try{let e=await $a(Xt),r=({metadata:i,...s})=>({metadata:Kr(i)?[]:[Object.entries(i??{})],...s,...K0(Xt)}),n=await e.set_track_events(t.map(([i,{collected_at:s,...o}])=>[z0({key:i,collected_at:s}),r(o)]));await H0(t.map(([i,s])=>i)),W0(n)}catch(e){console.error(e)}Ya=!1}},C1=Zs(async()=>await Y0(),250),q1=()=>{Vs(Xt)&&(Z0()||k1())},$1=()=>{Vs(Xt)&&(Z0()||C1())},z0=({key:t,collected_at:e})=>({collected_at:e,key:t}),K0=t=>({satellite_id:ae.fromText(t.satelliteId)}),Z0=()=>{let{userAgent:t}=navigator;return or(t)?ac(t):!1},Vs=t=>t!=null&&or(t.orbiterId)&&or(t.satelliteId),W0=t=>{"Ok"in t||t.Err.forEach(([e,r])=>console.warn(`${r} [Key: ${e.key}]`))};})();
42
41
  /*!
43
42
  * The buffer module from node.js, for the browser.
44
43
  *