@junobuild/analytics 0.0.27 → 0.0.28
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,43 +1,43 @@
|
|
|
1
|
-
"use strict";(()=>{var fl=Object.create;var ai=Object.defineProperty;var ll=Object.getOwnPropertyDescriptor;var dl=Object.getOwnPropertyNames;var hl=Object.getPrototypeOf,pl=Object.prototype.hasOwnProperty;var xe=(t,e)=>()=>(t&&(e=t(t=0)),e);var Ge=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),gn=(t,e)=>{for(var r in e)ai(t,r,{get:e[r],enumerable:!0})},Ka=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of dl(e))!pl.call(t,i)&&i!==r&&ai(t,i,{get:()=>e[i],enumerable:!(n=ll(e,i))||n.enumerable});return t};var zr=(t,e,r)=>(r=t!=null?fl(hl(t)):{},Ka(e||!t||!t.__esModule?ai(r,"default",{value:t,enumerable:!0}):r,t)),ml=t=>Ka(ai({},"__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+=ci[r>>3],e+=5),0)}for(let s=0;s<t.length;)s+=i(t[s]);return n+(e<0?ci[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=Kr[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 ci,Kr,Xa=xe(()=>{ci="abcdefghijklmnopqrstuvwxyz234567",Kr=Object.create(null);for(let t=0;t<ci.length;t++)Kr[ci[t]]=t;Kr[0]=Kr.o;Kr[1]=Kr.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=yl[s]^r>>>8}return(r^-1)>>>0}var yl,Qa=xe(()=>{yl=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 gl(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Ks(t,...e){if(!gl(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 Zs(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){Ks(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var Ws=xe(()=>{});var ui,Da=xe(()=>{ui=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0});function ec(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Xs(t){return typeof t=="string"&&(t=ec(t)),Ks(t),t}function wn(t){let e=n=>t().update(Xs(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function di(t=32){if(ui&&typeof ui.getRandomValues=="function")return ui.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}var li,St,J1,fi,Q1,Zr=xe(()=>{Da();Ws();li=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),St=(t,e)=>t<<32-e|t>>>e,J1=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;fi=class{clone(){return this._cloneInto()}},Q1={}.toString});function wl(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,Wr,Js=xe(()=>{Ws();Zr();tc=(t,e,r)=>t&e^~t&r,rc=(t,e,r)=>t&e^t&r^e&r,Wr=class extends fi{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=li(this.buffer)}update(e){Zs(this);let{view:r,buffer:n,blockLen:i}=this;e=Xs(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=li(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){Zs(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;wl(n,i-8,BigInt(this.length*8),s),this.process(n,0);let c=li(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 bl,or,ar,hi,Qs,bn,nc,pi=xe(()=>{Js();Zr();bl=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]),or=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ar=new Uint32Array(64),hi=class extends Wr{constructor(){super(64,32,8,!1),this.A=or[0]|0,this.B=or[1]|0,this.C=or[2]|0,this.D=or[3]|0,this.E=or[4]|0,this.F=or[5]|0,this.G=or[6]|0,this.H=or[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)ar[f]=e.getUint32(r,!1);for(let f=16;f<64;f++){let T=ar[f-15],E=ar[f-2],w=St(T,7)^St(T,18)^T>>>3,x=St(E,17)^St(E,19)^E>>>10;ar[f]=x+ar[f-7]+w+ar[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=St(c,6)^St(c,11)^St(c,25),E=l+T+tc(c,a,d)+bl[f]+ar[f]|0,x=(St(n,2)^St(n,13)^St(n,22))+rc(n,i,s)|0;l=d,d=a,a=c,c=o+E|0,o=s,s=i,i=n,n=E+x|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(){ar.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},Qs=class extends hi{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}},bn=wn(()=>new hi),nc=wn(()=>new Qs)});function ic(t){return nc.create().update(new Uint8Array(t)).digest()}var sc=xe(()=>{pi()});var mi,xl,oc,_l,El,Bl,ue,xt=xe(()=>{Xa();Qa();sc();mi="__principal__",xl=2,oc=4,_l="aaaaa-aa",El=t=>{var e;return new Uint8Array(((e=t.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(r=>parseInt(r,16)))},Bl=t=>t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),""),ue=class t{constructor(e){this._arr=e,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([oc]))}static managementCanister(){return this.fromHex(_l)}static selfAuthenticating(e){let r=ic(e);return new this(new Uint8Array([...r,xl]))}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(El(e))}static fromText(e){let r=e;if(e.includes(mi)){let o=JSON.parse(e);mi in o&&(r=o[mi])}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 Bl(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{[mi]: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=Ge(yi=>{"use strict";yi.byteLength=Rl;yi.toByteArray=Fl;yi.fromByteArray=Pl;var Vt=[],_t=[],Nl=typeof Uint8Array<"u"?Uint8Array:Array,eo="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Nr=0,uc=eo.length;Nr<uc;++Nr)Vt[Nr]=eo[Nr],_t[eo.charCodeAt(Nr)]=Nr;var Nr,uc;_t[45]=62;_t[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 Rl(t){var e=fc(t),r=e[0],n=e[1];return(r+n)*3/4-n}function Ol(t,e,r){return(e+r)*3/4-r}function Fl(t){var e,r=fc(t),n=r[0],i=r[1],s=new Nl(Ol(t,n,i)),o=0,c=i>0?n-4:n,a;for(a=0;a<c;a+=4)e=_t[t.charCodeAt(a)]<<18|_t[t.charCodeAt(a+1)]<<12|_t[t.charCodeAt(a+2)]<<6|_t[t.charCodeAt(a+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=_t[t.charCodeAt(a)]<<2|_t[t.charCodeAt(a+1)]>>4,s[o++]=e&255),i===1&&(e=_t[t.charCodeAt(a)]<<10|_t[t.charCodeAt(a+1)]<<4|_t[t.charCodeAt(a+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function Il(t){return Vt[t>>18&63]+Vt[t>>12&63]+Vt[t>>6&63]+Vt[t&63]}function Ul(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(Il(n));return i.join("")}function Pl(t){for(var e,r=t.length,n=r%3,i=[],s=16383,o=0,c=r-n;o<c;o+=s)i.push(Ul(t,o,o+s>c?c:o+s));return n===1?(e=t[r-1],i.push(Vt[e>>2]+Vt[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(Vt[e>>10]+Vt[e>>4&63]+Vt[e<<2&63]+"=")),i.join("")}});var ro=Ge(to=>{to.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,E=t[e+f];for(f+=T,s=E&(1<<-l)-1,E>>=-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:(E?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-d}return(E?-1:1)*o*Math.pow(2,s-n)};to.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,E=n?0:s-1,w=n?1:-1,x=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+E]=c&255,E+=w,c/=256,i-=8);for(o=o<<i|c,d+=i;d>0;t[r+E]=o&255,E+=w,o/=256,d-=8);t[r+E-w]|=x*128}});var Nc=Ge(Lr=>{"use strict";var no=lc(),Jr=ro(),dc=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Lr.Buffer=P;Lr.SlowBuffer=$l;Lr.INSPECT_MAX_BYTES=50;var gi=2147483647;Lr.kMaxLength=gi;P.TYPED_ARRAY_SUPPORT=Ml();!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 Ml(){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 Lt(t){if(t>gi)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 ao(t)}return yc(t,e,r)}P.poolSize=8192;function yc(t,e,r){if(typeof t=="string")return Cl(t,e);if(ArrayBuffer.isView(t))return ql(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($t(t,ArrayBuffer)||t&&$t(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&($t(t,SharedArrayBuffer)||t&&$t(t.buffer,SharedArrayBuffer)))return so(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=Vl(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 kl(t,e,r){return gc(t),t<=0?Lt(t):e!==void 0?typeof r=="string"?Lt(t).fill(e,r):Lt(t).fill(e):Lt(t)}P.alloc=function(t,e,r){return kl(t,e,r)};function ao(t){return gc(t),Lt(t<0?0:co(t)|0)}P.allocUnsafe=function(t){return ao(t)};P.allocUnsafeSlow=function(t){return ao(t)};function Cl(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=Lt(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function io(t){let e=t.length<0?0:co(t.length)|0,r=Lt(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function ql(t){if($t(t,Uint8Array)){let e=new Uint8Array(t);return so(e.buffer,e.byteOffset,e.byteLength)}return io(t)}function so(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 Vl(t){if(P.isBuffer(t)){let e=co(t.length)|0,r=Lt(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||fo(t.length)?Lt(0):io(t);if(t.type==="Buffer"&&Array.isArray(t.data))return io(t.data)}function co(t){if(t>=gi)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+gi.toString(16)+" bytes");return t|0}function $l(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($t(e,Uint8Array)&&(e=P.from(e,e.offset,e.byteLength)),$t(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($t(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)||$t(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 oo(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:oo(t).length;e=(""+e).toLowerCase(),i=!0}}P.byteLength=wc;function Gl(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 Ql(this,e,r);case"utf8":case"utf-8":return xc(this,e,r);case"ascii":return Xl(this,e,r);case"latin1":case"binary":return Jl(this,e,r);case"base64":return Zl(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ll(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}P.prototype._isBuffer=!0;function Rr(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)Rr(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)Rr(this,r,r+3),Rr(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)Rr(this,r,r+7),Rr(this,r+1,r+6),Rr(this,r+2,r+5),Rr(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):Gl.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=Lr.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($t(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,fo(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 Hl(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(fo(c))return o;t[r+o]=c}return o}function jl(t,e,r,n){return wi(oo(e,t.length-r),t,r,n)}function Yl(t,e,r,n){return wi(rd(e),t,r,n)}function zl(t,e,r,n){return wi(Sc(e),t,r,n)}function Kl(t,e,r,n){return wi(nd(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 Hl(this,e,r,n);case"utf8":case"utf-8":return jl(this,e,r,n);case"ascii":case"latin1":case"binary":return Yl(this,e,r,n);case"base64":return zl(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Kl(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 Zl(t,e,r){return e===0&&r===t.length?no.fromByteArray(t):no.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 Wl(n)}var pc=4096;function Wl(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 Xl(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 Jl(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 Ql(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+=id[t[s]];return i}function Ll(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 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")}P.prototype.readUintLE=P.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||Le(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||Le(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||Le(e,1,this.length),this[e]};P.prototype.readUint16LE=P.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||Le(e,2,this.length),this[e]|this[e+1]<<8};P.prototype.readUint16BE=P.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||Le(e,2,this.length),this[e]<<8|this[e+1]};P.prototype.readUint32LE=P.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||Le(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||Le(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};P.prototype.readBigUInt64LE=ur(function(e){e=e>>>0,Qr(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&_n(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=ur(function(e){e=e>>>0,Qr(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&_n(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||Le(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||Le(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||Le(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};P.prototype.readInt16LE=function(e,r){e=e>>>0,r||Le(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||Le(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||Le(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||Le(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};P.prototype.readBigInt64LE=ur(function(e){e=e>>>0,Qr(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&_n(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=ur(function(e){e=e>>>0,Qr(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&_n(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||Le(e,4,this.length),Jr.read(this,e,!0,23,4)};P.prototype.readFloatBE=function(e,r){return e=e>>>0,r||Le(e,4,this.length),Jr.read(this,e,!1,23,4)};P.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||Le(e,8,this.length),Jr.read(this,e,!0,52,8)};P.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||Le(e,8,this.length),Jr.read(this,e,!1,52,8)};function lt(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;lt(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;lt(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||lt(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||lt(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||lt(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||lt(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||lt(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=ur(function(e,r=0){return _c(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});P.prototype.writeBigUInt64BE=ur(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);lt(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);lt(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||lt(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||lt(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||lt(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||lt(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||lt(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=ur(function(e,r=0){return _c(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});P.prototype.writeBigInt64BE=ur(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),Jr.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),Jr.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 Xr={};function uo(t,e,r){Xr[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}`}}}uo("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);uo("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);uo("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 Dl(t,e,r){Qr(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&_n(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 Xr.ERR_OUT_OF_RANGE("value",c,t)}Dl(n,i,s)}function Qr(t,e){if(typeof t!="number")throw new Xr.ERR_INVALID_ARG_TYPE(e,"number",t)}function _n(t,e,r){throw Math.floor(t)!==t?(Qr(t,r),new Xr.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new Xr.ERR_BUFFER_OUT_OF_BOUNDS:new Xr.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var ed=/[^+/0-9A-Za-z-_]/g;function td(t){if(t=t.split("=")[0],t=t.trim().replace(ed,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function oo(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 rd(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function nd(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 no.toByteArray(td(t))}function wi(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 $t(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function fo(t){return t!==t}var id=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 ur(t){return typeof BigInt>"u"?sd:t}function sd(){throw new Error("BigInt not supported")}});var Ze,Dr=xe(()=>{Ze=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 lo(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}function ho(t){return t instanceof Uint8Array?lo(t):t instanceof ArrayBuffer?t:Array.isArray(t)?lo(new Uint8Array(t)):"buffer"in t?ho(t.buffer):lo(new Uint8Array(t))}var Nt,xi=xe(()=>{Nt=class{constructor(e,r=e?.byteLength||0){this._buffer=ho(e||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return ho(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 od(t){let r=new TextEncoder().encode(t),n=0;for(let i of r)n=(n*223+i)%2**32;return n}function Rt(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 od(t)}var po=xe(()=>{});function Rc(){throw new Error("unexpected end of buffer")}function lr(t,e){return t.byteLength<e&&Rc(),t.read(e)}function fr(t){let e=t.readUint8();return e===void 0&&Rc(),e}function Fe(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 Nt(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 He(t){let e=BigInt(1),r=BigInt(0),n;do n=fr(t),r+=BigInt(n&127).valueOf()*e,e*=BigInt(128);while(n>=128);return r}function je(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 Nt(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 Dt(t){let e=new Uint8Array(t.buffer),r=0;for(;r<e.byteLength;r++)if(e[r]<128){if(!(e[r]&64))return He(t);break}let n=new Uint8Array(lr(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 Oc(t,e){if(BigInt(t)<BigInt(0))throw new Error("Cannot write negative values.");return mo(t,e)}function mo(t,e){t=BigInt(t);let r=new Nt(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 yo(t,e){let r=BigInt(fr(t)),n=BigInt(1),i=0;for(;++i<e;){n*=BigInt(256);let s=BigInt(fr(t));r=r+n*s}return r}function Fc(t,e){let r=yo(t,e),n=BigInt(2)**(BigInt(8)*BigInt(e-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}var go=xe(()=>{xi()});function _i(t){let e=BigInt(t);if(t<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<e}var Ic=xe(()=>{});var hr={};gn(hr,{Bool:()=>kc,BoolClass:()=>Ti,ConstructType:()=>Ht,Empty:()=>Pc,EmptyClass:()=>vi,FixedIntClass:()=>er,FixedNatClass:()=>Gt,Float32:()=>Gc,Float64:()=>Hc,FloatClass:()=>Bn,Func:()=>iu,FuncClass:()=>An,Int:()=>Vc,Int16:()=>Yc,Int32:()=>zc,Int64:()=>Kc,Int8:()=>jc,IntClass:()=>Ri,Nat:()=>$c,Nat16:()=>Wc,Nat32:()=>Xc,Nat64:()=>Jc,Nat8:()=>Zc,NatClass:()=>Oi,Null:()=>Cc,NullClass:()=>Si,Opt:()=>eu,OptClass:()=>rn,PrimitiveType:()=>dt,Principal:()=>Qc,PrincipalClass:()=>Pi,Rec:()=>nu,RecClass:()=>dr,Record:()=>tu,RecordClass:()=>vn,Reserved:()=>Mc,ReservedClass:()=>tn,Service:()=>su,ServiceClass:()=>Mi,Text:()=>qc,TextClass:()=>Ni,Tuple:()=>Lc,TupleClass:()=>Ii,Type:()=>en,Unknown:()=>ud,UnknownClass:()=>Ai,Variant:()=>ru,VariantClass:()=>Ui,Vec:()=>Dc,VecClass:()=>Fi,Visitor:()=>Bi,decode:()=>cd,encode:()=>ad});function En(t,e,r){return t.map((n,i)=>r(n,e[i]))}function bo(t){if(fr(t)!==1)throw new Error("Cannot decode principal");let r=Number(He(t));return ue.fromUint8Array(new Uint8Array(lr(t,r)))}function Ce(t){let e=JSON.stringify(t,(r,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return e&&e.length>Uc?e.substring(0,Uc-3)+"...":e}function ad(t,e){if(e.length<t.length)throw Error("Wrong number of message arguments");let r=new wo;t.forEach(a=>a.buildTypeTable(r));let n=new TextEncoder().encode(Ei),i=r.encode(),s=Fe(e.length),o=ve(...t.map(a=>a.encodeType(r))),c=ve(...En(t,e,(a,d)=>{try{a.covariant(d)}catch(l){throw new Error(l.message+`
|
|
1
|
+
"use strict";(()=>{var gl=Object.create;var gi=Object.defineProperty;var wl=Object.getOwnPropertyDescriptor;var bl=Object.getOwnPropertyNames;var xl=Object.getPrototypeOf,_l=Object.prototype.hasOwnProperty;var bt=(e,t)=>()=>(e&&(t=e(e=0)),t);var Vt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Sn=(e,t)=>{for(var r in t)gi(e,r,{get:t[r],enumerable:!0})},cc=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of bl(t))!_l.call(e,i)&&i!==r&&gi(e,i,{get:()=>t[i],enumerable:!(n=wl(t,i))||n.enumerable});return e};var Jr=(e,t,r)=>(r=e!=null?gl(xl(e)):{},cc(t||!e||!e.__esModule?gi(r,"default",{value:e,enumerable:!0}):r,e)),El=e=>cc(gi({},"__esModule",{value:!0}),e);function uc(e){let t=0,r=0,n="";function i(s){return t<0?r|=s>>-t:r=s<<t&248,t>3?(t-=8,1):(t<4&&(n+=wi[r>>3],t+=5),0)}for(let s=0;s<e.length;)s+=i(e[s]);return n+(t<0?wi[r>>3]:"")}function fc(e){let t=0,r=0,n=new Uint8Array(e.length*4/3|0),i=0;function s(o){let a=Qr[o.toLowerCase()];if(a===void 0)throw new Error(`Invalid character: ${JSON.stringify(o)}`);a<<=3,r|=a>>>t,t+=5,t>=8&&(n[i++]=r,t-=8,t>0?r=a<<5-t&255:r=0)}for(let o of e)s(o);return n.slice(0,i)}var wi,Qr,lc=bt(()=>{wi="abcdefghijklmnopqrstuvwxyz234567",Qr=Object.create(null);for(let e=0;e<wi.length;e++)Qr[wi[e]]=e;Qr[0]=Qr.o;Qr[1]=Qr.i});function hc(e){let t=new Uint8Array(e),r=-1;for(let n=0;n<t.length;n++){let s=(t[n]^r)&255;r=vl[s]^r>>>8}return(r^-1)>>>0}var vl,dc=bt(()=>{vl=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(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function io(e,...t){if(!Bl(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function so(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function pc(e,t){io(e);let r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var oo=bt(()=>{});var bi,mc=bt(()=>{bi=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0});function yc(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function ao(e){return typeof e=="string"&&(e=yc(e)),io(e),e}function Nn(e){let t=n=>e().update(ao(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Ei(e=32){if(bi&&typeof bi.getRandomValues=="function")return bi.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}var _i,Se,X1,xi,J1,Lr=bt(()=>{mc();oo();_i=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),Se=(e,t)=>e<<32-t|e>>>t,X1=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;xi=class{clone(){return this._cloneInto()}},J1={}.toString});function Al(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let i=BigInt(32),s=BigInt(4294967295),o=Number(r>>i&s),a=Number(r&s),c=n?4:0,l=n?0:4;e.setUint32(t+c,o,n),e.setUint32(t+l,a,n)}var gc,wc,Dr,co=bt(()=>{oo();Lr();gc=(e,t,r)=>e&t^~e&r,wc=(e,t,r)=>e&t^e&r^t&r,Dr=class extends xi{constructor(t,r,n,i){super(),this.blockLen=t,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(t),this.view=_i(this.buffer)}update(t){so(this);let{view:r,buffer:n,blockLen:i}=this;t=ao(t);let s=t.length;for(let o=0;o<s;){let a=Math.min(i-this.pos,s-o);if(a===i){let c=_i(t);for(;i<=s-o;o+=i)this.process(c,o);continue}n.set(t.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){so(this),pc(t,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 h=o;h<i;h++)r[h]=0;Al(n,i-8,BigInt(this.length*8),s),this.process(n,0);let a=_i(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=c/4,d=this.get();if(l>d.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<l;h++)a.setUint32(4*h,d[h],s)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:s,destroyed:o,pos:a}=this;return t.length=i,t.pos=a,t.finished=s,t.destroyed=o,i%r&&t.buffer.set(n),t}}});var Tl,hr,dr,vi,uo,Rn,bc,Bi=bt(()=>{co();Lr();Tl=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]),hr=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),dr=new Uint32Array(64),vi=class extends Dr{constructor(){super(64,32,8,!1),this.A=hr[0]|0,this.B=hr[1]|0,this.C=hr[2]|0,this.D=hr[3]|0,this.E=hr[4]|0,this.F=hr[5]|0,this.G=hr[6]|0,this.H=hr[7]|0}get(){let{A:t,B:r,C:n,D:i,E:s,F:o,G:a,H:c}=this;return[t,r,n,i,s,o,a,c]}set(t,r,n,i,s,o,a,c){this.A=t|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(t,r){for(let h=0;h<16;h++,r+=4)dr[h]=t.getUint32(r,!1);for(let h=16;h<64;h++){let N=dr[h-15],w=dr[h-2],u=Se(N,7)^Se(N,18)^N>>>3,x=Se(w,17)^Se(w,19)^w>>>10;dr[h]=x+dr[h-7]+u+dr[h-16]|0}let{A:n,B:i,C:s,D:o,E:a,F:c,G:l,H:d}=this;for(let h=0;h<64;h++){let N=Se(a,6)^Se(a,11)^Se(a,25),w=d+N+gc(a,c,l)+Tl[h]+dr[h]|0,x=(Se(n,2)^Se(n,13)^Se(n,22))+wc(n,i,s)|0;d=l,l=c,c=a,a=o+w|0,o=s,s=i,i=n,n=w+x|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,l=l+this.G|0,d=d+this.H|0,this.set(n,i,s,o,a,c,l,d)}roundClean(){dr.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},uo=class extends vi{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}},Rn=Nn(()=>new vi),bc=Nn(()=>new uo)});function xc(e){return bc.create().update(new Uint8Array(e)).digest()}var _c=bt(()=>{Bi()});var Ai,Sl,Ec,Nl,Rl,Ol,ht,xe=bt(()=>{lc();dc();_c();Ai="__principal__",Sl=2,Ec=4,Nl="aaaaa-aa",Rl=e=>{var t;return new Uint8Array(((t=e.match(/.{1,2}/g))!==null&&t!==void 0?t:[]).map(r=>parseInt(r,16)))},Ol=e=>e.reduce((t,r)=>t+r.toString(16).padStart(2,"0"),""),ht=class e{constructor(t){this._arr=t,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([Ec]))}static managementCanister(){return this.fromHex(Nl)}static selfAuthenticating(t){let r=xc(t);return new this(new Uint8Array([...r,Sl]))}static from(t){if(typeof t=="string")return e.fromText(t);if(Object.getPrototypeOf(t)===Uint8Array.prototype)return new e(t);if(typeof t=="object"&&t!==null&&t._isPrincipal===!0)return new e(t._arr);throw new Error(`Impossible to convert ${JSON.stringify(t)} to Principal.`)}static fromHex(t){return new this(Rl(t))}static fromText(t){let r=t;if(t.includes(Ai)){let o=JSON.parse(t);Ai in o&&(r=o[Ai])}let n=r.toLowerCase().replace(/-/g,""),i=fc(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(t){return new this(t)}isAnonymous(){return this._arr.byteLength===1&&this._arr[0]===Ec}toUint8Array(){return this._arr}toHex(){return Ol(this._arr).toUpperCase()}toText(){let t=new ArrayBuffer(4);new DataView(t).setUint32(0,hc(this._arr));let n=new Uint8Array(t),i=Uint8Array.from(this._arr),s=new Uint8Array([...n,...i]),a=uc(s).match(/.{1,5}/g);if(!a)throw new Error;return a.join("-")}toString(){return this.toText()}toJSON(){return{[Ai]:this.toText()}}compareTo(t){for(let r=0;r<Math.min(this._arr.length,t._arr.length);r++){if(this._arr[r]<t._arr[r])return"lt";if(this._arr[r]>t._arr[r])return"gt"}return this._arr.length<t._arr.length?"lt":this._arr.length>t._arr.length?"gt":"eq"}ltEq(t){let r=this.compareTo(t);return r=="lt"||r=="eq"}gtEq(t){let r=this.compareTo(t);return r=="gt"||r=="eq"}}});var Sc=Vt(Ti=>{"use strict";Ti.byteLength=Ml;Ti.toByteArray=ql;Ti.fromByteArray=Hl;var Ge=[],_e=[],kl=typeof Uint8Array<"u"?Uint8Array:Array,ho="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Ir=0,Ac=ho.length;Ir<Ac;++Ir)Ge[Ir]=ho[Ir],_e[ho.charCodeAt(Ir)]=Ir;var Ir,Ac;_e[45]=62;_e[95]=63;function Tc(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function Ml(e){var t=Tc(e),r=t[0],n=t[1];return(r+n)*3/4-n}function Cl(e,t,r){return(t+r)*3/4-r}function ql(e){var t,r=Tc(e),n=r[0],i=r[1],s=new kl(Cl(e,n,i)),o=0,a=i>0?n-4:n,c;for(c=0;c<a;c+=4)t=_e[e.charCodeAt(c)]<<18|_e[e.charCodeAt(c+1)]<<12|_e[e.charCodeAt(c+2)]<<6|_e[e.charCodeAt(c+3)],s[o++]=t>>16&255,s[o++]=t>>8&255,s[o++]=t&255;return i===2&&(t=_e[e.charCodeAt(c)]<<2|_e[e.charCodeAt(c+1)]>>4,s[o++]=t&255),i===1&&(t=_e[e.charCodeAt(c)]<<10|_e[e.charCodeAt(c+1)]<<4|_e[e.charCodeAt(c+2)]>>2,s[o++]=t>>8&255,s[o++]=t&255),s}function $l(e){return Ge[e>>18&63]+Ge[e>>12&63]+Ge[e>>6&63]+Ge[e&63]}function Vl(e,t,r){for(var n,i=[],s=t;s<r;s+=3)n=(e[s]<<16&16711680)+(e[s+1]<<8&65280)+(e[s+2]&255),i.push($l(n));return i.join("")}function Hl(e){for(var t,r=e.length,n=r%3,i=[],s=16383,o=0,a=r-n;o<a;o+=s)i.push(Vl(e,o,o+s>a?a:o+s));return n===1?(t=e[r-1],i.push(Ge[t>>2]+Ge[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(Ge[t>>10]+Ge[t>>4&63]+Ge[t<<2&63]+"=")),i.join("")}});var mo=Vt(po=>{po.read=function(e,t,r,n,i){var s,o,a=i*8-n-1,c=(1<<a)-1,l=c>>1,d=-7,h=r?i-1:0,N=r?-1:1,w=e[t+h];for(h+=N,s=w&(1<<-d)-1,w>>=-d,d+=a;d>0;s=s*256+e[t+h],h+=N,d-=8);for(o=s&(1<<-d)-1,s>>=-d,d+=n;d>0;o=o*256+e[t+h],h+=N,d-=8);if(s===0)s=1-l;else{if(s===c)return o?NaN:(w?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-l}return(w?-1:1)*o*Math.pow(2,s-n)};po.write=function(e,t,r,n,i,s){var o,a,c,l=s*8-i-1,d=(1<<l)-1,h=d>>1,N=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=n?0:s-1,u=n?1:-1,x=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=d):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+h>=1?t+=N/c:t+=N*Math.pow(2,1-h),t*c>=2&&(o++,c/=2),o+h>=d?(a=0,o=d):o+h>=1?(a=(t*c-1)*Math.pow(2,i),o=o+h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;e[r+w]=a&255,w+=u,a/=256,i-=8);for(o=o<<i|a,l+=i;l>0;e[r+w]=o&255,w+=u,o/=256,l-=8);e[r+w-u]|=x*128}});var Yc=Vt(nn=>{"use strict";var yo=Sc(),en=mo(),Nc=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;nn.Buffer=$;nn.SlowBuffer=Wl;nn.INSPECT_MAX_BYTES=50;var Si=2147483647;nn.kMaxLength=Si;$.TYPED_ARRAY_SUPPORT=Gl();!$.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 e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty($.prototype,"parent",{enumerable:!0,get:function(){if($.isBuffer(this))return this.buffer}});Object.defineProperty($.prototype,"offset",{enumerable:!0,get:function(){if($.isBuffer(this))return this.byteOffset}});function tr(e){if(e>Si)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,$.prototype),t}function $(e,t,r){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return xo(e)}return Uc(e,t,r)}$.poolSize=8192;function Uc(e,t,r){if(typeof e=="string")return Yl(e,t);if(ArrayBuffer.isView(e))return zl(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(je(e,ArrayBuffer)||e&&je(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(je(e,SharedArrayBuffer)||e&&je(e.buffer,SharedArrayBuffer)))return wo(e,t,r);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=e.valueOf&&e.valueOf();if(n!=null&&n!==e)return $.from(n,t,r);let i=Kl(e);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return $.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}$.from=function(e,t,r){return Uc(e,t,r)};Object.setPrototypeOf($.prototype,Uint8Array.prototype);Object.setPrototypeOf($,Uint8Array);function Ic(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function jl(e,t,r){return Ic(e),e<=0?tr(e):t!==void 0?typeof r=="string"?tr(e).fill(t,r):tr(e).fill(t):tr(e)}$.alloc=function(e,t,r){return jl(e,t,r)};function xo(e){return Ic(e),tr(e<0?0:_o(e)|0)}$.allocUnsafe=function(e){return xo(e)};$.allocUnsafeSlow=function(e){return xo(e)};function Yl(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!$.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let r=Pc(e,t)|0,n=tr(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}function go(e){let t=e.length<0?0:_o(e.length)|0,r=tr(t);for(let n=0;n<t;n+=1)r[n]=e[n]&255;return r}function zl(e){if(je(e,Uint8Array)){let t=new Uint8Array(e);return wo(t.buffer,t.byteOffset,t.byteLength)}return go(e)}function wo(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return t===void 0&&r===void 0?n=new Uint8Array(e):r===void 0?n=new Uint8Array(e,t):n=new Uint8Array(e,t,r),Object.setPrototypeOf(n,$.prototype),n}function Kl(e){if($.isBuffer(e)){let t=_o(e.length)|0,r=tr(t);return r.length===0||e.copy(r,0,0,t),r}if(e.length!==void 0)return typeof e.length!="number"||vo(e.length)?tr(0):go(e);if(e.type==="Buffer"&&Array.isArray(e.data))return go(e.data)}function _o(e){if(e>=Si)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Si.toString(16)+" bytes");return e|0}function Wl(e){return+e!=e&&(e=0),$.alloc(+e)}$.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==$.prototype};$.compare=function(t,r){if(je(t,Uint8Array)&&(t=$.from(t,t.offset,t.byteLength)),je(r,Uint8Array)&&(r=$.from(r,r.offset,r.byteLength)),!$.isBuffer(t)||!$.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===r)return 0;let n=t.length,i=r.length;for(let s=0,o=Math.min(n,i);s<o;++s)if(t[s]!==r[s]){n=t[s],i=r[s];break}return n<i?-1:i<n?1:0};$.isEncoding=function(t){switch(String(t).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}};$.concat=function(t,r){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return $.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<t.length;++n)r+=t[n].length;let i=$.allocUnsafe(r),s=0;for(n=0;n<t.length;++n){let o=t[n];if(je(o,Uint8Array))s+o.length>i.length?($.isBuffer(o)||(o=$.from(o)),o.copy(i,s)):Uint8Array.prototype.set.call(i,o,s);else if($.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function Pc(e,t){if($.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||je(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let r=e.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return bo(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return jc(e).length;default:if(i)return n?-1:bo(e).length;t=(""+t).toLowerCase(),i=!0}}$.byteLength=Pc;function Zl(e,t,r){let n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return ih(this,t,r);case"utf8":case"utf-8":return Mc(this,t,r);case"ascii":return rh(this,t,r);case"latin1":case"binary":return nh(this,t,r);case"base64":return th(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return sh(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}$.prototype._isBuffer=!0;function Pr(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}$.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<t;r+=2)Pr(this,r,r+1);return this};$.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<t;r+=4)Pr(this,r,r+3),Pr(this,r+1,r+2);return this};$.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<t;r+=8)Pr(this,r,r+7),Pr(this,r+1,r+6),Pr(this,r+2,r+5),Pr(this,r+3,r+4);return this};$.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?Mc(this,0,t):Zl.apply(this,arguments)};$.prototype.toLocaleString=$.prototype.toString;$.prototype.equals=function(t){if(!$.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:$.compare(this,t)===0};$.prototype.inspect=function(){let t="",r=nn.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"};Nc&&($.prototype[Nc]=$.prototype.inspect);$.prototype.compare=function(t,r,n,i,s){if(je(t,Uint8Array)&&(t=$.from(t,t.offset,t.byteLength)),!$.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(r===void 0&&(r=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),r<0||n>t.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===t)return 0;let o=s-i,a=n-r,c=Math.min(o,a),l=this.slice(i,s),d=t.slice(r,n);for(let h=0;h<c;++h)if(l[h]!==d[h]){o=l[h],a=d[h];break}return o<a?-1:a<o?1:0};function kc(e,t,r,n,i){if(e.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,vo(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof t=="string"&&(t=$.from(t,n)),$.isBuffer(t))return t.length===0?-1:Rc(e,t,r,n,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Rc(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Rc(e,t,r,n,i){let s=1,o=e.length,a=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||t.length<2)return-1;s=2,o/=2,a/=2,r/=2}function c(d,h){return s===1?d[h]:d.readUInt16BE(h*s)}let l;if(i){let d=-1;for(l=r;l<o;l++)if(c(e,l)===c(t,d===-1?0:l-d)){if(d===-1&&(d=l),l-d+1===a)return d*s}else d!==-1&&(l-=l-d),d=-1}else for(r+a>o&&(r=o-a),l=r;l>=0;l--){let d=!0;for(let h=0;h<a;h++)if(c(e,l+h)!==c(t,h)){d=!1;break}if(d)return l}return-1}$.prototype.includes=function(t,r,n){return this.indexOf(t,r,n)!==-1};$.prototype.indexOf=function(t,r,n){return kc(this,t,r,n,!0)};$.prototype.lastIndexOf=function(t,r,n){return kc(this,t,r,n,!1)};function Xl(e,t,r,n){r=Number(r)||0;let i=e.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let s=t.length;n>s/2&&(n=s/2);let o;for(o=0;o<n;++o){let a=parseInt(t.substr(o*2,2),16);if(vo(a))return o;e[r+o]=a}return o}function Jl(e,t,r,n){return Ni(bo(t,e.length-r),e,r,n)}function Ql(e,t,r,n){return Ni(uh(t),e,r,n)}function Ll(e,t,r,n){return Ni(jc(t),e,r,n)}function Dl(e,t,r,n){return Ni(fh(t,e.length-r),e,r,n)}$.prototype.write=function(t,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),t.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 Xl(this,t,r,n);case"utf8":case"utf-8":return Jl(this,t,r,n);case"ascii":case"latin1":case"binary":return Ql(this,t,r,n);case"base64":return Ll(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Dl(this,t,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};$.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function th(e,t,r){return t===0&&r===e.length?yo.fromByteArray(e):yo.fromByteArray(e.slice(t,r))}function Mc(e,t,r){r=Math.min(e.length,r);let n=[],i=t;for(;i<r;){let s=e[i],o=null,a=s>239?4:s>223?3:s>191?2:1;if(i+a<=r){let c,l,d,h;switch(a){case 1:s<128&&(o=s);break;case 2:c=e[i+1],(c&192)===128&&(h=(s&31)<<6|c&63,h>127&&(o=h));break;case 3:c=e[i+1],l=e[i+2],(c&192)===128&&(l&192)===128&&(h=(s&15)<<12|(c&63)<<6|l&63,h>2047&&(h<55296||h>57343)&&(o=h));break;case 4:c=e[i+1],l=e[i+2],d=e[i+3],(c&192)===128&&(l&192)===128&&(d&192)===128&&(h=(s&15)<<18|(c&63)<<12|(l&63)<<6|d&63,h>65535&&h<1114112&&(o=h))}}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 eh(n)}var Oc=4096;function eh(e){let t=e.length;if(t<=Oc)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Oc));return r}function rh(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]&127);return n}function nh(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function ih(e,t,r){let n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);let i="";for(let s=t;s<r;++s)i+=lh[e[s]];return i}function sh(e,t,r){let n=e.slice(t,r),i="";for(let s=0;s<n.length-1;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}$.prototype.slice=function(t,r){let n=this.length;t=~~t,r=r===void 0?n:~~r,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<t&&(r=t);let i=this.subarray(t,r);return Object.setPrototypeOf(i,$.prototype),i};function Jt(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}$.prototype.readUintLE=$.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||Jt(t,r,this.length);let i=this[t],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[t+o]*s;return i};$.prototype.readUintBE=$.prototype.readUIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||Jt(t,r,this.length);let i=this[t+--r],s=1;for(;r>0&&(s*=256);)i+=this[t+--r]*s;return i};$.prototype.readUint8=$.prototype.readUInt8=function(t,r){return t=t>>>0,r||Jt(t,1,this.length),this[t]};$.prototype.readUint16LE=$.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||Jt(t,2,this.length),this[t]|this[t+1]<<8};$.prototype.readUint16BE=$.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||Jt(t,2,this.length),this[t]<<8|this[t+1]};$.prototype.readUint32LE=$.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||Jt(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};$.prototype.readUint32BE=$.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||Jt(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};$.prototype.readBigUInt64LE=mr(function(t){t=t>>>0,rn(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Fn(t,this.length-8);let i=r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,s=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(i)+(BigInt(s)<<BigInt(32))});$.prototype.readBigUInt64BE=mr(function(t){t=t>>>0,rn(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Fn(t,this.length-8);let i=r*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],s=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(s)});$.prototype.readIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||Jt(t,r,this.length);let i=this[t],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[t+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*r)),i};$.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||Jt(t,r,this.length);let i=r,s=1,o=this[t+--i];for(;i>0&&(s*=256);)o+=this[t+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*r)),o};$.prototype.readInt8=function(t,r){return t=t>>>0,r||Jt(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};$.prototype.readInt16LE=function(t,r){t=t>>>0,r||Jt(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};$.prototype.readInt16BE=function(t,r){t=t>>>0,r||Jt(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};$.prototype.readInt32LE=function(t,r){return t=t>>>0,r||Jt(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};$.prototype.readInt32BE=function(t,r){return t=t>>>0,r||Jt(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};$.prototype.readBigInt64LE=mr(function(t){t=t>>>0,rn(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Fn(t,this.length-8);let i=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)});$.prototype.readBigInt64BE=mr(function(t){t=t>>>0,rn(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Fn(t,this.length-8);let i=(r<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n)});$.prototype.readFloatLE=function(t,r){return t=t>>>0,r||Jt(t,4,this.length),en.read(this,t,!0,23,4)};$.prototype.readFloatBE=function(t,r){return t=t>>>0,r||Jt(t,4,this.length),en.read(this,t,!1,23,4)};$.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||Jt(t,8,this.length),en.read(this,t,!0,52,8)};$.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||Jt(t,8,this.length),en.read(this,t,!1,52,8)};function ce(e,t,r,n,i,s){if(!$.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}$.prototype.writeUintLE=$.prototype.writeUIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;ce(this,t,r,n,a,0)}let s=1,o=0;for(this[r]=t&255;++o<n&&(s*=256);)this[r+o]=t/s&255;return r+n};$.prototype.writeUintBE=$.prototype.writeUIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;ce(this,t,r,n,a,0)}let s=n-1,o=1;for(this[r+s]=t&255;--s>=0&&(o*=256);)this[r+s]=t/o&255;return r+n};$.prototype.writeUint8=$.prototype.writeUInt8=function(t,r,n){return t=+t,r=r>>>0,n||ce(this,t,r,1,255,0),this[r]=t&255,r+1};$.prototype.writeUint16LE=$.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||ce(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2};$.prototype.writeUint16BE=$.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||ce(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2};$.prototype.writeUint32LE=$.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||ce(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255,r+4};$.prototype.writeUint32BE=$.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||ce(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};function Cc(e,t,r,n,i){Gc(t,n,i,e,r,7);let s=Number(t&BigInt(4294967295));e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o,r}function qc(e,t,r,n,i){Gc(t,n,i,e,r,7);let s=Number(t&BigInt(4294967295));e[r+7]=s,s=s>>8,e[r+6]=s,s=s>>8,e[r+5]=s,s=s>>8,e[r+4]=s;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=o,o=o>>8,e[r+2]=o,o=o>>8,e[r+1]=o,o=o>>8,e[r]=o,r+8}$.prototype.writeBigUInt64LE=mr(function(t,r=0){return Cc(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});$.prototype.writeBigUInt64BE=mr(function(t,r=0){return qc(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});$.prototype.writeIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let c=Math.pow(2,8*n-1);ce(this,t,r,n,c-1,-c)}let s=0,o=1,a=0;for(this[r]=t&255;++s<n&&(o*=256);)t<0&&a===0&&this[r+s-1]!==0&&(a=1),this[r+s]=(t/o>>0)-a&255;return r+n};$.prototype.writeIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let c=Math.pow(2,8*n-1);ce(this,t,r,n,c-1,-c)}let s=n-1,o=1,a=0;for(this[r+s]=t&255;--s>=0&&(o*=256);)t<0&&a===0&&this[r+s+1]!==0&&(a=1),this[r+s]=(t/o>>0)-a&255;return r+n};$.prototype.writeInt8=function(t,r,n){return t=+t,r=r>>>0,n||ce(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1};$.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||ce(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2};$.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||ce(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2};$.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||ce(this,t,r,4,2147483647,-2147483648),this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4};$.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||ce(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};$.prototype.writeBigInt64LE=mr(function(t,r=0){return Cc(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});$.prototype.writeBigInt64BE=mr(function(t,r=0){return qc(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function $c(e,t,r,n,i,s){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Vc(e,t,r,n,i){return t=+t,r=r>>>0,i||$c(e,t,r,4,34028234663852886e22,-34028234663852886e22),en.write(e,t,r,n,23,4),r+4}$.prototype.writeFloatLE=function(t,r,n){return Vc(this,t,r,!0,n)};$.prototype.writeFloatBE=function(t,r,n){return Vc(this,t,r,!1,n)};function Hc(e,t,r,n,i){return t=+t,r=r>>>0,i||$c(e,t,r,8,17976931348623157e292,-17976931348623157e292),en.write(e,t,r,n,52,8),r+8}$.prototype.writeDoubleLE=function(t,r,n){return Hc(this,t,r,!0,n)};$.prototype.writeDoubleBE=function(t,r,n){return Hc(this,t,r,!1,n)};$.prototype.copy=function(t,r,n,i){if(!$.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&i<n&&(i=n),i===n||t.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),t.length-r<i-n&&(i=t.length-r+n);let s=i-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(t,this.subarray(n,i),r),s};$.prototype.fill=function(t,r,n,i){if(typeof t=="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"&&!$.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){let o=t.charCodeAt(0);(i==="utf8"&&o<128||i==="latin1")&&(t=o)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));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,t||(t=0);let s;if(typeof t=="number")for(s=r;s<n;++s)this[s]=t;else{let o=$.isBuffer(t)?t:$.from(t,i),a=o.length;if(a===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(s=0;s<n-r;++s)this[s+r]=o[s%a]}return this};var tn={};function Eo(e,t,r){tn[e]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}Eo("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Eo("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError);Eo("ERR_OUT_OF_RANGE",function(e,t,r){let n=`The value of "${e}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=Fc(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=Fc(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function Fc(e){let t="",r=e.length,n=e[0]==="-"?1:0;for(;r>=n+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function oh(e,t,r){rn(t,"offset"),(e[t]===void 0||e[t+r]===void 0)&&Fn(t,e.length-(r+1))}function Gc(e,t,r,n,i,s){if(e>r||e<t){let o=typeof t=="bigint"?"n":"",a;throw s>3?t===0||t===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=`>= ${t}${o} and <= ${r}${o}`,new tn.ERR_OUT_OF_RANGE("value",a,e)}oh(n,i,s)}function rn(e,t){if(typeof e!="number")throw new tn.ERR_INVALID_ARG_TYPE(t,"number",e)}function Fn(e,t,r){throw Math.floor(e)!==e?(rn(e,r),new tn.ERR_OUT_OF_RANGE(r||"offset","an integer",e)):t<0?new tn.ERR_BUFFER_OUT_OF_BOUNDS:new tn.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}var ah=/[^+/0-9A-Za-z-_]/g;function ch(e){if(e=e.split("=")[0],e=e.trim().replace(ah,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function bo(e,t){t=t||1/0;let r,n=e.length,i=null,s=[];for(let o=0;o<n;++o){if(r=e.charCodeAt(o),r>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(t-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&s.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;s.push(r)}else if(r<2048){if((t-=2)<0)break;s.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;s.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=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 uh(e){let t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function fh(e,t){let r,n,i,s=[];for(let o=0;o<e.length&&!((t-=2)<0);++o)r=e.charCodeAt(o),n=r>>8,i=r%256,s.push(i),s.push(n);return s}function jc(e){return yo.toByteArray(ch(e))}function Ni(e,t,r,n){let i;for(i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function je(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function vo(e){return e!==e}var lh=function(){let e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)t[n+i]=e[r]+e[i]}return t}();function mr(e){return typeof BigInt>"u"?hh:e}function hh(){throw new Error("BigInt not supported")}});var Ht,sn=bt(()=>{Ht=class e extends Error{constructor(t){super(t),this.message=t,Object.setPrototypeOf(this,e.prototype)}}});function Et(...e){let t=new Uint8Array(e.reduce((n,i)=>n+i.byteLength,0)),r=0;for(let n of e)t.set(new Uint8Array(n),r),r+=n.byteLength;return t}function Bo(e){return new DataView(e.buffer,e.byteOffset,e.byteLength).buffer}function Ao(e){return e instanceof Uint8Array?Bo(e):e instanceof ArrayBuffer?e:Array.isArray(e)?Bo(new Uint8Array(e)):"buffer"in e?Ao(e.buffer):Bo(new Uint8Array(e))}var Ne,Oi=bt(()=>{Ne=class{constructor(t,r=t?.byteLength||0){this._buffer=Ao(t||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(t){let r=this._view.subarray(0,t);return this._view=this._view.subarray(t),r.slice().buffer}readUint8(){let t=this._view[0];return this._view=this._view.subarray(1),t}write(t){let r=new Uint8Array(t),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(t){let r=new ArrayBuffer((this._buffer.byteLength+t)*1.2|0),n=new Uint8Array(r,0,this._view.byteLength+t);n.set(this._view),this._buffer=r,this._view=n}}});function dh(e){let r=new TextEncoder().encode(e),n=0;for(let i of r)n=(n*223+i)%2**32;return n}function Re(e){if(/^_\d+_$/.test(e)||/^_0x[0-9a-fA-F]+_$/.test(e)){let t=+e.slice(1,-1);if(Number.isSafeInteger(t)&&t>=0&&t<2**32)return t}return dh(e)}var To=bt(()=>{});function zc(){throw new Error("unexpected end of buffer")}function gr(e,t){return e.byteLength<t&&zc(),e.read(t)}function yr(e){let t=e.readUint8();return t===void 0&&zc(),t}function Ot(e){if(typeof e=="number"&&(e=BigInt(e)),e<BigInt(0))throw new Error("Cannot leb encode negative values.");let t=(e===BigInt(0)?0:Math.ceil(Math.log2(Number(e))))+1,r=new Ne(new ArrayBuffer(t),0);for(;;){let n=Number(e&BigInt(127));if(e/=BigInt(128),e===BigInt(0)){r.write(new Uint8Array([n]));break}else r.write(new Uint8Array([n|128]))}return r.buffer}function Gt(e){let t=BigInt(1),r=BigInt(0),n;do n=yr(e),r+=BigInt(n&127).valueOf()*t,t*=BigInt(128);while(n>=128);return r}function jt(e){typeof e=="number"&&(e=BigInt(e));let t=e<BigInt(0);t&&(e=-e-BigInt(1));let r=(e===BigInt(0)?0:Math.ceil(Math.log2(Number(e))))+1,n=new Ne(new ArrayBuffer(r),0);for(;;){let s=i(e);if(e/=BigInt(128),t&&e===BigInt(0)&&s&64||!t&&e===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(t?BigInt(128)-o-BigInt(1):o)}return n.buffer}function er(e){let t=new Uint8Array(e.buffer),r=0;for(;r<t.byteLength;r++)if(t[r]<128){if(!(t[r]&64))return Gt(e);break}let n=new Uint8Array(gr(e,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 Kc(e,t){if(BigInt(e)<BigInt(0))throw new Error("Cannot write negative values.");return So(e,t)}function So(e,t){e=BigInt(e);let r=new Ne(new ArrayBuffer(Math.min(1,t)),0),n=0,i=BigInt(256),s=BigInt(0),o=Number(e%i);for(r.write(new Uint8Array([o]));++n<t;)e<0&&s===BigInt(0)&&o!==0&&(s=BigInt(1)),o=Number((e/i-s)%BigInt(256)),r.write(new Uint8Array([o])),i*=BigInt(256);return r.buffer}function No(e,t){let r=BigInt(yr(e)),n=BigInt(1),i=0;for(;++i<t;){n*=BigInt(256);let s=BigInt(yr(e));r=r+n*s}return r}function Wc(e,t){let r=No(e,t),n=BigInt(2)**(BigInt(8)*BigInt(t-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}var Ro=bt(()=>{Oi()});function Fi(e){let t=BigInt(e);if(e<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<t}var Zc=bt(()=>{});var br={};Sn(br,{Bool:()=>Lc,BoolClass:()=>Mi,ConstructType:()=>ze,Empty:()=>Jc,EmptyClass:()=>Pi,FixedIntClass:()=>rr,FixedNatClass:()=>Ye,Float32:()=>nu,Float64:()=>iu,FloatClass:()=>In,Func:()=>xu,FuncClass:()=>kn,Int:()=>eu,Int16:()=>ou,Int32:()=>au,Int64:()=>cu,Int8:()=>su,IntClass:()=>$i,Nat:()=>ru,Nat16:()=>fu,Nat32:()=>lu,Nat64:()=>hu,Nat8:()=>uu,NatClass:()=>Vi,Null:()=>Dc,NullClass:()=>Ci,Opt:()=>yu,OptClass:()=>cn,PrimitiveType:()=>ue,Principal:()=>du,PrincipalClass:()=>Yi,Rec:()=>bu,RecClass:()=>wr,Record:()=>gu,RecordClass:()=>Pn,Reserved:()=>Qc,ReservedClass:()=>an,Service:()=>_u,ServiceClass:()=>zi,Text:()=>tu,TextClass:()=>qi,Tuple:()=>pu,TupleClass:()=>Gi,Type:()=>on,Unknown:()=>yh,UnknownClass:()=>ki,Variant:()=>wu,VariantClass:()=>ji,Vec:()=>mu,VecClass:()=>Hi,Visitor:()=>Ii,decode:()=>mh,encode:()=>ph});function Un(e,t,r){return e.map((n,i)=>r(n,t[i]))}function Fo(e){if(yr(e)!==1)throw new Error("Cannot decode principal");let r=Number(Gt(e));return ht.fromUint8Array(new Uint8Array(gr(e,r)))}function Pt(e){let t=JSON.stringify(e,(r,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return t&&t.length>Xc?t.substring(0,Xc-3)+"...":t}function ph(e,t){if(t.length<e.length)throw Error("Wrong number of message arguments");let r=new Oo;e.forEach(c=>c.buildTypeTable(r));let n=new TextEncoder().encode(Ui),i=r.encode(),s=Ot(t.length),o=Et(...e.map(c=>c.encodeType(r))),a=Et(...Un(e,t,(c,l)=>{try{c.covariant(l)}catch(d){throw new Error(d.message+`
|
|
2
2
|
|
|
3
|
-
`)}return a.encodeValue(d)}));return ve(n,i,s,o,c)}function cd(t,e){let r=new Nt(e);if(e.byteLength<Ei.length)throw new Error("Message length smaller than magic number");let n=lr(r,Ei.length),i=new TextDecoder().decode(n);if(i!==Ei)throw new Error("Wrong magic number: "+JSON.stringify(i));function s(E){let w=[],x=Number(He(E));for(let q=0;q<x;q++){let V=Number(Dt(E));switch(V){case-18:case-19:{let Z=Number(Dt(E));w.push([V,Z]);break}case-20:case-21:{let Z=[],U=Number(He(E)),M;for(;U--;){let Y=Number(He(E));if(Y>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof M=="number"&&M>=Y)throw new Error("field id collision or not sorted");M=Y;let z=Number(Dt(E));Z.push([Y,z])}w.push([V,Z]);break}case-22:{let Z=[],U=Number(He(E));for(;U--;)Z.push(Number(Dt(E)));let M=[],Y=Number(He(E));for(;Y--;)M.push(Number(Dt(E)));let z=[],G=Number(He(E));for(;G--;)switch(Number(He(E))){case 1:{z.push("query");break}case 2:{z.push("oneway");break}case 3:{z.push("composite_query");break}default:throw new Error("unknown annotation")}w.push([V,[Z,M,z]]);break}case-23:{let Z=Number(He(E)),U=[];for(;Z--;){let M=Number(He(E)),Y=new TextDecoder().decode(lr(E,M)),z=Dt(E);U.push([Y,z])}w.push([V,U]);break}default:throw new Error("Illegal op_code: "+V)}}let I=[],O=Number(He(E));for(let q=0;q<O;q++)I.push(Number(Dt(E)));return[w,I]}let[o,c]=s(r);if(c.length<t.length)throw new Error("Wrong number of return values");let a=o.map(E=>nu());function d(E){if(E<-24)throw new Error("future value not supported");if(E<0)switch(E){case-1:return Cc;case-2:return kc;case-3:return $c;case-4:return Vc;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: "+E)}if(E>=o.length)throw new Error("type index out of range");return a[E]}function l(E){switch(E[0]){case-19:{let w=d(E[1]);return Dc(w)}case-18:{let w=d(E[1]);return eu(w)}case-20:{let w={};for(let[O,q]of E[1]){let V=`_${O}_`;w[V]=d(q)}let x=tu(w),I=x.tryAsTuple();return Array.isArray(I)?Lc(...I):x}case-21:{let w={};for(let[x,I]of E[1]){let O=`_${x}_`;w[O]=d(I)}return ru(w)}case-22:{let[w,x,I]=E[1];return iu(w.map(O=>d(O)),x.map(O=>d(O)),I)}case-23:{let w={},x=E[1];for(let[I,O]of x){let q=d(O);if(q instanceof dr&&(q=q.getType()),!(q instanceof An))throw new Error("Illegal service definition: services can only contain functions");w[I]=q}return su(w)}default:throw new Error("Illegal op_code: "+E[0])}}o.forEach((E,w)=>{if(E[0]===-22){let x=l(E);a[w].fill(x)}}),o.forEach((E,w)=>{if(E[0]!==-22){let x=l(E);a[w].fill(x)}});let f=c.map(E=>d(E)),T=t.map((E,w)=>E.decodeValue(r,f[w]));for(let E=t.length;E<f.length;E++)f[E].decodeValue(r,f[E]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return T}function Lc(...t){return new Ii(t)}function Dc(t){return new Fi(t)}function eu(t){return new rn(t)}function tu(t){return new vn(t)}function ru(t){return new Ui(t)}function nu(){return new dr}function iu(t,e,r=[]){return new An(t,e,r)}function su(t){return new Mi(t)}var Ei,Uc,wo,Bi,en,dt,Ht,vi,Ai,Ti,Si,tn,Ni,Ri,Oi,Bn,er,Gt,Fi,rn,vn,Ii,Ui,dr,Pi,An,Mi,Pc,Mc,ud,kc,Cc,qc,Vc,$c,Gc,Hc,jc,Yc,zc,Kc,Zc,Wc,Xc,Jc,Qc,xo=xe(()=>{xt();xi();po();go();Ic();Ei="DIDL",Uc=400;wo=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=Fe(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 je(this._idx.get(e)||0)}},Bi=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)}},en=class{display(){return this.name}valueToString(e){return Ce(e)}buildTypeTable(e){e.has(this)||this._buildTypeTableImpl(e)}},dt=class extends en{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){}},Ht=class extends en{checkType(e){if(e instanceof dr){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)}},vi=class extends dt{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 je(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}},Ai=class extends en{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 dr?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"}},Ti=class extends dt{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 je(-2)}decodeValue(e,r){switch(this.checkType(r),fr(e)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}},Si=class extends dt{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 je(-1)}decodeValue(e,r){return this.checkType(r),null}get name(){return"null"}},tn=class extends dt{accept(e,r){return e.visitReserved(this,r)}covariant(e){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return je(-16)}decodeValue(e,r){return r.name!==this.name&&r.decodeValue(e,r),null}get name(){return"reserved"}},Ni=class extends dt{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=Fe(r.byteLength);return ve(n,r)}encodeType(){return je(-15)}decodeValue(e,r){this.checkType(r);let n=He(e),i=lr(e,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(i)}get name(){return"text"}valueToString(e){return'"'+e+'"'}},Ri=class extends dt{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 je(e)}encodeType(){return je(-4)}decodeValue(e,r){return this.checkType(r),Dt(e)}get name(){return"int"}valueToString(e){return e.toString()}},Oi=class extends dt{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 Fe(e)}encodeType(){return je(-3)}decodeValue(e,r){return this.checkType(r),He(e)}get name(){return"nat"}valueToString(e){return e.toString()}},Bn=class extends dt{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 je(e)}decodeValue(e,r){this.checkType(r);let n=lr(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()}},er=class extends dt{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedInt(this,r)}covariant(e){let r=_i(this._bits-1)*BigInt(-1),n=_i(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 mo(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return je(-9-e)}decodeValue(e,r){this.checkType(r);let n=Fc(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(e){return e.toString()}},Gt=class extends dt{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedNat(this,r)}covariant(e){let r=_i(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 Oc(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return je(-5-e)}decodeValue(e,r){this.checkType(r);let n=yo(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(e){return e.toString()}},Fi=class t extends Ht{constructor(e){super(),this._type=e,this._blobOptimization=!1,e instanceof Gt&&e._bits===8&&(this._blobOptimization=!0)}accept(e,r){return e.visitVec(this,this._type,r)}covariant(e){let r=this._type instanceof Gt?this._type._bits:this._type instanceof er?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:
|
|
3
|
+
`)}return c.encodeValue(l)}));return Et(n,i,s,o,a)}function mh(e,t){let r=new Ne(t);if(t.byteLength<Ui.length)throw new Error("Message length smaller than magic number");let n=gr(r,Ui.length),i=new TextDecoder().decode(n);if(i!==Ui)throw new Error("Wrong magic number: "+JSON.stringify(i));function s(w){let u=[],x=Number(Gt(w));for(let k=0;k<x;k++){let H=Number(er(w));switch(H){case-18:case-19:{let X=Number(er(w));u.push([H,X]);break}case-20:case-21:{let X=[],E=Number(Gt(w)),q;for(;E--;){let W=Number(Gt(w));if(W>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof q=="number"&&q>=W)throw new Error("field id collision or not sorted");q=W;let K=Number(er(w));X.push([W,K])}u.push([H,X]);break}case-22:{let X=[],E=Number(Gt(w));for(;E--;)X.push(Number(er(w)));let q=[],W=Number(Gt(w));for(;W--;)q.push(Number(er(w)));let K=[],G=Number(Gt(w));for(;G--;)switch(Number(Gt(w))){case 1:{K.push("query");break}case 2:{K.push("oneway");break}case 3:{K.push("composite_query");break}default:throw new Error("unknown annotation")}u.push([H,[X,q,K]]);break}case-23:{let X=Number(Gt(w)),E=[];for(;X--;){let q=Number(Gt(w)),W=new TextDecoder().decode(gr(w,q)),K=er(w);E.push([W,K])}u.push([H,E]);break}default:throw new Error("Illegal op_code: "+H)}}let C=[],M=Number(Gt(w));for(let k=0;k<M;k++)C.push(Number(er(w)));return[u,C]}let[o,a]=s(r);if(a.length<e.length)throw new Error("Wrong number of return values");let c=o.map(w=>bu());function l(w){if(w<-24)throw new Error("future value not supported");if(w<0)switch(w){case-1:return Dc;case-2:return Lc;case-3:return ru;case-4:return eu;case-5:return uu;case-6:return fu;case-7:return lu;case-8:return hu;case-9:return su;case-10:return ou;case-11:return au;case-12:return cu;case-13:return nu;case-14:return iu;case-15:return tu;case-16:return Qc;case-17:return Jc;case-24:return du;default:throw new Error("Illegal op_code: "+w)}if(w>=o.length)throw new Error("type index out of range");return c[w]}function d(w){switch(w[0]){case-19:{let u=l(w[1]);return mu(u)}case-18:{let u=l(w[1]);return yu(u)}case-20:{let u={};for(let[M,k]of w[1]){let H=`_${M}_`;u[H]=l(k)}let x=gu(u),C=x.tryAsTuple();return Array.isArray(C)?pu(...C):x}case-21:{let u={};for(let[x,C]of w[1]){let M=`_${x}_`;u[M]=l(C)}return wu(u)}case-22:{let[u,x,C]=w[1];return xu(u.map(M=>l(M)),x.map(M=>l(M)),C)}case-23:{let u={},x=w[1];for(let[C,M]of x){let k=l(M);if(k instanceof wr&&(k=k.getType()),!(k instanceof kn))throw new Error("Illegal service definition: services can only contain functions");u[C]=k}return _u(u)}default:throw new Error("Illegal op_code: "+w[0])}}o.forEach((w,u)=>{if(w[0]===-22){let x=d(w);c[u].fill(x)}}),o.forEach((w,u)=>{if(w[0]!==-22){let x=d(w);c[u].fill(x)}});let h=a.map(w=>l(w)),N=e.map((w,u)=>w.decodeValue(r,h[u]));for(let w=e.length;w<h.length;w++)h[w].decodeValue(r,h[w]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return N}function pu(...e){return new Gi(e)}function mu(e){return new Hi(e)}function yu(e){return new cn(e)}function gu(e){return new Pn(e)}function wu(e){return new ji(e)}function bu(){return new wr}function xu(e,t,r=[]){return new kn(e,t,r)}function _u(e){return new zi(e)}var Ui,Xc,Oo,Ii,on,ue,ze,Pi,ki,Mi,Ci,an,qi,$i,Vi,In,rr,Ye,Hi,cn,Pn,Gi,ji,wr,Yi,kn,zi,Jc,Qc,yh,Lc,Dc,tu,eu,ru,nu,iu,su,ou,au,cu,uu,fu,lu,hu,du,Uo=bt(()=>{xe();Oi();To();Ro();Zc();Ui="DIDL",Xc=400;Oo=class{constructor(){this._typs=[],this._idx=new Map}has(t){return this._idx.has(t.name)}add(t,r){let n=this._typs.length;this._idx.set(t.name,n),this._typs.push(r)}merge(t,r){let n=this._idx.get(t.name),i=this._idx.get(r);if(n===void 0)throw new Error("Missing type index for "+t);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 t=Ot(this._typs.length),r=Et(...this._typs);return Et(t,r)}indexOf(t){if(!this._idx.has(t))throw new Error("Missing type index for "+t);return jt(this._idx.get(t)||0)}},Ii=class{visitType(t,r){throw new Error("Not implemented")}visitPrimitive(t,r){return this.visitType(t,r)}visitEmpty(t,r){return this.visitPrimitive(t,r)}visitBool(t,r){return this.visitPrimitive(t,r)}visitNull(t,r){return this.visitPrimitive(t,r)}visitReserved(t,r){return this.visitPrimitive(t,r)}visitText(t,r){return this.visitPrimitive(t,r)}visitNumber(t,r){return this.visitPrimitive(t,r)}visitInt(t,r){return this.visitNumber(t,r)}visitNat(t,r){return this.visitNumber(t,r)}visitFloat(t,r){return this.visitPrimitive(t,r)}visitFixedInt(t,r){return this.visitNumber(t,r)}visitFixedNat(t,r){return this.visitNumber(t,r)}visitPrincipal(t,r){return this.visitPrimitive(t,r)}visitConstruct(t,r){return this.visitType(t,r)}visitVec(t,r,n){return this.visitConstruct(t,n)}visitOpt(t,r,n){return this.visitConstruct(t,n)}visitRecord(t,r,n){return this.visitConstruct(t,n)}visitTuple(t,r,n){let i=r.map((s,o)=>[`_${o}_`,s]);return this.visitRecord(t,i,n)}visitVariant(t,r,n){return this.visitConstruct(t,n)}visitRec(t,r,n){return this.visitConstruct(r,n)}visitFunc(t,r){return this.visitConstruct(t,r)}visitService(t,r){return this.visitConstruct(t,r)}},on=class{display(){return this.name}valueToString(t){return Pt(t)}buildTypeTable(t){t.has(this)||this._buildTypeTableImpl(t)}},ue=class extends on{checkType(t){if(this.name!==t.name)throw new Error(`type mismatch: type on the wire ${t.name}, expect type ${this.name}`);return t}_buildTypeTableImpl(t){}},ze=class extends on{checkType(t){if(t instanceof wr){let r=t.getType();if(typeof r>"u")throw new Error("type mismatch with uninitialized type");return r}throw new Error(`type mismatch: type on the wire ${t.name}, expect type ${this.name}`)}encodeType(t){return t.indexOf(this.name)}},Pi=class extends ue{accept(t,r){return t.visitEmpty(this,r)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${Pt(t)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return jt(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}},ki=class extends on{checkType(t){throw new Error("Method not implemented for unknown.")}accept(t,r){throw t.visitType(this,r)}covariant(t){throw new Error(`Invalid ${this.display()} argument: ${Pt(t)}`)}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(t,r){let n=r.decodeValue(t,r);Object(n)!==n&&(n=Object(n));let i;return r instanceof wr?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"}},Mi=class extends ue{accept(t,r){return t.visitBool(this,r)}covariant(t){if(typeof t=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${Pt(t)}`)}encodeValue(t){return new Uint8Array([t?1:0])}encodeType(){return jt(-2)}decodeValue(t,r){switch(this.checkType(r),yr(t)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}},Ci=class extends ue{accept(t,r){return t.visitNull(this,r)}covariant(t){if(t===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${Pt(t)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return jt(-1)}decodeValue(t,r){return this.checkType(r),null}get name(){return"null"}},an=class extends ue{accept(t,r){return t.visitReserved(this,r)}covariant(t){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return jt(-16)}decodeValue(t,r){return r.name!==this.name&&r.decodeValue(t,r),null}get name(){return"reserved"}},qi=class extends ue{accept(t,r){return t.visitText(this,r)}covariant(t){if(typeof t=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${Pt(t)}`)}encodeValue(t){let r=new TextEncoder().encode(t),n=Ot(r.byteLength);return Et(n,r)}encodeType(){return jt(-15)}decodeValue(t,r){this.checkType(r);let n=Gt(t),i=gr(t,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(i)}get name(){return"text"}valueToString(t){return'"'+t+'"'}},$i=class extends ue{accept(t,r){return t.visitInt(this,r)}covariant(t){if(typeof t=="bigint"||Number.isInteger(t))return!0;throw new Error(`Invalid ${this.display()} argument: ${Pt(t)}`)}encodeValue(t){return jt(t)}encodeType(){return jt(-4)}decodeValue(t,r){return this.checkType(r),er(t)}get name(){return"int"}valueToString(t){return t.toString()}},Vi=class extends ue{accept(t,r){return t.visitNat(this,r)}covariant(t){if(typeof t=="bigint"&&t>=BigInt(0)||Number.isInteger(t)&&t>=0)return!0;throw new Error(`Invalid ${this.display()} argument: ${Pt(t)}`)}encodeValue(t){return Ot(t)}encodeType(){return jt(-3)}decodeValue(t,r){return this.checkType(r),Gt(t)}get name(){return"nat"}valueToString(t){return t.toString()}},In=class extends ue{constructor(t){if(super(),this._bits=t,t!==32&&t!==64)throw new Error("not a valid float type")}accept(t,r){return t.visitFloat(this,r)}covariant(t){if(typeof t=="number"||t instanceof Number)return!0;throw new Error(`Invalid ${this.display()} argument: ${Pt(t)}`)}encodeValue(t){let r=new ArrayBuffer(this._bits/8),n=new DataView(r);return this._bits===32?n.setFloat32(0,t,!0):n.setFloat64(0,t,!0),r}encodeType(){let t=this._bits===32?-13:-14;return jt(t)}decodeValue(t,r){this.checkType(r);let n=gr(t,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(t){return t.toString()}},rr=class extends ue{constructor(t){super(),this._bits=t}accept(t,r){return t.visitFixedInt(this,r)}covariant(t){let r=Fi(this._bits-1)*BigInt(-1),n=Fi(this._bits-1)-BigInt(1),i=!1;if(typeof t=="bigint")i=t>=r&&t<=n;else if(Number.isInteger(t)){let s=BigInt(t);i=s>=r&&s<=n}else i=!1;if(i)return!0;throw new Error(`Invalid ${this.display()} argument: ${Pt(t)}`)}encodeValue(t){return So(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return jt(-9-t)}decodeValue(t,r){this.checkType(r);let n=Wc(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(t){return t.toString()}},Ye=class extends ue{constructor(t){super(),this._bits=t}accept(t,r){return t.visitFixedNat(this,r)}covariant(t){let r=Fi(this._bits),n=!1;if(typeof t=="bigint"&&t>=BigInt(0)?n=t<r:Number.isInteger(t)&&t>=0?n=BigInt(t)<r:n=!1,n)return!0;throw new Error(`Invalid ${this.display()} argument: ${Pt(t)}`)}encodeValue(t){return Kc(t,this._bits/8)}encodeType(){let t=Math.log2(this._bits)-3;return jt(-5-t)}decodeValue(t,r){this.checkType(r);let n=No(t,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(t){return t.toString()}},Hi=class e extends ze{constructor(t){super(),this._type=t,this._blobOptimization=!1,t instanceof Ye&&t._bits===8&&(this._blobOptimization=!0)}accept(t,r){return t.visitVec(this,this._type,r)}covariant(t){let r=this._type instanceof Ye?this._type._bits:this._type instanceof rr?this._type._bits:0;if(ArrayBuffer.isView(t)&&r==t.BYTES_PER_ELEMENT*8||Array.isArray(t)&&t.every((n,i)=>{try{return this._type.covariant(n)}catch(s){throw new Error(`Invalid ${this.display()} argument:
|
|
4
4
|
|
|
5
|
-
index ${i} -> ${s.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${
|
|
5
|
+
index ${i} -> ${s.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Pt(t)}`)}encodeValue(t){let r=Ot(t.length);if(this._blobOptimization)return Et(r,new Uint8Array(t));if(ArrayBuffer.isView(t))return Et(r,new Uint8Array(t.buffer));let n=new Ne(new ArrayBuffer(r.byteLength+t.length),0);n.write(r);for(let i of t){let s=this._type.encodeValue(i);n.write(new Uint8Array(s))}return n.buffer}_buildTypeTableImpl(t){this._type.buildTypeTable(t);let r=jt(-19),n=this._type.encodeType(t);t.add(this,Et(r,n))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not a vector type");let i=Number(Gt(t));if(this._type instanceof Ye){if(this._type._bits==8)return new Uint8Array(t.read(i));if(this._type._bits==16)return new Uint16Array(t.read(i*2));if(this._type._bits==32)return new Uint32Array(t.read(i*4));if(this._type._bits==64)return new BigUint64Array(t.read(i*8))}if(this._type instanceof rr){if(this._type._bits==8)return new Int8Array(t.read(i));if(this._type._bits==16)return new Int16Array(t.read(i*2));if(this._type._bits==32)return new Int32Array(t.read(i*4));if(this._type._bits==64)return new BigInt64Array(t.read(i*8))}let s=[];for(let o=0;o<i;o++)s.push(this._type.decodeValue(t,n._type));return s}get name(){return`vec ${this._type.name}`}display(){return`vec ${this._type.display()}`}valueToString(t){return"vec {"+t.map(n=>this._type.valueToString(n)).join("; ")+"}"}},cn=class e extends ze{constructor(t){super(),this._type=t}accept(t,r){return t.visitOpt(this,this._type,r)}covariant(t){try{if(Array.isArray(t)&&(t.length===0||t.length===1&&this._type.covariant(t[0])))return!0}catch(r){throw new Error(`Invalid ${this.display()} argument: ${Pt(t)}
|
|
6
6
|
|
|
7
|
-
-> ${r.message}`)}throw new Error(`Invalid ${this.display()} argument: ${
|
|
7
|
+
-> ${r.message}`)}throw new Error(`Invalid ${this.display()} argument: ${Pt(t)}`)}encodeValue(t){return t.length===0?new Uint8Array([0]):Et(new Uint8Array([1]),this._type.encodeValue(t[0]))}_buildTypeTableImpl(t){this._type.buildTypeTable(t);let r=jt(-18),n=this._type.encodeType(t);t.add(this,Et(r,n))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not an option type");switch(yr(t)){case 0:return[];case 1:return[this._type.decodeValue(t,n._type)];default:throw new Error("Not an option value")}}get name(){return`opt ${this._type.name}`}display(){return`opt ${this._type.display()}`}valueToString(t){return t.length===0?"null":`opt ${this._type.valueToString(t[0])}`}},Pn=class e extends ze{constructor(t={}){super(),this._fields=Object.entries(t).sort((r,n)=>Re(r[0])-Re(n[0]))}accept(t,r){return t.visitRecord(this,this._fields,r)}tryAsTuple(){let t=[];for(let r=0;r<this._fields.length;r++){let[n,i]=this._fields[r];if(n!==`_${r}_`)return null;t.push(i)}return t}covariant(t){if(typeof t=="object"&&this._fields.every(([r,n])=>{if(!t.hasOwnProperty(r))throw new Error(`Record is missing key "${r}".`);try{return n.covariant(t[r])}catch(i){throw new Error(`Invalid ${this.display()} argument:
|
|
8
8
|
|
|
9
|
-
field ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${
|
|
9
|
+
field ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Pt(t)}`)}encodeValue(t){let r=this._fields.map(([i])=>t[i]),n=Un(this._fields,r,([,i],s)=>i.encodeValue(s));return Et(...n)}_buildTypeTableImpl(t){this._fields.forEach(([s,o])=>o.buildTypeTable(t));let r=jt(-20),n=Ot(this._fields.length),i=this._fields.map(([s,o])=>Et(Ot(Re(s)),o.encodeType(t)));t.add(this,Et(r,n,Et(...i)))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))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(t,c),o++;continue}let[l,d]=this._fields[s],h=Re(this._fields[s][0]),N=Re(a);if(h===N)i[l]=d.decodeValue(t,c),s++,o++;else if(N>h)if(d instanceof cn||d instanceof an)i[l]=[],s++;else throw new Error("Cannot find required field "+l);else c.decodeValue(t,c),o++}for(let[a,c]of this._fields.slice(s))if(c instanceof cn||c instanceof an)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(t){let r=this._fields.map(([i])=>t[i]);return`record {${Un(this._fields,r,([i,s],o)=>i+"="+s.valueToString(o)).join("; ")}}`}},Gi=class e extends Pn{constructor(t){let r={};t.forEach((n,i)=>r["_"+i+"_"]=n),super(r),this._components=t}accept(t,r){return t.visitTuple(this,this._components,r)}covariant(t){if(Array.isArray(t)&&t.length>=this._fields.length&&this._components.every((r,n)=>{try{return r.covariant(t[n])}catch(i){throw new Error(`Invalid ${this.display()} argument:
|
|
10
10
|
|
|
11
|
-
index ${n} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${
|
|
11
|
+
index ${n} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Pt(t)}`)}encodeValue(t){let r=Un(this._components,t,(n,i)=>n.encodeValue(i));return Et(...r)}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))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(t,o):i.push(this._components[s].decodeValue(t,o));return i}display(){return`record {${this._components.map(r=>r.display()).join("; ")}}`}valueToString(t){return`record {${Un(this._components,t,(n,i)=>n.valueToString(i)).join("; ")}}`}},ji=class e extends ze{constructor(t={}){super(),this._fields=Object.entries(t).sort((r,n)=>Re(r[0])-Re(n[0]))}accept(t,r){return t.visitVariant(this,this._fields,r)}covariant(t){if(typeof t=="object"&&Object.entries(t).length===1&&this._fields.every(([r,n])=>{try{return!t.hasOwnProperty(r)||n.covariant(t[r])}catch(i){throw new Error(`Invalid ${this.display()} argument:
|
|
12
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=Fe(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=je(-21),n=Fe(this._fields.length),i=this._fields.map(([s,o])=>ve(Fe(Rt(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(He(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(Rt(s)===Rt(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)}},dr=class t extends Ht{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)}};dr._counter=0;Pi=class extends dt{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=Fe(r.byteLength);return ve(new Uint8Array([1]),n,r)}encodeType(){return je(-24)}decodeValue(e,r){return this.checkType(r),bo(e)}get name(){return"principal"}valueToString(e){return`${this.name} "${e.toText()}"`}},An=class extends Ht{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=Fe(n.byteLength),s=ve(new Uint8Array([1]),i,n),o=new TextEncoder().encode(r),c=Fe(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=je(-22),n=Fe(this.argTypes.length),i=ve(...this.argTypes.map(d=>d.encodeType(e))),s=Fe(this.retTypes.length),o=ve(...this.retTypes.map(d=>d.encodeType(e))),c=Fe(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(fr(e)!==1)throw new Error("Cannot decode function reference");let n=bo(e),i=Number(He(e)),s=lr(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")}},Mi=class extends Ht{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=Fe(r.length);return ve(new Uint8Array([1]),n,r)}_buildTypeTableImpl(e){this._fields.forEach(([s,o])=>o.buildTypeTable(e));let r=je(-23),n=Fe(this._fields.length),i=this._fields.map(([s,o])=>{let c=new TextEncoder().encode(s),a=Fe(c.length);return ve(a,c,o.encodeType(e))});e.add(this,ve(r,n,...i))}decodeValue(e){return bo(e)}get name(){return`service {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}valueToString(e){return`service "${e.toText()}"`}};Pc=new vi,Mc=new tn,ud=new Ai,kc=new Ti,Cc=new Si,qc=new Ni,Vc=new Ri,$c=new Oi,Gc=new Bn(32),Hc=new Bn(64),jc=new er(8),Yc=new er(16),zc=new er(32),Kc=new er(64),Zc=new Gt(8),Wc=new Gt(16),Xc=new Gt(32),Jc=new Gt(64),Qc=new Pi});var _o=xe(()=>{});var ou=xe(()=>{xo();xt();_o()});var au=xe(()=>{});var Tn=xe(()=>{ou();_o();xo();po();go();xi();au()});var Su={};gn(Su,{Buffer:()=>j,INSPECT_MAX_BYTES:()=>pu,SlowBuffer:()=>_d,isBuffer:()=>Au,kMaxLength:()=>yd});function lu(){Bo=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0,r=t.length;e<r;++e)jt[e]=t[e],Et[t.charCodeAt(e)]=e;Et[45]=62,Et[95]=63}function dd(t){Bo||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 ld(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=Et[t.charCodeAt(e)]<<18|Et[t.charCodeAt(e+1)]<<12|Et[t.charCodeAt(e+2)]<<6|Et[t.charCodeAt(e+3)],o[a++]=i>>16&255,o[a++]=i>>8&255,o[a++]=i&255;return s===2?(i=Et[t.charCodeAt(e)]<<2|Et[t.charCodeAt(e+1)]>>4,o[a++]=i&255):s===1&&(i=Et[t.charCodeAt(e)]<<10|Et[t.charCodeAt(e+1)]<<4|Et[t.charCodeAt(e+2)]>>2,o[a++]=i>>8&255,o[a++]=i&255),o}function hd(t){return jt[t>>18&63]+jt[t>>12&63]+jt[t>>6&63]+jt[t&63]}function pd(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(hd(n));return i.join("")}function cu(t){Bo||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(pd(t,c,c+o>a?a:c+o));return n===1?(e=t[r-1],i+=jt[e>>2],i+=jt[e<<4&63],i+="=="):n===2&&(e=(t[r-2]<<8)+t[r-1],i+=jt[e>>10],i+=jt[e>>4&63],i+=jt[e<<2&63],i+="="),s.push(i),s.join("")}function qi(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,E=t[e+f];for(f+=T,s=E&(1<<-l)-1,E>>=-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:(E?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-d}return(E?-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,E=n?0:s-1,w=n?1:-1,x=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+E]=c&255,E+=w,c/=256,i-=8);for(o=o<<i|c,d+=i;d>0;t[r+E]=o&255,E+=w,o/=256,d-=8);t[r+E-w]|=x*128}function ki(){return j.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function tr(t,e){if(ki()<e)throw new RangeError("Invalid typed array length");return j.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e),t.__proto__=j.prototype):(t===null&&(t=new j(e)),t.length=e),t}function j(t,e,r){if(!j.TYPED_ARRAY_SUPPORT&&!(this instanceof j))return new j(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 vo(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?bd(t,e,r,n):typeof e=="string"?wd(t,e,r):xd(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 gd(t,e,r,n){return yu(e),e<=0?tr(t,e):r!==void 0?typeof n=="string"?tr(t,e).fill(r,n):tr(t,e).fill(r):tr(t,e)}function vo(t,e){if(yu(e),t=tr(t,e<0?0:Ao(e)|0),!j.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function wd(t,e,r){if((typeof r!="string"||r==="")&&(r="utf8"),!j.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=gu(e,r)|0;t=tr(t,n);var i=t.write(e,r);return i!==n&&(t=t.slice(0,i)),t}function Eo(t,e){var r=e.length<0?0:Ao(e.length)|0;t=tr(t,r);for(var n=0;n<r;n+=1)t[n]=e[n]&255;return t}function bd(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),j.TYPED_ARRAY_SUPPORT?(t=e,t.__proto__=j.prototype):t=Eo(t,e),t}function xd(t,e){if(Yt(e)){var r=Ao(e.length)|0;return t=tr(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"||$d(e.length)?tr(t,0):Eo(t,e);if(e.type==="Buffer"&&hu(e.data))return Eo(t,e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function Ao(t){if(t>=ki())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ki().toString(16)+" bytes");return t|0}function _d(t){return+t!=t&&(t=0),j.alloc(+t)}function Yt(t){return!!(t!=null&&t._isBuffer)}function gu(t,e){if(Yt(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 Ci(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 Ci(t).length;e=(""+e).toLowerCase(),n=!0}}function Ed(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 Id(this,e,r);case"utf8":case"utf-8":return xu(this,e,r);case"ascii":return Od(this,e,r);case"latin1":case"binary":return Fd(this,e,r);case"base64":return Nd(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ud(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function Or(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=j.from(e,n)),Yt(e))return e.length===0?-1:uu(t,e,r,n,i);if(typeof e=="number")return e=e&255,j.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(E,w){return s===1?E[w]:E.readUInt16BE(w*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 Bd(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 vd(t,e,r,n){return Gi(Ci(e,t.length-r),t,r,n)}function bu(t,e,r,n){return Gi(qd(e),t,r,n)}function Ad(t,e,r,n){return bu(t,e,r,n)}function Td(t,e,r,n){return Gi(vu(e),t,r,n)}function Sd(t,e,r,n){return Gi(Vd(e,t.length-r),t,r,n)}function Nd(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 Rd(n)}function Rd(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 Od(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 Fd(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 Id(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+=Cd(t[s]);return i}function Ud(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 De(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 ht(t,e,r,n,i,s){if(!Yt(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 Vi(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 $i(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 Md(t){if(t=kd(t).replace(Pd,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function kd(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function Cd(t){return t<16?"0"+t.toString(16):t.toString(16)}function Ci(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 qd(t){for(var e=[],r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function Vd(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 dd(Md(t))}function Gi(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 $d(t){return t!==t}function Au(t){return t!=null&&(!!t._isBuffer||Tu(t)||Gd(t))}function Tu(t){return!!t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function Gd(t){return typeof t.readFloatLE=="function"&&typeof t.slice=="function"&&Tu(t.slice(0,0))}var jt,Et,ld,Bo,md,hu,pu,yd,fu,Pd,Nu=xe(()=>{jt=[],Et=[],ld=typeof Uint8Array<"u"?Uint8Array:Array,Bo=!1;md={}.toString,hu=Array.isArray||function(t){return md.call(t)=="[object Array]"};pu=50;j.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;yd=ki();j.poolSize=8192;j._augment=function(t){return t.__proto__=j.prototype,t};j.from=function(t,e,r){return mu(null,t,e,r)};j.TYPED_ARRAY_SUPPORT&&(j.prototype.__proto__=Uint8Array.prototype,j.__proto__=Uint8Array);j.alloc=function(t,e,r){return gd(null,t,e,r)};j.allocUnsafe=function(t){return vo(null,t)};j.allocUnsafeSlow=function(t){return vo(null,t)};j.isBuffer=Au;j.compare=function(e,r){if(!Yt(e)||!Yt(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};j.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}};j.concat=function(e,r){if(!hu(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return j.alloc(0);var n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;var i=j.allocUnsafe(r),s=0;for(n=0;n<e.length;++n){var o=e[n];if(!Yt(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(i,s),s+=o.length}return i};j.byteLength=gu;j.prototype._isBuffer=!0;j.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)Or(this,r,r+1);return this};j.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)Or(this,r,r+3),Or(this,r+1,r+2);return this};j.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)Or(this,r,r+7),Or(this,r+1,r+6),Or(this,r+2,r+5),Or(this,r+3,r+4);return this};j.prototype.toString=function(){var e=this.length|0;return e===0?"":arguments.length===0?xu(this,0,e):Ed.apply(this,arguments)};j.prototype.equals=function(e){if(!Yt(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:j.compare(this,e)===0};j.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+">"};j.prototype.compare=function(e,r,n,i,s){if(!Yt(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};j.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};j.prototype.indexOf=function(e,r,n){return wu(this,e,r,n,!0)};j.prototype.lastIndexOf=function(e,r,n){return wu(this,e,r,n,!1)};j.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 Bd(this,e,r,n);case"utf8":case"utf-8":return vd(this,e,r,n);case"ascii":return bu(this,e,r,n);case"latin1":case"binary":return Ad(this,e,r,n);case"base64":return Td(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Sd(this,e,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};j.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};fu=4096;j.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(j.TYPED_ARRAY_SUPPORT)i=this.subarray(e,r),i.__proto__=j.prototype;else{var s=r-e;i=new j(s,void 0);for(var o=0;o<s;++o)i[o]=this[o+e]}return i};j.prototype.readUIntLE=function(e,r,n){e=e|0,r=r|0,n||De(e,r,this.length);for(var i=this[e],s=1,o=0;++o<r&&(s*=256);)i+=this[e+o]*s;return i};j.prototype.readUIntBE=function(e,r,n){e=e|0,r=r|0,n||De(e,r,this.length);for(var i=this[e+--r],s=1;r>0&&(s*=256);)i+=this[e+--r]*s;return i};j.prototype.readUInt8=function(e,r){return r||De(e,1,this.length),this[e]};j.prototype.readUInt16LE=function(e,r){return r||De(e,2,this.length),this[e]|this[e+1]<<8};j.prototype.readUInt16BE=function(e,r){return r||De(e,2,this.length),this[e]<<8|this[e+1]};j.prototype.readUInt32LE=function(e,r){return r||De(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};j.prototype.readUInt32BE=function(e,r){return r||De(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};j.prototype.readIntLE=function(e,r,n){e=e|0,r=r|0,n||De(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};j.prototype.readIntBE=function(e,r,n){e=e|0,r=r|0,n||De(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};j.prototype.readInt8=function(e,r){return r||De(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};j.prototype.readInt16LE=function(e,r){r||De(e,2,this.length);var n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};j.prototype.readInt16BE=function(e,r){r||De(e,2,this.length);var n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};j.prototype.readInt32LE=function(e,r){return r||De(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};j.prototype.readInt32BE=function(e,r){return r||De(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};j.prototype.readFloatLE=function(e,r){return r||De(e,4,this.length),qi(this,e,!0,23,4)};j.prototype.readFloatBE=function(e,r){return r||De(e,4,this.length),qi(this,e,!1,23,4)};j.prototype.readDoubleLE=function(e,r){return r||De(e,8,this.length),qi(this,e,!0,52,8)};j.prototype.readDoubleBE=function(e,r){return r||De(e,8,this.length),qi(this,e,!1,52,8)};j.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;ht(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};j.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;ht(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};j.prototype.writeUInt8=function(e,r,n){return e=+e,r=r|0,n||ht(this,e,r,1,255,0),j.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[r]=e&255,r+1};j.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r|0,n||ht(this,e,r,2,65535,0),j.TYPED_ARRAY_SUPPORT?(this[r]=e&255,this[r+1]=e>>>8):Vi(this,e,r,!0),r+2};j.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r|0,n||ht(this,e,r,2,65535,0),j.TYPED_ARRAY_SUPPORT?(this[r]=e>>>8,this[r+1]=e&255):Vi(this,e,r,!1),r+2};j.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r|0,n||ht(this,e,r,4,4294967295,0),j.TYPED_ARRAY_SUPPORT?(this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255):$i(this,e,r,!0),r+4};j.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r|0,n||ht(this,e,r,4,4294967295,0),j.TYPED_ARRAY_SUPPORT?(this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255):$i(this,e,r,!1),r+4};j.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r|0,!i){var s=Math.pow(2,8*n-1);ht(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};j.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r|0,!i){var s=Math.pow(2,8*n-1);ht(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};j.prototype.writeInt8=function(e,r,n){return e=+e,r=r|0,n||ht(this,e,r,1,127,-128),j.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[r]=e&255,r+1};j.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r|0,n||ht(this,e,r,2,32767,-32768),j.TYPED_ARRAY_SUPPORT?(this[r]=e&255,this[r+1]=e>>>8):Vi(this,e,r,!0),r+2};j.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r|0,n||ht(this,e,r,2,32767,-32768),j.TYPED_ARRAY_SUPPORT?(this[r]=e>>>8,this[r+1]=e&255):Vi(this,e,r,!1),r+2};j.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r|0,n||ht(this,e,r,4,2147483647,-2147483648),j.TYPED_ARRAY_SUPPORT?(this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24):$i(this,e,r,!0),r+4};j.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r|0,n||ht(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),j.TYPED_ARRAY_SUPPORT?(this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255):$i(this,e,r,!1),r+4};j.prototype.writeFloatLE=function(e,r,n){return Eu(this,e,r,!0,n)};j.prototype.writeFloatBE=function(e,r,n){return Eu(this,e,r,!1,n)};j.prototype.writeDoubleLE=function(e,r,n){return Bu(this,e,r,!0,n)};j.prototype.writeDoubleBE=function(e,r,n){return Bu(this,e,r,!1,n)};j.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||!j.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};j.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"&&!j.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=Yt(e)?e:Ci(new j(e,i).toString()),a=c.length;for(o=0;o<n-r;++o)this[o+r]=c[o%a]}return this};Pd=/[^+\/0-9A-Za-z-_]/g});var Sn=Ge((Zm,Hi)=>{var Fr=(Nu(),ml(Su));if(Fr&&Fr.default){Hi.exports=Fr.default;for(let t in Fr)Hi.exports[t]=Fr[t]}else Fr&&(Hi.exports=Fr)});var Nn=Ge((Ru,ji)=>{(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 E(U){var M,Y,z,G=F.prototype={constructor:F,toString:null,valueOf:null},ee=new F(1),D=20,ae=4,le=-7,_e=21,he=-1e7,K=1e7,ce=!1,H=1,k=0,W={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},L="0123456789abcdefghijklmnopqrstuvwxyz",re=!0;function F(u,h){var p,A,_,v,N,g,B,R,S=this;if(!(S instanceof F))return new F(u,h);if(h==null){if(u&&u._isBigNumber===!0){S.s=u.s,!u.c||u.e>K?S.c=S.e=null:u.e<he?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>K?S.c=S.e=null:(S.e=v,S.c=[u]);return}R=String(u)}else{if(!r.test(R=String(u)))return z(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(O(h,2,L.length,"Base"),h==10&&re)return S=new F(u),se(S,D+S.e+1,ae);if(R=String(u),g=typeof u=="number"){if(u*0!=0)return z(S,R,g,h);if(S.s=1/u<0?(R=R.slice(1),-1):1,F.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=L.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(!_&&(R==R.toUpperCase()&&(R=R.toLowerCase())||R==R.toLowerCase()&&(R=R.toUpperCase()))){_=!0,N=-1,v=0;continue}return z(S,String(u),g,h)}g=!1,R=Y(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&&F.DEBUG&&B>15&&(u>d||u!==i(u)))throw Error(o+S.s*u);if((v=v-N-1)>K)S.c=S.e=null;else if(v<he)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]}F.clone=E,F.ROUND_UP=0,F.ROUND_DOWN=1,F.ROUND_CEIL=2,F.ROUND_FLOOR=3,F.ROUND_HALF_UP=4,F.ROUND_HALF_DOWN=5,F.ROUND_HALF_EVEN=6,F.ROUND_HALF_CEIL=7,F.ROUND_HALF_FLOOR=8,F.EUCLID=9,F.config=F.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,T,h),D=p),u.hasOwnProperty(h="ROUNDING_MODE")&&(p=u[h],O(p,0,8,h),ae=p),u.hasOwnProperty(h="EXPONENTIAL_AT")&&(p=u[h],p&&p.pop?(O(p[0],-T,0,h),O(p[1],0,T,h),le=p[0],_e=p[1]):(O(p,-T,T,h),le=-(_e=p<0?-p:p))),u.hasOwnProperty(h="RANGE"))if(p=u[h],p&&p.pop)O(p[0],-T,-1,h),O(p[1],1,T,h),he=p[0],K=p[1];else if(O(p,-T,T,h),p)he=-(K=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))ce=p;else throw ce=!p,Error(s+"crypto unavailable");else ce=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),H=p),u.hasOwnProperty(h="POW_PRECISION")&&(p=u[h],O(p,0,T,h),k=p),u.hasOwnProperty(h="FORMAT"))if(p=u[h],typeof p=="object")W=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))re=p.slice(0,10)=="0123456789",L=p;else throw Error(s+h+" invalid: "+p)}else throw Error(s+"Object expected: "+u);return{DECIMAL_PLACES:D,ROUNDING_MODE:ae,EXPONENTIAL_AT:[le,_e],RANGE:[he,K],CRYPTO:ce,MODULO_MODE:H,POW_PRECISION:k,FORMAT:W,ALPHABET:L}},F.isBigNumber=function(u){if(!u||u._isBigNumber!==!0)return!1;if(!F.DEBUG)return!0;var h,p,A=u.c,_=u.e,v=u.s;e:if({}.toString.call(A)=="[object Array]"){if((v===1||v===-1)&&_>=-T&&_<=T&&_===i(_)){if(A[0]===0){if(_===0&&A.length===1)return!0;break e}if(h=(_+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&&_===null&&(v===null||v===1||v===-1))return!0;throw Error(s+"Invalid BigNumber: "+u)},F.maximum=F.max=function(){return fe(arguments,-1)},F.minimum=F.min=function(){return fe(arguments,1)},F.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,_,v,N,g,B=0,R=[],S=new F(ee);if(p==null?p=D:O(p,0,T),N=n(p/a),ce)if(crypto.getRandomValues){for(A=crypto.getRandomValues(new Uint32Array(N*=2));B<N;)g=A[B]*131072+(A[B+1]>>>11),g>=9e15?(_=crypto.getRandomValues(new Uint32Array(2)),A[B]=_[0],A[B+1]=_[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 ce=!1,Error(s+"crypto unavailable");if(!ce)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}}(),F.sum=function(){for(var u=1,h=arguments,p=new F(h[0]);u<h.length;)p=p.plus(h[u++]);return p},Y=function(){var u="0123456789";function h(p,A,_,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]>_-1&&(g[N+1]==null&&(g[N+1]=0),g[N+1]+=g[N]/_|0,g[N]%=_)}return g.reverse()}return function(p,A,_,v,N){var g,B,R,S,$,X,te,me,Be=p.indexOf("."),Se=D,ye=ae;for(Be>=0&&(S=k,k=0,p=p.replace(".",""),me=new F(A),X=me.pow(p.length-Be),k=S,me.c=h(Z(x(X.c),X.e,"0"),10,_,u),me.e=me.c.length),te=h(p,A,_,N?(g=L,u):(g=u,L)),R=S=te.length;te[--S]==0;te.pop());if(!te[0])return g.charAt(0);if(Be<0?--R:(X.c=te,X.e=R,X.s=v,X=M(X,me,Se,ye,_),te=X.c,$=X.r,R=X.e),B=R+Se+1,Be=te[B],S=_/2,$=$||B<0||te[B+1]!=null,$=ye<4?(Be!=null||$)&&(ye==0||ye==(X.s<0?3:2)):Be>S||Be==S&&(ye==4||$||ye==6&&te[B-1]&1||ye==(X.s<0?8:7)),B<1||!te[0])p=$?Z(g.charAt(1),-Se,g.charAt(0)):g.charAt(0);else{if(te.length=B,$)for(--_;++te[--B]>_;)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=Z(p,R,g.charAt(0))}return p}}(),M=function(){function u(A,_,v){var N,g,B,R,S=0,$=A.length,X=_%f,te=_/f|0;for(A=A.slice();$--;)B=A[$]%f,R=A[$]/f|0,N=te*B+R*X,g=X*B+N%f*f+S,S=(g/v|0)+(N/f|0)+te*R,A[$]=g%v;return S&&(A=[S].concat(A)),A}function h(A,_,v,N){var g,B;if(v!=N)B=v>N?1:-1;else for(g=B=0;g<v;g++)if(A[g]!=_[g]){B=A[g]>_[g]?1:-1;break}return B}function p(A,_,v,N){for(var g=0;v--;)A[v]-=g,g=A[v]<_[v]?1:0,A[v]=g*N+A[v]-_[v];for(;!A[0]&&A.length>1;A.splice(0,1));}return function(A,_,v,N,g){var B,R,S,$,X,te,me,Be,Se,ye,ne,ke,Qt,Ar,Tr,ut,Ee,ft=A.s==_.s?1:-1,rt=A.c,Ie=_.c;if(!rt||!rt[0]||!Ie||!Ie[0])return new F(!A.s||!_.s||(rt?Ie&&rt[0]==Ie[0]:!Ie)?NaN:rt&&rt[0]==0||!Ie?ft*0:ft/0);for(Be=new F(ft),Se=Be.c=[],R=A.e-_.e,ft=v+R+1,g||(g=c,R=w(A.e/a)-w(_.e/a),ft=ft/a|0),S=0;Ie[S]==(rt[S]||0);S++);if(Ie[S]>(rt[S]||0)&&R--,ft<0)Se.push(1),$=!0;else{for(Ar=rt.length,ut=Ie.length,S=0,ft+=2,X=i(g/(Ie[0]+1)),X>1&&(Ie=u(Ie,X,g),rt=u(rt,X,g),ut=Ie.length,Ar=rt.length),Qt=ut,ye=rt.slice(0,ut),ne=ye.length;ne<ut;ye[ne++]=0);Ee=Ie.slice(),Ee=[0].concat(Ee),Tr=Ie[0],Ie[1]>=g/2&&Tr++;do{if(X=0,B=h(Ie,ye,ut,ne),B<0){if(ke=ye[0],ut!=ne&&(ke=ke*g+(ye[1]||0)),X=i(ke/Tr),X>1)for(X>=g&&(X=g-1),te=u(Ie,X,g),me=te.length,ne=ye.length;h(te,ye,me,ne)==1;)X--,p(te,ut<me?Ee:Ie,me,g),me=te.length,B=1;else X==0&&(B=X=1),te=Ie.slice(),me=te.length;if(me<ne&&(te=[0].concat(te)),p(ye,te,ne,g),ne=ye.length,B==-1)for(;h(Ie,ye,ut,ne)<1;)X++,p(ye,ut<ne?Ee:Ie,ne,g),ne=ye.length}else B===0&&(X++,ye=[0]);Se[S++]=X,ye[0]?ye[ne++]=rt[Qt]||0:(ye=[rt[Qt]],ne=1)}while((Qt++<Ar||ye[0]!=null)&&ft--);$=ye[0]!=null,Se[0]||Se.splice(0,1)}if(g==c){for(S=1,ft=Se[0];ft>=10;ft/=10,S++);se(Be,v+(Be.e=S+R*a-1)+1,N,$)}else Be.e=R,Be.r=+$;return Be}}();function m(u,h,p,A){var _,v,N,g,B;if(p==null?p=ae:O(p,0,8),!u.c)return u.toString();if(_=u.c[0],N=u.e,h==null)B=x(u.c),B=A==1||A==2&&(N<=le||N>=_e)?V(B,N):Z(B,N,"0");else if(u=se(new F(u),h,p),v=u.e,B=x(u.c),g=B.length,A==1||A==2&&(h<=v||v<=le)){for(;g<h;B+="0",g++);B=V(B,v)}else if(h-=N,B=Z(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&&_?"-"+B:B}function fe(u,h){for(var p,A,_=1,v=new F(u[0]);_<u.length;_++)A=new F(u[_]),(!A.s||(p=I(v,A))===h||p===0&&v.s===h)&&(v=A);return v}function ie(u,h,p){for(var A=1,_=h.length;!h[--_];h.pop());for(_=h[0];_>=10;_/=10,A++);return(p=A+p*a-1)>K?u.c=u.e=null:p<he?u.c=[u.e=0]:(u.e=p,u.c=h),u}z=function(){var u=/^(-?)0([xbo])(?=\w[\w.]*$)/i,h=/^([^.]+)\.$/,p=/^\.([^.]+)$/,A=/^-?(Infinity|NaN)$/,_=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(v,N,g,B){var R,S=g?N:N.replace(_,"");if(A.test(S))v.s=isNaN(S)?null:S<0?-1:1;else{if(!g&&(S=S.replace(u,function($,X,te){return R=(te=te.toLowerCase())=="x"?16:te=="b"?2:8,!B||B==R?X:$}),B&&(R=B,S=S.replace(h,"$1").replace(p,"0.$1")),N!=S))return new F(S,R);if(F.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 _,v,N,g,B,R,S,$=u.c,X=l;if($){e:{for(_=1,g=$[0];g>=10;g/=10,_++);if(v=h-_,v<0)v+=a,N=h,B=$[R=0],S=i(B/X[_-N-1]%10);else if(R=n((v+1)/a),R>=$.length)if(A){for(;$.length<=R;$.push(0));B=S=0,_=1,v%=a,N=v-a+1}else break e;else{for(B=g=$[R],_=1;g>=10;g/=10,_++);v%=a,N=v-a+_,S=N<0?0:i(B/X[_-N-1]%10)}if(A=A||h<0||$[R+1]!=null||(N<0?B:B%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/X[_-N]:0:$[R-1])%10&1||p==(u.s<0?8:7)),h<1||!$[0])return $.length=0,A?(h-=u.e+1,$[0]=X[(a-h%a)%a],u.e=-h||0):$[0]=u.e=0,u;if(v==0?($.length=R,g=1,R--):($.length=R+1,g=X[a-v],$[R]=N>0?i(B/X[_-N]%X[N])*g:0),A)for(;;)if(R==0){for(v=1,N=$[0];N>=10;N/=10,v++);for(N=$[0]+=g,g=1;N>=10;N/=10,g++);v!=g&&(u.e++,$[0]==c&&($[0]=1));break}else{if($[R]+=g,$[R]!=c)break;$[R--]=0,g=1}for(v=$.length;$[--v]===0;$.pop());}u.e>K?u.c=u.e=null:u.e<he&&(u.c=[u.e=0])}return u}function Q(u){var h,p=u.e;return p===null?u.toString():(h=x(u.c),h=p<=le||p>=_e?V(h,p):Z(h,p,"0"),u.s<0?"-"+h:h)}return G.absoluteValue=G.abs=function(){var u=new F(this);return u.s<0&&(u.s=1),u},G.comparedTo=function(u,h){return I(this,new F(u,h))},G.decimalPlaces=G.dp=function(u,h){var p,A,_,v=this;if(u!=null)return O(u,0,T),h==null?h=ae:O(h,0,8),se(new F(v),u+v.e+1,h);if(!(p=v.c))return null;if(A=((_=p.length-1)-w(this.e/a))*a,_=p[_])for(;_%10==0;_/=10,A--);return A<0&&(A=0),A},G.dividedBy=G.div=function(u,h){return M(this,new F(u,h),D,ae)},G.dividedToIntegerBy=G.idiv=function(u,h){return M(this,new F(u,h),0,1)},G.exponentiatedBy=G.pow=function(u,h){var p,A,_,v,N,g,B,R,S,$=this;if(u=new F(u),u.c&&!u.isInteger())throw Error(s+"Exponent not an integer: "+Q(u));if(h!=null&&(h=new F(h)),g=u.e>14,!$.c||!$.c[0]||$.c[0]==1&&!$.e&&$.c.length==1||!u.c||!u.c[0])return S=new F(Math.pow(+Q($),g?u.s*(2-q(u)):+Q(u))),h?S.mod(h):S;if(B=u.s<0,h){if(h.c?!h.c[0]:!h.s)return new F(NaN);A=!B&&$.isInteger()&&h.isInteger(),A&&($=$.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 v=$.s<0&&q(u)?-0:0,$.e>-1&&(v=1/v),new F(B?1/v:v);k&&(v=n(k/a+2))}for(g?(p=new F(.5),B&&(u.s=1),R=q(u)):(_=Math.abs(+Q(u)),R=_%2),S=new F(ee);;){if(R){if(S=S.times($),!S.c)break;v?S.c.length>v&&(S.c.length=v):A&&(S=S.mod(h))}if(_){if(_=i(_/2),_===0)break;R=_%2}else if(u=u.times(p),se(u,u.e+1,1),u.e>14)R=q(u);else{if(_=+Q(u),_===0)break;R=_%2}$=$.times($),v?$.c&&$.c.length>v&&($.c.length=v):A&&($=$.mod(h))}return A?S:(B&&(S=ee.div(S)),h?S.mod(h):v?se(S,k,ae,N):S)},G.integerValue=function(u){var h=new F(this);return u==null?u=ae:O(u,0,8),se(h,h.e+1,u)},G.isEqualTo=G.eq=function(u,h){return I(this,new F(u,h))===0},G.isFinite=function(){return!!this.c},G.isGreaterThan=G.gt=function(u,h){return I(this,new F(u,h))>0},G.isGreaterThanOrEqualTo=G.gte=function(u,h){return(h=I(this,new F(u,h)))===1||h===0},G.isInteger=function(){return!!this.c&&w(this.e/a)>this.c.length-2},G.isLessThan=G.lt=function(u,h){return I(this,new F(u,h))<0},G.isLessThanOrEqualTo=G.lte=function(u,h){return(h=I(this,new F(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,_,v,N=this,g=N.s;if(u=new F(u,h),h=u.s,!g||!h)return new F(NaN);if(g!=h)return u.s=-h,N.plus(u);var B=N.e/a,R=u.e/a,S=N.c,$=u.c;if(!B||!R){if(!S||!$)return S?(u.s=-h,u):new F($?N:NaN);if(!S[0]||!$[0])return $[0]?(u.s=-h,u):new F(S[0]?N:ae==3?-0:0)}if(B=w(B),R=w(R),S=S.slice(),g=B-R){for((v=g<0)?(g=-g,_=S):(R=B,_=$),_.reverse(),h=g;h--;_.push(0));_.reverse()}else for(A=(v=(g=S.length)<(h=$.length))?g:h,g=h=0;h<A;h++)if(S[h]!=$[h]){v=S[h]<$[h];break}if(v&&(_=S,S=$,$=_,u.s=-u.s),h=(A=$.length)-(p=S.length),h>0)for(;h--;S[p++]=0);for(h=c-1;A>g;){if(S[--A]<$[A]){for(p=A;p&&!S[--p];S[p]=h);--S[p],S[A]+=c}S[A]-=$[A]}for(;S[0]==0;S.splice(0,1),--R);return S[0]?ie(u,S,R):(u.s=ae==3?-1:1,u.c=[u.e=0],u)},G.modulo=G.mod=function(u,h){var p,A,_=this;return u=new F(u,h),!_.c||!u.s||u.c&&!u.c[0]?new F(NaN):!u.c||_.c&&!_.c[0]?new F(_):(H==9?(A=u.s,u.s=1,p=M(_,u,0,3),u.s=A,p.s*=A):p=M(_,u,0,H),u=_.minus(p.times(u)),!u.c[0]&&H==1&&(u.s=_.s),u)},G.multipliedBy=G.times=function(u,h){var p,A,_,v,N,g,B,R,S,$,X,te,me,Be,Se,ye=this,ne=ye.c,ke=(u=new F(u,h)).c;if(!ne||!ke||!ne[0]||!ke[0])return!ye.s||!u.s||ne&&!ne[0]&&!ke||ke&&!ke[0]&&!ne?u.c=u.e=u.s=null:(u.s*=ye.s,!ne||!ke?u.c=u.e=null:(u.c=[0],u.e=0)),u;for(A=w(ye.e/a)+w(u.e/a),u.s*=ye.s,B=ne.length,$=ke.length,B<$&&(me=ne,ne=ke,ke=me,_=B,B=$,$=_),_=B+$,me=[];_--;me.push(0));for(Be=c,Se=f,_=$;--_>=0;){for(p=0,X=ke[_]%Se,te=ke[_]/Se|0,N=B,v=_+N;v>_;)R=ne[--N]%Se,S=ne[N]/Se|0,g=te*R+S*X,R=X*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 F(this);return u.s=-u.s||null,u},G.plus=function(u,h){var p,A=this,_=A.s;if(u=new F(u,h),h=u.s,!_||!h)return new F(NaN);if(_!=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 F(_/0);if(!g[0]||!B[0])return B[0]?u:new F(g[0]?A:_*0)}if(v=w(v),N=w(N),g=g.slice(),_=v-N){for(_>0?(N=v,p=B):(_=-_,p=g),p.reverse();_--;p.push(0));p.reverse()}for(_=g.length,h=B.length,_-h<0&&(p=B,B=g,g=p,h=_),_=0;h;)_=(g[--h]=g[h]+B[h]+_)/c|0,g[h]=c===g[h]?0:g[h]%c;return _&&(g=[_].concat(g),++N),ie(u,g,N)},G.precision=G.sd=function(u,h){var p,A,_,v=this;if(u!=null&&u!==!!u)return O(u,1,T),h==null?h=ae:O(h,0,8),se(new F(v),u,h);if(!(p=v.c))return null;if(_=p.length-1,A=_*a+1,_=p[_]){for(;_%10==0;_/=10,A--);for(_=p[0];_>=10;_/=10,A++);}return u&&v.e+1>A&&(A=v.e+1),A},G.shiftedBy=function(u){return O(u,-d,d),this.times("1e"+u)},G.squareRoot=G.sqrt=function(){var u,h,p,A,_,v=this,N=v.c,g=v.s,B=v.e,R=D+4,S=new F("0.5");if(g!==1||!N||!N[0])return new F(!g||g<0&&(!N||N[0])?NaN:N?v:1/0);if(g=Math.sqrt(+Q(v)),g==0||g==1/0?(h=x(N),(h.length+B)%2==0&&(h+="0"),g=Math.sqrt(+h),B=w((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 F(h)):p=new F(g+""),p.c[0]){for(B=p.e,g=B+R,g<3&&(g=0);;)if(_=p,p=S.times(_.plus(M(v,_,R,1))),x(_.c).slice(0,g)===(h=x(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(_,_.e+D+2,0),_.times(_).eq(v))){p=_;break}R+=4,g+=4,A=1}else{(!+h||!+h.slice(1)&&h.charAt(0)=="5")&&(se(p,p.e+D+2,1),u=!p.times(p).eq(v));break}}return se(p,p.e+D+1,ae,u)},G.toExponential=function(u,h){return u!=null&&(O(u,0,T),u++),m(this,u,h,1)},G.toFixed=function(u,h){return u!=null&&(O(u,0,T),u=u+this.e+1),m(this,u,h)},G.toFormat=function(u,h,p){var A,_=this;if(p==null)u!=null&&h&&typeof h=="object"?(p=h,h=null):u&&typeof u=="object"?(p=u,u=h=null):p=W;else if(typeof p!="object")throw Error(s+"Argument not an object: "+p);if(A=_.toFixed(u,h),_.c){var v,N=A.split("."),g=+p.groupSize,B=+p.secondaryGroupSize,R=p.groupSeparator||"",S=N[0],$=N[1],X=_.s<0,te=X?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)),X&&(S="-"+S)}A=$?S+(p.decimalSeparator||"")+((B=+p.fractionGroupSize)?$.replace(new RegExp("\\d{"+B+"}\\B","g"),"$&"+(p.fractionGroupSeparator||"")):$):S}return(p.prefix||"")+A+(p.suffix||"")},G.toFraction=function(u){var h,p,A,_,v,N,g,B,R,S,$,X,te=this,me=te.c;if(u!=null&&(g=new F(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 F(te);for(h=new F(ee),R=p=new F(ee),A=B=new F(ee),X=x(me),v=h.e=X.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=K,K=1/0,g=new F(X),B.c[0]=0;S=M(g,h,0,1),_=p.plus(S.times(A)),_.comparedTo(u)!=1;)p=A,A=_,R=B.plus(S.times(_=R)),B=_,h=g.minus(S.times(_=h)),g=_;return _=M(u.minus(p),A,0,1),B=B.plus(_.times(R)),p=p.plus(_.times(A)),B.s=R.s=te.s,v=v*2,$=M(R,A,v,ae).minus(te).abs().comparedTo(M(B,p,v,ae).minus(te).abs())<1?[R,A]:[B,p],K=N,$},G.toNumber=function(){return+Q(this)},G.toPrecision=function(u,h){return u!=null&&O(u,1,T),m(this,u,h,2)},G.toString=function(u){var h,p=this,A=p.s,_=p.e;return _===null?A?(h="Infinity",A<0&&(h="-"+h)):h="NaN":(u==null?h=_<=le||_>=_e?V(x(p.c),_):Z(x(p.c),_,"0"):u===10&&re?(p=se(new F(p),D+_+1,ae),h=Z(x(p.c),p.e,"0")):(O(u,2,L.length,"Base"),h=Y(Z(x(p.c),_,"0"),10,u,A,!0)),A<0&&p.c[0]&&(h="-"+h)),h},G.valueOf=G.toJSON=function(){return Q(this)},G._isBigNumber=!0,U!=null&&F.set(U),F}function w(U){var M=U|0;return U>0||U===M?M:M-1}function x(U){for(var M,Y,z=1,G=U.length,ee=U[0]+"";z<G;){for(M=U[z++]+"",Y=a-M.length;Y--;M="0"+M);ee+=M}for(G=ee.length;ee.charCodeAt(--G)===48;);return ee.slice(0,G+1||1)}function I(U,M){var Y,z,G=U.c,ee=M.c,D=U.s,ae=M.s,le=U.e,_e=M.e;if(!D||!ae)return null;if(Y=G&&!G[0],z=ee&&!ee[0],Y||z)return Y?z?0:-ae:D;if(D!=ae)return D;if(Y=D<0,z=le==_e,!G||!ee)return z?0:!G^Y?1:-1;if(!z)return le>_e^Y?1:-1;for(ae=(le=G.length)<(_e=ee.length)?le:_e,D=0;D<ae;D++)if(G[D]!=ee[D])return G[D]>ee[D]^Y?1:-1;return le==_e?0:le>_e^Y?1:-1}function O(U,M,Y,z){if(U<M||U>Y||U!==i(U))throw Error(s+(z||"Argument")+(typeof U=="number"?U<M||U>Y?" out of range: ":" not an integer: ":" not a primitive number: ")+String(U))}function q(U){var M=U.c.length-1;return w(U.e/a)==M&&U.c[M]%2!=0}function V(U,M){return(U.length>1?U.charAt(0)+"."+U.slice(1):U)+(M<0?"e":"e+")+M}function Z(U,M,Y){var z,G;if(M<0){for(G=Y+".";++M;G+=Y);U=G+U}else if(z=U.length,++M>z){for(G=Y,M-=z;--M;G+=Y);U+=G}else M<z&&(U=U.slice(0,M)+"."+U.slice(M));return U}e=E(),e.default=e.BigNumber=e,typeof define=="function"&&define.amd?define(function(){return e}):typeof ji<"u"&&ji.exports?ji.exports=e:(t||(t=typeof self<"u"&&self?self:window),t.BigNumber=e)})(Ru)});var Fu=Ge((Wm,Ou)=>{Ou.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,E=r.pushTrue,w=r.pushFalse,x=r.pushUndefined,I=r.pushNull,O=r.pushInfinity,q=r.pushInfinityNeg,V=r.pushNaN,Z=r.pushNaNNeg,U=r.pushArrayStart,M=r.pushArrayStartFixed,Y=r.pushArrayStartFixed32,z=r.pushArrayStartFixed64,G=r.pushObjectStart,ee=r.pushObjectStartFixed,D=r.pushObjectStartFixed32,ae=r.pushObjectStartFixed64,le=r.pushByteString,_e=r.pushByteStringStart,he=r.pushUtf8String,K=r.pushUtf8StringStart,ce=r.pushSimpleUnassigned,H=r.pushTagStart,k=r.pushTagStart4,W=r.pushTagStart8,L=r.pushTagUnassigned,re=r.pushBreak,F=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=ul[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 A(b){return b=b|0,Q(1)|0?1:(s(i[m+1|0]|0),m=m+2|0,0)}function _(b){return b=b|0,Q(2)|0?1:(s(u(m+1|0)|0),m=m+3|0,0)}function v(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:(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(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 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(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 $(b){return b=b|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 X(b){b=b|0;var we=0,be=0,ge=0;return ge=b-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(b){b=b|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(b){b=b|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(b){b=b|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(b){return b=b|0,1}function ye(b){return b=b|0,_e(),m=m+1|0,0}function ne(b){b=b|0;var we=0,be=0,ge=0;return ge=b-96|0,Q(ge|0)|0?1:(we=m+1|0,be=(m+1|0)+(ge|0)|0,he(we|0,be|0),m=be|0,0)}function ke(b){b=b|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:(he(we|0,be|0),m=be|0,0)}function Qt(b){b=b|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:(he(we|0,be|0),m=be|0,0)}function Ar(b){b=b|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:(he(we|0,be|0),m=be|0,0)}function Tr(b){return b=b|0,1}function ut(b){return b=b|0,K(),m=m+1|0,0}function Ee(b){return b=b|0,M(b-128|0),m=m+1|0,0}function ft(b){return b=b|0,Q(1)|0?1:(M(i[m+1|0]|0),m=m+2|0,0)}function rt(b){return b=b|0,Q(2)|0?1:(M(u(m+1|0)|0),m=m+3|0,0)}function Ie(b){return b=b|0,Q(4)|0?1:(Y(u(m+1|0)|0,u(m+3|0)|0),m=m+5|0,0)}function j0(b){return b=b|0,Q(8)|0?1:(z(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 Y0(b){return b=b|0,U(),m=m+1|0,0}function Ue(b){b=b|0;var we=0;return we=b-160|0,Q(we|0)|0?1:(ee(we|0),m=m+1|0,0)}function z0(b){return b=b|0,Q(1)|0?1:(ee(i[m+1|0]|0),m=m+2|0,0)}function K0(b){return b=b|0,Q(2)|0?1:(ee(u(m+1|0)|0),m=m+3|0,0)}function Z0(b){return b=b|0,Q(4)|0?1:(D(u(m+1|0)|0,u(m+3|0)|0),m=m+5|0,0)}function W0(b){return b=b|0,Q(8)|0?1:(ae(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 X0(b){return b=b|0,G(),m=m+1|0,0}function Yr(b){return b=b|0,H(b-192|0|0),m=m+1|0,0}function M1(b){return b=b|0,H(b|0),m=m+1|0,0}function k1(b){return b=b|0,H(b|0),m=m+1|0,0}function C1(b){return b=b|0,H(b|0),m=m+1|0,0}function q1(b){return b=b|0,H(b|0),m=m+1|0,0}function Qe(b){return b=b|0,H(b-192|0|0),m=m+1|0,0}function V1(b){return b=b|0,H(b|0),m=m+1|0,0}function $1(b){return b=b|0,H(b|0),m=m+1|0,0}function G1(b){return b=b|0,H(b|0),m=m+1|0,0}function J0(b){return b=b|0,Q(1)|0?1:(H(i[m+1|0]|0),m=m+2|0,0)}function Q0(b){return b=b|0,Q(2)|0?1:(H(u(m+1|0)|0),m=m+3|0,0)}function L0(b){return b=b|0,Q(4)|0?1:(k(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:(W(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(b){return b=b|0,ce((b|0)-224|0),m=m+1|0,0}function el(b){return b=b|0,w(),m=m+1|0,0}function tl(b){return b=b|0,E(),m=m+1|0,0}function rl(b){return b=b|0,I(),m=m+1|0,0}function nl(b){return b=b|0,x(),m=m+1|0,0}function il(b){return b=b|0,Q(1)|0?1:(ce(i[m+1|0]|0),m=m+2|0,0)}function sl(b){b=b|0;var we=0,be=0,ge=1,oi=0,yn=0,H1=0;return Q(2)|0?1:(we=i[m+1|0]|0,be=i[m+2|0]|0,(we|0)&128&&(ge=-1),oi=+(((we|0)&124)>>2),yn=+(((we|0)&3)<<8|be),+oi==0?l(+(+ge*5960464477539063e-23*+yn)):+oi==31?+ge==1?+yn>0?V():O():+yn>0?Z():q():l(+(+ge*F(2,+(+oi-25))*+(1024+yn))),m=m+3|0,0)}function ol(b){return b=b|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 al(b){return b=b|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(b){return b=b|0,1}function cl(b){return b=b|0,re(),m=m+1|0,0}var ul=[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,_,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,$,Te,Te,Te,Te,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,te,me,Be,Se,Te,Te,Te,ye,ne,ne,ne,ne,ne,ne,ne,ne,ne,ne,ne,ne,ne,ne,ne,ne,ne,ne,ne,ne,ne,ne,ne,ne,ke,Qt,Ar,Tr,Te,Te,Te,ut,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,Ee,ft,rt,Ie,j0,Te,Te,Te,Y0,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,Ue,z0,K0,Z0,W0,Te,Te,Te,X0,Yr,Yr,Yr,Yr,Yr,Yr,Qe,Qe,Qe,Qe,Qe,Qe,Qe,Qe,Qe,Qe,Qe,Qe,Qe,Qe,Qe,Qe,Qe,Qe,J0,Q0,L0,D0,Te,Te,Te,Te,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,$e,el,tl,rl,nl,il,sl,ol,al,Te,Te,Te,cl];return{parse:se}}});var Rn=Ge(mt=>{"use strict";var To=Nn().BigNumber;mt.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};mt.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};mt.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};mt.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};mt.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};mt.SHIFT32=Math.pow(2,32);mt.SHIFT16=Math.pow(2,16);mt.MAX_SAFE_HIGH=2097151;mt.NEG_ONE=new To(-1);mt.TEN=new To(10);mt.TWO=new To(2);mt.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var Yi=Ge(Bt=>{"use strict";var{Buffer:Hd}=Sn(),Uu=Nn().BigNumber,Pu=Rn(),Iu=Pu.SHIFT32,jd=Pu.SHIFT16,Yd=2097151;Bt.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 zd(t){return t<16?"0"+t.toString(16):t.toString(16)}Bt.arrayBufferToBignumber=function(t){let e=t.byteLength,r="";for(let n=0;n<e;n++)r+=zd(t[n]);return new Uu(r,16)};Bt.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};Bt.buildInt32=(t,e)=>t*jd+e;Bt.buildInt64=(t,e,r,n)=>{let i=Bt.buildInt32(t,e),s=Bt.buildInt32(r,n);return i>Yd?new Uu(i).times(Iu).plus(s):i*Iu+s};Bt.writeHalf=function(e,r){let n=Hd.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};Bt.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])};Bt.isNegativeZero=t=>t===0&&1/t<0;Bt.nextPowerOf2=t=>{let e=0;if(t&&!(t&t-1))return t;for(;t!==0;)t>>=1,e+=1;return 1<<e}});var Oo=Ge((Qm,Mu)=>{"use strict";var Ro=Rn(),Kd=Ro.MT,zi=Ro.SIMPLE,So=Ro.SYMS,No=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,Kd.SIMPLE_FLOAT)}static isSimple(e){return e instanceof t}static decode(e,r){switch(r==null&&(r=!0),e){case zi.FALSE:return!1;case zi.TRUE:return!0;case zi.NULL:return r?null:So.NULL;case zi.UNDEFINED:return r?void 0:So.UNDEFINED;case-1:if(!r)throw new Error("Invalid BREAK");return So.BREAK;default:return new t(e)}}};Mu.exports=No});var Io=Ge((Lm,ku)=>{"use strict";var Fo=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=Fo});var Mo=Ge((Dm,qu)=>{"use strict";var Cu=self.location?self.location.protocol+"//"+self.location.host:"",Uo=self.URL,Po=class{constructor(e="",r=Cu){this.super=new Uo(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 Zd(t){if(typeof t=="string")return new Uo(t).toString();if(!(t instanceof Uo)){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:Po,URLSearchParams:self.URLSearchParams,defaultBase:Cu,format:Zd}});var Gu=Ge((ey,$u)=>{"use strict";var{URLWithLegacySupport:Vu,format:Wd}=Mo();$u.exports=(t,e={},r={},n)=>{let i=e.protocol?e.protocol.replace(":",""):"http";i=(r[i]||n||i)+":";let s;try{s=new Vu(t)}catch{s={}}let o=Object.assign({},e,{protocol:i||s.protocol,host:e.host||s.host});return new Vu(t,Wd(o)).toString()}});var ko=Ge((ty,Hu)=>{"use strict";var{URLWithLegacySupport:Xd,format:Jd,URLSearchParams:Qd,defaultBase:Ld}=Mo(),Dd=Gu();Hu.exports={URL:Xd,URLSearchParams:Qd,format:Jd,relative:Dd,defaultBase:Ld}});var Co=Ge((ry,Yu)=>{"use strict";var{Buffer:nn}=Sn(),ju=ro(),eh=Nn().BigNumber,th=Fu(),ot=Yi(),Ae=Rn(),rh=Oo(),nh=Io(),{URL:ih}=ko(),On=class t{constructor(e){e=e||{},!e.size||e.size<65536?e.size=65536:e.size=ot.nextPowerOf2(e.size),this._heap=new ArrayBuffer(e.size),this._heap8=new Uint8Array(this._heap),this._buffer=nn.from(this._heap),this._reset(),this._knownTags=Object.assign({0:r=>new Date(r),1:r=>new Date(r*1e3),2:r=>ot.arrayBufferToBignumber(r),3:r=>Ae.NEG_ONE.minus(ot.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 ih(r),35:r=>new RegExp(r)},e.tags),this.parser=th(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=ot.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 nh(e,r)}createMap(e,r){return e}createObject(e,r){return e}createArray(e,r){return e}createByteString(e,r){return nn.concat(e)}createByteStringFromHeap(e,r){return e===r?nn.alloc(0):nn.from(this._heap.slice(e,r))}createInt(e){return e}createInt32(e,r){return ot.buildInt32(e,r)}createInt64(e,r,n,i){return ot.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-ot.buildInt32(e,r)}createInt64Neg(e,r,n,i){let s=ot.buildInt32(e,r),o=ot.buildInt32(n,i);return s>Ae.MAX_SAFE_HIGH?Ae.NEG_ONE.minus(new eh(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 rh(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=ot.buildInt32(e,r);this._createArrayStartFixed(n)}pushArrayStartFixed64(e,r,n,i){let s=ot.buildInt64(e,r,n,i);this._createArrayStartFixed(s)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(e){this._createObjectStartFixed(e)}pushObjectStartFixed32(e,r){let n=ot.buildInt32(e,r);this._createObjectStartFixed(n)}pushObjectStartFixed64(e,r,n,i){let s=ot.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(ot.buildInt32(e,r))}pushTagStart8(e,r,n,i){this.pushTagStart(ot.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=nn.from(e,r||"hex")),new t({size:e.length}).decodeFirst(e)}static decodeAll(e,r){return typeof e=="string"&&(e=nn.from(e,r||"hex")),new t({size:e.length}).decodeAll(e)}};On.decodeFirst=On.decode;Yu.exports=On});var Zu=Ge((ny,Ku)=>{"use strict";var{Buffer:qo}=Sn(),sh=Co(),oh=Yi(),Vo=class t extends sh{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 oh.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'${qo.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`"${qo.from(super.createUtf8StringFromHeap(e,r)).toString("utf8")}"`}static diagnose(e,r){return typeof e=="string"&&(e=qo.from(e,r||"hex")),new t().decodeFirst(e)}};Ku.exports=Vo;function zu(t){return(e,r)=>e?`${e}, ${r}: ${t[r]}`:`${r}: ${t[r]}`}});var Lu=Ge((iy,Qu)=>{"use strict";var{Buffer:zt}=Sn(),{URL:ah}=ko(),Go=Nn().BigNumber,$o=Yi(),We=Rn(),Ot=We.MT,Ki=We.NUMBYTES,Wu=We.SHIFT32,Xu=We.SYMS,sn=We.TAG,ch=We.MT.SIMPLE_FLOAT<<5|We.NUMBYTES.TWO,uh=We.MT.SIMPLE_FLOAT<<5|We.NUMBYTES.FOUR,fh=We.MT.SIMPLE_FLOAT<<5|We.NUMBYTES.EIGHT,lh=We.MT.SIMPLE_FLOAT<<5|We.SIMPLE.TRUE,dh=We.MT.SIMPLE_FLOAT<<5|We.SIMPLE.FALSE,hh=We.MT.SIMPLE_FLOAT<<5|We.SIMPLE.UNDEFINED,Ju=We.MT.SIMPLE_FLOAT<<5|We.SIMPLE.NULL,ph=new Go("0x20000000000000"),mh=zt.from("f97e00","hex"),yh=zt.from("f9fc00","hex"),gh=zt.from("f97c00","hex");function wh(t){return{}.toString.call(t).slice(8,-1)}var Ho=class t{constructor(e){e=e||{},this.streaming=typeof e.stream=="function",this.onData=e.stream,this.semanticTypes=[[ah,this._pushUrl],[Go,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(mh)}_pushInfinity(e){let r=e<0?yh:gh;return this.push(r)}_pushFloat(e){let r=zt.allocUnsafe(2);if($o.writeHalf(r,e)&&$o.parseHalf(r)===e)return this._pushUInt8(ch)&&this.push(r);let n=zt.allocUnsafe(4);return n.writeFloatBE(e,0),n.readFloatBE(0)===e?this._pushUInt8(uh)&&this.push(n):this._pushUInt8(fh)&&this._pushDoubleBE(e)}_pushInt(e,r,n){let i=r<<5;return e<24?this._pushUInt8(i|e):e<=255?this._pushUInt8(i|Ki.ONE)&&this._pushUInt8(e):e<=65535?this._pushUInt8(i|Ki.TWO)&&this._pushUInt16BE(e):e<=4294967295?this._pushUInt8(i|Ki.FOUR)&&this._pushUInt32BE(e):e<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|Ki.EIGHT)&&this._pushUInt32BE(Math.floor(e/Wu))&&this._pushUInt32BE(e%Wu):r===Ot.NEG_INT?this._pushFloat(n):this._pushFloat(e)}_pushIntNum(e){return e<0?this._pushInt(-e-1,Ot.NEG_INT,e):this._pushInt(e,Ot.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=zt.byteLength(e,"utf8");return this._pushInt(r,Ot.UTF8_STRING)&&this.pushWrite(e,5,r)}_pushBoolean(e){return this._pushUInt8(e?lh:dh)}_pushUndefined(e){return this._pushUInt8(hh)}_pushArray(e,r){let n=r.length;if(!e._pushInt(n,Ot.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,Ot.TAG)}_pushDate(e,r){return e._pushTag(sn.DATE_EPOCH)&&e.pushAny(Math.round(r/1e3))}_pushBuffer(e,r){return e._pushInt(r.length,Ot.BYTE_STRING)&&e.push(r)}_pushNoFilter(e,r){return e._pushBuffer(e,r.slice())}_pushRegexp(e,r){return e._pushTag(sn.REGEXP)&&e.pushAny(r.source)}_pushSet(e,r){if(!e._pushInt(r.size,Ot.ARRAY))return!1;for(let n of r)if(!e.pushAny(n))return!1;return!0}_pushUrl(e,r){return e._pushTag(sn.URI)&&e.pushAny(r.format())}_pushBigint(e){let r=sn.POS_BIGINT;e.isNegative()&&(e=e.negated().minus(1),r=sn.NEG_BIGINT);let n=e.toString(16);n.length%2&&(n="0"+n);let i=zt.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(sn.DECIMAL_FRAC)&&e._pushInt(2,Ot.ARRAY)))return!1;let n=r.decimalPlaces(),i=r.multipliedBy(new Go(10).pow(n));return e._pushIntNum(-n)?i.abs().isLessThan(ph)?e._pushIntNum(i.toNumber()):e._pushBigint(i):!1}_pushMap(e,r){return e._pushInt(r.size,Ot.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,Ot.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($o.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=wh(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,zt.isBuffer(e)?e:zt.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=zt.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=Ho});var jo=Ge(Xe=>{"use strict";Xe.Diagnose=Zu();Xe.Decoder=Co();Xe.Encoder=Lu();Xe.Simple=Oo();Xe.Tagged=Io();Xe.decodeAll=Xe.Decoder.decodeAll;Xe.decodeFirst=Xe.Decoder.decodeFirst;Xe.diagnose=Xe.Diagnose.diagnose;Xe.encode=Xe.Encoder.encode;Xe.decode=Xe.Decoder.decode;Xe.leveldb={decode:Xe.Decoder.decodeAll,encode:Xe.Encoder.encode,buffer:!0,name:"cbor"}});function at(...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 Ye(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}function Ir(t){if(!bh.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 Yo(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 In(t,e){return Yo(t,e)===0}function Fn(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}function zo(t){return t instanceof Uint8Array?Fn(t):t instanceof ArrayBuffer?t:Array.isArray(t)?Fn(new Uint8Array(t)):"buffer"in t?zo(t.buffer):Fn(new Uint8Array(t))}var bh,yt=xe(()=>{bh=new RegExp(/^[0-9a-fA-F]+$/)});function vt(t){return Fn(bn.create().update(new Uint8Array(t)).digest())}function Zi(t){if(t instanceof Du.default.Tagged)return Zi(t.value);if(typeof t=="string")return ef(t);if(typeof t=="number")return vt(Fe(t));if(t instanceof ArrayBuffer||ArrayBuffer.isView(t))return vt(t);if(Array.isArray(t)){let e=t.map(Zi);return vt(at(...e))}else{if(t&&typeof t=="object"&&t._isPrincipal)return vt(t.toUint8Array());if(typeof t=="object"&&t!==null&&typeof t.toHash=="function")return Zi(t.toHash());if(typeof t=="object")return Un(t);if(typeof t=="bigint")return vt(Fe(t))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${t}`),{value:t})}function Wi(t){return Un(t)}function Un(t){let n=Object.entries(t).filter(([,o])=>o!==void 0).map(([o,c])=>{let a=ef(o),d=Zi(c);return[a,d]}).sort(([o],[c])=>Yo(o,c)),i=at(...n.map(o=>at(...o)));return vt(i)}var Du,ef,Pn=xe(()=>{Tn();Du=zr(jo());pi();yt();ef=t=>{let e=new TextEncoder().encode(t);return vt(e)}});var Wo=Ge(Ne=>{"use strict";Object.defineProperty(Ne,"__esModule",{value:!0});var xh=9007199254740992;function rr(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 Ft(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 Xi(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 Ft(t,r,e.toString(16))}}function tf(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 rr(new Uint8Array(Xi(3,t.length)),new Uint8Array(e))}function _h(t,e){if(t==14277111)return rr(new Uint8Array([217,217,247]),e);if(t<24)return rr(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=_h;function Mn(t){return new Uint8Array(t).buffer}Ne.raw=Mn;function Ko(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=Ko;function rf(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),Ft(0,24,t)}Ne.u8=rf;function nf(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),Ft(0,25,t)}Ne.u16=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),4294967295),t=t.toString(16),Ft(0,26,t)}Ne.u32=sf;function Zo(t,e){if(typeof t=="string"&&e==16){if(t.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return Ft(0,27,t)}if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),xh),t=t.toString(16),Ft(0,27,t)}Ne.u64=Zo;function of(t){if(isNaN(t))throw new RangeError("Invalid number.");if(t===0)return Ko(0);t=Math.min(Math.max(0,-t),24)-1;let e=[32+t];return new Uint8Array(e).buffer}Ne.iSmall=of;function af(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),Ft(1,24,t)}Ne.i8=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),65535),t=t.toString(16),Ft(1,25,t)}Ne.i16=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),4294967295),t=t.toString(16),Ft(1,26,t)}Ne.i32=uf;function ff(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?Ft(1,27,n):Zo(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),Ft(1,27,t)}Ne.i64=ff;function Eh(t){return t>=0?t<24?Ko(t):t<=255?rf(t):t<=65535?nf(t):t<=4294967295?sf(t):Zo(t):t>=-24?of(t):t>=-255?af(t):t>=-65535?cf(t):t>=-4294967295?uf(t):ff(t)}Ne.number=Eh;function Bh(t){return rr(Xi(2,t.byteLength),t)}Ne.bytes=Bh;function vh(t){return tf(t)}Ne.string=vh;function Ah(t){return rr(Xi(4,t.length),...t)}Ne.array=Ah;function Th(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))),rr(Xi(5,t.size),...r.map(([n,i])=>rr(tf(n),i)))}Ne.map=Th;function Sh(t){let e=new Float32Array([t]);return rr(new Uint8Array([250]),new Uint8Array(e.buffer))}Ne.singleFloat=Sh;function Nh(t){let e=new Float64Array([t]);return rr(new Uint8Array([251]),new Uint8Array(e.buffer))}Ne.doubleFloat=Nh;function Rh(t){return t?lf():df()}Ne.bool=Rh;function lf(){return Mn(new Uint8Array([245]))}Ne.true_=lf;function df(){return Mn(new Uint8Array([244]))}Ne.false_=df;function Oh(){return Mn(new Uint8Array([246]))}Ne.null_=Oh;function Fh(){return Mn(new Uint8Array([247]))}Ne.undefined_=Fh});var hf=Ge(pr=>{"use strict";var Ih=pr&&pr.__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(pr,"__esModule",{value:!0});var It=Ih(Wo()),Uh=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],Ji=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 It.undefined_();case"boolean":return It.bool(e);case"number":return Math.floor(e)===e?It.number(e):It.doubleFloat(e);case"string":return It.string(e);case"object":if(e===null)return It.null_();if(Array.isArray(e))return It.array(e.map(r=>this._serializer.serializeValue(r)));if(Uh.find(r=>e instanceof r))return It.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 It.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 It.map(r,this._stable)}default:throw new Error("Invalid value.")}}};pr.JsonDefaultCborEncoder=Ji;var Qi=class{constructor(){this.name="cborEncoder",this.priority=-90}match(e){return typeof e=="object"&&typeof e.toCBOR=="function"}encode(e){return e.toCBOR()}};pr.ToCborEncoder=Qi;var Li=class{constructor(){this._encoders=new Set}static withDefaultEncoders(e=!1){let r=new this;return r.addEncoder(new Ji(r,e)),r.addEncoder(new Qi),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)}};pr.CborSerializer=Li;var Xo=class extends Li{serialize(e){return It.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(e))]))}};pr.SelfDescribeCborSerializer=Xo});var Di=Ge(Ur=>{"use strict";function Ph(t){for(var e in t)Ur.hasOwnProperty(e)||(Ur[e]=t[e])}var Mh=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});Ph(hf());var kh=Mh(Wo());Ur.value=kh});function ts(t){return es.serialize(t)}function pf(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 At(t){let e=new Uint8Array(t),r=new ea({size:e.byteLength,tags:{2:n=>pf(n),3:n=>-pf(n),[Do.Semantic]:n=>n}});try{return r.decodeFirst(e)}catch(n){throw new Error(`Failed to decode CBOR: ${n}, input: ${Ye(e)}`)}}var mf,Pr,yf,Jo,Qo,Lo,es,Do,ea,kn=xe(()=>{mf=zr(jo()),Pr=zr(Di()),yf=zr(Di());yt();Jo=class{get name(){return"Principal"}get priority(){return 0}match(e){return e&&e._isPrincipal===!0}encode(e){return Pr.value.bytes(e.toUint8Array())}},Qo=class{get name(){return"Buffer"}get priority(){return 1}match(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)}encode(e){return Pr.value.bytes(new Uint8Array(e))}},Lo=class{get name(){return"BigInt"}get priority(){return 1}match(e){return typeof e=="bigint"}encode(e){return e>BigInt(0)?Pr.value.tagged(2,Pr.value.bytes(Ir(e.toString(16)))):Pr.value.tagged(3,Pr.value.bytes(Ir((BigInt("-1")*e).toString(16))))}},es=yf.SelfDescribeCborSerializer.withDefaultEncoders(!0);es.addEncoder(new Jo);es.addEncoder(new Qo);es.addEncoder(new Lo);(function(t){t[t.Uint64LittleEndian=71]="Uint64LittleEndian",t[t.Semantic=55799]="Semantic"})(Do||(Do={}));ea=class extends mf.default.Decoder{createByteString(e){return at(...e)}createByteStringFromHeap(e,r){return e===r?new ArrayBuffer(0):new Uint8Array(this._heap.slice(e,r))}}});var ss={};gn(ss,{abytes:()=>Ut,bitGet:()=>un,bitLen:()=>yr,bitMask:()=>gr,bitSet:()=>jh,bytesToHex:()=>Pt,bytesToNumberBE:()=>nt,bytesToNumberLE:()=>mr,concatBytes:()=>Re,createHmacDrbg:()=>Ef,ensureBytes:()=>ze,equalBytes:()=>Hh,hexToBytes:()=>$n,hexToNumber:()=>na,isBytes:()=>cn,numberToBytesBE:()=>qe,numberToBytesLE:()=>kr,numberToHexUnpadded:()=>_f,numberToVarBytesBE:()=>Gh,utf8ToBytes:()=>Gn,validateObject:()=>Mt});function cn(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Ut(t){if(!cn(t))throw new Error("Uint8Array expected")}function Pt(t){Ut(t);let e="";for(let r=0;r<t.length;r++)e+=$h[t[r]];return e}function _f(t){let e=t.toString(16);return e.length&1?`0${e}`:e}function na(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}function wf(t){if(t>=nr._0&&t<=nr._9)return t-nr._0;if(t>=nr._A&&t<=nr._F)return t-(nr._A-10);if(t>=nr._a&&t<=nr._f)return t-(nr._a-10)}function $n(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=wf(t.charCodeAt(s)),c=wf(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 nt(t){return na(Pt(t))}function mr(t){return Ut(t),na(Pt(Uint8Array.from(t).reverse()))}function qe(t,e){return $n(t.toString(16).padStart(e*2,"0"))}function kr(t,e){return qe(t,e).reverse()}function Gh(t){return $n(_f(t))}function ze(t,e,r){let n;if(typeof e=="string")try{n=$n(e)}catch(s){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${s}`)}else if(cn(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];Ut(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 Hh(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 Gn(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function yr(t){let e;for(e=0;t>xf;t>>=is,e+=1);return e}function un(t,e){return t>>BigInt(e)&is}function jh(t,e,r){return t|(r?is:xf)<<BigInt(e)}function Ef(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=ra(t),i=ra(t),s=0,o=()=>{n.fill(1),i.fill(0),s=0},c=(...f)=>r(i,n,...f),a=(f=ra())=>{i=c(bf([0]),f),n=c(),f.length!==0&&(i=c(bf([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 E=n.slice();T.push(E),f+=n.length}return Re(...T)};return(f,T)=>{o(),a(f);let E;for(;!(E=T(d()));)a();return o(),E}}function Mt(t,e,r={}){let n=(i,s,o)=>{let c=Yh[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 xf,is,Vh,$h,nr,gr,ra,bf,Yh,Kt=xe(()=>{xf=BigInt(0),is=BigInt(1),Vh=BigInt(2);$h=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));nr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};gr=t=>(Vh<<BigInt(t-1))-is,ra=t=>new Uint8Array(t),bf=t=>Uint8Array.from(t);Yh={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"||cn(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 Oe(t,e){let r=t%e;return r>=Je?r:e+r}function Wh(t,e,r){if(r<=Je||e<Je)throw new Error("Expected power/modulo > 0");if(r===Pe)return Je;let n=Pe;for(;e>Je;)e&Pe&&(n=n*t%r),t=t*t%r,e>>=Pe;return n}function kt(t,e,r){let n=t;for(;e-- >Je;)n*=n,n%=r;return n}function sa(t,e){if(t===Je||e<=Je)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=Oe(t,e),n=e,i=Je,s=Pe,o=Pe,c=Je;for(;r!==Je;){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 Oe(i,e)}function Xh(t){let e=(t-Pe)/Cr,r,n,i;for(r=t-Pe,n=0;r%Cr===Je;r/=Cr,n++);for(i=Cr;i<t&&Wh(i,e,t)!==t-Pe;i++);if(n===1){let o=(t+Pe)/ia;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)/Cr;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 E=1;for(let x=c.sqr(T);E<d&&!c.eql(x,c.ONE);E++)x=c.sqr(x);let w=c.pow(l,Pe<<BigInt(d-E-1));l=c.sqr(w),f=c.mul(f,w),T=c.mul(T,l),d=E}return f}}function Jh(t){if(t%ia===zh){let e=(t+Pe)/ia;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%vf===Bf){let e=(t-Bf)/vf;return function(n,i){let s=n.mul(i,Cr),o=n.pow(s,e),c=n.mul(i,o),a=n.mul(n.mul(c,Cr),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%Zh,Xh(t)}function os(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=Qh.reduce((n,i)=>(n[i]="function",n),e);return Mt(t,r)}function Hn(t,e,r){if(r<Je)throw new Error("Expected power > 0");if(r===Je)return t.ONE;if(r===Pe)return e;let n=t.ONE,i=e;for(;r>Je;)r&Pe&&(n=t.mul(n,i)),i=t.sqr(i),r>>=Pe;return n}function jn(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 oa(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function Yn(t,e,r=!1,n={}){if(t<=Je)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:s}=oa(t,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=Jh(t),c=Object.freeze({ORDER:t,BITS:i,BYTES:s,MASK:gr(i),ZERO:Je,ONE:Pe,create:a=>Oe(a,t),isValid:a=>{if(typeof a!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof a}`);return Je<=a&&a<t},is0:a=>a===Je,isOdd:a=>(a&Pe)===Pe,neg:a=>Oe(-a,t),eql:(a,d)=>a===d,sqr:a=>Oe(a*a,t),add:(a,d)=>Oe(a+d,t),sub:(a,d)=>Oe(a-d,t),mul:(a,d)=>Oe(a*d,t),pow:(a,d)=>Hn(c,a,d),div:(a,d)=>Oe(a*sa(d,t),t),sqrN:a=>a*a,addN:(a,d)=>a+d,subN:(a,d)=>a-d,mulN:(a,d)=>a*d,inv:a=>sa(a,t),sqrt:n.sqrt||(a=>o(c,a)),invertBatch:a=>jn(c,a),cmov:(a,d,l)=>l?d:a,toBytes:a=>r?kr(a,s):qe(a,s),fromBytes:a=>{if(a.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${a.length}`);return r?mr(a):nt(a)}});return Object.freeze(c)}function Tf(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 as(t){let e=Tf(t);return e+Math.ceil(e/2)}function aa(t,e,r=!1){let n=t.length,i=Tf(e),s=as(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let o=r?nt(t):mr(t),c=Oe(o,e-Pe)+Pe;return r?kr(c,i):qe(c,i)}var Je,Pe,Cr,zh,ia,Bf,vf,Kh,Zh,Af,Qh,wr=xe(()=>{Kt();Je=BigInt(0),Pe=BigInt(1),Cr=BigInt(2),zh=BigInt(3),ia=BigInt(4),Bf=BigInt(5),vf=BigInt(8),Kh=BigInt(9),Zh=BigInt(16);Af=(t,e)=>(Oe(t,e)&Pe)===Pe,Qh=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"]});function br(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 Dh(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 ca(t){if(!Number.isSafeInteger(t))throw new Error("number expected")}function ep(t,e,r,n){Ut(t),Ut(e),ca(r),e.length>255&&(e=n(Re(Gn("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,br(e.length,1)),a=br(0,s),d=br(r,2),l=new Array(o),f=n(Re(a,t,d,br(0,1),c));l[0]=n(Re(f,br(1,1),c));for(let E=1;E<=o;E++){let w=[Dh(f,l[E-1]),br(E+1,1),c];l[E]=n(Re(...w))}return Re(...l).slice(0,r)}function tp(t,e,r,n,i){if(Ut(t),Ut(e),ca(r),e.length>255){let s=Math.ceil(2*n/8);e=i.create({dkLen:s}).update(Gn("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(br(r,2)).update(e).update(br(e.length,1)).digest()}function Nf(t,e,r){Mt(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;Ut(t),ca(e);let d=typeof a=="string"?Gn(a):a,l=n.toString(2).length,f=Math.ceil((l+i)/8),T=e*s*f,E;if(c==="xmd")E=ep(t,d,T,o);else if(c==="xof")E=tp(t,d,T,i,o);else if(c==="_internal_pass")E=t;else throw new Error('expand must be "xmd" or "xof"');let w=new Array(e);for(let x=0;x<e;x++){let I=new Array(s);for(let O=0;O<s;O++){let q=f*(O+x*s),V=E.subarray(q,q+f);I[O]=Oe(Lh(V),n)}w[x]=I}return w}function ua(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 fa(t,e,r){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){let s=Nf(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=Nf(n,1,{...r,DST:r.encodeDST,...i}),o=t.fromAffine(e(s[0])).clearCofactor();return o.assertValidity(),o},mapToCurve(n){if(!Array.isArray(n))throw new Error("mapToCurve: expected array of bigints");for(let s of n)if(typeof s!="bigint")throw new Error(`mapToCurve: expected array of bigints, got ${s} in array`);let i=t.fromAffine(e(n)).clearCofactor();return i.assertValidity(),i}}}var Lh,la=xe(()=>{wr();Kt();Lh=nt});function cs(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>rp;)s&da&&(o=o.add(c)),c=c.double(),s>>=da;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,E=BigInt(i);for(let w=0;w<c;w++){let x=w*a,I=Number(o&f);o>>=E,I>a&&(I-=T,o+=da);let O=x,q=x+Math.abs(I)-1,V=w%2!==0,Z=I<0;I===0?l=l.add(r(V,s[O])):d=d.add(r(Z,s[q]))}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 us(t){return os(t.Fp),Mt(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...oa(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}var rp,da,ha=xe(()=>{wr();Kt();rp=BigInt(0),da=BigInt(1)});function np(t){let e=us(t);Mt(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 pa(t){let e=np(t),{Fp:r}=e,n=e.toBytes||((w,x,I)=>{let O=x.toAffine();return Re(Uint8Array.from([4]),r.toBytes(O.x),r.toBytes(O.y))}),i=e.fromBytes||(w=>{let x=w.subarray(1),I=r.fromBytes(x.subarray(0,r.BYTES)),O=r.fromBytes(x.subarray(r.BYTES,2*r.BYTES));return{x:I,y:O}});function s(w){let{a:x,b:I}=e,O=r.sqr(w),q=r.mul(O,w);return r.add(r.add(q,r.mul(w,x)),I)}if(!r.eql(r.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function o(w){return typeof w=="bigint"&&qr<w&&w<e.n}function c(w){if(!o(w))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function a(w){let{allowedPrivateKeyLengths:x,nByteLength:I,wrapPrivateKey:O,n:q}=e;if(x&&typeof w!="bigint"){if(cn(w)&&(w=Pt(w)),typeof w!="string"||!x.includes(w.length))throw new Error("Invalid key");w=w.padStart(I*2,"0")}let V;try{V=typeof w=="bigint"?w:nt(ze("private key",w,I))}catch{throw new Error(`private key must be ${I} bytes, hex or bigint, not ${typeof w}`)}return O&&(V=Oe(V,q)),c(V),V}let d=new Map;function l(w){if(!(w instanceof f))throw new Error("ProjectivePoint expected")}class f{constructor(x,I,O){if(this.px=x,this.py=I,this.pz=O,x==null||!r.isValid(x))throw new Error("x required");if(I==null||!r.isValid(I))throw new Error("y required");if(O==null||!r.isValid(O))throw new Error("z required")}static fromAffine(x){let{x:I,y:O}=x||{};if(!x||!r.isValid(I)||!r.isValid(O))throw new Error("invalid affine point");if(x instanceof f)throw new Error("projective point not allowed");let q=V=>r.eql(V,r.ZERO);return q(I)&&q(O)?f.ZERO:new f(I,O,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(x){let I=r.invertBatch(x.map(O=>O.pz));return x.map((O,q)=>O.toAffine(I[q])).map(f.fromAffine)}static fromHex(x){let I=f.fromAffine(i(ze("pointHex",x)));return I.assertValidity(),I}static fromPrivateKey(x){return f.BASE.multiply(a(x))}_setWindowSize(x){this._WINDOW_SIZE=x,d.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}let{x,y:I}=this.toAffine();if(!r.isValid(x)||!r.isValid(I))throw new Error("bad point: x or y not FE");let O=r.sqr(I),q=s(x);if(!r.eql(O,q))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:x}=this.toAffine();if(r.isOdd)return!r.isOdd(x);throw new Error("Field doesn't support isOdd")}equals(x){l(x);let{px:I,py:O,pz:q}=this,{px:V,py:Z,pz:U}=x,M=r.eql(r.mul(I,U),r.mul(V,q)),Y=r.eql(r.mul(O,U),r.mul(Z,q));return M&&Y}negate(){return new f(this.px,r.neg(this.py),this.pz)}double(){let{a:x,b:I}=e,O=r.mul(I,fs),{px:q,py:V,pz:Z}=this,U=r.ZERO,M=r.ZERO,Y=r.ZERO,z=r.mul(q,q),G=r.mul(V,V),ee=r.mul(Z,Z),D=r.mul(q,V);return D=r.add(D,D),Y=r.mul(q,Z),Y=r.add(Y,Y),U=r.mul(x,Y),M=r.mul(O,ee),M=r.add(U,M),U=r.sub(G,M),M=r.add(G,M),M=r.mul(U,M),U=r.mul(D,U),Y=r.mul(O,Y),ee=r.mul(x,ee),D=r.sub(z,ee),D=r.mul(x,D),D=r.add(D,Y),Y=r.add(z,z),z=r.add(Y,z),z=r.add(z,ee),z=r.mul(z,D),M=r.add(M,z),ee=r.mul(V,Z),ee=r.add(ee,ee),z=r.mul(ee,D),U=r.sub(U,z),Y=r.mul(ee,G),Y=r.add(Y,Y),Y=r.add(Y,Y),new f(U,M,Y)}add(x){l(x);let{px:I,py:O,pz:q}=this,{px:V,py:Z,pz:U}=x,M=r.ZERO,Y=r.ZERO,z=r.ZERO,G=e.a,ee=r.mul(e.b,fs),D=r.mul(I,V),ae=r.mul(O,Z),le=r.mul(q,U),_e=r.add(I,O),he=r.add(V,Z);_e=r.mul(_e,he),he=r.add(D,ae),_e=r.sub(_e,he),he=r.add(I,q);let K=r.add(V,U);return he=r.mul(he,K),K=r.add(D,le),he=r.sub(he,K),K=r.add(O,q),M=r.add(Z,U),K=r.mul(K,M),M=r.add(ae,le),K=r.sub(K,M),z=r.mul(G,he),M=r.mul(ee,le),z=r.add(M,z),M=r.sub(ae,z),z=r.add(ae,z),Y=r.mul(M,z),ae=r.add(D,D),ae=r.add(ae,D),le=r.mul(G,le),he=r.mul(ee,he),ae=r.add(ae,le),le=r.sub(D,le),le=r.mul(G,le),he=r.add(he,le),D=r.mul(ae,he),Y=r.add(Y,D),D=r.mul(K,he),M=r.mul(_e,M),M=r.sub(M,D),D=r.mul(_e,ae),z=r.mul(K,z),z=r.add(z,D),new f(M,Y,z)}subtract(x){return this.add(x.negate())}is0(){return this.equals(f.ZERO)}wNAF(x){return E.wNAFCached(this,d,x,I=>{let O=r.invertBatch(I.map(q=>q.pz));return I.map((q,V)=>q.toAffine(O[V])).map(f.fromAffine)})}multiplyUnsafe(x){let I=f.ZERO;if(x===qr)return I;if(c(x),x===et)return this;let{endo:O}=e;if(!O)return E.unsafeLadder(this,x);let{k1neg:q,k1:V,k2neg:Z,k2:U}=O.splitScalar(x),M=I,Y=I,z=this;for(;V>qr||U>qr;)V&et&&(M=M.add(z)),U&et&&(Y=Y.add(z)),z=z.double(),V>>=et,U>>=et;return q&&(M=M.negate()),Z&&(Y=Y.negate()),Y=new f(r.mul(Y.px,O.beta),Y.py,Y.pz),M.add(Y)}multiply(x){c(x);let I=x,O,q,{endo:V}=e;if(V){let{k1neg:Z,k1:U,k2neg:M,k2:Y}=V.splitScalar(I),{p:z,f:G}=this.wNAF(U),{p:ee,f:D}=this.wNAF(Y);z=E.constTimeNegate(Z,z),ee=E.constTimeNegate(M,ee),ee=new f(r.mul(ee.px,V.beta),ee.py,ee.pz),O=z.add(ee),q=G.add(D)}else{let{p:Z,f:U}=this.wNAF(I);O=Z,q=U}return f.normalizeZ([O,q])[0]}multiplyAndAddUnsafe(x,I,O){let q=f.BASE,V=(U,M)=>M===qr||M===et||!U.equals(q)?U.multiplyUnsafe(M):U.multiply(M),Z=V(this,I).add(V(x,O));return Z.is0()?void 0:Z}toAffine(x){let{px:I,py:O,pz:q}=this,V=this.is0();x==null&&(x=V?r.ONE:r.inv(q));let Z=r.mul(I,x),U=r.mul(O,x),M=r.mul(q,x);if(V)return{x:r.ZERO,y:r.ZERO};if(!r.eql(M,r.ONE))throw new Error("invZ was invalid");return{x:Z,y:U}}isTorsionFree(){let{h:x,isTorsionFree:I}=e;if(x===et)return!0;if(I)return I(f,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:x,clearCofactor:I}=e;return x===et?this:I?I(f,this):this.multiplyUnsafe(e.h)}toRawBytes(x=!0){return this.assertValidity(),n(f,this,x)}toHex(x=!0){return Pt(this.toRawBytes(x))}}f.BASE=new f(e.Gx,e.Gy,r.ONE),f.ZERO=new f(r.ZERO,r.ONE,r.ZERO);let T=e.nBitLength,E=cs(f,e.endo?Math.ceil(T/2):T);return{CURVE:e,ProjectivePoint:f,normPrivateKeyToScalar:a,weierstrassEquation:s,isWithinCurveOrder:o}}function ip(t,e){let r=t.ORDER,n=qr;for(let w=r-et;w%xr===qr;w/=xr)n+=et;let i=n,s=xr<<i-et-et,o=s*xr,c=(r-et)/o,a=(c-et)/xr,d=o-et,l=s,f=t.pow(e,c),T=t.pow(e,(c+et)/xr),E=(w,x)=>{let I=f,O=t.pow(x,d),q=t.sqr(O);q=t.mul(q,x);let V=t.mul(w,q);V=t.pow(V,a),V=t.mul(V,O),O=t.mul(V,x),q=t.mul(V,w);let Z=t.mul(q,O);V=t.pow(Z,l);let U=t.eql(V,t.ONE);O=t.mul(q,T),V=t.mul(Z,I),q=t.cmov(O,q,U),Z=t.cmov(V,Z,U);for(let M=i;M>et;M--){let Y=M-xr;Y=xr<<Y-et;let z=t.pow(Z,Y),G=t.eql(z,t.ONE);O=t.mul(q,I),I=t.mul(I,I),z=t.mul(Z,I),q=t.cmov(O,q,G),Z=t.cmov(z,Z,G)}return{isValid:U,value:q}};if(t.ORDER%Rf===fs){let w=(t.ORDER-fs)/Rf,x=t.sqrt(t.neg(e));E=(I,O)=>{let q=t.sqr(O),V=t.mul(I,O);q=t.mul(q,V);let Z=t.pow(q,w);Z=t.mul(Z,V);let U=t.mul(Z,x),M=t.mul(t.sqr(Z),O),Y=t.eql(M,I),z=t.cmov(U,Z,Y);return{isValid:Y,value:z}}}return E}function ma(t,e){if(os(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let r=ip(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:E}=r(s,d);f=t.mul(i,n),f=t.mul(f,E),l=t.cmov(l,o,T),f=t.cmov(f,E,T);let w=t.isOdd(n)===t.isOdd(f);return f=t.cmov(t.neg(f),f,w),l=t.div(l,c),{x:l,y:f}}}var Cy,qy,qr,et,xr,fs,Rf,ya=xe(()=>{ha();wr();Kt();Kt();({bytesToNumberBE:Cy,hexToBytes:qy}=ss),qr=BigInt(0),et=BigInt(1),xr=BigInt(2),fs=BigInt(3),Rf=BigInt(4)});function Of(t){let{Fp:e,Fr:r,Fp2:n,Fp6:i,Fp12:s}=t.fields,o=yr(t.params.x);function c(K){let{x:ce,y:H}=K,k=ce,W=H,L=n.ONE,re=k,F=W,m=L,fe=[];for(let ie=o-2;ie>=0;ie--){let se=n.sqr(F),Q=n.sqr(m),u=n.multiplyByB(n.mul(Q,ls)),h=n.mul(u,ls),p=n.sub(n.sub(n.sqr(n.add(F,m)),Q),se);if(fe.push([n.sub(u,se),n.mul(n.sqr(re),ls),n.neg(p)]),re=n.div(n.mul(n.mul(n.sub(se,h),re),F),ga),F=n.sub(n.sqr(n.div(n.add(se,h),ga)),n.mul(n.sqr(u),ls)),m=n.mul(se,p),un(t.params.x,ie)){let A=n.sub(F,n.mul(W,m)),_=n.sub(re,n.mul(k,m));fe.push([n.sub(n.mul(A,k),n.mul(_,W)),n.neg(A),_]);let v=n.sqr(_),N=n.mul(v,_),g=n.mul(v,re),B=n.add(n.sub(N,n.mul(g,ga)),n.mul(n.sqr(A),m));re=n.mul(_,B),F=n.sub(n.mul(n.sub(g,B),A),n.mul(N,F)),m=n.mul(m,N)}}return fe}function a(K,ce){let{x:H}=t.params,k=ce[0],W=ce[1],L=s.ONE;for(let re=0,F=o-2;F>=0;F--,re++){let m=K[re];if(L=s.multiplyBy014(L,m[0],n.mul(m[1],k),n.mul(m[2],W)),un(H,F)){re+=1;let fe=K[re];L=s.multiplyBy014(L,fe[0],n.mul(fe[1],k),n.mul(fe[2],W))}F!==0&&(L=s.sqr(L))}return s.conjugate(L)}let d={randomPrivateKey:()=>{let K=as(r.ORDER);return aa(t.randomBytes(K),r.ORDER)},calcPairingPrecomputes:c},l=pa({n:r.ORDER,...t.G1}),f=Object.assign(l,fa(l.ProjectivePoint,t.G1.mapToCurve,{...t.htfDefaults,...t.G1.htfDefaults}));function T(K){let ce=K;return ce._PPRECOMPUTES||(ce._PPRECOMPUTES=c(K.toAffine())),ce._PPRECOMPUTES}let E=pa({n:r.ORDER,...t.G2}),w=Object.assign(E,fa(E.ProjectivePoint,t.G2.mapToCurve,{...t.htfDefaults,...t.G2.htfDefaults})),{ShortSignature:x}=t.G1,{Signature:I}=t.G2;function O(K,ce,H=!0){if(K.equals(f.ProjectivePoint.ZERO)||ce.equals(w.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");K.assertValidity(),ce.assertValidity();let k=K.toAffine(),W=a(T(ce),[k.x,k.y]);return H?s.finalExponentiate(W):W}function q(K){return K instanceof f.ProjectivePoint?K:f.ProjectivePoint.fromHex(K)}function V(K,ce){return K instanceof f.ProjectivePoint?K:f.hashToCurve(ze("point",K),ce)}function Z(K){return K instanceof w.ProjectivePoint?K:I.fromHex(K)}function U(K,ce){return K instanceof w.ProjectivePoint?K:w.hashToCurve(ze("point",K),ce)}function M(K){return f.ProjectivePoint.fromPrivateKey(K).toRawBytes(!0)}function Y(K){return w.ProjectivePoint.fromPrivateKey(K).toRawBytes(!0)}function z(K,ce,H){let k=U(K,H);k.assertValidity();let W=k.multiply(f.normPrivateKeyToScalar(ce));return K instanceof w.ProjectivePoint?W:I.toRawBytes(W)}function G(K,ce,H){let k=V(K,H);k.assertValidity();let W=k.multiply(f.normPrivateKeyToScalar(ce));return K instanceof f.ProjectivePoint?W:x.toRawBytes(W)}function ee(K,ce,H,k){let W=q(H),L=U(ce,k),re=f.ProjectivePoint.BASE,F=Z(K),m=O(W.negate(),L,!1),fe=O(re,F,!1),ie=s.finalExponentiate(s.mul(fe,m));return s.eql(ie,s.ONE)}function D(K,ce,H,k){let W=Z(H),L=V(ce,k),re=w.ProjectivePoint.BASE,F=q(K),m=O(L,W,!1),fe=O(F,re.negate(),!1),ie=s.finalExponentiate(s.mul(fe,m));return s.eql(ie,s.ONE)}function ae(K){if(!K.length)throw new Error("Expected non-empty array");let H=K.map(q).reduce((k,W)=>k.add(W),f.ProjectivePoint.ZERO);return K[0]instanceof f.ProjectivePoint?(H.assertValidity(),H):H.toRawBytes(!0)}function le(K){if(!K.length)throw new Error("Expected non-empty array");let H=K.map(Z).reduce((k,W)=>k.add(W),w.ProjectivePoint.ZERO);return K[0]instanceof w.ProjectivePoint?(H.assertValidity(),H):I.toRawBytes(H)}function _e(K){if(!K.length)throw new Error("Expected non-empty array");let H=K.map(q).reduce((k,W)=>k.add(W),f.ProjectivePoint.ZERO);return K[0]instanceof f.ProjectivePoint?(H.assertValidity(),H):x.toRawBytes(H)}function he(K,ce,H,k){if(!ce.length)throw new Error("Expected non-empty messages array");if(H.length!==ce.length)throw new Error("Pubkey count should equal msg count");let W=Z(K),L=ce.map(F=>U(F,k)),re=H.map(q);try{let F=[];for(let ie of new Set(L)){let se=L.reduce((Q,u,h)=>u===ie?Q.add(re[h]):Q,f.ProjectivePoint.ZERO);F.push(O(se,ie,!1))}F.push(O(f.ProjectivePoint.BASE.negate(),W,!1));let m=F.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:M,getPublicKeyForShortSignatures:Y,sign:z,signShortSignature:G,verify:ee,verifyBatch:he,verifyShortSignature:D,aggregatePublicKeys:ae,aggregateSignatures:le,aggregateShortSignatures:_e,millerLoop:a,pairing:O,G1:f,G2:w,Signature:I,ShortSignature:x,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 ga,ls,Ff=xe(()=>{wr();Kt();la();ya();ga=BigInt(2),ls=BigInt(3)});function wa(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 bp(t,e){let r=oe.mul(oe.frobeniusMap(oe.multiplyByFp2(gp,t),1),Xf).c0.c0,n=oe.mul(oe.frobeniusMap(oe.multiplyByFp2(wp,e),1),Jf).c0.c0;return[r,n]}function zf(t,e){let r=e.toAffine(),n=bp(r.x,r.y);return new t(n[0],n[1],y.ONE)}function _p(t,e){return[y.mul(t,xp),y.neg(e)]}function Ep(t,e){let r=e.toAffine(),n=_p(r.x,r.y);return new t(n[0],n[1],y.ONE)}function ps(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 Kn(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 Kf(t){t.assertValidity();let e=t.equals(tt.G1.ProjectivePoint.ZERO),{x:r,y:n}=t.toAffine();if(e)return ms.slice();let i=C.ORDER,s=!!(n*Me/i);return Kn(qe(r,C.BYTES),{compressed:!0,sort:s})}function Zf(t){t.assertValidity();let e=C.BYTES;if(t.equals(tt.G2.ProjectivePoint.ZERO))return Re(ms,qe(Ke,e));let{x:r,y:n}=t.toAffine(),{re:i,im:s}=y.reim(r),{re:o,im:c}=y.reim(n),d=!!((c>Ke?c*Me:o*Me)/C.ORDER&Vr),l=i;return Re(Kn(qe(s,e),{sort:d,compressed:!0}),qe(l,e))}var Ke,Vr,Me,ds,zn,sp,op,xa,C,If,Uf,Pf,Mf,kf,hs,y,ap,_r,cp,Cf,qf,Vf,$f,J,up,fp,_a,lp,Gf,Hf,jf,Yf,oe,dp,hp,pp,mp,yp,Wf,Xf,Jf,gp,wp,xp,ba,ms,tt,Qf=xe(()=>{pi();Zr();Ff();wr();Kt();la();ya();Ke=BigInt(0),Vr=BigInt(1),Me=BigInt(2),ds=BigInt(3),zn=BigInt(4),sp=BigInt(8),op=BigInt(16),xa=BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),C=Yn(xa),If=Yn(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),Uf=({c0:t,c1:e},{c0:r,c1:n})=>({c0:C.add(t,r),c1:C.add(e,n)}),Pf=({c0:t,c1:e},{c0:r,c1:n})=>({c0:C.sub(t,r),c1:C.sub(e,n)}),Mf=({c0:t,c1:e},r)=>{if(typeof r=="bigint")return{c0:C.mul(t,r),c1:C.mul(e,r)};let{c0:n,c1:i}=r,s=C.mul(t,n),o=C.mul(e,i),c=C.sub(s,o),a=C.sub(C.mul(C.add(t,e),C.add(n,i)),C.add(s,o));return{c0:c,c1:a}},kf=({c0:t,c1:e})=>{let r=C.add(t,e),n=C.sub(t,e),i=C.add(t,t);return{c0:C.mul(r,n),c1:C.mul(i,e)}},hs=xa*xa,y={ORDER:hs,BITS:yr(hs),BYTES:Math.ceil(yr(hs)/8),MASK:gr(yr(hs)),ZERO:{c0:C.ZERO,c1:C.ZERO},ONE:{c0:C.ONE,c1:C.ZERO},create:t=>t,isValid:({c0:t,c1:e})=>typeof t=="bigint"&&typeof e=="bigint",is0:({c0:t,c1:e})=>C.is0(t)&&C.is0(e),eql:({c0:t,c1:e},{c0:r,c1:n})=>C.eql(t,r)&&C.eql(e,n),neg:({c0:t,c1:e})=>({c0:C.neg(t),c1:C.neg(e)}),pow:(t,e)=>Hn(y,t,e),invertBatch:t=>jn(y,t),add:Uf,sub:Pf,mul:Mf,sqr:kf,addN:Uf,subN:Pf,mulN:Mf,sqrN:kf,div:(t,e)=>y.mul(t,typeof e=="bigint"?C.inv(C.create(e)):y.inv(e)),inv:({c0:t,c1:e})=>{let r=C.inv(C.create(t*t+e*e));return{c0:C.mul(r,C.create(t)),c1:C.mul(r,C.create(-e))}},sqrt:t=>{if(y.eql(t,y.ZERO))return y.ZERO;let e=y.pow(t,(y.ORDER+sp)/op),r=y.div(y.sqr(e),t),n=cp,i=[n[0],n[2],n[4],n[6]].find(E=>y.eql(E,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%Me,i=e===Ke,s=r%Me;return BigInt(n||i&&s)==Vr},fromBytes(t){if(t.length!==y.BYTES)throw new Error(`fromBytes wrong length=${t.length}`);return{c0:C.fromBytes(t.subarray(0,C.BYTES)),c1:C.fromBytes(t.subarray(C.BYTES))}},toBytes:({c0:t,c1:e})=>Re(C.toBytes(t),C.toBytes(e)),cmov:({c0:t,c1:e},{c0:r,c1:n},i)=>({c0:C.cmov(t,r,i),c1:C.cmov(e,n,i)}),reim:({c0:t,c1:e})=>({re:t,im:e}),mulByNonresidue:({c0:t,c1:e})=>({c0:C.sub(t,e),c1:C.add(t,e)}),multiplyByB:({c0:t,c1:e})=>{let r=C.mul(t,zn),n=C.mul(e,zn);return{c0:C.sub(r,n),c1:C.add(r,n)}},fromBigTuple:t=>{if(t.length!==2)throw new Error("Invalid tuple");let e=t.map(r=>C.create(r));return{c0:e[0],c1:e[1]}},frobeniusMap:({c0:t,c1:e},r)=>({c0:t,c1:C.mul(e,ap[r%2])})},ap=[BigInt("0x1"),BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaaa")].map(t=>C.create(t)),_r=BigInt("0x6af0e0437ff400b6831e36d6bd17ffe48395dabc2d3435e77f76e17009241c5ee67992f72ec05f4c81084fbede3cc09"),cp=[[Vr,Ke],[_r,-_r],[Ke,Vr],[_r,_r],[-Vr,Ke],[-_r,_r],[Ke,-Vr],[-_r,-_r]].map(t=>y.fromBigTuple(t)),Cf=({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)}),qf=({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)}),Vf=({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))}},$f=({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:gr(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"?C.inv(C.create(e)):J.inv(e)),pow:(t,e)=>Hn(J,t,e),invertBatch:t=>jn(J,t),add:Cf,sub:qf,mul:Vf,sqr:$f,addN:Cf,subN:qf,mulN:Vf,sqrN:$f,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),up[n%6]),c2:y.mul(y.frobeniusMap(r,n),fp[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)})},up=[[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)),fp=[[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)),_a=BigInt("0xd201000000010000"),lp=yr(_a),Gf=({c0:t,c1:e},{c0:r,c1:n})=>({c0:J.add(t,r),c1:J.add(e,n)}),Hf=({c0:t,c1:e},{c0:r,c1:n})=>({c0:J.sub(t,r),c1:J.sub(e,n)}),jf=({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))}},Yf=({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:gr(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"?C.inv(C.create(e)):oe.inv(e)),pow:(t,e)=>Hn(oe,t,e),invertBatch:t=>jn(oe,t),add:Gf,sub:Hf,mul:jf,sqr:Yf,addN:Gf,subN:Hf,mulN:jf,sqrN:Yf,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=dp[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}=wa(r,o),{first:l,second:f}=wa(s,i),{first:T,second:E}=wa(n,c),w=y.mulByNonresidue(E);return{c0:J.create({c0:y.add(y.mul(y.sub(a,r),Me),a),c1:y.add(y.mul(y.sub(l,n),Me),l),c2:y.add(y.mul(y.sub(T,i),Me),T)}),c1:J.create({c0:y.add(y.mul(y.add(w,s),Me),w),c1:y.add(y.mul(y.add(d,o),Me),d),c2:y.add(y.mul(y.add(f,c),Me),f)})}},_cyclotomicExp(t,e){let r=oe.ONE;for(let n=lp-1;n>=0;n--)r=oe._cyclotomicSquare(r),un(e,n)&&(r=oe.mul(r,t));return r},finalExponentiate:t=>{let e=_a,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),E=oe.mul(oe.mul(d,oe.conjugate(s)),n);return oe.mul(oe.mul(oe.mul(l,f),T),E)}},dp=[[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)),hp=ua(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))))),pp=ua(C,[["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)))),mp=ma(y,{A:y.create({c0:C.create(Ke),c1:C.create(BigInt(240))}),B:y.create({c0:C.create(BigInt(1012)),c1:C.create(BigInt(1012))}),Z:y.create({c0:C.create(BigInt(-2)),c1:C.create(BigInt(-1))})}),yp=ma(C,{A:C.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:C.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:C.create(BigInt(11))}),Wf=J.create({c0:y.ZERO,c1:y.ONE,c2:y.ZERO}),Xf=oe.create({c0:Wf,c1:J.ZERO}),Jf=oe.create({c0:J.ZERO,c1:Wf}),[gp,wp]=oe.invertBatch([Xf,Jf]);xp=BigInt("0x1a0111ea397fe699ec02408663d4de85aa0d857d89759ad4897d29650fb85f9b409427eb4f49fffd8bfd00000000aaac");ba=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:C.ORDER,m:2,k:128,expand:"xmd",hash:bn}),ms=Kn(C.toBytes(Ke),{infinity:!0,compressed:!0});tt=Of({fields:{Fp:C,Fp2:y,Fp6:J,Fp12:oe,Fr:If},G1:{Fp:C,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:C.ZERO,b:zn,htfDefaults:{...ba,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(C.mul(e.px,r),e.py,e.pz);return e.multiplyUnsafe(tt.params.x).negate().multiplyUnsafe(tt.params.x).equals(n)},clearCofactor:(t,e)=>e.multiplyUnsafe(tt.params.x).add(e),mapToCurve:t=>{let{x:e,y:r}=yp(C.create(t[0]));return pp(e,r)},fromBytes:t=>{let{compressed:e,infinity:r,sort:n,value:i}=ps(t);if(i.length===48&&e){let s=C.ORDER,o=nt(i),c=C.create(o&C.MASK);if(r){if(c!==Ke)throw new Error("G1: non-empty compressed point at infinity");return{x:Ke,y:Ke}}let a=C.add(C.pow(c,ds),C.create(tt.params.G1b)),d=C.sqrt(a);if(!d)throw new Error("Invalid compressed G1 point");return d*Me/s!==BigInt(n)&&(d=C.neg(d)),{x:C.create(c),y:C.create(d)}}else if(i.length===96&&!e){let s=nt(i.subarray(0,C.BYTES)),o=nt(i.subarray(C.BYTES));if(r){if(s!==Ke||o!==Ke)throw new Error("G1: non-empty point at infinity");return tt.G1.ProjectivePoint.ZERO.toAffine()}return{x:C.create(s),y:C.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 ms.slice();let o=C.ORDER,c=!!(s*Me/o);return Kn(qe(i,C.BYTES),{compressed:!0,sort:c})}else return n?Re(new Uint8Array([64]),new Uint8Array(2*C.BYTES-1)):Re(qe(i,C.BYTES),qe(s,C.BYTES))},ShortSignature:{fromHex(t){let{infinity:e,sort:r,value:n}=ps(ze("signatureHex",t,48)),i=C.ORDER,s=nt(n);if(e)return tt.G1.ProjectivePoint.ZERO;let o=C.create(s&C.MASK),c=C.add(C.pow(o,ds),C.create(tt.params.G1b)),a=C.sqrt(c);if(!a)throw new Error("Invalid compressed G1 point");let d=BigInt(r);a*Me/i!==d&&(a=C.neg(a));let l=tt.G1.ProjectivePoint.fromAffine({x:o,y:a});return l.assertValidity(),l},toRawBytes(t){return Kf(t)},toHex(t){return Pt(Kf(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([zn,zn]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...ba},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:t=>{let{x:e,y:r}=mp(y.fromBigTuple(t));return hp(e,r)},isTorsionFree:(t,e)=>e.multiplyUnsafe(tt.params.x).negate().equals(zf(t,e)),clearCofactor:(t,e)=>{let r=tt.params.x,n=e.multiplyUnsafe(r).negate(),i=zf(t,e),s=e.double();return s=Ep(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}=ps(t);if(!e&&!r&&n||!e&&r&&n||n&&r&&e)throw new Error("Invalid encoding flag: "+(t[0]&224));let s=C.BYTES,o=(c,a,d)=>nt(c.slice(a,d));if(i.length===96&&e){let c=tt.params.G2b,a=C.ORDER;if(r){if(i.reduce((x,I)=>x!==0?I+1:I,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:C.create(l),c1:C.create(d)}),T=y.add(y.pow(f,ds),c),E=y.sqrt(T),w=E.c1===Ke?E.c0*Me/a:E.c1*Me/a?Vr:Ke;return E=n&&w>0?E:y.neg(E),{x:f,y:E}}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}=C,s=e.equals(t.ZERO),{x:o,y:c}=e.toAffine();if(r){if(s)return Re(ms,qe(Ke,n));let a=!!(c.c1===Ke?c.c0*Me/i:c.c1*Me/i);return Re(Kn(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}=ps(ze("signatureHex",t)),i=C.ORDER,s=n.length/2;if(s!==48&&s!==96)throw new Error("Invalid compressed signature length, must be 96 or 192");let o=nt(n.slice(0,s)),c=nt(n.slice(s));if(e)return tt.G2.ProjectivePoint.ZERO;let a=C.create(o&C.MASK),d=C.create(c),l=y.create({c0:d,c1:a}),f=y.add(y.pow(l,ds),tt.params.G2b),T=y.sqrt(f);if(!T)throw new Error("Failed to find a square root");let{re:E,im:w}=y.reim(T),x=BigInt(r),I=w>Ke&&w*Me/i!==x,O=w===Ke&&E*Me/i!==x;(I||O)&&(T=y.neg(T));let q=tt.G2.ProjectivePoint.fromAffine({x:l,y:T});return q.assertValidity(),q},toRawBytes(t){return Zf(t)},toHex(t){return Pt(Zf(t))}}},params:{x:_a,r:If.ORDER},htfDefaults:ba,hash:bn,randomBytes:di})});function Lf(t,e,r){let n=typeof t=="string"?t:Ye(t),i=typeof e=="string"?e:Ye(e),s=typeof r=="string"?r:Ye(r);return tt.verifyShortSignature(i,s,n)}var Ea=xe(()=>{Qf();yt()});var Ba,fn,ys=xe(()=>{Tn();Ba=t=>He(new Nt(t)),fn=t=>{let e=Ba(t);return new Date(Number(e)/1e6)}});function vp(t,e){let r=new Uint8Array(t),n=new Uint8Array(e);for(let i=0;i<r.length;i++)if(r[i]>n[i])return!0;return!1}function Tp(t){let e=Zn.byteLength+Ap;if(t.byteLength!==e)throw new TypeError(`BLS DER-encoded public key must be ${e} bytes long`);let r=t.slice(0,Zn.byteLength);if(!In(r,Zn))throw new TypeError(`BLS DER-encoded public key is invalid. Expect the following prefix: ${Zn}, but get ${r}`);return t.slice(Zn.byteLength)}function sr(t){if(t.status===Ve.Found){if(t.value instanceof ArrayBuffer)return t.value;if(t.value instanceof Uint8Array)return t.value.buffer}}async function gs(t){switch(t[0]){case wt.Empty:return vt(Wn("ic-hashtree-empty"));case wt.Pruned:return t[1];case wt.Leaf:return vt(at(Wn("ic-hashtree-leaf"),t[1]));case wt.Labeled:return vt(at(Wn("ic-hashtree-labeled"),t[1],await gs(t[2])));case wt.Fork:return vt(at(Wn("ic-hashtree-fork"),await gs(t[1]),await gs(t[2])));default:throw new Error("unreachable")}}function Wn(t){let e=new Uint8Array([t.length]),r=new TextEncoder().encode(t);return at(e,r)}function Er(t,e){if(t.length===0)switch(e[0]){case wt.Leaf:{if(!e[1])throw new Error("Invalid tree structure for leaf");return e[1]instanceof ArrayBuffer?{status:Ve.Found,value:e[1]}:e[1]instanceof Uint8Array?{status:Ve.Found,value:e[1].buffer}:{status:Ve.Found,value:e[1]}}default:return{status:Ve.Found,value:e}}let r=typeof t[0]=="string"?new TextEncoder().encode(t[0]):t[0],n=ws(r,e);switch(n.status){case Ve.Found:return Er(t.slice(1),n.value);case ir.Greater:case ir.Less:return{status:Ve.Absent};default:return n}}function bs(t){switch(t[0]){case wt.Empty:return[];case wt.Fork:return bs(t[1]).concat(bs(t[2]));default:return[t]}}function ws(t,e){switch(e[0]){case wt.Labeled:return vp(t,e[1])?{status:ir.Greater}:In(t,e[1])?{status:Ve.Found,value:e[2]}:{status:ir.Less};case wt.Fork:let r=ws(t,e[1]);switch(r.status){case ir.Greater:{let n=ws(t,e[2]);return n.status===ir.Less?{status:Ve.Absent}:n}case Ve.Unknown:{let n=ws(t,e[2]);return n.status===ir.Less?{status:Ve.Unknown}:n}default:return r}case wt.Pruned:return{status:Ve.Unknown};default:return{status:Ve.Absent}}}function va(t){let{canisterId:e,subnetId:r,tree:n}=t,i=Er(["subnet",r.toUint8Array(),"canister_ranges"],n);if(i.status!==Ve.Found||!(i.value instanceof ArrayBuffer))throw new Error(`Could not find canister ranges for subnet ${r}`);return At(i.value).map(a=>[ue.fromUint8Array(a[0]),ue.fromUint8Array(a[1])]).some(a=>a[0].ltEq(e)&&a[1].gtEq(e))}var gt,wt,ln,Zn,Ap,Ve,ir,Xn=xe(()=>{kn();Dr();Pn();yt();xt();Ea();ys();gt=class extends Ze{constructor(e){super(`Invalid certificate: ${e}`)}};(function(t){t[t.Empty=0]="Empty",t[t.Fork=1]="Fork",t[t.Labeled=2]="Labeled",t[t.Leaf=3]="Leaf",t[t.Pruned=4]="Pruned"})(wt||(wt={}));ln=class t{constructor(e,r,n,i,s=5){this._rootKey=r,this._canisterId=n,this._blsVerify=i,this._maxAgeInMinutes=s,this.cert=At(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=Lf),new t(e.certificate,e.rootKey,e.canisterId,r,e.maxAgeInMinutes)}lookup(e){return Er(e,this.cert.tree)}lookup_label(e){return this.lookup([e])}async verify(){let e=await gs(this.cert.tree),r=await this._checkDelegationAndGetKey(this.cert.delegation),n=this.cert.signature,i=Tp(r),s=at(Wn("ic-state-root"),e),o=!1,c=sr(this.lookup(["time"]));if(!c)throw new gt("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,E=fn(c);if(E.getTime()<f)throw new gt(`Certificate is signed more than ${this._maxAgeInMinutes} minutes in the past. Certificate time: `+E.toISOString()+" Current time: "+new Date(l).toISOString());if(E.getTime()>T)throw new gt("Certificate is signed more than 5 minutes in the future. Certificate time: "+E.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 gt("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 gt("Delegation certificates cannot be nested");if(await r.verify(),!va({canisterId:this._canisterId,subnetId:ue.fromUint8Array(new Uint8Array(e.subnet_id)),tree:r.cert.tree}))throw new gt(`Canister ${this._canisterId} not in range of delegations for subnet 0x${Ye(e.subnet_id)}`);let i=sr(r.lookup(["subnet",e.subnet_id,"public_key"]));if(!i)throw new Error(`Could not find subnet key for subnet 0x${Ye(e.subnet_id)}`);return i}},Zn=Ir("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"),Ap=96;(function(t){t.Unknown="unknown",t.Absent="absent",t.Found="found"})(Ve||(Ve={}));(function(t){t.Less="less",t.Greater="greater"})(ir||(ir={}))});var _s={};gn(_s,{CustomPath:()=>Aa,encodePath:()=>Ta,fetchNodeKeys:()=>e0,request:()=>xs});var Aa,xs,e0,Ta,Df,t0,Sp,Np,Jn=xe(()=>{xt();Dr();Xn();yt();kn();ys();Aa=class{constructor(e,r,n){this.key=e,this.path=r,this.decodeStrategy=n}},xs=async t=>{let{agent:e,paths:r}=t,n=ue.from(t.canisterId),i=[...new Set(r)],s=i.map(a=>Ta(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 ln.create({certificate:f.certificate,rootKey:e.rootKey,canisterId:n}),E=(I,O)=>{if(O==="subnet"){let q=e0(f.certificate,n,e.rootKey);return{path:O,data:q}}else return{path:O,data:sr(I.lookup(Ta(O,n)))}},{path:w,data:x}=E(T,i[d]);if(!x)console.warn(`Expected to find result for path ${w}, but instead found nothing.`),typeof w=="string"?o.set(w,null):o.set(w.key,null);else switch(w){case"time":{o.set(w,fn(x));break}case"controllers":{o.set(w,Np(x));break}case"module_hash":{o.set(w,Df(x));break}case"subnet":{o.set(w,x);break}case"candid":{o.set(w,new TextDecoder().decode(x));break}default:if(typeof w!="string"&&"key"in w&&"path"in w)switch(w.decodeStrategy){case"raw":o.set(w.key,x);break;case"leb128":{o.set(w.key,Ba(x));break}case"cbor":{o.set(w.key,t0(x));break}case"hex":{o.set(w.key,Df(x));break}case"utf-8":o.set(w.key,Sp(x))}}}catch(f){if(!((l=f?.message)===null||l===void 0)&&l.includes("Invalid certificate"))throw new Ze(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},e0=(t,e,r)=>{if(!e._isPrincipal)throw new Error("Invalid canisterId");let n=At(new Uint8Array(t)),i=n.tree,s=n.delegation,o;if(s&&s.subnet_id?o=ue.fromUint8Array(new Uint8Array(s.subnet_id)):!s&&typeof r<"u"?(o=ue.selfAuthenticating(new Uint8Array(r)),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}):(o=ue.selfAuthenticating(ue.fromText("tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe").toUint8Array()),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}),!va({canisterId:e,subnetId:o,tree:i}))throw new Error("Canister not in range");let a=Er(["subnet",s.subnet_id,"node"],i);if(a.status!==Ve.Found)throw new Error("Node not found");if(a.value instanceof ArrayBuffer)throw new Error("Invalid node tree");let d=bs(a.value),l=new Map;return d.forEach(f=>{let T=ue.from(new Uint8Array(f[1])).toText(),E=Er(["public_key"],f[2]);if(E.status!==Ve.Found)throw new Error("Public key not found");let w=E.value;if(w.byteLength!==44)throw new Error("Invalid public key length");l.set(T,w)}),{subnetId:ue.fromUint8Array(new Uint8Array(s.subnet_id)).toText(),nodeKeys:l}},Ta=(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.`)},Df=t=>Ye(t),t0=t=>At(t),Sp=t=>new TextDecoder().decode(t),Np=t=>t0(t).map(r=>ue.fromUint8Array(new Uint8Array(r)))});xt();xt();var Ls=(t,e)=>{let r;return(...n)=>{let i=()=>t(...n);r&&clearTimeout(r),r=setTimeout(i,e!==void 0&&e>0?e:300)}},Sr=t=>t==null,cr=t=>!Sr(t),vl=class extends Error{},Ds=(t,e)=>{if(Sr(t))throw new vl(e)};var Al=" 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",Tl=/bot|spider|crawl|http|lighthouse/i,xn;function Sl(){if(xn instanceof RegExp)return xn;try{xn=new RegExp(Al,"i")}catch{xn=Tl}return xn}function ac(t){return!!t&&Sl().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}),E=t.Record({day:t.Nat8,month:t.Nat8,year:t.Int32}),w=t.Record({bounce_rate:t.Float64,average_page_views_per_session:t.Float64,daily_total_page_views:t.Vec(t.Tuple(E,t.Nat32)),total_page_views:t.Nat32,unique_page_views:t.Nat64,unique_sessions:t.Nat64}),x=t.Record({referrers:t.Vec(t.Tuple(t.Text,t.Nat32)),pages:t.Vec(t.Tuple(t.Text,t.Nat32))}),I=t.Variant({Navigate:t.Null,Restore:t.Null,Reload:t.Null,BackForward:t.Null,BackForwardCache:t.Null,Prerender:t.Null}),O=t.Record({id:t.Text,value:t.Float64,navigation_type:t.Opt(I),delta:t.Float64}),q=t.Variant({WebVitalsMetric:O}),V=t.Variant({CLS:t.Null,FCP:t.Null,INP:t.Null,LCP:t.Null,TTFB:t.Null}),Z=t.Record({updated_at:t.Nat64,session_id:t.Text,data:q,href:t.Text,metric_name:V,created_at:t.Nat64,satellite_id:t.Principal,version:t.Opt(t.Nat64)}),U=t.Record({cls:t.Opt(t.Float64),fcp:t.Opt(t.Float64),inp:t.Opt(t.Float64),lcp:t.Opt(t.Float64),ttfb:t.Opt(t.Float64)}),M=t.Record({overall:U,pages:t.Vec(t.Tuple(t.Text,U))}),Y=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)}),z=t.Record({total:t.Vec(t.Tuple(t.Text,t.Nat32))}),G=t.Record({performance_metrics:t.Bool,track_events:t.Bool,page_views:t.Bool}),ee=t.Record({updated_at:t.Nat64,features:t.Opt(G),created_at:t.Nat64,version:t.Opt(t.Nat64)}),D=t.Record({stable:t.Nat64,heap:t.Nat64}),ae=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:r,expires_at:t.Opt(t.Nat64)}),le=t.Record({controller:ae,controllers:t.Vec(t.Principal)}),_e=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)}),he=t.Variant({Ok:d,Err:t.Text}),K=t.Variant({Ok:t.Null,Err:t.Vec(t.Tuple(c,t.Text))}),ce=t.Record({session_id:t.Text,data:q,href:t.Text,metric_name:V,satellite_id:t.Principal,version:t.Opt(t.Nat64),user_agent:t.Opt(t.Text)}),H=t.Variant({Ok:Z,Err:t.Text}),k=t.Record({features:t.Opt(G),version:t.Opt(t.Nat64)}),W=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:Y,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],[w],["query"]),get_page_views_analytics_top_10:t.Func([o],[x],["query"]),get_performance_metrics:t.Func([o],[t.Vec(t.Tuple(c,Z))],["query"]),get_performance_metrics_analytics_web_vitals:t.Func([o],[M],["query"]),get_track_events:t.Func([o],[t.Vec(t.Tuple(c,Y))],["query"]),get_track_events_analytics:t.Func([o],[z],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,n))],["query"]),list_satellite_configs:t.Func([],[t.Vec(t.Tuple(t.Principal,ee))],["query"]),memory_size:t.Func([],[D],["query"]),set_controllers:t.Func([le],[t.Vec(t.Tuple(t.Principal,n))],[]),set_page_view:t.Func([c,_e],[he],[]),set_page_views:t.Func([t.Vec(t.Tuple(c,_e))],[K],[]),set_performance_metric:t.Func([c,ce],[H],[]),set_performance_metrics:t.Func([t.Vec(t.Tuple(c,ce))],[K],[]),set_satellite_configs:t.Func([t.Vec(t.Tuple(t.Principal,k))],[t.Vec(t.Tuple(t.Principal,ee))],[]),set_track_event:t.Func([c,W],[L],[]),set_track_events:t.Func([t.Vec(t.Tuple(c,W))],[K],[]),version:t.Func([],[t.Text],["query"])})};var S0=zr(Nc());var bi;(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"})(bi||(bi={}));xt();Dr();xt();Pn();yt();var py=new TextEncoder().encode(`
|
|
14
|
-
ic-request`);var on=class{getPrincipal(){return ue.anonymous()}async transformRequest(e){return Object.assign(Object.assign({},e),{body:{content:e.body}})}};kn();Pn();yt();Tn();var gf=zr(Di());var Cn=()=>{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 ns;(function(t){t.Call="call"})(ns||(ns={}));function an(){let t=new ArrayBuffer(16),e=new DataView(t),r=Cn(),n=Cn(),i=Cn(),s=Cn();return e.setUint32(0,r),e.setUint32(4,n),e.setUint32(8,i),e.setUint32(12,s),t}var Ch=BigInt(1e6),qh=60*1e3,Mr=class{constructor(e){let s=BigInt(Math.floor(Date.now()+e-qh))*Ch/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=s}toCBOR(){return gf.value.u64(this._value.toString(16),16)}toHash(){return Fe(this._value)}};function ta(t=an){return async e=>{let r=e.request.headers;e.request.headers=r,e.endpoint==="call"&&(e.body.nonce=t())}}function qn(t){let e=[];return t.forEach((r,n)=>{e.push([n,r])}),e}Dr();var Vn=class extends Ze{constructor(e,r){super(e),this.response=r,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};Jn();Xn();Js();var Es=BigInt(4294967295),Sa=BigInt(32);function r0(t,e=!1){return e?{h:Number(t&Es),l:Number(t>>Sa&Es)}:{h:Number(t>>Sa&Es)|0,l:Number(t&Es)|0}}function Rp(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}=r0(t[i],e);[r[i],n[i]]=[s,o]}return[r,n]}var Op=(t,e)=>BigInt(t>>>0)<<Sa|BigInt(e>>>0),Fp=(t,e,r)=>t>>>r,Ip=(t,e,r)=>t<<32-r|e>>>r,Up=(t,e,r)=>t>>>r|e<<32-r,Pp=(t,e,r)=>t<<32-r|e>>>r,Mp=(t,e,r)=>t<<64-r|e>>>r-32,kp=(t,e,r)=>t>>>r-32|e<<64-r,Cp=(t,e)=>e,qp=(t,e)=>t,Vp=(t,e,r)=>t<<r|e>>>32-r,$p=(t,e,r)=>e<<r|t>>>32-r,Gp=(t,e,r)=>e<<r-32|t>>>64-r,Hp=(t,e,r)=>t<<r-32|e>>>64-r;function jp(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}var Yp=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),zp=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,Kp=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),Zp=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,Wp=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0),Xp=(t,e,r,n,i,s)=>e+r+n+i+s+(t/2**32|0)|0;var Jp={fromBig:r0,split:Rp,toBig:Op,shrSH:Fp,shrSL:Ip,rotrSH:Up,rotrSL:Pp,rotrBH:Mp,rotrBL:kp,rotr32H:Cp,rotr32L:qp,rotlSH:Vp,rotlSL:$p,rotlBH:Gp,rotlBL:Hp,add:jp,add3L:Yp,add3H:zp,add4L:Kp,add4H:Zp,add5H:Xp,add5L:Wp},de=Jp;Zr();var[Qp,Lp]=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),vr=new Uint32Array(80),Na=class extends Wr{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:E,Gl:w,Hh:x,Hl:I}=this;return[e,r,n,i,s,o,c,a,d,l,f,T,E,w,x,I]}set(e,r,n,i,s,o,c,a,d,l,f,T,E,w,x,I){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=E|0,this.Gl=w|0,this.Hh=x|0,this.Hl=I|0}process(e,r){for(let V=0;V<16;V++,r+=4)Br[V]=e.getUint32(r),vr[V]=e.getUint32(r+=4);for(let V=16;V<80;V++){let Z=Br[V-15]|0,U=vr[V-15]|0,M=de.rotrSH(Z,U,1)^de.rotrSH(Z,U,8)^de.shrSH(Z,U,7),Y=de.rotrSL(Z,U,1)^de.rotrSL(Z,U,8)^de.shrSL(Z,U,7),z=Br[V-2]|0,G=vr[V-2]|0,ee=de.rotrSH(z,G,19)^de.rotrBH(z,G,61)^de.shrSH(z,G,6),D=de.rotrSL(z,G,19)^de.rotrBL(z,G,61)^de.shrSL(z,G,6),ae=de.add4L(Y,D,vr[V-7],vr[V-16]),le=de.add4H(ae,M,ee,Br[V-7],Br[V-16]);Br[V]=le|0,vr[V]=ae|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:c,Cl:a,Dh:d,Dl:l,Eh:f,El:T,Fh:E,Fl:w,Gh:x,Gl:I,Hh:O,Hl:q}=this;for(let V=0;V<80;V++){let Z=de.rotrSH(f,T,14)^de.rotrSH(f,T,18)^de.rotrBH(f,T,41),U=de.rotrSL(f,T,14)^de.rotrSL(f,T,18)^de.rotrBL(f,T,41),M=f&E^~f&x,Y=T&w^~T&I,z=de.add5L(q,U,Y,Lp[V],vr[V]),G=de.add5H(z,O,Z,M,Qp[V],Br[V]),ee=z|0,D=de.rotrSH(n,i,28)^de.rotrBH(n,i,34)^de.rotrBH(n,i,39),ae=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;O=x|0,q=I|0,x=E|0,I=w|0,E=f|0,w=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 he=de.add3L(ee,ae,_e);n=de.add3H(he,G,D,le),i=he|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:E,l:w}=de.add(this.Fh|0,this.Fl|0,E|0,w|0),{h:x,l:I}=de.add(this.Gh|0,this.Gl|0,x|0,I|0),{h:O,l:q}=de.add(this.Hh|0,this.Hl|0,O|0,q|0),this.set(n,i,s,o,c,a,d,l,f,T,E,w,x,I,O,q)}roundClean(){Br.fill(0),vr.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 n0=wn(()=>new Na);Zr();ha();wr();Kt();Kt();var Ct=BigInt(0),bt=BigInt(1),Bs=BigInt(2),Dp=BigInt(8),e1={zip215:!0};function t1(t){let e=us(t);return Mt(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function i0(t){let e=t1(t),{Fp:r,n,prehash:i,hash:s,randomBytes:o,nByteLength:c,h:a}=e,d=Bs<<BigInt(c*8)-bt,l=r.create,f=e.uvRatio||((H,k)=>{try{return{isValid:!0,value:r.sqrt(H*r.inv(k))}}catch{return{isValid:!1,value:Ct}}}),T=e.adjustScalarBytes||(H=>H),E=e.domain||((H,k,W)=>{if(k.length||W)throw new Error("Contexts/pre-hash are not supported");return H}),w=H=>typeof H=="bigint"&&Ct<H,x=(H,k)=>w(H)&&w(k)&&H<k,I=H=>H===Ct||x(H,d);function O(H,k){if(x(H,k))return H;throw new Error(`Expected valid scalar < ${k}, got ${typeof H} ${H}`)}function q(H){return H===Ct?H:O(H,n)}let V=new Map;function Z(H){if(!(H instanceof U))throw new Error("ExtendedPoint expected")}class U{constructor(k,W,L,re){if(this.ex=k,this.ey=W,this.ez=L,this.et=re,!I(k))throw new Error("x required");if(!I(W))throw new Error("y required");if(!I(L))throw new Error("z required");if(!I(re))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(k){if(k instanceof U)throw new Error("extended point not allowed");let{x:W,y:L}=k||{};if(!I(W)||!I(L))throw new Error("invalid affine point");return new U(W,L,bt,l(W*L))}static normalizeZ(k){let W=r.invertBatch(k.map(L=>L.ez));return k.map((L,re)=>L.toAffine(W[re])).map(U.fromAffine)}_setWindowSize(k){this._WINDOW_SIZE=k,V.delete(this)}assertValidity(){let{a:k,d:W}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:L,ey:re,ez:F,et:m}=this,fe=l(L*L),ie=l(re*re),se=l(F*F),Q=l(se*se),u=l(fe*k),h=l(se*l(u+ie)),p=l(Q+l(W*l(fe*ie)));if(h!==p)throw new Error("bad point: equation left != right (1)");let A=l(L*re),_=l(F*m);if(A!==_)throw new Error("bad point: equation left != right (2)")}equals(k){Z(k);let{ex:W,ey:L,ez:re}=this,{ex:F,ey:m,ez:fe}=k,ie=l(W*fe),se=l(F*re),Q=l(L*fe),u=l(m*re);return ie===se&&Q===u}is0(){return this.equals(U.ZERO)}negate(){return new U(l(-this.ex),this.ey,this.ez,l(-this.et))}double(){let{a:k}=e,{ex:W,ey:L,ez:re}=this,F=l(W*W),m=l(L*L),fe=l(Bs*l(re*re)),ie=l(k*F),se=W+L,Q=l(l(se*se)-F-m),u=ie+m,h=u-fe,p=ie-m,A=l(Q*h),_=l(u*p),v=l(Q*p),N=l(h*u);return new U(A,_,N,v)}add(k){Z(k);let{a:W,d:L}=e,{ex:re,ey:F,ez:m,et:fe}=this,{ex:ie,ey:se,ez:Q,et:u}=k;if(W===BigInt(-1)){let te=l((F-re)*(se+ie)),me=l((F+re)*(se-ie)),Be=l(me-te);if(Be===Ct)return this.double();let Se=l(m*Bs*u),ye=l(fe*Bs*Q),ne=ye+Se,ke=me+te,Qt=ye-Se,Ar=l(ne*Be),Tr=l(ke*Qt),ut=l(ne*Qt),Ee=l(Be*ke);return new U(Ar,Tr,Ee,ut)}let h=l(re*ie),p=l(F*se),A=l(fe*L*u),_=l(m*Q),v=l((re+F)*(ie+se)-h-p),N=_-A,g=_+A,B=l(p-W*h),R=l(v*N),S=l(g*B),$=l(v*B),X=l(N*g);return new U(R,S,X,$)}subtract(k){return this.add(k.negate())}wNAF(k){return z.wNAFCached(this,V,k,U.normalizeZ)}multiply(k){let{p:W,f:L}=this.wNAF(O(k,n));return U.normalizeZ([W,L])[0]}multiplyUnsafe(k){let W=q(k);return W===Ct?Y:this.equals(Y)||W===bt?this:this.equals(M)?this.wNAF(W).p:z.unsafeLadder(this,W)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return z.unsafeLadder(this,n).is0()}toAffine(k){let{ex:W,ey:L,ez:re}=this,F=this.is0();k==null&&(k=F?Dp:r.inv(re));let m=l(W*k),fe=l(L*k),ie=l(re*k);if(F)return{x:Ct,y:bt};if(ie!==bt)throw new Error("invZ was invalid");return{x:m,y:fe}}clearCofactor(){let{h:k}=e;return k===bt?this:this.multiplyUnsafe(k)}static fromHex(k,W=!1){let{d:L,a:re}=e,F=r.BYTES;k=ze("pointHex",k,F);let m=k.slice(),fe=k[F-1];m[F-1]=fe&-129;let ie=mr(m);ie===Ct||(W?O(ie,d):O(ie,r.ORDER));let se=l(ie*ie),Q=l(se-bt),u=l(L*se-re),{isValid:h,value:p}=f(Q,u);if(!h)throw new Error("Point.fromHex: invalid y coordinate");let A=(p&bt)===bt,_=(fe&128)!==0;if(!W&&p===Ct&&_)throw new Error("Point.fromHex: x=0 and x_0=1");return _!==A&&(p=l(-p)),U.fromAffine({x:p,y:ie})}static fromPrivateKey(k){return D(k).point}toRawBytes(){let{x:k,y:W}=this.toAffine(),L=kr(W,r.BYTES);return L[L.length-1]|=k&bt?128:0,L}toHex(){return Pt(this.toRawBytes())}}U.BASE=new U(e.Gx,e.Gy,bt,l(e.Gx*e.Gy)),U.ZERO=new U(Ct,bt,bt,Ct);let{BASE:M,ZERO:Y}=U,z=cs(U,c*8);function G(H){return Oe(H,n)}function ee(H){return G(mr(H))}function D(H){let k=c;H=ze("private key",H,k);let W=ze("hashed private key",s(H),2*k),L=T(W.slice(0,k)),re=W.slice(k,2*k),F=ee(L),m=M.multiply(F),fe=m.toRawBytes();return{head:L,prefix:re,scalar:F,point:m,pointBytes:fe}}function ae(H){return D(H).pointBytes}function le(H=new Uint8Array,...k){let W=Re(...k);return ee(s(E(W,ze("context",H),!!i)))}function _e(H,k,W={}){H=ze("message",H),i&&(H=i(H));let{prefix:L,scalar:re,pointBytes:F}=D(k),m=le(W.context,L,H),fe=M.multiply(m).toRawBytes(),ie=le(W.context,fe,F,H),se=G(m+ie*re);q(se);let Q=Re(fe,kr(se,r.BYTES));return ze("result",Q,c*2)}let he=e1;function K(H,k,W,L=he){let{context:re,zip215:F}=L,m=r.BYTES;H=ze("signature",H,2*m),k=ze("message",k),i&&(k=i(k));let fe=mr(H.slice(m,2*m)),ie,se,Q;try{ie=U.fromHex(W,F),se=U.fromHex(H.slice(0,m),F),Q=M.multiplyUnsafe(fe)}catch{return!1}if(!F&&ie.isSmallOrder())return!1;let u=le(re,se.toRawBytes(),ie.toRawBytes(),k);return se.add(ie.multiplyUnsafe(u)).subtract(Q).clearCofactor().equals(U.ZERO)}return M._setWindowSize(8),{CURVE:e,getPublicKey:ae,sign:_e,verify:K,ExtendedPoint:U,utils:{getExtendedPublicKey:D,randomPrivateKey:()=>o(r.BYTES),precompute(H=8,k=U.BASE){return k._setWindowSize(H),k.multiply(BigInt(3)),k}}}}wr();var Ra=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),s0=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Ng=BigInt(0),r1=BigInt(1),o0=BigInt(2),Rg=BigInt(3),n1=BigInt(5),i1=BigInt(8);function s1(t){let e=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),s=Ra,c=t*t%s*t%s,a=kt(c,o0,s)*c%s,d=kt(a,r1,s)*t%s,l=kt(d,n1,s)*d%s,f=kt(l,e,s)*l%s,T=kt(f,r,s)*f%s,E=kt(T,n,s)*T%s,w=kt(E,i,s)*E%s,x=kt(w,i,s)*E%s,I=kt(x,e,s)*l%s;return{pow_p_5_8:kt(I,o0,s)*t%s,b2:c}}function o1(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function a1(t,e){let r=Ra,n=Oe(e*e*e,r),i=Oe(n*n*e,r),s=s1(t*i).pow_p_5_8,o=Oe(t*n*s,r),c=Oe(e*o*o,r),a=o,d=Oe(o*s0,r),l=c===t,f=c===Oe(-t,r),T=c===Oe(-t*s0,r);return l&&(o=a),(f||T)&&(o=d),Af(o,r)&&(o=Oe(-o,r)),{isValid:l||f,value:o}}var c1=Yn(Ra,void 0,!0),u1={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:c1,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:i1,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:n0,randomBytes:di,adjustScalarBytes:o1,uvRatio:a1},a0=i0(u1);var c0=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},ct=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)},it,Qn,u0,f0,vs=class{constructor(e={}){it.set(this,void 0),Qn.set(this,void 0),this[u0]=this.entries.bind(this),this[f0]="ExpirableMap";let{source:r=[],expirationTime:n=10*60*1e3}=e,i=Date.now();c0(this,it,new Map([...r].map(([s,o])=>[s,{value:o,timestamp:i}])),"f"),c0(this,Qn,n,"f")}prune(){let e=Date.now();for(let[r,n]of ct(this,it,"f").entries())e-n.timestamp>ct(this,Qn,"f")&&ct(this,it,"f").delete(r);return this}set(e,r){this.prune();let n={value:r,timestamp:Date.now()};return ct(this,it,"f").set(e,n),this}get(e){let r=ct(this,it,"f").get(e);if(r!==void 0){if(Date.now()-r.timestamp>ct(this,Qn,"f")){ct(this,it,"f").delete(e);return}return r.value}}clear(){ct(this,it,"f").clear()}entries(){let e=ct(this,it,"f").entries();return function*(){for(let[n,i]of e)yield[n,i.value]}()}values(){let e=ct(this,it,"f").values();return function*(){for(let n of e)yield n.value}()}keys(){return ct(this,it,"f").keys()}forEach(e,r){for(let[n,i]of ct(this,it,"f").entries())e.call(r,i.value,n,this)}has(e){return ct(this,it,"f").has(e)}delete(e){return ct(this,it,"f").delete(e)}get size(){return ct(this,it,"f").size}};it=new WeakMap,Qn=new WeakMap,u0=Symbol.iterator,f0=Symbol.toStringTag;yt();var l0=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)")},d0=(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)")},Oa=(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)")},f1=(t,e)=>{let r=Oa(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)")},Ug=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]),Fa=Uint8Array.from([48,5,6,3,43,101,112]),Pg=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function h0(t,e){let r=2+l0(t.byteLength+1),n=e.byteLength+r+t.byteLength,i=0,s=new Uint8Array(1+l0(n)+n);return s[i++]=48,i+=d0(s,i,n),s.set(e,i),i+=e.byteLength,s[i++]=3,i+=d0(s,i,t.byteLength+1),s[i++]=0,s.set(new Uint8Array(t),i),s}var p0=(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+=Oa(i,r),!In(i.slice(r,r+e.byteLength),e))throw new Error("Not the expected OID.");r+=e.byteLength,n(3,"bit string");let s=f1(i,r)-1;r+=Oa(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 m0=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},y0=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)},As,Ts,Ln=class t{constructor(e){if(As.set(this,void 0),Ts.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");m0(this,As,e,"f"),m0(this,Ts,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 h0(e,Fa).buffer}static derDecode(e){let r=p0(e,Fa);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return y0(this,As,"f")}get derKey(){return y0(this,Ts,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};As=new WeakMap,Ts=new WeakMap;Ln.RAW_KEY_LENGTH=32;ys();var Ia=class{constructor(){this.observers=[]}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))}},Ss=class extends Ia{constructor(){super()}print(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)}};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},st=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)},Wt,Ns,Rs,Os,Fs,Is,Us,Ps,dn;var Dn=class t{constructor(e=t.default){Wt.set(this,void 0),Ns.set(this,void 0),Rs.set(this,void 0),Os.set(this,void 0),Fs.set(this,void 0),Is.set(this,void 0),Us.set(this,void 0),Ps.set(this,void 0),dn.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,Wt,r,"f"),Zt(this,Ns,n,"f"),Zt(this,Rs,i,"f"),Zt(this,Os,s,"f"),Zt(this,Ps,a,"f"),Zt(this,Fs,a.now(),"f"),Zt(this,Is,o,"f"),Zt(this,Us,c,"f")}get ellapsedTimeInMsec(){return st(this,Ps,"f").now()-st(this,Fs,"f")}get currentInterval(){return st(this,Wt,"f")}get count(){return st(this,dn,"f")}get randomValueFromInterval(){let e=st(this,Ns,"f")*st(this,Wt,"f"),r=st(this,Wt,"f")-e,n=st(this,Wt,"f")+e;return Math.random()*(n-r)+r}incrementCurrentInterval(){var e;return Zt(this,Wt,Math.min(st(this,Wt,"f")*st(this,Rs,"f"),st(this,Os,"f")),"f"),Zt(this,dn,(e=st(this,dn,"f"),e++,e),"f"),st(this,Wt,"f")}next(){return this.ellapsedTimeInMsec>=st(this,Is,"f")||st(this,dn,"f")>=st(this,Us,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};Wt=new WeakMap,Ns=new WeakMap,Rs=new WeakMap,Os=new WeakMap,Fs=new WeakMap,Is=new WeakMap,Us=new WeakMap,Ps=new WeakMap,dn=new WeakMap;Dn.default={initialInterval:500,randomizationFactor:.5,multiplier:1.5,maxInterval:6e4,maxElapsedTime:9e5,maxIterations:10,date:Date};var Ms=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)},Xt,qt,$r,Cs,hn,pn,Gr,Hr,g0,qs,Vs,Jt;(function(t){t.Received="received",t.Processing="processing",t.Replied="replied",t.Rejected="rejected",t.Unknown="unknown",t.Done="done"})(Jt||(Jt={}));var ks=5*60*1e3,l1="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae";var d1="ic0.app",h1=".ic0.app",p1="icp0.io",m1=".icp0.io",y1="icp-api.io",g1=".icp-api.io",ei=class extends Ze{constructor(e){super(e),this.message=e}},mn=class extends Ze{constructor(e){super(e),this.message=e}};function w1(){let t;if(typeof window<"u")if(window.fetch)t=window.fetch.bind(window);else throw new ei("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 ei("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 ei("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}var ti=class t{constructor(e={}){var r;if(Xt.add(this),this.rootKey=Ir(l1),this._timeDiffMsecs=0,this._rootKeyFetched=!1,qt.set(this,void 0),$r.set(this,void 0),this._isAgent=!0,Cs.set(this,0),this.log=new Ss,hn.set(this,[]),pn.set(this,[]),Gr.set(this,new vs({expirationTime:5*60*1e3})),Hr.set(this,!0),Vs.set(this,(i,s)=>{if(pe(this,Hr,"f")===!1)return i;if(!s)throw new gt("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,E=ue.fromUint8Array(T).toText(),w;if(o==="replied"){let{reply:V}=i;w=Un({status:o,reply:V,timestamp:BigInt(f),request_id:a})}else if(o==="rejected"){let{reject_code:V,reject_message:Z,error_code:U}=i;w=Un({status:o,reject_code:V,reject_message:Z,error_code:U,timestamp:BigInt(f),request_id:a})}else throw new Error(`Unknown status: ${o}`);let x=at(d,new Uint8Array(w)),I=s?.nodeKeys.get(E);if(!I)throw new gt("Invalid signature from replica signed query: no matching node key found.");let O=Ln.fromDer(I).rawKey;if(a0.verify(l.signature,new Uint8Array(x),new Uint8Array(O)))return i;throw new gt(`Invalid signature from replica ${E} 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||w1()||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&&Ms(this,Hr,e.verifyQuerySignatures,"f"),Ms(this,qt,(r=e.retryTimes)!==null&&r!==void 0?r:3,"f");let n=()=>new Dn({maxIterations:pe(this,qt,"f")});if(Ms(this,$r,e.backoffStrategy||n,"f"),this._host.hostname.endsWith(h1)?this._host.hostname=d1:this._host.hostname.endsWith(m1)?this._host.hostname=p1:this._host.hostname.endsWith(g1)&&(this._host.hostname=y1),e.credentials){let{name:i,password:s}=e.credentials;this._credentials=`${i}${s?":"+s:""}`}this._identity=Promise.resolve(e.identity||new on),this.addTransform("update",ta(an)),e.useQueryNonces&&this.addTransform("query",ta(an)),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,Cs,"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,pn,"f").findIndex(s=>(s.priority||0)<n);pe(this,pn,"f").splice(i>=0?i:pe(this,pn,"f").length,0,Object.assign(r,{priority:n}))}else if(e==="query"){let i=pe(this,hn,"f").findIndex(s=>(s.priority||0)<n);pe(this,hn,"f").splice(i>=0?i:pe(this,hn,"f").length,0,Object.assign(r,{priority:n}))}}async getPrincipal(){if(!this._identity)throw new mn("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 mn("This identity has expired due this application's security policy. Please refresh your authentication.");let s=ue.from(e),o=r.effectiveCanisterId?ue.from(r.effectiveCanisterId):s,c=i.getPrincipal()||ue.anonymous(),a=new Mr(ks);Math.abs(this._timeDiffMsecs)>1e3*30&&(a=new Mr(ks+this._timeDiffMsecs));let d={request_type:ns.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=ts(l.body);this.log.print(`fetching "/api/v2/canister/${o.toText()}/call" with request:`,l);let T=pe(this,$r,"f").call(this),E=pe(this,Xt,"m",qs).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}),[w,x]=await Promise.all([E,Wi(d)]),I=await w.arrayBuffer(),O=w.status===200&&I.byteLength>0?At(I):null;return{requestId:x,response:{ok:w.ok,status:w.status,statusText:w.statusText,body:O,headers:qn(w.headers)}}}async query(e,r,n){let i=pe(this,$r,"f").call(this),s=r.effectiveCanisterId?ue.from(r.effectiveCanisterId):ue.from(e);this.log.print(`ecid ${s.toString()}`),this.log.print(`canisterId ${e.toString()}`);let o=async()=>{let l=await(n!==void 0?await n:await this._identity);if(!l)throw new mn("This identity has expired due this application's security policy. Please refresh your authentication.");let f=ue.from(e),T=l?.getPrincipal()||ue.anonymous(),E={request_type:"query",canister_id:f,method_name:r.methodName,arg:r.arg,sender:T,ingress_expiry:new Mr(ks)},w=await Wi(E),x=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},this._credentials?{Authorization:"Basic "+btoa(this._credentials)}:{})},endpoint:"read",body:E});x=await l?.transformRequest(x);let I=ts(x.body),O={canister:f.toText(),ecid:s,transformedRequest:x,body:I,requestId:w,backoff:i,tries:0};return await pe(this,Xt,"m",g0).call(this,O)},c=async()=>{if(!pe(this,Hr,"f"))return;let l=pe(this,Gr,"f").get(s.toString());return l||(await this.fetchSubnetKeys(s.toString()),pe(this,Gr,"f").get(s.toString()))},[a,d]=await Promise.all([o(),c()]);if(this.log.print("Query response:",a),!pe(this,Hr,"f"))return a;try{return pe(this,Vs,"f").call(this,a,d)}catch{this.log.warn("Query response verification failed. Retrying with fresh subnet keys."),pe(this,Gr,"f").delete(e.toString()),await this.fetchSubnetKeys(s.toString());let f=pe(this,Gr,"f").get(e.toString());if(!f)throw new gt("Invalid signature from replica signed query: no matching node key found.");return pe(this,Vs,"f").call(this,a,f)}}async createReadStateRequest(e,r){let n=await(r!==void 0?await r:await this._identity);if(!n)throw new mn("This identity has expired due this application's security policy. Please refresh your authentication.");let i=n?.getPrincipal()||ue.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 Mr(ks)}});return n?.transformRequest(s)}async readState(e,r,n,i){let s=typeof e=="string"?ue.fromText(e):e,o=i??await this.createReadStateRequest(r,n),c=ts(o.body);this.log.print(`fetching "/api/v2/canister/${s}/read_state" with request:`,o);let a=pe(this,$r,"f").call(this),d=await pe(this,Xt,"m",qs).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: ${
|
|
16
|
-
Body: ${await
|
|
17
|
-
`);let
|
|
18
|
-
Code: ${
|
|
19
|
-
Body: ${await
|
|
20
|
-
`,{ok:
|
|
21
|
-
${
|
|
22
|
-
Retrying query.`),await
|
|
23
|
-
${
|
|
24
|
-
Retrying request.`),await
|
|
13
|
+
variant ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Pt(t)}`)}encodeValue(t){for(let r=0;r<this._fields.length;r++){let[n,i]=this._fields[r];if(t.hasOwnProperty(n)){let s=Ot(r),o=i.encodeValue(t[n]);return Et(s,o)}}throw Error("Variant has no data: "+t)}_buildTypeTableImpl(t){this._fields.forEach(([,s])=>{s.buildTypeTable(t)});let r=jt(-21),n=Ot(this._fields.length),i=this._fields.map(([s,o])=>Et(Ot(Re(s)),o.encodeType(t)));t.add(this,Et(r,n,...i))}decodeValue(t,r){let n=this.checkType(r);if(!(n instanceof e))throw new Error("Not a variant type");let i=Number(Gt(t));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(Re(s)===Re(a)){let l=c.decodeValue(t,o);return{[a]:l}}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(t){for(let[r,n]of this._fields)if(t.hasOwnProperty(r)){let i=n.valueToString(t[r]);return i==="null"?`variant {${r}}`:`variant {${r}=${i}}`}throw new Error("Variant has no data: "+t)}},wr=class e extends ze{constructor(){super(...arguments),this._id=e._counter++,this._type=void 0}accept(t,r){if(!this._type)throw Error("Recursive type uninitialized.");return t.visitRec(this,this._type,r)}fill(t){this._type=t}getType(){return this._type}covariant(t){if(this._type&&this._type.covariant(t))return!0;throw new Error(`Invalid ${this.display()} argument: ${Pt(t)}`)}encodeValue(t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.encodeValue(t)}_buildTypeTableImpl(t){if(!this._type)throw Error("Recursive type uninitialized.");t.add(this,new Uint8Array([])),this._type.buildTypeTable(t),t.merge(this,this._type.name)}decodeValue(t,r){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.decodeValue(t,r)}get name(){return`rec_${this._id}`}display(){if(!this._type)throw Error("Recursive type uninitialized.");return`\u03BC${this.name}.${this._type.name}`}valueToString(t){if(!this._type)throw Error("Recursive type uninitialized.");return this._type.valueToString(t)}};wr._counter=0;Yi=class extends ue{accept(t,r){return t.visitPrincipal(this,r)}covariant(t){if(t&&t._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${Pt(t)}`)}encodeValue(t){let r=t.toUint8Array(),n=Ot(r.byteLength);return Et(new Uint8Array([1]),n,r)}encodeType(){return jt(-24)}decodeValue(t,r){return this.checkType(r),Fo(t)}get name(){return"principal"}valueToString(t){return`${this.name} "${t.toText()}"`}},kn=class extends ze{constructor(t,r,n=[]){super(),this.argTypes=t,this.retTypes=r,this.annotations=n}static argsToString(t,r){if(t.length!==r.length)throw new Error("arity mismatch");return"("+t.map((n,i)=>n.valueToString(r[i])).join(", ")+")"}accept(t,r){return t.visitFunc(this,r)}covariant(t){if(Array.isArray(t)&&t.length===2&&t[0]&&t[0]._isPrincipal&&typeof t[1]=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${Pt(t)}`)}encodeValue([t,r]){let n=t.toUint8Array(),i=Ot(n.byteLength),s=Et(new Uint8Array([1]),i,n),o=new TextEncoder().encode(r),a=Ot(o.byteLength);return Et(new Uint8Array([1]),s,a,o)}_buildTypeTableImpl(t){this.argTypes.forEach(l=>l.buildTypeTable(t)),this.retTypes.forEach(l=>l.buildTypeTable(t));let r=jt(-22),n=Ot(this.argTypes.length),i=Et(...this.argTypes.map(l=>l.encodeType(t))),s=Ot(this.retTypes.length),o=Et(...this.retTypes.map(l=>l.encodeType(t))),a=Ot(this.annotations.length),c=Et(...this.annotations.map(l=>this.encodeAnnotation(l)));t.add(this,Et(r,n,i,s,o,a,c))}decodeValue(t){if(yr(t)!==1)throw new Error("Cannot decode function reference");let n=Fo(t),i=Number(Gt(t)),s=gr(t,i),a=new TextDecoder("utf8",{fatal:!0}).decode(s);return[n,a]}get name(){let t=this.argTypes.map(i=>i.name).join(", "),r=this.retTypes.map(i=>i.name).join(", "),n=" "+this.annotations.join(" ");return`(${t}) -> (${r})${n}`}valueToString([t,r]){return`func "${t.toText()}".${r}`}display(){let t=this.argTypes.map(i=>i.display()).join(", "),r=this.retTypes.map(i=>i.display()).join(", "),n=" "+this.annotations.join(" ");return`(${t}) \u2192 (${r})${n}`}encodeAnnotation(t){if(t==="query")return new Uint8Array([1]);if(t==="oneway")return new Uint8Array([2]);if(t==="composite_query")return new Uint8Array([3]);throw new Error("Illegal function annotation")}},zi=class extends ze{constructor(t){super(),this._fields=Object.entries(t).sort((r,n)=>r[0]<n[0]?-1:r[0]>n[0]?1:0)}accept(t,r){return t.visitService(this,r)}covariant(t){if(t&&t._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${Pt(t)}`)}encodeValue(t){let r=t.toUint8Array(),n=Ot(r.length);return Et(new Uint8Array([1]),n,r)}_buildTypeTableImpl(t){this._fields.forEach(([s,o])=>o.buildTypeTable(t));let r=jt(-23),n=Ot(this._fields.length),i=this._fields.map(([s,o])=>{let a=new TextEncoder().encode(s),c=Ot(a.length);return Et(c,a,o.encodeType(t))});t.add(this,Et(r,n,...i))}decodeValue(t){return Fo(t)}get name(){return`service {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}valueToString(t){return`service "${t.toText()}"`}};Jc=new Pi,Qc=new an,yh=new ki,Lc=new Mi,Dc=new Ci,tu=new qi,eu=new $i,ru=new Vi,nu=new In(32),iu=new In(64),su=new rr(8),ou=new rr(16),au=new rr(32),cu=new rr(64),uu=new Ye(8),fu=new Ye(16),lu=new Ye(32),hu=new Ye(64),du=new Yi});var Io=bt(()=>{});var Eu=bt(()=>{Uo();xe();Io()});var vu=bt(()=>{});var Mn=bt(()=>{Eu();Io();Uo();To();Ro();Oi();vu()});var ju={};Sn(ju,{Buffer:()=>Z,INSPECT_MAX_BYTES:()=>Ou,SlowBuffer:()=>Nh,isBuffer:()=>Hu,kMaxLength:()=>vh});function Su(){ko=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t<r;++t)Ke[t]=e[t],Ee[e.charCodeAt(t)]=t;Ee[45]=62,Ee[95]=63}function bh(e){ko||Su();var t,r,n,i,s,o,a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");s=e[a-2]==="="?2:e[a-1]==="="?1:0,o=new wh(a*3/4-s),n=s>0?a-4:a;var c=0;for(t=0,r=0;t<n;t+=4,r+=3)i=Ee[e.charCodeAt(t)]<<18|Ee[e.charCodeAt(t+1)]<<12|Ee[e.charCodeAt(t+2)]<<6|Ee[e.charCodeAt(t+3)],o[c++]=i>>16&255,o[c++]=i>>8&255,o[c++]=i&255;return s===2?(i=Ee[e.charCodeAt(t)]<<2|Ee[e.charCodeAt(t+1)]>>4,o[c++]=i&255):s===1&&(i=Ee[e.charCodeAt(t)]<<10|Ee[e.charCodeAt(t+1)]<<4|Ee[e.charCodeAt(t+2)]>>2,o[c++]=i>>8&255,o[c++]=i&255),o}function xh(e){return Ke[e>>18&63]+Ke[e>>12&63]+Ke[e>>6&63]+Ke[e&63]}function _h(e,t,r){for(var n,i=[],s=t;s<r;s+=3)n=(e[s]<<16)+(e[s+1]<<8)+e[s+2],i.push(xh(n));return i.join("")}function Bu(e){ko||Su();for(var t,r=e.length,n=r%3,i="",s=[],o=16383,a=0,c=r-n;a<c;a+=o)s.push(_h(e,a,a+o>c?c:a+o));return n===1?(t=e[r-1],i+=Ke[t>>2],i+=Ke[t<<4&63],i+="=="):n===2&&(t=(e[r-2]<<8)+e[r-1],i+=Ke[t>>10],i+=Ke[t>>4&63],i+=Ke[t<<2&63],i+="="),s.push(i),s.join("")}function Zi(e,t,r,n,i){var s,o,a=i*8-n-1,c=(1<<a)-1,l=c>>1,d=-7,h=r?i-1:0,N=r?-1:1,w=e[t+h];for(h+=N,s=w&(1<<-d)-1,w>>=-d,d+=a;d>0;s=s*256+e[t+h],h+=N,d-=8);for(o=s&(1<<-d)-1,s>>=-d,d+=n;d>0;o=o*256+e[t+h],h+=N,d-=8);if(s===0)s=1-l;else{if(s===c)return o?NaN:(w?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-l}return(w?-1:1)*o*Math.pow(2,s-n)}function Nu(e,t,r,n,i,s){var o,a,c,l=s*8-i-1,d=(1<<l)-1,h=d>>1,N=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=n?0:s-1,u=n?1:-1,x=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=d):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+h>=1?t+=N/c:t+=N*Math.pow(2,1-h),t*c>=2&&(o++,c/=2),o+h>=d?(a=0,o=d):o+h>=1?(a=(t*c-1)*Math.pow(2,i),o=o+h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;e[r+w]=a&255,w+=u,a/=256,i-=8);for(o=o<<i|a,l+=i;l>0;e[r+w]=o&255,w+=u,o/=256,l-=8);e[r+w-u]|=x*128}function Ki(){return Z.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function nr(e,t){if(Ki()<t)throw new RangeError("Invalid typed array length");return Z.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t),e.__proto__=Z.prototype):(e===null&&(e=new Z(t)),e.length=t),e}function Z(e,t,r){if(!Z.TYPED_ARRAY_SUPPORT&&!(this instanceof Z))return new Z(e,t,r);if(typeof e=="number"){if(typeof t=="string")throw new Error("If encoding is specified then the first argument must be a string");return Mo(this,e)}return Fu(this,e,t,r)}function Fu(e,t,r,n){if(typeof t=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&t instanceof ArrayBuffer?Th(e,t,r,n):typeof t=="string"?Ah(e,t,r):Sh(e,t)}function Uu(e){if(typeof e!="number")throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function Bh(e,t,r,n){return Uu(t),t<=0?nr(e,t):r!==void 0?typeof n=="string"?nr(e,t).fill(r,n):nr(e,t).fill(r):nr(e,t)}function Mo(e,t){if(Uu(t),e=nr(e,t<0?0:Co(t)|0),!Z.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function Ah(e,t,r){if((typeof r!="string"||r==="")&&(r="utf8"),!Z.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=Iu(t,r)|0;e=nr(e,n);var i=e.write(t,r);return i!==n&&(e=e.slice(0,i)),e}function Po(e,t){var r=t.length<0?0:Co(t.length)|0;e=nr(e,r);for(var n=0;n<r;n+=1)e[n]=t[n]&255;return e}function Th(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");return r===void 0&&n===void 0?t=new Uint8Array(t):n===void 0?t=new Uint8Array(t,r):t=new Uint8Array(t,r,n),Z.TYPED_ARRAY_SUPPORT?(e=t,e.__proto__=Z.prototype):e=Po(e,t),e}function Sh(e,t){if(We(t)){var r=Co(t.length)|0;return e=nr(e,r),e.length===0||t.copy(e,0,0,r),e}if(t){if(typeof ArrayBuffer<"u"&&t.buffer instanceof ArrayBuffer||"length"in t)return typeof t.length!="number"||Wh(t.length)?nr(e,0):Po(e,t);if(t.type==="Buffer"&&Ru(t.data))return Po(e,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function Co(e){if(e>=Ki())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Ki().toString(16)+" bytes");return e|0}function Nh(e){return+e!=e&&(e=0),Z.alloc(+e)}function We(e){return!!(e!=null&&e._isBuffer)}function Iu(e,t){if(We(e))return e.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;typeof e!="string"&&(e=""+e);var r=e.length;if(r===0)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Wi(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Vu(e).length;default:if(n)return Wi(e).length;t=(""+t).toLowerCase(),n=!0}}function Rh(e,t,r){var n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return $h(this,t,r);case"utf8":case"utf-8":return Mu(this,t,r);case"ascii":return Ch(this,t,r);case"latin1":case"binary":return qh(this,t,r);case"base64":return kh(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Vh(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function kr(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Pu(e,t,r,n,i){if(e.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:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof t=="string"&&(t=Z.from(t,n)),We(t))return t.length===0?-1:Au(e,t,r,n,i);if(typeof t=="number")return t=t&255,Z.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Au(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Au(e,t,r,n,i){var s=1,o=e.length,a=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||t.length<2)return-1;s=2,o/=2,a/=2,r/=2}function c(w,u){return s===1?w[u]:w.readUInt16BE(u*s)}var l;if(i){var d=-1;for(l=r;l<o;l++)if(c(e,l)===c(t,d===-1?0:l-d)){if(d===-1&&(d=l),l-d+1===a)return d*s}else d!==-1&&(l-=l-d),d=-1}else for(r+a>o&&(r=o-a),l=r;l>=0;l--){for(var h=!0,N=0;N<a;N++)if(c(e,l+N)!==c(t,N)){h=!1;break}if(h)return l}return-1}function Oh(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var s=t.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(t.substr(o*2,2),16);if(isNaN(a))return o;e[r+o]=a}return o}function Fh(e,t,r,n){return Qi(Wi(t,e.length-r),e,r,n)}function ku(e,t,r,n){return Qi(zh(t),e,r,n)}function Uh(e,t,r,n){return ku(e,t,r,n)}function Ih(e,t,r,n){return Qi(Vu(t),e,r,n)}function Ph(e,t,r,n){return Qi(Kh(t,e.length-r),e,r,n)}function kh(e,t,r){return t===0&&r===e.length?Bu(e):Bu(e.slice(t,r))}function Mu(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var s=e[i],o=null,a=s>239?4:s>223?3:s>191?2:1;if(i+a<=r){var c,l,d,h;switch(a){case 1:s<128&&(o=s);break;case 2:c=e[i+1],(c&192)===128&&(h=(s&31)<<6|c&63,h>127&&(o=h));break;case 3:c=e[i+1],l=e[i+2],(c&192)===128&&(l&192)===128&&(h=(s&15)<<12|(c&63)<<6|l&63,h>2047&&(h<55296||h>57343)&&(o=h));break;case 4:c=e[i+1],l=e[i+2],d=e[i+3],(c&192)===128&&(l&192)===128&&(d&192)===128&&(h=(s&15)<<18|(c&63)<<12|(l&63)<<6|d&63,h>65535&&h<1114112&&(o=h))}}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 Mh(n)}function Mh(e){var t=e.length;if(t<=Tu)return String.fromCharCode.apply(String,e);for(var r="",n=0;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Tu));return r}function Ch(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]&127);return n}function qh(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function $h(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",s=t;s<r;++s)i+=Yh(e[s]);return i}function Vh(e,t,r){for(var n=e.slice(t,r),i="",s=0;s<n.length;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}function Qt(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function fe(e,t,r,n,i,s){if(!We(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function Xi(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,s=Math.min(e.length-r,2);i<s;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>(n?i:1-i)*8}function Ji(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,s=Math.min(e.length-r,4);i<s;++i)e[r+i]=t>>>(n?i:3-i)*8&255}function Cu(e,t,r,n,i,s){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function qu(e,t,r,n,i){return i||Cu(e,t,r,4),Nu(e,t,r,n,23,4),r+4}function $u(e,t,r,n,i){return i||Cu(e,t,r,8),Nu(e,t,r,n,52,8),r+8}function Gh(e){if(e=jh(e).replace(Hh,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function jh(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function Yh(e){return e<16?"0"+e.toString(16):e.toString(16)}function Wi(e,t){t=t||1/0;for(var r,n=e.length,i=null,s=[],o=0;o<n;++o){if(r=e.charCodeAt(o),r>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(t-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&s.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;s.push(r)}else if(r<2048){if((t-=2)<0)break;s.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;s.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=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 zh(e){for(var t=[],r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function Kh(e,t){for(var r,n,i,s=[],o=0;o<e.length&&!((t-=2)<0);++o)r=e.charCodeAt(o),n=r>>8,i=r%256,s.push(i),s.push(n);return s}function Vu(e){return bh(Gh(e))}function Qi(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Wh(e){return e!==e}function Hu(e){return e!=null&&(!!e._isBuffer||Gu(e)||Zh(e))}function Gu(e){return!!e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function Zh(e){return typeof e.readFloatLE=="function"&&typeof e.slice=="function"&&Gu(e.slice(0,0))}var Ke,Ee,wh,ko,Eh,Ru,Ou,vh,Tu,Hh,Yu=bt(()=>{Ke=[],Ee=[],wh=typeof Uint8Array<"u"?Uint8Array:Array,ko=!1;Eh={}.toString,Ru=Array.isArray||function(e){return Eh.call(e)=="[object Array]"};Ou=50;Z.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;vh=Ki();Z.poolSize=8192;Z._augment=function(e){return e.__proto__=Z.prototype,e};Z.from=function(e,t,r){return Fu(null,e,t,r)};Z.TYPED_ARRAY_SUPPORT&&(Z.prototype.__proto__=Uint8Array.prototype,Z.__proto__=Uint8Array);Z.alloc=function(e,t,r){return Bh(null,e,t,r)};Z.allocUnsafe=function(e){return Mo(null,e)};Z.allocUnsafeSlow=function(e){return Mo(null,e)};Z.isBuffer=Hu;Z.compare=function(t,r){if(!We(t)||!We(r))throw new TypeError("Arguments must be Buffers");if(t===r)return 0;for(var n=t.length,i=r.length,s=0,o=Math.min(n,i);s<o;++s)if(t[s]!==r[s]){n=t[s],i=r[s];break}return n<i?-1:i<n?1:0};Z.isEncoding=function(t){switch(String(t).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}};Z.concat=function(t,r){if(!Ru(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return Z.alloc(0);var n;if(r===void 0)for(r=0,n=0;n<t.length;++n)r+=t[n].length;var i=Z.allocUnsafe(r),s=0;for(n=0;n<t.length;++n){var o=t[n];if(!We(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(i,s),s+=o.length}return i};Z.byteLength=Iu;Z.prototype._isBuffer=!0;Z.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var r=0;r<t;r+=2)kr(this,r,r+1);return this};Z.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var r=0;r<t;r+=4)kr(this,r,r+3),kr(this,r+1,r+2);return this};Z.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var r=0;r<t;r+=8)kr(this,r,r+7),kr(this,r+1,r+6),kr(this,r+2,r+5),kr(this,r+3,r+4);return this};Z.prototype.toString=function(){var t=this.length|0;return t===0?"":arguments.length===0?Mu(this,0,t):Rh.apply(this,arguments)};Z.prototype.equals=function(t){if(!We(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:Z.compare(this,t)===0};Z.prototype.inspect=function(){var t="",r=Ou;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"};Z.prototype.compare=function(t,r,n,i,s){if(!We(t))throw new TypeError("Argument must be a Buffer");if(r===void 0&&(r=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),r<0||n>t.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===t)return 0;for(var o=s-i,a=n-r,c=Math.min(o,a),l=this.slice(i,s),d=t.slice(r,n),h=0;h<c;++h)if(l[h]!==d[h]){o=l[h],a=d[h];break}return o<a?-1:a<o?1:0};Z.prototype.includes=function(t,r,n){return this.indexOf(t,r,n)!==-1};Z.prototype.indexOf=function(t,r,n){return Pu(this,t,r,n,!0)};Z.prototype.lastIndexOf=function(t,r,n){return Pu(this,t,r,n,!1)};Z.prototype.write=function(t,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),t.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 Oh(this,t,r,n);case"utf8":case"utf-8":return Fh(this,t,r,n);case"ascii":return ku(this,t,r,n);case"latin1":case"binary":return Uh(this,t,r,n);case"base64":return Ih(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ph(this,t,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};Z.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};Tu=4096;Z.prototype.slice=function(t,r){var n=this.length;t=~~t,r=r===void 0?n:~~r,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<t&&(r=t);var i;if(Z.TYPED_ARRAY_SUPPORT)i=this.subarray(t,r),i.__proto__=Z.prototype;else{var s=r-t;i=new Z(s,void 0);for(var o=0;o<s;++o)i[o]=this[o+t]}return i};Z.prototype.readUIntLE=function(t,r,n){t=t|0,r=r|0,n||Qt(t,r,this.length);for(var i=this[t],s=1,o=0;++o<r&&(s*=256);)i+=this[t+o]*s;return i};Z.prototype.readUIntBE=function(t,r,n){t=t|0,r=r|0,n||Qt(t,r,this.length);for(var i=this[t+--r],s=1;r>0&&(s*=256);)i+=this[t+--r]*s;return i};Z.prototype.readUInt8=function(t,r){return r||Qt(t,1,this.length),this[t]};Z.prototype.readUInt16LE=function(t,r){return r||Qt(t,2,this.length),this[t]|this[t+1]<<8};Z.prototype.readUInt16BE=function(t,r){return r||Qt(t,2,this.length),this[t]<<8|this[t+1]};Z.prototype.readUInt32LE=function(t,r){return r||Qt(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};Z.prototype.readUInt32BE=function(t,r){return r||Qt(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};Z.prototype.readIntLE=function(t,r,n){t=t|0,r=r|0,n||Qt(t,r,this.length);for(var i=this[t],s=1,o=0;++o<r&&(s*=256);)i+=this[t+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*r)),i};Z.prototype.readIntBE=function(t,r,n){t=t|0,r=r|0,n||Qt(t,r,this.length);for(var i=r,s=1,o=this[t+--i];i>0&&(s*=256);)o+=this[t+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*r)),o};Z.prototype.readInt8=function(t,r){return r||Qt(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};Z.prototype.readInt16LE=function(t,r){r||Qt(t,2,this.length);var n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};Z.prototype.readInt16BE=function(t,r){r||Qt(t,2,this.length);var n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};Z.prototype.readInt32LE=function(t,r){return r||Qt(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};Z.prototype.readInt32BE=function(t,r){return r||Qt(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};Z.prototype.readFloatLE=function(t,r){return r||Qt(t,4,this.length),Zi(this,t,!0,23,4)};Z.prototype.readFloatBE=function(t,r){return r||Qt(t,4,this.length),Zi(this,t,!1,23,4)};Z.prototype.readDoubleLE=function(t,r){return r||Qt(t,8,this.length),Zi(this,t,!0,52,8)};Z.prototype.readDoubleBE=function(t,r){return r||Qt(t,8,this.length),Zi(this,t,!1,52,8)};Z.prototype.writeUIntLE=function(t,r,n,i){if(t=+t,r=r|0,n=n|0,!i){var s=Math.pow(2,8*n)-1;fe(this,t,r,n,s,0)}var o=1,a=0;for(this[r]=t&255;++a<n&&(o*=256);)this[r+a]=t/o&255;return r+n};Z.prototype.writeUIntBE=function(t,r,n,i){if(t=+t,r=r|0,n=n|0,!i){var s=Math.pow(2,8*n)-1;fe(this,t,r,n,s,0)}var o=n-1,a=1;for(this[r+o]=t&255;--o>=0&&(a*=256);)this[r+o]=t/a&255;return r+n};Z.prototype.writeUInt8=function(t,r,n){return t=+t,r=r|0,n||fe(this,t,r,1,255,0),Z.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=t&255,r+1};Z.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r|0,n||fe(this,t,r,2,65535,0),Z.TYPED_ARRAY_SUPPORT?(this[r]=t&255,this[r+1]=t>>>8):Xi(this,t,r,!0),r+2};Z.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r|0,n||fe(this,t,r,2,65535,0),Z.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=t&255):Xi(this,t,r,!1),r+2};Z.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r|0,n||fe(this,t,r,4,4294967295,0),Z.TYPED_ARRAY_SUPPORT?(this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255):Ji(this,t,r,!0),r+4};Z.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r|0,n||fe(this,t,r,4,4294967295,0),Z.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255):Ji(this,t,r,!1),r+4};Z.prototype.writeIntLE=function(t,r,n,i){if(t=+t,r=r|0,!i){var s=Math.pow(2,8*n-1);fe(this,t,r,n,s-1,-s)}var o=0,a=1,c=0;for(this[r]=t&255;++o<n&&(a*=256);)t<0&&c===0&&this[r+o-1]!==0&&(c=1),this[r+o]=(t/a>>0)-c&255;return r+n};Z.prototype.writeIntBE=function(t,r,n,i){if(t=+t,r=r|0,!i){var s=Math.pow(2,8*n-1);fe(this,t,r,n,s-1,-s)}var o=n-1,a=1,c=0;for(this[r+o]=t&255;--o>=0&&(a*=256);)t<0&&c===0&&this[r+o+1]!==0&&(c=1),this[r+o]=(t/a>>0)-c&255;return r+n};Z.prototype.writeInt8=function(t,r,n){return t=+t,r=r|0,n||fe(this,t,r,1,127,-128),Z.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[r]=t&255,r+1};Z.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r|0,n||fe(this,t,r,2,32767,-32768),Z.TYPED_ARRAY_SUPPORT?(this[r]=t&255,this[r+1]=t>>>8):Xi(this,t,r,!0),r+2};Z.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r|0,n||fe(this,t,r,2,32767,-32768),Z.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=t&255):Xi(this,t,r,!1),r+2};Z.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r|0,n||fe(this,t,r,4,2147483647,-2147483648),Z.TYPED_ARRAY_SUPPORT?(this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24):Ji(this,t,r,!0),r+4};Z.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r|0,n||fe(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),Z.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255):Ji(this,t,r,!1),r+4};Z.prototype.writeFloatLE=function(t,r,n){return qu(this,t,r,!0,n)};Z.prototype.writeFloatBE=function(t,r,n){return qu(this,t,r,!1,n)};Z.prototype.writeDoubleLE=function(t,r,n){return $u(this,t,r,!0,n)};Z.prototype.writeDoubleBE=function(t,r,n){return $u(this,t,r,!1,n)};Z.prototype.copy=function(t,r,n,i){if(n||(n=0),!i&&i!==0&&(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&i<n&&(i=n),i===n||t.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),t.length-r<i-n&&(i=t.length-r+n);var s=i-n,o;if(this===t&&n<r&&r<i)for(o=s-1;o>=0;--o)t[o+r]=this[o+n];else if(s<1e3||!Z.TYPED_ARRAY_SUPPORT)for(o=0;o<s;++o)t[o+r]=this[o+n];else Uint8Array.prototype.set.call(t,this.subarray(n,n+s),r);return s};Z.prototype.fill=function(t,r,n,i){if(typeof t=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),t.length===1){var s=t.charCodeAt(0);s<256&&(t=s)}if(i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!Z.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else typeof t=="number"&&(t=t&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,t||(t=0);var o;if(typeof t=="number")for(o=r;o<n;++o)this[o]=t;else{var a=We(t)?t:Wi(new Z(t,i).toString()),c=a.length;for(o=0;o<n-r;++o)this[o+r]=a[o%c]}return this};Hh=/[^+\/0-9A-Za-z-_]/g});var Cn=Vt((Km,Li)=>{var Mr=(Yu(),El(ju));if(Mr&&Mr.default){Li.exports=Mr.default;for(let e in Mr)Li.exports[e]=Mr[e]}else Mr&&(Li.exports=Mr)});var qn=Vt((zu,Di)=>{(function(e){"use strict";var t,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,l=9007199254740991,d=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],h=1e7,N=1e9;function w(E){var q,W,K,G=F.prototype={constructor:F,toString:null,valueOf:null},tt=new F(1),rt=20,at=4,g=-7,T=21,B=-1e7,A=1e7,V=!1,Y=1,Q=0,ct={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},ft="0123456789abcdefghijklmnopqrstuvwxyz",z=!0;function F(f,p){var y,R,v,S,P,b,O,I,U=this;if(!(U instanceof F))return new F(f,p);if(p==null){if(f&&f._isBigNumber===!0){U.s=f.s,!f.c||f.e>A?U.c=U.e=null:f.e<B?U.c=[U.e=0]:(U.e=f.e,U.c=f.c.slice());return}if((b=typeof f=="number")&&f*0==0){if(U.s=1/f<0?(f=-f,-1):1,f===~~f){for(S=0,P=f;P>=10;P/=10,S++);S>A?U.c=U.e=null:(U.e=S,U.c=[f]);return}I=String(f)}else{if(!r.test(I=String(f)))return K(U,I,b);U.s=I.charCodeAt(0)==45?(I=I.slice(1),-1):1}(S=I.indexOf("."))>-1&&(I=I.replace(".","")),(P=I.search(/e/i))>0?(S<0&&(S=P),S+=+I.slice(P+1),I=I.substring(0,P)):S<0&&(S=I.length)}else{if(M(p,2,ft.length,"Base"),p==10&&z)return U=new F(f),lt(U,rt+U.e+1,at);if(I=String(f),b=typeof f=="number"){if(f*0!=0)return K(U,I,b,p);if(U.s=1/f<0?(I=I.slice(1),-1):1,F.DEBUG&&I.replace(/^0\.0*|\./,"").length>15)throw Error(o+f)}else U.s=I.charCodeAt(0)===45?(I=I.slice(1),-1):1;for(y=ft.slice(0,p),S=P=0,O=I.length;P<O;P++)if(y.indexOf(R=I.charAt(P))<0){if(R=="."){if(P>S){S=O;continue}}else if(!v&&(I==I.toUpperCase()&&(I=I.toLowerCase())||I==I.toLowerCase()&&(I=I.toUpperCase()))){v=!0,P=-1,S=0;continue}return K(U,String(f),b,p)}b=!1,I=W(I,p,10,U.s),(S=I.indexOf("."))>-1?I=I.replace(".",""):S=I.length}for(P=0;I.charCodeAt(P)===48;P++);for(O=I.length;I.charCodeAt(--O)===48;);if(I=I.slice(P,++O)){if(O-=P,b&&F.DEBUG&&O>15&&(f>l||f!==i(f)))throw Error(o+U.s*f);if((S=S-P-1)>A)U.c=U.e=null;else if(S<B)U.c=[U.e=0];else{if(U.e=S,U.c=[],P=(S+1)%c,S<0&&(P+=c),P<O){for(P&&U.c.push(+I.slice(0,P)),O-=c;P<O;)U.c.push(+I.slice(P,P+=c));P=c-(I=I.slice(P)).length}else P-=O;for(;P--;I+="0");U.c.push(+I)}}else U.c=[U.e=0]}F.clone=w,F.ROUND_UP=0,F.ROUND_DOWN=1,F.ROUND_CEIL=2,F.ROUND_FLOOR=3,F.ROUND_HALF_UP=4,F.ROUND_HALF_DOWN=5,F.ROUND_HALF_EVEN=6,F.ROUND_HALF_CEIL=7,F.ROUND_HALF_FLOOR=8,F.EUCLID=9,F.config=F.set=function(f){var p,y;if(f!=null)if(typeof f=="object"){if(f.hasOwnProperty(p="DECIMAL_PLACES")&&(y=f[p],M(y,0,N,p),rt=y),f.hasOwnProperty(p="ROUNDING_MODE")&&(y=f[p],M(y,0,8,p),at=y),f.hasOwnProperty(p="EXPONENTIAL_AT")&&(y=f[p],y&&y.pop?(M(y[0],-N,0,p),M(y[1],0,N,p),g=y[0],T=y[1]):(M(y,-N,N,p),g=-(T=y<0?-y:y))),f.hasOwnProperty(p="RANGE"))if(y=f[p],y&&y.pop)M(y[0],-N,-1,p),M(y[1],1,N,p),B=y[0],A=y[1];else if(M(y,-N,N,p),y)B=-(A=y<0?-y:y);else throw Error(s+p+" cannot be zero: "+y);if(f.hasOwnProperty(p="CRYPTO"))if(y=f[p],y===!!y)if(y)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))V=y;else throw V=!y,Error(s+"crypto unavailable");else V=y;else throw Error(s+p+" not true or false: "+y);if(f.hasOwnProperty(p="MODULO_MODE")&&(y=f[p],M(y,0,9,p),Y=y),f.hasOwnProperty(p="POW_PRECISION")&&(y=f[p],M(y,0,N,p),Q=y),f.hasOwnProperty(p="FORMAT"))if(y=f[p],typeof y=="object")ct=y;else throw Error(s+p+" not an object: "+y);if(f.hasOwnProperty(p="ALPHABET"))if(y=f[p],typeof y=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(y))z=y.slice(0,10)=="0123456789",ft=y;else throw Error(s+p+" invalid: "+y)}else throw Error(s+"Object expected: "+f);return{DECIMAL_PLACES:rt,ROUNDING_MODE:at,EXPONENTIAL_AT:[g,T],RANGE:[B,A],CRYPTO:V,MODULO_MODE:Y,POW_PRECISION:Q,FORMAT:ct,ALPHABET:ft}},F.isBigNumber=function(f){if(!f||f._isBigNumber!==!0)return!1;if(!F.DEBUG)return!0;var p,y,R=f.c,v=f.e,S=f.s;t:if({}.toString.call(R)=="[object Array]"){if((S===1||S===-1)&&v>=-N&&v<=N&&v===i(v)){if(R[0]===0){if(v===0&&R.length===1)return!0;break t}if(p=(v+1)%c,p<1&&(p+=c),String(R[0]).length==p){for(p=0;p<R.length;p++)if(y=R[p],y<0||y>=a||y!==i(y))break t;if(y!==0)return!0}}}else if(R===null&&v===null&&(S===null||S===1||S===-1))return!0;throw Error(s+"Invalid BigNumber: "+f)},F.maximum=F.max=function(){return D(arguments,-1)},F.minimum=F.min=function(){return D(arguments,1)},F.random=function(){var f=9007199254740992,p=Math.random()*f&2097151?function(){return i(Math.random()*f)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(y){var R,v,S,P,b,O=0,I=[],U=new F(tt);if(y==null?y=rt:M(y,0,N),P=n(y/c),V)if(crypto.getRandomValues){for(R=crypto.getRandomValues(new Uint32Array(P*=2));O<P;)b=R[O]*131072+(R[O+1]>>>11),b>=9e15?(v=crypto.getRandomValues(new Uint32Array(2)),R[O]=v[0],R[O+1]=v[1]):(I.push(b%1e14),O+=2);O=P/2}else if(crypto.randomBytes){for(R=crypto.randomBytes(P*=7);O<P;)b=(R[O]&31)*281474976710656+R[O+1]*1099511627776+R[O+2]*4294967296+R[O+3]*16777216+(R[O+4]<<16)+(R[O+5]<<8)+R[O+6],b>=9e15?crypto.randomBytes(7).copy(R,O):(I.push(b%1e14),O+=7);O=P/7}else throw V=!1,Error(s+"crypto unavailable");if(!V)for(;O<P;)b=p(),b<9e15&&(I[O++]=b%1e14);for(P=I[--O],y%=c,P&&y&&(b=d[c-y],I[O]=i(P/b)*b);I[O]===0;I.pop(),O--);if(O<0)I=[S=0];else{for(S=-1;I[0]===0;I.splice(0,1),S-=c);for(O=1,b=I[0];b>=10;b/=10,O++);O<c&&(S-=c-O)}return U.e=S,U.c=I,U}}(),F.sum=function(){for(var f=1,p=arguments,y=new F(p[0]);f<p.length;)y=y.plus(p[f++]);return y},W=function(){var f="0123456789";function p(y,R,v,S){for(var P,b=[0],O,I=0,U=y.length;I<U;){for(O=b.length;O--;b[O]*=R);for(b[0]+=S.indexOf(y.charAt(I++)),P=0;P<b.length;P++)b[P]>v-1&&(b[P+1]==null&&(b[P+1]=0),b[P+1]+=b[P]/v|0,b[P]%=v)}return b.reverse()}return function(y,R,v,S,P){var b,O,I,U,j,J,st,pt,vt=y.indexOf("."),St=rt,mt=at;for(vt>=0&&(U=Q,Q=0,y=y.replace(".",""),pt=new F(R),J=pt.pow(y.length-vt),Q=U,pt.c=p(X(x(J.c),J.e,"0"),10,v,f),pt.e=pt.c.length),st=p(y,R,v,P?(b=ft,f):(b=f,ft)),I=U=st.length;st[--U]==0;st.pop());if(!st[0])return b.charAt(0);if(vt<0?--I:(J.c=st,J.e=I,J.s=S,J=q(J,pt,St,mt,v),st=J.c,j=J.r,I=J.e),O=I+St+1,vt=st[O],U=v/2,j=j||O<0||st[O+1]!=null,j=mt<4?(vt!=null||j)&&(mt==0||mt==(J.s<0?3:2)):vt>U||vt==U&&(mt==4||j||mt==6&&st[O-1]&1||mt==(J.s<0?8:7)),O<1||!st[0])y=j?X(b.charAt(1),-St,b.charAt(0)):b.charAt(0);else{if(st.length=O,j)for(--v;++st[--O]>v;)st[O]=0,O||(++I,st=[1].concat(st));for(U=st.length;!st[--U];);for(vt=0,y="";vt<=U;y+=b.charAt(st[vt++]));y=X(y,I,b.charAt(0))}return y}}(),q=function(){function f(R,v,S){var P,b,O,I,U=0,j=R.length,J=v%h,st=v/h|0;for(R=R.slice();j--;)O=R[j]%h,I=R[j]/h|0,P=st*O+I*J,b=J*O+P%h*h+U,U=(b/S|0)+(P/h|0)+st*I,R[j]=b%S;return U&&(R=[U].concat(R)),R}function p(R,v,S,P){var b,O;if(S!=P)O=S>P?1:-1;else for(b=O=0;b<S;b++)if(R[b]!=v[b]){O=R[b]>v[b]?1:-1;break}return O}function y(R,v,S,P){for(var b=0;S--;)R[S]-=b,b=R[S]<v[S]?1:0,R[S]=b*P+R[S]-v[S];for(;!R[0]&&R.length>1;R.splice(0,1));}return function(R,v,S,P,b){var O,I,U,j,J,st,pt,vt,St,mt,ut,qt,lr,Fr,An,be,_t,ae=R.s==v.s?1:-1,Dt=R.c,Ut=v.c;if(!Dt||!Dt[0]||!Ut||!Ut[0])return new F(!R.s||!v.s||(Dt?Ut&&Dt[0]==Ut[0]:!Ut)?NaN:Dt&&Dt[0]==0||!Ut?ae*0:ae/0);for(vt=new F(ae),St=vt.c=[],I=R.e-v.e,ae=S+I+1,b||(b=a,I=u(R.e/c)-u(v.e/c),ae=ae/c|0),U=0;Ut[U]==(Dt[U]||0);U++);if(Ut[U]>(Dt[U]||0)&&I--,ae<0)St.push(1),j=!0;else{for(Fr=Dt.length,be=Ut.length,U=0,ae+=2,J=i(b/(Ut[0]+1)),J>1&&(Ut=f(Ut,J,b),Dt=f(Dt,J,b),be=Ut.length,Fr=Dt.length),lr=be,mt=Dt.slice(0,be),ut=mt.length;ut<be;mt[ut++]=0);_t=Ut.slice(),_t=[0].concat(_t),An=Ut[0],Ut[1]>=b/2&&An++;do{if(J=0,O=p(Ut,mt,be,ut),O<0){if(qt=mt[0],be!=ut&&(qt=qt*b+(mt[1]||0)),J=i(qt/An),J>1)for(J>=b&&(J=b-1),st=f(Ut,J,b),pt=st.length,ut=mt.length;p(st,mt,pt,ut)==1;)J--,y(st,be<pt?_t:Ut,pt,b),pt=st.length,O=1;else J==0&&(O=J=1),st=Ut.slice(),pt=st.length;if(pt<ut&&(st=[0].concat(st)),y(mt,st,ut,b),ut=mt.length,O==-1)for(;p(Ut,mt,be,ut)<1;)J++,y(mt,be<ut?_t:Ut,ut,b),ut=mt.length}else O===0&&(J++,mt=[0]);St[U++]=J,mt[0]?mt[ut++]=Dt[lr]||0:(mt=[Dt[lr]],ut=1)}while((lr++<Fr||mt[0]!=null)&&ae--);j=mt[0]!=null,St[0]||St.splice(0,1)}if(b==a){for(U=1,ae=St[0];ae>=10;ae/=10,U++);lt(vt,S+(vt.e=U+I*c-1)+1,P,j)}else vt.e=I,vt.r=+j;return vt}}();function m(f,p,y,R){var v,S,P,b,O;if(y==null?y=at:M(y,0,8),!f.c)return f.toString();if(v=f.c[0],P=f.e,p==null)O=x(f.c),O=R==1||R==2&&(P<=g||P>=T)?H(O,P):X(O,P,"0");else if(f=lt(new F(f),p,y),S=f.e,O=x(f.c),b=O.length,R==1||R==2&&(p<=S||S<=g)){for(;b<p;O+="0",b++);O=H(O,S)}else if(p-=P,O=X(O,S,"0"),S+1>b){if(--p>0)for(O+=".";p--;O+="0");}else if(p+=S-b,p>0)for(S+1==b&&(O+=".");p--;O+="0");return f.s<0&&v?"-"+O:O}function D(f,p){for(var y,R,v=1,S=new F(f[0]);v<f.length;v++)R=new F(f[v]),(!R.s||(y=C(S,R))===p||y===0&&S.s===p)&&(S=R);return S}function et(f,p,y){for(var R=1,v=p.length;!p[--v];p.pop());for(v=p[0];v>=10;v/=10,R++);return(y=R+y*c-1)>A?f.c=f.e=null:y<B?f.c=[f.e=0]:(f.e=y,f.c=p),f}K=function(){var f=/^(-?)0([xbo])(?=\w[\w.]*$)/i,p=/^([^.]+)\.$/,y=/^\.([^.]+)$/,R=/^-?(Infinity|NaN)$/,v=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(S,P,b,O){var I,U=b?P:P.replace(v,"");if(R.test(U))S.s=isNaN(U)?null:U<0?-1:1;else{if(!b&&(U=U.replace(f,function(j,J,st){return I=(st=st.toLowerCase())=="x"?16:st=="b"?2:8,!O||O==I?J:j}),O&&(I=O,U=U.replace(p,"$1").replace(y,"0.$1")),P!=U))return new F(U,I);if(F.DEBUG)throw Error(s+"Not a"+(O?" base "+O:"")+" number: "+P);S.s=null}S.c=S.e=null}}();function lt(f,p,y,R){var v,S,P,b,O,I,U,j=f.c,J=d;if(j){t:{for(v=1,b=j[0];b>=10;b/=10,v++);if(S=p-v,S<0)S+=c,P=p,O=j[I=0],U=i(O/J[v-P-1]%10);else if(I=n((S+1)/c),I>=j.length)if(R){for(;j.length<=I;j.push(0));O=U=0,v=1,S%=c,P=S-c+1}else break t;else{for(O=b=j[I],v=1;b>=10;b/=10,v++);S%=c,P=S-c+v,U=P<0?0:i(O/J[v-P-1]%10)}if(R=R||p<0||j[I+1]!=null||(P<0?O:O%J[v-P-1]),R=y<4?(U||R)&&(y==0||y==(f.s<0?3:2)):U>5||U==5&&(y==4||R||y==6&&(S>0?P>0?O/J[v-P]:0:j[I-1])%10&1||y==(f.s<0?8:7)),p<1||!j[0])return j.length=0,R?(p-=f.e+1,j[0]=J[(c-p%c)%c],f.e=-p||0):j[0]=f.e=0,f;if(S==0?(j.length=I,b=1,I--):(j.length=I+1,b=J[c-S],j[I]=P>0?i(O/J[v-P]%J[P])*b:0),R)for(;;)if(I==0){for(S=1,P=j[0];P>=10;P/=10,S++);for(P=j[0]+=b,b=1;P>=10;P/=10,b++);S!=b&&(f.e++,j[0]==a&&(j[0]=1));break}else{if(j[I]+=b,j[I]!=a)break;j[I--]=0,b=1}for(S=j.length;j[--S]===0;j.pop());}f.e>A?f.c=f.e=null:f.e<B&&(f.c=[f.e=0])}return f}function L(f){var p,y=f.e;return y===null?f.toString():(p=x(f.c),p=y<=g||y>=T?H(p,y):X(p,y,"0"),f.s<0?"-"+p:p)}return G.absoluteValue=G.abs=function(){var f=new F(this);return f.s<0&&(f.s=1),f},G.comparedTo=function(f,p){return C(this,new F(f,p))},G.decimalPlaces=G.dp=function(f,p){var y,R,v,S=this;if(f!=null)return M(f,0,N),p==null?p=at:M(p,0,8),lt(new F(S),f+S.e+1,p);if(!(y=S.c))return null;if(R=((v=y.length-1)-u(this.e/c))*c,v=y[v])for(;v%10==0;v/=10,R--);return R<0&&(R=0),R},G.dividedBy=G.div=function(f,p){return q(this,new F(f,p),rt,at)},G.dividedToIntegerBy=G.idiv=function(f,p){return q(this,new F(f,p),0,1)},G.exponentiatedBy=G.pow=function(f,p){var y,R,v,S,P,b,O,I,U,j=this;if(f=new F(f),f.c&&!f.isInteger())throw Error(s+"Exponent not an integer: "+L(f));if(p!=null&&(p=new F(p)),b=f.e>14,!j.c||!j.c[0]||j.c[0]==1&&!j.e&&j.c.length==1||!f.c||!f.c[0])return U=new F(Math.pow(+L(j),b?f.s*(2-k(f)):+L(f))),p?U.mod(p):U;if(O=f.s<0,p){if(p.c?!p.c[0]:!p.s)return new F(NaN);R=!O&&j.isInteger()&&p.isInteger(),R&&(j=j.mod(p))}else{if(f.e>9&&(j.e>0||j.e<-1||(j.e==0?j.c[0]>1||b&&j.c[1]>=24e7:j.c[0]<8e13||b&&j.c[0]<=9999975e7)))return S=j.s<0&&k(f)?-0:0,j.e>-1&&(S=1/S),new F(O?1/S:S);Q&&(S=n(Q/c+2))}for(b?(y=new F(.5),O&&(f.s=1),I=k(f)):(v=Math.abs(+L(f)),I=v%2),U=new F(tt);;){if(I){if(U=U.times(j),!U.c)break;S?U.c.length>S&&(U.c.length=S):R&&(U=U.mod(p))}if(v){if(v=i(v/2),v===0)break;I=v%2}else if(f=f.times(y),lt(f,f.e+1,1),f.e>14)I=k(f);else{if(v=+L(f),v===0)break;I=v%2}j=j.times(j),S?j.c&&j.c.length>S&&(j.c.length=S):R&&(j=j.mod(p))}return R?U:(O&&(U=tt.div(U)),p?U.mod(p):S?lt(U,Q,at,P):U)},G.integerValue=function(f){var p=new F(this);return f==null?f=at:M(f,0,8),lt(p,p.e+1,f)},G.isEqualTo=G.eq=function(f,p){return C(this,new F(f,p))===0},G.isFinite=function(){return!!this.c},G.isGreaterThan=G.gt=function(f,p){return C(this,new F(f,p))>0},G.isGreaterThanOrEqualTo=G.gte=function(f,p){return(p=C(this,new F(f,p)))===1||p===0},G.isInteger=function(){return!!this.c&&u(this.e/c)>this.c.length-2},G.isLessThan=G.lt=function(f,p){return C(this,new F(f,p))<0},G.isLessThanOrEqualTo=G.lte=function(f,p){return(p=C(this,new F(f,p)))===-1||p===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(f,p){var y,R,v,S,P=this,b=P.s;if(f=new F(f,p),p=f.s,!b||!p)return new F(NaN);if(b!=p)return f.s=-p,P.plus(f);var O=P.e/c,I=f.e/c,U=P.c,j=f.c;if(!O||!I){if(!U||!j)return U?(f.s=-p,f):new F(j?P:NaN);if(!U[0]||!j[0])return j[0]?(f.s=-p,f):new F(U[0]?P:at==3?-0:0)}if(O=u(O),I=u(I),U=U.slice(),b=O-I){for((S=b<0)?(b=-b,v=U):(I=O,v=j),v.reverse(),p=b;p--;v.push(0));v.reverse()}else for(R=(S=(b=U.length)<(p=j.length))?b:p,b=p=0;p<R;p++)if(U[p]!=j[p]){S=U[p]<j[p];break}if(S&&(v=U,U=j,j=v,f.s=-f.s),p=(R=j.length)-(y=U.length),p>0)for(;p--;U[y++]=0);for(p=a-1;R>b;){if(U[--R]<j[R]){for(y=R;y&&!U[--y];U[y]=p);--U[y],U[R]+=a}U[R]-=j[R]}for(;U[0]==0;U.splice(0,1),--I);return U[0]?et(f,U,I):(f.s=at==3?-1:1,f.c=[f.e=0],f)},G.modulo=G.mod=function(f,p){var y,R,v=this;return f=new F(f,p),!v.c||!f.s||f.c&&!f.c[0]?new F(NaN):!f.c||v.c&&!v.c[0]?new F(v):(Y==9?(R=f.s,f.s=1,y=q(v,f,0,3),f.s=R,y.s*=R):y=q(v,f,0,Y),f=v.minus(y.times(f)),!f.c[0]&&Y==1&&(f.s=v.s),f)},G.multipliedBy=G.times=function(f,p){var y,R,v,S,P,b,O,I,U,j,J,st,pt,vt,St,mt=this,ut=mt.c,qt=(f=new F(f,p)).c;if(!ut||!qt||!ut[0]||!qt[0])return!mt.s||!f.s||ut&&!ut[0]&&!qt||qt&&!qt[0]&&!ut?f.c=f.e=f.s=null:(f.s*=mt.s,!ut||!qt?f.c=f.e=null:(f.c=[0],f.e=0)),f;for(R=u(mt.e/c)+u(f.e/c),f.s*=mt.s,O=ut.length,j=qt.length,O<j&&(pt=ut,ut=qt,qt=pt,v=O,O=j,j=v),v=O+j,pt=[];v--;pt.push(0));for(vt=a,St=h,v=j;--v>=0;){for(y=0,J=qt[v]%St,st=qt[v]/St|0,P=O,S=v+P;S>v;)I=ut[--P]%St,U=ut[P]/St|0,b=st*I+U*J,I=J*I+b%St*St+pt[S]+y,y=(I/vt|0)+(b/St|0)+st*U,pt[S--]=I%vt;pt[S]=y}return y?++R:pt.splice(0,1),et(f,pt,R)},G.negated=function(){var f=new F(this);return f.s=-f.s||null,f},G.plus=function(f,p){var y,R=this,v=R.s;if(f=new F(f,p),p=f.s,!v||!p)return new F(NaN);if(v!=p)return f.s=-p,R.minus(f);var S=R.e/c,P=f.e/c,b=R.c,O=f.c;if(!S||!P){if(!b||!O)return new F(v/0);if(!b[0]||!O[0])return O[0]?f:new F(b[0]?R:v*0)}if(S=u(S),P=u(P),b=b.slice(),v=S-P){for(v>0?(P=S,y=O):(v=-v,y=b),y.reverse();v--;y.push(0));y.reverse()}for(v=b.length,p=O.length,v-p<0&&(y=O,O=b,b=y,p=v),v=0;p;)v=(b[--p]=b[p]+O[p]+v)/a|0,b[p]=a===b[p]?0:b[p]%a;return v&&(b=[v].concat(b),++P),et(f,b,P)},G.precision=G.sd=function(f,p){var y,R,v,S=this;if(f!=null&&f!==!!f)return M(f,1,N),p==null?p=at:M(p,0,8),lt(new F(S),f,p);if(!(y=S.c))return null;if(v=y.length-1,R=v*c+1,v=y[v]){for(;v%10==0;v/=10,R--);for(v=y[0];v>=10;v/=10,R++);}return f&&S.e+1>R&&(R=S.e+1),R},G.shiftedBy=function(f){return M(f,-l,l),this.times("1e"+f)},G.squareRoot=G.sqrt=function(){var f,p,y,R,v,S=this,P=S.c,b=S.s,O=S.e,I=rt+4,U=new F("0.5");if(b!==1||!P||!P[0])return new F(!b||b<0&&(!P||P[0])?NaN:P?S:1/0);if(b=Math.sqrt(+L(S)),b==0||b==1/0?(p=x(P),(p.length+O)%2==0&&(p+="0"),b=Math.sqrt(+p),O=u((O+1)/2)-(O<0||O%2),b==1/0?p="5e"+O:(p=b.toExponential(),p=p.slice(0,p.indexOf("e")+1)+O),y=new F(p)):y=new F(b+""),y.c[0]){for(O=y.e,b=O+I,b<3&&(b=0);;)if(v=y,y=U.times(v.plus(q(S,v,I,1))),x(v.c).slice(0,b)===(p=x(y.c)).slice(0,b))if(y.e<O&&--b,p=p.slice(b-3,b+1),p=="9999"||!R&&p=="4999"){if(!R&&(lt(v,v.e+rt+2,0),v.times(v).eq(S))){y=v;break}I+=4,b+=4,R=1}else{(!+p||!+p.slice(1)&&p.charAt(0)=="5")&&(lt(y,y.e+rt+2,1),f=!y.times(y).eq(S));break}}return lt(y,y.e+rt+1,at,f)},G.toExponential=function(f,p){return f!=null&&(M(f,0,N),f++),m(this,f,p,1)},G.toFixed=function(f,p){return f!=null&&(M(f,0,N),f=f+this.e+1),m(this,f,p)},G.toFormat=function(f,p,y){var R,v=this;if(y==null)f!=null&&p&&typeof p=="object"?(y=p,p=null):f&&typeof f=="object"?(y=f,f=p=null):y=ct;else if(typeof y!="object")throw Error(s+"Argument not an object: "+y);if(R=v.toFixed(f,p),v.c){var S,P=R.split("."),b=+y.groupSize,O=+y.secondaryGroupSize,I=y.groupSeparator||"",U=P[0],j=P[1],J=v.s<0,st=J?U.slice(1):U,pt=st.length;if(O&&(S=b,b=O,O=S,pt-=S),b>0&&pt>0){for(S=pt%b||b,U=st.substr(0,S);S<pt;S+=b)U+=I+st.substr(S,b);O>0&&(U+=I+st.slice(S)),J&&(U="-"+U)}R=j?U+(y.decimalSeparator||"")+((O=+y.fractionGroupSize)?j.replace(new RegExp("\\d{"+O+"}\\B","g"),"$&"+(y.fractionGroupSeparator||"")):j):U}return(y.prefix||"")+R+(y.suffix||"")},G.toFraction=function(f){var p,y,R,v,S,P,b,O,I,U,j,J,st=this,pt=st.c;if(f!=null&&(b=new F(f),!b.isInteger()&&(b.c||b.s!==1)||b.lt(tt)))throw Error(s+"Argument "+(b.isInteger()?"out of range: ":"not an integer: ")+L(b));if(!pt)return new F(st);for(p=new F(tt),I=y=new F(tt),R=O=new F(tt),J=x(pt),S=p.e=J.length-st.e-1,p.c[0]=d[(P=S%c)<0?c+P:P],f=!f||b.comparedTo(p)>0?S>0?p:I:b,P=A,A=1/0,b=new F(J),O.c[0]=0;U=q(b,p,0,1),v=y.plus(U.times(R)),v.comparedTo(f)!=1;)y=R,R=v,I=O.plus(U.times(v=I)),O=v,p=b.minus(U.times(v=p)),b=v;return v=q(f.minus(y),R,0,1),O=O.plus(v.times(I)),y=y.plus(v.times(R)),O.s=I.s=st.s,S=S*2,j=q(I,R,S,at).minus(st).abs().comparedTo(q(O,y,S,at).minus(st).abs())<1?[I,R]:[O,y],A=P,j},G.toNumber=function(){return+L(this)},G.toPrecision=function(f,p){return f!=null&&M(f,1,N),m(this,f,p,2)},G.toString=function(f){var p,y=this,R=y.s,v=y.e;return v===null?R?(p="Infinity",R<0&&(p="-"+p)):p="NaN":(f==null?p=v<=g||v>=T?H(x(y.c),v):X(x(y.c),v,"0"):f===10&&z?(y=lt(new F(y),rt+v+1,at),p=X(x(y.c),y.e,"0")):(M(f,2,ft.length,"Base"),p=W(X(x(y.c),v,"0"),10,f,R,!0)),R<0&&y.c[0]&&(p="-"+p)),p},G.valueOf=G.toJSON=function(){return L(this)},G._isBigNumber=!0,E!=null&&F.set(E),F}function u(E){var q=E|0;return E>0||E===q?q:q-1}function x(E){for(var q,W,K=1,G=E.length,tt=E[0]+"";K<G;){for(q=E[K++]+"",W=c-q.length;W--;q="0"+q);tt+=q}for(G=tt.length;tt.charCodeAt(--G)===48;);return tt.slice(0,G+1||1)}function C(E,q){var W,K,G=E.c,tt=q.c,rt=E.s,at=q.s,g=E.e,T=q.e;if(!rt||!at)return null;if(W=G&&!G[0],K=tt&&!tt[0],W||K)return W?K?0:-at:rt;if(rt!=at)return rt;if(W=rt<0,K=g==T,!G||!tt)return K?0:!G^W?1:-1;if(!K)return g>T^W?1:-1;for(at=(g=G.length)<(T=tt.length)?g:T,rt=0;rt<at;rt++)if(G[rt]!=tt[rt])return G[rt]>tt[rt]^W?1:-1;return g==T?0:g>T^W?1:-1}function M(E,q,W,K){if(E<q||E>W||E!==i(E))throw Error(s+(K||"Argument")+(typeof E=="number"?E<q||E>W?" out of range: ":" not an integer: ":" not a primitive number: ")+String(E))}function k(E){var q=E.c.length-1;return u(E.e/c)==q&&E.c[q]%2!=0}function H(E,q){return(E.length>1?E.charAt(0)+"."+E.slice(1):E)+(q<0?"e":"e+")+q}function X(E,q,W){var K,G;if(q<0){for(G=W+".";++q;G+=W);E=G+E}else if(K=E.length,++q>K){for(G=W,q-=K;--q;G+=W);E+=G}else q<K&&(E=E.slice(0,q)+"."+E.slice(q));return E}t=w(),t.default=t.BigNumber=t,typeof define=="function"&&define.amd?define(function(){return t}):typeof Di<"u"&&Di.exports?Di.exports=t:(e||(e=typeof self<"u"&&self?self:window),e.BigNumber=t)})(zu)});var Wu=Vt((Wm,Ku)=>{Ku.exports=function(t,r,n){var i=new t.Uint8Array(n),s=r.pushInt,o=r.pushInt32,a=r.pushInt32Neg,c=r.pushInt64,l=r.pushInt64Neg,d=r.pushFloat,h=r.pushFloatSingle,N=r.pushFloatDouble,w=r.pushTrue,u=r.pushFalse,x=r.pushUndefined,C=r.pushNull,M=r.pushInfinity,k=r.pushInfinityNeg,H=r.pushNaN,X=r.pushNaNNeg,E=r.pushArrayStart,q=r.pushArrayStartFixed,W=r.pushArrayStartFixed32,K=r.pushArrayStartFixed64,G=r.pushObjectStart,tt=r.pushObjectStartFixed,rt=r.pushObjectStartFixed32,at=r.pushObjectStartFixed64,g=r.pushByteString,T=r.pushByteStringStart,B=r.pushUtf8String,A=r.pushUtf8StringStart,V=r.pushSimpleUnassigned,Y=r.pushTagStart,Q=r.pushTagStart4,ct=r.pushTagStart8,ft=r.pushTagUnassigned,z=r.pushBreak,F=t.Math.pow,m=0,D=0,et=0;function lt(_){for(_=_|0,m=0,D=_;(m|0)<(D|0)&&(et=yl[i[m]&255](i[m]|0)|0,!((et|0)>0)););return et|0}function L(_){return _=_|0,((m|0)+(_|0)|0)<(D|0)?0:1}function f(_){return _=_|0,i[_|0]<<8|i[_+1|0]|0}function p(_){return _=_|0,i[_|0]<<24|i[_+1|0]<<16|i[_+2|0]<<8|i[_+3|0]|0}function y(_){return _=_|0,s(_|0),m=m+1|0,0}function R(_){return _=_|0,L(1)|0?1:(s(i[m+1|0]|0),m=m+2|0,0)}function v(_){return _=_|0,L(2)|0?1:(s(f(m+1|0)|0),m=m+3|0,0)}function S(_){return _=_|0,L(4)|0?1:(o(f(m+1|0)|0,f(m+3|0)|0),m=m+5|0,0)}function P(_){return _=_|0,L(8)|0?1:(c(f(m+1|0)|0,f(m+3|0)|0,f(m+5|0)|0,f(m+7|0)|0),m=m+9|0,0)}function b(_){return _=_|0,s(-1-(_-32|0)|0),m=m+1|0,0}function O(_){return _=_|0,L(1)|0?1:(s(-1-(i[m+1|0]|0)|0),m=m+2|0,0)}function I(_){_=_|0;var wt=0;return L(2)|0?1:(wt=f(m+1|0)|0,s(-1-(wt|0)|0),m=m+3|0,0)}function U(_){return _=_|0,L(4)|0?1:(a(f(m+1|0)|0,f(m+3|0)|0),m=m+5|0,0)}function j(_){return _=_|0,L(8)|0?1:(l(f(m+1|0)|0,f(m+3|0)|0,f(m+5|0)|0,f(m+7|0)|0),m=m+9|0,0)}function J(_){_=_|0;var wt=0,xt=0,yt=0;return yt=_-64|0,L(yt|0)|0?1:(wt=m+1|0,xt=(m+1|0)+(yt|0)|0,g(wt|0,xt|0),m=xt|0,0)}function st(_){_=_|0;var wt=0,xt=0,yt=0;return L(1)|0||(yt=i[m+1|0]|0,wt=m+2|0,xt=(m+2|0)+(yt|0)|0,L(yt+1|0)|0)?1:(g(wt|0,xt|0),m=xt|0,0)}function pt(_){_=_|0;var wt=0,xt=0,yt=0;return L(2)|0||(yt=f(m+1|0)|0,wt=m+3|0,xt=(m+3|0)+(yt|0)|0,L(yt+2|0)|0)?1:(g(wt|0,xt|0),m=xt|0,0)}function vt(_){_=_|0;var wt=0,xt=0,yt=0;return L(4)|0||(yt=p(m+1|0)|0,wt=m+5|0,xt=(m+5|0)+(yt|0)|0,L(yt+4|0)|0)?1:(g(wt|0,xt|0),m=xt|0,0)}function St(_){return _=_|0,1}function mt(_){return _=_|0,T(),m=m+1|0,0}function ut(_){_=_|0;var wt=0,xt=0,yt=0;return yt=_-96|0,L(yt|0)|0?1:(wt=m+1|0,xt=(m+1|0)+(yt|0)|0,B(wt|0,xt|0),m=xt|0,0)}function qt(_){_=_|0;var wt=0,xt=0,yt=0;return L(1)|0||(yt=i[m+1|0]|0,wt=m+2|0,xt=(m+2|0)+(yt|0)|0,L(yt+1|0)|0)?1:(B(wt|0,xt|0),m=xt|0,0)}function lr(_){_=_|0;var wt=0,xt=0,yt=0;return L(2)|0||(yt=f(m+1|0)|0,wt=m+3|0,xt=(m+3|0)+(yt|0)|0,L(yt+2|0)|0)?1:(B(wt|0,xt|0),m=xt|0,0)}function Fr(_){_=_|0;var wt=0,xt=0,yt=0;return L(4)|0||(yt=p(m+1|0)|0,wt=m+5|0,xt=(m+5|0)+(yt|0)|0,L(yt+4|0)|0)?1:(B(wt|0,xt|0),m=xt|0,0)}function An(_){return _=_|0,1}function be(_){return _=_|0,A(),m=m+1|0,0}function _t(_){return _=_|0,q(_-128|0),m=m+1|0,0}function ae(_){return _=_|0,L(1)|0?1:(q(i[m+1|0]|0),m=m+2|0,0)}function Dt(_){return _=_|0,L(2)|0?1:(q(f(m+1|0)|0),m=m+3|0,0)}function Ut(_){return _=_|0,L(4)|0?1:(W(f(m+1|0)|0,f(m+3|0)|0),m=m+5|0,0)}function J0(_){return _=_|0,L(8)|0?1:(K(f(m+1|0)|0,f(m+3|0)|0,f(m+5|0)|0,f(m+7|0)|0),m=m+9|0,0)}function Q0(_){return _=_|0,E(),m=m+1|0,0}function It(_){_=_|0;var wt=0;return wt=_-160|0,L(wt|0)|0?1:(tt(wt|0),m=m+1|0,0)}function L0(_){return _=_|0,L(1)|0?1:(tt(i[m+1|0]|0),m=m+2|0,0)}function D0(_){return _=_|0,L(2)|0?1:(tt(f(m+1|0)|0),m=m+3|0,0)}function tl(_){return _=_|0,L(4)|0?1:(rt(f(m+1|0)|0,f(m+3|0)|0),m=m+5|0,0)}function el(_){return _=_|0,L(8)|0?1:(at(f(m+1|0)|0,f(m+3|0)|0,f(m+5|0)|0,f(m+7|0)|0),m=m+9|0,0)}function rl(_){return _=_|0,G(),m=m+1|0,0}function Xr(_){return _=_|0,Y(_-192|0|0),m=m+1|0,0}function P1(_){return _=_|0,Y(_|0),m=m+1|0,0}function k1(_){return _=_|0,Y(_|0),m=m+1|0,0}function M1(_){return _=_|0,Y(_|0),m=m+1|0,0}function C1(_){return _=_|0,Y(_|0),m=m+1|0,0}function Xt(_){return _=_|0,Y(_-192|0|0),m=m+1|0,0}function q1(_){return _=_|0,Y(_|0),m=m+1|0,0}function $1(_){return _=_|0,Y(_|0),m=m+1|0,0}function V1(_){return _=_|0,Y(_|0),m=m+1|0,0}function nl(_){return _=_|0,L(1)|0?1:(Y(i[m+1|0]|0),m=m+2|0,0)}function il(_){return _=_|0,L(2)|0?1:(Y(f(m+1|0)|0),m=m+3|0,0)}function sl(_){return _=_|0,L(4)|0?1:(Q(f(m+1|0)|0,f(m+3|0)|0),m=m+5|0,0)}function ol(_){return _=_|0,L(8)|0?1:(ct(f(m+1|0)|0,f(m+3|0)|0,f(m+5|0)|0,f(m+7|0)|0),m=m+9|0,0)}function $t(_){return _=_|0,V((_|0)-224|0),m=m+1|0,0}function al(_){return _=_|0,u(),m=m+1|0,0}function cl(_){return _=_|0,w(),m=m+1|0,0}function ul(_){return _=_|0,C(),m=m+1|0,0}function fl(_){return _=_|0,x(),m=m+1|0,0}function ll(_){return _=_|0,L(1)|0?1:(V(i[m+1|0]|0),m=m+2|0,0)}function hl(_){_=_|0;var wt=0,xt=0,yt=1,yi=0,Tn=0,H1=0;return L(2)|0?1:(wt=i[m+1|0]|0,xt=i[m+2|0]|0,(wt|0)&128&&(yt=-1),yi=+(((wt|0)&124)>>2),Tn=+(((wt|0)&3)<<8|xt),+yi==0?d(+(+yt*5960464477539063e-23*+Tn)):+yi==31?+yt==1?+Tn>0?H():M():+Tn>0?X():k():d(+(+yt*F(2,+(+yi-25))*+(1024+Tn))),m=m+3|0,0)}function dl(_){return _=_|0,L(4)|0?1:(h(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 pl(_){return _=_|0,L(8)|0?1:(N(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 At(_){return _=_|0,1}function ml(_){return _=_|0,z(),m=m+1|0,0}var yl=[y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,y,R,v,S,P,At,At,At,At,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,O,I,U,j,At,At,At,At,J,J,J,J,J,J,J,J,J,J,J,J,J,J,J,J,J,J,J,J,J,J,J,J,st,pt,vt,St,At,At,At,mt,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,qt,lr,Fr,An,At,At,At,be,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,_t,ae,Dt,Ut,J0,At,At,At,Q0,It,It,It,It,It,It,It,It,It,It,It,It,It,It,It,It,It,It,It,It,It,It,It,It,L0,D0,tl,el,At,At,At,rl,Xr,Xr,Xr,Xr,Xr,Xr,Xt,Xt,Xt,Xt,Xt,Xt,Xt,Xt,Xt,Xt,Xt,Xt,Xt,Xt,Xt,Xt,Xt,Xt,nl,il,sl,ol,At,At,At,At,$t,$t,$t,$t,$t,$t,$t,$t,$t,$t,$t,$t,$t,$t,$t,$t,$t,$t,$t,$t,al,cl,ul,fl,ll,hl,dl,pl,At,At,At,ml];return{parse:lt}}});var $n=Vt(de=>{"use strict";var qo=qn().BigNumber;de.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};de.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};de.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};de.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};de.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};de.SHIFT32=Math.pow(2,32);de.SHIFT16=Math.pow(2,16);de.MAX_SAFE_HIGH=2097151;de.NEG_ONE=new qo(-1);de.TEN=new qo(10);de.TWO=new qo(2);de.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var ts=Vt(ve=>{"use strict";var{Buffer:Xh}=Cn(),Xu=qn().BigNumber,Ju=$n(),Zu=Ju.SHIFT32,Jh=Ju.SHIFT16,Qh=2097151;ve.parseHalf=function(t){var r,n,i;return i=t[0]&128?-1:1,r=(t[0]&124)>>2,n=(t[0]&3)<<8|t[1],r?r===31?i*(n?NaN:1/0):i*Math.pow(2,r-25)*(1024+n):i*5960464477539063e-23*n};function Lh(e){return e<16?"0"+e.toString(16):e.toString(16)}ve.arrayBufferToBignumber=function(e){let t=e.byteLength,r="";for(let n=0;n<t;n++)r+=Lh(e[n]);return new Xu(r,16)};ve.buildMap=e=>{let t=new Map,r=Object.keys(e),n=r.length;for(let i=0;i<n;i++)t.set(r[i],e[r[i]]);return t};ve.buildInt32=(e,t)=>e*Jh+t;ve.buildInt64=(e,t,r,n)=>{let i=ve.buildInt32(e,t),s=ve.buildInt32(r,n);return i>Qh?new Xu(i).times(Zu).plus(s):i*Zu+s};ve.writeHalf=function(t,r){let n=Xh.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 t.writeUInt16BE(s,0),!0};ve.keySorter=function(e,t){var r=e[0].byteLength,n=t[0].byteLength;return r>n?1:n>r?-1:e[0].compare(t[0])};ve.isNegativeZero=e=>e===0&&1/e<0;ve.nextPowerOf2=e=>{let t=0;if(e&&!(e&e-1))return e;for(;e!==0;)e>>=1,t+=1;return 1<<t}});var Go=Vt((Jm,Qu)=>{"use strict";var Ho=$n(),Dh=Ho.MT,es=Ho.SIMPLE,$o=Ho.SYMS,Vo=class e{constructor(t){if(typeof t!="number")throw new Error("Invalid Simple type: "+typeof t);if(t<0||t>255||(t|0)!==t)throw new Error("value must be a small positive integer: "+t);this.value=t}toString(){return"simple("+this.value+")"}inspect(){return"simple("+this.value+")"}encodeCBOR(t){return t._pushInt(this.value,Dh.SIMPLE_FLOAT)}static isSimple(t){return t instanceof e}static decode(t,r){switch(r==null&&(r=!0),t){case es.FALSE:return!1;case es.TRUE:return!0;case es.NULL:return r?null:$o.NULL;case es.UNDEFINED:return r?void 0:$o.UNDEFINED;case-1:if(!r)throw new Error("Invalid BREAK");return $o.BREAK;default:return new e(t)}}};Qu.exports=Vo});var Yo=Vt((Qm,Lu)=>{"use strict";var jo=class e{constructor(t,r,n){if(this.tag=t,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(t){return t._pushTag(this.tag),t.pushAny(this.value)}convert(t){var r,n;if(n=t?.[this.tag],typeof n!="function"&&(n=e["_tag"+this.tag],typeof n!="function"))return this;try{return n.call(e,this.value)}catch(i){return r=i,this.err=r,this}}};Lu.exports=jo});var Wo=Vt((Lm,tf)=>{"use strict";var Du=self.location?self.location.protocol+"//"+self.location.host:"",zo=self.URL,Ko=class{constructor(t="",r=Du){this.super=new zo(t,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(t){this.super.hash=t}set host(t){this.super.host=t}set hostname(t){this.super.hostname=t}set href(t){this.super.href=t}set origin(t){this.super.origin=t}set password(t){this.super.password=t}set pathname(t){this.super.pathname=t}set port(t){this.super.port=t}set protocol(t){this.super.protocol=t}set search(t){this.super.search=t}set searchParams(t){this.super.searchParams=t}set username(t){this.super.username=t}createObjectURL(t){return this.super.createObjectURL(t)}revokeObjectURL(t){this.super.revokeObjectURL(t)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}};function td(e){if(typeof e=="string")return new zo(e).toString();if(!(e instanceof zo)){let t=e.username&&e.password?`${e.username}:${e.password}@`:"",r=e.auth?e.auth+"@":"",n=e.port?":"+e.port:"",i=e.protocol?e.protocol+"//":"",s=e.host||"",o=e.hostname||"",a=e.search||(e.query?"?"+e.query:""),c=e.hash||"",l=e.pathname||"",d=e.path||l+a;return`${i}${t||r}${s||o+n}${d}${c}`}}tf.exports={URLWithLegacySupport:Ko,URLSearchParams:self.URLSearchParams,defaultBase:Du,format:td}});var nf=Vt((Dm,rf)=>{"use strict";var{URLWithLegacySupport:ef,format:ed}=Wo();rf.exports=(e,t={},r={},n)=>{let i=t.protocol?t.protocol.replace(":",""):"http";i=(r[i]||n||i)+":";let s;try{s=new ef(e)}catch{s={}}let o=Object.assign({},t,{protocol:i||s.protocol,host:t.host||s.host});return new ef(e,ed(o)).toString()}});var Zo=Vt((ty,sf)=>{"use strict";var{URLWithLegacySupport:rd,format:nd,URLSearchParams:id,defaultBase:sd}=Wo(),od=nf();sf.exports={URL:rd,URLSearchParams:id,format:nd,relative:od,defaultBase:sd}});var Xo=Vt((ey,af)=>{"use strict";var{Buffer:un}=Cn(),of=mo(),ad=qn().BigNumber,cd=Wu(),ne=ts(),Bt=$n(),ud=Go(),fd=Yo(),{URL:ld}=Zo(),Vn=class e{constructor(t){t=t||{},!t.size||t.size<65536?t.size=65536:t.size=ne.nextPowerOf2(t.size),this._heap=new ArrayBuffer(t.size),this._heap8=new Uint8Array(this._heap),this._buffer=un.from(this._heap),this._reset(),this._knownTags=Object.assign({0:r=>new Date(r),1:r=>new Date(r*1e3),2:r=>ne.arrayBufferToBignumber(r),3:r=>Bt.NEG_ONE.minus(ne.arrayBufferToBignumber(r)),4:r=>Bt.TEN.pow(r[0]).times(r[1]),5:r=>Bt.TWO.pow(r[0]).times(r[1]),32:r=>new ld(r),35:r=>new RegExp(r)},t.tags),this.parser=cd(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 t=this._parents.pop();if(t.length>0)throw new Error(`Missing ${t.length} elements`);switch(t.type){case Bt.PARENT.TAG:this._push(this.createTag(t.ref[0],t.ref[1]));break;case Bt.PARENT.BYTE_STRING:this._push(this.createByteString(t.ref,t.length));break;case Bt.PARENT.UTF8_STRING:this._push(this.createUtf8String(t.ref,t.length));break;case Bt.PARENT.MAP:if(t.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createMap(t.ref,t.length));break;case Bt.PARENT.OBJECT:if(t.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createObject(t.ref,t.length));break;case Bt.PARENT.ARRAY:this._push(this.createArray(t.ref,t.length));break;default:break}this._currentParent&&this._currentParent.type===Bt.PARENT.TAG&&this._dec()}_dec(){let t=this._currentParent;t.length<0||(t.length--,t.length===0&&this._closeParent())}_push(t,r){let n=this._currentParent;switch(n.values++,n.type){case Bt.PARENT.ARRAY:case Bt.PARENT.BYTE_STRING:case Bt.PARENT.UTF8_STRING:n.length>-1?this._ref[this._ref.length-n.length]=t:this._ref.push(t),this._dec();break;case Bt.PARENT.OBJECT:n.tmpKey!=null?(this._ref[n.tmpKey]=t,n.tmpKey=null,this._dec()):(n.tmpKey=t,typeof n.tmpKey!="string"&&(n.type=Bt.PARENT.MAP,n.ref=ne.buildMap(n.ref)));break;case Bt.PARENT.MAP:n.tmpKey!=null?(this._ref.set(n.tmpKey,t),n.tmpKey=null,this._dec()):n.tmpKey=t;break;case Bt.PARENT.TAG:this._ref.push(t),r||this._dec();break;default:throw new Error("Unknown parent type")}}_createParent(t,r,n){this._parents[this._depth]={type:r,length:n,ref:t,values:0,tmpKey:null}}_reset(){this._res=[],this._parents=[{type:Bt.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(t,r){let n=this._knownTags[t];return n?n(r):new fd(t,r)}createMap(t,r){return t}createObject(t,r){return t}createArray(t,r){return t}createByteString(t,r){return un.concat(t)}createByteStringFromHeap(t,r){return t===r?un.alloc(0):un.from(this._heap.slice(t,r))}createInt(t){return t}createInt32(t,r){return ne.buildInt32(t,r)}createInt64(t,r,n,i){return ne.buildInt64(t,r,n,i)}createFloat(t){return t}createFloatSingle(t,r,n,i){return of.read([t,r,n,i],0,!1,23,4)}createFloatDouble(t,r,n,i,s,o,a,c){return of.read([t,r,n,i,s,o,a,c],0,!1,52,8)}createInt32Neg(t,r){return-1-ne.buildInt32(t,r)}createInt64Neg(t,r,n,i){let s=ne.buildInt32(t,r),o=ne.buildInt32(n,i);return s>Bt.MAX_SAFE_HIGH?Bt.NEG_ONE.minus(new ad(s).times(Bt.SHIFT32).plus(o)):-1-(s*Bt.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(t,r){return t.join("")}createUtf8StringFromHeap(t,r){return t===r?"":this._buffer.toString("utf8",t,r)}createSimpleUnassigned(t){return new ud(t)}pushInt(t){this._push(this.createInt(t))}pushInt32(t,r){this._push(this.createInt32(t,r))}pushInt64(t,r,n,i){this._push(this.createInt64(t,r,n,i))}pushFloat(t){this._push(this.createFloat(t))}pushFloatSingle(t,r,n,i){this._push(this.createFloatSingle(t,r,n,i))}pushFloatDouble(t,r,n,i,s,o,a,c){this._push(this.createFloatDouble(t,r,n,i,s,o,a,c))}pushInt32Neg(t,r){this._push(this.createInt32Neg(t,r))}pushInt64Neg(t,r,n,i){this._push(this.createInt64Neg(t,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([],Bt.PARENT.ARRAY,-1)}pushArrayStartFixed(t){this._createArrayStartFixed(t)}pushArrayStartFixed32(t,r){let n=ne.buildInt32(t,r);this._createArrayStartFixed(n)}pushArrayStartFixed64(t,r,n,i){let s=ne.buildInt64(t,r,n,i);this._createArrayStartFixed(s)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(t){this._createObjectStartFixed(t)}pushObjectStartFixed32(t,r){let n=ne.buildInt32(t,r);this._createObjectStartFixed(n)}pushObjectStartFixed64(t,r,n,i){let s=ne.buildInt64(t,r,n,i);this._createObjectStartFixed(s)}pushByteStringStart(){this._parents[this._depth]={type:Bt.PARENT.BYTE_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushByteString(t,r){this._push(this.createByteStringFromHeap(t,r))}pushUtf8StringStart(){this._parents[this._depth]={type:Bt.PARENT.UTF8_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushUtf8String(t,r){this._push(this.createUtf8StringFromHeap(t,r))}pushSimpleUnassigned(t){this._push(this.createSimpleUnassigned(t))}pushTagStart(t){this._parents[this._depth]={type:Bt.PARENT.TAG,length:1,ref:[t]}}pushTagStart4(t,r){this.pushTagStart(ne.buildInt32(t,r))}pushTagStart8(t,r,n,i){this.pushTagStart(ne.buildInt64(t,r,n,i))}pushTagUnassigned(t){this._push(this.createTag(t))}pushBreak(){if(this._currentParent.length>-1)throw new Error("Unexpected break");this._closeParent()}_createObjectStartFixed(t){if(t===0){this._push(this.createObject({}));return}this._createParent({},Bt.PARENT.OBJECT,t)}_createArrayStartFixed(t){if(t===0){this._push(this.createArray([]));return}this._createParent(new Array(t),Bt.PARENT.ARRAY,t)}_decode(t){if(t.byteLength===0)throw new Error("Input too short");this._reset(),this._heap8.set(t);let r=this.parser.parse(t.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(t){return this._decode(t),this._res[0]}decodeAll(t){return this._decode(t),this._res}static decode(t,r){return typeof t=="string"&&(t=un.from(t,r||"hex")),new e({size:t.length}).decodeFirst(t)}static decodeAll(t,r){return typeof t=="string"&&(t=un.from(t,r||"hex")),new e({size:t.length}).decodeAll(t)}};Vn.decodeFirst=Vn.decode;af.exports=Vn});var ff=Vt((ry,uf)=>{"use strict";var{Buffer:Jo}=Cn(),hd=Xo(),dd=ts(),Qo=class e extends hd{createTag(t,r){return`${t}(${r})`}createInt(t){return super.createInt(t).toString()}createInt32(t,r){return super.createInt32(t,r).toString()}createInt64(t,r,n,i){return super.createInt64(t,r,n,i).toString()}createInt32Neg(t,r){return super.createInt32Neg(t,r).toString()}createInt64Neg(t,r,n,i){return super.createInt64Neg(t,r,n,i).toString()}createTrue(){return"true"}createFalse(){return"false"}createFloat(t){let r=super.createFloat(t);return dd.isNegativeZero(t)?"-0_1":`${r}_1`}createFloatSingle(t,r,n,i){return`${super.createFloatSingle(t,r,n,i)}_2`}createFloatDouble(t,r,n,i,s,o,a,c){return`${super.createFloatDouble(t,r,n,i,s,o,a,c)}_3`}createByteString(t,r){let n=t.join(", ");return r===-1?`(_ ${n})`:`h'${n}`}createByteStringFromHeap(t,r){return`h'${Jo.from(super.createByteStringFromHeap(t,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(t){return`simple(${t})`}createArray(t,r){let n=super.createArray(t,r);return r===-1?`[_ ${n.join(", ")}]`:`[${n.join(", ")}]`}createMap(t,r){let n=super.createMap(t),i=Array.from(n.keys()).reduce(cf(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createObject(t,r){let n=super.createObject(t),i=Object.keys(n).reduce(cf(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createUtf8String(t,r){let n=t.join(", ");return r===-1?`(_ ${n})`:`"${n}"`}createUtf8StringFromHeap(t,r){return`"${Jo.from(super.createUtf8StringFromHeap(t,r)).toString("utf8")}"`}static diagnose(t,r){return typeof t=="string"&&(t=Jo.from(t,r||"hex")),new e().decodeFirst(t)}};uf.exports=Qo;function cf(e){return(t,r)=>t?`${t}, ${r}: ${e[r]}`:`${r}: ${e[r]}`}});var mf=Vt((ny,pf)=>{"use strict";var{Buffer:Ze}=Cn(),{URL:pd}=Zo(),Do=qn().BigNumber,Lo=ts(),Kt=$n(),Oe=Kt.MT,rs=Kt.NUMBYTES,lf=Kt.SHIFT32,hf=Kt.SYMS,fn=Kt.TAG,md=Kt.MT.SIMPLE_FLOAT<<5|Kt.NUMBYTES.TWO,yd=Kt.MT.SIMPLE_FLOAT<<5|Kt.NUMBYTES.FOUR,gd=Kt.MT.SIMPLE_FLOAT<<5|Kt.NUMBYTES.EIGHT,wd=Kt.MT.SIMPLE_FLOAT<<5|Kt.SIMPLE.TRUE,bd=Kt.MT.SIMPLE_FLOAT<<5|Kt.SIMPLE.FALSE,xd=Kt.MT.SIMPLE_FLOAT<<5|Kt.SIMPLE.UNDEFINED,df=Kt.MT.SIMPLE_FLOAT<<5|Kt.SIMPLE.NULL,_d=new Do("0x20000000000000"),Ed=Ze.from("f97e00","hex"),vd=Ze.from("f9fc00","hex"),Bd=Ze.from("f97c00","hex");function Ad(e){return{}.toString.call(e).slice(8,-1)}var ta=class e{constructor(t){t=t||{},this.streaming=typeof t.stream=="function",this.onData=t.stream,this.semanticTypes=[[pd,this._pushUrl],[Do,this._pushBigNumber]];let r=t.genTypes||[],n=r.length;for(let i=0;i<n;i++)this.addSemanticType(r[i][0],r[i][1]);this._reset()}addSemanticType(t,r){let n=this.semanticTypes.length;for(let i=0;i<n;i++)if(this.semanticTypes[i][0]===t){let o=this.semanticTypes[i][1];return this.semanticTypes[i][1]=r,o}return this.semanticTypes.push([t,r]),null}push(t){return t&&(this.result[this.offset]=t,this.resultMethod[this.offset]=0,this.resultLength[this.offset]=t.length,this.offset++,this.streaming&&this.onData(this.finalize())),!0}pushWrite(t,r,n){return this.result[this.offset]=t,this.resultMethod[this.offset]=r,this.resultLength[this.offset]=n,this.offset++,this.streaming&&this.onData(this.finalize()),!0}_pushUInt8(t){return this.pushWrite(t,1,1)}_pushUInt16BE(t){return this.pushWrite(t,2,2)}_pushUInt32BE(t){return this.pushWrite(t,3,4)}_pushDoubleBE(t){return this.pushWrite(t,4,8)}_pushNaN(){return this.push(Ed)}_pushInfinity(t){let r=t<0?vd:Bd;return this.push(r)}_pushFloat(t){let r=Ze.allocUnsafe(2);if(Lo.writeHalf(r,t)&&Lo.parseHalf(r)===t)return this._pushUInt8(md)&&this.push(r);let n=Ze.allocUnsafe(4);return n.writeFloatBE(t,0),n.readFloatBE(0)===t?this._pushUInt8(yd)&&this.push(n):this._pushUInt8(gd)&&this._pushDoubleBE(t)}_pushInt(t,r,n){let i=r<<5;return t<24?this._pushUInt8(i|t):t<=255?this._pushUInt8(i|rs.ONE)&&this._pushUInt8(t):t<=65535?this._pushUInt8(i|rs.TWO)&&this._pushUInt16BE(t):t<=4294967295?this._pushUInt8(i|rs.FOUR)&&this._pushUInt32BE(t):t<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|rs.EIGHT)&&this._pushUInt32BE(Math.floor(t/lf))&&this._pushUInt32BE(t%lf):r===Oe.NEG_INT?this._pushFloat(n):this._pushFloat(t)}_pushIntNum(t){return t<0?this._pushInt(-t-1,Oe.NEG_INT,t):this._pushInt(t,Oe.POS_INT)}_pushNumber(t){switch(!1){case t===t:return this._pushNaN(t);case isFinite(t):return this._pushInfinity(t);case t%1!==0:return this._pushIntNum(t);default:return this._pushFloat(t)}}_pushString(t){let r=Ze.byteLength(t,"utf8");return this._pushInt(r,Oe.UTF8_STRING)&&this.pushWrite(t,5,r)}_pushBoolean(t){return this._pushUInt8(t?wd:bd)}_pushUndefined(t){return this._pushUInt8(xd)}_pushArray(t,r){let n=r.length;if(!t._pushInt(n,Oe.ARRAY))return!1;for(let i=0;i<n;i++)if(!t.pushAny(r[i]))return!1;return!0}_pushTag(t){return this._pushInt(t,Oe.TAG)}_pushDate(t,r){return t._pushTag(fn.DATE_EPOCH)&&t.pushAny(Math.round(r/1e3))}_pushBuffer(t,r){return t._pushInt(r.length,Oe.BYTE_STRING)&&t.push(r)}_pushNoFilter(t,r){return t._pushBuffer(t,r.slice())}_pushRegexp(t,r){return t._pushTag(fn.REGEXP)&&t.pushAny(r.source)}_pushSet(t,r){if(!t._pushInt(r.size,Oe.ARRAY))return!1;for(let n of r)if(!t.pushAny(n))return!1;return!0}_pushUrl(t,r){return t._pushTag(fn.URI)&&t.pushAny(r.format())}_pushBigint(t){let r=fn.POS_BIGINT;t.isNegative()&&(t=t.negated().minus(1),r=fn.NEG_BIGINT);let n=t.toString(16);n.length%2&&(n="0"+n);let i=Ze.from(n,"hex");return this._pushTag(r)&&this._pushBuffer(this,i)}_pushBigNumber(t,r){if(r.isNaN())return t._pushNaN();if(!r.isFinite())return t._pushInfinity(r.isNegative()?-1/0:1/0);if(r.isInteger())return t._pushBigint(r);if(!(t._pushTag(fn.DECIMAL_FRAC)&&t._pushInt(2,Oe.ARRAY)))return!1;let n=r.decimalPlaces(),i=r.multipliedBy(new Do(10).pow(n));return t._pushIntNum(-n)?i.abs().isLessThan(_d)?t._pushIntNum(i.toNumber()):t._pushBigint(i):!1}_pushMap(t,r){return t._pushInt(r.size,Oe.MAP)?this._pushRawMap(r.size,Array.from(r)):!1}_pushObject(t){if(!t)return this._pushUInt8(df);for(var r=this.semanticTypes.length,n=0;n<r;n++)if(t instanceof this.semanticTypes[n][0])return this.semanticTypes[n][1].call(t,this,t);var i=t.encodeCBOR;if(typeof i=="function")return i.call(t,this);var s=Object.keys(t),o=s.length;return this._pushInt(o,Oe.MAP)?this._pushRawMap(o,s.map(a=>[a,t[a]])):!1}_pushRawMap(t,r){r=r.map(function(i){return i[0]=e.encode(i[0]),i}).sort(Lo.keySorter);for(var n=0;n<t;n++)if(!this.push(r[n][0])||!this.pushAny(r[n][1]))return!1;return!0}write(t){return this.pushAny(t)}pushAny(t){var r=Ad(t);switch(r){case"Number":return this._pushNumber(t);case"String":return this._pushString(t);case"Boolean":return this._pushBoolean(t);case"Object":return this._pushObject(t);case"Array":return this._pushArray(this,t);case"Uint8Array":return this._pushBuffer(this,Ze.isBuffer(t)?t:Ze.from(t));case"Null":return this._pushUInt8(df);case"Undefined":return this._pushUndefined(t);case"Map":return this._pushMap(this,t);case"Set":return this._pushSet(this,t);case"URL":return this._pushUrl(this,t);case"BigNumber":return this._pushBigNumber(this,t);case"Date":return this._pushDate(this,t);case"RegExp":return this._pushRegexp(this,t);case"Symbol":switch(t){case hf.NULL:return this._pushObject(null);case hf.UNDEFINED:return this._pushUndefined(void 0);default:throw new Error("Unknown symbol: "+t.toString())}default:throw new Error("Unknown type: "+typeof t+", "+(t?t.toString():""))}}finalize(){if(this.offset===0)return null;for(var t=this.result,r=this.resultLength,n=this.resultMethod,i=this.offset,s=0,o=0;o<i;o++)s+=r[o];var a=Ze.allocUnsafe(s),c=0,l=0;for(o=0;o<i;o++){switch(l=r[o],n[o]){case 0:t[o].copy(a,c);break;case 1:a.writeUInt8(t[o],c,!0);break;case 2:a.writeUInt16BE(t[o],c,!0);break;case 3:a.writeUInt32BE(t[o],c,!0);break;case 4:a.writeDoubleBE(t[o],c,!0);break;case 5:a.write(t[o],c,l,"utf8");break;default:throw new Error("unkown method")}c+=l}var d=a;return this._reset(),d}_reset(){this.result=[],this.resultMethod=[],this.resultLength=[],this.offset=0}static encode(t){let r=new e;if(!r.pushAny(t))throw new Error("Failed to encode input");return r.finalize()}};pf.exports=ta});var ea=Vt(Wt=>{"use strict";Wt.Diagnose=ff();Wt.Decoder=Xo();Wt.Encoder=mf();Wt.Simple=Go();Wt.Tagged=Yo();Wt.decodeAll=Wt.Decoder.decodeAll;Wt.decodeFirst=Wt.Decoder.decodeFirst;Wt.diagnose=Wt.Diagnose.diagnose;Wt.encode=Wt.Encoder.encode;Wt.decode=Wt.Decoder.decode;Wt.leveldb={decode:Wt.Decoder.decodeAll,encode:Wt.Encoder.encode,buffer:!0,name:"cbor"}});function ie(...e){let t=new Uint8Array(e.reduce((n,i)=>n+i.byteLength,0)),r=0;for(let n of e)t.set(new Uint8Array(n),r),r+=n.byteLength;return t.buffer}function Yt(e){return[...new Uint8Array(e)].map(t=>t.toString(16).padStart(2,"0")).join("")}function Cr(e){if(!Td.test(e))throw new Error("Invalid hexadecimal string.");let t=[...e].reduce((r,n,i)=>(r[i/2|0]=(r[i/2|0]||"")+n,r),[]).map(r=>Number.parseInt(r,16));return new Uint8Array(t).buffer}function ra(e,t){if(e.byteLength!==t.byteLength)return e.byteLength-t.byteLength;let r=new Uint8Array(e),n=new Uint8Array(t);for(let i=0;i<r.length;i++)if(r[i]!==n[i])return r[i]-n[i];return 0}function Gn(e,t){return ra(e,t)===0}function Hn(e){return new DataView(e.buffer,e.byteOffset,e.byteLength).buffer}function na(e){return e instanceof Uint8Array?Hn(e):e instanceof ArrayBuffer?e:Array.isArray(e)?Hn(new Uint8Array(e)):"buffer"in e?na(e.buffer):Hn(new Uint8Array(e))}var Td,pe=bt(()=>{Td=new RegExp(/^[0-9a-fA-F]+$/)});function Be(e){return Hn(Rn.create().update(new Uint8Array(e)).digest())}function ns(e){if(e instanceof yf.default.Tagged)return ns(e.value);if(typeof e=="string")return gf(e);if(typeof e=="number")return Be(Ot(e));if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return Be(e);if(Array.isArray(e)){let t=e.map(ns);return Be(ie(...t))}else{if(e&&typeof e=="object"&&e._isPrincipal)return Be(e.toUint8Array());if(typeof e=="object"&&e!==null&&typeof e.toHash=="function")return ns(e.toHash());if(typeof e=="object")return jn(e);if(typeof e=="bigint")return Be(Ot(e))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${e}`),{value:e})}function is(e){return jn(e)}function jn(e){let n=Object.entries(e).filter(([,o])=>o!==void 0).map(([o,a])=>{let c=gf(o),l=ns(a);return[c,l]}).sort(([o],[a])=>ra(o,a)),i=ie(...n.map(o=>ie(...o)));return Be(i)}var yf,gf,Yn=bt(()=>{Mn();yf=Jr(ea());Bi();pe();gf=e=>{let t=new TextEncoder().encode(e);return Be(t)}});var oa=Vt(Nt=>{"use strict";Object.defineProperty(Nt,"__esModule",{value:!0});var Sd=9007199254740992;function ir(e,...t){let r=new Uint8Array(e.byteLength+t.reduce((i,s)=>i+s.byteLength,0));r.set(new Uint8Array(e),0);let n=e.byteLength;for(let i of t)r.set(new Uint8Array(i),n),n+=i.byteLength;return r.buffer}function Fe(e,t,r){r=r.replace(/[^0-9a-fA-F]/g,"");let n=2**(t-24);r=r.slice(-n*2).padStart(n*2,"0");let i=[(e<<5)+t].concat(r.match(/../g).map(s=>parseInt(s,16)));return new Uint8Array(i).buffer}function ss(e,t){if(t<24)return new Uint8Array([(e<<5)+t]).buffer;{let r=t<=255?24:t<=65535?25:t<=4294967295?26:27;return Fe(e,r,t.toString(16))}}function wf(e){let t=[];for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);n<128?t.push(n):n<2048?t.push(192|n>>6,128|n&63):n<55296||n>=57344?t.push(224|n>>12,128|n>>6&63,128|n&63):(r++,n=(n&1023)<<10|e.charCodeAt(r)&1023,t.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|n&63))}return ir(new Uint8Array(ss(3,e.length)),new Uint8Array(t))}function Nd(e,t){if(e==14277111)return ir(new Uint8Array([217,217,247]),t);if(e<24)return ir(new Uint8Array([192+e]),t);{let r=e<=255?24:e<=65535?25:e<=4294967295?26:27,n=2**(r-24),i=e.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}}Nt.tagged=Nd;function zn(e){return new Uint8Array(e).buffer}Nt.raw=zn;function ia(e){if(isNaN(e))throw new RangeError("Invalid number.");e=Math.min(Math.max(0,e),23);let t=[0+e];return new Uint8Array(t).buffer}Nt.uSmall=ia;function bf(e,t){if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,e),255),e=e.toString(16),Fe(0,24,e)}Nt.u8=bf;function xf(e,t){if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,e),65535),e=e.toString(16),Fe(0,25,e)}Nt.u16=xf;function _f(e,t){if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,e),4294967295),e=e.toString(16),Fe(0,26,e)}Nt.u32=_f;function sa(e,t){if(typeof e=="string"&&t==16){if(e.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return Fe(0,27,e)}if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,e),Sd),e=e.toString(16),Fe(0,27,e)}Nt.u64=sa;function Ef(e){if(isNaN(e))throw new RangeError("Invalid number.");if(e===0)return ia(0);e=Math.min(Math.max(0,-e),24)-1;let t=[32+e];return new Uint8Array(t).buffer}Nt.iSmall=Ef;function vf(e,t){if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,-e-1),255),e=e.toString(16),Fe(1,24,e)}Nt.i8=vf;function Bf(e,t){if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,-e-1),65535),e=e.toString(16),Fe(1,25,e)}Nt.i16=Bf;function Af(e,t){if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,-e-1),4294967295),e=e.toString(16),Fe(1,26,e)}Nt.i32=Af;function Tf(e,t){if(typeof e=="string"&&t==16){if(e.startsWith("-")?e=e.slice(1):e="0",e.match(/[^0-9a-fA-F]/)||e.length>16)throw new RangeError("Invalid number.");let r=!1,n=e.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?Fe(1,27,n):sa(0)}if(e=parseInt(""+e,t),isNaN(e))throw new RangeError("Invalid number.");return e=Math.min(Math.max(0,-e-1),9007199254740992),e=e.toString(16),Fe(1,27,e)}Nt.i64=Tf;function Rd(e){return e>=0?e<24?ia(e):e<=255?bf(e):e<=65535?xf(e):e<=4294967295?_f(e):sa(e):e>=-24?Ef(e):e>=-255?vf(e):e>=-65535?Bf(e):e>=-4294967295?Af(e):Tf(e)}Nt.number=Rd;function Od(e){return ir(ss(2,e.byteLength),e)}Nt.bytes=Od;function Fd(e){return wf(e)}Nt.string=Fd;function Ud(e){return ir(ss(4,e.length),...e)}Nt.array=Ud;function Id(e,t=!1){e instanceof Map||(e=new Map(Object.entries(e)));let r=Array.from(e.entries());return t&&(r=r.sort(([n],[i])=>n.localeCompare(i))),ir(ss(5,e.size),...r.map(([n,i])=>ir(wf(n),i)))}Nt.map=Id;function Pd(e){let t=new Float32Array([e]);return ir(new Uint8Array([250]),new Uint8Array(t.buffer))}Nt.singleFloat=Pd;function kd(e){let t=new Float64Array([e]);return ir(new Uint8Array([251]),new Uint8Array(t.buffer))}Nt.doubleFloat=kd;function Md(e){return e?Sf():Nf()}Nt.bool=Md;function Sf(){return zn(new Uint8Array([245]))}Nt.true_=Sf;function Nf(){return zn(new Uint8Array([244]))}Nt.false_=Nf;function Cd(){return zn(new Uint8Array([246]))}Nt.null_=Cd;function qd(){return zn(new Uint8Array([247]))}Nt.undefined_=qd});var Rf=Vt(xr=>{"use strict";var $d=xr&&xr.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(xr,"__esModule",{value:!0});var Ue=$d(oa()),Vd=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],os=class{constructor(t,r=!1){this._serializer=t,this._stable=r,this.name="jsonDefault",this.priority=-100}match(t){return["undefined","boolean","number","string","object"].indexOf(typeof t)!=-1}encode(t){switch(typeof t){case"undefined":return Ue.undefined_();case"boolean":return Ue.bool(t);case"number":return Math.floor(t)===t?Ue.number(t):Ue.doubleFloat(t);case"string":return Ue.string(t);case"object":if(t===null)return Ue.null_();if(Array.isArray(t))return Ue.array(t.map(r=>this._serializer.serializeValue(r)));if(Vd.find(r=>t instanceof r))return Ue.bytes(t.buffer);if(Object.getOwnPropertyNames(t).indexOf("toJSON")!==-1)return this.encode(t.toJSON());if(t instanceof Map){let r=new Map;for(let[n,i]of t.entries())r.set(n,this._serializer.serializeValue(i));return Ue.map(r,this._stable)}else{let r=new Map;for(let[n,i]of Object.entries(t))r.set(n,this._serializer.serializeValue(i));return Ue.map(r,this._stable)}default:throw new Error("Invalid value.")}}};xr.JsonDefaultCborEncoder=os;var as=class{constructor(){this.name="cborEncoder",this.priority=-90}match(t){return typeof t=="object"&&typeof t.toCBOR=="function"}encode(t){return t.toCBOR()}};xr.ToCborEncoder=as;var cs=class{constructor(){this._encoders=new Set}static withDefaultEncoders(t=!1){let r=new this;return r.addEncoder(new os(r,t)),r.addEncoder(new as),r}removeEncoder(t){for(let r of this._encoders.values())r.name==t&&this._encoders.delete(r)}addEncoder(t){this._encoders.add(t)}getEncoderFor(t){let r=null;for(let n of this._encoders)(!r||n.priority>r.priority)&&n.match(t)&&(r=n);if(r===null)throw new Error("Could not find an encoder for value.");return r}serializeValue(t){return this.getEncoderFor(t).encode(t)}serialize(t){return this.serializeValue(t)}};xr.CborSerializer=cs;var aa=class extends cs{serialize(t){return Ue.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(t))]))}};xr.SelfDescribeCborSerializer=aa});var us=Vt(qr=>{"use strict";function Hd(e){for(var t in e)qr.hasOwnProperty(t)||(qr[t]=e[t])}var Gd=qr&&qr.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(qr,"__esModule",{value:!0});Hd(Rf());var jd=Gd(oa());qr.value=jd});function ls(e){return fs.serialize(e)}function Of(e){let t=e.byteLength,r=BigInt(0);for(let n=0;n<t;n++)r=r*BigInt(256)+BigInt(e[n]);return r}function Ae(e){let t=new Uint8Array(e),r=new ha({size:t.byteLength,tags:{2:n=>Of(n),3:n=>-Of(n),[la.Semantic]:n=>n}});try{return r.decodeFirst(t)}catch(n){throw new Error(`Failed to decode CBOR: ${n}, input: ${Yt(t)}`)}}var Ff,$r,Uf,ca,ua,fa,fs,la,ha,Kn=bt(()=>{Ff=Jr(ea()),$r=Jr(us()),Uf=Jr(us());pe();ca=class{get name(){return"Principal"}get priority(){return 0}match(t){return t&&t._isPrincipal===!0}encode(t){return $r.value.bytes(t.toUint8Array())}},ua=class{get name(){return"Buffer"}get priority(){return 1}match(t){return t instanceof ArrayBuffer||ArrayBuffer.isView(t)}encode(t){return $r.value.bytes(new Uint8Array(t))}},fa=class{get name(){return"BigInt"}get priority(){return 1}match(t){return typeof t=="bigint"}encode(t){return t>BigInt(0)?$r.value.tagged(2,$r.value.bytes(Cr(t.toString(16)))):$r.value.tagged(3,$r.value.bytes(Cr((BigInt("-1")*t).toString(16))))}},fs=Uf.SelfDescribeCborSerializer.withDefaultEncoders(!0);fs.addEncoder(new ca);fs.addEncoder(new ua);fs.addEncoder(new fa);(function(e){e[e.Uint64LittleEndian=71]="Uint64LittleEndian",e[e.Semantic=55799]="Semantic"})(la||(la={}));ha=class extends Ff.default.Decoder{createByteString(t){return ie(...t)}createByteStringFromHeap(t,r){return t===r?new ArrayBuffer(0):new Uint8Array(this._heap.slice(t,r))}}});var gs={};Sn(gs,{aInRange:()=>ke,abool:()=>_r,abytes:()=>Ie,bitGet:()=>wa,bitLen:()=>Gr,bitMask:()=>vr,bitSet:()=>Jd,bytesToHex:()=>Pe,bytesToNumberBE:()=>te,bytesToNumberLE:()=>Er,concatBytes:()=>Tt,createHmacDrbg:()=>Cf,ensureBytes:()=>zt,equalBytes:()=>Xd,hexToBytes:()=>Jn,hexToNumber:()=>ga,inRange:()=>ms,isBytes:()=>dn,memoized:()=>or,notImplemented:()=>ys,numberToBytesBE:()=>kt,numberToBytesLE:()=>Hr,numberToHexUnpadded:()=>Mf,numberToVarBytesBE:()=>Zd,utf8ToBytes:()=>Qn,validateObject:()=>Me});function dn(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function Ie(e){if(!dn(e))throw new Error("Uint8Array expected")}function _r(e,t){if(typeof t!="boolean")throw new Error(`${e} must be valid boolean, got "${t}".`)}function Pe(e){Ie(e);let t="";for(let r=0;r<e.length;r++)t+=Wd[e[r]];return t}function Mf(e){let t=e.toString(16);return t.length&1?`0${t}`:t}function ga(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return BigInt(e===""?"0":`0x${e}`)}function Pf(e){if(e>=sr._0&&e<=sr._9)return e-sr._0;if(e>=sr._A&&e<=sr._F)return e-(sr._A-10);if(e>=sr._a&&e<=sr._f)return e-(sr._a-10)}function Jn(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);let t=e.length,r=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){let o=Pf(e.charCodeAt(s)),a=Pf(e.charCodeAt(s+1));if(o===void 0||a===void 0){let c=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=o*16+a}return n}function te(e){return ga(Pe(e))}function Er(e){return Ie(e),ga(Pe(Uint8Array.from(e).reverse()))}function kt(e,t){return Jn(e.toString(16).padStart(t*2,"0"))}function Hr(e,t){return kt(e,t).reverse()}function Zd(e){return Jn(Mf(e))}function zt(e,t,r){let n;if(typeof t=="string")try{n=Jn(t)}catch(s){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${s}`)}else if(dn(t))n=Uint8Array.from(t);else throw new Error(`${e} must be hex string or Uint8Array`);let i=n.length;if(typeof r=="number"&&i!==r)throw new Error(`${e} expected ${r} bytes, got ${i}`);return n}function Tt(...e){let t=0;for(let n=0;n<e.length;n++){let i=e[n];Ie(i),t+=i.length}let r=new Uint8Array(t);for(let n=0,i=0;n<e.length;n++){let s=e[n];r.set(s,i),i+=s.length}return r}function Xd(e,t){if(e.length!==t.length)return!1;let r=0;for(let n=0;n<e.length;n++)r|=e[n]^t[n];return r===0}function Qn(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function ms(e,t,r){return pa(e)&&pa(t)&&pa(r)&&t<=e&&e<r}function ke(e,t,r,n){if(!ms(t,r,n))throw new Error(`expected valid ${e}: ${r} <= n < ${n}, got ${typeof t} ${t}`)}function Gr(e){let t;for(t=0;e>ya;e>>=ps,t+=1);return t}function wa(e,t){return e>>BigInt(t)&ps}function Jd(e,t,r){return e|(r?ps:ya)<<BigInt(t)}function Cf(e,t,r){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=ma(e),i=ma(e),s=0,o=()=>{n.fill(1),i.fill(0),s=0},a=(...h)=>r(i,n,...h),c=(h=ma())=>{i=a(kf([0]),h),n=a(),h.length!==0&&(i=a(kf([1]),h),n=a())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let h=0,N=[];for(;h<t;){n=a();let w=n.slice();N.push(w),h+=n.length}return Tt(...N)};return(h,N)=>{o(),c(h);let w;for(;!(w=N(l()));)c();return o(),w}}function Me(e,t,r={}){let n=(i,s,o)=>{let a=Qd[s];if(typeof a!="function")throw new Error(`Invalid validator "${s}", expected function`);let c=e[i];if(!(o&&c===void 0)&&!a(c,e))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${s}`)};for(let[i,s]of Object.entries(t))n(i,s,!1);for(let[i,s]of Object.entries(r))n(i,s,!0);return e}function or(e){let t=new WeakMap;return(r,...n)=>{let i=t.get(r);if(i!==void 0)return i;let s=e(r,...n);return t.set(r,s),s}}var ya,ps,Kd,Wd,sr,pa,vr,ma,kf,Qd,ys,Ce=bt(()=>{ya=BigInt(0),ps=BigInt(1),Kd=BigInt(2);Wd=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));sr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};pa=e=>typeof e=="bigint"&&ya<=e;vr=e=>(Kd<<BigInt(e-1))-ps,ma=e=>new Uint8Array(e),kf=e=>Uint8Array.from(e);Qd={bigint:e=>typeof e=="bigint",function:e=>typeof e=="function",boolean:e=>typeof e=="boolean",string:e=>typeof e=="string",stringOrUint8Array:e=>typeof e=="string"||dn(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e=="function"&&Number.isSafeInteger(e.outputLen)};ys=()=>{throw new Error("not implemented")}});function Rt(e,t){let r=e%t;return r>=Zt?r:t+r}function ep(e,t,r){if(r<=Zt||t<Zt)throw new Error("Expected power/modulo > 0");if(r===Ft)return Zt;let n=Ft;for(;t>Zt;)t&Ft&&(n=n*e%r),e=e*e%r,t>>=Ft;return n}function qe(e,t,r){let n=e;for(;t-- >Zt;)n*=n,n%=r;return n}function xa(e,t){if(e===Zt||t<=Zt)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let r=Rt(e,t),n=t,i=Zt,s=Ft,o=Ft,a=Zt;for(;r!==Zt;){let l=n/r,d=n%r,h=i-o*l,N=s-a*l;n=r,r=d,i=o,s=a,o=h,a=N}if(n!==Ft)throw new Error("invert: does not exist");return Rt(i,t)}function rp(e){let t=(e-Ft)/Br,r,n,i;for(r=e-Ft,n=0;r%Br===Zt;r/=Br,n++);for(i=Br;i<e&&ep(i,t,e)!==e-Ft;i++);if(n===1){let o=(e+Ft)/ba;return function(c,l){let d=c.pow(l,o);if(!c.eql(c.sqr(d),l))throw new Error("Cannot find square root");return d}}let s=(r+Ft)/Br;return function(a,c){if(a.pow(c,t)===a.neg(a.ONE))throw new Error("Cannot find square root");let l=n,d=a.pow(a.mul(a.ONE,i),r),h=a.pow(c,s),N=a.pow(c,r);for(;!a.eql(N,a.ONE);){if(a.eql(N,a.ZERO))return a.ZERO;let w=1;for(let x=a.sqr(N);w<l&&!a.eql(x,a.ONE);w++)x=a.sqr(x);let u=a.pow(d,Ft<<BigInt(l-w-1));d=a.sqr(u),h=a.mul(h,u),N=a.mul(N,d),l=w}return h}}function np(e){if(e%ba===Ld){let t=(e+Ft)/ba;return function(n,i){let s=n.pow(i,t);if(!n.eql(n.sqr(s),i))throw new Error("Cannot find square root");return s}}if(e%$f===qf){let t=(e-qf)/$f;return function(n,i){let s=n.mul(i,Br),o=n.pow(s,t),a=n.mul(i,o),c=n.mul(n.mul(a,Br),o),l=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(l),i))throw new Error("Cannot find square root");return l}}return e%tp,rp(e)}function ws(e){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=ip.reduce((n,i)=>(n[i]="function",n),t);return Me(e,r)}function Ln(e,t,r){if(r<Zt)throw new Error("Expected power > 0");if(r===Zt)return e.ONE;if(r===Ft)return t;let n=e.ONE,i=t;for(;r>Zt;)r&Ft&&(n=e.mul(n,i)),i=e.sqr(i),r>>=Ft;return n}function Dn(e,t){let r=new Array(t.length),n=t.reduce((s,o,a)=>e.is0(o)?s:(r[a]=s,e.mul(s,o)),e.ONE),i=e.inv(n);return t.reduceRight((s,o,a)=>e.is0(o)?s:(r[a]=e.mul(s,r[a]),e.mul(s,o)),i),r}function Hf(e){let t=(e-Ft)/Br;return(r,n)=>r.pow(n,t)}function _a(e,t){let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function pn(e,t,r=!1,n={}){if(e<=Zt)throw new Error(`Expected Field ORDER > 0, got ${e}`);let{nBitLength:i,nByteLength:s}=_a(e,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=np(e),a=Object.freeze({ORDER:e,BITS:i,BYTES:s,MASK:vr(i),ZERO:Zt,ONE:Ft,create:c=>Rt(c,e),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return Zt<=c&&c<e},is0:c=>c===Zt,isOdd:c=>(c&Ft)===Ft,neg:c=>Rt(-c,e),eql:(c,l)=>c===l,sqr:c=>Rt(c*c,e),add:(c,l)=>Rt(c+l,e),sub:(c,l)=>Rt(c-l,e),mul:(c,l)=>Rt(c*l,e),pow:(c,l)=>Ln(a,c,l),div:(c,l)=>Rt(c*xa(l,e),e),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>xa(c,e),sqrt:n.sqrt||(c=>o(a,c)),invertBatch:c=>Dn(a,c),cmov:(c,l,d)=>d?l:c,toBytes:c=>r?Hr(c,s):kt(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return r?Er(c):te(c)}});return Object.freeze(a)}function Gf(e){if(typeof e!="bigint")throw new Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function bs(e){let t=Gf(e);return t+Math.ceil(t/2)}function Ea(e,t,r=!1){let n=e.length,i=Gf(t),s=bs(t);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let o=r?te(e):Er(e),a=Rt(o,t-Ft)+Ft;return r?Hr(a,i):kt(a,i)}var Zt,Ft,Br,Ld,ba,qf,$f,Dd,tp,Vf,ip,ar=bt(()=>{Ce();Zt=BigInt(0),Ft=BigInt(1),Br=BigInt(2),Ld=BigInt(3),ba=BigInt(4),qf=BigInt(5),$f=BigInt(8),Dd=BigInt(9),tp=BigInt(16);Vf=(e,t)=>(Rt(e,t)&Ft)===Ft,ip=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"]});function Ar(e,t){if(e<0||e>=1<<8*t)throw new Error(`bad I2OSP call: value=${e} length=${t}`);let r=Array.from({length:t}).fill(0);for(let n=t-1;n>=0;n--)r[n]=e&255,e>>>=8;return new Uint8Array(r)}function op(e,t){let r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e[n]^t[n];return r}function Ba(e){if(!Number.isSafeInteger(e))throw new Error("number expected")}function ap(e,t,r,n){Ie(e),Ie(t),Ba(r),t.length>255&&(t=n(Tt(Qn("H2C-OVERSIZE-DST-"),t)));let{outputLen:i,blockLen:s}=n,o=Math.ceil(r/i);if(o>255)throw new Error("Invalid xmd length");let a=Tt(t,Ar(t.length,1)),c=Ar(0,s),l=Ar(r,2),d=new Array(o),h=n(Tt(c,e,l,Ar(0,1),a));d[0]=n(Tt(h,Ar(1,1),a));for(let w=1;w<=o;w++){let u=[op(h,d[w-1]),Ar(w+1,1),a];d[w]=n(Tt(...u))}return Tt(...d).slice(0,r)}function cp(e,t,r,n,i){if(Ie(e),Ie(t),Ba(r),t.length>255){let s=Math.ceil(2*n/8);t=i.create({dkLen:s}).update(Qn("H2C-OVERSIZE-DST-")).update(t).digest()}if(r>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:r}).update(e).update(Ar(r,2)).update(t).update(Ar(t.length,1)).digest()}function jf(e,t,r){Me(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;Ie(e),Ba(t);let l=typeof c=="string"?Qn(c):c,d=n.toString(2).length,h=Math.ceil((d+i)/8),N=t*s*h,w;if(a==="xmd")w=ap(e,l,N,o);else if(a==="xof")w=cp(e,l,N,i,o);else if(a==="_internal_pass")w=e;else throw new Error('expand must be "xmd" or "xof"');let u=new Array(t);for(let x=0;x<t;x++){let C=new Array(s);for(let M=0;M<s;M++){let k=h*(M+x*s),H=w.subarray(k,k+h);C[M]=Rt(sp(H),n)}u[x]=C}return u}function Aa(e,t){let r=t.map(n=>Array.from(n).reverse());return(n,i)=>{let[s,o,a,c]=r.map(l=>l.reduce((d,h)=>e.add(e.mul(d,n),h)));return n=e.div(s,o),i=e.mul(i,e.div(a,c)),{x:n,y:i}}}function Ta(e,t,r){if(typeof t!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){let s=jf(n,2,{...r,DST:r.DST,...i}),o=e.fromAffine(t(s[0])),a=e.fromAffine(t(s[1])),c=o.add(a).clearCofactor();return c.assertValidity(),c},encodeToCurve(n,i){let s=jf(n,1,{...r,DST:r.encodeDST,...i}),o=e.fromAffine(t(s[0])).clearCofactor();return o.assertValidity(),o},mapToCurve(n){if(!Array.isArray(n))throw new Error("mapToCurve: expected array of bigints");for(let s of n)if(typeof s!="bigint")throw new Error(`mapToCurve: expected array of bigints, got ${s} in array`);let i=e.fromAffine(t(n)).clearCofactor();return i.assertValidity(),i}}}var sp,Sa=bt(()=>{ar();Ce();sp=te});function xs(e,t){let r=(s,o)=>{let a=o.negate();return s?a:o},n=s=>{if(!Number.isSafeInteger(s)||s<=0||s>t)throw new Error(`Wrong window size=${s}, should be [1..${t}]`)},i=s=>{n(s);let o=Math.ceil(t/s)+1,a=2**(s-1);return{windows:o,windowSize:a}};return{constTimeNegate:r,unsafeLadder(s,o){let a=e.ZERO,c=s;for(;o>up;)o&Na&&(a=a.add(c)),c=c.double(),o>>=Na;return a},precomputeWindow(s,o){let{windows:a,windowSize:c}=i(o),l=[],d=s,h=d;for(let N=0;N<a;N++){h=d,l.push(h);for(let w=1;w<c;w++)h=h.add(d),l.push(h);d=h.double()}return l},wNAF(s,o,a){let{windows:c,windowSize:l}=i(s),d=e.ZERO,h=e.BASE,N=BigInt(2**s-1),w=2**s,u=BigInt(s);for(let x=0;x<c;x++){let C=x*l,M=Number(a&N);a>>=u,M>l&&(M-=w,a+=Na);let k=C,H=C+Math.abs(M)-1,X=x%2!==0,E=M<0;M===0?h=h.add(r(X,o[k])):d=d.add(r(E,o[H]))}return{p:d,f:h}},wNAFCached(s,o,a){let c=Yf.get(s)||1,l=Ra.get(s);return l||(l=this.precomputeWindow(s,c),c!==1&&Ra.set(s,a(l))),this.wNAF(c,l,o)},setWindowSize(s,o){n(o),Yf.set(s,o),Ra.delete(s)}}}function _s(e){return ws(e.Fp),Me(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({..._a(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}var up,Na,Ra,Yf,Oa=bt(()=>{ar();Ce();up=BigInt(0),Na=BigInt(1),Ra=new WeakMap,Yf=new WeakMap});function fp(e){let t=_s(e);Me(t,{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}=t;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({...t})}function Fa(e){let t=fp(e),{Fp:r}=t,n=t.toBytes||((u,x,C)=>{let M=x.toAffine();return Tt(Uint8Array.from([4]),r.toBytes(M.x),r.toBytes(M.y))}),i=t.fromBytes||(u=>{let x=u.subarray(1),C=r.fromBytes(x.subarray(0,r.BYTES)),M=r.fromBytes(x.subarray(r.BYTES,2*r.BYTES));return{x:C,y:M}});function s(u){let{a:x,b:C}=t,M=r.sqr(u),k=r.mul(M,u);return r.add(r.add(k,r.mul(u,x)),C)}if(!r.eql(r.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function o(u){return ms(u,Mt,t.n)}function a(u){let{allowedPrivateKeyLengths:x,nByteLength:C,wrapPrivateKey:M,n:k}=t;if(x&&typeof u!="bigint"){if(dn(u)&&(u=Pe(u)),typeof u!="string"||!x.includes(u.length))throw new Error("Invalid key");u=u.padStart(C*2,"0")}let H;try{H=typeof u=="bigint"?u:te(zt("private key",u,C))}catch{throw new Error(`private key must be ${C} bytes, hex or bigint, not ${typeof u}`)}return M&&(H=Rt(H,k)),ke("private key",H,Mt,k),H}function c(u){if(!(u instanceof h))throw new Error("ProjectivePoint expected")}let l=or((u,x)=>{let{px:C,py:M,pz:k}=u;if(r.eql(k,r.ONE))return{x:C,y:M};let H=u.is0();x==null&&(x=H?r.ONE:r.inv(k));let X=r.mul(C,x),E=r.mul(M,x),q=r.mul(k,x);if(H)return{x:r.ZERO,y:r.ZERO};if(!r.eql(q,r.ONE))throw new Error("invZ was invalid");return{x:X,y:E}}),d=or(u=>{if(u.is0()){if(t.allowInfinityPoint&&!r.is0(u.py))return;throw new Error("bad point: ZERO")}let{x,y:C}=u.toAffine();if(!r.isValid(x)||!r.isValid(C))throw new Error("bad point: x or y not FE");let M=r.sqr(C),k=s(x);if(!r.eql(M,k))throw new Error("bad point: equation left != right");if(!u.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class h{constructor(x,C,M){if(this.px=x,this.py=C,this.pz=M,x==null||!r.isValid(x))throw new Error("x required");if(C==null||!r.isValid(C))throw new Error("y required");if(M==null||!r.isValid(M))throw new Error("z required");Object.freeze(this)}static fromAffine(x){let{x:C,y:M}=x||{};if(!x||!r.isValid(C)||!r.isValid(M))throw new Error("invalid affine point");if(x instanceof h)throw new Error("projective point not allowed");let k=H=>r.eql(H,r.ZERO);return k(C)&&k(M)?h.ZERO:new h(C,M,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(x){let C=r.invertBatch(x.map(M=>M.pz));return x.map((M,k)=>M.toAffine(C[k])).map(h.fromAffine)}static fromHex(x){let C=h.fromAffine(i(zt("pointHex",x)));return C.assertValidity(),C}static fromPrivateKey(x){return h.BASE.multiply(a(x))}_setWindowSize(x){w.setWindowSize(this,x)}assertValidity(){d(this)}hasEvenY(){let{y:x}=this.toAffine();if(r.isOdd)return!r.isOdd(x);throw new Error("Field doesn't support isOdd")}equals(x){c(x);let{px:C,py:M,pz:k}=this,{px:H,py:X,pz:E}=x,q=r.eql(r.mul(C,E),r.mul(H,k)),W=r.eql(r.mul(M,E),r.mul(X,k));return q&&W}negate(){return new h(this.px,r.neg(this.py),this.pz)}double(){let{a:x,b:C}=t,M=r.mul(C,Es),{px:k,py:H,pz:X}=this,E=r.ZERO,q=r.ZERO,W=r.ZERO,K=r.mul(k,k),G=r.mul(H,H),tt=r.mul(X,X),rt=r.mul(k,H);return rt=r.add(rt,rt),W=r.mul(k,X),W=r.add(W,W),E=r.mul(x,W),q=r.mul(M,tt),q=r.add(E,q),E=r.sub(G,q),q=r.add(G,q),q=r.mul(E,q),E=r.mul(rt,E),W=r.mul(M,W),tt=r.mul(x,tt),rt=r.sub(K,tt),rt=r.mul(x,rt),rt=r.add(rt,W),W=r.add(K,K),K=r.add(W,K),K=r.add(K,tt),K=r.mul(K,rt),q=r.add(q,K),tt=r.mul(H,X),tt=r.add(tt,tt),K=r.mul(tt,rt),E=r.sub(E,K),W=r.mul(tt,G),W=r.add(W,W),W=r.add(W,W),new h(E,q,W)}add(x){c(x);let{px:C,py:M,pz:k}=this,{px:H,py:X,pz:E}=x,q=r.ZERO,W=r.ZERO,K=r.ZERO,G=t.a,tt=r.mul(t.b,Es),rt=r.mul(C,H),at=r.mul(M,X),g=r.mul(k,E),T=r.add(C,M),B=r.add(H,X);T=r.mul(T,B),B=r.add(rt,at),T=r.sub(T,B),B=r.add(C,k);let A=r.add(H,E);return B=r.mul(B,A),A=r.add(rt,g),B=r.sub(B,A),A=r.add(M,k),q=r.add(X,E),A=r.mul(A,q),q=r.add(at,g),A=r.sub(A,q),K=r.mul(G,B),q=r.mul(tt,g),K=r.add(q,K),q=r.sub(at,K),K=r.add(at,K),W=r.mul(q,K),at=r.add(rt,rt),at=r.add(at,rt),g=r.mul(G,g),B=r.mul(tt,B),at=r.add(at,g),g=r.sub(rt,g),g=r.mul(G,g),B=r.add(B,g),rt=r.mul(at,B),W=r.add(W,rt),rt=r.mul(A,B),q=r.mul(T,q),q=r.sub(q,rt),rt=r.mul(T,at),K=r.mul(A,K),K=r.add(K,rt),new h(q,W,K)}subtract(x){return this.add(x.negate())}is0(){return this.equals(h.ZERO)}wNAF(x){return w.wNAFCached(this,x,h.normalizeZ)}multiplyUnsafe(x){ke("scalar",x,jr,t.n);let C=h.ZERO;if(x===jr)return C;if(x===Mt)return this;let{endo:M}=t;if(!M)return w.unsafeLadder(this,x);let{k1neg:k,k1:H,k2neg:X,k2:E}=M.splitScalar(x),q=C,W=C,K=this;for(;H>jr||E>jr;)H&Mt&&(q=q.add(K)),E&Mt&&(W=W.add(K)),K=K.double(),H>>=Mt,E>>=Mt;return k&&(q=q.negate()),X&&(W=W.negate()),W=new h(r.mul(W.px,M.beta),W.py,W.pz),q.add(W)}multiply(x){let{endo:C,n:M}=t;ke("scalar",x,Mt,M);let k,H;if(C){let{k1neg:X,k1:E,k2neg:q,k2:W}=C.splitScalar(x),{p:K,f:G}=this.wNAF(E),{p:tt,f:rt}=this.wNAF(W);K=w.constTimeNegate(X,K),tt=w.constTimeNegate(q,tt),tt=new h(r.mul(tt.px,C.beta),tt.py,tt.pz),k=K.add(tt),H=G.add(rt)}else{let{p:X,f:E}=this.wNAF(x);k=X,H=E}return h.normalizeZ([k,H])[0]}multiplyAndAddUnsafe(x,C,M){let k=h.BASE,H=(E,q)=>q===jr||q===Mt||!E.equals(k)?E.multiplyUnsafe(q):E.multiply(q),X=H(this,C).add(H(x,M));return X.is0()?void 0:X}toAffine(x){return l(this,x)}isTorsionFree(){let{h:x,isTorsionFree:C}=t;if(x===Mt)return!0;if(C)return C(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:x,clearCofactor:C}=t;return x===Mt?this:C?C(h,this):this.multiplyUnsafe(t.h)}toRawBytes(x=!0){return _r("isCompressed",x),this.assertValidity(),n(h,this,x)}toHex(x=!0){return _r("isCompressed",x),Pe(this.toRawBytes(x))}}h.BASE=new h(t.Gx,t.Gy,r.ONE),h.ZERO=new h(r.ZERO,r.ONE,r.ZERO);let N=t.nBitLength,w=xs(h,t.endo?Math.ceil(N/2):N);return{CURVE:t,ProjectivePoint:h,normPrivateKeyToScalar:a,weierstrassEquation:s,isWithinCurveOrder:o}}function lp(e,t){let r=e.ORDER,n=jr;for(let u=r-Mt;u%Tr===jr;u/=Tr)n+=Mt;let i=n,s=Tr<<i-Mt-Mt,o=s*Tr,a=(r-Mt)/o,c=(a-Mt)/Tr,l=o-Mt,d=s,h=e.pow(t,a),N=e.pow(t,(a+Mt)/Tr),w=(u,x)=>{let C=h,M=e.pow(x,l),k=e.sqr(M);k=e.mul(k,x);let H=e.mul(u,k);H=e.pow(H,c),H=e.mul(H,M),M=e.mul(H,x),k=e.mul(H,u);let X=e.mul(k,M);H=e.pow(X,d);let E=e.eql(H,e.ONE);M=e.mul(k,N),H=e.mul(X,C),k=e.cmov(M,k,E),X=e.cmov(H,X,E);for(let q=i;q>Mt;q--){let W=q-Tr;W=Tr<<W-Mt;let K=e.pow(X,W),G=e.eql(K,e.ONE);M=e.mul(k,C),C=e.mul(C,C),K=e.mul(X,C),k=e.cmov(M,k,G),X=e.cmov(K,X,G)}return{isValid:E,value:k}};if(e.ORDER%zf===Es){let u=(e.ORDER-Es)/zf,x=e.sqrt(e.neg(t));w=(C,M)=>{let k=e.sqr(M),H=e.mul(C,M);k=e.mul(k,H);let X=e.pow(k,u);X=e.mul(X,H);let E=e.mul(X,x),q=e.mul(e.sqr(X),M),W=e.eql(q,C),K=e.cmov(E,X,W);return{isValid:W,value:K}}}return w}function Ua(e,t){if(ws(e),!e.isValid(t.A)||!e.isValid(t.B)||!e.isValid(t.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let r=lp(e,t.Z);if(!e.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,s,o,a,c,l,d,h;i=e.sqr(n),i=e.mul(i,t.Z),s=e.sqr(i),s=e.add(s,i),o=e.add(s,e.ONE),o=e.mul(o,t.B),a=e.cmov(t.Z,e.neg(s),!e.eql(s,e.ZERO)),a=e.mul(a,t.A),s=e.sqr(o),l=e.sqr(a),c=e.mul(l,t.A),s=e.add(s,c),s=e.mul(s,o),l=e.mul(l,a),c=e.mul(l,t.B),s=e.add(s,c),d=e.mul(i,o);let{isValid:N,value:w}=r(s,l);h=e.mul(i,n),h=e.mul(h,w),d=e.cmov(d,o,N),h=e.cmov(h,w,N);let u=e.isOdd(n)===e.isOdd(h);return h=e.cmov(e.neg(h),h,u),d=e.div(d,a),{x:d,y:h}}}var My,Cy,jr,Mt,Tr,Es,zf,Ia=bt(()=>{Oa();ar();Ce();Ce();({bytesToNumberBE:My,hexToBytes:Cy}=gs),jr=BigInt(0),Mt=BigInt(1),Tr=BigInt(2),Es=BigInt(3),zf=BigInt(4)});function dp(e){let t=[];for(;e>vs;e>>=vs)(e&vs)===hp?t.unshift(0):(e&mn)===mn?(t.unshift(-1),e+=vs):t.unshift(1);return t}function Wf(e){let{Fp:t,Fr:r,Fp2:n,Fp6:i,Fp12:s}=e.fields,o=e.params.xNegative,a=e.params.twistType,c=Fa({n:r.ORDER,...e.G1}),l=Object.assign(c,Ta(c.ProjectivePoint,e.G1.mapToCurve,{...e.htfDefaults,...e.G1.htfDefaults})),d=Fa({n:r.ORDER,...e.G2}),h=Object.assign(d,Ta(d.ProjectivePoint,e.G2.mapToCurve,{...e.htfDefaults,...e.G2.htfDefaults})),N;if(a==="multiplicative")N=(z,F,m,D,et,lt)=>s.mul014(D,z,n.mul(F,et),n.mul(m,lt));else if(a==="divisive")N=(z,F,m,D,et,lt)=>s.mul034(D,n.mul(m,lt),n.mul(F,et),z);else throw new Error("bls: unknown twist type");let w=n.div(n.ONE,n.mul(n.ONE,Kf));function u(z,F,m,D){let et=n.sqr(m),lt=n.sqr(D),L=n.mulByB(n.mul(lt,mn)),f=n.mul(L,mn),p=n.sub(n.sub(n.sqr(n.add(m,D)),lt),et),y=n.sub(L,et),R=n.mul(n.sqr(F),mn),v=n.neg(p);return z.push([y,R,v]),F=n.mul(n.mul(n.mul(n.sub(et,f),F),m),w),m=n.sub(n.sqr(n.mul(n.add(et,f),w)),n.mul(n.sqr(L),mn)),D=n.mul(et,p),{Rx:F,Ry:m,Rz:D}}function x(z,F,m,D,et,lt){let L=n.sub(m,n.mul(lt,D)),f=n.sub(F,n.mul(et,D)),p=n.sub(n.mul(L,et),n.mul(f,lt)),y=n.neg(L),R=f;z.push([p,y,R]);let v=n.sqr(f),S=n.mul(v,f),P=n.mul(v,F),b=n.add(n.sub(S,n.mul(P,Kf)),n.mul(n.sqr(L),D));return F=n.mul(f,b),m=n.sub(n.mul(n.sub(P,b),L),n.mul(S,m)),D=n.mul(D,S),{Rx:F,Ry:m,Rz:D}}let C=dp(e.params.ateLoopSize),M=or(z=>{let F=z,{x:m,y:D}=F.toAffine(),et=m,lt=D,L=n.neg(D),f=et,p=lt,y=n.ONE,R=[];for(let v of C){let S=[];({Rx:f,Ry:p,Rz:y}=u(S,f,p,y)),v&&({Rx:f,Ry:p,Rz:y}=x(S,f,p,y,et,v===-1?L:lt)),R.push(S)}if(e.postPrecompute){let v=R[R.length-1];e.postPrecompute(f,p,y,et,lt,x.bind(null,v))}return R});function k(z,F=!1){let m=s.ONE;if(z.length){let D=z[0][0].length;for(let et=0;et<D;et++){m=s.sqr(m);for(let[lt,L,f]of z)for(let[p,y,R]of lt[et])m=N(p,y,R,m,L,f)}}return o&&(m=s.conjugate(m)),F?s.finalExponentiate(m):m}function H(z,F=!0){let m=[];l.ProjectivePoint.normalizeZ(z.map(({g1:D})=>D)),h.ProjectivePoint.normalizeZ(z.map(({g2:D})=>D));for(let{g1:D,g2:et}of z){if(D.equals(l.ProjectivePoint.ZERO)||et.equals(h.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");D.assertValidity(),et.assertValidity();let lt=D.toAffine();m.push([M(et),lt.x,lt.y])}return k(m,F)}function X(z,F,m=!0){return H([{g1:z,g2:F}],m)}let E={randomPrivateKey:()=>{let z=bs(r.ORDER);return Ea(e.randomBytes(z),r.ORDER)},calcPairingPrecomputes:M},{ShortSignature:q}=e.G1,{Signature:W}=e.G2;function K(z){return z instanceof l.ProjectivePoint?z:l.ProjectivePoint.fromHex(z)}function G(z,F){return z instanceof l.ProjectivePoint?z:l.hashToCurve(zt("point",z),F)}function tt(z){return z instanceof h.ProjectivePoint?z:W.fromHex(z)}function rt(z,F){return z instanceof h.ProjectivePoint?z:h.hashToCurve(zt("point",z),F)}function at(z){return l.ProjectivePoint.fromPrivateKey(z).toRawBytes(!0)}function g(z){return h.ProjectivePoint.fromPrivateKey(z).toRawBytes(!0)}function T(z,F,m){let D=rt(z,m);D.assertValidity();let et=D.multiply(l.normPrivateKeyToScalar(F));return z instanceof h.ProjectivePoint?et:W.toRawBytes(et)}function B(z,F,m){let D=G(z,m);D.assertValidity();let et=D.multiply(l.normPrivateKeyToScalar(F));return z instanceof l.ProjectivePoint?et:q.toRawBytes(et)}function A(z,F,m,D){let et=K(m),lt=rt(F,D),L=l.ProjectivePoint.BASE,f=tt(z),p=H([{g1:et.negate(),g2:lt},{g1:L,g2:f}]);return s.eql(p,s.ONE)}function V(z,F,m,D){let et=tt(m),lt=G(F,D),L=h.ProjectivePoint.BASE,f=K(z),p=H([{g1:lt,g2:et},{g1:f,g2:L.negate()}]);return s.eql(p,s.ONE)}function Y(z){if(!z.length)throw new Error("Expected non-empty array");let m=z.map(K).reduce((D,et)=>D.add(et),l.ProjectivePoint.ZERO);return z[0]instanceof l.ProjectivePoint?(m.assertValidity(),m):m.toRawBytes(!0)}function Q(z){if(!z.length)throw new Error("Expected non-empty array");let m=z.map(tt).reduce((D,et)=>D.add(et),h.ProjectivePoint.ZERO);return z[0]instanceof h.ProjectivePoint?(m.assertValidity(),m):W.toRawBytes(m)}function ct(z){if(!z.length)throw new Error("Expected non-empty array");let m=z.map(K).reduce((D,et)=>D.add(et),l.ProjectivePoint.ZERO);return z[0]instanceof l.ProjectivePoint?(m.assertValidity(),m):q.toRawBytes(m)}function ft(z,F,m,D){if(!F.length)throw new Error("Expected non-empty messages array");if(m.length!==F.length)throw new Error("Pubkey count should equal msg count");let et=tt(z),lt=F.map(y=>rt(y,D)),L=m.map(K),f=new Map;for(let y=0;y<L.length;y++){let R=L[y],v=lt[y],S=f.get(v);S===void 0&&(S=[],f.set(v,S)),S.push(R)}let p=[];try{for(let[y,R]of f){let v=R.reduce((S,P)=>S.add(P));p.push({g1:v,g2:y})}return p.push({g1:l.ProjectivePoint.BASE.negate(),g2:et}),s.eql(H(p),s.ONE)}catch{return!1}}return l.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:at,getPublicKeyForShortSignatures:g,sign:T,signShortSignature:B,verify:A,verifyBatch:ft,verifyShortSignature:V,aggregatePublicKeys:Y,aggregateSignatures:Q,aggregateShortSignatures:ct,millerLoopBatch:k,pairing:X,pairingBatch:H,G1:l,G2:h,Signature:W,ShortSignature:q,fields:{Fr:r,Fp:t,Fp2:n,Fp6:i,Fp12:s},params:{ateLoopSize:e.params.ateLoopSize,r:e.params.r,G1b:e.G1.b,G2b:e.G2.b},utils:E}}var hp,vs,Kf,mn,Zf=bt(()=>{ar();Ce();Sa();Ia();hp=BigInt(0),vs=BigInt(1),Kf=BigInt(2),mn=BigInt(3)});function Pa(e,t,r,n,i=1,s){let o=BigInt(s===void 0?n:s),a=r**BigInt(n),c=[];for(let l=0;l<i;l++){let d=BigInt(l+1),h=[];for(let N=0,w=yn;N<n;N++){let u=(d*w-d)/o%a;h.push(e.pow(t,u)),w*=r}c.push(h)}return c}function Jf(e,t,r){let n=t.pow(r,(e.ORDER-yn)/Xf),i=t.pow(r,(e.ORDER-yn)/cr);function s(N,w){let u=t.mul(t.frobeniusMap(N,1),n),x=t.mul(t.frobeniusMap(w,1),i);return[u,x]}let o=t.pow(r,(e.ORDER**cr-yn)/Xf),a=t.pow(r,(e.ORDER**cr-yn)/cr);if(!t.eql(a,t.neg(t.ONE)))throw new Error("psiFrobenius: PSI2_Y!==-1");function c(N,w){return[t.mul(N,o),t.neg(w)]}let l=N=>(w,u)=>{let x=u.toAffine(),C=N(x.x,x.y);return w.fromAffine({x:C[0],y:C[1]})},d=l(s),h=l(c);return{psi:s,psi2:c,G2psi:d,G2psi2:h,PSI_X:n,PSI_Y:i,PSI2_X:o,PSI2_Y:a}}function Qf(e){let{ORDER:t}=e,r=pn(t),n=r.create(e.NONRESIDUE||BigInt(-1)),i=Hf(t),s=r.div(r.ONE,cr),o=Pa(r,n,r.ORDER,2)[0],a=({c0:g,c1:T},{c0:B,c1:A})=>({c0:r.add(g,B),c1:r.add(T,A)}),c=({c0:g,c1:T},{c0:B,c1:A})=>({c0:r.sub(g,B),c1:r.sub(T,A)}),l=({c0:g,c1:T},B)=>{if(typeof B=="bigint")return{c0:r.mul(g,B),c1:r.mul(T,B)};let{c0:A,c1:V}=B,Y=r.mul(g,A),Q=r.mul(T,V),ct=r.sub(Y,Q),ft=r.sub(r.mul(r.add(g,T),r.add(A,V)),r.add(Y,Q));return{c0:ct,c1:ft}},d=({c0:g,c1:T})=>{let B=r.add(g,T),A=r.sub(g,T),V=r.add(g,g);return{c0:r.mul(B,A),c1:r.mul(V,T)}},h=g=>{if(g.length!==2)throw new Error("Invalid tuple");let T=g.map(B=>r.create(B));return{c0:T[0],c1:T[1]}},N=t*t,w=h(e.FP2_NONRESIDUE),u={ORDER:N,NONRESIDUE:w,BITS:Gr(N),BYTES:Math.ceil(Gr(N)/8),MASK:vr(Gr(N)),ZERO:{c0:r.ZERO,c1:r.ZERO},ONE:{c0:r.ONE,c1:r.ZERO},create:g=>g,isValid:({c0:g,c1:T})=>typeof g=="bigint"&&typeof T=="bigint",is0:({c0:g,c1:T})=>r.is0(g)&&r.is0(T),eql:({c0:g,c1:T},{c0:B,c1:A})=>r.eql(g,B)&&r.eql(T,A),neg:({c0:g,c1:T})=>({c0:r.neg(g),c1:r.neg(T)}),pow:(g,T)=>Ln(u,g,T),invertBatch:g=>Dn(u,g),add:a,sub:c,mul:l,sqr:d,addN:a,subN:c,mulN:l,sqrN:d,div:(g,T)=>u.mul(g,typeof T=="bigint"?r.inv(r.create(T)):u.inv(T)),inv:({c0:g,c1:T})=>{let B=r.inv(r.create(g*g+T*T));return{c0:r.mul(B,r.create(g)),c1:r.mul(B,r.create(-T))}},sqrt:g=>{if(e.Fp2sqrt)return e.Fp2sqrt(g);let{c0:T,c1:B}=g;if(r.is0(B))return r.eql(i(r,T),r.ONE)?u.create({c0:r.sqrt(T),c1:r.ZERO}):u.create({c0:r.ZERO,c1:r.sqrt(r.div(T,n))});let A=r.sqrt(r.sub(r.sqr(T),r.mul(r.sqr(B),n))),V=r.mul(r.add(A,T),s),Y=i(r,V);!r.is0(Y)&&!r.eql(Y,r.ONE)&&(V=r.sub(V,A));let Q=r.sqrt(V),ct=u.create({c0:Q,c1:r.div(r.mul(B,s),Q)});if(!u.eql(u.sqr(ct),g))throw new Error("Cannot find square root");let ft=ct,z=u.neg(ft),{re:F,im:m}=u.reim(ft),{re:D,im:et}=u.reim(z);return m>et||m===et&&F>D?ft:z},isOdd:g=>{let{re:T,im:B}=u.reim(g),A=T%cr,V=T===pp,Y=B%cr;return BigInt(A||V&&Y)==yn},fromBytes(g){if(g.length!==u.BYTES)throw new Error(`fromBytes wrong length=${g.length}`);return{c0:r.fromBytes(g.subarray(0,r.BYTES)),c1:r.fromBytes(g.subarray(r.BYTES))}},toBytes:({c0:g,c1:T})=>Tt(r.toBytes(g),r.toBytes(T)),cmov:({c0:g,c1:T},{c0:B,c1:A},V)=>({c0:r.cmov(g,B,V),c1:r.cmov(T,A,V)}),reim:({c0:g,c1:T})=>({re:g,im:T}),mulByNonresidue:({c0:g,c1:T})=>u.mul({c0:g,c1:T},w),mulByB:e.Fp2mulByB,fromBigTuple:h,frobeniusMap:({c0:g,c1:T},B)=>({c0:g,c1:r.mul(T,o[B%2])})},x=({c0:g,c1:T,c2:B},{c0:A,c1:V,c2:Y})=>({c0:u.add(g,A),c1:u.add(T,V),c2:u.add(B,Y)}),C=({c0:g,c1:T,c2:B},{c0:A,c1:V,c2:Y})=>({c0:u.sub(g,A),c1:u.sub(T,V),c2:u.sub(B,Y)}),M=({c0:g,c1:T,c2:B},A)=>{if(typeof A=="bigint")return{c0:u.mul(g,A),c1:u.mul(T,A),c2:u.mul(B,A)};let{c0:V,c1:Y,c2:Q}=A,ct=u.mul(g,V),ft=u.mul(T,Y),z=u.mul(B,Q);return{c0:u.add(ct,u.mulByNonresidue(u.sub(u.mul(u.add(T,B),u.add(Y,Q)),u.add(ft,z)))),c1:u.add(u.sub(u.mul(u.add(g,T),u.add(V,Y)),u.add(ct,ft)),u.mulByNonresidue(z)),c2:u.sub(u.add(ft,u.mul(u.add(g,B),u.add(V,Q))),u.add(ct,z))}},k=({c0:g,c1:T,c2:B})=>{let A=u.sqr(g),V=u.mul(u.mul(g,T),cr),Y=u.mul(u.mul(T,B),cr),Q=u.sqr(B);return{c0:u.add(u.mulByNonresidue(Y),A),c1:u.add(u.mulByNonresidue(Q),V),c2:u.sub(u.sub(u.add(u.add(V,u.sqr(u.add(u.sub(g,T),B))),Y),A),Q)}},[H,X]=Pa(u,w,r.ORDER,6,2,3),E={ORDER:u.ORDER,BITS:3*u.BITS,BYTES:3*u.BYTES,MASK:vr(3*u.BITS),ZERO:{c0:u.ZERO,c1:u.ZERO,c2:u.ZERO},ONE:{c0:u.ONE,c1:u.ZERO,c2:u.ZERO},create:g=>g,isValid:({c0:g,c1:T,c2:B})=>u.isValid(g)&&u.isValid(T)&&u.isValid(B),is0:({c0:g,c1:T,c2:B})=>u.is0(g)&&u.is0(T)&&u.is0(B),neg:({c0:g,c1:T,c2:B})=>({c0:u.neg(g),c1:u.neg(T),c2:u.neg(B)}),eql:({c0:g,c1:T,c2:B},{c0:A,c1:V,c2:Y})=>u.eql(g,A)&&u.eql(T,V)&&u.eql(B,Y),sqrt:ys,div:(g,T)=>E.mul(g,typeof T=="bigint"?r.inv(r.create(T)):E.inv(T)),pow:(g,T)=>Ln(E,g,T),invertBatch:g=>Dn(E,g),add:x,sub:C,mul:M,sqr:k,addN:x,subN:C,mulN:M,sqrN:k,inv:({c0:g,c1:T,c2:B})=>{let A=u.sub(u.sqr(g),u.mulByNonresidue(u.mul(B,T))),V=u.sub(u.mulByNonresidue(u.sqr(B)),u.mul(g,T)),Y=u.sub(u.sqr(T),u.mul(g,B)),Q=u.inv(u.add(u.mulByNonresidue(u.add(u.mul(B,V),u.mul(T,Y))),u.mul(g,A)));return{c0:u.mul(Q,A),c1:u.mul(Q,V),c2:u.mul(Q,Y)}},fromBytes:g=>{if(g.length!==E.BYTES)throw new Error(`fromBytes wrong length=${g.length}`);return{c0:u.fromBytes(g.subarray(0,u.BYTES)),c1:u.fromBytes(g.subarray(u.BYTES,2*u.BYTES)),c2:u.fromBytes(g.subarray(2*u.BYTES))}},toBytes:({c0:g,c1:T,c2:B})=>Tt(u.toBytes(g),u.toBytes(T),u.toBytes(B)),cmov:({c0:g,c1:T,c2:B},{c0:A,c1:V,c2:Y},Q)=>({c0:u.cmov(g,A,Q),c1:u.cmov(T,V,Q),c2:u.cmov(B,Y,Q)}),fromBigSix:g=>{if(!Array.isArray(g)||g.length!==6)throw new Error("Invalid Fp6 usage");return{c0:u.fromBigTuple(g.slice(0,2)),c1:u.fromBigTuple(g.slice(2,4)),c2:u.fromBigTuple(g.slice(4,6))}},frobeniusMap:({c0:g,c1:T,c2:B},A)=>({c0:u.frobeniusMap(g,A),c1:u.mul(u.frobeniusMap(T,A),H[A%6]),c2:u.mul(u.frobeniusMap(B,A),X[A%6])}),mulByFp2:({c0:g,c1:T,c2:B},A)=>({c0:u.mul(g,A),c1:u.mul(T,A),c2:u.mul(B,A)}),mulByNonresidue:({c0:g,c1:T,c2:B})=>({c0:u.mulByNonresidue(B),c1:g,c2:T}),mul1:({c0:g,c1:T,c2:B},A)=>({c0:u.mulByNonresidue(u.mul(B,A)),c1:u.mul(g,A),c2:u.mul(T,A)}),mul01({c0:g,c1:T,c2:B},A,V){let Y=u.mul(g,A),Q=u.mul(T,V);return{c0:u.add(u.mulByNonresidue(u.sub(u.mul(u.add(T,B),V),Q)),Y),c1:u.sub(u.sub(u.mul(u.add(A,V),u.add(g,T)),Y),Q),c2:u.add(u.sub(u.mul(u.add(g,B),A),Y),Q)}}},q=Pa(u,w,r.ORDER,12,1,6)[0],W=({c0:g,c1:T},{c0:B,c1:A})=>({c0:E.add(g,B),c1:E.add(T,A)}),K=({c0:g,c1:T},{c0:B,c1:A})=>({c0:E.sub(g,B),c1:E.sub(T,A)}),G=({c0:g,c1:T},B)=>{if(typeof B=="bigint")return{c0:E.mul(g,B),c1:E.mul(T,B)};let{c0:A,c1:V}=B,Y=E.mul(g,A),Q=E.mul(T,V);return{c0:E.add(Y,E.mulByNonresidue(Q)),c1:E.sub(E.mul(E.add(g,T),E.add(A,V)),E.add(Y,Q))}},tt=({c0:g,c1:T})=>{let B=E.mul(g,T);return{c0:E.sub(E.sub(E.mul(E.add(E.mulByNonresidue(T),g),E.add(g,T)),B),E.mulByNonresidue(B)),c1:E.add(B,B)}};function rt(g,T){let B=u.sqr(g),A=u.sqr(T);return{first:u.add(u.mulByNonresidue(A),B),second:u.sub(u.sub(u.sqr(u.add(g,T)),B),A)}}let at={ORDER:u.ORDER,BITS:2*u.BITS,BYTES:2*u.BYTES,MASK:vr(2*u.BITS),ZERO:{c0:E.ZERO,c1:E.ZERO},ONE:{c0:E.ONE,c1:E.ZERO},create:g=>g,isValid:({c0:g,c1:T})=>E.isValid(g)&&E.isValid(T),is0:({c0:g,c1:T})=>E.is0(g)&&E.is0(T),neg:({c0:g,c1:T})=>({c0:E.neg(g),c1:E.neg(T)}),eql:({c0:g,c1:T},{c0:B,c1:A})=>E.eql(g,B)&&E.eql(T,A),sqrt:ys,inv:({c0:g,c1:T})=>{let B=E.inv(E.sub(E.sqr(g),E.mulByNonresidue(E.sqr(T))));return{c0:E.mul(g,B),c1:E.neg(E.mul(T,B))}},div:(g,T)=>at.mul(g,typeof T=="bigint"?r.inv(r.create(T)):at.inv(T)),pow:(g,T)=>Ln(at,g,T),invertBatch:g=>Dn(at,g),add:W,sub:K,mul:G,sqr:tt,addN:W,subN:K,mulN:G,sqrN:tt,fromBytes:g=>{if(g.length!==at.BYTES)throw new Error(`fromBytes wrong length=${g.length}`);return{c0:E.fromBytes(g.subarray(0,E.BYTES)),c1:E.fromBytes(g.subarray(E.BYTES))}},toBytes:({c0:g,c1:T})=>Tt(E.toBytes(g),E.toBytes(T)),cmov:({c0:g,c1:T},{c0:B,c1:A},V)=>({c0:E.cmov(g,B,V),c1:E.cmov(T,A,V)}),fromBigTwelve:g=>({c0:E.fromBigSix(g.slice(0,6)),c1:E.fromBigSix(g.slice(6,12))}),frobeniusMap(g,T){let{c0:B,c1:A,c2:V}=E.frobeniusMap(g.c1,T),Y=q[T%12];return{c0:E.frobeniusMap(g.c0,T),c1:E.create({c0:u.mul(B,Y),c1:u.mul(A,Y),c2:u.mul(V,Y)})}},mulByFp2:({c0:g,c1:T},B)=>({c0:E.mulByFp2(g,B),c1:E.mulByFp2(T,B)}),conjugate:({c0:g,c1:T})=>({c0:g,c1:E.neg(T)}),mul014:({c0:g,c1:T},B,A,V)=>{let Y=E.mul01(g,B,A),Q=E.mul1(T,V);return{c0:E.add(E.mulByNonresidue(Q),Y),c1:E.sub(E.sub(E.mul01(E.add(T,g),B,u.add(A,V)),Y),Q)}},mul034:({c0:g,c1:T},B,A,V)=>{let Y=E.create({c0:u.mul(g.c0,B),c1:u.mul(g.c1,B),c2:u.mul(g.c2,B)}),Q=E.mul01(T,A,V),ct=E.mul01(E.add(g,T),u.add(B,A),V);return{c0:E.add(E.mulByNonresidue(Q),Y),c1:E.sub(ct,E.add(Y,Q))}},_cyclotomicSquare:e.Fp12cyclotomicSquare,_cyclotomicExp:e.Fp12cyclotomicExp,finalExponentiate:e.Fp12finalExponentiate};return{Fp:r,Fp2:u,Fp6:E,Fp4Square:rt,Fp12:at}}var pp,yn,cr,Xf,Lf=bt(()=>{ar();Ce();pp=BigInt(0),yn=BigInt(1),cr=BigInt(2),Xf=BigInt(3)});function As(e){e=e.slice();let t=e[0]&224,r=!!(t>>7&1),n=!!(t>>6&1),i=!!(t>>5&1);return e[0]&=31,{compressed:r,infinity:n,sort:i,value:e}}function ei(e,t){if(e[0]&224)throw new Error("setMask: non-empty mask");return t.compressed&&(e[0]|=128),t.infinity&&(e[0]|=64),t.sort&&(e[0]|=32),e}function e0(e){e.assertValidity();let t=e.equals(me.G1.ProjectivePoint.ZERO),{x:r,y:n}=e.toAffine();if(t)return Ss.slice();let i=it.ORDER,s=!!(n*Lt/i);return ei(kt(r,it.BYTES),{compressed:!0,sort:s})}function r0(e){e.assertValidity();let t=it.BYTES;if(e.equals(me.G2.ProjectivePoint.ZERO))return Tt(Ss,kt(se,t));let{x:r,y:n}=e.toAffine(),{re:i,im:s}=ot.reim(r),{re:o,im:a}=ot.reim(n),l=!!((a>se?a*Lt:o*Lt)/it.ORDER&Ts),d=i;return Tt(ei(kt(s,t),{sort:l,compressed:!0}),kt(d,t))}var se,Ts,Lt,Bs,ti,Sr,mp,it,ot,Ca,ka,gt,Df,yp,gp,wp,bp,t0,xp,Ma,Ss,me,n0=bt(()=>{Bi();Lr();Zf();ar();Ce();Sa();Ia();Lf();se=BigInt(0),Ts=BigInt(1),Lt=BigInt(2),Bs=BigInt(3),ti=BigInt(4),Sr=BigInt("0xd201000000010000"),mp=Gr(Sr),{Fp:it,Fp2:ot,Fp6:Ca,Fp4Square:ka,Fp12:gt}=Qf({ORDER:BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),FP2_NONRESIDUE:[Ts,Ts],Fp2mulByB:({c0:e,c1:t})=>{let r=it.mul(e,ti),n=it.mul(t,ti);return{c0:it.sub(r,n),c1:it.add(r,n)}},Fp12cyclotomicSquare:({c0:e,c1:t})=>{let{c0:r,c1:n,c2:i}=e,{c0:s,c1:o,c2:a}=t,{first:c,second:l}=ka(r,o),{first:d,second:h}=ka(s,i),{first:N,second:w}=ka(n,a),u=ot.mulByNonresidue(w);return{c0:Ca.create({c0:ot.add(ot.mul(ot.sub(c,r),Lt),c),c1:ot.add(ot.mul(ot.sub(d,n),Lt),d),c2:ot.add(ot.mul(ot.sub(N,i),Lt),N)}),c1:Ca.create({c0:ot.add(ot.mul(ot.add(u,s),Lt),u),c1:ot.add(ot.mul(ot.add(l,o),Lt),l),c2:ot.add(ot.mul(ot.add(h,a),Lt),h)})}},Fp12cyclotomicExp(e,t){let r=gt.ONE;for(let n=mp-1;n>=0;n--)r=gt._cyclotomicSquare(r),wa(t,n)&&(r=gt.mul(r,e));return r},Fp12finalExponentiate:e=>{let t=Sr,r=gt.div(gt.frobeniusMap(e,6),e),n=gt.mul(gt.frobeniusMap(r,2),r),i=gt.conjugate(gt._cyclotomicExp(n,t)),s=gt.mul(gt.conjugate(gt._cyclotomicSquare(n)),i),o=gt.conjugate(gt._cyclotomicExp(s,t)),a=gt.conjugate(gt._cyclotomicExp(o,t)),c=gt.mul(gt.conjugate(gt._cyclotomicExp(a,t)),gt._cyclotomicSquare(i)),l=gt.conjugate(gt._cyclotomicExp(c,t)),d=gt.frobeniusMap(gt.mul(i,a),2),h=gt.frobeniusMap(gt.mul(o,n),3),N=gt.frobeniusMap(gt.mul(c,gt.conjugate(n)),1),w=gt.mul(gt.mul(l,gt.conjugate(s)),n);return gt.mul(gt.mul(gt.mul(d,h),N),w)}}),Df=pn(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),yp=Aa(ot,[[["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(e=>e.map(t=>ot.fromBigTuple(t.map(BigInt))))),gp=Aa(it,[["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(e=>e.map(t=>BigInt(t)))),wp=Ua(ot,{A:ot.create({c0:it.create(se),c1:it.create(BigInt(240))}),B:ot.create({c0:it.create(BigInt(1012)),c1:it.create(BigInt(1012))}),Z:ot.create({c0:it.create(BigInt(-2)),c1:it.create(BigInt(-1))})}),bp=Ua(it,{A:it.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:it.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:it.create(BigInt(11))}),{G2psi:t0,G2psi2:xp}=Jf(it,ot,ot.div(ot.ONE,ot.NONRESIDUE)),Ma=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:it.ORDER,m:2,k:128,expand:"xmd",hash:Rn}),Ss=ei(it.toBytes(se),{infinity:!0,compressed:!0});me=Wf({fields:{Fp:it,Fp2:ot,Fp6:Ca,Fp12:gt,Fr:Df},G1:{Fp:it,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:it.ZERO,b:ti,htfDefaults:{...Ma,m:1,DST:"BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_"},wrapPrivateKey:!0,allowInfinityPoint:!0,isTorsionFree:(e,t)=>{let r=BigInt("0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),n=new e(it.mul(t.px,r),t.py,t.pz);return t.multiplyUnsafe(Sr).negate().multiplyUnsafe(Sr).equals(n)},clearCofactor:(e,t)=>t.multiplyUnsafe(Sr).add(t),mapToCurve:e=>{let{x:t,y:r}=bp(it.create(e[0]));return gp(t,r)},fromBytes:e=>{let{compressed:t,infinity:r,sort:n,value:i}=As(e);if(i.length===48&&t){let s=it.ORDER,o=te(i),a=it.create(o&it.MASK);if(r){if(a!==se)throw new Error("G1: non-empty compressed point at infinity");return{x:se,y:se}}let c=it.add(it.pow(a,Bs),it.create(me.params.G1b)),l=it.sqrt(c);if(!l)throw new Error("Invalid compressed G1 point");return l*Lt/s!==BigInt(n)&&(l=it.neg(l)),{x:it.create(a),y:it.create(l)}}else if(i.length===96&&!t){let s=te(i.subarray(0,it.BYTES)),o=te(i.subarray(it.BYTES));if(r){if(s!==se||o!==se)throw new Error("G1: non-empty point at infinity");return me.G1.ProjectivePoint.ZERO.toAffine()}return{x:it.create(s),y:it.create(o)}}else throw new Error("Invalid point G1, expected 48/96 bytes")},toBytes:(e,t,r)=>{let n=t.equals(e.ZERO),{x:i,y:s}=t.toAffine();if(r){if(n)return Ss.slice();let o=it.ORDER,a=!!(s*Lt/o);return ei(kt(i,it.BYTES),{compressed:!0,sort:a})}else return n?Tt(new Uint8Array([64]),new Uint8Array(2*it.BYTES-1)):Tt(kt(i,it.BYTES),kt(s,it.BYTES))},ShortSignature:{fromHex(e){let{infinity:t,sort:r,value:n}=As(zt("signatureHex",e,48)),i=it.ORDER,s=te(n);if(t)return me.G1.ProjectivePoint.ZERO;let o=it.create(s&it.MASK),a=it.add(it.pow(o,Bs),it.create(me.params.G1b)),c=it.sqrt(a);if(!c)throw new Error("Invalid compressed G1 point");let l=BigInt(r);c*Lt/i!==l&&(c=it.neg(c));let d=me.G1.ProjectivePoint.fromAffine({x:o,y:c});return d.assertValidity(),d},toRawBytes(e){return e0(e)},toHex(e){return Pe(e0(e))}}},G2:{Fp:ot,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),Gx:ot.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:ot.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")]),a:ot.ZERO,b:ot.fromBigTuple([ti,ti]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...Ma},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:e=>{let{x:t,y:r}=wp(ot.fromBigTuple(e));return yp(t,r)},isTorsionFree:(e,t)=>t.multiplyUnsafe(Sr).negate().equals(t0(e,t)),clearCofactor:(e,t)=>{let r=Sr,n=t.multiplyUnsafe(r).negate(),i=t0(e,t),s=t.double();return s=xp(e,s),s=s.subtract(i),i=n.add(i),i=i.multiplyUnsafe(r).negate(),s=s.add(i),s=s.subtract(n),s.subtract(t)},fromBytes:e=>{let{compressed:t,infinity:r,sort:n,value:i}=As(e);if(!t&&!r&&n||!t&&r&&n||n&&r&&t)throw new Error("Invalid encoding flag: "+(e[0]&224));let s=it.BYTES,o=(a,c,l)=>te(a.slice(c,l));if(i.length===96&&t){let a=me.params.G2b,c=it.ORDER;if(r){if(i.reduce((x,C)=>x!==0?C+1:C,0)>0)throw new Error("Invalid compressed G2 point");return{x:ot.ZERO,y:ot.ZERO}}let l=o(i,0,s),d=o(i,s,2*s),h=ot.create({c0:it.create(d),c1:it.create(l)}),N=ot.add(ot.pow(h,Bs),a),w=ot.sqrt(N),u=w.c1===se?w.c0*Lt/c:w.c1*Lt/c?Ts:se;return w=n&&u>0?w:ot.neg(w),{x:h,y:w}}else if(i.length===192&&!t){if(r){if(i.reduce((h,N)=>h!==0?N+1:N,0)>0)throw new Error("Invalid uncompressed G2 point");return{x:ot.ZERO,y:ot.ZERO}}let a=o(i,0,s),c=o(i,s,2*s),l=o(i,2*s,3*s),d=o(i,3*s,4*s);return{x:ot.fromBigTuple([c,a]),y:ot.fromBigTuple([d,l])}}else throw new Error("Invalid point G2, expected 96/192 bytes")},toBytes:(e,t,r)=>{let{BYTES:n,ORDER:i}=it,s=t.equals(e.ZERO),{x:o,y:a}=t.toAffine();if(r){if(s)return Tt(Ss,kt(se,n));let c=!!(a.c1===se?a.c0*Lt/i:a.c1*Lt/i);return Tt(ei(kt(o.c1,n),{compressed:!0,sort:c}),kt(o.c0,n))}else{if(s)return Tt(new Uint8Array([64]),new Uint8Array(4*n-1));let{re:c,im:l}=ot.reim(o),{re:d,im:h}=ot.reim(a);return Tt(kt(l,n),kt(c,n),kt(h,n),kt(d,n))}},Signature:{fromHex(e){let{infinity:t,sort:r,value:n}=As(zt("signatureHex",e)),i=it.ORDER,s=n.length/2;if(s!==48&&s!==96)throw new Error("Invalid compressed signature length, must be 96 or 192");let o=te(n.slice(0,s)),a=te(n.slice(s));if(t)return me.G2.ProjectivePoint.ZERO;let c=it.create(o&it.MASK),l=it.create(a),d=ot.create({c0:l,c1:c}),h=ot.add(ot.pow(d,Bs),me.params.G2b),N=ot.sqrt(h);if(!N)throw new Error("Failed to find a square root");let{re:w,im:u}=ot.reim(N),x=BigInt(r),C=u>se&&u*Lt/i!==x,M=u===se&&w*Lt/i!==x;(C||M)&&(N=ot.neg(N));let k=me.G2.ProjectivePoint.fromAffine({x:d,y:N});return k.assertValidity(),k},toRawBytes(e){return r0(e)},toHex(e){return Pe(r0(e))}}},params:{ateLoopSize:Sr,r:Df.ORDER,xNegative:!0,twistType:"multiplicative"},htfDefaults:Ma,hash:Rn,randomBytes:Ei})});function i0(e,t,r){let n=typeof e=="string"?e:Yt(e),i=typeof t=="string"?t:Yt(t),s=typeof r=="string"?r:Yt(r);return me.verifyShortSignature(i,s,n)}var qa=bt(()=>{n0();pe()});var $a,gn,Ns=bt(()=>{Mn();$a=e=>Gt(new Ne(e)),gn=e=>{let t=$a(e);return new Date(Number(t)/1e6)}});function Ep(e,t){let r=new Uint8Array(e),n=new Uint8Array(t);for(let i=0;i<r.length;i++)if(r[i]>n[i])return!0;return!1}function Bp(e){let t=ri.byteLength+vp;if(e.byteLength!==t)throw new TypeError(`BLS DER-encoded public key must be ${t} bytes long`);let r=e.slice(0,ri.byteLength);if(!Gn(r,ri))throw new TypeError(`BLS DER-encoded public key is invalid. Expect the following prefix: ${ri}, but get ${r}`);return e.slice(ri.byteLength)}function fr(e){if(e.status===Ct.Found){if(e.value instanceof ArrayBuffer)return e.value;if(e.value instanceof Uint8Array)return e.value.buffer}}async function Rs(e){switch(e[0]){case ge.Empty:return Be(ni("ic-hashtree-empty"));case ge.Pruned:return e[1];case ge.Leaf:return Be(ie(ni("ic-hashtree-leaf"),e[1]));case ge.Labeled:return Be(ie(ni("ic-hashtree-labeled"),e[1],await Rs(e[2])));case ge.Fork:return Be(ie(ni("ic-hashtree-fork"),await Rs(e[1]),await Rs(e[2])));default:throw new Error("unreachable")}}function ni(e){let t=new Uint8Array([e.length]),r=new TextEncoder().encode(e);return ie(t,r)}function Nr(e,t){if(e.length===0)switch(t[0]){case ge.Leaf:{if(!t[1])throw new Error("Invalid tree structure for leaf");return t[1]instanceof ArrayBuffer?{status:Ct.Found,value:t[1]}:t[1]instanceof Uint8Array?{status:Ct.Found,value:t[1].buffer}:{status:Ct.Found,value:t[1]}}default:return{status:Ct.Found,value:t}}let r=typeof e[0]=="string"?new TextEncoder().encode(e[0]):e[0],n=Os(r,t);switch(n.status){case Ct.Found:return Nr(e.slice(1),n.value);case ur.Greater:case ur.Less:return{status:Ct.Absent};default:return n}}function Fs(e){switch(e[0]){case ge.Empty:return[];case ge.Fork:return Fs(e[1]).concat(Fs(e[2]));default:return[e]}}function Os(e,t){switch(t[0]){case ge.Labeled:return Ep(e,t[1])?{status:ur.Greater}:Gn(e,t[1])?{status:Ct.Found,value:t[2]}:{status:ur.Less};case ge.Fork:let r=Os(e,t[1]);switch(r.status){case ur.Greater:{let n=Os(e,t[2]);return n.status===ur.Less?{status:Ct.Absent}:n}case Ct.Unknown:{let n=Os(e,t[2]);return n.status===ur.Less?{status:Ct.Unknown}:n}default:return r}case ge.Pruned:return{status:Ct.Unknown};default:return{status:Ct.Absent}}}function Va(e){let{canisterId:t,subnetId:r,tree:n}=e,i=Nr(["subnet",r.toUint8Array(),"canister_ranges"],n);if(i.status!==Ct.Found||!(i.value instanceof ArrayBuffer))throw new Error(`Could not find canister ranges for subnet ${r}`);return Ae(i.value).map(c=>[ht.fromUint8Array(c[0]),ht.fromUint8Array(c[1])]).some(c=>c[0].ltEq(t)&&c[1].gtEq(t))}var ye,ge,wn,ri,vp,Ct,ur,ii=bt(()=>{Kn();sn();Yn();pe();xe();qa();Ns();ye=class extends Ht{constructor(t){super(`Invalid certificate: ${t}`)}};(function(e){e[e.Empty=0]="Empty",e[e.Fork=1]="Fork",e[e.Labeled=2]="Labeled",e[e.Leaf=3]="Leaf",e[e.Pruned=4]="Pruned"})(ge||(ge={}));wn=class e{constructor(t,r,n,i,s=5){this._rootKey=r,this._canisterId=n,this._blsVerify=i,this._maxAgeInMinutes=s,this.cert=Ae(new Uint8Array(t))}static async create(t){let r=e.createUnverified(t);return await r.verify(),r}static createUnverified(t){let r=t.blsVerify;return r||(r=i0),new e(t.certificate,t.rootKey,t.canisterId,r,t.maxAgeInMinutes)}lookup(t){return Nr(t,this.cert.tree)}lookup_label(t){return this.lookup([t])}async verify(){let t=await Rs(this.cert.tree),r=await this._checkDelegationAndGetKey(this.cert.delegation),n=this.cert.signature,i=Bp(r),s=ie(ni("ic-state-root"),t),o=!1,a=fr(this.lookup(["time"]));if(!a)throw new ye("Certificate does not contain a time");let c=5*60*1e3,l=this._maxAgeInMinutes*60*1e3,d=Date.now(),h=d-l,N=d+c,w=gn(a);if(w.getTime()<h)throw new ye(`Certificate is signed more than ${this._maxAgeInMinutes} minutes in the past. Certificate time: `+w.toISOString()+" Current time: "+new Date(d).toISOString());if(w.getTime()>N)throw new ye("Certificate is signed more than 5 minutes in the future. Certificate time: "+w.toISOString()+" Current time: "+new Date(d).toISOString());try{o=await this._blsVerify(new Uint8Array(i),new Uint8Array(n),new Uint8Array(s))}catch{o=!1}if(!o)throw new ye("Signature verification failed")}async _checkDelegationAndGetKey(t){if(!t)return this._rootKey;let r=await e.createUnverified({certificate:t.certificate,rootKey:this._rootKey,canisterId:this._canisterId,blsVerify:this._blsVerify,maxAgeInMinutes:1/0});if(r.cert.delegation)throw new ye("Delegation certificates cannot be nested");if(await r.verify(),!Va({canisterId:this._canisterId,subnetId:ht.fromUint8Array(new Uint8Array(t.subnet_id)),tree:r.cert.tree}))throw new ye(`Canister ${this._canisterId} not in range of delegations for subnet 0x${Yt(t.subnet_id)}`);let i=fr(r.lookup(["subnet",t.subnet_id,"public_key"]));if(!i)throw new Error(`Could not find subnet key for subnet 0x${Yt(t.subnet_id)}`);return i}},ri=Cr("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"),vp=96;(function(e){e.Unknown="unknown",e.Absent="absent",e.Found="found"})(Ct||(Ct={}));(function(e){e.Less="less",e.Greater="greater"})(ur||(ur={}))});var Is={};Sn(Is,{CustomPath:()=>Ha,encodePath:()=>Ga,fetchNodeKeys:()=>o0,request:()=>Us});var Ha,Us,o0,Ga,s0,a0,Ap,Tp,si=bt(()=>{xe();sn();ii();pe();Kn();Ns();Ha=class{constructor(t,r,n){this.key=t,this.path=r,this.decodeStrategy=n}},Us=async e=>{let{agent:t,paths:r}=e,n=ht.from(e.canisterId),i=[...new Set(r)],s=i.map(c=>Ga(c,n)),o=new Map,a=i.map((c,l)=>(async()=>{var d;try{let h=await t.readState(n,{paths:[s[l]]}),N=await wn.create({certificate:h.certificate,rootKey:t.rootKey,canisterId:n}),w=(C,M)=>{if(M==="subnet"){let k=o0(h.certificate,n,t.rootKey);return{path:M,data:k}}else return{path:M,data:fr(C.lookup(Ga(M,n)))}},{path:u,data:x}=w(N,i[l]);if(!x)console.warn(`Expected to find result for path ${u}, but instead found nothing.`),typeof u=="string"?o.set(u,null):o.set(u.key,null);else switch(u){case"time":{o.set(u,gn(x));break}case"controllers":{o.set(u,Tp(x));break}case"module_hash":{o.set(u,s0(x));break}case"subnet":{o.set(u,x);break}case"candid":{o.set(u,new TextDecoder().decode(x));break}default:if(typeof u!="string"&&"key"in u&&"path"in u)switch(u.decodeStrategy){case"raw":o.set(u.key,x);break;case"leb128":{o.set(u.key,$a(x));break}case"cbor":{o.set(u.key,a0(x));break}case"hex":{o.set(u.key,s0(x));break}case"utf-8":o.set(u.key,Ap(x))}}}catch(h){if(!((d=h?.message)===null||d===void 0)&&d.includes("Invalid certificate"))throw new Ht(h.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(h),console.groupEnd()}})());return await Promise.all(a),o},o0=(e,t,r)=>{if(!t._isPrincipal)throw new Error("Invalid canisterId");let n=Ae(new Uint8Array(e)),i=n.tree,s=n.delegation,o;if(s&&s.subnet_id?o=ht.fromUint8Array(new Uint8Array(s.subnet_id)):!s&&typeof r<"u"?(o=ht.selfAuthenticating(new Uint8Array(r)),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}):(o=ht.selfAuthenticating(ht.fromText("tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe").toUint8Array()),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}),!Va({canisterId:t,subnetId:o,tree:i}))throw new Error("Canister not in range");let c=Nr(["subnet",s.subnet_id,"node"],i);if(c.status!==Ct.Found)throw new Error("Node not found");if(c.value instanceof ArrayBuffer)throw new Error("Invalid node tree");let l=Fs(c.value),d=new Map;return l.forEach(h=>{let N=ht.from(new Uint8Array(h[1])).toText(),w=Nr(["public_key"],h[2]);if(w.status!==Ct.Found)throw new Error("Public key not found");let u=w.value;if(u.byteLength!==44)throw new Error("Invalid public key length");d.set(N,u)}),{subnetId:ht.fromUint8Array(new Uint8Array(s.subnet_id)).toText(),nodeKeys:d}},Ga=(e,t)=>{let r=new TextEncoder,n=s=>new DataView(r.encode(s).buffer).buffer,i=new DataView(t.toUint8Array().buffer).buffer;switch(e){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 e&&"path"in e)if(typeof e.path=="string"||e.path instanceof ArrayBuffer){let s=e.path,o=typeof s=="string"?n(s):s;return[n("canister"),i,n("metadata"),o]}else return e.path}throw new Error(`An unexpeected error was encountered while encoding your path for canister status. Please ensure that your path, ${e} was formatted correctly.`)},s0=e=>Yt(e),a0=e=>Ae(e),Ap=e=>new TextDecoder().decode(e),Tp=e=>a0(e).map(r=>ht.fromUint8Array(new Uint8Array(r)))});xe();xe();var fo=(e,t)=>{let r;return(...n)=>{let i=()=>e(...n);r&&clearTimeout(r),r=setTimeout(i,t!==void 0&&t>0?t:300)}},Ur=e=>e==null,pr=e=>!Ur(e),Fl=class extends Error{},lo=(e,t)=>{if(Ur(e))throw new Fl(t)};var Ul=" 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",Il=/bot|spider|crawl|http|lighthouse/i,On;function Pl(){if(On instanceof RegExp)return On;try{On=new RegExp(Ul,"i")}catch{On=Il}return On}function vc(e){return!!e&&Pl().test(e)}var Bc=({IDL:e})=>{let t=e.Record({controllers:e.Vec(e.Principal)}),r=e.Variant({Write:e.Null,Admin:e.Null}),n=e.Record({updated_at:e.Nat64,metadata:e.Vec(e.Tuple(e.Text,e.Text)),created_at:e.Nat64,scope:r,expires_at:e.Opt(e.Nat64)}),i=e.Record({version:e.Opt(e.Nat64)}),s=e.Record({cycles:e.Nat,destination_id:e.Principal}),o=e.Record({to:e.Opt(e.Nat64),from:e.Opt(e.Nat64),satellite_id:e.Opt(e.Principal)}),a=e.Record({key:e.Text,collected_at:e.Nat64}),c=e.Record({inner_height:e.Nat16,inner_width:e.Nat16}),l=e.Record({title:e.Text,updated_at:e.Nat64,referrer:e.Opt(e.Text),time_zone:e.Text,session_id:e.Text,href:e.Text,created_at:e.Nat64,satellite_id:e.Principal,device:c,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),d=e.Record({safari:e.Float64,opera:e.Float64,others:e.Float64,firefox:e.Float64,chrome:e.Float64}),h=e.Record({desktop:e.Float64,others:e.Float64,mobile:e.Float64}),N=e.Record({browsers:d,devices:h}),w=e.Record({day:e.Nat8,month:e.Nat8,year:e.Int32}),u=e.Record({bounce_rate:e.Float64,average_page_views_per_session:e.Float64,daily_total_page_views:e.Vec(e.Tuple(w,e.Nat32)),total_page_views:e.Nat32,unique_page_views:e.Nat64,unique_sessions:e.Nat64}),x=e.Record({referrers:e.Vec(e.Tuple(e.Text,e.Nat32)),pages:e.Vec(e.Tuple(e.Text,e.Nat32))}),C=e.Variant({Navigate:e.Null,Restore:e.Null,Reload:e.Null,BackForward:e.Null,BackForwardCache:e.Null,Prerender:e.Null}),M=e.Record({id:e.Text,value:e.Float64,navigation_type:e.Opt(C),delta:e.Float64}),k=e.Variant({WebVitalsMetric:M}),H=e.Variant({CLS:e.Null,FCP:e.Null,INP:e.Null,LCP:e.Null,TTFB:e.Null}),X=e.Record({updated_at:e.Nat64,session_id:e.Text,data:k,href:e.Text,metric_name:H,created_at:e.Nat64,satellite_id:e.Principal,version:e.Opt(e.Nat64)}),E=e.Record({cls:e.Opt(e.Float64),fcp:e.Opt(e.Float64),inp:e.Opt(e.Float64),lcp:e.Opt(e.Float64),ttfb:e.Opt(e.Float64)}),q=e.Record({overall:E,pages:e.Vec(e.Tuple(e.Text,E))}),W=e.Record({updated_at:e.Nat64,session_id:e.Text,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),name:e.Text,created_at:e.Nat64,satellite_id:e.Principal,version:e.Opt(e.Nat64)}),K=e.Record({total:e.Vec(e.Tuple(e.Text,e.Nat32))}),G=e.Record({performance_metrics:e.Bool,track_events:e.Bool,page_views:e.Bool}),tt=e.Record({updated_at:e.Nat64,features:e.Opt(G),created_at:e.Nat64,version:e.Opt(e.Nat64)}),rt=e.Record({stable:e.Nat64,heap:e.Nat64}),at=e.Record({metadata:e.Vec(e.Tuple(e.Text,e.Text)),scope:r,expires_at:e.Opt(e.Nat64)}),g=e.Record({controller:at,controllers:e.Vec(e.Principal)}),T=e.Record({title:e.Text,updated_at:e.Opt(e.Nat64),referrer:e.Opt(e.Text),time_zone:e.Text,session_id:e.Text,href:e.Text,satellite_id:e.Principal,device:c,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),B=e.Variant({Ok:l,Err:e.Text}),A=e.Variant({Ok:e.Null,Err:e.Vec(e.Tuple(a,e.Text))}),V=e.Record({session_id:e.Text,data:k,href:e.Text,metric_name:H,satellite_id:e.Principal,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),Y=e.Variant({Ok:X,Err:e.Text}),Q=e.Record({features:e.Opt(G),version:e.Opt(e.Nat64)}),ct=e.Record({updated_at:e.Opt(e.Nat64),session_id:e.Text,metadata:e.Opt(e.Vec(e.Tuple(e.Text,e.Text))),name:e.Text,satellite_id:e.Principal,version:e.Opt(e.Nat64),user_agent:e.Opt(e.Text)}),ft=e.Variant({Ok:W,Err:e.Text});return e.Service({del_controllers:e.Func([t],[e.Vec(e.Tuple(e.Principal,n))],[]),del_satellite_config:e.Func([e.Principal,i],[],[]),deposit_cycles:e.Func([s],[],[]),get_page_views:e.Func([o],[e.Vec(e.Tuple(a,l))],["query"]),get_page_views_analytics_clients:e.Func([o],[N],["query"]),get_page_views_analytics_metrics:e.Func([o],[u],["query"]),get_page_views_analytics_top_10:e.Func([o],[x],["query"]),get_performance_metrics:e.Func([o],[e.Vec(e.Tuple(a,X))],["query"]),get_performance_metrics_analytics_web_vitals:e.Func([o],[q],["query"]),get_track_events:e.Func([o],[e.Vec(e.Tuple(a,W))],["query"]),get_track_events_analytics:e.Func([o],[K],["query"]),list_controllers:e.Func([],[e.Vec(e.Tuple(e.Principal,n))],["query"]),list_satellite_configs:e.Func([],[e.Vec(e.Tuple(e.Principal,tt))],["query"]),memory_size:e.Func([],[rt],["query"]),set_controllers:e.Func([g],[e.Vec(e.Tuple(e.Principal,n))],[]),set_page_view:e.Func([a,T],[B],[]),set_page_views:e.Func([e.Vec(e.Tuple(a,T))],[A],[]),set_performance_metric:e.Func([a,V],[Y],[]),set_performance_metrics:e.Func([e.Vec(e.Tuple(a,V))],[A],[]),set_satellite_configs:e.Func([e.Vec(e.Tuple(e.Principal,Q))],[e.Vec(e.Tuple(e.Principal,tt))],[]),set_track_event:e.Func([a,ct],[ft],[]),set_track_events:e.Func([e.Vec(e.Tuple(a,ct))],[A],[]),version:e.Func([],[e.Text],["query"])})};var I0=Jr(Yc());var Ri;(function(e){e[e.SysFatal=1]="SysFatal",e[e.SysTransient=2]="SysTransient",e[e.DestinationInvalid=3]="DestinationInvalid",e[e.CanisterReject=4]="CanisterReject",e[e.CanisterError=5]="CanisterError"})(Ri||(Ri={}));xe();sn();xe();Yn();pe();var dy=new TextEncoder().encode(`
|
|
14
|
+
ic-request`);var ln=class{getPrincipal(){return ht.anonymous()}async transformRequest(t){return Object.assign(Object.assign({},t),{body:{content:t.body}})}};Kn();Yn();pe();Mn();var If=Jr(us());var Wn=()=>{if(typeof window<"u"&&window.crypto&&window.crypto.getRandomValues){let e=new Uint32Array(1);return window.crypto.getRandomValues(e),e[0]}if(typeof crypto<"u"&&crypto.getRandomValues){let e=new Uint32Array(1);return crypto.getRandomValues(e),e[0]}return typeof crypto<"u"&&crypto.randomInt?crypto.randomInt(0,4294967295):Math.floor(Math.random()*4294967295)};var ds;(function(e){e.Call="call"})(ds||(ds={}));function hn(){let e=new ArrayBuffer(16),t=new DataView(e),r=Wn(),n=Wn(),i=Wn(),s=Wn();return t.setUint32(0,r),t.setUint32(4,n),t.setUint32(8,i),t.setUint32(12,s),e}var Yd=BigInt(1e6),zd=60*1e3,Vr=class{constructor(t){let s=BigInt(Math.floor(Date.now()+t-zd))*Yd/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=s}toCBOR(){return If.value.u64(this._value.toString(16),16)}toHash(){return Ot(this._value)}};function da(e=hn){return async t=>{let r=t.request.headers;t.request.headers=r,t.endpoint==="call"&&(t.body.nonce=e())}}function Zn(e){let t=[];return e.forEach((r,n)=>{t.push([n,r])}),t}sn();var Xn=class extends Ht{constructor(t,r){super(t),this.response=r,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};si();ii();co();var Ps=BigInt(4294967295),ja=BigInt(32);function c0(e,t=!1){return t?{h:Number(e&Ps),l:Number(e>>ja&Ps)}:{h:Number(e>>ja&Ps)|0,l:Number(e&Ps)|0}}function Sp(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let i=0;i<e.length;i++){let{h:s,l:o}=c0(e[i],t);[r[i],n[i]]=[s,o]}return[r,n]}var Np=(e,t)=>BigInt(e>>>0)<<ja|BigInt(t>>>0),Rp=(e,t,r)=>e>>>r,Op=(e,t,r)=>e<<32-r|t>>>r,Fp=(e,t,r)=>e>>>r|t<<32-r,Up=(e,t,r)=>e<<32-r|t>>>r,Ip=(e,t,r)=>e<<64-r|t>>>r-32,Pp=(e,t,r)=>e>>>r-32|t<<64-r,kp=(e,t)=>t,Mp=(e,t)=>e,Cp=(e,t,r)=>e<<r|t>>>32-r,qp=(e,t,r)=>t<<r|e>>>32-r,$p=(e,t,r)=>t<<r-32|e>>>64-r,Vp=(e,t,r)=>e<<r-32|t>>>64-r;function Hp(e,t,r,n){let i=(t>>>0)+(n>>>0);return{h:e+r+(i/2**32|0)|0,l:i|0}}var Gp=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),jp=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,Yp=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),zp=(e,t,r,n,i)=>t+r+n+i+(e/2**32|0)|0,Kp=(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0),Wp=(e,t,r,n,i,s)=>t+r+n+i+s+(e/2**32|0)|0;var Zp={fromBig:c0,split:Sp,toBig:Np,shrSH:Rp,shrSL:Op,rotrSH:Fp,rotrSL:Up,rotrBH:Ip,rotrBL:Pp,rotr32H:kp,rotr32L:Mp,rotlSH:Cp,rotlSL:qp,rotlBH:$p,rotlBL:Vp,add:Hp,add3L:Gp,add3H:jp,add4L:Yp,add4H:zp,add5H:Wp,add5L:Kp},dt=Zp;Lr();var[Xp,Jp]=dt.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(e=>BigInt(e))),Rr=new Uint32Array(80),Or=new Uint32Array(80),Ya=class extends Dr{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:t,Al:r,Bh:n,Bl:i,Ch:s,Cl:o,Dh:a,Dl:c,Eh:l,El:d,Fh:h,Fl:N,Gh:w,Gl:u,Hh:x,Hl:C}=this;return[t,r,n,i,s,o,a,c,l,d,h,N,w,u,x,C]}set(t,r,n,i,s,o,a,c,l,d,h,N,w,u,x,C){this.Ah=t|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=l|0,this.El=d|0,this.Fh=h|0,this.Fl=N|0,this.Gh=w|0,this.Gl=u|0,this.Hh=x|0,this.Hl=C|0}process(t,r){for(let H=0;H<16;H++,r+=4)Rr[H]=t.getUint32(r),Or[H]=t.getUint32(r+=4);for(let H=16;H<80;H++){let X=Rr[H-15]|0,E=Or[H-15]|0,q=dt.rotrSH(X,E,1)^dt.rotrSH(X,E,8)^dt.shrSH(X,E,7),W=dt.rotrSL(X,E,1)^dt.rotrSL(X,E,8)^dt.shrSL(X,E,7),K=Rr[H-2]|0,G=Or[H-2]|0,tt=dt.rotrSH(K,G,19)^dt.rotrBH(K,G,61)^dt.shrSH(K,G,6),rt=dt.rotrSL(K,G,19)^dt.rotrBL(K,G,61)^dt.shrSL(K,G,6),at=dt.add4L(W,rt,Or[H-7],Or[H-16]),g=dt.add4H(at,q,tt,Rr[H-7],Rr[H-16]);Rr[H]=g|0,Or[H]=at|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:a,Cl:c,Dh:l,Dl:d,Eh:h,El:N,Fh:w,Fl:u,Gh:x,Gl:C,Hh:M,Hl:k}=this;for(let H=0;H<80;H++){let X=dt.rotrSH(h,N,14)^dt.rotrSH(h,N,18)^dt.rotrBH(h,N,41),E=dt.rotrSL(h,N,14)^dt.rotrSL(h,N,18)^dt.rotrBL(h,N,41),q=h&w^~h&x,W=N&u^~N&C,K=dt.add5L(k,E,W,Jp[H],Or[H]),G=dt.add5H(K,M,X,q,Xp[H],Rr[H]),tt=K|0,rt=dt.rotrSH(n,i,28)^dt.rotrBH(n,i,34)^dt.rotrBH(n,i,39),at=dt.rotrSL(n,i,28)^dt.rotrBL(n,i,34)^dt.rotrBL(n,i,39),g=n&s^n&a^s&a,T=i&o^i&c^o&c;M=x|0,k=C|0,x=w|0,C=u|0,w=h|0,u=N|0,{h,l:N}=dt.add(l|0,d|0,G|0,tt|0),l=a|0,d=c|0,a=s|0,c=o|0,s=n|0,o=i|0;let B=dt.add3L(tt,at,T);n=dt.add3H(B,G,rt,g),i=B|0}({h:n,l:i}=dt.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=dt.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:c}=dt.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:d}=dt.add(this.Dh|0,this.Dl|0,l|0,d|0),{h,l:N}=dt.add(this.Eh|0,this.El|0,h|0,N|0),{h:w,l:u}=dt.add(this.Fh|0,this.Fl|0,w|0,u|0),{h:x,l:C}=dt.add(this.Gh|0,this.Gl|0,x|0,C|0),{h:M,l:k}=dt.add(this.Hh|0,this.Hl|0,M|0,k|0),this.set(n,i,s,o,a,c,l,d,h,N,w,u,x,C,M,k)}roundClean(){Rr.fill(0),Or.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 u0=Nn(()=>new Ya);Lr();Oa();ar();Ce();Ce();var $e=BigInt(0),le=BigInt(1),ks=BigInt(2),Qp=BigInt(8),Lp={zip215:!0};function Dp(e){let t=_s(e);return Me(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function f0(e){let t=Dp(e),{Fp:r,n,prehash:i,hash:s,randomBytes:o,nByteLength:a,h:c}=t,l=ks<<BigInt(a*8)-le,d=r.create,h=t.uvRatio||((B,A)=>{try{return{isValid:!0,value:r.sqrt(B*r.inv(A))}}catch{return{isValid:!1,value:$e}}}),N=t.adjustScalarBytes||(B=>B),w=t.domain||((B,A,V)=>{if(_r("phflag",V),A.length||V)throw new Error("Contexts/pre-hash are not supported");return B});function u(B,A){ke("coordinate "+B,A,$e,l)}function x(B){if(!(B instanceof k))throw new Error("ExtendedPoint expected")}let C=or((B,A)=>{let{ex:V,ey:Y,ez:Q}=B,ct=B.is0();A==null&&(A=ct?Qp:r.inv(Q));let ft=d(V*A),z=d(Y*A),F=d(Q*A);if(ct)return{x:$e,y:le};if(F!==le)throw new Error("invZ was invalid");return{x:ft,y:z}}),M=or(B=>{let{a:A,d:V}=t;if(B.is0())throw new Error("bad point: ZERO");let{ex:Y,ey:Q,ez:ct,et:ft}=B,z=d(Y*Y),F=d(Q*Q),m=d(ct*ct),D=d(m*m),et=d(z*A),lt=d(m*d(et+F)),L=d(D+d(V*d(z*F)));if(lt!==L)throw new Error("bad point: equation left != right (1)");let f=d(Y*Q),p=d(ct*ft);if(f!==p)throw new Error("bad point: equation left != right (2)");return!0});class k{constructor(A,V,Y,Q){this.ex=A,this.ey=V,this.ez=Y,this.et=Q,u("x",A),u("y",V),u("z",Y),u("t",Q),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(A){if(A instanceof k)throw new Error("extended point not allowed");let{x:V,y:Y}=A||{};return u("x",V),u("y",Y),new k(V,Y,le,d(V*Y))}static normalizeZ(A){let V=r.invertBatch(A.map(Y=>Y.ez));return A.map((Y,Q)=>Y.toAffine(V[Q])).map(k.fromAffine)}_setWindowSize(A){E.setWindowSize(this,A)}assertValidity(){M(this)}equals(A){x(A);let{ex:V,ey:Y,ez:Q}=this,{ex:ct,ey:ft,ez:z}=A,F=d(V*z),m=d(ct*Q),D=d(Y*z),et=d(ft*Q);return F===m&&D===et}is0(){return this.equals(k.ZERO)}negate(){return new k(d(-this.ex),this.ey,this.ez,d(-this.et))}double(){let{a:A}=t,{ex:V,ey:Y,ez:Q}=this,ct=d(V*V),ft=d(Y*Y),z=d(ks*d(Q*Q)),F=d(A*ct),m=V+Y,D=d(d(m*m)-ct-ft),et=F+ft,lt=et-z,L=F-ft,f=d(D*lt),p=d(et*L),y=d(D*L),R=d(lt*et);return new k(f,p,R,y)}add(A){x(A);let{a:V,d:Y}=t,{ex:Q,ey:ct,ez:ft,et:z}=this,{ex:F,ey:m,ez:D,et}=A;if(V===BigInt(-1)){let U=d((ct-Q)*(m+F)),j=d((ct+Q)*(m-F)),J=d(j-U);if(J===$e)return this.double();let st=d(ft*ks*et),pt=d(z*ks*D),vt=pt+st,St=j+U,mt=pt-st,ut=d(vt*J),qt=d(St*mt),lr=d(vt*mt),Fr=d(J*St);return new k(ut,qt,Fr,lr)}let lt=d(Q*F),L=d(ct*m),f=d(z*Y*et),p=d(ft*D),y=d((Q+ct)*(F+m)-lt-L),R=p-f,v=p+f,S=d(L-V*lt),P=d(y*R),b=d(v*S),O=d(y*S),I=d(R*v);return new k(P,b,I,O)}subtract(A){return this.add(A.negate())}wNAF(A){return E.wNAFCached(this,A,k.normalizeZ)}multiply(A){let V=A;ke("scalar",V,le,n);let{p:Y,f:Q}=this.wNAF(V);return k.normalizeZ([Y,Q])[0]}multiplyUnsafe(A){let V=A;return ke("scalar",V,$e,n),V===$e?X:this.equals(X)||V===le?this:this.equals(H)?this.wNAF(V).p:E.unsafeLadder(this,V)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return E.unsafeLadder(this,n).is0()}toAffine(A){return C(this,A)}clearCofactor(){let{h:A}=t;return A===le?this:this.multiplyUnsafe(A)}static fromHex(A,V=!1){let{d:Y,a:Q}=t,ct=r.BYTES;A=zt("pointHex",A,ct),_r("zip215",V);let ft=A.slice(),z=A[ct-1];ft[ct-1]=z&-129;let F=Er(ft),m=V?l:r.ORDER;ke("pointHex.y",F,$e,m);let D=d(F*F),et=d(D-le),lt=d(Y*D-Q),{isValid:L,value:f}=h(et,lt);if(!L)throw new Error("Point.fromHex: invalid y coordinate");let p=(f&le)===le,y=(z&128)!==0;if(!V&&f===$e&&y)throw new Error("Point.fromHex: x=0 and x_0=1");return y!==p&&(f=d(-f)),k.fromAffine({x:f,y:F})}static fromPrivateKey(A){return K(A).point}toRawBytes(){let{x:A,y:V}=this.toAffine(),Y=Hr(V,r.BYTES);return Y[Y.length-1]|=A&le?128:0,Y}toHex(){return Pe(this.toRawBytes())}}k.BASE=new k(t.Gx,t.Gy,le,d(t.Gx*t.Gy)),k.ZERO=new k($e,le,le,$e);let{BASE:H,ZERO:X}=k,E=xs(k,a*8);function q(B){return Rt(B,n)}function W(B){return q(Er(B))}function K(B){let A=a;B=zt("private key",B,A);let V=zt("hashed private key",s(B),2*A),Y=N(V.slice(0,A)),Q=V.slice(A,2*A),ct=W(Y),ft=H.multiply(ct),z=ft.toRawBytes();return{head:Y,prefix:Q,scalar:ct,point:ft,pointBytes:z}}function G(B){return K(B).pointBytes}function tt(B=new Uint8Array,...A){let V=Tt(...A);return W(s(w(V,zt("context",B),!!i)))}function rt(B,A,V={}){B=zt("message",B),i&&(B=i(B));let{prefix:Y,scalar:Q,pointBytes:ct}=K(A),ft=tt(V.context,Y,B),z=H.multiply(ft).toRawBytes(),F=tt(V.context,z,ct,B),m=q(ft+F*Q);ke("signature.s",m,$e,n);let D=Tt(z,Hr(m,r.BYTES));return zt("result",D,a*2)}let at=Lp;function g(B,A,V,Y=at){let{context:Q,zip215:ct}=Y,ft=r.BYTES;B=zt("signature",B,2*ft),A=zt("message",A),ct!==void 0&&_r("zip215",ct),i&&(A=i(A));let z=Er(B.slice(ft,2*ft)),F,m,D;try{F=k.fromHex(V,ct),m=k.fromHex(B.slice(0,ft),ct),D=H.multiplyUnsafe(z)}catch{return!1}if(!ct&&F.isSmallOrder())return!1;let et=tt(Q,m.toRawBytes(),F.toRawBytes(),A);return m.add(F.multiplyUnsafe(et)).subtract(D).clearCofactor().equals(k.ZERO)}return H._setWindowSize(8),{CURVE:t,getPublicKey:G,sign:rt,verify:g,ExtendedPoint:k,utils:{getExtendedPublicKey:K,randomPrivateKey:()=>o(r.BYTES),precompute(B=8,A=k.BASE){return A._setWindowSize(B),A.multiply(BigInt(3)),A}}}}ar();var za=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),l0=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Og=BigInt(0),t1=BigInt(1),h0=BigInt(2),Fg=BigInt(3),e1=BigInt(5),r1=BigInt(8);function n1(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),s=za,a=e*e%s*e%s,c=qe(a,h0,s)*a%s,l=qe(c,t1,s)*e%s,d=qe(l,e1,s)*l%s,h=qe(d,t,s)*d%s,N=qe(h,r,s)*h%s,w=qe(N,n,s)*N%s,u=qe(w,i,s)*w%s,x=qe(u,i,s)*w%s,C=qe(x,t,s)*d%s;return{pow_p_5_8:qe(C,h0,s)*e%s,b2:a}}function i1(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function s1(e,t){let r=za,n=Rt(t*t*t,r),i=Rt(n*n*t,r),s=n1(e*i).pow_p_5_8,o=Rt(e*n*s,r),a=Rt(t*o*o,r),c=o,l=Rt(o*l0,r),d=a===e,h=a===Rt(-e,r),N=a===Rt(-e*l0,r);return d&&(o=c),(h||N)&&(o=l),Vf(o,r)&&(o=Rt(-o,r)),{isValid:d||h,value:o}}var o1=pn(za,void 0,!0),a1={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:o1,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:r1,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:u0,randomBytes:Ei,adjustScalarBytes:i1,uvRatio:s1},d0=f0(a1);var p0=function(e,t,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 t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r},oe=function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},ee,oi,m0,y0,Ms=class{constructor(t={}){ee.set(this,void 0),oi.set(this,void 0),this[m0]=this.entries.bind(this),this[y0]="ExpirableMap";let{source:r=[],expirationTime:n=10*60*1e3}=t,i=Date.now();p0(this,ee,new Map([...r].map(([s,o])=>[s,{value:o,timestamp:i}])),"f"),p0(this,oi,n,"f")}prune(){let t=Date.now();for(let[r,n]of oe(this,ee,"f").entries())t-n.timestamp>oe(this,oi,"f")&&oe(this,ee,"f").delete(r);return this}set(t,r){this.prune();let n={value:r,timestamp:Date.now()};return oe(this,ee,"f").set(t,n),this}get(t){let r=oe(this,ee,"f").get(t);if(r!==void 0){if(Date.now()-r.timestamp>oe(this,oi,"f")){oe(this,ee,"f").delete(t);return}return r.value}}clear(){oe(this,ee,"f").clear()}entries(){let t=oe(this,ee,"f").entries();return function*(){for(let[n,i]of t)yield[n,i.value]}()}values(){let t=oe(this,ee,"f").values();return function*(){for(let n of t)yield n.value}()}keys(){return oe(this,ee,"f").keys()}forEach(t,r){for(let[n,i]of oe(this,ee,"f").entries())t.call(r,i.value,n,this)}has(t){return oe(this,ee,"f").has(t)}delete(t){return oe(this,ee,"f").delete(t)}get size(){return oe(this,ee,"f").size}};ee=new WeakMap,oi=new WeakMap,m0=Symbol.iterator,y0=Symbol.toStringTag;pe();var g0=e=>{if(e<=127)return 1;if(e<=255)return 2;if(e<=65535)return 3;if(e<=16777215)return 4;throw new Error("Length too long (> 4 bytes)")},w0=(e,t,r)=>{if(r<=127)return e[t]=r,1;if(r<=255)return e[t]=129,e[t+1]=r,2;if(r<=65535)return e[t]=130,e[t+1]=r>>8,e[t+2]=r,3;if(r<=16777215)return e[t]=131,e[t+1]=r>>16,e[t+2]=r>>8,e[t+3]=r,4;throw new Error("Length too long (> 4 bytes)")},Ka=(e,t)=>{if(e[t]<128)return 1;if(e[t]===128)throw new Error("Invalid length 0");if(e[t]===129)return 2;if(e[t]===130)return 3;if(e[t]===131)return 4;throw new Error("Length too long (> 4 bytes)")},c1=(e,t)=>{let r=Ka(e,t);if(r===1)return e[t];if(r===2)return e[t+1];if(r===3)return(e[t+1]<<8)+e[t+2];if(r===4)return(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];throw new Error("Length too long (> 4 bytes)")},kg=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]),Wa=Uint8Array.from([48,5,6,3,43,101,112]),Mg=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function b0(e,t){let r=2+g0(e.byteLength+1),n=t.byteLength+r+e.byteLength,i=0,s=new Uint8Array(1+g0(n)+n);return s[i++]=48,i+=w0(s,i,n),s.set(t,i),i+=t.byteLength,s[i++]=3,i+=w0(s,i,e.byteLength+1),s[i++]=0,s.set(new Uint8Array(e),i),s}var x0=(e,t)=>{let r=0,n=(a,c)=>{if(i[r++]!==a)throw new Error("Expected: "+c)},i=new Uint8Array(e);if(n(48,"sequence"),r+=Ka(i,r),!Gn(i.slice(r,r+t.byteLength),t))throw new Error("Not the expected OID.");r+=t.byteLength,n(3,"bit string");let s=c1(i,r)-1;r+=Ka(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(e,t,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 t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r},E0=function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},Cs,qs,ai=class e{constructor(t){if(Cs.set(this,void 0),qs.set(this,void 0),t.byteLength!==e.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");_0(this,Cs,t,"f"),_0(this,qs,e.derEncode(t),"f")}static from(t){return this.fromDer(t.toDer())}static fromRaw(t){return new e(t)}static fromDer(t){return new e(this.derDecode(t))}static derEncode(t){return b0(t,Wa).buffer}static derDecode(t){let r=x0(t,Wa);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,Cs,"f")}get derKey(){return E0(this,qs,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Cs=new WeakMap,qs=new WeakMap;ai.RAW_KEY_LENGTH=32;Ns();var Za=class{constructor(){this.observers=[]}subscribe(t){this.observers.push(t)}unsubscribe(t){this.observers=this.observers.filter(r=>r!==t)}notify(t,...r){this.observers.forEach(n=>n(t,...r))}},$s=class extends Za{constructor(){super()}print(t,...r){this.notify({message:t,level:"info"},...r)}warn(t,...r){this.notify({message:t,level:"warn"},...r)}error(t,r,...n){this.notify({message:t,level:"error",error:r},...n)}};var Xe=function(e,t,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 t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r},re=function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},Je,Vs,Hs,Gs,js,Ys,zs,Ks,bn;var ci=class e{constructor(t=e.default){Je.set(this,void 0),Vs.set(this,void 0),Hs.set(this,void 0),Gs.set(this,void 0),js.set(this,void 0),Ys.set(this,void 0),zs.set(this,void 0),Ks.set(this,void 0),bn.set(this,0);let{initialInterval:r=500,randomizationFactor:n=.5,multiplier:i=1.5,maxInterval:s=6e4,maxElapsedTime:o=9e5,maxIterations:a=10,date:c=Date}=t;Xe(this,Je,r,"f"),Xe(this,Vs,n,"f"),Xe(this,Hs,i,"f"),Xe(this,Gs,s,"f"),Xe(this,Ks,c,"f"),Xe(this,js,c.now(),"f"),Xe(this,Ys,o,"f"),Xe(this,zs,a,"f")}get ellapsedTimeInMsec(){return re(this,Ks,"f").now()-re(this,js,"f")}get currentInterval(){return re(this,Je,"f")}get count(){return re(this,bn,"f")}get randomValueFromInterval(){let t=re(this,Vs,"f")*re(this,Je,"f"),r=re(this,Je,"f")-t,n=re(this,Je,"f")+t;return Math.random()*(n-r)+r}incrementCurrentInterval(){var t;return Xe(this,Je,Math.min(re(this,Je,"f")*re(this,Hs,"f"),re(this,Gs,"f")),"f"),Xe(this,bn,(t=re(this,bn,"f"),t++,t),"f"),re(this,Je,"f")}next(){return this.ellapsedTimeInMsec>=re(this,Ys,"f")||re(this,bn,"f")>=re(this,zs,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};Je=new WeakMap,Vs=new WeakMap,Hs=new WeakMap,Gs=new WeakMap,js=new WeakMap,Ys=new WeakMap,zs=new WeakMap,Ks=new WeakMap,bn=new WeakMap;ci.default={initialInterval:500,randomizationFactor:.5,multiplier:1.5,maxInterval:6e4,maxElapsedTime:9e5,maxIterations:10,date:Date};var we=function(e,t,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 t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r},nt=function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},Le,Qe,Kr,En,Zs,ui,Ve,Xs,He,Yr,Js,xn,_n,zr,Wr,v0,Qs,Ls,De;(function(e){e.Received="received",e.Processing="processing",e.Replied="replied",e.Rejected="rejected",e.Unknown="unknown",e.Done="done"})(De||(De={}));var Ws=5*60*1e3,u1="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae";var f1="ic0.app",l1=".ic0.app",h1="icp0.io",d1=".icp0.io",p1="icp-api.io",m1=".icp-api.io",fi=class extends Ht{constructor(t){super(t),this.message=t}},vn=class extends Ht{constructor(t){super(t),this.message=t}};function y1(){let e;if(typeof window<"u")if(window.fetch)e=window.fetch.bind(window);else throw new fi("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)e=globalThis.fetch.bind(globalThis);else throw new fi("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&&(e=self.fetch.bind(self));if(e)return e;throw new fi("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}function g1(e){let t;if(e!==void 0)!e.match(/^[a-z]+:/)&&typeof window<"u"?t=new URL(window.location.protocol+"//"+e):t=new URL(e);else{let r=["ic0.app","icp0.io","127.0.0.1","localhost"],n=[".github.dev",".gitpod.io"],i=typeof window<"u"?window.location:void 0,s=i?.hostname,o;s&&typeof s=="string"&&(n.some(a=>s.endsWith(a))?o=s:o=r.find(a=>s.endsWith(a))),i&&o?t=new URL(`${i.protocol}//${o}${i.port?":"+i.port:""}`):t=new URL("https://icp-api.io")}return t.toString()}var li=class e{constructor(t={}){var r;Le.add(this),this.rootKey=Cr(u1),Qe.set(this,void 0),Kr.set(this,void 0),En.set(this,void 0),Zs.set(this,void 0),ui.set(this,0),Ve.set(this,void 0),Xs.set(this,!1),He.set(this,void 0),Yr.set(this,void 0),this._isAgent=!0,this.config={},Js.set(this,0),this.log=new $s,xn.set(this,[]),_n.set(this,[]),zr.set(this,new Ms({expirationTime:5*60*1e3})),Wr.set(this,!0),Ls.set(this,(s,o)=>{if(nt(this,Wr,"f")===!1)return s;if(!o)throw new ye("Invalid signature from replica signed query: no matching node key found.");let{status:a,signatures:c=[],requestId:l}=s,d=new TextEncoder().encode("\vic-response");for(let h of c){let{timestamp:N,identity:w}=h,u=ht.fromUint8Array(w).toText(),x;if(a==="replied"){let{reply:X}=s;x=jn({status:a,reply:X,timestamp:BigInt(N),request_id:l})}else if(a==="rejected"){let{reject_code:X,reject_message:E,error_code:q}=s;x=jn({status:a,reject_code:X,reject_message:E,error_code:q,timestamp:BigInt(N),request_id:l})}else throw new Error(`Unknown status: ${a}`);let C=ie(d,new Uint8Array(x)),M=o?.nodeKeys.get(u);if(!M)throw new ye("Invalid signature from replica signed query: no matching node key found.");let k=ai.fromDer(M).rawKey;if(d0.verify(h.signature,new Uint8Array(C),new Uint8Array(k)))return s;throw new ye(`Invalid signature from replica ${u} signed query.`)}return s}),this.config=t,we(this,Kr,t.fetch||y1()||fetch.bind(globalThis),"f"),we(this,En,t.fetchOptions,"f"),we(this,Zs,t.callOptions,"f");let n=g1(t.host);this.host=new URL(n),t.verifyQuerySignatures!==void 0&&we(this,Wr,t.verifyQuerySignatures,"f"),we(this,He,(r=t.retryTimes)!==null&&r!==void 0?r:3,"f");let i=()=>new ci({maxIterations:nt(this,He,"f")});if(we(this,Yr,t.backoffStrategy||i,"f"),this.host.hostname.endsWith(l1)?this.host.hostname=f1:this.host.hostname.endsWith(d1)?this.host.hostname=h1:this.host.hostname.endsWith(m1)&&(this.host.hostname=p1),t.credentials){let{name:s,password:o}=t.credentials;we(this,Ve,`${s}${o?":"+o:""}`,"f")}we(this,Qe,Promise.resolve(t.identity||new ln),"f"),this.addTransform("update",da(hn)),t.useQueryNonces&&this.addTransform("query",da(hn)),t.logToConsole&&this.log.subscribe(s=>{s.level==="error"?console.error(s.message):s.level==="warn"?console.warn(s.message):console.log(s.message)})}get waterMark(){return nt(this,Js,"f")}static createSync(t={}){return new this(Object.assign({},t))}static async create(t={shouldFetchRootKey:!1}){let r=e.createSync(t),n=[r.syncTime()];return r.host.toString()!=="https://icp-api.io"&&t.shouldFetchRootKey&&n.push(r.fetchRootKey()),await Promise.all(n),r}static async from(t){var r;try{return"config"in t?await e.create(t.config):await e.create({fetch:t._fetch,fetchOptions:t._fetchOptions,callOptions:t._callOptions,host:t._host.toString(),identity:(r=t._identity)!==null&&r!==void 0?r:void 0})}catch{throw new Ht("Failed to create agent from provided agent")}}isLocal(){let t=this.host.hostname;return t==="127.0.0.1"||t.endsWith("127.0.0.1")}addTransform(t,r,n=r.priority||0){if(t==="update"){let i=nt(this,_n,"f").findIndex(s=>(s.priority||0)<n);nt(this,_n,"f").splice(i>=0?i:nt(this,_n,"f").length,0,Object.assign(r,{priority:n}))}else if(t==="query"){let i=nt(this,xn,"f").findIndex(s=>(s.priority||0)<n);nt(this,xn,"f").splice(i>=0?i:nt(this,xn,"f").length,0,Object.assign(r,{priority:n}))}}async getPrincipal(){if(!nt(this,Qe,"f"))throw new vn("This identity has expired due this application's security policy. Please refresh your authentication.");return(await nt(this,Qe,"f")).getPrincipal()}async call(t,r,n){let i=await(n!==void 0?await n:await nt(this,Qe,"f"));if(!i)throw new vn("This identity has expired due this application's security policy. Please refresh your authentication.");let s=ht.from(t),o=r.effectiveCanisterId?ht.from(r.effectiveCanisterId):s,a=i.getPrincipal()||ht.anonymous(),c=new Vr(Ws);Math.abs(nt(this,ui,"f"))>1e3*30&&(c=new Vr(Ws+nt(this,ui,"f")));let l={request_type:ds.Call,canister_id:s,method_name:r.methodName,arg:r.arg,sender:a,ingress_expiry:c},d=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},nt(this,Ve,"f")?{Authorization:"Basic "+btoa(nt(this,Ve,"f"))}:{})},endpoint:"call",body:l}),h=d.body.nonce?N(d.body.nonce):void 0;l.nonce=h;function N(X){return new Uint8Array(X)}d=await i.transformRequest(d);let w=ls(d.body);this.log.print(`fetching "/api/v2/canister/${o.toText()}/call" with request:`,d);let u=nt(this,Yr,"f").call(this),x=nt(this,Le,"m",Qs).call(this,{request:()=>nt(this,Kr,"f").call(this,""+new URL(`/api/v2/canister/${o.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},nt(this,Zs,"f")),d.request),{body:w})),backoff:u,tries:0}),[C,M]=await Promise.all([x,is(l)]),k=await C.arrayBuffer(),H=C.status===200&&k.byteLength>0?Ae(k):null;return{requestId:M,response:{ok:C.ok,status:C.status,statusText:C.statusText,body:H,headers:Zn(C.headers)},requestDetails:l}}async query(t,r,n){let i=nt(this,Yr,"f").call(this),s=r.effectiveCanisterId?ht.from(r.effectiveCanisterId):ht.from(t);this.log.print(`ecid ${s.toString()}`),this.log.print(`canisterId ${t.toString()}`);let o=async()=>{let w=await(n!==void 0?await n:await nt(this,Qe,"f"));if(!w)throw new vn("This identity has expired due this application's security policy. Please refresh your authentication.");let u=ht.from(t),x=w?.getPrincipal()||ht.anonymous(),C={request_type:"query",canister_id:u,method_name:r.methodName,arg:r.arg,sender:x,ingress_expiry:new Vr(Ws)},M=await is(C),k=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},nt(this,Ve,"f")?{Authorization:"Basic "+btoa(nt(this,Ve,"f"))}:{})},endpoint:"read",body:C});k=await w?.transformRequest(k);let H=ls(k.body),X={canister:u.toText(),ecid:s,transformedRequest:k,body:H,requestId:M,backoff:i,tries:0};return{requestDetails:C,query:await nt(this,Le,"m",v0).call(this,X)}},a=async()=>{if(!nt(this,Wr,"f"))return;let w=nt(this,zr,"f").get(s.toString());return w||(await this.fetchSubnetKeys(s.toString()),nt(this,zr,"f").get(s.toString()))},[c,l]=await Promise.all([o(),a()]),{requestDetails:d,query:h}=c,N=Object.assign(Object.assign({},h),{requestDetails:d});if(this.log.print("Query response:",N),!nt(this,Wr,"f"))return N;try{return nt(this,Ls,"f").call(this,N,l)}catch{this.log.warn("Query response verification failed. Retrying with fresh subnet keys."),nt(this,zr,"f").delete(t.toString()),await this.fetchSubnetKeys(s.toString());let u=nt(this,zr,"f").get(t.toString());if(!u)throw new ye("Invalid signature from replica signed query: no matching node key found.");return nt(this,Ls,"f").call(this,N,u)}}async createReadStateRequest(t,r){let n=await(r!==void 0?await r:await nt(this,Qe,"f"));if(!n)throw new vn("This identity has expired due this application's security policy. Please refresh your authentication.");let i=n?.getPrincipal()||ht.anonymous(),s=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},nt(this,Ve,"f")?{Authorization:"Basic "+btoa(nt(this,Ve,"f"))}:{})},endpoint:"read_state",body:{request_type:"read_state",paths:t.paths,sender:i,ingress_expiry:new Vr(Ws)}});return n?.transformRequest(s)}async readState(t,r,n,i){let s=typeof t=="string"?ht.fromText(t):t,o=i??await this.createReadStateRequest(r,n),a=ls(o.body);this.log.print(`fetching "/api/v2/canister/${s}/read_state" with request:`,o);let c=nt(this,Yr,"f").call(this),l=await nt(this,Le,"m",Qs).call(this,{request:()=>nt(this,Kr,"f").call(this,""+new URL(`/api/v2/canister/${s.toString()}/read_state`,this.host),Object.assign(Object.assign(Object.assign({},nt(this,En,"f")),o.request),{body:a})),backoff:c,tries:0});if(!l.ok)throw new Error(`Server returned an error:
|
|
15
|
+
Code: ${l.status} (${l.statusText})
|
|
16
|
+
Body: ${await l.text()}
|
|
17
|
+
`);let d=Ae(await l.arrayBuffer());this.log.print("Read state response:",d);let h=await this.parseTimeFromResponse(d);return h>0&&(this.log.print("Read state response time:",h),we(this,Js,h,"f")),d}async parseTimeFromResponse(t){let r;if(t.certificate){let n=Ae(t.certificate);if(n&&"tree"in n)r=n.tree;else throw new Error("Could not decode time from response");let i=Nr(["time"],r);if(i.status!==Ct.Found)throw new Error("Time was not found in the response or was not in its expected format.");if(!(i.value instanceof ArrayBuffer)&&!ArrayBuffer.isView(i))throw new Error("Time was not found in the response or was not in its expected format.");let s=gn(na(i.value));return this.log.print("Time from response:",s),this.log.print("Time from response in milliseconds:",Number(s)),Number(s)}else this.log.warn("No certificate found in response");return 0}async syncTime(t){let r=await Promise.resolve().then(()=>(si(),Is)),n=Date.now();try{t||this.log.print("Syncing time with the IC. No canisterId provided, so falling back to ryjl3-tyaaa-aaaaa-aaaba-cai");let s=(await r.request({canisterId:t??ht.from("ryjl3-tyaaa-aaaaa-aaaba-cai"),agent:this,paths:["time"]})).get("time");s&&we(this,ui,Number(s)-Number(n),"f")}catch(i){this.log.error("Caught exception while attempting to sync time",i)}}async status(){let t=nt(this,Ve,"f")?{Authorization:"Basic "+btoa(nt(this,Ve,"f"))}:{};this.log.print('fetching "/api/v2/status"');let r=nt(this,Yr,"f").call(this),n=await nt(this,Le,"m",Qs).call(this,{backoff:r,request:()=>nt(this,Kr,"f").call(this,""+new URL("/api/v2/status",this.host),Object.assign({headers:t},nt(this,En,"f"))),tries:0});return Ae(await n.arrayBuffer())}async fetchRootKey(){return nt(this,Xs,"f")||(this.rootKey=(await this.status()).root_key,we(this,Xs,!0,"f")),this.rootKey}invalidateIdentity(){we(this,Qe,null,"f")}replaceIdentity(t){we(this,Qe,Promise.resolve(t),"f")}async fetchSubnetKeys(t){let r=ht.from(t),i=(await Us({canisterId:r,paths:["subnet"],agent:this})).get("subnet");if(i&&typeof i=="object"&&"nodeKeys"in i)return nt(this,zr,"f").set(r.toText(),i),i}_transform(t){let r=Promise.resolve(t);if(t.endpoint==="call")for(let n of nt(this,_n,"f"))r=r.then(i=>n(i).then(s=>s||i));else for(let n of nt(this,xn,"f"))r=r.then(i=>n(i).then(s=>s||i));return r}};Qe=new WeakMap,Kr=new WeakMap,En=new WeakMap,Zs=new WeakMap,ui=new WeakMap,Ve=new WeakMap,Xs=new WeakMap,He=new WeakMap,Yr=new WeakMap,Js=new WeakMap,xn=new WeakMap,_n=new WeakMap,zr=new WeakMap,Wr=new WeakMap,Ls=new WeakMap,Le=new WeakSet,v0=async function e(t){var r,n;let{ecid:i,transformedRequest:s,body:o,requestId:a,backoff:c,tries:l}=t,d=l===0?0:c.next();if(this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with tries:`,{tries:l,backoff:c,delay:d}),d===null)throw new Ht(`Timestamp failed to pass the watermark after retrying the configured ${nt(this,He,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);d>0&&await new Promise(u=>setTimeout(u,d));let h;try{this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with request:`,s);let u=await nt(this,Kr,"f").call(this,""+new URL(`/api/v2/canister/${i.toString()}/query`,this.host),Object.assign(Object.assign(Object.assign({},nt(this,En,"f")),s.request),{body:o}));if(u.status===200){let x=Ae(await u.arrayBuffer());h=Object.assign(Object.assign({},x),{httpDetails:{ok:u.ok,status:u.status,statusText:u.statusText,headers:Zn(u.headers)},requestId:a})}else throw new Xn(`Gateway returned an error:
|
|
18
|
+
Code: ${u.status} (${u.statusText})
|
|
19
|
+
Body: ${await u.text()}
|
|
20
|
+
`,{ok:u.ok,status:u.status,statusText:u.statusText,headers:Zn(u.headers)})}catch(u){if(l<nt(this,He,"f"))return this.log.warn(`Caught exception while attempting to make query:
|
|
21
|
+
${u}
|
|
22
|
+
Retrying query.`),await nt(this,Le,"m",e).call(this,Object.assign(Object.assign({},t),{tries:l+1}));throw u}let N=(n=(r=h.signatures)===null||r===void 0?void 0:r[0])===null||n===void 0?void 0:n.timestamp;if(!nt(this,Wr,"f"))return h;if(!N)throw new Error("Timestamp not found in query response. This suggests a malformed or malicious response.");let w=Number(BigInt(N)/BigInt(1e6));if(this.log.print("watermark and timestamp",{waterMark:this.waterMark,timestamp:w}),Number(this.waterMark)>w){let u=new Ht("Timestamp is below the watermark. Retrying query.");if(this.log.error("Timestamp is below",u,{timestamp:N,waterMark:this.waterMark}),l<nt(this,He,"f"))return await nt(this,Le,"m",e).call(this,Object.assign(Object.assign({},t),{tries:l+1}));throw new Ht(`Timestamp failed to pass the watermark after retrying the configured ${nt(this,He,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`)}return h},Qs=async function e(t){let{request:r,backoff:n,tries:i}=t,s=i===0?0:n.next();if(s===null)throw new Ht(`Timestamp failed to pass the watermark after retrying the configured ${nt(this,He,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);s>0&&await new Promise(l=>setTimeout(l,s));let o;try{o=await r()}catch(l){if(nt(this,He,"f")>i)return this.log.warn(`Caught exception while attempting to make request:
|
|
23
|
+
${l}
|
|
24
|
+
Retrying request.`),await nt(this,Le,"m",e).call(this,{request:r,backoff:n,tries:i+1});throw l}if(o.ok)return o;let a=await o.clone().text(),c=`Server returned an error:
|
|
25
25
|
Code: ${o.status} (${o.statusText})
|
|
26
|
-
Body: ${
|
|
27
|
-
`;if(i<
|
|
28
|
-
Request ID: ${
|
|
26
|
+
Body: ${a}
|
|
27
|
+
`;if(i<nt(this,He,"f"))return await nt(this,Le,"m",e).call(this,{request:r,backoff:n,tries:i+1});throw new Xn(c,{ok:o.ok,status:o.status,statusText:o.statusText,headers:Zn(o.headers)})};xe();var B0;(function(e){e.Error="err",e.GetPrincipal="gp",e.GetPrincipalResponse="gpr",e.Query="q",e.QueryResponse="qr",e.Call="c",e.CallResponse="cr",e.ReadState="rs",e.ReadStateResponse="rsr",e.Status="s",e.StatusResponse="sr"})(B0||(B0={}));function Xa(){let e=typeof window>"u"?typeof globalThis>"u"?typeof self>"u"?void 0:self.ic.agent:globalThis.ic.agent:window.ic.agent;if(!e)throw new Error("No Agent could be found.");return e}sn();Mn();ii();pe();var Ds={};Sn(Ds,{backoff:()=>R0,chain:()=>O0,conditionalDelay:()=>S0,defaultStrategy:()=>A0,maxAttempts:()=>b1,once:()=>T0,throttle:()=>x1,timeout:()=>N0});pe();var w1=5*60*1e3;function A0(){return O0(S0(T0(),1e3),R0(1e3,1.2),N0(w1))}function T0(){let e=!0;return async()=>e?(e=!1,!0):!1}function S0(e,t){return async(r,n,i)=>{if(await e(r,n,i))return new Promise(s=>setTimeout(s,t))}}function b1(e){let t=e;return async(r,n,i)=>{if(--t<=0)throw new Error(`Failed to retrieve a reply for request after ${e} attempts:
|
|
28
|
+
Request ID: ${Yt(n)}
|
|
29
29
|
Request status: ${i}
|
|
30
|
-
`)}}function
|
|
31
|
-
Request ID: ${
|
|
30
|
+
`)}}function x1(e){return()=>new Promise(t=>setTimeout(t,e))}function N0(e){let t=Date.now()+e;return async(r,n,i)=>{if(Date.now()>t)throw new Error(`Request timed out after ${e} msec:
|
|
31
|
+
Request ID: ${Yt(n)}
|
|
32
32
|
Request status: ${i}
|
|
33
|
-
`)}}function
|
|
34
|
-
Request ID: ${
|
|
35
|
-
Reject code: ${
|
|
36
|
-
Reject text: ${
|
|
37
|
-
`)}case
|
|
38
|
-
Request ID: ${
|
|
39
|
-
`)}throw new Error("unreachable")}
|
|
40
|
-
`)),this.canisterId=
|
|
33
|
+
`)}}function R0(e,t){let r=e;return()=>new Promise(n=>setTimeout(()=>{r*=t,n()},r))}function O0(...e){return async(t,r,n)=>{for(let i of e)await i(t,r,n)}}async function Ja(e,t,r,n,i,s){var o;let a=[new TextEncoder().encode("request_status"),r],c=i??await((o=e.createReadStateRequest)===null||o===void 0?void 0:o.call(e,{paths:[a]})),l=await e.readState(t,{paths:[a]},void 0,c);if(e.rootKey==null)throw new Error("Agent root key not initialized before polling");let d=await wn.create({certificate:l.certificate,rootKey:e.rootKey,canisterId:t,blsVerify:s}),h=fr(d.lookup([...a,new TextEncoder().encode("status")])),N;switch(typeof h>"u"?N=De.Unknown:N=new TextDecoder().decode(h),N){case De.Replied:return{reply:fr(d.lookup([...a,"reply"])),certificate:d};case De.Received:case De.Unknown:case De.Processing:return await n(t,r,N),Ja(e,t,r,n,c);case De.Rejected:{let w=new Uint8Array(fr(d.lookup([...a,"reject_code"])))[0],u=new TextDecoder().decode(fr(d.lookup([...a,"reject_message"])));throw new Error(`Call was rejected:
|
|
34
|
+
Request ID: ${Yt(r)}
|
|
35
|
+
Reject code: ${w}
|
|
36
|
+
Reject text: ${u}
|
|
37
|
+
`)}case De.Done:throw new Error(`Call was marked as done but we never saw the reply:
|
|
38
|
+
Request ID: ${Yt(r)}
|
|
39
|
+
`)}throw new Error("unreachable")}xe();pe();var F0=({IDL:e})=>{let t=e.Variant({mainnet:e.Null,testnet:e.Null}),r=e.Text,n=e.Record({network:t,address:r,min_confirmations:e.Opt(e.Nat32)}),i=e.Nat64,s=i,o=e.Record({network:t}),a=e.Nat64,c=e.Vec(a),l=e.Record({network:t,filter:e.Opt(e.Variant({page:e.Vec(e.Nat8),min_confirmations:e.Nat32})),address:r}),d=e.Vec(e.Nat8),h=e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32}),N=e.Record({height:e.Nat32,value:i,outpoint:h}),w=e.Record({next_page:e.Opt(e.Vec(e.Nat8)),tip_height:e.Nat32,tip_block_hash:d,utxos:e.Vec(N)}),u=e.Record({transaction:e.Vec(e.Nat8),network:t}),x=e.Principal,C=e.Record({canister_id:x,num_requested_changes:e.Opt(e.Nat64)}),M=e.Variant({from_user:e.Record({user_id:e.Principal}),from_canister:e.Record({canister_version:e.Opt(e.Nat64),canister_id:e.Principal})}),k=e.Variant({creation:e.Record({controllers:e.Vec(e.Principal)}),code_deployment:e.Record({mode:e.Variant({reinstall:e.Null,upgrade:e.Null,install:e.Null}),module_hash:e.Vec(e.Nat8)}),controllers_change:e.Record({controllers:e.Vec(e.Principal)}),code_uninstall:e.Null}),H=e.Record({timestamp_nanos:e.Nat64,canister_version:e.Nat64,origin:M,details:k}),X=e.Record({controllers:e.Vec(e.Principal),module_hash:e.Opt(e.Vec(e.Nat8)),recent_changes:e.Vec(H),total_num_changes:e.Nat64}),E=e.Record({canister_id:x}),q=e.Variant({controllers:e.Null,public:e.Null}),W=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),reserved_cycles_limit:e.Nat,log_visibility:q,wasm_memory_limit:e.Nat,memory_allocation:e.Nat,compute_allocation:e.Nat}),K=e.Record({status:e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),memory_size:e.Nat,cycles:e.Nat,settings:W,query_stats:e.Record({response_payload_bytes_total:e.Nat,num_instructions_total:e.Nat,num_calls_total:e.Nat,request_payload_bytes_total:e.Nat}),idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8)),reserved_cycles:e.Nat}),G=e.Record({canister_id:x}),tt=e.Record({freezing_threshold:e.Opt(e.Nat),controllers:e.Opt(e.Vec(e.Principal)),reserved_cycles_limit:e.Opt(e.Nat),log_visibility:e.Opt(q),wasm_memory_limit:e.Opt(e.Nat),memory_allocation:e.Opt(e.Nat),compute_allocation:e.Opt(e.Nat)}),rt=e.Record({settings:e.Opt(tt),sender_canister_version:e.Opt(e.Nat64)}),at=e.Record({canister_id:x}),g=e.Record({canister_id:x}),T=e.Record({canister_id:x}),B=e.Variant({secp256k1:e.Null}),A=e.Record({key_id:e.Record({name:e.Text,curve:B}),canister_id:e.Opt(x),derivation_path:e.Vec(e.Vec(e.Nat8))}),V=e.Record({public_key:e.Vec(e.Nat8),chain_code:e.Vec(e.Nat8)}),Y=e.Record({canister_id:x}),Q=e.Record({idx:e.Nat64,timestamp_nanos:e.Nat64,content:e.Vec(e.Nat8)}),ct=e.Record({canister_log_records:e.Vec(Q)}),ft=e.Record({value:e.Text,name:e.Text}),z=e.Record({status:e.Nat,body:e.Vec(e.Nat8),headers:e.Vec(ft)}),F=e.Record({url:e.Text,method:e.Variant({get:e.Null,head:e.Null,post:e.Null}),max_response_bytes:e.Opt(e.Nat64),body:e.Opt(e.Vec(e.Nat8)),transform:e.Opt(e.Record({function:e.Func([e.Record({context:e.Vec(e.Nat8),response:z})],[z],["query"]),context:e.Vec(e.Nat8)})),headers:e.Vec(ft)}),m=e.Variant({reinstall:e.Null,upgrade:e.Opt(e.Record({wasm_memory_persistence:e.Opt(e.Variant({keep:e.Null,replace:e.Null})),skip_pre_upgrade:e.Opt(e.Bool)})),install:e.Null}),D=e.Record({hash:e.Vec(e.Nat8)}),et=e.Record({arg:e.Vec(e.Nat8),wasm_module_hash:e.Vec(e.Nat8),mode:m,chunk_hashes_list:e.Vec(D),target_canister:x,store_canister:e.Opt(x),sender_canister_version:e.Opt(e.Nat64)}),lt=e.Vec(e.Nat8),L=e.Record({arg:e.Vec(e.Nat8),wasm_module:lt,mode:m,canister_id:x,sender_canister_version:e.Opt(e.Nat64)}),f=e.Record({start_at_timestamp_nanos:e.Nat64,subnet_id:e.Principal}),p=e.Record({num_block_failures_total:e.Nat64,node_id:e.Principal,num_blocks_proposed_total:e.Nat64}),y=e.Vec(e.Record({timestamp_nanos:e.Nat64,node_metrics:e.Vec(p)})),R=e.Record({settings:e.Opt(tt),specified_id:e.Opt(x),amount:e.Opt(e.Nat),sender_canister_version:e.Opt(e.Nat64)}),v=e.Record({canister_id:x}),S=e.Record({canister_id:x,amount:e.Nat}),P=e.Vec(e.Nat8),b=e.Record({key_id:e.Record({name:e.Text,curve:B}),derivation_path:e.Vec(e.Vec(e.Nat8)),message_hash:e.Vec(e.Nat8)}),O=e.Record({signature:e.Vec(e.Nat8)}),I=e.Record({canister_id:x}),U=e.Record({canister_id:x}),j=e.Record({canister_id:x}),J=e.Vec(D),st=e.Record({canister_id:x,sender_canister_version:e.Opt(e.Nat64)}),pt=e.Record({canister_id:e.Principal,settings:tt,sender_canister_version:e.Opt(e.Nat64)}),vt=e.Record({chunk:e.Vec(e.Nat8),canister_id:e.Principal}),St=D;return e.Service({bitcoin_get_balance:e.Func([n],[s],[]),bitcoin_get_current_fee_percentiles:e.Func([o],[c],[]),bitcoin_get_utxos:e.Func([l],[w],[]),bitcoin_send_transaction:e.Func([u],[],[]),canister_info:e.Func([C],[X],[]),canister_status:e.Func([E],[K],[]),clear_chunk_store:e.Func([G],[],[]),create_canister:e.Func([rt],[at],[]),delete_canister:e.Func([g],[],[]),deposit_cycles:e.Func([T],[],[]),ecdsa_public_key:e.Func([A],[V],[]),fetch_canister_logs:e.Func([Y],[ct],["query"]),http_request:e.Func([F],[z],[]),install_chunked_code:e.Func([et],[],[]),install_code:e.Func([L],[],[]),node_metrics_history:e.Func([f],[y],[]),provisional_create_canister_with_cycles:e.Func([R],[v],[]),provisional_top_up_canister:e.Func([S],[],[]),raw_rand:e.Func([],[P],[]),sign_with_ecdsa:e.Func([b],[O],[]),start_canister:e.Func([I],[],[]),stop_canister:e.Func([U],[],[]),stored_chunks:e.Func([j],[J],[]),uninstall_code:e.Func([st],[],[]),update_settings:e.Func([pt],[],[]),upload_chunk:e.Func([vt],[St],[])})};var to=class extends Ht{constructor(t,r,n,i){super(["Call failed:",` Canister: ${t.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(i).map(s=>` "${s}": ${JSON.stringify(i[s])}`)].join(`
|
|
40
|
+
`)),this.canisterId=t,this.methodName=r,this.type=n,this.props=i}},Qa=class extends to{constructor(t,r,n){var i;super(t,r,"query",{Status:n.status,Code:(i=Ri[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}},La=class extends to{constructor(t,r,n,i){super(t,r,"update",Object.assign({"Request ID":Yt(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}},Te=Symbol.for("ic-agent-metadata"),Zr=class e{constructor(t){this[Te]=Object.freeze(t)}static agentOf(t){return t[Te].config.agent}static interfaceOf(t){return t[Te].service}static canisterIdOf(t){return ht.from(t[Te].config.canisterId)}static async install(t,r){let n=t.mode===void 0?{install:null}:t.mode,i=t.arg?[...new Uint8Array(t.arg)]:[],s=[...new Uint8Array(t.module)],o=typeof r.canisterId=="string"?ht.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(t,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:[],wasm_memory_limit:[]}]}let{canister_id:i}=await U0(t||{}).provisional_create_canister_with_cycles({amount:[],settings:n(r||{}),specified_id:[],sender_canister_version:[]});return i}static async createAndInstallCanister(t,r,n){let i=await this.createCanister(n);return await this.install(Object.assign({},r),Object.assign(Object.assign({},n),{canisterId:i})),this.createActor(t,Object.assign(Object.assign({},n),{canisterId:i}))}static createActorClass(t,r){let n=t({IDL:br});class i extends e{constructor(o){if(!o.canisterId)throw new Ht(`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"?ht.fromText(o.canisterId):o.canisterId;super({config:Object.assign(Object.assign(Object.assign({},P0),o),{canisterId:a}),service:n});for(let[c,l]of n._fields)r?.httpDetails&&l.annotations.push(Da),r?.certificate&&l.annotations.push(k0),this[c]=E1(this,c,l,o.blsVerify)}}return i}static createActor(t,r){if(!r.canisterId)throw new Ht(`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(t))(r)}static createActorWithHttpDetails(t,r){return new(this.createActorClass(t,{httpDetails:!0}))(r)}static createActorWithExtendedDetails(t,r,n={httpDetails:!0,certificate:!0}){return new(this.createActorClass(t,n))(r)}};function Bn(e,t){let r=br.decode(e,I0.Buffer.from(t));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var P0={pollingStrategyFactory:Ds.defaultStrategy},Da="http-details",k0="certificate";function E1(e,t,r,n){let i;r.annotations.includes("query")||r.annotations.includes("composite_query")?i=async(o,...a)=>{var c,l;o=Object.assign(Object.assign({},o),(l=(c=e[Te].config).queryTransform)===null||l===void 0?void 0:l.call(c,t,a,Object.assign(Object.assign({},e[Te].config),o)));let d=o.agent||e[Te].config.agent||Xa(),h=ht.from(o.canisterId||e[Te].config.canisterId),N=br.encode(r.argTypes,a),w=await d.query(h,{methodName:t,arg:N,effectiveCanisterId:o.effectiveCanisterId}),u=Object.assign(Object.assign({},w.httpDetails),{requestDetails:w.requestDetails});switch(w.status){case"rejected":throw new Qa(h,t,w);case"replied":return r.annotations.includes(Da)?{httpDetails:u,result:Bn(r.retTypes,w.reply.arg)}:Bn(r.retTypes,w.reply.arg)}}:i=async(o,...a)=>{var c,l;o=Object.assign(Object.assign({},o),(l=(c=e[Te].config).callTransform)===null||l===void 0?void 0:l.call(c,t,a,Object.assign(Object.assign({},e[Te].config),o)));let d=o.agent||e[Te].config.agent||Xa(),{canisterId:h,effectiveCanisterId:N,pollingStrategyFactory:w}=Object.assign(Object.assign(Object.assign({},P0),e[Te].config),o),u=ht.from(h),x=N!==void 0?ht.from(N):u,C=br.encode(r.argTypes,a),{requestId:M,response:k,requestDetails:H}=await d.call(u,{methodName:t,arg:C,effectiveCanisterId:x});if(!k.ok||k.body)throw new La(u,t,M,k);let X=w(),{certificate:E,reply:q}=await Ja(d,x,M,X,n),W=r.annotations.includes(Da),K=r.annotations.includes(k0),G=Object.assign(Object.assign({},k),{requestDetails:H});if(q!==void 0)return W&&K?{httpDetails:G,certificate:E,result:Bn(r.retTypes,q)}:K?{certificate:E,result:Bn(r.retTypes,q)}:W?{httpDetails:G,result:Bn(r.retTypes,q)}:Bn(r.retTypes,q);if(r.retTypes.length===0)return W?{httpDetails:k,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 U0(e){function t(r,n){if(e.effectiveCanisterId)return{effectiveCanisterId:ht.from(e.effectiveCanisterId)};let i=n[0],s=ht.fromHex("");return i&&typeof i=="object"&&i.canister_id&&(s=ht.from(i.canister_id)),{effectiveCanisterId:s}}return Zr.createActor(F0,Object.assign(Object.assign(Object.assign({},e),{canisterId:ht.fromHex("")}),{callTransform:t,queryTransform:t}))}ii();xe();si();Yn();qa();pe();si();Kn();var M0=async({orbiterId:e,idlFactory:t,container:r})=>{let n=pr(r)&&r!==!1,i=n?r===!0?"http://127.0.0.1:5987":r:"https://icp-api.io",s=await li.create({identity:new ln,host:i,shouldFetchRootKey:n});return Zr.createActor(t,{agent:s,canisterId:e})};var eo=async e=>M0({idlFactory:Bc,...e});function hi(e){return new Promise((t,r)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>r(e.error)})}function di(e,t){let r=indexedDB.open(e);r.onupgradeneeded=()=>r.result.createObjectStore(t);let n=hi(r);return(i,s)=>n.then(o=>s(o.transaction(t,i).objectStore(t)))}var tc;function C0(){return tc||(tc=di("keyval-store","keyval")),tc}function ro(e,t=C0()){return t("readwrite",r=>(e.forEach(n=>r.delete(n)),hi(r.transaction)))}function v1(e,t){return e.openCursor().onsuccess=function(){this.result&&(t(this.result),this.result.continue())},hi(e.transaction)}function no(e=C0()){return e("readonly",t=>{if(t.getAll&&t.getAllKeys)return Promise.all([hi(t.getAllKeys()),hi(t.getAll())]).then(([n,i])=>n.map((s,o)=>[s,i[o]]));let r=[];return e("readonly",n=>v1(n,i=>r.push([i.key,i.value])).then(()=>r))})}var q0=di("juno-views","views"),$0=di("juno-events","events"),V0=di("juno-metrics","metrics");var H0=()=>no(q0),G0=e=>ro(e,q0);var j0=()=>no($0),Y0=e=>ro(e,$0);var z0=()=>no(V0),K0=e=>ro(e,V0);onmessage=async({data:e})=>{let{msg:t,data:r}=e;switch(t){case"junoInitEnvironment":await T1(r);return;case"junoTrackPageView":U1();return;case"junoTrackEvent":I1();return;case"junoStartTrackTimer":await N1();return;case"junoStopTracker":await S1();return}};var B1="Analytics worker not initialized. Did you set `satelliteId`?",A1="Analytics worker not initialized. Did you set `orbiterId`?",he,T1=async e=>{let{orbiterId:t,satelliteId:r}=e;lo(t,A1),lo(r,B1),he=e},pi,ic=async()=>await Promise.all([W0(),Z0(),F1()]),S1=async()=>{await ic(),pr(pi)&&(clearInterval(pi),pi=void 0),self.close()},N1=async()=>{pr(pi)||(await ic(),pi=setInterval(ic,he?.worker?.timerInterval??1e3))},ec=!1,rc=!1,nc=!1,W0=async()=>{if(!mi(he)||ec)return;let e=await H0();if(!(Ur(e)||e.length===0)){ec=!0;try{let r=await(await eo(he)).set_page_views(e.map(([n,{collected_at:i,...s}])=>[sc({key:n,collected_at:i}),{...s,...oc(he)}]));await G0(e.map(([n,i])=>n)),ac(r)}catch(t){console.error(t)}ec=!1}},R1=fo(async()=>await W0(),100),Z0=async()=>{if(!mi(he)||rc)return;let e=await j0();if(!(Ur(e)||e.length===0)){rc=!0;try{let t=await eo(he),r=({metadata:i,...s})=>({metadata:Ur(i)?[]:[Object.entries(i??{})],...s,...oc(he)}),n=await t.set_track_events(e.map(([i,{collected_at:s,...o}])=>[sc({key:i,collected_at:s}),r(o)]));await Y0(e.map(([i,s])=>i)),ac(n)}catch(t){console.error(t)}rc=!1}},O1=fo(async()=>await Z0(),250),F1=async()=>{if(!mi(he)||he?.options?.performance===!1||nc)return;let e=await z0();if(!(Ur(e)||e.length===0)){nc=!0;try{let r=await(await eo(he)).set_performance_metrics(e.map(([n,{collected_at:i,...s}])=>[sc({key:n,collected_at:i}),{...s,...oc(he)}]));await K0(e.map(([n,i])=>n)),ac(r)}catch(t){console.error(t)}nc=!1}},U1=()=>{mi(he)&&(X0()||R1())},I1=()=>{mi(he)&&(X0()||O1())},sc=({key:e,collected_at:t})=>({collected_at:t,key:e}),oc=e=>({satellite_id:ht.fromText(e.satelliteId)}),X0=()=>{let{userAgent:e}=navigator;return pr(e)?vc(e):!1},mi=e=>e!=null&&pr(e.orbiterId)&&pr(e.satelliteId),ac=e=>{"Ok"in e||e.Err.forEach(([t,r])=>console.warn(`${r} [Key: ${t.key}]`))};})();
|
|
41
41
|
/*!
|
|
42
42
|
* The buffer module from node.js, for the browser.
|
|
43
43
|
*
|
|
@@ -72,6 +72,9 @@ buffer/index.js:
|
|
|
72
72
|
@noble/curves/esm/abstract/weierstrass.js:
|
|
73
73
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
74
74
|
|
|
75
|
+
@noble/curves/esm/abstract/bls.js:
|
|
76
|
+
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
77
|
+
|
|
75
78
|
@noble/curves/esm/bls12-381.js:
|
|
76
79
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
77
80
|
|