@junobuild/core 0.0.61 → 0.0.62

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,59 +1,60 @@
1
1
  import { createRequire as topLevelCreateRequire } from 'module';
2
2
  const require = topLevelCreateRequire(import.meta.url);
3
- var qy=Object.create;var As=Object.defineProperty;var jy=Object.getOwnPropertyDescriptor;var ky=Object.getOwnPropertyNames;var Vy=Object.getPrototypeOf,Hy=Object.prototype.hasOwnProperty;var Dn=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var Ql=(t,e)=>()=>(t&&(e=t(t=0)),e);var L=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),$y=(t,e)=>{for(var r in e)As(t,r,{get:e[r],enumerable:!0})},ef=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ky(e))!Hy.call(t,i)&&i!==r&&As(t,i,{get:()=>e[i],enumerable:!(n=jy(e,i))||n.enumerable});return t};var Sn=(t,e,r)=>(r=t!=null?qy(Vy(t)):{},ef(e||!t||!t.__esModule?As(r,"default",{value:t,enumerable:!0}):r,t)),Ky=t=>ef(As({},"__esModule",{value:!0}),t);var tf=L(Xn=>{"use strict";Object.defineProperty(Xn,"__esModule",{value:!0});Xn.decode=Xn.encode=void 0;var Ss="abcdefghijklmnopqrstuvwxyz234567",Zn=Object.create(null);for(let t=0;t<Ss.length;t++)Zn[Ss[t]]=t;Zn[0]=Zn.o;Zn[1]=Zn.i;function Gy(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+=Ss[r>>3],e+=5),0)}for(let s=0;s<t.length;)s+=i(t[s]);return n+(e<0?Ss[r>>3]:"")}Xn.encode=Gy;function Yy(t){let e=0,r=0,n=new Uint8Array(t.length*4/3|0),i=0;function s(o){let a=Zn[o.toLowerCase()];if(a===void 0)throw new Error(`Invalid character: ${JSON.stringify(o)}`);a<<=3,r|=a>>>e,e+=5,e>=8&&(n[i++]=r,e-=8,e>0?r=a<<5-e&255:r=0)}for(let o of t)s(o);return n.slice(0,i)}Xn.decode=Yy});var rf=L(Bs=>{"use strict";Object.defineProperty(Bs,"__esModule",{value:!0});Bs.getCrc32=void 0;var Wy=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 zy(t){let e=new Uint8Array(t),r=-1;for(let n=0;n<e.length;n++){let s=(e[n]^r)&255;r=Wy[s]^r>>>8}return(r^-1)>>>0}Bs.getCrc32=zy});var qa=L(mt=>{"use strict";Object.defineProperty(mt,"__esModule",{value:!0});mt.output=mt.exists=mt.hash=mt.bytes=mt.bool=mt.number=mt.isBytes=void 0;function Os(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}mt.number=Os;function nf(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}mt.bool=nf;function sf(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}mt.isBytes=sf;function Ca(t,...e){if(!sf(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}`)}mt.bytes=Ca;function of(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Os(t.outputLen),Os(t.blockLen)}mt.hash=of;function af(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")}mt.exists=af;function cf(t,e){Ca(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}mt.output=cf;var Dy={number:Os,bool:nf,bytes:Ca,hash:of,exists:af,output:cf};mt.default=Dy});var uf=L(Ps=>{"use strict";Object.defineProperty(Ps,"__esModule",{value:!0});Ps.crypto=void 0;var Ns=Dn("node:crypto");Ps.crypto=Ns&&typeof Ns=="object"&&"webcrypto"in Ns?Ns.webcrypto:void 0});var Bn=L(ye=>{"use strict";Object.defineProperty(ye,"__esModule",{value:!0});ye.randomBytes=ye.wrapXOFConstructorWithOpts=ye.wrapConstructorWithOpts=ye.wrapConstructor=ye.checkOpts=ye.Hash=ye.concatBytes=ye.toBytes=ye.utf8ToBytes=ye.asyncLoop=ye.nextTick=ye.hexToBytes=ye.bytesToHex=ye.byteSwap32=ye.byteSwapIfBE=ye.byteSwap=ye.isLE=ye.rotl=ye.rotr=ye.createView=ye.u32=ye.u8=ye.isBytes=void 0;var ja=uf(),Va=qa();function Zy(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}ye.isBytes=Zy;var Xy=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);ye.u8=Xy;var Jy=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));ye.u32=Jy;var Ly=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);ye.createView=Ly;var Qy=(t,e)=>t<<32-e|t>>>e;ye.rotr=Qy;var em=(t,e)=>t<<e|t>>>32-e>>>0;ye.rotl=em;ye.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var tm=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255;ye.byteSwap=tm;ye.byteSwapIfBE=ye.isLE?t=>t:t=>(0,ye.byteSwap)(t);function rm(t){for(let e=0;e<t.length;e++)t[e]=(0,ye.byteSwap)(t[e])}ye.byteSwap32=rm;var nm=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function im(t){(0,Va.bytes)(t);let e="";for(let r=0;r<t.length;r++)e+=nm[t[r]];return e}ye.bytesToHex=im;var Hr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function lf(t){if(t>=Hr._0&&t<=Hr._9)return t-Hr._0;if(t>=Hr._A&&t<=Hr._F)return t-(Hr._A-10);if(t>=Hr._a&&t<=Hr._f)return t-(Hr._a-10)}function sm(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=lf(t.charCodeAt(s)),a=lf(t.charCodeAt(s+1));if(o===void 0||a===void 0){let c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=o*16+a}return n}ye.hexToBytes=sm;var om=async()=>{};ye.nextTick=om;async function am(t,e,r){let n=Date.now();for(let i=0;i<t;i++){r(i);let s=Date.now()-n;s>=0&&s<e||(await(0,ye.nextTick)(),n+=s)}}ye.asyncLoop=am;function ff(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}ye.utf8ToBytes=ff;function Rs(t){return typeof t=="string"&&(t=ff(t)),(0,Va.bytes)(t),t}ye.toBytes=Rs;function cm(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];(0,Va.bytes)(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}ye.concatBytes=cm;var ka=class{clone(){return this._cloneInto()}};ye.Hash=ka;var um={}.toString;function lm(t,e){if(e!==void 0&&um.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(t,e)}ye.checkOpts=lm;function fm(t){let e=n=>t().update(Rs(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}ye.wrapConstructor=fm;function dm(t){let e=(n,i)=>t(i).update(Rs(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}ye.wrapConstructorWithOpts=dm;function hm(t){let e=(n,i)=>t(i).update(Rs(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}ye.wrapXOFConstructorWithOpts=hm;function pm(t=32){if(ja.crypto&&typeof ja.crypto.getRandomValues=="function")return ja.crypto.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}ye.randomBytes=pm});var Ka=L(Lr=>{"use strict";Object.defineProperty(Lr,"__esModule",{value:!0});Lr.HashMD=Lr.Maj=Lr.Chi=void 0;var Ha=qa(),Mi=Bn();function ym(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let i=BigInt(32),s=BigInt(4294967295),o=Number(r>>i&s),a=Number(r&s),c=n?4:0,f=n?0:4;t.setUint32(e+c,o,n),t.setUint32(e+f,a,n)}var mm=(t,e,r)=>t&e^~t&r;Lr.Chi=mm;var gm=(t,e,r)=>t&e^t&r^e&r;Lr.Maj=gm;var $a=class extends Mi.Hash{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=(0,Mi.createView)(this.buffer)}update(e){(0,Ha.exists)(this);let{view:r,buffer:n,blockLen:i}=this;e=(0,Mi.toBytes)(e);let s=e.length;for(let o=0;o<s;){let a=Math.min(i-this.pos,s-o);if(a===i){let c=(0,Mi.createView)(e);for(;i<=s-o;o+=i)this.process(c,o);continue}n.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,Ha.exists)(this),(0,Ha.output)(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 h=o;h<i;h++)r[h]=0;ym(n,i-8,BigInt(this.length*8),s),this.process(n,0);let a=(0,Mi.createView)(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,d=this.get();if(f>d.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<f;h++)a.setUint32(4*h,d[h],s)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:s,destroyed:o,pos:a}=this;return e.length=i,e.pos=a,e.finished=s,e.destroyed=o,i%r&&e.buffer.set(n),e}};Lr.HashMD=$a});var Us=L(Jn=>{"use strict";Object.defineProperty(Jn,"__esModule",{value:!0});Jn.sha224=Jn.sha256=void 0;var Ga=Ka(),er=Bn(),bm=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]),Qr=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),en=new Uint32Array(64),Is=class extends Ga.HashMD{constructor(){super(64,32,8,!1),this.A=Qr[0]|0,this.B=Qr[1]|0,this.C=Qr[2]|0,this.D=Qr[3]|0,this.E=Qr[4]|0,this.F=Qr[5]|0,this.G=Qr[6]|0,this.H=Qr[7]|0}get(){let{A:e,B:r,C:n,D:i,E:s,F:o,G:a,H:c}=this;return[e,r,n,i,s,o,a,c]}set(e,r,n,i,s,o,a,c){this.A=e|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,r){for(let h=0;h<16;h++,r+=4)en[h]=e.getUint32(r,!1);for(let h=16;h<64;h++){let S=en[h-15],w=en[h-2],u=(0,er.rotr)(S,7)^(0,er.rotr)(S,18)^S>>>3,g=(0,er.rotr)(w,17)^(0,er.rotr)(w,19)^w>>>10;en[h]=g+en[h-7]+u+en[h-16]|0}let{A:n,B:i,C:s,D:o,E:a,F:c,G:f,H:d}=this;for(let h=0;h<64;h++){let S=(0,er.rotr)(a,6)^(0,er.rotr)(a,11)^(0,er.rotr)(a,25),w=d+S+(0,Ga.Chi)(a,c,f)+bm[h]+en[h]|0,g=((0,er.rotr)(n,2)^(0,er.rotr)(n,13)^(0,er.rotr)(n,22))+(0,Ga.Maj)(n,i,s)|0;d=f,f=c,c=a,a=o+w|0,o=s,s=i,i=n,n=w+g|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,d=d+this.H|0,this.set(n,i,s,o,a,c,f,d)}roundClean(){en.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},Ya=class extends Is{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}};Jn.sha256=(0,er.wrapConstructor)(()=>new Is);Jn.sha224=(0,er.wrapConstructor)(()=>new Ya)});var df=L(Fs=>{"use strict";Object.defineProperty(Fs,"__esModule",{value:!0});Fs.sha224=void 0;var _m=Us();function wm(t){return _m.sha224.create().update(new Uint8Array(t)).digest()}Fs.sha224=wm});var Nt=L(_r=>{"use strict";Object.defineProperty(_r,"__esModule",{value:!0});_r.Principal=_r.JSON_KEY_PRINCIPAL=void 0;var hf=tf(),Em=rf(),xm=df();_r.JSON_KEY_PRINCIPAL="__principal__";var vm=2,pf=4,Tm="aaaaa-aa",Am=t=>{var e;return new Uint8Array(((e=t.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(r=>parseInt(r,16)))},Sm=t=>t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),""),Wa=class t{constructor(e){this._arr=e,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([pf]))}static managementCanister(){return this.fromHex(Tm)}static selfAuthenticating(e){let r=(0,xm.sha224)(e);return new this(new Uint8Array([...r,vm]))}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(Am(e))}static fromText(e){let r=e;if(e.includes(_r.JSON_KEY_PRINCIPAL)){let o=JSON.parse(e);_r.JSON_KEY_PRINCIPAL in o&&(r=o[_r.JSON_KEY_PRINCIPAL])}let n=r.toLowerCase().replace(/-/g,""),i=(0,hf.decode)(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]===pf}toUint8Array(){return this._arr}toHex(){return Sm(this._arr).toUpperCase()}toText(){let e=new ArrayBuffer(4);new DataView(e).setUint32(0,(0,Em.getCrc32)(this._arr));let n=new Uint8Array(e),i=Uint8Array.from(this._arr),s=new Uint8Array([...n,...i]),a=(0,hf.encode)(s).match(/.{1,5}/g);if(!a)throw new Error;return a.join("-")}toString(){return this.toText()}toJSON(){return{[_r.JSON_KEY_PRINCIPAL]: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"}};_r.Principal=Wa});var Sf=L(js=>{"use strict";js.byteLength=Rm;js.toByteArray=Um;js.fromByteArray=Cm;var Er=[],tr=[],Pm=typeof Uint8Array<"u"?Uint8Array:Array,Qa="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(On=0,Tf=Qa.length;On<Tf;++On)Er[On]=Qa[On],tr[Qa.charCodeAt(On)]=On;var On,Tf;tr[45]=62;tr[95]=63;function Af(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 Rm(t){var e=Af(t),r=e[0],n=e[1];return(r+n)*3/4-n}function Im(t,e,r){return(e+r)*3/4-r}function Um(t){var e,r=Af(t),n=r[0],i=r[1],s=new Pm(Im(t,n,i)),o=0,a=i>0?n-4:n,c;for(c=0;c<a;c+=4)e=tr[t.charCodeAt(c)]<<18|tr[t.charCodeAt(c+1)]<<12|tr[t.charCodeAt(c+2)]<<6|tr[t.charCodeAt(c+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=tr[t.charCodeAt(c)]<<2|tr[t.charCodeAt(c+1)]>>4,s[o++]=e&255),i===1&&(e=tr[t.charCodeAt(c)]<<10|tr[t.charCodeAt(c+1)]<<4|tr[t.charCodeAt(c+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function Fm(t){return Er[t>>18&63]+Er[t>>12&63]+Er[t>>6&63]+Er[t&63]}function Mm(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(Fm(n));return i.join("")}function Cm(t){for(var e,r=t.length,n=r%3,i=[],s=16383,o=0,a=r-n;o<a;o+=s)i.push(Mm(t,o,o+s>a?a:o+s));return n===1?(e=t[r-1],i.push(Er[e>>2]+Er[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(Er[e>>10]+Er[e>>4&63]+Er[e<<2&63]+"=")),i.join("")}});var tc=L(ec=>{ec.read=function(t,e,r,n,i){var s,o,a=i*8-n-1,c=(1<<a)-1,f=c>>1,d=-7,h=r?i-1:0,S=r?-1:1,w=t[e+h];for(h+=S,s=w&(1<<-d)-1,w>>=-d,d+=a;d>0;s=s*256+t[e+h],h+=S,d-=8);for(o=s&(1<<-d)-1,s>>=-d,d+=n;d>0;o=o*256+t[e+h],h+=S,d-=8);if(s===0)s=1-f;else{if(s===c)return o?NaN:(w?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-f}return(w?-1:1)*o*Math.pow(2,s-n)};ec.write=function(t,e,r,n,i,s){var o,a,c,f=s*8-i-1,d=(1<<f)-1,h=d>>1,S=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=n?0:s-1,u=n?1:-1,g=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=d):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+h>=1?e+=S/c:e+=S*Math.pow(2,1-h),e*c>=2&&(o++,c/=2),o+h>=d?(a=0,o=d):o+h>=1?(a=(e*c-1)*Math.pow(2,i),o=o+h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;t[r+w]=a&255,w+=u,a/=256,i-=8);for(o=o<<i|a,f+=i;f>0;t[r+w]=o&255,w+=u,o/=256,f-=8);t[r+w-u]|=g*128}});var Kf=L(ni=>{"use strict";var rc=Sf(),ti=tc(),Bf=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;ni.Buffer=$;ni.SlowBuffer=$m;ni.INSPECT_MAX_BYTES=50;var ks=2147483647;ni.kMaxLength=ks;$.TYPED_ARRAY_SUPPORT=qm();!$.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 qm(){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($.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 Kr(t){if(t>ks)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,$.prototype),e}function $(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 oc(t)}return Rf(t,e,r)}$.poolSize=8192;function Rf(t,e,r){if(typeof t=="string")return km(t,e);if(ArrayBuffer.isView(t))return Vm(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(xr(t,ArrayBuffer)||t&&xr(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(xr(t,SharedArrayBuffer)||t&&xr(t.buffer,SharedArrayBuffer)))return ic(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 $.from(n,e,r);let i=Hm(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return $.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)}$.from=function(t,e,r){return Rf(t,e,r)};Object.setPrototypeOf($.prototype,Uint8Array.prototype);Object.setPrototypeOf($,Uint8Array);function If(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 jm(t,e,r){return If(t),t<=0?Kr(t):e!==void 0?typeof r=="string"?Kr(t).fill(e,r):Kr(t).fill(e):Kr(t)}$.alloc=function(t,e,r){return jm(t,e,r)};function oc(t){return If(t),Kr(t<0?0:ac(t)|0)}$.allocUnsafe=function(t){return oc(t)};$.allocUnsafeSlow=function(t){return oc(t)};function km(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!$.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=Uf(t,e)|0,n=Kr(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function nc(t){let e=t.length<0?0:ac(t.length)|0,r=Kr(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function Vm(t){if(xr(t,Uint8Array)){let e=new Uint8Array(t);return ic(e.buffer,e.byteOffset,e.byteLength)}return nc(t)}function ic(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,$.prototype),n}function Hm(t){if($.isBuffer(t)){let e=ac(t.length)|0,r=Kr(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||uc(t.length)?Kr(0):nc(t);if(t.type==="Buffer"&&Array.isArray(t.data))return nc(t.data)}function ac(t){if(t>=ks)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ks.toString(16)+" bytes");return t|0}function $m(t){return+t!=t&&(t=0),$.alloc(+t)}$.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==$.prototype};$.compare=function(e,r){if(xr(e,Uint8Array)&&(e=$.from(e,e.offset,e.byteLength)),xr(r,Uint8Array)&&(r=$.from(r,r.offset,r.byteLength)),!$.isBuffer(e)||!$.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};$.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}};$.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return $.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=$.allocUnsafe(r),s=0;for(n=0;n<e.length;++n){let o=e[n];if(xr(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 Uf(t,e){if($.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||xr(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 sc(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return $f(t).length;default:if(i)return n?-1:sc(t).length;e=(""+e).toLowerCase(),i=!0}}$.byteLength=Uf;function Km(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 Qm(this,e,r);case"utf8":case"utf-8":return Mf(this,e,r);case"ascii":return Jm(this,e,r);case"latin1":case"binary":return Lm(this,e,r);case"base64":return Zm(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return eg(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}$.prototype._isBuffer=!0;function Nn(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}$.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)Nn(this,r,r+1);return this};$.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)Nn(this,r,r+3),Nn(this,r+1,r+2);return this};$.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)Nn(this,r,r+7),Nn(this,r+1,r+6),Nn(this,r+2,r+5),Nn(this,r+3,r+4);return this};$.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?Mf(this,0,e):Km.apply(this,arguments)};$.prototype.toLocaleString=$.prototype.toString;$.prototype.equals=function(e){if(!$.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:$.compare(this,e)===0};$.prototype.inspect=function(){let e="",r=ni.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};Bf&&($.prototype[Bf]=$.prototype.inspect);$.prototype.compare=function(e,r,n,i,s){if(xr(e,Uint8Array)&&(e=$.from(e,e.offset,e.byteLength)),!$.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),r<0||n>e.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&r>=n)return 0;if(i>=s)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,s>>>=0,this===e)return 0;let o=s-i,a=n-r,c=Math.min(o,a),f=this.slice(i,s),d=e.slice(r,n);for(let h=0;h<c;++h)if(f[h]!==d[h]){o=f[h],a=d[h];break}return o<a?-1:a<o?1:0};function Ff(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,uc(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=$.from(e,n)),$.isBuffer(e))return e.length===0?-1:Of(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):Of(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Of(t,e,r,n,i){let s=1,o=t.length,a=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;s=2,o/=2,a/=2,r/=2}function c(d,h){return s===1?d[h]:d.readUInt16BE(h*s)}let f;if(i){let d=-1;for(f=r;f<o;f++)if(c(t,f)===c(e,d===-1?0:f-d)){if(d===-1&&(d=f),f-d+1===a)return d*s}else d!==-1&&(f-=f-d),d=-1}else for(r+a>o&&(r=o-a),f=r;f>=0;f--){let d=!0;for(let h=0;h<a;h++)if(c(t,f+h)!==c(e,h)){d=!1;break}if(d)return f}return-1}$.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};$.prototype.indexOf=function(e,r,n){return Ff(this,e,r,n,!0)};$.prototype.lastIndexOf=function(e,r,n){return Ff(this,e,r,n,!1)};function Gm(t,e,r,n){r=Number(r)||0;let i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let s=e.length;n>s/2&&(n=s/2);let o;for(o=0;o<n;++o){let a=parseInt(e.substr(o*2,2),16);if(uc(a))return o;t[r+o]=a}return o}function Ym(t,e,r,n){return Vs(sc(e,t.length-r),t,r,n)}function Wm(t,e,r,n){return Vs(ig(e),t,r,n)}function zm(t,e,r,n){return Vs($f(e),t,r,n)}function Dm(t,e,r,n){return Vs(sg(e,t.length-r),t,r,n)}$.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 Gm(this,e,r,n);case"utf8":case"utf-8":return Ym(this,e,r,n);case"ascii":case"latin1":case"binary":return Wm(this,e,r,n);case"base64":return zm(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Dm(this,e,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 Zm(t,e,r){return e===0&&r===t.length?rc.fromByteArray(t):rc.fromByteArray(t.slice(e,r))}function Mf(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i<r;){let s=t[i],o=null,a=s>239?4:s>223?3:s>191?2:1;if(i+a<=r){let c,f,d,h;switch(a){case 1:s<128&&(o=s);break;case 2:c=t[i+1],(c&192)===128&&(h=(s&31)<<6|c&63,h>127&&(o=h));break;case 3:c=t[i+1],f=t[i+2],(c&192)===128&&(f&192)===128&&(h=(s&15)<<12|(c&63)<<6|f&63,h>2047&&(h<55296||h>57343)&&(o=h));break;case 4:c=t[i+1],f=t[i+2],d=t[i+3],(c&192)===128&&(f&192)===128&&(d&192)===128&&(h=(s&15)<<18|(c&63)<<12|(f&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 Xm(n)}var Nf=4096;function Xm(t){let e=t.length;if(e<=Nf)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Nf));return r}function Jm(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 Lm(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 Qm(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+=og[t[s]];return i}function eg(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}$.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,$.prototype),i};function ft(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")}$.prototype.readUintLE=$.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||ft(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return i};$.prototype.readUintBE=$.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||ft(e,r,this.length);let i=this[e+--r],s=1;for(;r>0&&(s*=256);)i+=this[e+--r]*s;return i};$.prototype.readUint8=$.prototype.readUInt8=function(e,r){return e=e>>>0,r||ft(e,1,this.length),this[e]};$.prototype.readUint16LE=$.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||ft(e,2,this.length),this[e]|this[e+1]<<8};$.prototype.readUint16BE=$.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||ft(e,2,this.length),this[e]<<8|this[e+1]};$.prototype.readUint32LE=$.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||ft(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};$.prototype.readUint32BE=$.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||ft(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};$.prototype.readBigUInt64LE=tn(function(e){e=e>>>0,ri(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Ci(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))});$.prototype.readBigUInt64BE=tn(function(e){e=e>>>0,ri(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Ci(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)});$.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||ft(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};$.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||ft(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};$.prototype.readInt8=function(e,r){return e=e>>>0,r||ft(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};$.prototype.readInt16LE=function(e,r){e=e>>>0,r||ft(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};$.prototype.readInt16BE=function(e,r){e=e>>>0,r||ft(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};$.prototype.readInt32LE=function(e,r){return e=e>>>0,r||ft(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};$.prototype.readInt32BE=function(e,r){return e=e>>>0,r||ft(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};$.prototype.readBigInt64LE=tn(function(e){e=e>>>0,ri(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Ci(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)});$.prototype.readBigInt64BE=tn(function(e){e=e>>>0,ri(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Ci(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)});$.prototype.readFloatLE=function(e,r){return e=e>>>0,r||ft(e,4,this.length),ti.read(this,e,!0,23,4)};$.prototype.readFloatBE=function(e,r){return e=e>>>0,r||ft(e,4,this.length),ti.read(this,e,!1,23,4)};$.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||ft(e,8,this.length),ti.read(this,e,!0,52,8)};$.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||ft(e,8,this.length),ti.read(this,e,!1,52,8)};function qt(t,e,r,n,i,s){if(!$.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")}$.prototype.writeUintLE=$.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;qt(this,e,r,n,a,0)}let s=1,o=0;for(this[r]=e&255;++o<n&&(s*=256);)this[r+o]=e/s&255;return r+n};$.prototype.writeUintBE=$.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;qt(this,e,r,n,a,0)}let s=n-1,o=1;for(this[r+s]=e&255;--s>=0&&(o*=256);)this[r+s]=e/o&255;return r+n};$.prototype.writeUint8=$.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||qt(this,e,r,1,255,0),this[r]=e&255,r+1};$.prototype.writeUint16LE=$.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||qt(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};$.prototype.writeUint16BE=$.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||qt(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};$.prototype.writeUint32LE=$.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||qt(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};$.prototype.writeUint32BE=$.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||qt(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 Cf(t,e,r,n,i){Hf(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 qf(t,e,r,n,i){Hf(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}$.prototype.writeBigUInt64LE=tn(function(e,r=0){return Cf(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});$.prototype.writeBigUInt64BE=tn(function(e,r=0){return qf(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});$.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);qt(this,e,r,n,c-1,-c)}let s=0,o=1,a=0;for(this[r]=e&255;++s<n&&(o*=256);)e<0&&a===0&&this[r+s-1]!==0&&(a=1),this[r+s]=(e/o>>0)-a&255;return r+n};$.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);qt(this,e,r,n,c-1,-c)}let s=n-1,o=1,a=0;for(this[r+s]=e&255;--s>=0&&(o*=256);)e<0&&a===0&&this[r+s+1]!==0&&(a=1),this[r+s]=(e/o>>0)-a&255;return r+n};$.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||qt(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};$.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||qt(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};$.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||qt(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};$.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||qt(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};$.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||qt(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};$.prototype.writeBigInt64LE=tn(function(e,r=0){return Cf(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});$.prototype.writeBigInt64BE=tn(function(e,r=0){return qf(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function jf(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 kf(t,e,r,n,i){return e=+e,r=r>>>0,i||jf(t,e,r,4,34028234663852886e22,-34028234663852886e22),ti.write(t,e,r,n,23,4),r+4}$.prototype.writeFloatLE=function(e,r,n){return kf(this,e,r,!0,n)};$.prototype.writeFloatBE=function(e,r,n){return kf(this,e,r,!1,n)};function Vf(t,e,r,n,i){return e=+e,r=r>>>0,i||jf(t,e,r,8,17976931348623157e292,-17976931348623157e292),ti.write(t,e,r,n,52,8),r+8}$.prototype.writeDoubleLE=function(e,r,n){return Vf(this,e,r,!0,n)};$.prototype.writeDoubleBE=function(e,r,n){return Vf(this,e,r,!1,n)};$.prototype.copy=function(e,r,n,i){if(!$.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};$.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"&&!$.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=$.isBuffer(e)?e:$.from(e,i),a=o.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(s=0;s<n-r;++s)this[s+r]=o[s%a]}return this};var ei={};function cc(t,e,r){ei[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}`}}}cc("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);cc("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);cc("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=Pf(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=Pf(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function Pf(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 tg(t,e,r){ri(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&Ci(e,t.length-(r+1))}function Hf(t,e,r,n,i,s){if(t>r||t<e){let o=typeof e=="bigint"?"n":"",a;throw s>3?e===0||e===BigInt(0)?a=`>= 0${o} and < 2${o} ** ${(s+1)*8}${o}`:a=`>= -(2${o} ** ${(s+1)*8-1}${o}) and < 2 ** ${(s+1)*8-1}${o}`:a=`>= ${e}${o} and <= ${r}${o}`,new ei.ERR_OUT_OF_RANGE("value",a,t)}tg(n,i,s)}function ri(t,e){if(typeof t!="number")throw new ei.ERR_INVALID_ARG_TYPE(e,"number",t)}function Ci(t,e,r){throw Math.floor(t)!==t?(ri(t,r),new ei.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new ei.ERR_BUFFER_OUT_OF_BOUNDS:new ei.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var rg=/[^+/0-9A-Za-z-_]/g;function ng(t){if(t=t.split("=")[0],t=t.trim().replace(rg,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function sc(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 ig(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function sg(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 $f(t){return rc.toByteArray(ng(t))}function Vs(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 xr(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function uc(t){return t!==t}var og=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 tn(t){return typeof BigInt>"u"?ag:t}function ag(){throw new Error("BigInt not supported")}});var Gf=L(qi=>{"use strict";Object.defineProperty(qi,"__esModule",{value:!0});qi.ReplicaRejectCode=void 0;var cg;(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"})(cg=qi.ReplicaRejectCode||(qi.ReplicaRejectCode={}))});var ii=L(Hs=>{"use strict";Object.defineProperty(Hs,"__esModule",{value:!0});Hs.AgentError=void 0;var lc=class t extends Error{constructor(e){super(e),this.message=e,Object.setPrototypeOf(this,t.prototype)}};Hs.AgentError=lc});var Gs=L(jt=>{"use strict";Object.defineProperty(jt,"__esModule",{value:!0});jt.bufFromBufLike=jt.uint8ToBuf=jt.PipeArrayBuffer=jt.fromHexString=jt.toHexString=jt.concat=void 0;function ug(...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}jt.concat=ug;function lg(t){return new Uint8Array(t).reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}jt.toHexString=lg;function fg(t){var e;return new Uint8Array(((e=t.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(r=>parseInt(r,16)))}jt.fromHexString=fg;var fc=class{constructor(e,r=e?.byteLength||0){this._buffer=Ks(e||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return Ks(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}};jt.PipeArrayBuffer=fc;function $s(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}jt.uint8ToBuf=$s;function Ks(t){return t instanceof Uint8Array?$s(t):t instanceof ArrayBuffer?t:Array.isArray(t)?$s(new Uint8Array(t)):"buffer"in t?Ks(t.buffer):$s(new Uint8Array(t))}jt.bufFromBufLike=Ks});var dc=L(Ys=>{"use strict";Object.defineProperty(Ys,"__esModule",{value:!0});Ys.idlLabelToId=void 0;function dg(t){let r=new TextEncoder().encode(t),n=0;for(let i of r)n=(n*223+i)%2**32;return n}function hg(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 dg(t)}Ys.idlLabelToId=hg});var pc=L(Xe=>{"use strict";Object.defineProperty(Xe,"__esModule",{value:!0});Xe.readIntLE=Xe.readUIntLE=Xe.writeIntLE=Xe.writeUIntLE=Xe.slebDecode=Xe.slebEncode=Xe.lebDecode=Xe.lebEncode=Xe.safeReadUint8=Xe.safeRead=void 0;var hc=Gs();function Yf(){throw new Error("unexpected end of buffer")}function Wf(t,e){return t.byteLength<e&&Yf(),t.read(e)}Xe.safeRead=Wf;function Ws(t){let e=t.readUint8();return e===void 0&&Yf(),e}Xe.safeReadUint8=Ws;function pg(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 hc.PipeArrayBuffer(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}Xe.lebEncode=pg;function zf(t){let e=BigInt(1),r=BigInt(0),n;do n=Ws(t),r+=BigInt(n&127).valueOf()*e,e*=BigInt(128);while(n>=128);return r}Xe.lebDecode=zf;function yg(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 hc.PipeArrayBuffer(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}Xe.slebEncode=yg;function mg(t){let e=new Uint8Array(t.buffer),r=0;for(;r<e.byteLength;r++)if(e[r]<128){if(!(e[r]&64))return zf(t);break}let n=new Uint8Array(Wf(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)}Xe.slebDecode=mg;function gg(t,e){if(BigInt(t)<BigInt(0))throw new Error("Cannot write negative values.");return Df(t,e)}Xe.writeUIntLE=gg;function Df(t,e){t=BigInt(t);let r=new hc.PipeArrayBuffer(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}Xe.writeIntLE=Df;function Zf(t,e){let r=BigInt(Ws(t)),n=BigInt(1),i=0;for(;++i<e;){n*=BigInt(256);let s=BigInt(Ws(t));r=r+n*s}return r}Xe.readUIntLE=Zf;function bg(t,e){let r=Zf(t,e),n=BigInt(2)**(BigInt(8)*BigInt(e-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}Xe.readIntLE=bg});var Xf=L(si=>{"use strict";Object.defineProperty(si,"__esModule",{value:!0});si.iexp2=si.ilog2=void 0;function _g(t){let e=BigInt(t);if(t<=0)throw new RangeError("Input must be positive");return e.toString(2).length-1}si.ilog2=_g;function wg(t){let e=BigInt(t);if(t<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<e}si.iexp2=wg});var _c=L(K=>{"use strict";Object.defineProperty(K,"__esModule",{value:!0});K.Variant=K.Record=K.Opt=K.Vec=K.Tuple=K.Principal=K.Nat64=K.Nat32=K.Nat16=K.Nat8=K.Int64=K.Int32=K.Int16=K.Int8=K.Float64=K.Float32=K.Nat=K.Int=K.Text=K.Null=K.Bool=K.Unknown=K.Reserved=K.Empty=K.decode=K.encode=K.ServiceClass=K.FuncClass=K.PrincipalClass=K.RecClass=K.VariantClass=K.TupleClass=K.RecordClass=K.OptClass=K.VecClass=K.FixedNatClass=K.FixedIntClass=K.FloatClass=K.NatClass=K.IntClass=K.TextClass=K.ReservedClass=K.NullClass=K.BoolClass=K.UnknownClass=K.EmptyClass=K.ConstructType=K.PrimitiveType=K.Type=K.Visitor=void 0;K.Service=K.Func=K.Rec=void 0;var Eg=Nt(),Oe=Gs(),vr=dc(),ie=pc(),yc=Xf(),zs="DIDL",Jf=400;function ji(t,e,r){return t.map((n,i)=>r(n,e[i]))}var mc=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=(0,ie.lebEncode)(this._typs.length),r=(0,Oe.concat)(...this._typs);return(0,Oe.concat)(e,r)}indexOf(e){if(!this._idx.has(e))throw new Error("Missing type index for "+e);return(0,ie.slebEncode)(this._idx.get(e)||0)}},gc=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)}};K.Visitor=gc;var oi=class{display(){return this.name}valueToString(e){return Qe(e)}buildTypeTable(e){e.has(this)||this._buildTypeTableImpl(e)}};K.Type=oi;var kt=class extends oi{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){}};K.PrimitiveType=kt;var Ar=class extends oi{checkType(e){if(e instanceof rn){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)}};K.ConstructType=Ar;var Ds=class extends kt{accept(e,r){return e.visitEmpty(this,r)}covariant(e){throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return(0,ie.slebEncode)(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}};K.EmptyClass=Ds;var Zs=class extends oi{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: ${Qe(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 rn?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"}};K.UnknownClass=Zs;var Xs=class extends kt{accept(e,r){return e.visitBool(this,r)}covariant(e){if(typeof e=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}`)}encodeValue(e){return new Uint8Array([e?1:0])}encodeType(){return(0,ie.slebEncode)(-2)}decodeValue(e,r){switch(this.checkType(r),(0,ie.safeReadUint8)(e)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}};K.BoolClass=Xs;var Js=class extends kt{accept(e,r){return e.visitNull(this,r)}covariant(e){if(e===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,ie.slebEncode)(-1)}decodeValue(e,r){return this.checkType(r),null}get name(){return"null"}};K.NullClass=Js;var ai=class extends kt{accept(e,r){return e.visitReserved(this,r)}covariant(e){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,ie.slebEncode)(-16)}decodeValue(e,r){return r.name!==this.name&&r.decodeValue(e,r),null}get name(){return"reserved"}};K.ReservedClass=ai;var Ls=class extends kt{accept(e,r){return e.visitText(this,r)}covariant(e){if(typeof e=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}`)}encodeValue(e){let r=new TextEncoder().encode(e),n=(0,ie.lebEncode)(r.byteLength);return(0,Oe.concat)(n,r)}encodeType(){return(0,ie.slebEncode)(-15)}decodeValue(e,r){this.checkType(r);let n=(0,ie.lebDecode)(e),i=(0,ie.safeRead)(e,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(i)}get name(){return"text"}valueToString(e){return'"'+e+'"'}};K.TextClass=Ls;var Qs=class extends kt{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: ${Qe(e)}`)}encodeValue(e){return(0,ie.slebEncode)(e)}encodeType(){return(0,ie.slebEncode)(-4)}decodeValue(e,r){return this.checkType(r),(0,ie.slebDecode)(e)}get name(){return"int"}valueToString(e){return e.toString()}};K.IntClass=Qs;var eo=class extends kt{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: ${Qe(e)}`)}encodeValue(e){return(0,ie.lebEncode)(e)}encodeType(){return(0,ie.slebEncode)(-3)}decodeValue(e,r){return this.checkType(r),(0,ie.lebDecode)(e)}get name(){return"nat"}valueToString(e){return e.toString()}};K.NatClass=eo;var ki=class extends kt{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: ${Qe(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(0,ie.slebEncode)(e)}decodeValue(e,r){this.checkType(r);let n=(0,ie.safeRead)(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()}};K.FloatClass=ki;var Gr=class extends kt{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedInt(this,r)}covariant(e){let r=(0,yc.iexp2)(this._bits-1)*BigInt(-1),n=(0,yc.iexp2)(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: ${Qe(e)}`)}encodeValue(e){return(0,ie.writeIntLE)(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return(0,ie.slebEncode)(-9-e)}decodeValue(e,r){this.checkType(r);let n=(0,ie.readIntLE)(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(e){return e.toString()}};K.FixedIntClass=Gr;var Tr=class extends kt{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedNat(this,r)}covariant(e){let r=(0,yc.iexp2)(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: ${Qe(e)}`)}encodeValue(e){return(0,ie.writeUIntLE)(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return(0,ie.slebEncode)(-5-e)}decodeValue(e,r){this.checkType(r);let n=(0,ie.readUIntLE)(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(e){return e.toString()}};K.FixedNatClass=Tr;var to=class t extends Ar{constructor(e){super(),this._type=e,this._blobOptimization=!1,e instanceof Tr&&e._bits===8&&(this._blobOptimization=!0)}accept(e,r){return e.visitVec(this,this._type,r)}covariant(e){let r=this._type instanceof Tr?this._type._bits:this._type instanceof Gr?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
+ var Dy=Object.create;var ks=Object.defineProperty;var Zy=Object.getOwnPropertyDescriptor;var Xy=Object.getOwnPropertyNames;var Jy=Object.getPrototypeOf,Ly=Object.prototype.hasOwnProperty;var ei=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var ff=(t,e)=>()=>(t&&(e=t(t=0)),e);var Q=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Qy=(t,e)=>{for(var r in e)ks(t,r,{get:e[r],enumerable:!0})},df=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Xy(e))!Ly.call(t,i)&&i!==r&&ks(t,i,{get:()=>e[i],enumerable:!(n=Zy(e,i))||n.enumerable});return t};var Un=(t,e,r)=>(r=t!=null?Dy(Jy(t)):{},df(e||!t||!t.__esModule?ks(r,"default",{value:t,enumerable:!0}):r,t)),eg=t=>df(ks({},"__esModule",{value:!0}),t);var hf=Q(ri=>{"use strict";Object.defineProperty(ri,"__esModule",{value:!0});ri.decode=ri.encode=void 0;var Hs="abcdefghijklmnopqrstuvwxyz234567",ti=Object.create(null);for(let t=0;t<Hs.length;t++)ti[Hs[t]]=t;ti[0]=ti.o;ti[1]=ti.i;function tg(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+=Hs[r>>3],e+=5),0)}for(let s=0;s<t.length;)s+=i(t[s]);return n+(e<0?Hs[r>>3]:"")}ri.encode=tg;function rg(t){let e=0,r=0,n=new Uint8Array(t.length*4/3|0),i=0;function s(o){let a=ti[o.toLowerCase()];if(a===void 0)throw new Error(`Invalid character: ${JSON.stringify(o)}`);a<<=3,r|=a>>>e,e+=5,e>=8&&(n[i++]=r,e-=8,e>0?r=a<<5-e&255:r=0)}for(let o of t)s(o);return n.slice(0,i)}ri.decode=rg});var pf=Q(Vs=>{"use strict";Object.defineProperty(Vs,"__esModule",{value:!0});Vs.getCrc32=void 0;var ng=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 ig(t){let e=new Uint8Array(t),r=-1;for(let n=0;n<e.length;n++){let s=(e[n]^r)&255;r=ng[s]^r>>>8}return(r^-1)>>>0}Vs.getCrc32=ig});var Ja=Q(xr=>{"use strict";Object.defineProperty(xr,"__esModule",{value:!0});xr.isBytes=gf;xr.number=$s;xr.bool=yf;xr.bytes=Xa;xr.hash=mf;xr.exists=bf;xr.output=_f;function $s(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function yf(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}function gf(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Xa(t,...e){if(!gf(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 mf(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");$s(t.outputLen),$s(t.blockLen)}function bf(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 _f(t,e){Xa(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var sg={number:$s,bool:yf,bytes:Xa,hash:mf,exists:bf,output:_f};xr.default=sg});var wf=Q(Ks=>{"use strict";Object.defineProperty(Ks,"__esModule",{value:!0});Ks.crypto=void 0;var tn=ei("node:crypto");Ks.crypto=tn&&typeof tn=="object"&&"webcrypto"in tn?tn.webcrypto:tn&&typeof tn=="object"&&"randomBytes"in tn?tn:void 0});var Fn=Q(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});we.Hash=we.nextTick=we.byteSwapIfBE=we.byteSwap=we.isLE=we.rotl=we.rotr=we.createView=we.u32=we.u8=void 0;we.isBytes=og;we.byteSwap32=hg;we.bytesToHex=yg;we.hexToBytes=gg;we.asyncLoop=bg;we.utf8ToBytes=xf;we.toBytes=Gs;we.concatBytes=_g;we.checkOpts=Eg;we.wrapConstructor=xg;we.wrapConstructorWithOpts=vg;we.wrapXOFConstructorWithOpts=Tg;we.randomBytes=Ag;var ni=wf(),Qa=Ja();function og(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var ag=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);we.u8=ag;var cg=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));we.u32=cg;var ug=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);we.createView=ug;var lg=(t,e)=>t<<32-e|t>>>e;we.rotr=lg;var fg=(t,e)=>t<<e|t>>>32-e>>>0;we.rotl=fg;we.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var dg=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255;we.byteSwap=dg;we.byteSwapIfBE=we.isLE?t=>t:t=>(0,we.byteSwap)(t);function hg(t){for(let e=0;e<t.length;e++)t[e]=(0,we.byteSwap)(t[e])}var pg=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function yg(t){(0,Qa.bytes)(t);let e="";for(let r=0;r<t.length;r++)e+=pg[t[r]];return e}var Gr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Ef(t){if(t>=Gr._0&&t<=Gr._9)return t-Gr._0;if(t>=Gr._A&&t<=Gr._F)return t-(Gr._A-10);if(t>=Gr._a&&t<=Gr._f)return t-(Gr._a-10)}function gg(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){let o=Ef(t.charCodeAt(s)),a=Ef(t.charCodeAt(s+1));if(o===void 0||a===void 0){let c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=o*16+a}return n}var mg=async()=>{};we.nextTick=mg;async function bg(t,e,r){let n=Date.now();for(let i=0;i<t;i++){r(i);let s=Date.now()-n;s>=0&&s<e||(await(0,we.nextTick)(),n+=s)}}function xf(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Gs(t){return typeof t=="string"&&(t=xf(t)),(0,Qa.bytes)(t),t}function _g(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];(0,Qa.bytes)(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}var La=class{clone(){return this._cloneInto()}};we.Hash=La;var wg={}.toString;function Eg(t,e){if(e!==void 0&&wg.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(t,e)}function xg(t){let e=n=>t().update(Gs(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function vg(t){let e=(n,i)=>t(i).update(Gs(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}function Tg(t){let e=(n,i)=>t(i).update(Gs(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}function Ag(t=32){if(ni.crypto&&typeof ni.crypto.getRandomValues=="function")return ni.crypto.getRandomValues(new Uint8Array(t));if(ni.crypto&&typeof ni.crypto.randomBytes=="function")return ni.crypto.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}});var rc=Q(rn=>{"use strict";Object.defineProperty(rn,"__esModule",{value:!0});rn.HashMD=rn.Maj=rn.Chi=void 0;var ec=Ja(),Vi=Fn();function Sg(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let i=BigInt(32),s=BigInt(4294967295),o=Number(r>>i&s),a=Number(r&s),c=n?4:0,f=n?0:4;t.setUint32(e+c,o,n),t.setUint32(e+f,a,n)}var Bg=(t,e,r)=>t&e^~t&r;rn.Chi=Bg;var Og=(t,e,r)=>t&e^t&r^e&r;rn.Maj=Og;var tc=class extends Vi.Hash{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=(0,Vi.createView)(this.buffer)}update(e){(0,ec.exists)(this);let{view:r,buffer:n,blockLen:i}=this;e=(0,Vi.toBytes)(e);let s=e.length;for(let o=0;o<s;){let a=Math.min(i-this.pos,s-o);if(a===i){let c=(0,Vi.createView)(e);for(;i<=s-o;o+=i)this.process(c,o);continue}n.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,ec.exists)(this),(0,ec.output)(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 h=o;h<i;h++)r[h]=0;Sg(n,i-8,BigInt(this.length*8),s),this.process(n,0);let a=(0,Vi.createView)(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,d=this.get();if(f>d.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<f;h++)a.setUint32(4*h,d[h],s)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:s,destroyed:o,pos:a}=this;return e.length=i,e.pos=a,e.finished=s,e.destroyed=o,i%r&&e.buffer.set(n),e}};rn.HashMD=tc});var Ys=Q(on=>{"use strict";Object.defineProperty(on,"__esModule",{value:!0});on.sha224=on.sha256=on.SHA256=void 0;var nc=rc(),er=Fn(),Ng=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]),nn=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),sn=new Uint32Array(64),$i=class extends nc.HashMD{constructor(){super(64,32,8,!1),this.A=nn[0]|0,this.B=nn[1]|0,this.C=nn[2]|0,this.D=nn[3]|0,this.E=nn[4]|0,this.F=nn[5]|0,this.G=nn[6]|0,this.H=nn[7]|0}get(){let{A:e,B:r,C:n,D:i,E:s,F:o,G:a,H:c}=this;return[e,r,n,i,s,o,a,c]}set(e,r,n,i,s,o,a,c){this.A=e|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,r){for(let h=0;h<16;h++,r+=4)sn[h]=e.getUint32(r,!1);for(let h=16;h<64;h++){let m=sn[h-15],_=sn[h-2],u=(0,er.rotr)(m,7)^(0,er.rotr)(m,18)^m>>>3,T=(0,er.rotr)(_,17)^(0,er.rotr)(_,19)^_>>>10;sn[h]=T+sn[h-7]+u+sn[h-16]|0}let{A:n,B:i,C:s,D:o,E:a,F:c,G:f,H:d}=this;for(let h=0;h<64;h++){let m=(0,er.rotr)(a,6)^(0,er.rotr)(a,11)^(0,er.rotr)(a,25),_=d+m+(0,nc.Chi)(a,c,f)+Ng[h]+sn[h]|0,T=((0,er.rotr)(n,2)^(0,er.rotr)(n,13)^(0,er.rotr)(n,22))+(0,nc.Maj)(n,i,s)|0;d=f,f=c,c=a,a=o+_|0,o=s,s=i,i=n,n=_+T|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,d=d+this.H|0,this.set(n,i,s,o,a,c,f,d)}roundClean(){sn.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};on.SHA256=$i;var ic=class extends $i{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}};on.sha256=(0,er.wrapConstructor)(()=>new $i);on.sha224=(0,er.wrapConstructor)(()=>new ic)});var vf=Q(Ws=>{"use strict";Object.defineProperty(Ws,"__esModule",{value:!0});Ws.sha224=void 0;var Rg=Ys();function Pg(t){return Rg.sha224.create().update(new Uint8Array(t)).digest()}Ws.sha224=Pg});var Tt=Q(vr=>{"use strict";Object.defineProperty(vr,"__esModule",{value:!0});vr.Principal=vr.JSON_KEY_PRINCIPAL=void 0;var Tf=hf(),Ig=pf(),Ug=vf();vr.JSON_KEY_PRINCIPAL="__principal__";var Fg=2,Af=4,Mg="aaaaa-aa",qg=t=>{var e;return new Uint8Array(((e=t.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(r=>parseInt(r,16)))},Cg=t=>t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),""),sc=class t{constructor(e){this._arr=e,this._isPrincipal=!0}static anonymous(){return new this(new Uint8Array([Af]))}static managementCanister(){return this.fromHex(Mg)}static selfAuthenticating(e){let r=(0,Ug.sha224)(e);return new this(new Uint8Array([...r,Fg]))}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(qg(e))}static fromText(e){let r=e;if(e.includes(vr.JSON_KEY_PRINCIPAL)){let o=JSON.parse(e);vr.JSON_KEY_PRINCIPAL in o&&(r=o[vr.JSON_KEY_PRINCIPAL])}let n=r.toLowerCase().replace(/-/g,""),i=(0,Tf.decode)(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]===Af}toUint8Array(){return this._arr}toHex(){return Cg(this._arr).toUpperCase()}toText(){let e=new ArrayBuffer(4);new DataView(e).setUint32(0,(0,Ig.getCrc32)(this._arr));let n=new Uint8Array(e),i=Uint8Array.from(this._arr),s=new Uint8Array([...n,...i]),a=(0,Tf.encode)(s).match(/.{1,5}/g);if(!a)throw new Error;return a.join("-")}toString(){return this.toText()}toJSON(){return{[vr.JSON_KEY_PRINCIPAL]: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"}};vr.Principal=sc});var Cf=Q(Xs=>{"use strict";Xs.byteLength=$g;Xs.toByteArray=Gg;Xs.fromByteArray=zg;var Ar=[],tr=[],Vg=typeof Uint8Array<"u"?Uint8Array:Array,dc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Mn=0,Mf=dc.length;Mn<Mf;++Mn)Ar[Mn]=dc[Mn],tr[dc.charCodeAt(Mn)]=Mn;var Mn,Mf;tr[45]=62;tr[95]=63;function qf(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 $g(t){var e=qf(t),r=e[0],n=e[1];return(r+n)*3/4-n}function Kg(t,e,r){return(e+r)*3/4-r}function Gg(t){var e,r=qf(t),n=r[0],i=r[1],s=new Vg(Kg(t,n,i)),o=0,a=i>0?n-4:n,c;for(c=0;c<a;c+=4)e=tr[t.charCodeAt(c)]<<18|tr[t.charCodeAt(c+1)]<<12|tr[t.charCodeAt(c+2)]<<6|tr[t.charCodeAt(c+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=tr[t.charCodeAt(c)]<<2|tr[t.charCodeAt(c+1)]>>4,s[o++]=e&255),i===1&&(e=tr[t.charCodeAt(c)]<<10|tr[t.charCodeAt(c+1)]<<4|tr[t.charCodeAt(c+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function Yg(t){return Ar[t>>18&63]+Ar[t>>12&63]+Ar[t>>6&63]+Ar[t&63]}function Wg(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(Yg(n));return i.join("")}function zg(t){for(var e,r=t.length,n=r%3,i=[],s=16383,o=0,a=r-n;o<a;o+=s)i.push(Wg(t,o,o+s>a?a:o+s));return n===1?(e=t[r-1],i.push(Ar[e>>2]+Ar[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(Ar[e>>10]+Ar[e>>4&63]+Ar[e<<2&63]+"=")),i.join("")}});var pc=Q(hc=>{hc.read=function(t,e,r,n,i){var s,o,a=i*8-n-1,c=(1<<a)-1,f=c>>1,d=-7,h=r?i-1:0,m=r?-1:1,_=t[e+h];for(h+=m,s=_&(1<<-d)-1,_>>=-d,d+=a;d>0;s=s*256+t[e+h],h+=m,d-=8);for(o=s&(1<<-d)-1,s>>=-d,d+=n;d>0;o=o*256+t[e+h],h+=m,d-=8);if(s===0)s=1-f;else{if(s===c)return o?NaN:(_?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-f}return(_?-1:1)*o*Math.pow(2,s-n)};hc.write=function(t,e,r,n,i,s){var o,a,c,f=s*8-i-1,d=(1<<f)-1,h=d>>1,m=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,_=n?0:s-1,u=n?1:-1,T=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=d):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+h>=1?e+=m/c:e+=m*Math.pow(2,1-h),e*c>=2&&(o++,c/=2),o+h>=d?(a=0,o=d):o+h>=1?(a=(e*c-1)*Math.pow(2,i),o=o+h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;t[r+_]=a&255,_+=u,a/=256,i-=8);for(o=o<<i|a,f+=i;f>0;t[r+_]=o&255,_+=u,o/=256,f-=8);t[r+_-u]|=T*128}});var ed=Q(ui=>{"use strict";var yc=Cf(),ai=pc(),jf=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;ui.Buffer=G;ui.SlowBuffer=Qg;ui.INSPECT_MAX_BYTES=50;var Js=2147483647;ui.kMaxLength=Js;G.TYPED_ARRAY_SUPPORT=Dg();!G.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 Dg(){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(G.prototype,"parent",{enumerable:!0,get:function(){if(G.isBuffer(this))return this.buffer}});Object.defineProperty(G.prototype,"offset",{enumerable:!0,get:function(){if(G.isBuffer(this))return this.byteOffset}});function Wr(t){if(t>Js)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,G.prototype),e}function G(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 _c(t)}return $f(t,e,r)}G.poolSize=8192;function $f(t,e,r){if(typeof t=="string")return Xg(t,e);if(ArrayBuffer.isView(t))return Jg(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(Sr(t,ArrayBuffer)||t&&Sr(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Sr(t,SharedArrayBuffer)||t&&Sr(t.buffer,SharedArrayBuffer)))return mc(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 G.from(n,e,r);let i=Lg(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return G.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)}G.from=function(t,e,r){return $f(t,e,r)};Object.setPrototypeOf(G.prototype,Uint8Array.prototype);Object.setPrototypeOf(G,Uint8Array);function Kf(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 Zg(t,e,r){return Kf(t),t<=0?Wr(t):e!==void 0?typeof r=="string"?Wr(t).fill(e,r):Wr(t).fill(e):Wr(t)}G.alloc=function(t,e,r){return Zg(t,e,r)};function _c(t){return Kf(t),Wr(t<0?0:wc(t)|0)}G.allocUnsafe=function(t){return _c(t)};G.allocUnsafeSlow=function(t){return _c(t)};function Xg(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!G.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=Gf(t,e)|0,n=Wr(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function gc(t){let e=t.length<0?0:wc(t.length)|0,r=Wr(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function Jg(t){if(Sr(t,Uint8Array)){let e=new Uint8Array(t);return mc(e.buffer,e.byteOffset,e.byteLength)}return gc(t)}function mc(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,G.prototype),n}function Lg(t){if(G.isBuffer(t)){let e=wc(t.length)|0,r=Wr(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||xc(t.length)?Wr(0):gc(t);if(t.type==="Buffer"&&Array.isArray(t.data))return gc(t.data)}function wc(t){if(t>=Js)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Js.toString(16)+" bytes");return t|0}function Qg(t){return+t!=t&&(t=0),G.alloc(+t)}G.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==G.prototype};G.compare=function(e,r){if(Sr(e,Uint8Array)&&(e=G.from(e,e.offset,e.byteLength)),Sr(r,Uint8Array)&&(r=G.from(r,r.offset,r.byteLength)),!G.isBuffer(e)||!G.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};G.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}};G.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return G.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=G.allocUnsafe(r),s=0;for(n=0;n<e.length;++n){let o=e[n];if(Sr(o,Uint8Array))s+o.length>i.length?(G.isBuffer(o)||(o=G.from(o)),o.copy(i,s)):Uint8Array.prototype.set.call(i,o,s);else if(G.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function Gf(t,e){if(G.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Sr(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 bc(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Qf(t).length;default:if(i)return n?-1:bc(t).length;e=(""+e).toLowerCase(),i=!0}}G.byteLength=Gf;function em(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 lm(this,e,r);case"utf8":case"utf-8":return Wf(this,e,r);case"ascii":return cm(this,e,r);case"latin1":case"binary":return um(this,e,r);case"base64":return om(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fm(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}G.prototype._isBuffer=!0;function qn(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}G.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)qn(this,r,r+1);return this};G.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)qn(this,r,r+3),qn(this,r+1,r+2);return this};G.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)qn(this,r,r+7),qn(this,r+1,r+6),qn(this,r+2,r+5),qn(this,r+3,r+4);return this};G.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?Wf(this,0,e):em.apply(this,arguments)};G.prototype.toLocaleString=G.prototype.toString;G.prototype.equals=function(e){if(!G.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:G.compare(this,e)===0};G.prototype.inspect=function(){let e="",r=ui.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};jf&&(G.prototype[jf]=G.prototype.inspect);G.prototype.compare=function(e,r,n,i,s){if(Sr(e,Uint8Array)&&(e=G.from(e,e.offset,e.byteLength)),!G.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),r<0||n>e.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&r>=n)return 0;if(i>=s)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,s>>>=0,this===e)return 0;let o=s-i,a=n-r,c=Math.min(o,a),f=this.slice(i,s),d=e.slice(r,n);for(let h=0;h<c;++h)if(f[h]!==d[h]){o=f[h],a=d[h];break}return o<a?-1:a<o?1:0};function Yf(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,xc(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=G.from(e,n)),G.isBuffer(e))return e.length===0?-1:kf(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):kf(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function kf(t,e,r,n,i){let s=1,o=t.length,a=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;s=2,o/=2,a/=2,r/=2}function c(d,h){return s===1?d[h]:d.readUInt16BE(h*s)}let f;if(i){let d=-1;for(f=r;f<o;f++)if(c(t,f)===c(e,d===-1?0:f-d)){if(d===-1&&(d=f),f-d+1===a)return d*s}else d!==-1&&(f-=f-d),d=-1}else for(r+a>o&&(r=o-a),f=r;f>=0;f--){let d=!0;for(let h=0;h<a;h++)if(c(t,f+h)!==c(e,h)){d=!1;break}if(d)return f}return-1}G.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};G.prototype.indexOf=function(e,r,n){return Yf(this,e,r,n,!0)};G.prototype.lastIndexOf=function(e,r,n){return Yf(this,e,r,n,!1)};function tm(t,e,r,n){r=Number(r)||0;let i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let s=e.length;n>s/2&&(n=s/2);let o;for(o=0;o<n;++o){let a=parseInt(e.substr(o*2,2),16);if(xc(a))return o;t[r+o]=a}return o}function rm(t,e,r,n){return Ls(bc(e,t.length-r),t,r,n)}function nm(t,e,r,n){return Ls(ym(e),t,r,n)}function im(t,e,r,n){return Ls(Qf(e),t,r,n)}function sm(t,e,r,n){return Ls(gm(e,t.length-r),t,r,n)}G.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 tm(this,e,r,n);case"utf8":case"utf-8":return rm(this,e,r,n);case"ascii":case"latin1":case"binary":return nm(this,e,r,n);case"base64":return im(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return sm(this,e,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};G.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function om(t,e,r){return e===0&&r===t.length?yc.fromByteArray(t):yc.fromByteArray(t.slice(e,r))}function Wf(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i<r;){let s=t[i],o=null,a=s>239?4:s>223?3:s>191?2:1;if(i+a<=r){let c,f,d,h;switch(a){case 1:s<128&&(o=s);break;case 2:c=t[i+1],(c&192)===128&&(h=(s&31)<<6|c&63,h>127&&(o=h));break;case 3:c=t[i+1],f=t[i+2],(c&192)===128&&(f&192)===128&&(h=(s&15)<<12|(c&63)<<6|f&63,h>2047&&(h<55296||h>57343)&&(o=h));break;case 4:c=t[i+1],f=t[i+2],d=t[i+3],(c&192)===128&&(f&192)===128&&(d&192)===128&&(h=(s&15)<<18|(c&63)<<12|(f&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 am(n)}var Hf=4096;function am(t){let e=t.length;if(e<=Hf)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Hf));return r}function cm(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 um(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 lm(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+=mm[t[s]];return i}function fm(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}G.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,G.prototype),i};function ft(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")}G.prototype.readUintLE=G.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||ft(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return i};G.prototype.readUintBE=G.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||ft(e,r,this.length);let i=this[e+--r],s=1;for(;r>0&&(s*=256);)i+=this[e+--r]*s;return i};G.prototype.readUint8=G.prototype.readUInt8=function(e,r){return e=e>>>0,r||ft(e,1,this.length),this[e]};G.prototype.readUint16LE=G.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||ft(e,2,this.length),this[e]|this[e+1]<<8};G.prototype.readUint16BE=G.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||ft(e,2,this.length),this[e]<<8|this[e+1]};G.prototype.readUint32LE=G.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||ft(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};G.prototype.readUint32BE=G.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||ft(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};G.prototype.readBigUInt64LE=an(function(e){e=e>>>0,ci(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Ki(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))});G.prototype.readBigUInt64BE=an(function(e){e=e>>>0,ci(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Ki(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)});G.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||ft(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};G.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||ft(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};G.prototype.readInt8=function(e,r){return e=e>>>0,r||ft(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};G.prototype.readInt16LE=function(e,r){e=e>>>0,r||ft(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};G.prototype.readInt16BE=function(e,r){e=e>>>0,r||ft(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};G.prototype.readInt32LE=function(e,r){return e=e>>>0,r||ft(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};G.prototype.readInt32BE=function(e,r){return e=e>>>0,r||ft(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};G.prototype.readBigInt64LE=an(function(e){e=e>>>0,ci(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Ki(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)});G.prototype.readBigInt64BE=an(function(e){e=e>>>0,ci(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Ki(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)});G.prototype.readFloatLE=function(e,r){return e=e>>>0,r||ft(e,4,this.length),ai.read(this,e,!0,23,4)};G.prototype.readFloatBE=function(e,r){return e=e>>>0,r||ft(e,4,this.length),ai.read(this,e,!1,23,4)};G.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||ft(e,8,this.length),ai.read(this,e,!0,52,8)};G.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||ft(e,8,this.length),ai.read(this,e,!1,52,8)};function kt(t,e,r,n,i,s){if(!G.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")}G.prototype.writeUintLE=G.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;kt(this,e,r,n,a,0)}let s=1,o=0;for(this[r]=e&255;++o<n&&(s*=256);)this[r+o]=e/s&255;return r+n};G.prototype.writeUintBE=G.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;kt(this,e,r,n,a,0)}let s=n-1,o=1;for(this[r+s]=e&255;--s>=0&&(o*=256);)this[r+s]=e/o&255;return r+n};G.prototype.writeUint8=G.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||kt(this,e,r,1,255,0),this[r]=e&255,r+1};G.prototype.writeUint16LE=G.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||kt(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};G.prototype.writeUint16BE=G.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||kt(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};G.prototype.writeUint32LE=G.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||kt(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};G.prototype.writeUint32BE=G.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||kt(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 zf(t,e,r,n,i){Lf(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 Df(t,e,r,n,i){Lf(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}G.prototype.writeBigUInt64LE=an(function(e,r=0){return zf(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});G.prototype.writeBigUInt64BE=an(function(e,r=0){return Df(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});G.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);kt(this,e,r,n,c-1,-c)}let s=0,o=1,a=0;for(this[r]=e&255;++s<n&&(o*=256);)e<0&&a===0&&this[r+s-1]!==0&&(a=1),this[r+s]=(e/o>>0)-a&255;return r+n};G.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);kt(this,e,r,n,c-1,-c)}let s=n-1,o=1,a=0;for(this[r+s]=e&255;--s>=0&&(o*=256);)e<0&&a===0&&this[r+s+1]!==0&&(a=1),this[r+s]=(e/o>>0)-a&255;return r+n};G.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||kt(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};G.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||kt(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};G.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||kt(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};G.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||kt(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};G.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||kt(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};G.prototype.writeBigInt64LE=an(function(e,r=0){return zf(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});G.prototype.writeBigInt64BE=an(function(e,r=0){return Df(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Zf(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 Xf(t,e,r,n,i){return e=+e,r=r>>>0,i||Zf(t,e,r,4,34028234663852886e22,-34028234663852886e22),ai.write(t,e,r,n,23,4),r+4}G.prototype.writeFloatLE=function(e,r,n){return Xf(this,e,r,!0,n)};G.prototype.writeFloatBE=function(e,r,n){return Xf(this,e,r,!1,n)};function Jf(t,e,r,n,i){return e=+e,r=r>>>0,i||Zf(t,e,r,8,17976931348623157e292,-17976931348623157e292),ai.write(t,e,r,n,52,8),r+8}G.prototype.writeDoubleLE=function(e,r,n){return Jf(this,e,r,!0,n)};G.prototype.writeDoubleBE=function(e,r,n){return Jf(this,e,r,!1,n)};G.prototype.copy=function(e,r,n,i){if(!G.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};G.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"&&!G.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=G.isBuffer(e)?e:G.from(e,i),a=o.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(s=0;s<n-r;++s)this[s+r]=o[s%a]}return this};var oi={};function Ec(t,e,r){oi[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}`}}}Ec("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Ec("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);Ec("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=Vf(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=Vf(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function Vf(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 dm(t,e,r){ci(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&Ki(e,t.length-(r+1))}function Lf(t,e,r,n,i,s){if(t>r||t<e){let o=typeof e=="bigint"?"n":"",a;throw s>3?e===0||e===BigInt(0)?a=`>= 0${o} and < 2${o} ** ${(s+1)*8}${o}`:a=`>= -(2${o} ** ${(s+1)*8-1}${o}) and < 2 ** ${(s+1)*8-1}${o}`:a=`>= ${e}${o} and <= ${r}${o}`,new oi.ERR_OUT_OF_RANGE("value",a,t)}dm(n,i,s)}function ci(t,e){if(typeof t!="number")throw new oi.ERR_INVALID_ARG_TYPE(e,"number",t)}function Ki(t,e,r){throw Math.floor(t)!==t?(ci(t,r),new oi.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new oi.ERR_BUFFER_OUT_OF_BOUNDS:new oi.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var hm=/[^+/0-9A-Za-z-_]/g;function pm(t){if(t=t.split("=")[0],t=t.trim().replace(hm,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function bc(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 ym(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function gm(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 Qf(t){return yc.toByteArray(pm(t))}function Ls(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 Sr(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function xc(t){return t!==t}var mm=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 an(t){return typeof BigInt>"u"?bm:t}function bm(){throw new Error("BigInt not supported")}});var vc=Q(Gi=>{"use strict";Object.defineProperty(Gi,"__esModule",{value:!0});Gi.ReplicaRejectCode=void 0;var _m;(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"})(_m=Gi.ReplicaRejectCode||(Gi.ReplicaRejectCode={}))});var Ht=Q(At=>{"use strict";Object.defineProperty(At,"__esModule",{value:!0});At.bufFromBufLike=At.uint8ToBuf=At.bufEquals=At.compare=At.fromHex=At.toHex=At.concat=void 0;function wm(...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}At.concat=wm;function Em(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}At.toHex=Em;var xm=new RegExp(/^[0-9a-fA-F]+$/);function vm(t){if(!xm.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}At.fromHex=vm;function td(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}At.compare=td;function Tm(t,e){return td(t,e)===0}At.bufEquals=Tm;function Qs(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}At.uint8ToBuf=Qs;function rd(t){return t instanceof Uint8Array?Qs(t):t instanceof ArrayBuffer?t:Array.isArray(t)?Qs(new Uint8Array(t)):"buffer"in t?rd(t.buffer):Qs(new Uint8Array(t))}At.bufFromBufLike=rd});var li=Q(Br=>{"use strict";Object.defineProperty(Br,"__esModule",{value:!0});Br.UpdateCallRejectedError=Br.QueryCallRejectedError=Br.ActorCallError=Br.AgentError=void 0;var Sc=Tt(),Am=vc(),Sm=Ht(),eo=class t extends Error{constructor(e){super(e),this.message=e,this.name="AgentError",this.__proto__=t.prototype,Object.setPrototypeOf(this,t.prototype)}};Br.AgentError=eo;var Yi=class t extends eo{constructor(e,r,n,i){let s=Sc.Principal.from(e);super(["Call failed:",` Canister: ${s.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(i).map(o=>` "${o}": ${JSON.stringify(i[o])}`)].join(`
4
+ `)),this.canisterId=e,this.methodName=r,this.type=n,this.props=i,this.name="ActorCallError",this.__proto__=t.prototype,Object.setPrototypeOf(this,t.prototype)}};Br.ActorCallError=Yi;var Tc=class t extends Yi{constructor(e,r,n){var i;let s=Sc.Principal.from(e);super(s,r,"query",{Status:n.status,Code:(i=Am.ReplicaRejectCode[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n,this.name="QueryCallRejectedError",this.__proto__=t.prototype,Object.setPrototypeOf(this,t.prototype)}};Br.QueryCallRejectedError=Tc;var Ac=class t extends Yi{constructor(e,r,n,i){let s=Sc.Principal.from(e);super(s,r,"update",Object.assign({"Request ID":(0,Sm.toHex)(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,this.name="UpdateCallRejectedError",this.__proto__=t.prototype,Object.setPrototypeOf(this,t.prototype)}};Br.UpdateCallRejectedError=Ac});var no=Q(Vt=>{"use strict";Object.defineProperty(Vt,"__esModule",{value:!0});Vt.bufFromBufLike=Vt.uint8ToBuf=Vt.PipeArrayBuffer=Vt.fromHexString=Vt.toHexString=Vt.concat=void 0;function Bm(...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}Vt.concat=Bm;function Om(t){return new Uint8Array(t).reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}Vt.toHexString=Om;function Nm(t){var e;return new Uint8Array(((e=t.match(/.{1,2}/g))!==null&&e!==void 0?e:[]).map(r=>parseInt(r,16)))}Vt.fromHexString=Nm;var Bc=class{constructor(e,r=e?.byteLength||0){this._buffer=ro(e||new ArrayBuffer(0)),this._view=new Uint8Array(this._buffer,0,r)}get buffer(){return ro(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}};Vt.PipeArrayBuffer=Bc;function to(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}Vt.uint8ToBuf=to;function ro(t){return t instanceof Uint8Array?to(t):t instanceof ArrayBuffer?t:Array.isArray(t)?to(new Uint8Array(t)):"buffer"in t?ro(t.buffer):to(new Uint8Array(t))}Vt.bufFromBufLike=ro});var Oc=Q(io=>{"use strict";Object.defineProperty(io,"__esModule",{value:!0});io.idlLabelToId=void 0;function Rm(t){let r=new TextEncoder().encode(t),n=0;for(let i of r)n=(n*223+i)%2**32;return n}function Pm(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 Rm(t)}io.idlLabelToId=Pm});var Rc=Q(Je=>{"use strict";Object.defineProperty(Je,"__esModule",{value:!0});Je.readIntLE=Je.readUIntLE=Je.writeIntLE=Je.writeUIntLE=Je.slebDecode=Je.slebEncode=Je.lebDecode=Je.lebEncode=Je.safeReadUint8=Je.safeRead=void 0;var Nc=no();function nd(){throw new Error("unexpected end of buffer")}function id(t,e){return t.byteLength<e&&nd(),t.read(e)}Je.safeRead=id;function so(t){let e=t.readUint8();return e===void 0&&nd(),e}Je.safeReadUint8=so;function Im(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 Nc.PipeArrayBuffer(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}Je.lebEncode=Im;function sd(t){let e=BigInt(1),r=BigInt(0),n;do n=so(t),r+=BigInt(n&127).valueOf()*e,e*=BigInt(128);while(n>=128);return r}Je.lebDecode=sd;function Um(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 Nc.PipeArrayBuffer(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}Je.slebEncode=Um;function Fm(t){let e=new Uint8Array(t.buffer),r=0;for(;r<e.byteLength;r++)if(e[r]<128){if(!(e[r]&64))return sd(t);break}let n=new Uint8Array(id(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)}Je.slebDecode=Fm;function Mm(t,e){if(BigInt(t)<BigInt(0))throw new Error("Cannot write negative values.");return od(t,e)}Je.writeUIntLE=Mm;function od(t,e){t=BigInt(t);let r=new Nc.PipeArrayBuffer(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}Je.writeIntLE=od;function ad(t,e){let r=BigInt(so(t)),n=BigInt(1),i=0;for(;++i<e;){n*=BigInt(256);let s=BigInt(so(t));r=r+n*s}return r}Je.readUIntLE=ad;function qm(t,e){let r=ad(t,e),n=BigInt(2)**(BigInt(8)*BigInt(e-1)+BigInt(7));return r>=n&&(r-=n*BigInt(2)),r}Je.readIntLE=qm});var cd=Q(fi=>{"use strict";Object.defineProperty(fi,"__esModule",{value:!0});fi.iexp2=fi.ilog2=void 0;function Cm(t){let e=BigInt(t);if(t<=0)throw new RangeError("Input must be positive");return e.toString(2).length-1}fi.ilog2=Cm;function jm(t){let e=BigInt(t);if(t<0)throw new RangeError("Input must be non-negative");return BigInt(1)<<e}fi.iexp2=jm});var Mc=Q(Y=>{"use strict";Object.defineProperty(Y,"__esModule",{value:!0});Y.Variant=Y.Record=Y.Opt=Y.Vec=Y.Tuple=Y.Principal=Y.Nat64=Y.Nat32=Y.Nat16=Y.Nat8=Y.Int64=Y.Int32=Y.Int16=Y.Int8=Y.Float64=Y.Float32=Y.Nat=Y.Int=Y.Text=Y.Null=Y.Bool=Y.Unknown=Y.Reserved=Y.Empty=Y.decode=Y.encode=Y.ServiceClass=Y.FuncClass=Y.PrincipalClass=Y.RecClass=Y.VariantClass=Y.TupleClass=Y.RecordClass=Y.OptClass=Y.VecClass=Y.FixedNatClass=Y.FixedIntClass=Y.FloatClass=Y.NatClass=Y.IntClass=Y.TextClass=Y.ReservedClass=Y.NullClass=Y.BoolClass=Y.UnknownClass=Y.EmptyClass=Y.ConstructType=Y.PrimitiveType=Y.Type=Y.Visitor=void 0;Y.Service=Y.Func=Y.Rec=void 0;var km=Tt(),Ne=no(),Or=Oc(),se=Rc(),Pc=cd(),oo="DIDL",ud=400;function Wi(t,e,r){return t.map((n,i)=>r(n,e[i]))}var Ic=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=(0,se.lebEncode)(this._typs.length),r=(0,Ne.concat)(...this._typs);return(0,Ne.concat)(e,r)}indexOf(e){if(!this._idx.has(e))throw new Error("Missing type index for "+e);return(0,se.slebEncode)(this._idx.get(e)||0)}},Uc=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)}};Y.Visitor=Uc;var di=class{display(){return this.name}valueToString(e){return et(e)}buildTypeTable(e){e.has(this)||this._buildTypeTableImpl(e)}};Y.Type=di;var $t=class extends di{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){}};Y.PrimitiveType=$t;var Rr=class extends di{checkType(e){if(e instanceof cn){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)}};Y.ConstructType=Rr;var ao=class extends $t{accept(e,r){return e.visitEmpty(this,r)}covariant(e){throw new Error(`Invalid ${this.display()} argument: ${et(e)}`)}encodeValue(){throw new Error("Empty cannot appear as a function argument")}valueToString(){throw new Error("Empty cannot appear as a value")}encodeType(){return(0,se.slebEncode)(-17)}decodeValue(){throw new Error("Empty cannot appear as an output")}get name(){return"empty"}};Y.EmptyClass=ao;var co=class extends di{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: ${et(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 cn?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"}};Y.UnknownClass=co;var uo=class extends $t{accept(e,r){return e.visitBool(this,r)}covariant(e){if(typeof e=="boolean")return!0;throw new Error(`Invalid ${this.display()} argument: ${et(e)}`)}encodeValue(e){return new Uint8Array([e?1:0])}encodeType(){return(0,se.slebEncode)(-2)}decodeValue(e,r){switch(this.checkType(r),(0,se.safeReadUint8)(e)){case 0:return!1;case 1:return!0;default:throw new Error("Boolean value out of range")}}get name(){return"bool"}};Y.BoolClass=uo;var lo=class extends $t{accept(e,r){return e.visitNull(this,r)}covariant(e){if(e===null)return!0;throw new Error(`Invalid ${this.display()} argument: ${et(e)}`)}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,se.slebEncode)(-1)}decodeValue(e,r){return this.checkType(r),null}get name(){return"null"}};Y.NullClass=lo;var hi=class extends $t{accept(e,r){return e.visitReserved(this,r)}covariant(e){return!0}encodeValue(){return new ArrayBuffer(0)}encodeType(){return(0,se.slebEncode)(-16)}decodeValue(e,r){return r.name!==this.name&&r.decodeValue(e,r),null}get name(){return"reserved"}};Y.ReservedClass=hi;var fo=class extends $t{accept(e,r){return e.visitText(this,r)}covariant(e){if(typeof e=="string")return!0;throw new Error(`Invalid ${this.display()} argument: ${et(e)}`)}encodeValue(e){let r=new TextEncoder().encode(e),n=(0,se.lebEncode)(r.byteLength);return(0,Ne.concat)(n,r)}encodeType(){return(0,se.slebEncode)(-15)}decodeValue(e,r){this.checkType(r);let n=(0,se.lebDecode)(e),i=(0,se.safeRead)(e,Number(n));return new TextDecoder("utf8",{fatal:!0}).decode(i)}get name(){return"text"}valueToString(e){return'"'+e+'"'}};Y.TextClass=fo;var ho=class extends $t{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: ${et(e)}`)}encodeValue(e){return(0,se.slebEncode)(e)}encodeType(){return(0,se.slebEncode)(-4)}decodeValue(e,r){return this.checkType(r),(0,se.slebDecode)(e)}get name(){return"int"}valueToString(e){return e.toString()}};Y.IntClass=ho;var po=class extends $t{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: ${et(e)}`)}encodeValue(e){return(0,se.lebEncode)(e)}encodeType(){return(0,se.slebEncode)(-3)}decodeValue(e,r){return this.checkType(r),(0,se.lebDecode)(e)}get name(){return"nat"}valueToString(e){return e.toString()}};Y.NatClass=po;var zi=class extends $t{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: ${et(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(0,se.slebEncode)(e)}decodeValue(e,r){this.checkType(r);let n=(0,se.safeRead)(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()}};Y.FloatClass=zi;var zr=class extends $t{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedInt(this,r)}covariant(e){let r=(0,Pc.iexp2)(this._bits-1)*BigInt(-1),n=(0,Pc.iexp2)(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: ${et(e)}`)}encodeValue(e){return(0,se.writeIntLE)(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return(0,se.slebEncode)(-9-e)}decodeValue(e,r){this.checkType(r);let n=(0,se.readIntLE)(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`int${this._bits}`}valueToString(e){return e.toString()}};Y.FixedIntClass=zr;var Nr=class extends $t{constructor(e){super(),this._bits=e}accept(e,r){return e.visitFixedNat(this,r)}covariant(e){let r=(0,Pc.iexp2)(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: ${et(e)}`)}encodeValue(e){return(0,se.writeUIntLE)(e,this._bits/8)}encodeType(){let e=Math.log2(this._bits)-3;return(0,se.slebEncode)(-5-e)}decodeValue(e,r){this.checkType(r);let n=(0,se.readUIntLE)(e,this._bits/8);return this._bits<=32?Number(n):n}get name(){return`nat${this._bits}`}valueToString(e){return e.toString()}};Y.FixedNatClass=Nr;var yo=class t extends Rr{constructor(e){super(),this._type=e,this._blobOptimization=!1,e instanceof Nr&&e._bits===8&&(this._blobOptimization=!0)}accept(e,r){return e.visitVec(this,this._type,r)}covariant(e){let r=this._type instanceof Nr?this._type._bits:this._type instanceof zr?this._type._bits:0;if(ArrayBuffer.isView(e)&&r==e.BYTES_PER_ELEMENT*8||Array.isArray(e)&&e.every((n,i)=>{try{return this._type.covariant(n)}catch(s){throw new Error(`Invalid ${this.display()} argument:
4
5
 
5
- index ${i} -> ${s.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}`)}encodeValue(e){let r=(0,ie.lebEncode)(e.length);if(this._blobOptimization)return(0,Oe.concat)(r,new Uint8Array(e));if(ArrayBuffer.isView(e))return(0,Oe.concat)(r,new Uint8Array(e.buffer));let n=new Oe.PipeArrayBuffer(new ArrayBuffer(r.byteLength+e.length),0);n.write(r);for(let i of e){let s=this._type.encodeValue(i);n.write(new Uint8Array(s))}return n.buffer}_buildTypeTableImpl(e){this._type.buildTypeTable(e);let r=(0,ie.slebEncode)(-19),n=this._type.encodeType(e);e.add(this,(0,Oe.concat)(r,n))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not a vector type");let i=Number((0,ie.lebDecode)(e));if(this._type instanceof Tr){if(this._type._bits==8)return new Uint8Array(e.read(i));if(this._type._bits==16)return new Uint16Array(e.read(i*2));if(this._type._bits==32)return new Uint32Array(e.read(i*4));if(this._type._bits==64)return new BigUint64Array(e.read(i*8))}if(this._type instanceof Gr){if(this._type._bits==8)return new Int8Array(e.read(i));if(this._type._bits==16)return new Int16Array(e.read(i*2));if(this._type._bits==32)return new Int32Array(e.read(i*4));if(this._type._bits==64)return new BigInt64Array(e.read(i*8))}let s=[];for(let o=0;o<i;o++)s.push(this._type.decodeValue(e,n._type));return s}get name(){return`vec ${this._type.name}`}display(){return`vec ${this._type.display()}`}valueToString(e){return"vec {"+e.map(n=>this._type.valueToString(n)).join("; ")+"}"}};K.VecClass=to;var ci=class t extends Ar{constructor(e){super(),this._type=e}accept(e,r){return e.visitOpt(this,this._type,r)}covariant(e){try{if(Array.isArray(e)&&(e.length===0||e.length===1&&this._type.covariant(e[0])))return!0}catch(r){throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}
6
+ index ${i} -> ${s.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${et(e)}`)}encodeValue(e){let r=(0,se.lebEncode)(e.length);if(this._blobOptimization)return(0,Ne.concat)(r,new Uint8Array(e));if(ArrayBuffer.isView(e))return(0,Ne.concat)(r,new Uint8Array(e.buffer));let n=new Ne.PipeArrayBuffer(new ArrayBuffer(r.byteLength+e.length),0);n.write(r);for(let i of e){let s=this._type.encodeValue(i);n.write(new Uint8Array(s))}return n.buffer}_buildTypeTableImpl(e){this._type.buildTypeTable(e);let r=(0,se.slebEncode)(-19),n=this._type.encodeType(e);e.add(this,(0,Ne.concat)(r,n))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not a vector type");let i=Number((0,se.lebDecode)(e));if(this._type instanceof Nr){if(this._type._bits==8)return new Uint8Array(e.read(i));if(this._type._bits==16)return new Uint16Array(e.read(i*2));if(this._type._bits==32)return new Uint32Array(e.read(i*4));if(this._type._bits==64)return new BigUint64Array(e.read(i*8))}if(this._type instanceof zr){if(this._type._bits==8)return new Int8Array(e.read(i));if(this._type._bits==16)return new Int16Array(e.read(i*2));if(this._type._bits==32)return new Int32Array(e.read(i*4));if(this._type._bits==64)return new BigInt64Array(e.read(i*8))}let s=[];for(let o=0;o<i;o++)s.push(this._type.decodeValue(e,n._type));return s}get name(){return`vec ${this._type.name}`}display(){return`vec ${this._type.display()}`}valueToString(e){return"vec {"+e.map(n=>this._type.valueToString(n)).join("; ")+"}"}};Y.VecClass=yo;var pi=class t extends Rr{constructor(e){super(),this._type=e}accept(e,r){return e.visitOpt(this,this._type,r)}covariant(e){try{if(Array.isArray(e)&&(e.length===0||e.length===1&&this._type.covariant(e[0])))return!0}catch(r){throw new Error(`Invalid ${this.display()} argument: ${et(e)}
6
7
 
7
- -> ${r.message}`)}throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}`)}encodeValue(e){return e.length===0?new Uint8Array([0]):(0,Oe.concat)(new Uint8Array([1]),this._type.encodeValue(e[0]))}_buildTypeTableImpl(e){this._type.buildTypeTable(e);let r=(0,ie.slebEncode)(-18),n=this._type.encodeType(e);e.add(this,(0,Oe.concat)(r,n))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not an option type");switch((0,ie.safeReadUint8)(e)){case 0:return[];case 1:return[this._type.decodeValue(e,n._type)];default:throw new Error("Not an option value")}}get name(){return`opt ${this._type.name}`}display(){return`opt ${this._type.display()}`}valueToString(e){return e.length===0?"null":`opt ${this._type.valueToString(e[0])}`}};K.OptClass=ci;var Vi=class t extends Ar{constructor(e={}){super(),this._fields=Object.entries(e).sort((r,n)=>(0,vr.idlLabelToId)(r[0])-(0,vr.idlLabelToId)(n[0]))}accept(e,r){return e.visitRecord(this,this._fields,r)}tryAsTuple(){let e=[];for(let r=0;r<this._fields.length;r++){let[n,i]=this._fields[r];if(n!==`_${r}_`)return null;e.push(i)}return e}covariant(e){if(typeof e=="object"&&this._fields.every(([r,n])=>{if(!e.hasOwnProperty(r))throw new Error(`Record is missing key "${r}".`);try{return n.covariant(e[r])}catch(i){throw new Error(`Invalid ${this.display()} argument:
8
+ -> ${r.message}`)}throw new Error(`Invalid ${this.display()} argument: ${et(e)}`)}encodeValue(e){return e.length===0?new Uint8Array([0]):(0,Ne.concat)(new Uint8Array([1]),this._type.encodeValue(e[0]))}_buildTypeTableImpl(e){this._type.buildTypeTable(e);let r=(0,se.slebEncode)(-18),n=this._type.encodeType(e);e.add(this,(0,Ne.concat)(r,n))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not an option type");switch((0,se.safeReadUint8)(e)){case 0:return[];case 1:return[this._type.decodeValue(e,n._type)];default:throw new Error("Not an option value")}}get name(){return`opt ${this._type.name}`}display(){return`opt ${this._type.display()}`}valueToString(e){return e.length===0?"null":`opt ${this._type.valueToString(e[0])}`}};Y.OptClass=pi;var Di=class t extends Rr{constructor(e={}){super(),this._fields=Object.entries(e).sort((r,n)=>(0,Or.idlLabelToId)(r[0])-(0,Or.idlLabelToId)(n[0]))}accept(e,r){return e.visitRecord(this,this._fields,r)}tryAsTuple(){let e=[];for(let r=0;r<this._fields.length;r++){let[n,i]=this._fields[r];if(n!==`_${r}_`)return null;e.push(i)}return e}covariant(e){if(typeof e=="object"&&this._fields.every(([r,n])=>{if(!e.hasOwnProperty(r))throw new Error(`Record is missing key "${r}".`);try{return n.covariant(e[r])}catch(i){throw new Error(`Invalid ${this.display()} argument:
8
9
 
9
- field ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}`)}encodeValue(e){let r=this._fields.map(([i])=>e[i]),n=ji(this._fields,r,([,i],s)=>i.encodeValue(s));return(0,Oe.concat)(...n)}_buildTypeTableImpl(e){this._fields.forEach(([s,o])=>o.buildTypeTable(e));let r=(0,ie.slebEncode)(-20),n=(0,ie.lebEncode)(this._fields.length),i=this._fields.map(([s,o])=>(0,Oe.concat)((0,ie.lebEncode)((0,vr.idlLabelToId)(s)),o.encodeType(e)));e.add(this,(0,Oe.concat)(r,n,(0,Oe.concat)(...i)))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not a record type");let i={},s=0,o=0;for(;o<n._fields.length;){let[a,c]=n._fields[o];if(s>=this._fields.length){c.decodeValue(e,c),o++;continue}let[f,d]=this._fields[s],h=(0,vr.idlLabelToId)(this._fields[s][0]),S=(0,vr.idlLabelToId)(a);if(h===S)i[f]=d.decodeValue(e,c),s++,o++;else if(S>h)if(d instanceof ci||d instanceof ai)i[f]=[],s++;else throw new Error("Cannot find required field "+f);else c.decodeValue(e,c),o++}for(let[a,c]of this._fields.slice(s))if(c instanceof ci||c instanceof ai)i[a]=[];else throw new Error("Cannot find required field "+a);return i}get name(){return`record {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`record {${this._fields.map(([r,n])=>r+":"+n.display()).join("; ")}}`}valueToString(e){let r=this._fields.map(([i])=>e[i]);return`record {${ji(this._fields,r,([i,s],o)=>i+"="+s.valueToString(o)).join("; ")}}`}};K.RecordClass=Vi;var ro=class t extends Vi{constructor(e){let r={};e.forEach((n,i)=>r["_"+i+"_"]=n),super(r),this._components=e}accept(e,r){return e.visitTuple(this,this._components,r)}covariant(e){if(Array.isArray(e)&&e.length>=this._fields.length&&this._components.every((r,n)=>{try{return r.covariant(e[n])}catch(i){throw new Error(`Invalid ${this.display()} argument:
10
+ field ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${et(e)}`)}encodeValue(e){let r=this._fields.map(([i])=>e[i]),n=Wi(this._fields,r,([,i],s)=>i.encodeValue(s));return(0,Ne.concat)(...n)}_buildTypeTableImpl(e){this._fields.forEach(([s,o])=>o.buildTypeTable(e));let r=(0,se.slebEncode)(-20),n=(0,se.lebEncode)(this._fields.length),i=this._fields.map(([s,o])=>(0,Ne.concat)((0,se.lebEncode)((0,Or.idlLabelToId)(s)),o.encodeType(e)));e.add(this,(0,Ne.concat)(r,n,(0,Ne.concat)(...i)))}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("Not a record type");let i={},s=0,o=0;for(;o<n._fields.length;){let[a,c]=n._fields[o];if(s>=this._fields.length){c.decodeValue(e,c),o++;continue}let[f,d]=this._fields[s],h=(0,Or.idlLabelToId)(this._fields[s][0]),m=(0,Or.idlLabelToId)(a);if(h===m)i[f]=d.decodeValue(e,c),s++,o++;else if(m>h)if(d instanceof pi||d instanceof hi)i[f]=[],s++;else throw new Error("Cannot find required field "+f);else c.decodeValue(e,c),o++}for(let[a,c]of this._fields.slice(s))if(c instanceof pi||c instanceof hi)i[a]=[];else throw new Error("Cannot find required field "+a);return i}get name(){return`record {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`record {${this._fields.map(([r,n])=>r+":"+n.display()).join("; ")}}`}valueToString(e){let r=this._fields.map(([i])=>e[i]);return`record {${Wi(this._fields,r,([i,s],o)=>i+"="+s.valueToString(o)).join("; ")}}`}};Y.RecordClass=Di;var go=class t extends Di{constructor(e){let r={};e.forEach((n,i)=>r["_"+i+"_"]=n),super(r),this._components=e}accept(e,r){return e.visitTuple(this,this._components,r)}covariant(e){if(Array.isArray(e)&&e.length>=this._fields.length&&this._components.every((r,n)=>{try{return r.covariant(e[n])}catch(i){throw new Error(`Invalid ${this.display()} argument:
10
11
 
11
- index ${n} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}`)}encodeValue(e){let r=ji(this._components,e,(n,i)=>n.encodeValue(i));return(0,Oe.concat)(...r)}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("not a tuple type");if(n._components.length<this._components.length)throw new Error("tuple mismatch");let i=[];for(let[s,o]of n._components.entries())s>=this._components.length?o.decodeValue(e,o):i.push(this._components[s].decodeValue(e,o));return i}display(){return`record {${this._components.map(r=>r.display()).join("; ")}}`}valueToString(e){return`record {${ji(this._components,e,(n,i)=>n.valueToString(i)).join("; ")}}`}};K.TupleClass=ro;var no=class t extends Ar{constructor(e={}){super(),this._fields=Object.entries(e).sort((r,n)=>(0,vr.idlLabelToId)(r[0])-(0,vr.idlLabelToId)(n[0]))}accept(e,r){return e.visitVariant(this,this._fields,r)}covariant(e){if(typeof e=="object"&&Object.entries(e).length===1&&this._fields.every(([r,n])=>{try{return!e.hasOwnProperty(r)||n.covariant(e[r])}catch(i){throw new Error(`Invalid ${this.display()} argument:
12
+ index ${n} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${et(e)}`)}encodeValue(e){let r=Wi(this._components,e,(n,i)=>n.encodeValue(i));return(0,Ne.concat)(...r)}decodeValue(e,r){let n=this.checkType(r);if(!(n instanceof t))throw new Error("not a tuple type");if(n._components.length<this._components.length)throw new Error("tuple mismatch");let i=[];for(let[s,o]of n._components.entries())s>=this._components.length?o.decodeValue(e,o):i.push(this._components[s].decodeValue(e,o));return i}display(){return`record {${this._components.map(r=>r.display()).join("; ")}}`}valueToString(e){return`record {${Wi(this._components,e,(n,i)=>n.valueToString(i)).join("; ")}}`}};Y.TupleClass=go;var mo=class t extends Rr{constructor(e={}){super(),this._fields=Object.entries(e).sort((r,n)=>(0,Or.idlLabelToId)(r[0])-(0,Or.idlLabelToId)(n[0]))}accept(e,r){return e.visitVariant(this,this._fields,r)}covariant(e){if(typeof e=="object"&&Object.entries(e).length===1&&this._fields.every(([r,n])=>{try{return!e.hasOwnProperty(r)||n.covariant(e[r])}catch(i){throw new Error(`Invalid ${this.display()} argument:
12
13
 
13
- variant ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}`)}encodeValue(e){for(let r=0;r<this._fields.length;r++){let[n,i]=this._fields[r];if(e.hasOwnProperty(n)){let s=(0,ie.lebEncode)(r),o=i.encodeValue(e[n]);return(0,Oe.concat)(s,o)}}throw Error("Variant has no data: "+e)}_buildTypeTableImpl(e){this._fields.forEach(([,s])=>{s.buildTypeTable(e)});let r=(0,ie.slebEncode)(-21),n=(0,ie.lebEncode)(this._fields.length),i=this._fields.map(([s,o])=>(0,Oe.concat)((0,ie.lebEncode)((0,vr.idlLabelToId)(s)),o.encodeType(e)));e.add(this,(0,Oe.concat)(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((0,ie.lebDecode)(e));if(i>=n._fields.length)throw Error("Invalid variant index: "+i);let[s,o]=n._fields[i];for(let[a,c]of this._fields)if((0,vr.idlLabelToId)(s)===(0,vr.idlLabelToId)(a)){let f=c.decodeValue(e,o);return{[a]:f}}throw new Error("Cannot find field hash "+s)}get name(){return`variant {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`variant {${this._fields.map(([r,n])=>r+(n.name==="null"?"":`:${n.display()}`)).join("; ")}}`}valueToString(e){for(let[r,n]of this._fields)if(e.hasOwnProperty(r)){let i=n.valueToString(e[r]);return i==="null"?`variant {${r}}`:`variant {${r}=${i}}`}throw new Error("Variant has no data: "+e)}};K.VariantClass=no;var rn=class t extends Ar{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: ${Qe(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)}};K.RecClass=rn;rn._counter=0;function bc(t){if((0,ie.safeReadUint8)(t)!==1)throw new Error("Cannot decode principal");let r=Number((0,ie.lebDecode)(t));return Eg.Principal.fromUint8Array(new Uint8Array((0,ie.safeRead)(t,r)))}var io=class extends kt{accept(e,r){return e.visitPrincipal(this,r)}covariant(e){if(e&&e._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${Qe(e)}`)}encodeValue(e){let r=e.toUint8Array(),n=(0,ie.lebEncode)(r.byteLength);return(0,Oe.concat)(new Uint8Array([1]),n,r)}encodeType(){return(0,ie.slebEncode)(-24)}decodeValue(e,r){return this.checkType(r),bc(e)}get name(){return"principal"}valueToString(e){return`${this.name} "${e.toText()}"`}};K.PrincipalClass=io;var Hi=class extends Ar{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: ${Qe(e)}`)}encodeValue([e,r]){let n=e.toUint8Array(),i=(0,ie.lebEncode)(n.byteLength),s=(0,Oe.concat)(new Uint8Array([1]),i,n),o=new TextEncoder().encode(r),a=(0,ie.lebEncode)(o.byteLength);return(0,Oe.concat)(new Uint8Array([1]),s,a,o)}_buildTypeTableImpl(e){this.argTypes.forEach(f=>f.buildTypeTable(e)),this.retTypes.forEach(f=>f.buildTypeTable(e));let r=(0,ie.slebEncode)(-22),n=(0,ie.lebEncode)(this.argTypes.length),i=(0,Oe.concat)(...this.argTypes.map(f=>f.encodeType(e))),s=(0,ie.lebEncode)(this.retTypes.length),o=(0,Oe.concat)(...this.retTypes.map(f=>f.encodeType(e))),a=(0,ie.lebEncode)(this.annotations.length),c=(0,Oe.concat)(...this.annotations.map(f=>this.encodeAnnotation(f)));e.add(this,(0,Oe.concat)(r,n,i,s,o,a,c))}decodeValue(e){if((0,ie.safeReadUint8)(e)!==1)throw new Error("Cannot decode function reference");let n=bc(e),i=Number((0,ie.lebDecode)(e)),s=(0,ie.safeRead)(e,i),a=new TextDecoder("utf8",{fatal:!0}).decode(s);return[n,a]}get name(){let e=this.argTypes.map(i=>i.name).join(", "),r=this.retTypes.map(i=>i.name).join(", "),n=" "+this.annotations.join(" ");return`(${e}) -> (${r})${n}`}valueToString([e,r]){return`func "${e.toText()}".${r}`}display(){let e=this.argTypes.map(i=>i.display()).join(", "),r=this.retTypes.map(i=>i.display()).join(", "),n=" "+this.annotations.join(" ");return`(${e}) \u2192 (${r})${n}`}encodeAnnotation(e){if(e==="query")return new Uint8Array([1]);if(e==="oneway")return new Uint8Array([2]);if(e==="composite_query")return new Uint8Array([3]);throw new Error("Illegal function annotation")}};K.FuncClass=Hi;var so=class extends Ar{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: ${Qe(e)}`)}encodeValue(e){let r=e.toUint8Array(),n=(0,ie.lebEncode)(r.length);return(0,Oe.concat)(new Uint8Array([1]),n,r)}_buildTypeTableImpl(e){this._fields.forEach(([s,o])=>o.buildTypeTable(e));let r=(0,ie.slebEncode)(-23),n=(0,ie.lebEncode)(this._fields.length),i=this._fields.map(([s,o])=>{let a=new TextEncoder().encode(s),c=(0,ie.lebEncode)(a.length);return(0,Oe.concat)(c,a,o.encodeType(e))});e.add(this,(0,Oe.concat)(r,n,...i))}decodeValue(e){return bc(e)}get name(){return`service {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}valueToString(e){return`service "${e.toText()}"`}};K.ServiceClass=so;function Qe(t){let e=JSON.stringify(t,(r,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return e&&e.length>Jf?e.substring(0,Jf-3)+"...":e}function xg(t,e){if(e.length<t.length)throw Error("Wrong number of message arguments");let r=new mc;t.forEach(c=>c.buildTypeTable(r));let n=new TextEncoder().encode(zs),i=r.encode(),s=(0,ie.lebEncode)(e.length),o=(0,Oe.concat)(...t.map(c=>c.encodeType(r))),a=(0,Oe.concat)(...ji(t,e,(c,f)=>{try{c.covariant(f)}catch(d){throw new Error(d.message+`
14
+ variant ${r} -> ${i.message}`)}}))return!0;throw new Error(`Invalid ${this.display()} argument: ${et(e)}`)}encodeValue(e){for(let r=0;r<this._fields.length;r++){let[n,i]=this._fields[r];if(e.hasOwnProperty(n)){let s=(0,se.lebEncode)(r),o=i.encodeValue(e[n]);return(0,Ne.concat)(s,o)}}throw Error("Variant has no data: "+e)}_buildTypeTableImpl(e){this._fields.forEach(([,s])=>{s.buildTypeTable(e)});let r=(0,se.slebEncode)(-21),n=(0,se.lebEncode)(this._fields.length),i=this._fields.map(([s,o])=>(0,Ne.concat)((0,se.lebEncode)((0,Or.idlLabelToId)(s)),o.encodeType(e)));e.add(this,(0,Ne.concat)(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((0,se.lebDecode)(e));if(i>=n._fields.length)throw Error("Invalid variant index: "+i);let[s,o]=n._fields[i];for(let[a,c]of this._fields)if((0,Or.idlLabelToId)(s)===(0,Or.idlLabelToId)(a)){let f=c.decodeValue(e,o);return{[a]:f}}throw new Error("Cannot find field hash "+s)}get name(){return`variant {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}display(){return`variant {${this._fields.map(([r,n])=>r+(n.name==="null"?"":`:${n.display()}`)).join("; ")}}`}valueToString(e){for(let[r,n]of this._fields)if(e.hasOwnProperty(r)){let i=n.valueToString(e[r]);return i==="null"?`variant {${r}}`:`variant {${r}=${i}}`}throw new Error("Variant has no data: "+e)}};Y.VariantClass=mo;var cn=class t extends Rr{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: ${et(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)}};Y.RecClass=cn;cn._counter=0;function Fc(t){if((0,se.safeReadUint8)(t)!==1)throw new Error("Cannot decode principal");let r=Number((0,se.lebDecode)(t));return km.Principal.fromUint8Array(new Uint8Array((0,se.safeRead)(t,r)))}var bo=class extends $t{accept(e,r){return e.visitPrincipal(this,r)}covariant(e){if(e&&e._isPrincipal)return!0;throw new Error(`Invalid ${this.display()} argument: ${et(e)}`)}encodeValue(e){let r=e.toUint8Array(),n=(0,se.lebEncode)(r.byteLength);return(0,Ne.concat)(new Uint8Array([1]),n,r)}encodeType(){return(0,se.slebEncode)(-24)}decodeValue(e,r){return this.checkType(r),Fc(e)}get name(){return"principal"}valueToString(e){return`${this.name} "${e.toText()}"`}};Y.PrincipalClass=bo;var Zi=class extends Rr{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: ${et(e)}`)}encodeValue([e,r]){let n=e.toUint8Array(),i=(0,se.lebEncode)(n.byteLength),s=(0,Ne.concat)(new Uint8Array([1]),i,n),o=new TextEncoder().encode(r),a=(0,se.lebEncode)(o.byteLength);return(0,Ne.concat)(new Uint8Array([1]),s,a,o)}_buildTypeTableImpl(e){this.argTypes.forEach(f=>f.buildTypeTable(e)),this.retTypes.forEach(f=>f.buildTypeTable(e));let r=(0,se.slebEncode)(-22),n=(0,se.lebEncode)(this.argTypes.length),i=(0,Ne.concat)(...this.argTypes.map(f=>f.encodeType(e))),s=(0,se.lebEncode)(this.retTypes.length),o=(0,Ne.concat)(...this.retTypes.map(f=>f.encodeType(e))),a=(0,se.lebEncode)(this.annotations.length),c=(0,Ne.concat)(...this.annotations.map(f=>this.encodeAnnotation(f)));e.add(this,(0,Ne.concat)(r,n,i,s,o,a,c))}decodeValue(e){if((0,se.safeReadUint8)(e)!==1)throw new Error("Cannot decode function reference");let n=Fc(e),i=Number((0,se.lebDecode)(e)),s=(0,se.safeRead)(e,i),a=new TextDecoder("utf8",{fatal:!0}).decode(s);return[n,a]}get name(){let e=this.argTypes.map(i=>i.name).join(", "),r=this.retTypes.map(i=>i.name).join(", "),n=" "+this.annotations.join(" ");return`(${e}) -> (${r})${n}`}valueToString([e,r]){return`func "${e.toText()}".${r}`}display(){let e=this.argTypes.map(i=>i.display()).join(", "),r=this.retTypes.map(i=>i.display()).join(", "),n=" "+this.annotations.join(" ");return`(${e}) \u2192 (${r})${n}`}encodeAnnotation(e){if(e==="query")return new Uint8Array([1]);if(e==="oneway")return new Uint8Array([2]);if(e==="composite_query")return new Uint8Array([3]);throw new Error("Illegal function annotation")}};Y.FuncClass=Zi;var _o=class extends Rr{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: ${et(e)}`)}encodeValue(e){let r=e.toUint8Array(),n=(0,se.lebEncode)(r.length);return(0,Ne.concat)(new Uint8Array([1]),n,r)}_buildTypeTableImpl(e){this._fields.forEach(([s,o])=>o.buildTypeTable(e));let r=(0,se.slebEncode)(-23),n=(0,se.lebEncode)(this._fields.length),i=this._fields.map(([s,o])=>{let a=new TextEncoder().encode(s),c=(0,se.lebEncode)(a.length);return(0,Ne.concat)(c,a,o.encodeType(e))});e.add(this,(0,Ne.concat)(r,n,...i))}decodeValue(e){return Fc(e)}get name(){return`service {${this._fields.map(([r,n])=>r+":"+n.name).join("; ")}}`}valueToString(e){return`service "${e.toText()}"`}};Y.ServiceClass=_o;function et(t){let e=JSON.stringify(t,(r,n)=>typeof n=="bigint"?`BigInt(${n})`:n);return e&&e.length>ud?e.substring(0,ud-3)+"...":e}function Hm(t,e){if(e.length<t.length)throw Error("Wrong number of message arguments");let r=new Ic;t.forEach(c=>c.buildTypeTable(r));let n=new TextEncoder().encode(oo),i=r.encode(),s=(0,se.lebEncode)(e.length),o=(0,Ne.concat)(...t.map(c=>c.encodeType(r))),a=(0,Ne.concat)(...Wi(t,e,(c,f)=>{try{c.covariant(f)}catch(d){throw new Error(d.message+`
14
15
 
15
- `)}return c.encodeValue(f)}));return(0,Oe.concat)(n,i,s,o,a)}K.encode=xg;function vg(t,e){let r=new Oe.PipeArrayBuffer(e);if(e.byteLength<zs.length)throw new Error("Message length smaller than magic number");let n=(0,ie.safeRead)(r,zs.length),i=new TextDecoder().decode(n);if(i!==zs)throw new Error("Wrong magic number: "+JSON.stringify(i));function s(w){let u=[],g=Number((0,ie.lebDecode)(w));for(let N=0;N<g;N++){let V=Number((0,ie.slebDecode)(w));switch(V){case-18:case-19:{let W=Number((0,ie.slebDecode)(w));u.push([V,W]);break}case-20:case-21:{let W=[],T=Number((0,ie.lebDecode)(w)),C;for(;T--;){let z=Number((0,ie.lebDecode)(w));if(z>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof C=="number"&&C>=z)throw new Error("field id collision or not sorted");C=z;let D=Number((0,ie.slebDecode)(w));W.push([z,D])}u.push([V,W]);break}case-22:{let W=[],T=Number((0,ie.lebDecode)(w));for(;T--;)W.push(Number((0,ie.slebDecode)(w)));let C=[],z=Number((0,ie.lebDecode)(w));for(;z--;)C.push(Number((0,ie.slebDecode)(w)));let D=[],G=Number((0,ie.lebDecode)(w));for(;G--;)switch(Number((0,ie.lebDecode)(w))){case 1:{D.push("query");break}case 2:{D.push("oneway");break}case 3:{D.push("composite_query");break}default:throw new Error("unknown annotation")}u.push([V,[W,C,D]]);break}case-23:{let W=Number((0,ie.lebDecode)(w)),T=[];for(;W--;){let C=Number((0,ie.lebDecode)(w)),z=new TextDecoder().decode((0,ie.safeRead)(w,C)),D=(0,ie.slebDecode)(w);T.push([z,D])}u.push([V,T]);break}default:throw new Error("Illegal op_code: "+V)}}let U=[],F=Number((0,ie.lebDecode)(w));for(let N=0;N<F;N++)U.push(Number((0,ie.slebDecode)(w)));return[u,U]}let[o,a]=s(r);if(a.length<t.length)throw new Error("Wrong number of return values");let c=o.map(w=>nd());function f(w){if(w<-24)throw new Error("future value not supported");if(w<0)switch(w){case-1:return K.Null;case-2:return K.Bool;case-3:return K.Nat;case-4:return K.Int;case-5:return K.Nat8;case-6:return K.Nat16;case-7:return K.Nat32;case-8:return K.Nat64;case-9:return K.Int8;case-10:return K.Int16;case-11:return K.Int32;case-12:return K.Int64;case-13:return K.Float32;case-14:return K.Float64;case-15:return K.Text;case-16:return K.Reserved;case-17:return K.Empty;case-24:return K.Principal;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=f(w[1]);return Qf(u)}case-18:{let u=f(w[1]);return ed(u)}case-20:{let u={};for(let[F,N]of w[1]){let V=`_${F}_`;u[V]=f(N)}let g=td(u),U=g.tryAsTuple();return Array.isArray(U)?Lf(...U):g}case-21:{let u={};for(let[g,U]of w[1]){let F=`_${g}_`;u[F]=f(U)}return rd(u)}case-22:{let[u,g,U]=w[1];return id(u.map(F=>f(F)),g.map(F=>f(F)),U)}case-23:{let u={},g=w[1];for(let[U,F]of g){let N=f(F);if(N instanceof rn&&(N=N.getType()),!(N instanceof Hi))throw new Error("Illegal service definition: services can only contain functions");u[U]=N}return sd(u)}default:throw new Error("Illegal op_code: "+w[0])}}o.forEach((w,u)=>{if(w[0]===-22){let g=d(w);c[u].fill(g)}}),o.forEach((w,u)=>{if(w[0]!==-22){let g=d(w);c[u].fill(g)}});let h=a.map(w=>f(w)),S=t.map((w,u)=>w.decodeValue(r,h[u]));for(let w=t.length;w<h.length;w++)h[w].decodeValue(r,h[w]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return S}K.decode=vg;K.Empty=new Ds;K.Reserved=new ai;K.Unknown=new Zs;K.Bool=new Xs;K.Null=new Js;K.Text=new Ls;K.Int=new Qs;K.Nat=new eo;K.Float32=new ki(32);K.Float64=new ki(64);K.Int8=new Gr(8);K.Int16=new Gr(16);K.Int32=new Gr(32);K.Int64=new Gr(64);K.Nat8=new Tr(8);K.Nat16=new Tr(16);K.Nat32=new Tr(32);K.Nat64=new Tr(64);K.Principal=new io;function Lf(...t){return new ro(t)}K.Tuple=Lf;function Qf(t){return new to(t)}K.Vec=Qf;function ed(t){return new ci(t)}K.Opt=ed;function td(t){return new Vi(t)}K.Record=td;function rd(t){return new no(t)}K.Variant=rd;function nd(){return new rn}K.Rec=nd;function id(t,e,r=[]){return new Hi(t,e,r)}K.Func=id;function sd(t){return new so(t)}K.Service=sd});var Sc=L(vt=>{"use strict";Object.defineProperty(vt,"__esModule",{value:!0});vt.VecForm=vt.OptionForm=vt.VariantForm=vt.TupleForm=vt.RecordForm=vt.InputForm=vt.InputBox=void 0;var wc=class{constructor(e,r){this.idl=e,this.ui=r,this.label=null,this.value=void 0;let n=document.createElement("span");n.className="status",this.status=n,r.input&&(r.input.addEventListener("blur",()=>{r.input.value!==""&&this.parse()}),r.input.addEventListener("input",()=>{n.style.display="none",r.input.classList.remove("reject")}))}isRejected(){return this.value===void 0}parse(e={}){if(this.ui.form){let r=this.ui.form.parse(e);return this.value=r,r}if(this.ui.input){let r=this.ui.input;try{let n=this.ui.parse(this.idl,e,r.value);if(!this.idl.covariant(n))throw new Error(`${r.value} is not of type ${this.idl.display()}`);return this.status.style.display="none",this.value=n,n}catch(n){r.classList.add("reject"),this.status.style.display="block",this.status.innerHTML="InputError: "+n.message,this.value=void 0;return}}return null}render(e){let r=document.createElement("span");if(this.label){let n=document.createElement("label");n.innerText=this.label,r.appendChild(n)}this.ui.input&&(r.appendChild(this.ui.input),r.appendChild(this.status)),this.ui.form&&this.ui.form.render(r),e.appendChild(r)}};vt.InputBox=wc;var nn=class{constructor(e){this.ui=e,this.form=[]}renderForm(e){this.ui.container?(this.form.forEach(r=>r.render(this.ui.container)),e.appendChild(this.ui.container)):this.form.forEach(r=>r.render(e))}render(e){if(this.ui.open&&this.ui.event){e.appendChild(this.ui.open);let r=this;r.ui.open.addEventListener(r.ui.event,()=>{if(r.ui.container)r.ui.container.innerHTML="";else{let n=r.ui.open.nextElementSibling;n&&n.parentNode.removeChild(n)}r.generateForm(),r.renderForm(e)})}else this.generateForm(),this.renderForm(e)}};vt.InputForm=nn;var Ec=class extends nn{constructor(e,r){super(r),this.fields=e,this.ui=r}generateForm(){this.form=this.fields.map(([e,r])=>{let n=this.ui.render(r);return this.ui.labelMap&&this.ui.labelMap.hasOwnProperty(e)?n.label=this.ui.labelMap[e]+" ":n.label=e+" ",n})}parse(e){let r={};if(this.fields.forEach(([n,i],s)=>{let o=this.form[s].parse(e);r[n]=o}),!this.form.some(n=>n.isRejected()))return r}};vt.RecordForm=Ec;var xc=class extends nn{constructor(e,r){super(r),this.components=e,this.ui=r}generateForm(){this.form=this.components.map(e=>this.ui.render(e))}parse(e){let r=[];if(this.components.forEach((n,i)=>{let s=this.form[i].parse(e);r.push(s)}),!this.form.some(n=>n.isRejected()))return r}};vt.TupleForm=xc;var vc=class extends nn{constructor(e,r){super(r),this.fields=e,this.ui=r}generateForm(){let e=this.ui.open.selectedIndex,[r,n]=this.fields[e],i=this.ui.render(n);this.form=[i]}parse(e){let r=this.ui.open,n=r.options[r.selectedIndex].value,i=this.form[0].parse(e);if(i===void 0)return;let s={};return s[n]=i,s}};vt.VariantForm=vc;var Tc=class extends nn{constructor(e,r){super(r),this.ty=e,this.ui=r}generateForm(){if(this.ui.open.checked){let e=this.ui.render(this.ty);this.form=[e]}else this.form=[]}parse(e){if(this.form.length===0)return[];{let r=this.form[0].parse(e);return r===void 0?void 0:[r]}}};vt.OptionForm=Tc;var Ac=class extends nn{constructor(e,r){super(r),this.ty=e,this.ui=r}generateForm(){let e=+this.ui.open.value;this.form=[];for(let r=0;r<e;r++){let n=this.ui.render(this.ty);this.form.push(n)}}parse(e){let r=this.form.map(n=>n.parse(e));if(!this.form.some(n=>n.isRejected()))return r}};vt.VecForm=Ac});var ad=L(Ee=>{"use strict";var Tg=Ee&&Ee.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Ag=Ee&&Ee.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),od=Ee&&Ee.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Tg(e,t,r);return Ag(e,t),e};Object.defineProperty(Ee,"__esModule",{value:!0});Ee.renderValue=Ee.renderInput=Ee.Render=Ee.vecForm=Ee.optForm=Ee.variantForm=Ee.tupleForm=Ee.recordForm=Ee.inputBox=void 0;var ao=od(_c()),Bc=Nt(),ui=od(Sc()),Sg={parse:Ug},$i={render:Rc},Bg=(t,e)=>new ui.InputBox(t,Object.assign(Object.assign({},Sg),e));Ee.inputBox=Bg;var Og=(t,e)=>new ui.RecordForm(t,Object.assign(Object.assign({},$i),e));Ee.recordForm=Og;var Ng=(t,e)=>new ui.TupleForm(t,Object.assign(Object.assign({},$i),e));Ee.tupleForm=Ng;var Pg=(t,e)=>new ui.VariantForm(t,Object.assign(Object.assign({},$i),e));Ee.variantForm=Pg;var Rg=(t,e)=>new ui.OptionForm(t,Object.assign(Object.assign({},$i),e));Ee.optForm=Rg;var Ig=(t,e)=>new ui.VecForm(t,Object.assign(Object.assign({},$i),e));Ee.vecForm=Ig;var oo=class extends ao.Visitor{visitType(e,r){let n=document.createElement("input");return n.classList.add("argument"),n.placeholder=e.display(),(0,Ee.inputBox)(e,{input:n})}visitNull(e,r){return(0,Ee.inputBox)(e,{})}visitRecord(e,r,n){let i={};if(r.length>1){let o=document.createElement("div");o.classList.add("popup-form"),i={container:o}}let s=(0,Ee.recordForm)(r,i);return(0,Ee.inputBox)(e,{form:s})}visitTuple(e,r,n){let i={};if(r.length>1){let o=document.createElement("div");o.classList.add("popup-form"),i={container:o}}let s=(0,Ee.tupleForm)(r,i);return(0,Ee.inputBox)(e,{form:s})}visitVariant(e,r,n){let i=document.createElement("select");for(let[a,c]of r){let f=new Option(a);i.add(f)}i.selectedIndex=-1,i.classList.add("open");let s={open:i,event:"change"},o=(0,Ee.variantForm)(r,s);return(0,Ee.inputBox)(e,{form:o})}visitOpt(e,r,n){let i=document.createElement("input");i.type="checkbox",i.classList.add("open");let s=(0,Ee.optForm)(r,{open:i,event:"change"});return(0,Ee.inputBox)(e,{form:s})}visitVec(e,r,n){let i=document.createElement("input");i.type="number",i.min="0",i.max="100",i.style.width="8rem",i.placeholder="len",i.classList.add("open");let s=document.createElement("div");s.classList.add("popup-form");let o=(0,Ee.vecForm)(r,{open:i,event:"change",container:s});return(0,Ee.inputBox)(e,{form:o})}visitRec(e,r,n){return Rc(r)}};Ee.Render=oo;var Oc=class extends ao.Visitor{visitNull(e,r){return null}visitBool(e,r){if(r==="true")return!0;if(r==="false")return!1;throw new Error(`Cannot parse ${r} as boolean`)}visitText(e,r){return r}visitFloat(e,r){return parseFloat(r)}visitFixedInt(e,r){return e._bits<=32?parseInt(r,10):BigInt(r)}visitFixedNat(e,r){return e._bits<=32?parseInt(r,10):BigInt(r)}visitNumber(e,r){return BigInt(r)}visitPrincipal(e,r){return Bc.Principal.fromText(r)}visitService(e,r){return Bc.Principal.fromText(r)}visitFunc(e,r){let n=r.split(".",2);return[Bc.Principal.fromText(n[0]),n[1]]}},Nc=class extends ao.Visitor{visitNull(e,r){return null}visitBool(e,r){return Math.random()<.5}visitText(e,r){return Math.random().toString(36).substring(6)}visitFloat(e,r){return Math.random()}visitInt(e,r){return BigInt(this.generateNumber(!0))}visitNat(e,r){return BigInt(this.generateNumber(!1))}visitFixedInt(e,r){let n=this.generateNumber(!0);return e._bits<=32?n:BigInt(r)}visitFixedNat(e,r){let n=this.generateNumber(!1);return e._bits<=32?n:BigInt(r)}generateNumber(e){let r=Math.floor(Math.random()*100);return e&&Math.random()<.5?-r:r}};function Ug(t,e,r){return e.random&&r===""?t.accept(new Nc,r):t.accept(new Oc,r)}function Rc(t){return t.accept(new oo,null)}Ee.renderInput=Rc;function Pn(t,e,r){return t.accept(new Pc,{input:e,value:r})}Ee.renderValue=Pn;var Pc=class extends ao.Visitor{visitType(e,r){r.input.ui.input.value=e.valueToString(r.value)}visitNull(e,r){}visitText(e,r){r.input.ui.input.value=r.value}visitRec(e,r,n){Pn(r,n.input,n.value)}visitOpt(e,r,n){if(n.value.length!==0){let i=n.input.ui.form,s=i.ui.open;s.checked=!0,s.dispatchEvent(new Event(i.ui.event)),Pn(r,i.form[0],n.value[0])}}visitRecord(e,r,n){let i=n.input.ui.form;r.forEach(([s,o],a)=>{Pn(o,i.form[a],n.value[s])})}visitTuple(e,r,n){let i=n.input.ui.form;r.forEach((s,o)=>{Pn(s,i.form[o],n.value[o])})}visitVariant(e,r,n){let i=n.input.ui.form,s=Object.entries(n.value)[0];r.forEach(([o,a],c)=>{if(o===s[0]){let f=i.ui.open;f.selectedIndex=c,f.dispatchEvent(new Event(i.ui.event)),Pn(a,i.form[0],s[1])}})}visitVec(e,r,n){let i=n.input.ui.form,s=n.value.length,o=i.ui.open;o.value=s,o.dispatchEvent(new Event(i.ui.event)),n.value.forEach((a,c)=>{Pn(r,i.form[c],a)})}}});var ud=L(cd=>{"use strict";Object.defineProperty(cd,"__esModule",{value:!0})});var fi=L(dt=>{"use strict";var ld=dt&&dt.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Fg=dt&&dt.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),li=dt&&dt.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&ld(e,t,r)},Mg=dt&&dt.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&ld(e,t,r);return Fg(e,t),e};Object.defineProperty(dt,"__esModule",{value:!0});dt.IDL=void 0;li(ad(),dt);li(Sc(),dt);dt.IDL=Mg(_c());li(dc(),dt);li(pc(),dt);li(Gs(),dt);li(ud(),dt)});var Ki=L((fd,co)=>{(function(t){"use strict";var e,r=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,i=Math.floor,s="[BigNumber Error] ",o=s+"Number primitive has more than 15 significant digits: ",a=1e14,c=14,f=9007199254740991,d=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],h=1e7,S=1e9;function w(T){var C,z,D,G=R.prototype={constructor:R,toString:null,valueOf:null},ne=new R(1),Q=20,le=4,E=-7,_=21,b=-1e7,x=1e7,j=!1,H=1,X=0,oe={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},ae="0123456789abcdefghijklmnopqrstuvwxyz",Y=!0;function R(l,y){var m,P,B,O,q,v,I,k,M=this;if(!(M instanceof R))return new R(l,y);if(y==null){if(l&&l._isBigNumber===!0){M.s=l.s,!l.c||l.e>x?M.c=M.e=null:l.e<b?M.c=[M.e=0]:(M.e=l.e,M.c=l.c.slice());return}if((v=typeof l=="number")&&l*0==0){if(M.s=1/l<0?(l=-l,-1):1,l===~~l){for(O=0,q=l;q>=10;q/=10,O++);O>x?M.c=M.e=null:(M.e=O,M.c=[l]);return}k=String(l)}else{if(!r.test(k=String(l)))return D(M,k,v);M.s=k.charCodeAt(0)==45?(k=k.slice(1),-1):1}(O=k.indexOf("."))>-1&&(k=k.replace(".","")),(q=k.search(/e/i))>0?(O<0&&(O=q),O+=+k.slice(q+1),k=k.substring(0,q)):O<0&&(O=k.length)}else{if(F(y,2,ae.length,"Base"),y==10&&Y)return M=new R(l),de(M,Q+M.e+1,le);if(k=String(l),v=typeof l=="number"){if(l*0!=0)return D(M,k,v,y);if(M.s=1/l<0?(k=k.slice(1),-1):1,R.DEBUG&&k.replace(/^0\.0*|\./,"").length>15)throw Error(o+l)}else M.s=k.charCodeAt(0)===45?(k=k.slice(1),-1):1;for(m=ae.slice(0,y),O=q=0,I=k.length;q<I;q++)if(m.indexOf(P=k.charAt(q))<0){if(P=="."){if(q>O){O=I;continue}}else if(!B&&(k==k.toUpperCase()&&(k=k.toLowerCase())||k==k.toLowerCase()&&(k=k.toUpperCase()))){B=!0,q=-1,O=0;continue}return D(M,String(l),v,y)}v=!1,k=z(k,y,10,M.s),(O=k.indexOf("."))>-1?k=k.replace(".",""):O=k.length}for(q=0;k.charCodeAt(q)===48;q++);for(I=k.length;k.charCodeAt(--I)===48;);if(k=k.slice(q,++I)){if(I-=q,v&&R.DEBUG&&I>15&&(l>f||l!==i(l)))throw Error(o+M.s*l);if((O=O-q-1)>x)M.c=M.e=null;else if(O<b)M.c=[M.e=0];else{if(M.e=O,M.c=[],q=(O+1)%c,O<0&&(q+=c),q<I){for(q&&M.c.push(+k.slice(0,q)),I-=c;q<I;)M.c.push(+k.slice(q,q+=c));q=c-(k=k.slice(q)).length}else q-=I;for(;q--;k+="0");M.c.push(+k)}}else M.c=[M.e=0]}R.clone=w,R.ROUND_UP=0,R.ROUND_DOWN=1,R.ROUND_CEIL=2,R.ROUND_FLOOR=3,R.ROUND_HALF_UP=4,R.ROUND_HALF_DOWN=5,R.ROUND_HALF_EVEN=6,R.ROUND_HALF_CEIL=7,R.ROUND_HALF_FLOOR=8,R.EUCLID=9,R.config=R.set=function(l){var y,m;if(l!=null)if(typeof l=="object"){if(l.hasOwnProperty(y="DECIMAL_PLACES")&&(m=l[y],F(m,0,S,y),Q=m),l.hasOwnProperty(y="ROUNDING_MODE")&&(m=l[y],F(m,0,8,y),le=m),l.hasOwnProperty(y="EXPONENTIAL_AT")&&(m=l[y],m&&m.pop?(F(m[0],-S,0,y),F(m[1],0,S,y),E=m[0],_=m[1]):(F(m,-S,S,y),E=-(_=m<0?-m:m))),l.hasOwnProperty(y="RANGE"))if(m=l[y],m&&m.pop)F(m[0],-S,-1,y),F(m[1],1,S,y),b=m[0],x=m[1];else if(F(m,-S,S,y),m)b=-(x=m<0?-m:m);else throw Error(s+y+" cannot be zero: "+m);if(l.hasOwnProperty(y="CRYPTO"))if(m=l[y],m===!!m)if(m)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))j=m;else throw j=!m,Error(s+"crypto unavailable");else j=m;else throw Error(s+y+" not true or false: "+m);if(l.hasOwnProperty(y="MODULO_MODE")&&(m=l[y],F(m,0,9,y),H=m),l.hasOwnProperty(y="POW_PRECISION")&&(m=l[y],F(m,0,S,y),X=m),l.hasOwnProperty(y="FORMAT"))if(m=l[y],typeof m=="object")oe=m;else throw Error(s+y+" not an object: "+m);if(l.hasOwnProperty(y="ALPHABET"))if(m=l[y],typeof m=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(m))Y=m.slice(0,10)=="0123456789",ae=m;else throw Error(s+y+" invalid: "+m)}else throw Error(s+"Object expected: "+l);return{DECIMAL_PLACES:Q,ROUNDING_MODE:le,EXPONENTIAL_AT:[E,_],RANGE:[b,x],CRYPTO:j,MODULO_MODE:H,POW_PRECISION:X,FORMAT:oe,ALPHABET:ae}},R.isBigNumber=function(l){if(!l||l._isBigNumber!==!0)return!1;if(!R.DEBUG)return!0;var y,m,P=l.c,B=l.e,O=l.s;e:if({}.toString.call(P)=="[object Array]"){if((O===1||O===-1)&&B>=-S&&B<=S&&B===i(B)){if(P[0]===0){if(B===0&&P.length===1)return!0;break e}if(y=(B+1)%c,y<1&&(y+=c),String(P[0]).length==y){for(y=0;y<P.length;y++)if(m=P[y],m<0||m>=a||m!==i(m))break e;if(m!==0)return!0}}}else if(P===null&&B===null&&(O===null||O===1||O===-1))return!0;throw Error(s+"Invalid BigNumber: "+l)},R.maximum=R.max=function(){return ee(arguments,-1)},R.minimum=R.min=function(){return ee(arguments,1)},R.random=function(){var l=9007199254740992,y=Math.random()*l&2097151?function(){return i(Math.random()*l)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(m){var P,B,O,q,v,I=0,k=[],M=new R(ne);if(m==null?m=Q:F(m,0,S),q=n(m/c),j)if(crypto.getRandomValues){for(P=crypto.getRandomValues(new Uint32Array(q*=2));I<q;)v=P[I]*131072+(P[I+1]>>>11),v>=9e15?(B=crypto.getRandomValues(new Uint32Array(2)),P[I]=B[0],P[I+1]=B[1]):(k.push(v%1e14),I+=2);I=q/2}else if(crypto.randomBytes){for(P=crypto.randomBytes(q*=7);I<q;)v=(P[I]&31)*281474976710656+P[I+1]*1099511627776+P[I+2]*4294967296+P[I+3]*16777216+(P[I+4]<<16)+(P[I+5]<<8)+P[I+6],v>=9e15?crypto.randomBytes(7).copy(P,I):(k.push(v%1e14),I+=7);I=q/7}else throw j=!1,Error(s+"crypto unavailable");if(!j)for(;I<q;)v=y(),v<9e15&&(k[I++]=v%1e14);for(q=k[--I],m%=c,q&&m&&(v=d[c-m],k[I]=i(q/v)*v);k[I]===0;k.pop(),I--);if(I<0)k=[O=0];else{for(O=-1;k[0]===0;k.splice(0,1),O-=c);for(I=1,v=k[0];v>=10;v/=10,I++);I<c&&(O-=c-I)}return M.e=O,M.c=k,M}}(),R.sum=function(){for(var l=1,y=arguments,m=new R(y[0]);l<y.length;)m=m.plus(y[l++]);return m},z=function(){var l="0123456789";function y(m,P,B,O){for(var q,v=[0],I,k=0,M=m.length;k<M;){for(I=v.length;I--;v[I]*=P);for(v[0]+=O.indexOf(m.charAt(k++)),q=0;q<v.length;q++)v[q]>B-1&&(v[q+1]==null&&(v[q+1]=0),v[q+1]+=v[q]/B|0,v[q]%=B)}return v.reverse()}return function(m,P,B,O,q){var v,I,k,M,Z,te,fe,_e,Fe=m.indexOf("."),$e=Q,we=le;for(Fe>=0&&(M=X,X=0,m=m.replace(".",""),_e=new R(P),te=_e.pow(m.length-Fe),X=M,_e.c=y(W(g(te.c),te.e,"0"),10,B,l),_e.e=_e.c.length),fe=y(m,P,B,q?(v=ae,l):(v=l,ae)),k=M=fe.length;fe[--M]==0;fe.pop());if(!fe[0])return v.charAt(0);if(Fe<0?--k:(te.c=fe,te.e=k,te.s=O,te=C(te,_e,$e,we,B),fe=te.c,Z=te.r,k=te.e),I=k+$e+1,Fe=fe[I],M=B/2,Z=Z||I<0||fe[I+1]!=null,Z=we<4?(Fe!=null||Z)&&(we==0||we==(te.s<0?3:2)):Fe>M||Fe==M&&(we==4||Z||we==6&&fe[I-1]&1||we==(te.s<0?8:7)),I<1||!fe[0])m=Z?W(v.charAt(1),-$e,v.charAt(0)):v.charAt(0);else{if(fe.length=I,Z)for(--B;++fe[--I]>B;)fe[I]=0,I||(++k,fe=[1].concat(fe));for(M=fe.length;!fe[--M];);for(Fe=0,m="";Fe<=M;m+=v.charAt(fe[Fe++]));m=W(m,k,v.charAt(0))}return m}}(),C=function(){function l(P,B,O){var q,v,I,k,M=0,Z=P.length,te=B%h,fe=B/h|0;for(P=P.slice();Z--;)I=P[Z]%h,k=P[Z]/h|0,q=fe*I+k*te,v=te*I+q%h*h+M,M=(v/O|0)+(q/h|0)+fe*k,P[Z]=v%O;return M&&(P=[M].concat(P)),P}function y(P,B,O,q){var v,I;if(O!=q)I=O>q?1:-1;else for(v=I=0;v<O;v++)if(P[v]!=B[v]){I=P[v]>B[v]?1:-1;break}return I}function m(P,B,O,q){for(var v=0;O--;)P[O]-=v,v=P[O]<B[O]?1:0,P[O]=v*q+P[O]-B[O];for(;!P[0]&&P.length>1;P.splice(0,1));}return function(P,B,O,q,v){var I,k,M,Z,te,fe,_e,Fe,$e,we,pe,et,Jr,An,Ui,Qt,Pe,Ct=P.s==B.s?1:-1,yt=P.c,We=B.c;if(!yt||!yt[0]||!We||!We[0])return new R(!P.s||!B.s||(yt?We&&yt[0]==We[0]:!We)?NaN:yt&&yt[0]==0||!We?Ct*0:Ct/0);for(Fe=new R(Ct),$e=Fe.c=[],k=P.e-B.e,Ct=O+k+1,v||(v=a,k=u(P.e/c)-u(B.e/c),Ct=Ct/c|0),M=0;We[M]==(yt[M]||0);M++);if(We[M]>(yt[M]||0)&&k--,Ct<0)$e.push(1),Z=!0;else{for(An=yt.length,Qt=We.length,M=0,Ct+=2,te=i(v/(We[0]+1)),te>1&&(We=l(We,te,v),yt=l(yt,te,v),Qt=We.length,An=yt.length),Jr=Qt,we=yt.slice(0,Qt),pe=we.length;pe<Qt;we[pe++]=0);Pe=We.slice(),Pe=[0].concat(Pe),Ui=We[0],We[1]>=v/2&&Ui++;do{if(te=0,I=y(We,we,Qt,pe),I<0){if(et=we[0],Qt!=pe&&(et=et*v+(we[1]||0)),te=i(et/Ui),te>1)for(te>=v&&(te=v-1),fe=l(We,te,v),_e=fe.length,pe=we.length;y(fe,we,_e,pe)==1;)te--,m(fe,Qt<_e?Pe:We,_e,v),_e=fe.length,I=1;else te==0&&(I=te=1),fe=We.slice(),_e=fe.length;if(_e<pe&&(fe=[0].concat(fe)),m(we,fe,pe,v),pe=we.length,I==-1)for(;y(We,we,Qt,pe)<1;)te++,m(we,Qt<pe?Pe:We,pe,v),pe=we.length}else I===0&&(te++,we=[0]);$e[M++]=te,we[0]?we[pe++]=yt[Jr]||0:(we=[yt[Jr]],pe=1)}while((Jr++<An||we[0]!=null)&&Ct--);Z=we[0]!=null,$e[0]||$e.splice(0,1)}if(v==a){for(M=1,Ct=$e[0];Ct>=10;Ct/=10,M++);de(Fe,O+(Fe.e=M+k*c-1)+1,q,Z)}else Fe.e=k,Fe.r=+Z;return Fe}}();function p(l,y,m,P){var B,O,q,v,I;if(m==null?m=le:F(m,0,8),!l.c)return l.toString();if(B=l.c[0],q=l.e,y==null)I=g(l.c),I=P==1||P==2&&(q<=E||q>=_)?V(I,q):W(I,q,"0");else if(l=de(new R(l),y,m),O=l.e,I=g(l.c),v=I.length,P==1||P==2&&(y<=O||O<=E)){for(;v<y;I+="0",v++);I=V(I,O)}else if(y-=q,I=W(I,O,"0"),O+1>v){if(--y>0)for(I+=".";y--;I+="0");}else if(y+=O-v,y>0)for(O+1==v&&(I+=".");y--;I+="0");return l.s<0&&B?"-"+I:I}function ee(l,y){for(var m,P,B=1,O=new R(l[0]);B<l.length;B++)P=new R(l[B]),(!P.s||(m=U(O,P))===y||m===0&&O.s===y)&&(O=P);return O}function re(l,y,m){for(var P=1,B=y.length;!y[--B];y.pop());for(B=y[0];B>=10;B/=10,P++);return(m=P+m*c-1)>x?l.c=l.e=null:m<b?l.c=[l.e=0]:(l.e=m,l.c=y),l}D=function(){var l=/^(-?)0([xbo])(?=\w[\w.]*$)/i,y=/^([^.]+)\.$/,m=/^\.([^.]+)$/,P=/^-?(Infinity|NaN)$/,B=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(O,q,v,I){var k,M=v?q:q.replace(B,"");if(P.test(M))O.s=isNaN(M)?null:M<0?-1:1;else{if(!v&&(M=M.replace(l,function(Z,te,fe){return k=(fe=fe.toLowerCase())=="x"?16:fe=="b"?2:8,!I||I==k?te:Z}),I&&(k=I,M=M.replace(y,"$1").replace(m,"0.$1")),q!=M))return new R(M,k);if(R.DEBUG)throw Error(s+"Not a"+(I?" base "+I:"")+" number: "+q);O.s=null}O.c=O.e=null}}();function de(l,y,m,P){var B,O,q,v,I,k,M,Z=l.c,te=d;if(Z){e:{for(B=1,v=Z[0];v>=10;v/=10,B++);if(O=y-B,O<0)O+=c,q=y,I=Z[k=0],M=i(I/te[B-q-1]%10);else if(k=n((O+1)/c),k>=Z.length)if(P){for(;Z.length<=k;Z.push(0));I=M=0,B=1,O%=c,q=O-c+1}else break e;else{for(I=v=Z[k],B=1;v>=10;v/=10,B++);O%=c,q=O-c+B,M=q<0?0:i(I/te[B-q-1]%10)}if(P=P||y<0||Z[k+1]!=null||(q<0?I:I%te[B-q-1]),P=m<4?(M||P)&&(m==0||m==(l.s<0?3:2)):M>5||M==5&&(m==4||P||m==6&&(O>0?q>0?I/te[B-q]:0:Z[k-1])%10&1||m==(l.s<0?8:7)),y<1||!Z[0])return Z.length=0,P?(y-=l.e+1,Z[0]=te[(c-y%c)%c],l.e=-y||0):Z[0]=l.e=0,l;if(O==0?(Z.length=k,v=1,k--):(Z.length=k+1,v=te[c-O],Z[k]=q>0?i(I/te[B-q]%te[q])*v:0),P)for(;;)if(k==0){for(O=1,q=Z[0];q>=10;q/=10,O++);for(q=Z[0]+=v,v=1;q>=10;q/=10,v++);O!=v&&(l.e++,Z[0]==a&&(Z[0]=1));break}else{if(Z[k]+=v,Z[k]!=a)break;Z[k--]=0,v=1}for(O=Z.length;Z[--O]===0;Z.pop());}l.e>x?l.c=l.e=null:l.e<b&&(l.c=[l.e=0])}return l}function J(l){var y,m=l.e;return m===null?l.toString():(y=g(l.c),y=m<=E||m>=_?V(y,m):W(y,m,"0"),l.s<0?"-"+y:y)}return G.absoluteValue=G.abs=function(){var l=new R(this);return l.s<0&&(l.s=1),l},G.comparedTo=function(l,y){return U(this,new R(l,y))},G.decimalPlaces=G.dp=function(l,y){var m,P,B,O=this;if(l!=null)return F(l,0,S),y==null?y=le:F(y,0,8),de(new R(O),l+O.e+1,y);if(!(m=O.c))return null;if(P=((B=m.length-1)-u(this.e/c))*c,B=m[B])for(;B%10==0;B/=10,P--);return P<0&&(P=0),P},G.dividedBy=G.div=function(l,y){return C(this,new R(l,y),Q,le)},G.dividedToIntegerBy=G.idiv=function(l,y){return C(this,new R(l,y),0,1)},G.exponentiatedBy=G.pow=function(l,y){var m,P,B,O,q,v,I,k,M,Z=this;if(l=new R(l),l.c&&!l.isInteger())throw Error(s+"Exponent not an integer: "+J(l));if(y!=null&&(y=new R(y)),v=l.e>14,!Z.c||!Z.c[0]||Z.c[0]==1&&!Z.e&&Z.c.length==1||!l.c||!l.c[0])return M=new R(Math.pow(+J(Z),v?l.s*(2-N(l)):+J(l))),y?M.mod(y):M;if(I=l.s<0,y){if(y.c?!y.c[0]:!y.s)return new R(NaN);P=!I&&Z.isInteger()&&y.isInteger(),P&&(Z=Z.mod(y))}else{if(l.e>9&&(Z.e>0||Z.e<-1||(Z.e==0?Z.c[0]>1||v&&Z.c[1]>=24e7:Z.c[0]<8e13||v&&Z.c[0]<=9999975e7)))return O=Z.s<0&&N(l)?-0:0,Z.e>-1&&(O=1/O),new R(I?1/O:O);X&&(O=n(X/c+2))}for(v?(m=new R(.5),I&&(l.s=1),k=N(l)):(B=Math.abs(+J(l)),k=B%2),M=new R(ne);;){if(k){if(M=M.times(Z),!M.c)break;O?M.c.length>O&&(M.c.length=O):P&&(M=M.mod(y))}if(B){if(B=i(B/2),B===0)break;k=B%2}else if(l=l.times(m),de(l,l.e+1,1),l.e>14)k=N(l);else{if(B=+J(l),B===0)break;k=B%2}Z=Z.times(Z),O?Z.c&&Z.c.length>O&&(Z.c.length=O):P&&(Z=Z.mod(y))}return P?M:(I&&(M=ne.div(M)),y?M.mod(y):O?de(M,X,le,q):M)},G.integerValue=function(l){var y=new R(this);return l==null?l=le:F(l,0,8),de(y,y.e+1,l)},G.isEqualTo=G.eq=function(l,y){return U(this,new R(l,y))===0},G.isFinite=function(){return!!this.c},G.isGreaterThan=G.gt=function(l,y){return U(this,new R(l,y))>0},G.isGreaterThanOrEqualTo=G.gte=function(l,y){return(y=U(this,new R(l,y)))===1||y===0},G.isInteger=function(){return!!this.c&&u(this.e/c)>this.c.length-2},G.isLessThan=G.lt=function(l,y){return U(this,new R(l,y))<0},G.isLessThanOrEqualTo=G.lte=function(l,y){return(y=U(this,new R(l,y)))===-1||y===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(l,y){var m,P,B,O,q=this,v=q.s;if(l=new R(l,y),y=l.s,!v||!y)return new R(NaN);if(v!=y)return l.s=-y,q.plus(l);var I=q.e/c,k=l.e/c,M=q.c,Z=l.c;if(!I||!k){if(!M||!Z)return M?(l.s=-y,l):new R(Z?q:NaN);if(!M[0]||!Z[0])return Z[0]?(l.s=-y,l):new R(M[0]?q:le==3?-0:0)}if(I=u(I),k=u(k),M=M.slice(),v=I-k){for((O=v<0)?(v=-v,B=M):(k=I,B=Z),B.reverse(),y=v;y--;B.push(0));B.reverse()}else for(P=(O=(v=M.length)<(y=Z.length))?v:y,v=y=0;y<P;y++)if(M[y]!=Z[y]){O=M[y]<Z[y];break}if(O&&(B=M,M=Z,Z=B,l.s=-l.s),y=(P=Z.length)-(m=M.length),y>0)for(;y--;M[m++]=0);for(y=a-1;P>v;){if(M[--P]<Z[P]){for(m=P;m&&!M[--m];M[m]=y);--M[m],M[P]+=a}M[P]-=Z[P]}for(;M[0]==0;M.splice(0,1),--k);return M[0]?re(l,M,k):(l.s=le==3?-1:1,l.c=[l.e=0],l)},G.modulo=G.mod=function(l,y){var m,P,B=this;return l=new R(l,y),!B.c||!l.s||l.c&&!l.c[0]?new R(NaN):!l.c||B.c&&!B.c[0]?new R(B):(H==9?(P=l.s,l.s=1,m=C(B,l,0,3),l.s=P,m.s*=P):m=C(B,l,0,H),l=B.minus(m.times(l)),!l.c[0]&&H==1&&(l.s=B.s),l)},G.multipliedBy=G.times=function(l,y){var m,P,B,O,q,v,I,k,M,Z,te,fe,_e,Fe,$e,we=this,pe=we.c,et=(l=new R(l,y)).c;if(!pe||!et||!pe[0]||!et[0])return!we.s||!l.s||pe&&!pe[0]&&!et||et&&!et[0]&&!pe?l.c=l.e=l.s=null:(l.s*=we.s,!pe||!et?l.c=l.e=null:(l.c=[0],l.e=0)),l;for(P=u(we.e/c)+u(l.e/c),l.s*=we.s,I=pe.length,Z=et.length,I<Z&&(_e=pe,pe=et,et=_e,B=I,I=Z,Z=B),B=I+Z,_e=[];B--;_e.push(0));for(Fe=a,$e=h,B=Z;--B>=0;){for(m=0,te=et[B]%$e,fe=et[B]/$e|0,q=I,O=B+q;O>B;)k=pe[--q]%$e,M=pe[q]/$e|0,v=fe*k+M*te,k=te*k+v%$e*$e+_e[O]+m,m=(k/Fe|0)+(v/$e|0)+fe*M,_e[O--]=k%Fe;_e[O]=m}return m?++P:_e.splice(0,1),re(l,_e,P)},G.negated=function(){var l=new R(this);return l.s=-l.s||null,l},G.plus=function(l,y){var m,P=this,B=P.s;if(l=new R(l,y),y=l.s,!B||!y)return new R(NaN);if(B!=y)return l.s=-y,P.minus(l);var O=P.e/c,q=l.e/c,v=P.c,I=l.c;if(!O||!q){if(!v||!I)return new R(B/0);if(!v[0]||!I[0])return I[0]?l:new R(v[0]?P:B*0)}if(O=u(O),q=u(q),v=v.slice(),B=O-q){for(B>0?(q=O,m=I):(B=-B,m=v),m.reverse();B--;m.push(0));m.reverse()}for(B=v.length,y=I.length,B-y<0&&(m=I,I=v,v=m,y=B),B=0;y;)B=(v[--y]=v[y]+I[y]+B)/a|0,v[y]=a===v[y]?0:v[y]%a;return B&&(v=[B].concat(v),++q),re(l,v,q)},G.precision=G.sd=function(l,y){var m,P,B,O=this;if(l!=null&&l!==!!l)return F(l,1,S),y==null?y=le:F(y,0,8),de(new R(O),l,y);if(!(m=O.c))return null;if(B=m.length-1,P=B*c+1,B=m[B]){for(;B%10==0;B/=10,P--);for(B=m[0];B>=10;B/=10,P++);}return l&&O.e+1>P&&(P=O.e+1),P},G.shiftedBy=function(l){return F(l,-f,f),this.times("1e"+l)},G.squareRoot=G.sqrt=function(){var l,y,m,P,B,O=this,q=O.c,v=O.s,I=O.e,k=Q+4,M=new R("0.5");if(v!==1||!q||!q[0])return new R(!v||v<0&&(!q||q[0])?NaN:q?O:1/0);if(v=Math.sqrt(+J(O)),v==0||v==1/0?(y=g(q),(y.length+I)%2==0&&(y+="0"),v=Math.sqrt(+y),I=u((I+1)/2)-(I<0||I%2),v==1/0?y="5e"+I:(y=v.toExponential(),y=y.slice(0,y.indexOf("e")+1)+I),m=new R(y)):m=new R(v+""),m.c[0]){for(I=m.e,v=I+k,v<3&&(v=0);;)if(B=m,m=M.times(B.plus(C(O,B,k,1))),g(B.c).slice(0,v)===(y=g(m.c)).slice(0,v))if(m.e<I&&--v,y=y.slice(v-3,v+1),y=="9999"||!P&&y=="4999"){if(!P&&(de(B,B.e+Q+2,0),B.times(B).eq(O))){m=B;break}k+=4,v+=4,P=1}else{(!+y||!+y.slice(1)&&y.charAt(0)=="5")&&(de(m,m.e+Q+2,1),l=!m.times(m).eq(O));break}}return de(m,m.e+Q+1,le,l)},G.toExponential=function(l,y){return l!=null&&(F(l,0,S),l++),p(this,l,y,1)},G.toFixed=function(l,y){return l!=null&&(F(l,0,S),l=l+this.e+1),p(this,l,y)},G.toFormat=function(l,y,m){var P,B=this;if(m==null)l!=null&&y&&typeof y=="object"?(m=y,y=null):l&&typeof l=="object"?(m=l,l=y=null):m=oe;else if(typeof m!="object")throw Error(s+"Argument not an object: "+m);if(P=B.toFixed(l,y),B.c){var O,q=P.split("."),v=+m.groupSize,I=+m.secondaryGroupSize,k=m.groupSeparator||"",M=q[0],Z=q[1],te=B.s<0,fe=te?M.slice(1):M,_e=fe.length;if(I&&(O=v,v=I,I=O,_e-=O),v>0&&_e>0){for(O=_e%v||v,M=fe.substr(0,O);O<_e;O+=v)M+=k+fe.substr(O,v);I>0&&(M+=k+fe.slice(O)),te&&(M="-"+M)}P=Z?M+(m.decimalSeparator||"")+((I=+m.fractionGroupSize)?Z.replace(new RegExp("\\d{"+I+"}\\B","g"),"$&"+(m.fractionGroupSeparator||"")):Z):M}return(m.prefix||"")+P+(m.suffix||"")},G.toFraction=function(l){var y,m,P,B,O,q,v,I,k,M,Z,te,fe=this,_e=fe.c;if(l!=null&&(v=new R(l),!v.isInteger()&&(v.c||v.s!==1)||v.lt(ne)))throw Error(s+"Argument "+(v.isInteger()?"out of range: ":"not an integer: ")+J(v));if(!_e)return new R(fe);for(y=new R(ne),k=m=new R(ne),P=I=new R(ne),te=g(_e),O=y.e=te.length-fe.e-1,y.c[0]=d[(q=O%c)<0?c+q:q],l=!l||v.comparedTo(y)>0?O>0?y:k:v,q=x,x=1/0,v=new R(te),I.c[0]=0;M=C(v,y,0,1),B=m.plus(M.times(P)),B.comparedTo(l)!=1;)m=P,P=B,k=I.plus(M.times(B=k)),I=B,y=v.minus(M.times(B=y)),v=B;return B=C(l.minus(m),P,0,1),I=I.plus(B.times(k)),m=m.plus(B.times(P)),I.s=k.s=fe.s,O=O*2,Z=C(k,P,O,le).minus(fe).abs().comparedTo(C(I,m,O,le).minus(fe).abs())<1?[k,P]:[I,m],x=q,Z},G.toNumber=function(){return+J(this)},G.toPrecision=function(l,y){return l!=null&&F(l,1,S),p(this,l,y,2)},G.toString=function(l){var y,m=this,P=m.s,B=m.e;return B===null?P?(y="Infinity",P<0&&(y="-"+y)):y="NaN":(l==null?y=B<=E||B>=_?V(g(m.c),B):W(g(m.c),B,"0"):l===10&&Y?(m=de(new R(m),Q+B+1,le),y=W(g(m.c),m.e,"0")):(F(l,2,ae.length,"Base"),y=z(W(g(m.c),B,"0"),10,l,P,!0)),P<0&&m.c[0]&&(y="-"+y)),y},G.valueOf=G.toJSON=function(){return J(this)},G._isBigNumber=!0,T!=null&&R.set(T),R}function u(T){var C=T|0;return T>0||T===C?C:C-1}function g(T){for(var C,z,D=1,G=T.length,ne=T[0]+"";D<G;){for(C=T[D++]+"",z=c-C.length;z--;C="0"+C);ne+=C}for(G=ne.length;ne.charCodeAt(--G)===48;);return ne.slice(0,G+1||1)}function U(T,C){var z,D,G=T.c,ne=C.c,Q=T.s,le=C.s,E=T.e,_=C.e;if(!Q||!le)return null;if(z=G&&!G[0],D=ne&&!ne[0],z||D)return z?D?0:-le:Q;if(Q!=le)return Q;if(z=Q<0,D=E==_,!G||!ne)return D?0:!G^z?1:-1;if(!D)return E>_^z?1:-1;for(le=(E=G.length)<(_=ne.length)?E:_,Q=0;Q<le;Q++)if(G[Q]!=ne[Q])return G[Q]>ne[Q]^z?1:-1;return E==_?0:E>_^z?1:-1}function F(T,C,z,D){if(T<C||T>z||T!==i(T))throw Error(s+(D||"Argument")+(typeof T=="number"?T<C||T>z?" out of range: ":" not an integer: ":" not a primitive number: ")+String(T))}function N(T){var C=T.c.length-1;return u(T.e/c)==C&&T.c[C]%2!=0}function V(T,C){return(T.length>1?T.charAt(0)+"."+T.slice(1):T)+(C<0?"e":"e+")+C}function W(T,C,z){var D,G;if(C<0){for(G=z+".";++C;G+=z);T=G+T}else if(D=T.length,++C>D){for(G=z,C-=D;--C;G+=z);T+=G}else C<D&&(T=T.slice(0,C)+"."+T.slice(C));return T}e=w(),e.default=e.BigNumber=e,typeof define=="function"&&define.amd?define(function(){return e}):typeof co<"u"&&co.exports?co.exports=e:(t||(t=typeof self<"u"&&self?self:window),t.BigNumber=e)})(fd)});var hd=L((xx,dd)=>{dd.exports=function(e,r,n){var i=new e.Uint8Array(n),s=r.pushInt,o=r.pushInt32,a=r.pushInt32Neg,c=r.pushInt64,f=r.pushInt64Neg,d=r.pushFloat,h=r.pushFloatSingle,S=r.pushFloatDouble,w=r.pushTrue,u=r.pushFalse,g=r.pushUndefined,U=r.pushNull,F=r.pushInfinity,N=r.pushInfinityNeg,V=r.pushNaN,W=r.pushNaNNeg,T=r.pushArrayStart,C=r.pushArrayStartFixed,z=r.pushArrayStartFixed32,D=r.pushArrayStartFixed64,G=r.pushObjectStart,ne=r.pushObjectStartFixed,Q=r.pushObjectStartFixed32,le=r.pushObjectStartFixed64,E=r.pushByteString,_=r.pushByteStringStart,b=r.pushUtf8String,x=r.pushUtf8StringStart,j=r.pushSimpleUnassigned,H=r.pushTagStart,X=r.pushTagStart4,oe=r.pushTagStart8,ae=r.pushTagUnassigned,Y=r.pushBreak,R=e.Math.pow,p=0,ee=0,re=0;function de(A){for(A=A|0,p=0,ee=A;(p|0)<(ee|0)&&(re=Cy[i[p]&255](i[p]|0)|0,!((re|0)>0)););return re|0}function J(A){return A=A|0,((p|0)+(A|0)|0)<(ee|0)?0:1}function l(A){return A=A|0,i[A|0]<<8|i[A+1|0]|0}function y(A){return A=A|0,i[A|0]<<24|i[A+1|0]<<16|i[A+2|0]<<8|i[A+3|0]|0}function m(A){return A=A|0,s(A|0),p=p+1|0,0}function P(A){return A=A|0,J(1)|0?1:(s(i[p+1|0]|0),p=p+2|0,0)}function B(A){return A=A|0,J(2)|0?1:(s(l(p+1|0)|0),p=p+3|0,0)}function O(A){return A=A|0,J(4)|0?1:(o(l(p+1|0)|0,l(p+3|0)|0),p=p+5|0,0)}function q(A){return A=A|0,J(8)|0?1:(c(l(p+1|0)|0,l(p+3|0)|0,l(p+5|0)|0,l(p+7|0)|0),p=p+9|0,0)}function v(A){return A=A|0,s(-1-(A-32|0)|0),p=p+1|0,0}function I(A){return A=A|0,J(1)|0?1:(s(-1-(i[p+1|0]|0)|0),p=p+2|0,0)}function k(A){A=A|0;var Te=0;return J(2)|0?1:(Te=l(p+1|0)|0,s(-1-(Te|0)|0),p=p+3|0,0)}function M(A){return A=A|0,J(4)|0?1:(a(l(p+1|0)|0,l(p+3|0)|0),p=p+5|0,0)}function Z(A){return A=A|0,J(8)|0?1:(f(l(p+1|0)|0,l(p+3|0)|0,l(p+5|0)|0,l(p+7|0)|0),p=p+9|0,0)}function te(A){A=A|0;var Te=0,Se=0,xe=0;return xe=A-64|0,J(xe|0)|0?1:(Te=p+1|0,Se=(p+1|0)+(xe|0)|0,E(Te|0,Se|0),p=Se|0,0)}function fe(A){A=A|0;var Te=0,Se=0,xe=0;return J(1)|0||(xe=i[p+1|0]|0,Te=p+2|0,Se=(p+2|0)+(xe|0)|0,J(xe+1|0)|0)?1:(E(Te|0,Se|0),p=Se|0,0)}function _e(A){A=A|0;var Te=0,Se=0,xe=0;return J(2)|0||(xe=l(p+1|0)|0,Te=p+3|0,Se=(p+3|0)+(xe|0)|0,J(xe+2|0)|0)?1:(E(Te|0,Se|0),p=Se|0,0)}function Fe(A){A=A|0;var Te=0,Se=0,xe=0;return J(4)|0||(xe=y(p+1|0)|0,Te=p+5|0,Se=(p+5|0)+(xe|0)|0,J(xe+4|0)|0)?1:(E(Te|0,Se|0),p=Se|0,0)}function $e(A){return A=A|0,1}function we(A){return A=A|0,_(),p=p+1|0,0}function pe(A){A=A|0;var Te=0,Se=0,xe=0;return xe=A-96|0,J(xe|0)|0?1:(Te=p+1|0,Se=(p+1|0)+(xe|0)|0,b(Te|0,Se|0),p=Se|0,0)}function et(A){A=A|0;var Te=0,Se=0,xe=0;return J(1)|0||(xe=i[p+1|0]|0,Te=p+2|0,Se=(p+2|0)+(xe|0)|0,J(xe+1|0)|0)?1:(b(Te|0,Se|0),p=Se|0,0)}function Jr(A){A=A|0;var Te=0,Se=0,xe=0;return J(2)|0||(xe=l(p+1|0)|0,Te=p+3|0,Se=(p+3|0)+(xe|0)|0,J(xe+2|0)|0)?1:(b(Te|0,Se|0),p=Se|0,0)}function An(A){A=A|0;var Te=0,Se=0,xe=0;return J(4)|0||(xe=y(p+1|0)|0,Te=p+5|0,Se=(p+5|0)+(xe|0)|0,J(xe+4|0)|0)?1:(b(Te|0,Se|0),p=Se|0,0)}function Ui(A){return A=A|0,1}function Qt(A){return A=A|0,x(),p=p+1|0,0}function Pe(A){return A=A|0,C(A-128|0),p=p+1|0,0}function Ct(A){return A=A|0,J(1)|0?1:(C(i[p+1|0]|0),p=p+2|0,0)}function yt(A){return A=A|0,J(2)|0?1:(C(l(p+1|0)|0),p=p+3|0,0)}function We(A){return A=A|0,J(4)|0?1:(z(l(p+1|0)|0,l(p+3|0)|0),p=p+5|0,0)}function my(A){return A=A|0,J(8)|0?1:(D(l(p+1|0)|0,l(p+3|0)|0,l(p+5|0)|0,l(p+7|0)|0),p=p+9|0,0)}function gy(A){return A=A|0,T(),p=p+1|0,0}function ze(A){A=A|0;var Te=0;return Te=A-160|0,J(Te|0)|0?1:(ne(Te|0),p=p+1|0,0)}function by(A){return A=A|0,J(1)|0?1:(ne(i[p+1|0]|0),p=p+2|0,0)}function _y(A){return A=A|0,J(2)|0?1:(ne(l(p+1|0)|0),p=p+3|0,0)}function wy(A){return A=A|0,J(4)|0?1:(Q(l(p+1|0)|0,l(p+3|0)|0),p=p+5|0,0)}function Ey(A){return A=A|0,J(8)|0?1:(le(l(p+1|0)|0,l(p+3|0)|0,l(p+5|0)|0,l(p+7|0)|0),p=p+9|0,0)}function xy(A){return A=A|0,G(),p=p+1|0,0}function zn(A){return A=A|0,H(A-192|0|0),p=p+1|0,0}function AE(A){return A=A|0,H(A|0),p=p+1|0,0}function SE(A){return A=A|0,H(A|0),p=p+1|0,0}function BE(A){return A=A|0,H(A|0),p=p+1|0,0}function OE(A){return A=A|0,H(A|0),p=p+1|0,0}function ut(A){return A=A|0,H(A-192|0|0),p=p+1|0,0}function NE(A){return A=A|0,H(A|0),p=p+1|0,0}function PE(A){return A=A|0,H(A|0),p=p+1|0,0}function RE(A){return A=A|0,H(A|0),p=p+1|0,0}function vy(A){return A=A|0,J(1)|0?1:(H(i[p+1|0]|0),p=p+2|0,0)}function Ty(A){return A=A|0,J(2)|0?1:(H(l(p+1|0)|0),p=p+3|0,0)}function Ay(A){return A=A|0,J(4)|0?1:(X(l(p+1|0)|0,l(p+3|0)|0),p=p+5|0,0)}function Sy(A){return A=A|0,J(8)|0?1:(oe(l(p+1|0)|0,l(p+3|0)|0,l(p+5|0)|0,l(p+7|0)|0),p=p+9|0,0)}function tt(A){return A=A|0,j((A|0)-224|0),p=p+1|0,0}function By(A){return A=A|0,u(),p=p+1|0,0}function Oy(A){return A=A|0,w(),p=p+1|0,0}function Ny(A){return A=A|0,U(),p=p+1|0,0}function Py(A){return A=A|0,g(),p=p+1|0,0}function Ry(A){return A=A|0,J(1)|0?1:(j(i[p+1|0]|0),p=p+2|0,0)}function Iy(A){A=A|0;var Te=0,Se=0,xe=1,Ts=0,Fi=0,IE=0;return J(2)|0?1:(Te=i[p+1|0]|0,Se=i[p+2|0]|0,(Te|0)&128&&(xe=-1),Ts=+(((Te|0)&124)>>2),Fi=+(((Te|0)&3)<<8|Se),+Ts==0?d(+(+xe*5960464477539063e-23*+Fi)):+Ts==31?+xe==1?+Fi>0?V():F():+Fi>0?W():N():d(+(+xe*R(2,+(+Ts-25))*+(1024+Fi))),p=p+3|0,0)}function Uy(A){return A=A|0,J(4)|0?1:(h(i[p+1|0]|0,i[p+2|0]|0,i[p+3|0]|0,i[p+4|0]|0),p=p+5|0,0)}function Fy(A){return A=A|0,J(8)|0?1:(S(i[p+1|0]|0,i[p+2|0]|0,i[p+3|0]|0,i[p+4|0]|0,i[p+5|0]|0,i[p+6|0]|0,i[p+7|0]|0,i[p+8|0]|0),p=p+9|0,0)}function Ve(A){return A=A|0,1}function My(A){return A=A|0,Y(),p=p+1|0,0}var Cy=[m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,P,B,O,q,Ve,Ve,Ve,Ve,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,v,I,k,M,Z,Ve,Ve,Ve,Ve,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,fe,_e,Fe,$e,Ve,Ve,Ve,we,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,pe,et,Jr,An,Ui,Ve,Ve,Ve,Qt,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Ct,yt,We,my,Ve,Ve,Ve,gy,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,by,_y,wy,Ey,Ve,Ve,Ve,xy,zn,zn,zn,zn,zn,zn,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,vy,Ty,Ay,Sy,Ve,Ve,Ve,Ve,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,By,Oy,Ny,Py,Ry,Iy,Uy,Fy,Ve,Ve,Ve,My];return{parse:de}}});var Gi=L(Gt=>{"use strict";var Ic=Ki().BigNumber;Gt.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};Gt.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};Gt.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};Gt.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};Gt.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};Gt.SHIFT32=Math.pow(2,32);Gt.SHIFT16=Math.pow(2,16);Gt.MAX_SAFE_HIGH=2097151;Gt.NEG_ONE=new Ic(-1);Gt.TEN=new Ic(10);Gt.TWO=new Ic(2);Gt.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var uo=L(rr=>{"use strict";var{Buffer:Cg}=Dn("buffer"),yd=Ki().BigNumber,md=Gi(),pd=md.SHIFT32,qg=md.SHIFT16,jg=2097151;rr.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 kg(t){return t<16?"0"+t.toString(16):t.toString(16)}rr.arrayBufferToBignumber=function(t){let e=t.byteLength,r="";for(let n=0;n<e;n++)r+=kg(t[n]);return new yd(r,16)};rr.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};rr.buildInt32=(t,e)=>t*qg+e;rr.buildInt64=(t,e,r,n)=>{let i=rr.buildInt32(t,e),s=rr.buildInt32(r,n);return i>jg?new yd(i).times(pd).plus(s):i*pd+s};rr.writeHalf=function(e,r){let n=Cg.allocUnsafe(4);n.writeFloatBE(r,0);let i=n.readUInt32BE(0);if(i&8191)return!1;var s=i>>16&32768;let o=i>>23&255,a=i&8388607;if(o>=113&&o<=142)s+=(o-112<<10)+(a>>13);else if(o>=103&&o<113){if(a&(1<<126-o)-1)return!1;s+=a+8388608>>126-o}else return!1;return e.writeUInt16BE(s,0),!0};rr.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])};rr.isNegativeZero=t=>t===0&&1/t<0;rr.nextPowerOf2=t=>{let e=0;if(t&&!(t&t-1))return t;for(;t!==0;)t>>=1,e+=1;return 1<<e}});var Cc=L((Ax,gd)=>{"use strict";var Mc=Gi(),Vg=Mc.MT,lo=Mc.SIMPLE,Uc=Mc.SYMS,Fc=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,Vg.SIMPLE_FLOAT)}static isSimple(e){return e instanceof t}static decode(e,r){switch(r==null&&(r=!0),e){case lo.FALSE:return!1;case lo.TRUE:return!0;case lo.NULL:return r?null:Uc.NULL;case lo.UNDEFINED:return r?void 0:Uc.UNDEFINED;case-1:if(!r)throw new Error("Invalid BREAK");return Uc.BREAK;default:return new t(e)}}};gd.exports=Fc});var jc=L((Sx,bd)=>{"use strict";var qc=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}}};bd.exports=qc});var Vc=L((Bx,wd)=>{"use strict";var{URL:Hg,URLSearchParams:$g,format:Kg}=Dn("url"),_d="http://localhost",kc=class extends Hg{constructor(e="",r=_d){super(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}format(){return this.toString()}};wd.exports={URLWithLegacySupport:kc,URLSearchParams:$g,format:Kg,defaultBase:_d}});var vd=L((Ox,xd)=>{"use strict";var{URLWithLegacySupport:Ed,format:Gg}=Vc();xd.exports=(t,e={},r={},n)=>{let i=e.protocol?e.protocol.replace(":",""):"http";i=(r[i]||n||i)+":";let s;try{s=new Ed(t)}catch{s={}}let o=Object.assign({},e,{protocol:i||s.protocol,host:e.host||s.host});return new Ed(t,Gg(o)).toString()}});var Hc=L((Nx,Td)=>{"use strict";var{URLWithLegacySupport:Yg,format:Wg,URLSearchParams:zg,defaultBase:Dg}=Vc(),Zg=vd();Td.exports={URL:Yg,URLSearchParams:zg,format:Wg,relative:Zg,defaultBase:Dg}});var $c=L((Px,Sd)=>{"use strict";var{Buffer:di}=Dn("buffer"),Ad=tc(),Xg=Ki().BigNumber,Jg=hd(),Pt=uo(),qe=Gi(),Lg=Cc(),Qg=jc(),{URL:eb}=Hc(),Yi=class t{constructor(e){e=e||{},!e.size||e.size<65536?e.size=65536:e.size=Pt.nextPowerOf2(e.size),this._heap=new ArrayBuffer(e.size),this._heap8=new Uint8Array(this._heap),this._buffer=di.from(this._heap),this._reset(),this._knownTags=Object.assign({0:r=>new Date(r),1:r=>new Date(r*1e3),2:r=>Pt.arrayBufferToBignumber(r),3:r=>qe.NEG_ONE.minus(Pt.arrayBufferToBignumber(r)),4:r=>qe.TEN.pow(r[0]).times(r[1]),5:r=>qe.TWO.pow(r[0]).times(r[1]),32:r=>new eb(r),35:r=>new RegExp(r)},e.tags),this.parser=Jg(global,{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 qe.PARENT.TAG:this._push(this.createTag(e.ref[0],e.ref[1]));break;case qe.PARENT.BYTE_STRING:this._push(this.createByteString(e.ref,e.length));break;case qe.PARENT.UTF8_STRING:this._push(this.createUtf8String(e.ref,e.length));break;case qe.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 qe.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 qe.PARENT.ARRAY:this._push(this.createArray(e.ref,e.length));break;default:break}this._currentParent&&this._currentParent.type===qe.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 qe.PARENT.ARRAY:case qe.PARENT.BYTE_STRING:case qe.PARENT.UTF8_STRING:n.length>-1?this._ref[this._ref.length-n.length]=e:this._ref.push(e),this._dec();break;case qe.PARENT.OBJECT:n.tmpKey!=null?(this._ref[n.tmpKey]=e,n.tmpKey=null,this._dec()):(n.tmpKey=e,typeof n.tmpKey!="string"&&(n.type=qe.PARENT.MAP,n.ref=Pt.buildMap(n.ref)));break;case qe.PARENT.MAP:n.tmpKey!=null?(this._ref.set(n.tmpKey,e),n.tmpKey=null,this._dec()):n.tmpKey=e;break;case qe.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:qe.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(e,r){let n=this._knownTags[e];return n?n(r):new Qg(e,r)}createMap(e,r){return e}createObject(e,r){return e}createArray(e,r){return e}createByteString(e,r){return di.concat(e)}createByteStringFromHeap(e,r){return e===r?di.alloc(0):di.from(this._heap.slice(e,r))}createInt(e){return e}createInt32(e,r){return Pt.buildInt32(e,r)}createInt64(e,r,n,i){return Pt.buildInt64(e,r,n,i)}createFloat(e){return e}createFloatSingle(e,r,n,i){return Ad.read([e,r,n,i],0,!1,23,4)}createFloatDouble(e,r,n,i,s,o,a,c){return Ad.read([e,r,n,i,s,o,a,c],0,!1,52,8)}createInt32Neg(e,r){return-1-Pt.buildInt32(e,r)}createInt64Neg(e,r,n,i){let s=Pt.buildInt32(e,r),o=Pt.buildInt32(n,i);return s>qe.MAX_SAFE_HIGH?qe.NEG_ONE.minus(new Xg(s).times(qe.SHIFT32).plus(o)):-1-(s*qe.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 Lg(e)}pushInt(e){this._push(this.createInt(e))}pushInt32(e,r){this._push(this.createInt32(e,r))}pushInt64(e,r,n,i){this._push(this.createInt64(e,r,n,i))}pushFloat(e){this._push(this.createFloat(e))}pushFloatSingle(e,r,n,i){this._push(this.createFloatSingle(e,r,n,i))}pushFloatDouble(e,r,n,i,s,o,a,c){this._push(this.createFloatDouble(e,r,n,i,s,o,a,c))}pushInt32Neg(e,r){this._push(this.createInt32Neg(e,r))}pushInt64Neg(e,r,n,i){this._push(this.createInt64Neg(e,r,n,i))}pushTrue(){this._push(this.createTrue())}pushFalse(){this._push(this.createFalse())}pushNull(){this._push(this.createNull())}pushUndefined(){this._push(this.createUndefined())}pushInfinity(){this._push(this.createInfinity())}pushInfinityNeg(){this._push(this.createInfinityNeg())}pushNaN(){this._push(this.createNaN())}pushNaNNeg(){this._push(this.createNaNNeg())}pushArrayStart(){this._createParent([],qe.PARENT.ARRAY,-1)}pushArrayStartFixed(e){this._createArrayStartFixed(e)}pushArrayStartFixed32(e,r){let n=Pt.buildInt32(e,r);this._createArrayStartFixed(n)}pushArrayStartFixed64(e,r,n,i){let s=Pt.buildInt64(e,r,n,i);this._createArrayStartFixed(s)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(e){this._createObjectStartFixed(e)}pushObjectStartFixed32(e,r){let n=Pt.buildInt32(e,r);this._createObjectStartFixed(n)}pushObjectStartFixed64(e,r,n,i){let s=Pt.buildInt64(e,r,n,i);this._createObjectStartFixed(s)}pushByteStringStart(){this._parents[this._depth]={type:qe.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:qe.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:qe.PARENT.TAG,length:1,ref:[e]}}pushTagStart4(e,r){this.pushTagStart(Pt.buildInt32(e,r))}pushTagStart8(e,r,n,i){this.pushTagStart(Pt.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({},qe.PARENT.OBJECT,e)}_createArrayStartFixed(e){if(e===0){this._push(this.createArray([]));return}this._createParent(new Array(e),qe.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=di.from(e,r||"hex")),new t({size:e.length}).decodeFirst(e)}static decodeAll(e,r){return typeof e=="string"&&(e=di.from(e,r||"hex")),new t({size:e.length}).decodeAll(e)}};Yi.decodeFirst=Yi.decode;Sd.exports=Yi});var Nd=L((Rx,Od)=>{"use strict";var{Buffer:Kc}=Dn("buffer"),tb=$c(),rb=uo(),Gc=class t extends tb{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 rb.isNegativeZero(e)?"-0_1":`${r}_1`}createFloatSingle(e,r,n,i){return`${super.createFloatSingle(e,r,n,i)}_2`}createFloatDouble(e,r,n,i,s,o,a,c){return`${super.createFloatDouble(e,r,n,i,s,o,a,c)}_3`}createByteString(e,r){let n=e.join(", ");return r===-1?`(_ ${n})`:`h'${n}`}createByteStringFromHeap(e,r){return`h'${Kc.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(Bd(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createObject(e,r){let n=super.createObject(e),i=Object.keys(n).reduce(Bd(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createUtf8String(e,r){let n=e.join(", ");return r===-1?`(_ ${n})`:`"${n}"`}createUtf8StringFromHeap(e,r){return`"${Kc.from(super.createUtf8StringFromHeap(e,r)).toString("utf8")}"`}static diagnose(e,r){return typeof e=="string"&&(e=Kc.from(e,r||"hex")),new t().decodeFirst(e)}};Od.exports=Gc;function Bd(t){return(e,r)=>e?`${e}, ${r}: ${t[r]}`:`${r}: ${t[r]}`}});var Fd=L((Ix,Ud)=>{"use strict";var{Buffer:Sr}=Dn("buffer"),{URL:nb}=Hc(),Wc=Ki().BigNumber,Yc=uo(),st=Gi(),ur=st.MT,fo=st.NUMBYTES,Pd=st.SHIFT32,Rd=st.SYMS,hi=st.TAG,ib=st.MT.SIMPLE_FLOAT<<5|st.NUMBYTES.TWO,sb=st.MT.SIMPLE_FLOAT<<5|st.NUMBYTES.FOUR,ob=st.MT.SIMPLE_FLOAT<<5|st.NUMBYTES.EIGHT,ab=st.MT.SIMPLE_FLOAT<<5|st.SIMPLE.TRUE,cb=st.MT.SIMPLE_FLOAT<<5|st.SIMPLE.FALSE,ub=st.MT.SIMPLE_FLOAT<<5|st.SIMPLE.UNDEFINED,Id=st.MT.SIMPLE_FLOAT<<5|st.SIMPLE.NULL,lb=new Wc("0x20000000000000"),fb=Sr.from("f97e00","hex"),db=Sr.from("f9fc00","hex"),hb=Sr.from("f97c00","hex");function pb(t){return{}.toString.call(t).slice(8,-1)}var zc=class t{constructor(e){e=e||{},this.streaming=typeof e.stream=="function",this.onData=e.stream,this.semanticTypes=[[nb,this._pushUrl],[Wc,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(fb)}_pushInfinity(e){let r=e<0?db:hb;return this.push(r)}_pushFloat(e){let r=Sr.allocUnsafe(2);if(Yc.writeHalf(r,e)&&Yc.parseHalf(r)===e)return this._pushUInt8(ib)&&this.push(r);let n=Sr.allocUnsafe(4);return n.writeFloatBE(e,0),n.readFloatBE(0)===e?this._pushUInt8(sb)&&this.push(n):this._pushUInt8(ob)&&this._pushDoubleBE(e)}_pushInt(e,r,n){let i=r<<5;return e<24?this._pushUInt8(i|e):e<=255?this._pushUInt8(i|fo.ONE)&&this._pushUInt8(e):e<=65535?this._pushUInt8(i|fo.TWO)&&this._pushUInt16BE(e):e<=4294967295?this._pushUInt8(i|fo.FOUR)&&this._pushUInt32BE(e):e<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|fo.EIGHT)&&this._pushUInt32BE(Math.floor(e/Pd))&&this._pushUInt32BE(e%Pd):r===ur.NEG_INT?this._pushFloat(n):this._pushFloat(e)}_pushIntNum(e){return e<0?this._pushInt(-e-1,ur.NEG_INT,e):this._pushInt(e,ur.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=Sr.byteLength(e,"utf8");return this._pushInt(r,ur.UTF8_STRING)&&this.pushWrite(e,5,r)}_pushBoolean(e){return this._pushUInt8(e?ab:cb)}_pushUndefined(e){return this._pushUInt8(ub)}_pushArray(e,r){let n=r.length;if(!e._pushInt(n,ur.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,ur.TAG)}_pushDate(e,r){return e._pushTag(hi.DATE_EPOCH)&&e.pushAny(Math.round(r/1e3))}_pushBuffer(e,r){return e._pushInt(r.length,ur.BYTE_STRING)&&e.push(r)}_pushNoFilter(e,r){return e._pushBuffer(e,r.slice())}_pushRegexp(e,r){return e._pushTag(hi.REGEXP)&&e.pushAny(r.source)}_pushSet(e,r){if(!e._pushInt(r.size,ur.ARRAY))return!1;for(let n of r)if(!e.pushAny(n))return!1;return!0}_pushUrl(e,r){return e._pushTag(hi.URI)&&e.pushAny(r.format())}_pushBigint(e){let r=hi.POS_BIGINT;e.isNegative()&&(e=e.negated().minus(1),r=hi.NEG_BIGINT);let n=e.toString(16);n.length%2&&(n="0"+n);let i=Sr.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(hi.DECIMAL_FRAC)&&e._pushInt(2,ur.ARRAY)))return!1;let n=r.decimalPlaces(),i=r.multipliedBy(new Wc(10).pow(n));return e._pushIntNum(-n)?i.abs().isLessThan(lb)?e._pushIntNum(i.toNumber()):e._pushBigint(i):!1}_pushMap(e,r){return e._pushInt(r.size,ur.MAP)?this._pushRawMap(r.size,Array.from(r)):!1}_pushObject(e){if(!e)return this._pushUInt8(Id);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,ur.MAP)?this._pushRawMap(o,s.map(a=>[a,e[a]])):!1}_pushRawMap(e,r){r=r.map(function(i){return i[0]=t.encode(i[0]),i}).sort(Yc.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=pb(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,Sr.isBuffer(e)?e:Sr.from(e));case"Null":return this._pushUInt8(Id);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 Rd.NULL:return this._pushObject(null);case Rd.UNDEFINED:return this._pushUndefined(void 0);default:throw new Error("Unknown symbol: "+e.toString())}default:throw new Error("Unknown type: "+typeof e+", "+(e?e.toString():""))}}finalize(){if(this.offset===0)return null;for(var e=this.result,r=this.resultLength,n=this.resultMethod,i=this.offset,s=0,o=0;o<i;o++)s+=r[o];var a=Sr.allocUnsafe(s),c=0,f=0;for(o=0;o<i;o++){switch(f=r[o],n[o]){case 0:e[o].copy(a,c);break;case 1:a.writeUInt8(e[o],c,!0);break;case 2:a.writeUInt16BE(e[o],c,!0);break;case 3:a.writeUInt32BE(e[o],c,!0);break;case 4:a.writeDoubleBE(e[o],c,!0);break;case 5:a.write(e[o],c,f,"utf8");break;default:throw new Error("unkown method")}c+=f}var d=a;return this._reset(),d}_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()}};Ud.exports=zc});var ho=L(ot=>{"use strict";ot.Diagnose=Nd();ot.Decoder=$c();ot.Encoder=Fd();ot.Simple=Cc();ot.Tagged=jc();ot.decodeAll=ot.Decoder.decodeAll;ot.decodeFirst=ot.Decoder.decodeFirst;ot.diagnose=ot.Diagnose.diagnose;ot.encode=ot.Encoder.encode;ot.decode=ot.Decoder.decode;ot.leveldb={decode:ot.Decoder.decodeAll,encode:ot.Encoder.encode,buffer:!0,name:"cbor"}});var Yt=L(Tt=>{"use strict";Object.defineProperty(Tt,"__esModule",{value:!0});Tt.bufFromBufLike=Tt.uint8ToBuf=Tt.bufEquals=Tt.compare=Tt.fromHex=Tt.toHex=Tt.concat=void 0;function yb(...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}Tt.concat=yb;function mb(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}Tt.toHex=mb;var gb=new RegExp(/^[0-9a-fA-F]+$/);function bb(t){if(!gb.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}Tt.fromHex=bb;function Md(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}Tt.compare=Md;function _b(t,e){return Md(t,e)===0}Tt.bufEquals=_b;function po(t){return new DataView(t.buffer,t.byteOffset,t.byteLength).buffer}Tt.uint8ToBuf=po;function Cd(t){return t instanceof Uint8Array?po(t):t instanceof ArrayBuffer?t:Array.isArray(t)?po(new Uint8Array(t)):"buffer"in t?Cd(t.buffer):po(new Uint8Array(t))}Tt.bufFromBufLike=Cd});var Di=L(nr=>{"use strict";var wb=nr&&nr.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(nr,"__esModule",{value:!0});nr.hashOfMap=nr.requestIdOf=nr.hashValue=nr.hash=void 0;var qd=fi(),Eb=wb(ho()),xb=Us(),Wi=Yt();function sn(t){return(0,Wi.uint8ToBuf)(xb.sha256.create().update(new Uint8Array(t)).digest())}nr.hash=sn;function zi(t){if(t instanceof Eb.default.Tagged)return zi(t.value);if(typeof t=="string")return jd(t);if(typeof t=="number")return sn((0,qd.lebEncode)(t));if(t instanceof ArrayBuffer||ArrayBuffer.isView(t))return sn(t);if(Array.isArray(t)){let e=t.map(zi);return sn((0,Wi.concat)(...e))}else{if(t&&typeof t=="object"&&t._isPrincipal)return sn(t.toUint8Array());if(typeof t=="object"&&t!==null&&typeof t.toHash=="function")return zi(t.toHash());if(typeof t=="object")return Dc(t);if(typeof t=="bigint")return sn((0,qd.lebEncode)(t))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${t}`),{value:t})}nr.hashValue=zi;var jd=t=>{let e=new TextEncoder().encode(t);return sn(e)};function vb(t){return Dc(t)}nr.requestIdOf=vb;function Dc(t){let n=Object.entries(t).filter(([,o])=>o!==void 0).map(([o,a])=>{let c=jd(o),f=zi(a);return[c,f]}).sort(([o],[a])=>(0,Wi.compare)(o,a)),i=(0,Wi.concat)(...n.map(o=>(0,Wi.concat)(...o)));return sn(i)}nr.hashOfMap=Dc});var Jc=L(Br=>{"use strict";var Tb=Br&&Br.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r};Object.defineProperty(Br,"__esModule",{value:!0});Br.createIdentityDescriptor=Br.AnonymousIdentity=Br.SignIdentity=void 0;var kd=Nt(),Ab=Di(),Vd=Yt(),Sb=new TextEncoder().encode(`
16
- ic-request`),Zc=class{getPrincipal(){return this._principal||(this._principal=kd.Principal.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(e){let{body:r}=e,n=Tb(e,["body"]),i=await(0,Ab.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign((0,Vd.concat)(Sb,i))}})}};Br.SignIdentity=Zc;var Xc=class{getPrincipal(){return kd.Principal.anonymous()}async transformRequest(e){return Object.assign(Object.assign({},e),{body:{content:e.body}})}};Br.AnonymousIdentity=Xc;function Bb(t){return"getPublicKey"in t?{type:"PublicKeyIdentity",publicKey:(0,Vd.toHex)(t.getPublicKey().toDer())}:{type:"AnonymousIdentity"}}Br.createIdentityDescriptor=Bb});var eu=L(Ke=>{"use strict";Object.defineProperty(Ke,"__esModule",{value:!0});var Ob=9007199254740992;function Yr(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 lr(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 yo(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 lr(t,r,e.toString(16))}}function Hd(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 Yr(new Uint8Array(yo(3,t.length)),new Uint8Array(e))}function Nb(t,e){if(t==14277111)return Yr(new Uint8Array([217,217,247]),e);if(t<24)return Yr(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}}Ke.tagged=Nb;function Zi(t){return new Uint8Array(t).buffer}Ke.raw=Zi;function Lc(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}Ke.uSmall=Lc;function $d(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),lr(0,24,t)}Ke.u8=$d;function Kd(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),lr(0,25,t)}Ke.u16=Kd;function Gd(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),lr(0,26,t)}Ke.u32=Gd;function Qc(t,e){if(typeof t=="string"&&e==16){if(t.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return lr(0,27,t)}if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),Ob),t=t.toString(16),lr(0,27,t)}Ke.u64=Qc;function Yd(t){if(isNaN(t))throw new RangeError("Invalid number.");if(t===0)return Lc(0);t=Math.min(Math.max(0,-t),24)-1;let e=[32+t];return new Uint8Array(e).buffer}Ke.iSmall=Yd;function Wd(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),lr(1,24,t)}Ke.i8=Wd;function zd(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),lr(1,25,t)}Ke.i16=zd;function Dd(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),lr(1,26,t)}Ke.i32=Dd;function Zd(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?lr(1,27,n):Qc(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),lr(1,27,t)}Ke.i64=Zd;function Pb(t){return t>=0?t<24?Lc(t):t<=255?$d(t):t<=65535?Kd(t):t<=4294967295?Gd(t):Qc(t):t>=-24?Yd(t):t>=-255?Wd(t):t>=-65535?zd(t):t>=-4294967295?Dd(t):Zd(t)}Ke.number=Pb;function Rb(t){return Yr(yo(2,t.byteLength),t)}Ke.bytes=Rb;function Ib(t){return Hd(t)}Ke.string=Ib;function Ub(t){return Yr(yo(4,t.length),...t)}Ke.array=Ub;function Fb(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))),Yr(yo(5,t.size),...r.map(([n,i])=>Yr(Hd(n),i)))}Ke.map=Fb;function Mb(t){let e=new Float32Array([t]);return Yr(new Uint8Array([250]),new Uint8Array(e.buffer))}Ke.singleFloat=Mb;function Cb(t){let e=new Float64Array([t]);return Yr(new Uint8Array([251]),new Uint8Array(e.buffer))}Ke.doubleFloat=Cb;function qb(t){return t?Xd():Jd()}Ke.bool=qb;function Xd(){return Zi(new Uint8Array([245]))}Ke.true_=Xd;function Jd(){return Zi(new Uint8Array([244]))}Ke.false_=Jd;function jb(){return Zi(new Uint8Array([246]))}Ke.null_=jb;function kb(){return Zi(new Uint8Array([247]))}Ke.undefined_=kb});var Ld=L(on=>{"use strict";var Vb=on&&on.__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(on,"__esModule",{value:!0});var fr=Vb(eu()),Hb=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],mo=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 fr.undefined_();case"boolean":return fr.bool(e);case"number":return Math.floor(e)===e?fr.number(e):fr.doubleFloat(e);case"string":return fr.string(e);case"object":if(e===null)return fr.null_();if(Array.isArray(e))return fr.array(e.map(r=>this._serializer.serializeValue(r)));if(Hb.find(r=>e instanceof r))return fr.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 fr.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 fr.map(r,this._stable)}default:throw new Error("Invalid value.")}}};on.JsonDefaultCborEncoder=mo;var go=class{constructor(){this.name="cborEncoder",this.priority=-90}match(e){return typeof e=="object"&&typeof e.toCBOR=="function"}encode(e){return e.toCBOR()}};on.ToCborEncoder=go;var bo=class{constructor(){this._encoders=new Set}static withDefaultEncoders(e=!1){let r=new this;return r.addEncoder(new mo(r,e)),r.addEncoder(new go),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)}};on.CborSerializer=bo;var tu=class extends bo{serialize(e){return fr.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(e))]))}};on.SelfDescribeCborSerializer=tu});var Xi=L(Rn=>{"use strict";function $b(t){for(var e in t)Rn.hasOwnProperty(e)||(Rn[e]=t[e])}var Kb=Rn&&Rn.__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(Rn,"__esModule",{value:!0});$b(Ld());var Gb=Kb(eu());Rn.value=Gb});var Ji=L(bt=>{"use strict";var Yb=bt&&bt.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Wb=bt&&bt.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),zb=bt&&bt.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Yb(e,t,r);return Wb(e,t),e},Db=bt&&bt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(bt,"__esModule",{value:!0});bt.decode=bt.encode=bt.CborTag=void 0;var Zb=Db(ho()),pi=zb(Xi()),Xb=Xi(),_o=Yt(),ru=class{get name(){return"Principal"}get priority(){return 0}match(e){return e&&e._isPrincipal===!0}encode(e){return pi.value.bytes(e.toUint8Array())}},nu=class{get name(){return"Buffer"}get priority(){return 1}match(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)}encode(e){return pi.value.bytes(new Uint8Array(e))}},iu=class{get name(){return"BigInt"}get priority(){return 1}match(e){return typeof e=="bigint"}encode(e){return e>BigInt(0)?pi.value.tagged(2,pi.value.bytes((0,_o.fromHex)(e.toString(16)))):pi.value.tagged(3,pi.value.bytes((0,_o.fromHex)((BigInt("-1")*e).toString(16))))}},wo=Xb.SelfDescribeCborSerializer.withDefaultEncoders(!0);wo.addEncoder(new ru);wo.addEncoder(new nu);wo.addEncoder(new iu);var e0;(function(t){t[t.Uint64LittleEndian=71]="Uint64LittleEndian",t[t.Semantic=55799]="Semantic"})(e0=bt.CborTag||(bt.CborTag={}));function Jb(t){return wo.serialize(t)}bt.encode=Jb;function Qd(t){let e=t.byteLength,r=BigInt(0);for(let n=0;n<e;n++)r=r*BigInt(256)+BigInt(t[n]);return r}var su=class extends Zb.default.Decoder{createByteString(e){return(0,_o.concat)(...e)}createByteStringFromHeap(e,r){return e===r?new ArrayBuffer(0):new Uint8Array(this._heap.slice(e,r))}};function Lb(t){let e=new Uint8Array(t),r=new su({size:e.byteLength,tags:{2:n=>Qd(n),3:n=>-Qd(n),[e0.Semantic]:n=>n}});try{return r.decodeFirst(e)}catch(n){throw new Error(`Failed to decode CBOR: ${n}, input: ${(0,_o.toHex)(e)}`)}}bt.decode=Lb});var ou=L(Eo=>{"use strict";Object.defineProperty(Eo,"__esModule",{value:!0});Eo.randomNumber=void 0;var Qb=()=>{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)};Eo.randomNumber=Qb});var Li=L(In=>{"use strict";Object.defineProperty(In,"__esModule",{value:!0});In.makeNonce=In.SubmitRequestType=void 0;var xo=ou(),e_;(function(t){t.Call="call"})(e_=In.SubmitRequestType||(In.SubmitRequestType={}));function t_(){let t=new ArrayBuffer(16),e=new DataView(t),r=(0,xo.randomNumber)(),n=(0,xo.randomNumber)(),i=(0,xo.randomNumber)(),s=(0,xo.randomNumber)();return e.setUint32(0,r),e.setUint32(4,n),e.setUint32(8,i),e.setUint32(12,s),t}In.makeNonce=t_});var To=L(At=>{"use strict";var r_=At&&At.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),n_=At&&At.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),i_=At&&At.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&r_(e,t,r);return n_(e,t),e};Object.defineProperty(At,"__esModule",{value:!0});At.httpHeadersTransform=At.makeExpiryTransform=At.makeNonceTransform=At.Expiry=void 0;var s_=fi(),o_=i_(Xi()),a_=Li(),c_=BigInt(1e6),u_=60*1e3,vo=class{constructor(e){let s=BigInt(Math.floor(Date.now()+e-u_))*c_/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=s}toCBOR(){return o_.value.u64(this._value.toString(16),16)}toHash(){return(0,s_.lebEncode)(this._value)}};At.Expiry=vo;function l_(t=a_.makeNonce){return async e=>{let r=e.request.headers;e.request.headers=r,e.endpoint==="call"&&(e.body.nonce=t())}}At.makeNonceTransform=l_;function f_(t){return async e=>{e.body.ingress_expiry=new vo(t)}}At.makeExpiryTransform=f_;function d_(t){let e=[];return t.forEach((r,n)=>{e.push([n,r])}),e}At.httpHeadersTransform=d_});var cu=L(Ao=>{"use strict";Object.defineProperty(Ao,"__esModule",{value:!0});Ao.AgentHTTPResponseError=void 0;var h_=ii(),au=class extends h_.AgentError{constructor(e,r){super(e),this.response=r,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};Ao.AgentHTTPResponseError=au});var Wt=L(Re=>{"use strict";Object.defineProperty(Re,"__esModule",{value:!0});Re.notImplemented=Re.bitMask=void 0;Re.isBytes=Bo;Re.abytes=Oo;Re.abool=y_;Re.bytesToHex=du;Re.numberToHexUnpadded=n0;Re.hexToNumber=hu;Re.hexToBytes=No;Re.bytesToNumberBE=g_;Re.bytesToNumberLE=b_;Re.numberToBytesBE=i0;Re.numberToBytesLE=__;Re.numberToVarBytesBE=w_;Re.ensureBytes=E_;Re.concatBytes=s0;Re.equalBytes=x_;Re.utf8ToBytes=v_;Re.inRange=o0;Re.aInRange=T_;Re.bitLen=A_;Re.bitGet=S_;Re.bitSet=B_;Re.createHmacDrbg=N_;Re.validateObject=R_;Re.memoized=U_;var fu=BigInt(0),So=BigInt(1),p_=BigInt(2);function Bo(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Oo(t){if(!Bo(t))throw new Error("Uint8Array expected")}function y_(t,e){if(typeof e!="boolean")throw new Error(`${t} must be valid boolean, got "${e}".`)}var m_=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function du(t){Oo(t);let e="";for(let r=0;r<t.length;r++)e+=m_[t[r]];return e}function n0(t){let e=t.toString(16);return e.length&1?`0${e}`:e}function hu(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}var Wr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function t0(t){if(t>=Wr._0&&t<=Wr._9)return t-Wr._0;if(t>=Wr._A&&t<=Wr._F)return t-(Wr._A-10);if(t>=Wr._a&&t<=Wr._f)return t-(Wr._a-10)}function No(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=t0(t.charCodeAt(s)),a=t0(t.charCodeAt(s+1));if(o===void 0||a===void 0){let c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=o*16+a}return n}function g_(t){return hu(du(t))}function b_(t){return Oo(t),hu(du(Uint8Array.from(t).reverse()))}function i0(t,e){return No(t.toString(16).padStart(e*2,"0"))}function __(t,e){return i0(t,e).reverse()}function w_(t){return No(n0(t))}function E_(t,e,r){let n;if(typeof e=="string")try{n=No(e)}catch(s){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${s}`)}else if(Bo(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 s0(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];Oo(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 x_(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 v_(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}var uu=t=>typeof t=="bigint"&&fu<=t;function o0(t,e,r){return uu(t)&&uu(e)&&uu(r)&&e<=t&&t<r}function T_(t,e,r,n){if(!o0(e,r,n))throw new Error(`expected valid ${t}: ${r} <= n < ${n}, got ${typeof e} ${e}`)}function A_(t){let e;for(e=0;t>fu;t>>=So,e+=1);return e}function S_(t,e){return t>>BigInt(e)&So}function B_(t,e,r){return t|(r?So:fu)<<BigInt(e)}var O_=t=>(p_<<BigInt(t-1))-So;Re.bitMask=O_;var lu=t=>new Uint8Array(t),r0=t=>Uint8Array.from(t);function N_(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=lu(t),i=lu(t),s=0,o=()=>{n.fill(1),i.fill(0),s=0},a=(...h)=>r(i,n,...h),c=(h=lu())=>{i=a(r0([0]),h),n=a(),h.length!==0&&(i=a(r0([1]),h),n=a())},f=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let h=0,S=[];for(;h<e;){n=a();let w=n.slice();S.push(w),h+=n.length}return s0(...S)};return(h,S)=>{o(),c(h);let w;for(;!(w=S(f()));)c();return o(),w}}var P_={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"||Bo(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 R_(t,e,r={}){let n=(i,s,o)=>{let a=P_[s];if(typeof a!="function")throw new Error(`Invalid validator "${s}", expected function`);let c=t[i];if(!(o&&c===void 0)&&!a(c,t))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${s}`)};for(let[i,s]of Object.entries(e))n(i,s,!1);for(let[i,s]of Object.entries(r))n(i,s,!0);return t}var I_=()=>{throw new Error("not implemented")};Re.notImplemented=I_;function U_(t){let e=new WeakMap;return(r,...n)=>{let i=e.get(r);if(i!==void 0)return i;let s=t(r,...n);return e.set(r,s),s}}});var Or=L(De=>{"use strict";Object.defineProperty(De,"__esModule",{value:!0});De.isNegativeLE=void 0;De.mod=zt;De.pow=u0;De.pow2=q_;De.invert=Po;De.tonelliShanks=l0;De.FpSqrt=f0;De.validateField=V_;De.FpPow=d0;De.FpInvertBatch=h0;De.FpDiv=H_;De.FpLegendre=p0;De.FpIsSquare=$_;De.nLength=yu;De.Field=K_;De.FpSqrtOdd=G_;De.FpSqrtEven=Y_;De.hashToPrivateScalar=W_;De.getFieldBytesLength=mu;De.getMinHashLength=y0;De.mapHashToField=z_;var Dt=Wt(),at=BigInt(0),He=BigInt(1),an=BigInt(2),F_=BigInt(3),pu=BigInt(4),a0=BigInt(5),c0=BigInt(8),M_=BigInt(9),C_=BigInt(16);function zt(t,e){let r=t%e;return r>=at?r:e+r}function u0(t,e,r){if(r<=at||e<at)throw new Error("Expected power/modulo > 0");if(r===He)return at;let n=He;for(;e>at;)e&He&&(n=n*t%r),t=t*t%r,e>>=He;return n}function q_(t,e,r){let n=t;for(;e-- >at;)n*=n,n%=r;return n}function Po(t,e){if(t===at||e<=at)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=zt(t,e),n=e,i=at,s=He,o=He,a=at;for(;r!==at;){let f=n/r,d=n%r,h=i-o*f,S=s-a*f;n=r,r=d,i=o,s=a,o=h,a=S}if(n!==He)throw new Error("invert: does not exist");return zt(i,e)}function l0(t){let e=(t-He)/an,r,n,i;for(r=t-He,n=0;r%an===at;r/=an,n++);for(i=an;i<t&&u0(i,e,t)!==t-He;i++);if(n===1){let o=(t+He)/pu;return function(c,f){let d=c.pow(f,o);if(!c.eql(c.sqr(d),f))throw new Error("Cannot find square root");return d}}let s=(r+He)/an;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=n,d=a.pow(a.mul(a.ONE,i),r),h=a.pow(c,s),S=a.pow(c,r);for(;!a.eql(S,a.ONE);){if(a.eql(S,a.ZERO))return a.ZERO;let w=1;for(let g=a.sqr(S);w<f&&!a.eql(g,a.ONE);w++)g=a.sqr(g);let u=a.pow(d,He<<BigInt(f-w-1));d=a.sqr(u),h=a.mul(h,u),S=a.mul(S,d),f=w}return h}}function f0(t){if(t%pu===F_){let e=(t+He)/pu;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%c0===a0){let e=(t-a0)/c0;return function(n,i){let s=n.mul(i,an),o=n.pow(s,e),a=n.mul(i,o),c=n.mul(n.mul(a,an),o),f=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(f),i))throw new Error("Cannot find square root");return f}}return t%C_,l0(t)}var j_=(t,e)=>(zt(t,e)&He)===He;De.isNegativeLE=j_;var k_=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function V_(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=k_.reduce((n,i)=>(n[i]="function",n),e);return(0,Dt.validateObject)(t,r)}function d0(t,e,r){if(r<at)throw new Error("Expected power > 0");if(r===at)return t.ONE;if(r===He)return e;let n=t.ONE,i=e;for(;r>at;)r&He&&(n=t.mul(n,i)),i=t.sqr(i),r>>=He;return n}function h0(t,e){let r=new Array(e.length),n=e.reduce((s,o,a)=>t.is0(o)?s:(r[a]=s,t.mul(s,o)),t.ONE),i=t.inv(n);return e.reduceRight((s,o,a)=>t.is0(o)?s:(r[a]=t.mul(s,r[a]),t.mul(s,o)),i),r}function H_(t,e,r){return t.mul(e,typeof r=="bigint"?Po(r,t.ORDER):t.inv(r))}function p0(t){let e=(t-He)/an;return(r,n)=>r.pow(n,e)}function $_(t){let e=p0(t.ORDER);return r=>{let n=e(t,r);return t.eql(n,t.ZERO)||t.eql(n,t.ONE)}}function yu(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function K_(t,e,r=!1,n={}){if(t<=at)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:s}=yu(t,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=f0(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:s,MASK:(0,Dt.bitMask)(i),ZERO:at,ONE:He,create:c=>zt(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return at<=c&&c<t},is0:c=>c===at,isOdd:c=>(c&He)===He,neg:c=>zt(-c,t),eql:(c,f)=>c===f,sqr:c=>zt(c*c,t),add:(c,f)=>zt(c+f,t),sub:(c,f)=>zt(c-f,t),mul:(c,f)=>zt(c*f,t),pow:(c,f)=>d0(a,c,f),div:(c,f)=>zt(c*Po(f,t),t),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>Po(c,t),sqrt:n.sqrt||(c=>o(a,c)),invertBatch:c=>h0(a,c),cmov:(c,f,d)=>d?f:c,toBytes:c=>r?(0,Dt.numberToBytesLE)(c,s):(0,Dt.numberToBytesBE)(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return r?(0,Dt.bytesToNumberLE)(c):(0,Dt.bytesToNumberBE)(c)}});return Object.freeze(a)}function G_(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let r=t.sqrt(e);return t.isOdd(r)?r:t.neg(r)}function Y_(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let r=t.sqrt(e);return t.isOdd(r)?t.neg(r):r}function W_(t,e,r=!1){t=(0,Dt.ensureBytes)("privateHash",t);let n=t.length,i=yu(e).nByteLength+8;if(i<24||n<i||n>1024)throw new Error(`hashToPrivateScalar: expected ${i}-1024 bytes of input, got ${n}`);let s=r?(0,Dt.bytesToNumberLE)(t):(0,Dt.bytesToNumberBE)(t);return zt(s,e-He)+He}function mu(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 y0(t){let e=mu(t);return e+Math.ceil(e/2)}function z_(t,e,r=!1){let n=t.length,i=mu(e),s=y0(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let o=r?(0,Dt.bytesToNumberBE)(t):(0,Dt.bytesToNumberLE)(t),a=zt(o,e-He)+He;return r?(0,Dt.numberToBytesLE)(a,i):(0,Dt.numberToBytesBE)(a,i)}});var Ro=L(Un=>{"use strict";Object.defineProperty(Un,"__esModule",{value:!0});Un.expand_message_xmd=m0;Un.expand_message_xof=g0;Un.hash_to_field=gu;Un.isogenyMap=J_;Un.createHasher=L_;var D_=Or(),St=Wt(),Z_=St.bytesToNumberBE;function cn(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 X_(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 bu(t){if(!Number.isSafeInteger(t))throw new Error("number expected")}function m0(t,e,r,n){(0,St.abytes)(t),(0,St.abytes)(e),bu(r),e.length>255&&(e=n((0,St.concatBytes)((0,St.utf8ToBytes)("H2C-OVERSIZE-DST-"),e)));let{outputLen:i,blockLen:s}=n,o=Math.ceil(r/i);if(o>255)throw new Error("Invalid xmd length");let a=(0,St.concatBytes)(e,cn(e.length,1)),c=cn(0,s),f=cn(r,2),d=new Array(o),h=n((0,St.concatBytes)(c,t,f,cn(0,1),a));d[0]=n((0,St.concatBytes)(h,cn(1,1),a));for(let w=1;w<=o;w++){let u=[X_(h,d[w-1]),cn(w+1,1),a];d[w]=n((0,St.concatBytes)(...u))}return(0,St.concatBytes)(...d).slice(0,r)}function g0(t,e,r,n,i){if((0,St.abytes)(t),(0,St.abytes)(e),bu(r),e.length>255){let s=Math.ceil(2*n/8);e=i.create({dkLen:s}).update((0,St.utf8ToBytes)("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(cn(r,2)).update(e).update(cn(e.length,1)).digest()}function gu(t,e,r){(0,St.validateObject)(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;(0,St.abytes)(t),bu(e);let f=typeof c=="string"?(0,St.utf8ToBytes)(c):c,d=n.toString(2).length,h=Math.ceil((d+i)/8),S=e*s*h,w;if(a==="xmd")w=m0(t,f,S,o);else if(a==="xof")w=g0(t,f,S,i,o);else if(a==="_internal_pass")w=t;else throw new Error('expand must be "xmd" or "xof"');let u=new Array(e);for(let g=0;g<e;g++){let U=new Array(s);for(let F=0;F<s;F++){let N=h*(F+g*s),V=w.subarray(N,N+h);U[F]=(0,D_.mod)(Z_(V),n)}u[g]=U}return u}function J_(t,e){let r=e.map(n=>Array.from(n).reverse());return(n,i)=>{let[s,o,a,c]=r.map(f=>f.reduce((d,h)=>t.add(t.mul(d,n),h)));return n=t.div(s,o),i=t.mul(i,t.div(a,c)),{x:n,y:i}}}function L_(t,e,r){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){let s=gu(n,2,{...r,DST:r.DST,...i}),o=t.fromAffine(e(s[0])),a=t.fromAffine(e(s[1])),c=o.add(a).clearCofactor();return c.assertValidity(),c},encodeToCurve(n,i){let s=gu(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 Eu=L(Io=>{"use strict";Object.defineProperty(Io,"__esModule",{value:!0});Io.wNAF=t1;Io.validateBasic=r1;var b0=Or(),Q_=Wt(),e1=BigInt(0),_u=BigInt(1),wu=new WeakMap,_0=new WeakMap;function t1(t,e){let r=(s,o)=>{let a=o.negate();return s?a:o},n=s=>{if(!Number.isSafeInteger(s)||s<=0||s>e)throw new Error(`Wrong window size=${s}, should be [1..${e}]`)},i=s=>{n(s);let o=Math.ceil(e/s)+1,a=2**(s-1);return{windows:o,windowSize:a}};return{constTimeNegate:r,unsafeLadder(s,o){let a=t.ZERO,c=s;for(;o>e1;)o&_u&&(a=a.add(c)),c=c.double(),o>>=_u;return a},precomputeWindow(s,o){let{windows:a,windowSize:c}=i(o),f=[],d=s,h=d;for(let S=0;S<a;S++){h=d,f.push(h);for(let w=1;w<c;w++)h=h.add(d),f.push(h);d=h.double()}return f},wNAF(s,o,a){let{windows:c,windowSize:f}=i(s),d=t.ZERO,h=t.BASE,S=BigInt(2**s-1),w=2**s,u=BigInt(s);for(let g=0;g<c;g++){let U=g*f,F=Number(a&S);a>>=u,F>f&&(F-=w,a+=_u);let N=U,V=U+Math.abs(F)-1,W=g%2!==0,T=F<0;F===0?h=h.add(r(W,o[N])):d=d.add(r(T,o[V]))}return{p:d,f:h}},wNAFCached(s,o,a){let c=_0.get(s)||1,f=wu.get(s);return f||(f=this.precomputeWindow(s,c),c!==1&&wu.set(s,a(f))),this.wNAF(c,f,o)},setWindowSize(s,o){n(o),_0.set(s,o),wu.delete(s)}}}function r1(t){return(0,b0.validateField)(t.Fp),(0,Q_.validateObject)(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,b0.nLength)(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}});var vu=L(Rt=>{"use strict";Object.defineProperty(Rt,"__esModule",{value:!0});Rt.DER=void 0;Rt.weierstrassPoints=x0;Rt.weierstrass=a1;Rt.SWUFpSqrtRatio=v0;Rt.mapToCurveSimpleSWU=c1;var xu=Eu(),yi=Or(),Ne=Wt(),_t=Wt();function w0(t){t.lowS!==void 0&&(0,_t.abool)("lowS",t.lowS),t.prehash!==void 0&&(0,_t.abool)("prehash",t.prehash)}function n1(t){let e=(0,xu.validateBasic)(t);Ne.validateObject(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})}var{bytesToNumberBE:i1,hexToBytes:s1}=Ne;Rt.DER={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){let{Err:e}=Rt.DER;if(t.length<2||t[0]!==2)throw new e("Invalid signature integer tag");let r=t[1],n=t.subarray(2,r+2);if(!r||n.length!==r)throw new e("Invalid signature integer: wrong length");if(n[0]&128)throw new e("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:i1(n),l:t.subarray(r+2)}},toSig(t){let{Err:e}=Rt.DER,r=typeof t=="string"?s1(t):t;Ne.abytes(r);let n=r.length;if(n<2||r[0]!=48)throw new e("Invalid signature tag");if(r[1]!==n-2)throw new e("Invalid signature: incorrect length");let{d:i,l:s}=Rt.DER._parseInt(r.subarray(2)),{d:o,l:a}=Rt.DER._parseInt(s);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s:o}},hexFromSig(t){let e=f=>Number.parseInt(f[0],16)&8?"00"+f:f,r=f=>{let d=f.toString(16);return d.length&1?`0${d}`:d},n=e(r(t.s)),i=e(r(t.r)),s=n.length/2,o=i.length/2,a=r(s),c=r(o);return`30${r(o+s+4)}02${c}${i}02${a}${n}`}};var Nr=BigInt(0),je=BigInt(1),un=BigInt(2),Uo=BigInt(3),E0=BigInt(4);function x0(t){let e=n1(t),{Fp:r}=e,n=e.toBytes||((u,g,U)=>{let F=g.toAffine();return Ne.concatBytes(Uint8Array.from([4]),r.toBytes(F.x),r.toBytes(F.y))}),i=e.fromBytes||(u=>{let g=u.subarray(1),U=r.fromBytes(g.subarray(0,r.BYTES)),F=r.fromBytes(g.subarray(r.BYTES,2*r.BYTES));return{x:U,y:F}});function s(u){let{a:g,b:U}=e,F=r.sqr(u),N=r.mul(F,u);return r.add(r.add(N,r.mul(u,g)),U)}if(!r.eql(r.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function o(u){return Ne.inRange(u,je,e.n)}function a(u){let{allowedPrivateKeyLengths:g,nByteLength:U,wrapPrivateKey:F,n:N}=e;if(g&&typeof u!="bigint"){if(Ne.isBytes(u)&&(u=Ne.bytesToHex(u)),typeof u!="string"||!g.includes(u.length))throw new Error("Invalid key");u=u.padStart(U*2,"0")}let V;try{V=typeof u=="bigint"?u:Ne.bytesToNumberBE((0,_t.ensureBytes)("private key",u,U))}catch{throw new Error(`private key must be ${U} bytes, hex or bigint, not ${typeof u}`)}return F&&(V=yi.mod(V,N)),Ne.aInRange("private key",V,je,N),V}function c(u){if(!(u instanceof h))throw new Error("ProjectivePoint expected")}let f=(0,_t.memoized)((u,g)=>{let{px:U,py:F,pz:N}=u;if(r.eql(N,r.ONE))return{x:U,y:F};let V=u.is0();g==null&&(g=V?r.ONE:r.inv(N));let W=r.mul(U,g),T=r.mul(F,g),C=r.mul(N,g);if(V)return{x:r.ZERO,y:r.ZERO};if(!r.eql(C,r.ONE))throw new Error("invZ was invalid");return{x:W,y:T}}),d=(0,_t.memoized)(u=>{if(u.is0()){if(e.allowInfinityPoint&&!r.is0(u.py))return;throw new Error("bad point: ZERO")}let{x:g,y:U}=u.toAffine();if(!r.isValid(g)||!r.isValid(U))throw new Error("bad point: x or y not FE");let F=r.sqr(U),N=s(g);if(!r.eql(F,N))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(g,U,F){if(this.px=g,this.py=U,this.pz=F,g==null||!r.isValid(g))throw new Error("x required");if(U==null||!r.isValid(U))throw new Error("y required");if(F==null||!r.isValid(F))throw new Error("z required");Object.freeze(this)}static fromAffine(g){let{x:U,y:F}=g||{};if(!g||!r.isValid(U)||!r.isValid(F))throw new Error("invalid affine point");if(g instanceof h)throw new Error("projective point not allowed");let N=V=>r.eql(V,r.ZERO);return N(U)&&N(F)?h.ZERO:new h(U,F,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(g){let U=r.invertBatch(g.map(F=>F.pz));return g.map((F,N)=>F.toAffine(U[N])).map(h.fromAffine)}static fromHex(g){let U=h.fromAffine(i((0,_t.ensureBytes)("pointHex",g)));return U.assertValidity(),U}static fromPrivateKey(g){return h.BASE.multiply(a(g))}_setWindowSize(g){w.setWindowSize(this,g)}assertValidity(){d(this)}hasEvenY(){let{y:g}=this.toAffine();if(r.isOdd)return!r.isOdd(g);throw new Error("Field doesn't support isOdd")}equals(g){c(g);let{px:U,py:F,pz:N}=this,{px:V,py:W,pz:T}=g,C=r.eql(r.mul(U,T),r.mul(V,N)),z=r.eql(r.mul(F,T),r.mul(W,N));return C&&z}negate(){return new h(this.px,r.neg(this.py),this.pz)}double(){let{a:g,b:U}=e,F=r.mul(U,Uo),{px:N,py:V,pz:W}=this,T=r.ZERO,C=r.ZERO,z=r.ZERO,D=r.mul(N,N),G=r.mul(V,V),ne=r.mul(W,W),Q=r.mul(N,V);return Q=r.add(Q,Q),z=r.mul(N,W),z=r.add(z,z),T=r.mul(g,z),C=r.mul(F,ne),C=r.add(T,C),T=r.sub(G,C),C=r.add(G,C),C=r.mul(T,C),T=r.mul(Q,T),z=r.mul(F,z),ne=r.mul(g,ne),Q=r.sub(D,ne),Q=r.mul(g,Q),Q=r.add(Q,z),z=r.add(D,D),D=r.add(z,D),D=r.add(D,ne),D=r.mul(D,Q),C=r.add(C,D),ne=r.mul(V,W),ne=r.add(ne,ne),D=r.mul(ne,Q),T=r.sub(T,D),z=r.mul(ne,G),z=r.add(z,z),z=r.add(z,z),new h(T,C,z)}add(g){c(g);let{px:U,py:F,pz:N}=this,{px:V,py:W,pz:T}=g,C=r.ZERO,z=r.ZERO,D=r.ZERO,G=e.a,ne=r.mul(e.b,Uo),Q=r.mul(U,V),le=r.mul(F,W),E=r.mul(N,T),_=r.add(U,F),b=r.add(V,W);_=r.mul(_,b),b=r.add(Q,le),_=r.sub(_,b),b=r.add(U,N);let x=r.add(V,T);return b=r.mul(b,x),x=r.add(Q,E),b=r.sub(b,x),x=r.add(F,N),C=r.add(W,T),x=r.mul(x,C),C=r.add(le,E),x=r.sub(x,C),D=r.mul(G,b),C=r.mul(ne,E),D=r.add(C,D),C=r.sub(le,D),D=r.add(le,D),z=r.mul(C,D),le=r.add(Q,Q),le=r.add(le,Q),E=r.mul(G,E),b=r.mul(ne,b),le=r.add(le,E),E=r.sub(Q,E),E=r.mul(G,E),b=r.add(b,E),Q=r.mul(le,b),z=r.add(z,Q),Q=r.mul(x,b),C=r.mul(_,C),C=r.sub(C,Q),Q=r.mul(_,le),D=r.mul(x,D),D=r.add(D,Q),new h(C,z,D)}subtract(g){return this.add(g.negate())}is0(){return this.equals(h.ZERO)}wNAF(g){return w.wNAFCached(this,g,h.normalizeZ)}multiplyUnsafe(g){Ne.aInRange("scalar",g,Nr,e.n);let U=h.ZERO;if(g===Nr)return U;if(g===je)return this;let{endo:F}=e;if(!F)return w.unsafeLadder(this,g);let{k1neg:N,k1:V,k2neg:W,k2:T}=F.splitScalar(g),C=U,z=U,D=this;for(;V>Nr||T>Nr;)V&je&&(C=C.add(D)),T&je&&(z=z.add(D)),D=D.double(),V>>=je,T>>=je;return N&&(C=C.negate()),W&&(z=z.negate()),z=new h(r.mul(z.px,F.beta),z.py,z.pz),C.add(z)}multiply(g){let{endo:U,n:F}=e;Ne.aInRange("scalar",g,je,F);let N,V;if(U){let{k1neg:W,k1:T,k2neg:C,k2:z}=U.splitScalar(g),{p:D,f:G}=this.wNAF(T),{p:ne,f:Q}=this.wNAF(z);D=w.constTimeNegate(W,D),ne=w.constTimeNegate(C,ne),ne=new h(r.mul(ne.px,U.beta),ne.py,ne.pz),N=D.add(ne),V=G.add(Q)}else{let{p:W,f:T}=this.wNAF(g);N=W,V=T}return h.normalizeZ([N,V])[0]}multiplyAndAddUnsafe(g,U,F){let N=h.BASE,V=(T,C)=>C===Nr||C===je||!T.equals(N)?T.multiplyUnsafe(C):T.multiply(C),W=V(this,U).add(V(g,F));return W.is0()?void 0:W}toAffine(g){return f(this,g)}isTorsionFree(){let{h:g,isTorsionFree:U}=e;if(g===je)return!0;if(U)return U(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:g,clearCofactor:U}=e;return g===je?this:U?U(h,this):this.multiplyUnsafe(e.h)}toRawBytes(g=!0){return(0,_t.abool)("isCompressed",g),this.assertValidity(),n(h,this,g)}toHex(g=!0){return(0,_t.abool)("isCompressed",g),Ne.bytesToHex(this.toRawBytes(g))}}h.BASE=new h(e.Gx,e.Gy,r.ONE),h.ZERO=new h(r.ZERO,r.ONE,r.ZERO);let S=e.nBitLength,w=(0,xu.wNAF)(h,e.endo?Math.ceil(S/2):S);return{CURVE:e,ProjectivePoint:h,normPrivateKeyToScalar:a,weierstrassEquation:s,isWithinCurveOrder:o}}function o1(t){let e=(0,xu.validateBasic)(t);return Ne.validateObject(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function a1(t){let e=o1(t),{Fp:r,n}=e,i=r.BYTES+1,s=2*r.BYTES+1;function o(_){return yi.mod(_,n)}function a(_){return yi.invert(_,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:f,weierstrassEquation:d,isWithinCurveOrder:h}=x0({...e,toBytes(_,b,x){let j=b.toAffine(),H=r.toBytes(j.x),X=Ne.concatBytes;return(0,_t.abool)("isCompressed",x),x?X(Uint8Array.from([b.hasEvenY()?2:3]),H):X(Uint8Array.from([4]),H,r.toBytes(j.y))},fromBytes(_){let b=_.length,x=_[0],j=_.subarray(1);if(b===i&&(x===2||x===3)){let H=Ne.bytesToNumberBE(j);if(!Ne.inRange(H,je,r.ORDER))throw new Error("Point is not on curve");let X=d(H),oe;try{oe=r.sqrt(X)}catch(R){let p=R instanceof Error?": "+R.message:"";throw new Error("Point is not on curve"+p)}let ae=(oe&je)===je;return(x&1)===1!==ae&&(oe=r.neg(oe)),{x:H,y:oe}}else if(b===s&&x===4){let H=r.fromBytes(j.subarray(0,r.BYTES)),X=r.fromBytes(j.subarray(r.BYTES,2*r.BYTES));return{x:H,y:X}}else throw new Error(`Point of length ${b} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}}),S=_=>Ne.bytesToHex(Ne.numberToBytesBE(_,e.nByteLength));function w(_){let b=n>>je;return _>b}function u(_){return w(_)?o(-_):_}let g=(_,b,x)=>Ne.bytesToNumberBE(_.slice(b,x));class U{constructor(b,x,j){this.r=b,this.s=x,this.recovery=j,this.assertValidity()}static fromCompact(b){let x=e.nByteLength;return b=(0,_t.ensureBytes)("compactSignature",b,x*2),new U(g(b,0,x),g(b,x,2*x))}static fromDER(b){let{r:x,s:j}=Rt.DER.toSig((0,_t.ensureBytes)("DER",b));return new U(x,j)}assertValidity(){Ne.aInRange("r",this.r,je,n),Ne.aInRange("s",this.s,je,n)}addRecoveryBit(b){return new U(this.r,this.s,b)}recoverPublicKey(b){let{r:x,s:j,recovery:H}=this,X=C((0,_t.ensureBytes)("msgHash",b));if(H==null||![0,1,2,3].includes(H))throw new Error("recovery id invalid");let oe=H===2||H===3?x+e.n:x;if(oe>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let ae=H&1?"03":"02",Y=c.fromHex(ae+S(oe)),R=a(oe),p=o(-X*R),ee=o(j*R),re=c.BASE.multiplyAndAddUnsafe(Y,p,ee);if(!re)throw new Error("point at infinify");return re.assertValidity(),re}hasHighS(){return w(this.s)}normalizeS(){return this.hasHighS()?new U(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Ne.hexToBytes(this.toDERHex())}toDERHex(){return Rt.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Ne.hexToBytes(this.toCompactHex())}toCompactHex(){return S(this.r)+S(this.s)}}let F={isValidPrivateKey(_){try{return f(_),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let _=yi.getMinHashLength(e.n);return yi.mapHashToField(e.randomBytes(_),e.n)},precompute(_=8,b=c.BASE){return b._setWindowSize(_),b.multiply(BigInt(3)),b}};function N(_,b=!0){return c.fromPrivateKey(_).toRawBytes(b)}function V(_){let b=Ne.isBytes(_),x=typeof _=="string",j=(b||x)&&_.length;return b?j===i||j===s:x?j===2*i||j===2*s:_ instanceof c}function W(_,b,x=!0){if(V(_))throw new Error("first arg must be private key");if(!V(b))throw new Error("second arg must be public key");return c.fromHex(b).multiply(f(_)).toRawBytes(x)}let T=e.bits2int||function(_){let b=Ne.bytesToNumberBE(_),x=_.length*8-e.nBitLength;return x>0?b>>BigInt(x):b},C=e.bits2int_modN||function(_){return o(T(_))},z=Ne.bitMask(e.nBitLength);function D(_){return Ne.aInRange(`num < 2^${e.nBitLength}`,_,Nr,z),Ne.numberToBytesBE(_,e.nByteLength)}function G(_,b,x=ne){if(["recovered","canonical"].some(J=>J in x))throw new Error("sign() legacy options not supported");let{hash:j,randomBytes:H}=e,{lowS:X,prehash:oe,extraEntropy:ae}=x;X==null&&(X=!0),_=(0,_t.ensureBytes)("msgHash",_),w0(x),oe&&(_=(0,_t.ensureBytes)("prehashed msgHash",j(_)));let Y=C(_),R=f(b),p=[D(R),D(Y)];if(ae!=null&&ae!==!1){let J=ae===!0?H(r.BYTES):ae;p.push((0,_t.ensureBytes)("extraEntropy",J))}let ee=Ne.concatBytes(...p),re=Y;function de(J){let l=T(J);if(!h(l))return;let y=a(l),m=c.BASE.multiply(l).toAffine(),P=o(m.x);if(P===Nr)return;let B=o(y*o(re+P*R));if(B===Nr)return;let O=(m.x===P?0:2)|Number(m.y&je),q=B;return X&&w(B)&&(q=u(B),O^=1),new U(P,q,O)}return{seed:ee,k2sig:de}}let ne={lowS:e.lowS,prehash:!1},Q={lowS:e.lowS,prehash:!1};function le(_,b,x=ne){let{seed:j,k2sig:H}=G(_,b,x),X=e;return Ne.createHmacDrbg(X.hash.outputLen,X.nByteLength,X.hmac)(j,H)}c.BASE._setWindowSize(8);function E(_,b,x,j=Q){let H=_;if(b=(0,_t.ensureBytes)("msgHash",b),x=(0,_t.ensureBytes)("publicKey",x),"strict"in j)throw new Error("options.strict was renamed to lowS");w0(j);let{lowS:X,prehash:oe}=j,ae,Y;try{if(typeof H=="string"||Ne.isBytes(H))try{ae=U.fromDER(H)}catch(m){if(!(m instanceof Rt.DER.Err))throw m;ae=U.fromCompact(H)}else if(typeof H=="object"&&typeof H.r=="bigint"&&typeof H.s=="bigint"){let{r:m,s:P}=H;ae=new U(m,P)}else throw new Error("PARSE");Y=c.fromHex(x)}catch(m){if(m.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(X&&ae.hasHighS())return!1;oe&&(b=e.hash(b));let{r:R,s:p}=ae,ee=C(b),re=a(p),de=o(ee*re),J=o(R*re),l=c.BASE.multiplyAndAddUnsafe(Y,de,J)?.toAffine();return l?o(l.x)===R:!1}return{CURVE:e,getPublicKey:N,getSharedSecret:W,sign:le,verify:E,ProjectivePoint:c,Signature:U,utils:F}}function v0(t,e){let r=t.ORDER,n=Nr;for(let u=r-je;u%un===Nr;u/=un)n+=je;let i=n,s=un<<i-je-je,o=s*un,a=(r-je)/o,c=(a-je)/un,f=o-je,d=s,h=t.pow(e,a),S=t.pow(e,(a+je)/un),w=(u,g)=>{let U=h,F=t.pow(g,f),N=t.sqr(F);N=t.mul(N,g);let V=t.mul(u,N);V=t.pow(V,c),V=t.mul(V,F),F=t.mul(V,g),N=t.mul(V,u);let W=t.mul(N,F);V=t.pow(W,d);let T=t.eql(V,t.ONE);F=t.mul(N,S),V=t.mul(W,U),N=t.cmov(F,N,T),W=t.cmov(V,W,T);for(let C=i;C>je;C--){let z=C-un;z=un<<z-je;let D=t.pow(W,z),G=t.eql(D,t.ONE);F=t.mul(N,U),U=t.mul(U,U),D=t.mul(W,U),N=t.cmov(F,N,G),W=t.cmov(D,W,G)}return{isValid:T,value:N}};if(t.ORDER%E0===Uo){let u=(t.ORDER-Uo)/E0,g=t.sqrt(t.neg(e));w=(U,F)=>{let N=t.sqr(F),V=t.mul(U,F);N=t.mul(N,V);let W=t.pow(N,u);W=t.mul(W,V);let T=t.mul(W,g),C=t.mul(t.sqr(W),F),z=t.eql(C,U),D=t.cmov(T,W,z);return{isValid:z,value:D}}}return w}function c1(t,e){if(yi.validateField(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let r=v0(t,e.Z);if(!t.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,s,o,a,c,f,d,h;i=t.sqr(n),i=t.mul(i,e.Z),s=t.sqr(i),s=t.add(s,i),o=t.add(s,t.ONE),o=t.mul(o,e.B),a=t.cmov(e.Z,t.neg(s),!t.eql(s,t.ZERO)),a=t.mul(a,e.A),s=t.sqr(o),f=t.sqr(a),c=t.mul(f,e.A),s=t.add(s,c),s=t.mul(s,o),f=t.mul(f,a),c=t.mul(f,e.B),s=t.add(s,c),d=t.mul(i,o);let{isValid:S,value:w}=r(s,f);h=t.mul(i,n),h=t.mul(h,w),d=t.cmov(d,o,S),h=t.cmov(h,w,S);let u=t.isOdd(n)===t.isOdd(h);return h=t.cmov(t.neg(h),h,u),d=t.div(d,a),{x:d,y:h}}}});var O0=L(Au=>{"use strict";Object.defineProperty(Au,"__esModule",{value:!0});Au.bls=f1;var T0=Or(),Tu=Wt(),A0=Ro(),S0=vu(),u1=BigInt(0),Fo=BigInt(1),B0=BigInt(2),mi=BigInt(3);function l1(t){let e=[];for(;t>Fo;t>>=Fo)(t&Fo)===u1?e.unshift(0):(t&mi)===mi?(e.unshift(-1),t+=Fo):e.unshift(1);return e}function f1(t){let{Fp:e,Fr:r,Fp2:n,Fp6:i,Fp12:s}=t.fields,o=t.params.xNegative,a=t.params.twistType,c=(0,S0.weierstrassPoints)({n:r.ORDER,...t.G1}),f=Object.assign(c,(0,A0.createHasher)(c.ProjectivePoint,t.G1.mapToCurve,{...t.htfDefaults,...t.G1.htfDefaults})),d=(0,S0.weierstrassPoints)({n:r.ORDER,...t.G2}),h=Object.assign(d,(0,A0.createHasher)(d.ProjectivePoint,t.G2.mapToCurve,{...t.htfDefaults,...t.G2.htfDefaults})),S;if(a==="multiplicative")S=(Y,R,p,ee,re,de)=>s.mul014(ee,Y,n.mul(R,re),n.mul(p,de));else if(a==="divisive")S=(Y,R,p,ee,re,de)=>s.mul034(ee,n.mul(p,de),n.mul(R,re),Y);else throw new Error("bls: unknown twist type");let w=n.div(n.ONE,n.mul(n.ONE,B0));function u(Y,R,p,ee){let re=n.sqr(p),de=n.sqr(ee),J=n.mulByB(n.mul(de,mi)),l=n.mul(J,mi),y=n.sub(n.sub(n.sqr(n.add(p,ee)),de),re),m=n.sub(J,re),P=n.mul(n.sqr(R),mi),B=n.neg(y);return Y.push([m,P,B]),R=n.mul(n.mul(n.mul(n.sub(re,l),R),p),w),p=n.sub(n.sqr(n.mul(n.add(re,l),w)),n.mul(n.sqr(J),mi)),ee=n.mul(re,y),{Rx:R,Ry:p,Rz:ee}}function g(Y,R,p,ee,re,de){let J=n.sub(p,n.mul(de,ee)),l=n.sub(R,n.mul(re,ee)),y=n.sub(n.mul(J,re),n.mul(l,de)),m=n.neg(J),P=l;Y.push([y,m,P]);let B=n.sqr(l),O=n.mul(B,l),q=n.mul(B,R),v=n.add(n.sub(O,n.mul(q,B0)),n.mul(n.sqr(J),ee));return R=n.mul(l,v),p=n.sub(n.mul(n.sub(q,v),J),n.mul(O,p)),ee=n.mul(ee,O),{Rx:R,Ry:p,Rz:ee}}let U=l1(t.params.ateLoopSize),F=(0,Tu.memoized)(Y=>{let R=Y,{x:p,y:ee}=R.toAffine(),re=p,de=ee,J=n.neg(ee),l=re,y=de,m=n.ONE,P=[];for(let B of U){let O=[];({Rx:l,Ry:y,Rz:m}=u(O,l,y,m)),B&&({Rx:l,Ry:y,Rz:m}=g(O,l,y,m,re,B===-1?J:de)),P.push(O)}if(t.postPrecompute){let B=P[P.length-1];t.postPrecompute(l,y,m,re,de,g.bind(null,B))}return P});function N(Y,R=!1){let p=s.ONE;if(Y.length){let ee=Y[0][0].length;for(let re=0;re<ee;re++){p=s.sqr(p);for(let[de,J,l]of Y)for(let[y,m,P]of de[re])p=S(y,m,P,p,J,l)}}return o&&(p=s.conjugate(p)),R?s.finalExponentiate(p):p}function V(Y,R=!0){let p=[];f.ProjectivePoint.normalizeZ(Y.map(({g1:ee})=>ee)),h.ProjectivePoint.normalizeZ(Y.map(({g2:ee})=>ee));for(let{g1:ee,g2:re}of Y){if(ee.equals(f.ProjectivePoint.ZERO)||re.equals(h.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");ee.assertValidity(),re.assertValidity();let de=ee.toAffine();p.push([F(re),de.x,de.y])}return N(p,R)}function W(Y,R,p=!0){return V([{g1:Y,g2:R}],p)}let T={randomPrivateKey:()=>{let Y=(0,T0.getMinHashLength)(r.ORDER);return(0,T0.mapHashToField)(t.randomBytes(Y),r.ORDER)},calcPairingPrecomputes:F},{ShortSignature:C}=t.G1,{Signature:z}=t.G2;function D(Y){return Y instanceof f.ProjectivePoint?Y:f.ProjectivePoint.fromHex(Y)}function G(Y,R){return Y instanceof f.ProjectivePoint?Y:f.hashToCurve((0,Tu.ensureBytes)("point",Y),R)}function ne(Y){return Y instanceof h.ProjectivePoint?Y:z.fromHex(Y)}function Q(Y,R){return Y instanceof h.ProjectivePoint?Y:h.hashToCurve((0,Tu.ensureBytes)("point",Y),R)}function le(Y){return f.ProjectivePoint.fromPrivateKey(Y).toRawBytes(!0)}function E(Y){return h.ProjectivePoint.fromPrivateKey(Y).toRawBytes(!0)}function _(Y,R,p){let ee=Q(Y,p);ee.assertValidity();let re=ee.multiply(f.normPrivateKeyToScalar(R));return Y instanceof h.ProjectivePoint?re:z.toRawBytes(re)}function b(Y,R,p){let ee=G(Y,p);ee.assertValidity();let re=ee.multiply(f.normPrivateKeyToScalar(R));return Y instanceof f.ProjectivePoint?re:C.toRawBytes(re)}function x(Y,R,p,ee){let re=D(p),de=Q(R,ee),J=f.ProjectivePoint.BASE,l=ne(Y),y=V([{g1:re.negate(),g2:de},{g1:J,g2:l}]);return s.eql(y,s.ONE)}function j(Y,R,p,ee){let re=ne(p),de=G(R,ee),J=h.ProjectivePoint.BASE,l=D(Y),y=V([{g1:de,g2:re},{g1:l,g2:J.negate()}]);return s.eql(y,s.ONE)}function H(Y){if(!Y.length)throw new Error("Expected non-empty array");let p=Y.map(D).reduce((ee,re)=>ee.add(re),f.ProjectivePoint.ZERO);return Y[0]instanceof f.ProjectivePoint?(p.assertValidity(),p):p.toRawBytes(!0)}function X(Y){if(!Y.length)throw new Error("Expected non-empty array");let p=Y.map(ne).reduce((ee,re)=>ee.add(re),h.ProjectivePoint.ZERO);return Y[0]instanceof h.ProjectivePoint?(p.assertValidity(),p):z.toRawBytes(p)}function oe(Y){if(!Y.length)throw new Error("Expected non-empty array");let p=Y.map(D).reduce((ee,re)=>ee.add(re),f.ProjectivePoint.ZERO);return Y[0]instanceof f.ProjectivePoint?(p.assertValidity(),p):C.toRawBytes(p)}function ae(Y,R,p,ee){if(!R.length)throw new Error("Expected non-empty messages array");if(p.length!==R.length)throw new Error("Pubkey count should equal msg count");let re=ne(Y),de=R.map(m=>Q(m,ee)),J=p.map(D),l=new Map;for(let m=0;m<J.length;m++){let P=J[m],B=de[m],O=l.get(B);O===void 0&&(O=[],l.set(B,O)),O.push(P)}let y=[];try{for(let[m,P]of l){let B=P.reduce((O,q)=>O.add(q));y.push({g1:B,g2:m})}return y.push({g1:f.ProjectivePoint.BASE.negate(),g2:re}),s.eql(V(y),s.ONE)}catch{return!1}}return f.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:le,getPublicKeyForShortSignatures:E,sign:_,signShortSignature:b,verify:x,verifyBatch:ae,verifyShortSignature:j,aggregatePublicKeys:H,aggregateSignatures:X,aggregateShortSignatures:oe,millerLoopBatch:N,pairing:W,pairingBatch:V,G1:f,G2:h,Signature:z,ShortSignature:C,fields:{Fr:r,Fp:e,Fp2:n,Fp6:i,Fp12:s},params:{ateLoopSize:t.params.ateLoopSize,r:t.params.r,G1b:t.G1.b,G2b:t.G2.b},utils:T}}});var P0=L(Mo=>{"use strict";Object.defineProperty(Mo,"__esModule",{value:!0});Mo.psiFrobenius=h1;Mo.tower12=p1;var ln=Or(),dr=Wt(),d1=BigInt(0),gi=BigInt(1),zr=BigInt(2),N0=BigInt(3);function Su(t,e,r,n,i=1,s){let o=BigInt(s===void 0?n:s),a=r**BigInt(n),c=[];for(let f=0;f<i;f++){let d=BigInt(f+1),h=[];for(let S=0,w=gi;S<n;S++){let u=(d*w-d)/o%a;h.push(t.pow(e,u)),w*=r}c.push(h)}return c}function h1(t,e,r){let n=e.pow(r,(t.ORDER-gi)/N0),i=e.pow(r,(t.ORDER-gi)/zr);function s(S,w){let u=e.mul(e.frobeniusMap(S,1),n),g=e.mul(e.frobeniusMap(w,1),i);return[u,g]}let o=e.pow(r,(t.ORDER**zr-gi)/N0),a=e.pow(r,(t.ORDER**zr-gi)/zr);if(!e.eql(a,e.neg(e.ONE)))throw new Error("psiFrobenius: PSI2_Y!==-1");function c(S,w){return[e.mul(S,o),e.neg(w)]}let f=S=>(w,u)=>{let g=u.toAffine(),U=S(g.x,g.y);return w.fromAffine({x:U[0],y:U[1]})},d=f(s),h=f(c);return{psi:s,psi2:c,G2psi:d,G2psi2:h,PSI_X:n,PSI_Y:i,PSI2_X:o,PSI2_Y:a}}function p1(t){let{ORDER:e}=t,r=ln.Field(e),n=r.create(t.NONRESIDUE||BigInt(-1)),i=ln.FpLegendre(e),s=r.div(r.ONE,zr),o=Su(r,n,r.ORDER,2)[0],a=({c0:E,c1:_},{c0:b,c1:x})=>({c0:r.add(E,b),c1:r.add(_,x)}),c=({c0:E,c1:_},{c0:b,c1:x})=>({c0:r.sub(E,b),c1:r.sub(_,x)}),f=({c0:E,c1:_},b)=>{if(typeof b=="bigint")return{c0:r.mul(E,b),c1:r.mul(_,b)};let{c0:x,c1:j}=b,H=r.mul(E,x),X=r.mul(_,j),oe=r.sub(H,X),ae=r.sub(r.mul(r.add(E,_),r.add(x,j)),r.add(H,X));return{c0:oe,c1:ae}},d=({c0:E,c1:_})=>{let b=r.add(E,_),x=r.sub(E,_),j=r.add(E,E);return{c0:r.mul(b,x),c1:r.mul(j,_)}},h=E=>{if(E.length!==2)throw new Error("Invalid tuple");let _=E.map(b=>r.create(b));return{c0:_[0],c1:_[1]}},S=e*e,w=h(t.FP2_NONRESIDUE),u={ORDER:S,NONRESIDUE:w,BITS:(0,dr.bitLen)(S),BYTES:Math.ceil((0,dr.bitLen)(S)/8),MASK:(0,dr.bitMask)((0,dr.bitLen)(S)),ZERO:{c0:r.ZERO,c1:r.ZERO},ONE:{c0:r.ONE,c1:r.ZERO},create:E=>E,isValid:({c0:E,c1:_})=>typeof E=="bigint"&&typeof _=="bigint",is0:({c0:E,c1:_})=>r.is0(E)&&r.is0(_),eql:({c0:E,c1:_},{c0:b,c1:x})=>r.eql(E,b)&&r.eql(_,x),neg:({c0:E,c1:_})=>({c0:r.neg(E),c1:r.neg(_)}),pow:(E,_)=>ln.FpPow(u,E,_),invertBatch:E=>ln.FpInvertBatch(u,E),add:a,sub:c,mul:f,sqr:d,addN:a,subN:c,mulN:f,sqrN:d,div:(E,_)=>u.mul(E,typeof _=="bigint"?r.inv(r.create(_)):u.inv(_)),inv:({c0:E,c1:_})=>{let b=r.inv(r.create(E*E+_*_));return{c0:r.mul(b,r.create(E)),c1:r.mul(b,r.create(-_))}},sqrt:E=>{if(t.Fp2sqrt)return t.Fp2sqrt(E);let{c0:_,c1:b}=E;if(r.is0(b))return r.eql(i(r,_),r.ONE)?u.create({c0:r.sqrt(_),c1:r.ZERO}):u.create({c0:r.ZERO,c1:r.sqrt(r.div(_,n))});let x=r.sqrt(r.sub(r.sqr(_),r.mul(r.sqr(b),n))),j=r.mul(r.add(x,_),s),H=i(r,j);!r.is0(H)&&!r.eql(H,r.ONE)&&(j=r.sub(j,x));let X=r.sqrt(j),oe=u.create({c0:X,c1:r.div(r.mul(b,s),X)});if(!u.eql(u.sqr(oe),E))throw new Error("Cannot find square root");let ae=oe,Y=u.neg(ae),{re:R,im:p}=u.reim(ae),{re:ee,im:re}=u.reim(Y);return p>re||p===re&&R>ee?ae:Y},isOdd:E=>{let{re:_,im:b}=u.reim(E),x=_%zr,j=_===d1,H=b%zr;return BigInt(x||j&&H)==gi},fromBytes(E){if(E.length!==u.BYTES)throw new Error(`fromBytes wrong length=${E.length}`);return{c0:r.fromBytes(E.subarray(0,r.BYTES)),c1:r.fromBytes(E.subarray(r.BYTES))}},toBytes:({c0:E,c1:_})=>(0,dr.concatBytes)(r.toBytes(E),r.toBytes(_)),cmov:({c0:E,c1:_},{c0:b,c1:x},j)=>({c0:r.cmov(E,b,j),c1:r.cmov(_,x,j)}),reim:({c0:E,c1:_})=>({re:E,im:_}),mulByNonresidue:({c0:E,c1:_})=>u.mul({c0:E,c1:_},w),mulByB:t.Fp2mulByB,fromBigTuple:h,frobeniusMap:({c0:E,c1:_},b)=>({c0:E,c1:r.mul(_,o[b%2])})},g=({c0:E,c1:_,c2:b},{c0:x,c1:j,c2:H})=>({c0:u.add(E,x),c1:u.add(_,j),c2:u.add(b,H)}),U=({c0:E,c1:_,c2:b},{c0:x,c1:j,c2:H})=>({c0:u.sub(E,x),c1:u.sub(_,j),c2:u.sub(b,H)}),F=({c0:E,c1:_,c2:b},x)=>{if(typeof x=="bigint")return{c0:u.mul(E,x),c1:u.mul(_,x),c2:u.mul(b,x)};let{c0:j,c1:H,c2:X}=x,oe=u.mul(E,j),ae=u.mul(_,H),Y=u.mul(b,X);return{c0:u.add(oe,u.mulByNonresidue(u.sub(u.mul(u.add(_,b),u.add(H,X)),u.add(ae,Y)))),c1:u.add(u.sub(u.mul(u.add(E,_),u.add(j,H)),u.add(oe,ae)),u.mulByNonresidue(Y)),c2:u.sub(u.add(ae,u.mul(u.add(E,b),u.add(j,X))),u.add(oe,Y))}},N=({c0:E,c1:_,c2:b})=>{let x=u.sqr(E),j=u.mul(u.mul(E,_),zr),H=u.mul(u.mul(_,b),zr),X=u.sqr(b);return{c0:u.add(u.mulByNonresidue(H),x),c1:u.add(u.mulByNonresidue(X),j),c2:u.sub(u.sub(u.add(u.add(j,u.sqr(u.add(u.sub(E,_),b))),H),x),X)}},[V,W]=Su(u,w,r.ORDER,6,2,3),T={ORDER:u.ORDER,BITS:3*u.BITS,BYTES:3*u.BYTES,MASK:(0,dr.bitMask)(3*u.BITS),ZERO:{c0:u.ZERO,c1:u.ZERO,c2:u.ZERO},ONE:{c0:u.ONE,c1:u.ZERO,c2:u.ZERO},create:E=>E,isValid:({c0:E,c1:_,c2:b})=>u.isValid(E)&&u.isValid(_)&&u.isValid(b),is0:({c0:E,c1:_,c2:b})=>u.is0(E)&&u.is0(_)&&u.is0(b),neg:({c0:E,c1:_,c2:b})=>({c0:u.neg(E),c1:u.neg(_),c2:u.neg(b)}),eql:({c0:E,c1:_,c2:b},{c0:x,c1:j,c2:H})=>u.eql(E,x)&&u.eql(_,j)&&u.eql(b,H),sqrt:dr.notImplemented,div:(E,_)=>T.mul(E,typeof _=="bigint"?r.inv(r.create(_)):T.inv(_)),pow:(E,_)=>ln.FpPow(T,E,_),invertBatch:E=>ln.FpInvertBatch(T,E),add:g,sub:U,mul:F,sqr:N,addN:g,subN:U,mulN:F,sqrN:N,inv:({c0:E,c1:_,c2:b})=>{let x=u.sub(u.sqr(E),u.mulByNonresidue(u.mul(b,_))),j=u.sub(u.mulByNonresidue(u.sqr(b)),u.mul(E,_)),H=u.sub(u.sqr(_),u.mul(E,b)),X=u.inv(u.add(u.mulByNonresidue(u.add(u.mul(b,j),u.mul(_,H))),u.mul(E,x)));return{c0:u.mul(X,x),c1:u.mul(X,j),c2:u.mul(X,H)}},fromBytes:E=>{if(E.length!==T.BYTES)throw new Error(`fromBytes wrong length=${E.length}`);return{c0:u.fromBytes(E.subarray(0,u.BYTES)),c1:u.fromBytes(E.subarray(u.BYTES,2*u.BYTES)),c2:u.fromBytes(E.subarray(2*u.BYTES))}},toBytes:({c0:E,c1:_,c2:b})=>(0,dr.concatBytes)(u.toBytes(E),u.toBytes(_),u.toBytes(b)),cmov:({c0:E,c1:_,c2:b},{c0:x,c1:j,c2:H},X)=>({c0:u.cmov(E,x,X),c1:u.cmov(_,j,X),c2:u.cmov(b,H,X)}),fromBigSix:E=>{if(!Array.isArray(E)||E.length!==6)throw new Error("Invalid Fp6 usage");return{c0:u.fromBigTuple(E.slice(0,2)),c1:u.fromBigTuple(E.slice(2,4)),c2:u.fromBigTuple(E.slice(4,6))}},frobeniusMap:({c0:E,c1:_,c2:b},x)=>({c0:u.frobeniusMap(E,x),c1:u.mul(u.frobeniusMap(_,x),V[x%6]),c2:u.mul(u.frobeniusMap(b,x),W[x%6])}),mulByFp2:({c0:E,c1:_,c2:b},x)=>({c0:u.mul(E,x),c1:u.mul(_,x),c2:u.mul(b,x)}),mulByNonresidue:({c0:E,c1:_,c2:b})=>({c0:u.mulByNonresidue(b),c1:E,c2:_}),mul1:({c0:E,c1:_,c2:b},x)=>({c0:u.mulByNonresidue(u.mul(b,x)),c1:u.mul(E,x),c2:u.mul(_,x)}),mul01({c0:E,c1:_,c2:b},x,j){let H=u.mul(E,x),X=u.mul(_,j);return{c0:u.add(u.mulByNonresidue(u.sub(u.mul(u.add(_,b),j),X)),H),c1:u.sub(u.sub(u.mul(u.add(x,j),u.add(E,_)),H),X),c2:u.add(u.sub(u.mul(u.add(E,b),x),H),X)}}},C=Su(u,w,r.ORDER,12,1,6)[0],z=({c0:E,c1:_},{c0:b,c1:x})=>({c0:T.add(E,b),c1:T.add(_,x)}),D=({c0:E,c1:_},{c0:b,c1:x})=>({c0:T.sub(E,b),c1:T.sub(_,x)}),G=({c0:E,c1:_},b)=>{if(typeof b=="bigint")return{c0:T.mul(E,b),c1:T.mul(_,b)};let{c0:x,c1:j}=b,H=T.mul(E,x),X=T.mul(_,j);return{c0:T.add(H,T.mulByNonresidue(X)),c1:T.sub(T.mul(T.add(E,_),T.add(x,j)),T.add(H,X))}},ne=({c0:E,c1:_})=>{let b=T.mul(E,_);return{c0:T.sub(T.sub(T.mul(T.add(T.mulByNonresidue(_),E),T.add(E,_)),b),T.mulByNonresidue(b)),c1:T.add(b,b)}};function Q(E,_){let b=u.sqr(E),x=u.sqr(_);return{first:u.add(u.mulByNonresidue(x),b),second:u.sub(u.sub(u.sqr(u.add(E,_)),b),x)}}let le={ORDER:u.ORDER,BITS:2*u.BITS,BYTES:2*u.BYTES,MASK:(0,dr.bitMask)(2*u.BITS),ZERO:{c0:T.ZERO,c1:T.ZERO},ONE:{c0:T.ONE,c1:T.ZERO},create:E=>E,isValid:({c0:E,c1:_})=>T.isValid(E)&&T.isValid(_),is0:({c0:E,c1:_})=>T.is0(E)&&T.is0(_),neg:({c0:E,c1:_})=>({c0:T.neg(E),c1:T.neg(_)}),eql:({c0:E,c1:_},{c0:b,c1:x})=>T.eql(E,b)&&T.eql(_,x),sqrt:dr.notImplemented,inv:({c0:E,c1:_})=>{let b=T.inv(T.sub(T.sqr(E),T.mulByNonresidue(T.sqr(_))));return{c0:T.mul(E,b),c1:T.neg(T.mul(_,b))}},div:(E,_)=>le.mul(E,typeof _=="bigint"?r.inv(r.create(_)):le.inv(_)),pow:(E,_)=>ln.FpPow(le,E,_),invertBatch:E=>ln.FpInvertBatch(le,E),add:z,sub:D,mul:G,sqr:ne,addN:z,subN:D,mulN:G,sqrN:ne,fromBytes:E=>{if(E.length!==le.BYTES)throw new Error(`fromBytes wrong length=${E.length}`);return{c0:T.fromBytes(E.subarray(0,T.BYTES)),c1:T.fromBytes(E.subarray(T.BYTES))}},toBytes:({c0:E,c1:_})=>(0,dr.concatBytes)(T.toBytes(E),T.toBytes(_)),cmov:({c0:E,c1:_},{c0:b,c1:x},j)=>({c0:T.cmov(E,b,j),c1:T.cmov(_,x,j)}),fromBigTwelve:E=>({c0:T.fromBigSix(E.slice(0,6)),c1:T.fromBigSix(E.slice(6,12))}),frobeniusMap(E,_){let{c0:b,c1:x,c2:j}=T.frobeniusMap(E.c1,_),H=C[_%12];return{c0:T.frobeniusMap(E.c0,_),c1:T.create({c0:u.mul(b,H),c1:u.mul(x,H),c2:u.mul(j,H)})}},mulByFp2:({c0:E,c1:_},b)=>({c0:T.mulByFp2(E,b),c1:T.mulByFp2(_,b)}),conjugate:({c0:E,c1:_})=>({c0:E,c1:T.neg(_)}),mul014:({c0:E,c1:_},b,x,j)=>{let H=T.mul01(E,b,x),X=T.mul1(_,j);return{c0:T.add(T.mulByNonresidue(X),H),c1:T.sub(T.sub(T.mul01(T.add(_,E),b,u.add(x,j)),H),X)}},mul034:({c0:E,c1:_},b,x,j)=>{let H=T.create({c0:u.mul(E.c0,b),c1:u.mul(E.c1,b),c2:u.mul(E.c2,b)}),X=T.mul01(_,x,j),oe=T.mul01(T.add(E,_),u.add(b,x),j);return{c0:T.add(T.mulByNonresidue(X),H),c1:T.sub(oe,T.add(H,X))}},_cyclotomicSquare:t.Fp12cyclotomicSquare,_cyclotomicExp:t.Fp12cyclotomicExp,finalExponentiate:t.Fp12finalExponentiate};return{Fp:r,Fp2:u,Fp6:T,Fp4Square:Q,Fp12:le}}});var k0=L(Ut=>{"use strict";Object.defineProperty(Ut,"__esModule",{value:!0});Ut.bls12_381=void 0;var M0=Us(),y1=Bn(),m1=O0(),g1=Or(),Ae=Wt(),C0=Ro(),q0=vu(),j0=P0(),It=BigInt(0),jo=BigInt(1),ht=BigInt(2),Co=BigInt(3),Qi=BigInt(4),fn=BigInt("0xd201000000010000"),b1=(0,Ae.bitLen)(fn),{Fp:ue,Fp2:he,Fp6:Nu,Fp4Square:Bu,Fp12:ve}=(0,j0.tower12)({ORDER:BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),FP2_NONRESIDUE:[jo,jo],Fp2mulByB:({c0:t,c1:e})=>{let r=ue.mul(t,Qi),n=ue.mul(e,Qi);return{c0:ue.sub(r,n),c1:ue.add(r,n)}},Fp12cyclotomicSquare:({c0:t,c1:e})=>{let{c0:r,c1:n,c2:i}=t,{c0:s,c1:o,c2:a}=e,{first:c,second:f}=Bu(r,o),{first:d,second:h}=Bu(s,i),{first:S,second:w}=Bu(n,a),u=he.mulByNonresidue(w);return{c0:Nu.create({c0:he.add(he.mul(he.sub(c,r),ht),c),c1:he.add(he.mul(he.sub(d,n),ht),d),c2:he.add(he.mul(he.sub(S,i),ht),S)}),c1:Nu.create({c0:he.add(he.mul(he.add(u,s),ht),u),c1:he.add(he.mul(he.add(f,o),ht),f),c2:he.add(he.mul(he.add(h,a),ht),h)})}},Fp12cyclotomicExp(t,e){let r=ve.ONE;for(let n=b1-1;n>=0;n--)r=ve._cyclotomicSquare(r),(0,Ae.bitGet)(e,n)&&(r=ve.mul(r,t));return r},Fp12finalExponentiate:t=>{let e=fn,r=ve.div(ve.frobeniusMap(t,6),t),n=ve.mul(ve.frobeniusMap(r,2),r),i=ve.conjugate(ve._cyclotomicExp(n,e)),s=ve.mul(ve.conjugate(ve._cyclotomicSquare(n)),i),o=ve.conjugate(ve._cyclotomicExp(s,e)),a=ve.conjugate(ve._cyclotomicExp(o,e)),c=ve.mul(ve.conjugate(ve._cyclotomicExp(a,e)),ve._cyclotomicSquare(i)),f=ve.conjugate(ve._cyclotomicExp(c,e)),d=ve.frobeniusMap(ve.mul(i,a),2),h=ve.frobeniusMap(ve.mul(o,n),3),S=ve.frobeniusMap(ve.mul(c,ve.conjugate(n)),1),w=ve.mul(ve.mul(f,ve.conjugate(s)),n);return ve.mul(ve.mul(ve.mul(d,h),S),w)}}),R0=g1.Field(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),_1=(0,C0.isogenyMap)(he,[[["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=>he.fromBigTuple(e.map(BigInt))))),w1=(0,C0.isogenyMap)(ue,[["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)))),E1=(0,q0.mapToCurveSimpleSWU)(he,{A:he.create({c0:ue.create(It),c1:ue.create(BigInt(240))}),B:he.create({c0:ue.create(BigInt(1012)),c1:ue.create(BigInt(1012))}),Z:he.create({c0:ue.create(BigInt(-2)),c1:ue.create(BigInt(-1))})}),x1=(0,q0.mapToCurveSimpleSWU)(ue,{A:ue.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:ue.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:ue.create(BigInt(11))}),{G2psi:I0,G2psi2:v1}=(0,j0.psiFrobenius)(ue,he,he.div(he.ONE,he.NONRESIDUE)),Ou=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:ue.ORDER,m:2,k:128,expand:"xmd",hash:M0.sha256}),ko=es(ue.toBytes(It),{infinity:!0,compressed:!0});function qo(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 es(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 U0(t){t.assertValidity();let e=t.equals(Ut.bls12_381.G1.ProjectivePoint.ZERO),{x:r,y:n}=t.toAffine();if(e)return ko.slice();let i=ue.ORDER,s=!!(n*ht/i);return es((0,Ae.numberToBytesBE)(r,ue.BYTES),{compressed:!0,sort:s})}function F0(t){t.assertValidity();let e=ue.BYTES;if(t.equals(Ut.bls12_381.G2.ProjectivePoint.ZERO))return(0,Ae.concatBytes)(ko,(0,Ae.numberToBytesBE)(It,e));let{x:r,y:n}=t.toAffine(),{re:i,im:s}=he.reim(r),{re:o,im:a}=he.reim(n),f=!!((a>It?a*ht:o*ht)/ue.ORDER&jo),d=i;return(0,Ae.concatBytes)(es((0,Ae.numberToBytesBE)(s,e),{sort:f,compressed:!0}),(0,Ae.numberToBytesBE)(d,e))}Ut.bls12_381=(0,m1.bls)({fields:{Fp:ue,Fp2:he,Fp6:Nu,Fp12:ve,Fr:R0},G1:{Fp:ue,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:ue.ZERO,b:Qi,htfDefaults:{...Ou,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(ue.mul(e.px,r),e.py,e.pz);return e.multiplyUnsafe(fn).negate().multiplyUnsafe(fn).equals(n)},clearCofactor:(t,e)=>e.multiplyUnsafe(fn).add(e),mapToCurve:t=>{let{x:e,y:r}=x1(ue.create(t[0]));return w1(e,r)},fromBytes:t=>{let{compressed:e,infinity:r,sort:n,value:i}=qo(t);if(i.length===48&&e){let s=ue.ORDER,o=(0,Ae.bytesToNumberBE)(i),a=ue.create(o&ue.MASK);if(r){if(a!==It)throw new Error("G1: non-empty compressed point at infinity");return{x:It,y:It}}let c=ue.add(ue.pow(a,Co),ue.create(Ut.bls12_381.params.G1b)),f=ue.sqrt(c);if(!f)throw new Error("Invalid compressed G1 point");return f*ht/s!==BigInt(n)&&(f=ue.neg(f)),{x:ue.create(a),y:ue.create(f)}}else if(i.length===96&&!e){let s=(0,Ae.bytesToNumberBE)(i.subarray(0,ue.BYTES)),o=(0,Ae.bytesToNumberBE)(i.subarray(ue.BYTES));if(r){if(s!==It||o!==It)throw new Error("G1: non-empty point at infinity");return Ut.bls12_381.G1.ProjectivePoint.ZERO.toAffine()}return{x:ue.create(s),y:ue.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 ko.slice();let o=ue.ORDER,a=!!(s*ht/o);return es((0,Ae.numberToBytesBE)(i,ue.BYTES),{compressed:!0,sort:a})}else return n?(0,Ae.concatBytes)(new Uint8Array([64]),new Uint8Array(2*ue.BYTES-1)):(0,Ae.concatBytes)((0,Ae.numberToBytesBE)(i,ue.BYTES),(0,Ae.numberToBytesBE)(s,ue.BYTES))},ShortSignature:{fromHex(t){let{infinity:e,sort:r,value:n}=qo((0,Ae.ensureBytes)("signatureHex",t,48)),i=ue.ORDER,s=(0,Ae.bytesToNumberBE)(n);if(e)return Ut.bls12_381.G1.ProjectivePoint.ZERO;let o=ue.create(s&ue.MASK),a=ue.add(ue.pow(o,Co),ue.create(Ut.bls12_381.params.G1b)),c=ue.sqrt(a);if(!c)throw new Error("Invalid compressed G1 point");let f=BigInt(r);c*ht/i!==f&&(c=ue.neg(c));let d=Ut.bls12_381.G1.ProjectivePoint.fromAffine({x:o,y:c});return d.assertValidity(),d},toRawBytes(t){return U0(t)},toHex(t){return(0,Ae.bytesToHex)(U0(t))}}},G2:{Fp:he,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),Gx:he.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:he.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")]),a:he.ZERO,b:he.fromBigTuple([Qi,Qi]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...Ou},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:t=>{let{x:e,y:r}=E1(he.fromBigTuple(t));return _1(e,r)},isTorsionFree:(t,e)=>e.multiplyUnsafe(fn).negate().equals(I0(t,e)),clearCofactor:(t,e)=>{let r=fn,n=e.multiplyUnsafe(r).negate(),i=I0(t,e),s=e.double();return s=v1(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}=qo(t);if(!e&&!r&&n||!e&&r&&n||n&&r&&e)throw new Error("Invalid encoding flag: "+(t[0]&224));let s=ue.BYTES,o=(a,c,f)=>(0,Ae.bytesToNumberBE)(a.slice(c,f));if(i.length===96&&e){let a=Ut.bls12_381.params.G2b,c=ue.ORDER;if(r){if(i.reduce((g,U)=>g!==0?U+1:U,0)>0)throw new Error("Invalid compressed G2 point");return{x:he.ZERO,y:he.ZERO}}let f=o(i,0,s),d=o(i,s,2*s),h=he.create({c0:ue.create(d),c1:ue.create(f)}),S=he.add(he.pow(h,Co),a),w=he.sqrt(S),u=w.c1===It?w.c0*ht/c:w.c1*ht/c?jo:It;return w=n&&u>0?w:he.neg(w),{x:h,y:w}}else if(i.length===192&&!e){if(r){if(i.reduce((h,S)=>h!==0?S+1:S,0)>0)throw new Error("Invalid uncompressed G2 point");return{x:he.ZERO,y:he.ZERO}}let a=o(i,0,s),c=o(i,s,2*s),f=o(i,2*s,3*s),d=o(i,3*s,4*s);return{x:he.fromBigTuple([c,a]),y:he.fromBigTuple([d,f])}}else throw new Error("Invalid point G2, expected 96/192 bytes")},toBytes:(t,e,r)=>{let{BYTES:n,ORDER:i}=ue,s=e.equals(t.ZERO),{x:o,y:a}=e.toAffine();if(r){if(s)return(0,Ae.concatBytes)(ko,(0,Ae.numberToBytesBE)(It,n));let c=!!(a.c1===It?a.c0*ht/i:a.c1*ht/i);return(0,Ae.concatBytes)(es((0,Ae.numberToBytesBE)(o.c1,n),{compressed:!0,sort:c}),(0,Ae.numberToBytesBE)(o.c0,n))}else{if(s)return(0,Ae.concatBytes)(new Uint8Array([64]),new Uint8Array(4*n-1));let{re:c,im:f}=he.reim(o),{re:d,im:h}=he.reim(a);return(0,Ae.concatBytes)((0,Ae.numberToBytesBE)(f,n),(0,Ae.numberToBytesBE)(c,n),(0,Ae.numberToBytesBE)(h,n),(0,Ae.numberToBytesBE)(d,n))}},Signature:{fromHex(t){let{infinity:e,sort:r,value:n}=qo((0,Ae.ensureBytes)("signatureHex",t)),i=ue.ORDER,s=n.length/2;if(s!==48&&s!==96)throw new Error("Invalid compressed signature length, must be 96 or 192");let o=(0,Ae.bytesToNumberBE)(n.slice(0,s)),a=(0,Ae.bytesToNumberBE)(n.slice(s));if(e)return Ut.bls12_381.G2.ProjectivePoint.ZERO;let c=ue.create(o&ue.MASK),f=ue.create(a),d=he.create({c0:f,c1:c}),h=he.add(he.pow(d,Co),Ut.bls12_381.params.G2b),S=he.sqrt(h);if(!S)throw new Error("Failed to find a square root");let{re:w,im:u}=he.reim(S),g=BigInt(r),U=u>It&&u*ht/i!==g,F=u===It&&w*ht/i!==g;(U||F)&&(S=he.neg(S));let N=Ut.bls12_381.G2.ProjectivePoint.fromAffine({x:d,y:S});return N.assertValidity(),N},toRawBytes(t){return F0(t)},toHex(t){return(0,Ae.bytesToHex)(F0(t))}}},params:{ateLoopSize:fn,r:R0.ORDER,xNegative:!0,twistType:"multiplicative"},htfDefaults:Ou,hash:M0.sha256,randomBytes:y1.randomBytes})});var Ru=L(ts=>{"use strict";Object.defineProperty(ts,"__esModule",{value:!0});ts.blsVerify=ts.verify=void 0;var T1=k0(),Pu=Yt();function A1(t,e,r){let n=typeof t=="string"?t:(0,Pu.toHex)(t),i=typeof e=="string"?e:(0,Pu.toHex)(e),s=typeof r=="string"?r:(0,Pu.toHex)(r);return T1.bls12_381.verifyShortSignature(i,s,n)}ts.blsVerify=A1});var Vo=L(Fn=>{"use strict";Object.defineProperty(Fn,"__esModule",{value:!0});Fn.decodeTime=Fn.decodeLeb128=void 0;var V0=fi(),S1=t=>(0,V0.lebDecode)(new V0.PipeArrayBuffer(t));Fn.decodeLeb128=S1;var B1=t=>{let e=(0,Fn.decodeLeb128)(t);return new Date(Number(e)/1e6)};Fn.decodeTime=B1});var os=L(Be=>{"use strict";var O1=Be&&Be.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),N1=Be&&Be.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),H0=Be&&Be.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&O1(e,t,r);return N1(e,t),e};Object.defineProperty(Be,"__esModule",{value:!0});Be.check_canister_ranges=Be.find_label=Be.flatten_forks=Be.lookup_path=Be.LookupStatus=Be.reconstruct=Be.lookupResultToBuffer=Be.Certificate=Be.hashTreeToString=Be.NodeType=Be.CertificateVerificationError=void 0;var $0=H0(Ji()),P1=ii(),Ho=Di(),hr=Yt(),Iu=Nt(),R1=H0(Ru()),I1=Vo(),Dr=class extends P1.AgentError{constructor(e){super(`Invalid certificate: ${e}`)}};Be.CertificateVerificationError=Dr;var wt;(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=Be.NodeType||(Be.NodeType={}));function $o(t){let e=n=>n.split(`
16
+ `)}return c.encodeValue(f)}));return(0,Ne.concat)(n,i,s,o,a)}Y.encode=Hm;function Vm(t,e){let r=new Ne.PipeArrayBuffer(e);if(e.byteLength<oo.length)throw new Error("Message length smaller than magic number");let n=(0,se.safeRead)(r,oo.length),i=new TextDecoder().decode(n);if(i!==oo)throw new Error("Wrong magic number: "+JSON.stringify(i));function s(_){let u=[],T=Number((0,se.lebDecode)(_));for(let F=0;F<T;F++){let M=Number((0,se.slebDecode)(_));switch(M){case-18:case-19:{let K=Number((0,se.slebDecode)(_));u.push([M,K]);break}case-20:case-21:{let K=[],x=Number((0,se.lebDecode)(_)),$;for(;x--;){let W=Number((0,se.lebDecode)(_));if(W>=Math.pow(2,32))throw new Error("field id out of 32-bit range");if(typeof $=="number"&&$>=W)throw new Error("field id collision or not sorted");$=W;let D=Number((0,se.slebDecode)(_));K.push([W,D])}u.push([M,K]);break}case-22:{let K=[],x=Number((0,se.lebDecode)(_));for(;x--;)K.push(Number((0,se.slebDecode)(_)));let $=[],W=Number((0,se.lebDecode)(_));for(;W--;)$.push(Number((0,se.slebDecode)(_)));let D=[],j=Number((0,se.lebDecode)(_));for(;j--;)switch(Number((0,se.lebDecode)(_))){case 1:{D.push("query");break}case 2:{D.push("oneway");break}case 3:{D.push("composite_query");break}default:throw new Error("unknown annotation")}u.push([M,[K,$,D]]);break}case-23:{let K=Number((0,se.lebDecode)(_)),x=[];for(;K--;){let $=Number((0,se.lebDecode)(_)),W=new TextDecoder().decode((0,se.safeRead)(_,$)),D=(0,se.slebDecode)(_);x.push([W,D])}u.push([M,x]);break}default:throw new Error("Illegal op_code: "+M)}}let O=[],R=Number((0,se.lebDecode)(_));for(let F=0;F<R;F++)O.push(Number((0,se.slebDecode)(_)));return[u,O]}let[o,a]=s(r);if(a.length<t.length)throw new Error("Wrong number of return values");let c=o.map(_=>yd());function f(_){if(_<-24)throw new Error("future value not supported");if(_<0)switch(_){case-1:return Y.Null;case-2:return Y.Bool;case-3:return Y.Nat;case-4:return Y.Int;case-5:return Y.Nat8;case-6:return Y.Nat16;case-7:return Y.Nat32;case-8:return Y.Nat64;case-9:return Y.Int8;case-10:return Y.Int16;case-11:return Y.Int32;case-12:return Y.Int64;case-13:return Y.Float32;case-14:return Y.Float64;case-15:return Y.Text;case-16:return Y.Reserved;case-17:return Y.Empty;case-24:return Y.Principal;default:throw new Error("Illegal op_code: "+_)}if(_>=o.length)throw new Error("type index out of range");return c[_]}function d(_){switch(_[0]){case-19:{let u=f(_[1]);return fd(u)}case-18:{let u=f(_[1]);return dd(u)}case-20:{let u={};for(let[R,F]of _[1]){let M=`_${R}_`;u[M]=f(F)}let T=hd(u),O=T.tryAsTuple();return Array.isArray(O)?ld(...O):T}case-21:{let u={};for(let[T,O]of _[1]){let R=`_${T}_`;u[R]=f(O)}return pd(u)}case-22:{let[u,T,O]=_[1];return gd(u.map(R=>f(R)),T.map(R=>f(R)),O)}case-23:{let u={},T=_[1];for(let[O,R]of T){let F=f(R);if(F instanceof cn&&(F=F.getType()),!(F instanceof Zi))throw new Error("Illegal service definition: services can only contain functions");u[O]=F}return md(u)}default:throw new Error("Illegal op_code: "+_[0])}}o.forEach((_,u)=>{if(_[0]===-22){let T=d(_);c[u].fill(T)}}),o.forEach((_,u)=>{if(_[0]!==-22){let T=d(_);c[u].fill(T)}});let h=a.map(_=>f(_)),m=t.map((_,u)=>_.decodeValue(r,h[u]));for(let _=t.length;_<h.length;_++)h[_].decodeValue(r,h[_]);if(r.byteLength>0)throw new Error("decode: Left-over bytes");return m}Y.decode=Vm;Y.Empty=new ao;Y.Reserved=new hi;Y.Unknown=new co;Y.Bool=new uo;Y.Null=new lo;Y.Text=new fo;Y.Int=new ho;Y.Nat=new po;Y.Float32=new zi(32);Y.Float64=new zi(64);Y.Int8=new zr(8);Y.Int16=new zr(16);Y.Int32=new zr(32);Y.Int64=new zr(64);Y.Nat8=new Nr(8);Y.Nat16=new Nr(16);Y.Nat32=new Nr(32);Y.Nat64=new Nr(64);Y.Principal=new bo;function ld(...t){return new go(t)}Y.Tuple=ld;function fd(t){return new yo(t)}Y.Vec=fd;function dd(t){return new pi(t)}Y.Opt=dd;function hd(t){return new Di(t)}Y.Record=hd;function pd(t){return new mo(t)}Y.Variant=pd;function yd(){return new cn}Y.Rec=yd;function gd(t,e,r=[]){return new Zi(t,e,r)}Y.Func=gd;function md(t){return new _o(t)}Y.Service=md});var $c=Q(St=>{"use strict";Object.defineProperty(St,"__esModule",{value:!0});St.VecForm=St.OptionForm=St.VariantForm=St.TupleForm=St.RecordForm=St.InputForm=St.InputBox=void 0;var qc=class{constructor(e,r){this.idl=e,this.ui=r,this.label=null,this.value=void 0;let n=document.createElement("span");n.className="status",this.status=n,r.input&&(r.input.addEventListener("blur",()=>{r.input.value!==""&&this.parse()}),r.input.addEventListener("input",()=>{n.style.display="none",r.input.classList.remove("reject")}))}isRejected(){return this.value===void 0}parse(e={}){if(this.ui.form){let r=this.ui.form.parse(e);return this.value=r,r}if(this.ui.input){let r=this.ui.input;try{let n=this.ui.parse(this.idl,e,r.value);if(!this.idl.covariant(n))throw new Error(`${r.value} is not of type ${this.idl.display()}`);return this.status.style.display="none",this.value=n,n}catch(n){r.classList.add("reject"),this.status.style.display="block",this.status.innerHTML="InputError: "+n.message,this.value=void 0;return}}return null}render(e){let r=document.createElement("span");if(this.label){let n=document.createElement("label");n.innerText=this.label,r.appendChild(n)}this.ui.input&&(r.appendChild(this.ui.input),r.appendChild(this.status)),this.ui.form&&this.ui.form.render(r),e.appendChild(r)}};St.InputBox=qc;var un=class{constructor(e){this.ui=e,this.form=[]}renderForm(e){this.ui.container?(this.form.forEach(r=>r.render(this.ui.container)),e.appendChild(this.ui.container)):this.form.forEach(r=>r.render(e))}render(e){if(this.ui.open&&this.ui.event){e.appendChild(this.ui.open);let r=this;r.ui.open.addEventListener(r.ui.event,()=>{if(r.ui.container)r.ui.container.innerHTML="";else{let n=r.ui.open.nextElementSibling;n&&n.parentNode.removeChild(n)}r.generateForm(),r.renderForm(e)})}else this.generateForm(),this.renderForm(e)}};St.InputForm=un;var Cc=class extends un{constructor(e,r){super(r),this.fields=e,this.ui=r}generateForm(){this.form=this.fields.map(([e,r])=>{let n=this.ui.render(r);return this.ui.labelMap&&this.ui.labelMap.hasOwnProperty(e)?n.label=this.ui.labelMap[e]+" ":n.label=e+" ",n})}parse(e){let r={};if(this.fields.forEach(([n,i],s)=>{let o=this.form[s].parse(e);r[n]=o}),!this.form.some(n=>n.isRejected()))return r}};St.RecordForm=Cc;var jc=class extends un{constructor(e,r){super(r),this.components=e,this.ui=r}generateForm(){this.form=this.components.map(e=>this.ui.render(e))}parse(e){let r=[];if(this.components.forEach((n,i)=>{let s=this.form[i].parse(e);r.push(s)}),!this.form.some(n=>n.isRejected()))return r}};St.TupleForm=jc;var kc=class extends un{constructor(e,r){super(r),this.fields=e,this.ui=r}generateForm(){let e=this.ui.open.selectedIndex,[r,n]=this.fields[e],i=this.ui.render(n);this.form=[i]}parse(e){let r=this.ui.open,n=r.options[r.selectedIndex].value,i=this.form[0].parse(e);if(i===void 0)return;let s={};return s[n]=i,s}};St.VariantForm=kc;var Hc=class extends un{constructor(e,r){super(r),this.ty=e,this.ui=r}generateForm(){if(this.ui.open.checked){let e=this.ui.render(this.ty);this.form=[e]}else this.form=[]}parse(e){if(this.form.length===0)return[];{let r=this.form[0].parse(e);return r===void 0?void 0:[r]}}};St.OptionForm=Hc;var Vc=class extends un{constructor(e,r){super(r),this.ty=e,this.ui=r}generateForm(){let e=+this.ui.open.value;this.form=[];for(let r=0;r<e;r++){let n=this.ui.render(this.ty);this.form.push(n)}}parse(e){let r=this.form.map(n=>n.parse(e));if(!this.form.some(n=>n.isRejected()))return r}};St.VecForm=Vc});var _d=Q(Ee=>{"use strict";var $m=Ee&&Ee.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Km=Ee&&Ee.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),bd=Ee&&Ee.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&$m(e,t,r);return Km(e,t),e};Object.defineProperty(Ee,"__esModule",{value:!0});Ee.renderValue=Ee.renderInput=Ee.Render=Ee.vecForm=Ee.optForm=Ee.variantForm=Ee.tupleForm=Ee.recordForm=Ee.inputBox=void 0;var Eo=bd(Mc()),Kc=Tt(),yi=bd($c()),Gm={parse:Jm},Xi={render:zc},Ym=(t,e)=>new yi.InputBox(t,Object.assign(Object.assign({},Gm),e));Ee.inputBox=Ym;var Wm=(t,e)=>new yi.RecordForm(t,Object.assign(Object.assign({},Xi),e));Ee.recordForm=Wm;var zm=(t,e)=>new yi.TupleForm(t,Object.assign(Object.assign({},Xi),e));Ee.tupleForm=zm;var Dm=(t,e)=>new yi.VariantForm(t,Object.assign(Object.assign({},Xi),e));Ee.variantForm=Dm;var Zm=(t,e)=>new yi.OptionForm(t,Object.assign(Object.assign({},Xi),e));Ee.optForm=Zm;var Xm=(t,e)=>new yi.VecForm(t,Object.assign(Object.assign({},Xi),e));Ee.vecForm=Xm;var wo=class extends Eo.Visitor{visitType(e,r){let n=document.createElement("input");return n.classList.add("argument"),n.placeholder=e.display(),(0,Ee.inputBox)(e,{input:n})}visitNull(e,r){return(0,Ee.inputBox)(e,{})}visitRecord(e,r,n){let i={};if(r.length>1){let o=document.createElement("div");o.classList.add("popup-form"),i={container:o}}let s=(0,Ee.recordForm)(r,i);return(0,Ee.inputBox)(e,{form:s})}visitTuple(e,r,n){let i={};if(r.length>1){let o=document.createElement("div");o.classList.add("popup-form"),i={container:o}}let s=(0,Ee.tupleForm)(r,i);return(0,Ee.inputBox)(e,{form:s})}visitVariant(e,r,n){let i=document.createElement("select");for(let[a,c]of r){let f=new Option(a);i.add(f)}i.selectedIndex=-1,i.classList.add("open");let s={open:i,event:"change"},o=(0,Ee.variantForm)(r,s);return(0,Ee.inputBox)(e,{form:o})}visitOpt(e,r,n){let i=document.createElement("input");i.type="checkbox",i.classList.add("open");let s=(0,Ee.optForm)(r,{open:i,event:"change"});return(0,Ee.inputBox)(e,{form:s})}visitVec(e,r,n){let i=document.createElement("input");i.type="number",i.min="0",i.max="100",i.style.width="8rem",i.placeholder="len",i.classList.add("open");let s=document.createElement("div");s.classList.add("popup-form");let o=(0,Ee.vecForm)(r,{open:i,event:"change",container:s});return(0,Ee.inputBox)(e,{form:o})}visitRec(e,r,n){return zc(r)}};Ee.Render=wo;var Gc=class extends Eo.Visitor{visitNull(e,r){return null}visitBool(e,r){if(r==="true")return!0;if(r==="false")return!1;throw new Error(`Cannot parse ${r} as boolean`)}visitText(e,r){return r}visitFloat(e,r){return parseFloat(r)}visitFixedInt(e,r){return e._bits<=32?parseInt(r,10):BigInt(r)}visitFixedNat(e,r){return e._bits<=32?parseInt(r,10):BigInt(r)}visitNumber(e,r){return BigInt(r)}visitPrincipal(e,r){return Kc.Principal.fromText(r)}visitService(e,r){return Kc.Principal.fromText(r)}visitFunc(e,r){let n=r.split(".",2);return[Kc.Principal.fromText(n[0]),n[1]]}},Yc=class extends Eo.Visitor{visitNull(e,r){return null}visitBool(e,r){return Math.random()<.5}visitText(e,r){return Math.random().toString(36).substring(6)}visitFloat(e,r){return Math.random()}visitInt(e,r){return BigInt(this.generateNumber(!0))}visitNat(e,r){return BigInt(this.generateNumber(!1))}visitFixedInt(e,r){let n=this.generateNumber(!0);return e._bits<=32?n:BigInt(r)}visitFixedNat(e,r){let n=this.generateNumber(!1);return e._bits<=32?n:BigInt(r)}generateNumber(e){let r=Math.floor(Math.random()*100);return e&&Math.random()<.5?-r:r}};function Jm(t,e,r){return e.random&&r===""?t.accept(new Yc,r):t.accept(new Gc,r)}function zc(t){return t.accept(new wo,null)}Ee.renderInput=zc;function Cn(t,e,r){return t.accept(new Wc,{input:e,value:r})}Ee.renderValue=Cn;var Wc=class extends Eo.Visitor{visitType(e,r){r.input.ui.input.value=e.valueToString(r.value)}visitNull(e,r){}visitText(e,r){r.input.ui.input.value=r.value}visitRec(e,r,n){Cn(r,n.input,n.value)}visitOpt(e,r,n){if(n.value.length!==0){let i=n.input.ui.form,s=i.ui.open;s.checked=!0,s.dispatchEvent(new Event(i.ui.event)),Cn(r,i.form[0],n.value[0])}}visitRecord(e,r,n){let i=n.input.ui.form;r.forEach(([s,o],a)=>{Cn(o,i.form[a],n.value[s])})}visitTuple(e,r,n){let i=n.input.ui.form;r.forEach((s,o)=>{Cn(s,i.form[o],n.value[o])})}visitVariant(e,r,n){let i=n.input.ui.form,s=Object.entries(n.value)[0];r.forEach(([o,a],c)=>{if(o===s[0]){let f=i.ui.open;f.selectedIndex=c,f.dispatchEvent(new Event(i.ui.event)),Cn(a,i.form[0],s[1])}})}visitVec(e,r,n){let i=n.input.ui.form,s=n.value.length,o=i.ui.open;o.value=s,o.dispatchEvent(new Event(i.ui.event)),n.value.forEach((a,c)=>{Cn(r,i.form[c],a)})}}});var Ed=Q(wd=>{"use strict";Object.defineProperty(wd,"__esModule",{value:!0})});var mi=Q(dt=>{"use strict";var xd=dt&&dt.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Lm=dt&&dt.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),gi=dt&&dt.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&xd(e,t,r)},Qm=dt&&dt.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&xd(e,t,r);return Lm(e,t),e};Object.defineProperty(dt,"__esModule",{value:!0});dt.IDL=void 0;gi(_d(),dt);gi($c(),dt);dt.IDL=Qm(Mc());gi(Oc(),dt);gi(Rc(),dt);gi(no(),dt);gi(Ed(),dt)});var Ji=Q((vd,xo)=>{(function(t){"use strict";var e,r=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,i=Math.floor,s="[BigNumber Error] ",o=s+"Number primitive has more than 15 significant digits: ",a=1e14,c=14,f=9007199254740991,d=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],h=1e7,m=1e9;function _(x){var $,W,D,j=U.prototype={constructor:U,toString:null,valueOf:null},ie=new U(1),ee=20,ne=4,w=-7,b=21,B=-1e7,S=1e7,N=!1,H=1,Z=0,ae={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},oe="0123456789abcdefghijklmnopqrstuvwxyz",z=!0;function U(l,y){var g,I,A,P,k,E,q,V,C=this;if(!(C instanceof U))return new U(l,y);if(y==null){if(l&&l._isBigNumber===!0){C.s=l.s,!l.c||l.e>S?C.c=C.e=null:l.e<B?C.c=[C.e=0]:(C.e=l.e,C.c=l.c.slice());return}if((E=typeof l=="number")&&l*0==0){if(C.s=1/l<0?(l=-l,-1):1,l===~~l){for(P=0,k=l;k>=10;k/=10,P++);P>S?C.c=C.e=null:(C.e=P,C.c=[l]);return}V=String(l)}else{if(!r.test(V=String(l)))return D(C,V,E);C.s=V.charCodeAt(0)==45?(V=V.slice(1),-1):1}(P=V.indexOf("."))>-1&&(V=V.replace(".","")),(k=V.search(/e/i))>0?(P<0&&(P=k),P+=+V.slice(k+1),V=V.substring(0,k)):P<0&&(P=V.length)}else{if(R(y,2,oe.length,"Base"),y==10&&z)return C=new U(l),fe(C,ee+C.e+1,ne);if(V=String(l),E=typeof l=="number"){if(l*0!=0)return D(C,V,E,y);if(C.s=1/l<0?(V=V.slice(1),-1):1,U.DEBUG&&V.replace(/^0\.0*|\./,"").length>15)throw Error(o+l)}else C.s=V.charCodeAt(0)===45?(V=V.slice(1),-1):1;for(g=oe.slice(0,y),P=k=0,q=V.length;k<q;k++)if(g.indexOf(I=V.charAt(k))<0){if(I=="."){if(k>P){P=q;continue}}else if(!A&&(V==V.toUpperCase()&&(V=V.toLowerCase())||V==V.toLowerCase()&&(V=V.toUpperCase()))){A=!0,k=-1,P=0;continue}return D(C,String(l),E,y)}E=!1,V=W(V,y,10,C.s),(P=V.indexOf("."))>-1?V=V.replace(".",""):P=V.length}for(k=0;V.charCodeAt(k)===48;k++);for(q=V.length;V.charCodeAt(--q)===48;);if(V=V.slice(k,++q)){if(q-=k,E&&U.DEBUG&&q>15&&(l>f||l!==i(l)))throw Error(o+C.s*l);if((P=P-k-1)>S)C.c=C.e=null;else if(P<B)C.c=[C.e=0];else{if(C.e=P,C.c=[],k=(P+1)%c,P<0&&(k+=c),k<q){for(k&&C.c.push(+V.slice(0,k)),q-=c;k<q;)C.c.push(+V.slice(k,k+=c));k=c-(V=V.slice(k)).length}else k-=q;for(;k--;V+="0");C.c.push(+V)}}else C.c=[C.e=0]}U.clone=_,U.ROUND_UP=0,U.ROUND_DOWN=1,U.ROUND_CEIL=2,U.ROUND_FLOOR=3,U.ROUND_HALF_UP=4,U.ROUND_HALF_DOWN=5,U.ROUND_HALF_EVEN=6,U.ROUND_HALF_CEIL=7,U.ROUND_HALF_FLOOR=8,U.EUCLID=9,U.config=U.set=function(l){var y,g;if(l!=null)if(typeof l=="object"){if(l.hasOwnProperty(y="DECIMAL_PLACES")&&(g=l[y],R(g,0,m,y),ee=g),l.hasOwnProperty(y="ROUNDING_MODE")&&(g=l[y],R(g,0,8,y),ne=g),l.hasOwnProperty(y="EXPONENTIAL_AT")&&(g=l[y],g&&g.pop?(R(g[0],-m,0,y),R(g[1],0,m,y),w=g[0],b=g[1]):(R(g,-m,m,y),w=-(b=g<0?-g:g))),l.hasOwnProperty(y="RANGE"))if(g=l[y],g&&g.pop)R(g[0],-m,-1,y),R(g[1],1,m,y),B=g[0],S=g[1];else if(R(g,-m,m,y),g)B=-(S=g<0?-g:g);else throw Error(s+y+" cannot be zero: "+g);if(l.hasOwnProperty(y="CRYPTO"))if(g=l[y],g===!!g)if(g)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))N=g;else throw N=!g,Error(s+"crypto unavailable");else N=g;else throw Error(s+y+" not true or false: "+g);if(l.hasOwnProperty(y="MODULO_MODE")&&(g=l[y],R(g,0,9,y),H=g),l.hasOwnProperty(y="POW_PRECISION")&&(g=l[y],R(g,0,m,y),Z=g),l.hasOwnProperty(y="FORMAT"))if(g=l[y],typeof g=="object")ae=g;else throw Error(s+y+" not an object: "+g);if(l.hasOwnProperty(y="ALPHABET"))if(g=l[y],typeof g=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(g))z=g.slice(0,10)=="0123456789",oe=g;else throw Error(s+y+" invalid: "+g)}else throw Error(s+"Object expected: "+l);return{DECIMAL_PLACES:ee,ROUNDING_MODE:ne,EXPONENTIAL_AT:[w,b],RANGE:[B,S],CRYPTO:N,MODULO_MODE:H,POW_PRECISION:Z,FORMAT:ae,ALPHABET:oe}},U.isBigNumber=function(l){if(!l||l._isBigNumber!==!0)return!1;if(!U.DEBUG)return!0;var y,g,I=l.c,A=l.e,P=l.s;e:if({}.toString.call(I)=="[object Array]"){if((P===1||P===-1)&&A>=-m&&A<=m&&A===i(A)){if(I[0]===0){if(A===0&&I.length===1)return!0;break e}if(y=(A+1)%c,y<1&&(y+=c),String(I[0]).length==y){for(y=0;y<I.length;y++)if(g=I[y],g<0||g>=a||g!==i(g))break e;if(g!==0)return!0}}}else if(I===null&&A===null&&(P===null||P===1||P===-1))return!0;throw Error(s+"Invalid BigNumber: "+l)},U.maximum=U.max=function(){return J(arguments,-1)},U.minimum=U.min=function(){return J(arguments,1)},U.random=function(){var l=9007199254740992,y=Math.random()*l&2097151?function(){return i(Math.random()*l)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(g){var I,A,P,k,E,q=0,V=[],C=new U(ie);if(g==null?g=ee:R(g,0,m),k=n(g/c),N)if(crypto.getRandomValues){for(I=crypto.getRandomValues(new Uint32Array(k*=2));q<k;)E=I[q]*131072+(I[q+1]>>>11),E>=9e15?(A=crypto.getRandomValues(new Uint32Array(2)),I[q]=A[0],I[q+1]=A[1]):(V.push(E%1e14),q+=2);q=k/2}else if(crypto.randomBytes){for(I=crypto.randomBytes(k*=7);q<k;)E=(I[q]&31)*281474976710656+I[q+1]*1099511627776+I[q+2]*4294967296+I[q+3]*16777216+(I[q+4]<<16)+(I[q+5]<<8)+I[q+6],E>=9e15?crypto.randomBytes(7).copy(I,q):(V.push(E%1e14),q+=7);q=k/7}else throw N=!1,Error(s+"crypto unavailable");if(!N)for(;q<k;)E=y(),E<9e15&&(V[q++]=E%1e14);for(k=V[--q],g%=c,k&&g&&(E=d[c-g],V[q]=i(k/E)*E);V[q]===0;V.pop(),q--);if(q<0)V=[P=0];else{for(P=-1;V[0]===0;V.splice(0,1),P-=c);for(q=1,E=V[0];E>=10;E/=10,q++);q<c&&(P-=c-q)}return C.e=P,C.c=V,C}}(),U.sum=function(){for(var l=1,y=arguments,g=new U(y[0]);l<y.length;)g=g.plus(y[l++]);return g},W=function(){var l="0123456789";function y(g,I,A,P){for(var k,E=[0],q,V=0,C=g.length;V<C;){for(q=E.length;q--;E[q]*=I);for(E[0]+=P.indexOf(g.charAt(V++)),k=0;k<E.length;k++)E[k]>A-1&&(E[k+1]==null&&(E[k+1]=0),E[k+1]+=E[k]/A|0,E[k]%=A)}return E.reverse()}return function(g,I,A,P,k){var E,q,V,C,X,te,de,_e,Fe=g.indexOf("."),$e=ee,me=ne;for(Fe>=0&&(C=Z,Z=0,g=g.replace(".",""),_e=new U(I),te=_e.pow(g.length-Fe),Z=C,_e.c=y(K(T(te.c),te.e,"0"),10,A,l),_e.e=_e.c.length),de=y(g,I,A,k?(E=oe,l):(E=l,oe)),V=C=de.length;de[--C]==0;de.pop());if(!de[0])return E.charAt(0);if(Fe<0?--V:(te.c=de,te.e=V,te.s=P,te=$(te,_e,$e,me,A),de=te.c,X=te.r,V=te.e),q=V+$e+1,Fe=de[q],C=A/2,X=X||q<0||de[q+1]!=null,X=me<4?(Fe!=null||X)&&(me==0||me==(te.s<0?3:2)):Fe>C||Fe==C&&(me==4||X||me==6&&de[q-1]&1||me==(te.s<0?8:7)),q<1||!de[0])g=X?K(E.charAt(1),-$e,E.charAt(0)):E.charAt(0);else{if(de.length=q,X)for(--A;++de[--q]>A;)de[q]=0,q||(++V,de=[1].concat(de));for(C=de.length;!de[--C];);for(Fe=0,g="";Fe<=C;g+=E.charAt(de[Fe++]));g=K(g,V,E.charAt(0))}return g}}(),$=function(){function l(I,A,P){var k,E,q,V,C=0,X=I.length,te=A%h,de=A/h|0;for(I=I.slice();X--;)q=I[X]%h,V=I[X]/h|0,k=de*q+V*te,E=te*q+k%h*h+C,C=(E/P|0)+(k/h|0)+de*V,I[X]=E%P;return C&&(I=[C].concat(I)),I}function y(I,A,P,k){var E,q;if(P!=k)q=P>k?1:-1;else for(E=q=0;E<P;E++)if(I[E]!=A[E]){q=I[E]>A[E]?1:-1;break}return q}function g(I,A,P,k){for(var E=0;P--;)I[P]-=E,E=I[P]<A[P]?1:0,I[P]=E*k+I[P]-A[P];for(;!I[0]&&I.length>1;I.splice(0,1));}return function(I,A,P,k,E){var q,V,C,X,te,de,_e,Fe,$e,me,he,Xe,Er,Kr,In,Qt,Pe,jt=I.s==A.s?1:-1,gt=I.c,We=A.c;if(!gt||!gt[0]||!We||!We[0])return new U(!I.s||!A.s||(gt?We&&gt[0]==We[0]:!We)?NaN:gt&&gt[0]==0||!We?jt*0:jt/0);for(Fe=new U(jt),$e=Fe.c=[],V=I.e-A.e,jt=P+V+1,E||(E=a,V=u(I.e/c)-u(A.e/c),jt=jt/c|0),C=0;We[C]==(gt[C]||0);C++);if(We[C]>(gt[C]||0)&&V--,jt<0)$e.push(1),X=!0;else{for(Kr=gt.length,Qt=We.length,C=0,jt+=2,te=i(E/(We[0]+1)),te>1&&(We=l(We,te,E),gt=l(gt,te,E),Qt=We.length,Kr=gt.length),Er=Qt,me=gt.slice(0,Qt),he=me.length;he<Qt;me[he++]=0);Pe=We.slice(),Pe=[0].concat(Pe),In=We[0],We[1]>=E/2&&In++;do{if(te=0,q=y(We,me,Qt,he),q<0){if(Xe=me[0],Qt!=he&&(Xe=Xe*E+(me[1]||0)),te=i(Xe/In),te>1)for(te>=E&&(te=E-1),de=l(We,te,E),_e=de.length,he=me.length;y(de,me,_e,he)==1;)te--,g(de,Qt<_e?Pe:We,_e,E),_e=de.length,q=1;else te==0&&(q=te=1),de=We.slice(),_e=de.length;if(_e<he&&(de=[0].concat(de)),g(me,de,he,E),he=me.length,q==-1)for(;y(We,me,Qt,he)<1;)te++,g(me,Qt<he?Pe:We,he,E),he=me.length}else q===0&&(te++,me=[0]);$e[C++]=te,me[0]?me[he++]=gt[Er]||0:(me=[gt[Er]],he=1)}while((Er++<Kr||me[0]!=null)&&jt--);X=me[0]!=null,$e[0]||$e.splice(0,1)}if(E==a){for(C=1,jt=$e[0];jt>=10;jt/=10,C++);fe(Fe,P+(Fe.e=C+V*c-1)+1,k,X)}else Fe.e=V,Fe.r=+X;return Fe}}();function p(l,y,g,I){var A,P,k,E,q;if(g==null?g=ne:R(g,0,8),!l.c)return l.toString();if(A=l.c[0],k=l.e,y==null)q=T(l.c),q=I==1||I==2&&(k<=w||k>=b)?M(q,k):K(q,k,"0");else if(l=fe(new U(l),y,g),P=l.e,q=T(l.c),E=q.length,I==1||I==2&&(y<=P||P<=w)){for(;E<y;q+="0",E++);q=M(q,P)}else if(y-=k,q=K(q,P,"0"),P+1>E){if(--y>0)for(q+=".";y--;q+="0");}else if(y+=P-E,y>0)for(P+1==E&&(q+=".");y--;q+="0");return l.s<0&&A?"-"+q:q}function J(l,y){for(var g,I,A=1,P=new U(l[0]);A<l.length;A++)I=new U(l[A]),(!I.s||(g=O(P,I))===y||g===0&&P.s===y)&&(P=I);return P}function re(l,y,g){for(var I=1,A=y.length;!y[--A];y.pop());for(A=y[0];A>=10;A/=10,I++);return(g=I+g*c-1)>S?l.c=l.e=null:g<B?l.c=[l.e=0]:(l.e=g,l.c=y),l}D=function(){var l=/^(-?)0([xbo])(?=\w[\w.]*$)/i,y=/^([^.]+)\.$/,g=/^\.([^.]+)$/,I=/^-?(Infinity|NaN)$/,A=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(P,k,E,q){var V,C=E?k:k.replace(A,"");if(I.test(C))P.s=isNaN(C)?null:C<0?-1:1;else{if(!E&&(C=C.replace(l,function(X,te,de){return V=(de=de.toLowerCase())=="x"?16:de=="b"?2:8,!q||q==V?te:X}),q&&(V=q,C=C.replace(y,"$1").replace(g,"0.$1")),k!=C))return new U(C,V);if(U.DEBUG)throw Error(s+"Not a"+(q?" base "+q:"")+" number: "+k);P.s=null}P.c=P.e=null}}();function fe(l,y,g,I){var A,P,k,E,q,V,C,X=l.c,te=d;if(X){e:{for(A=1,E=X[0];E>=10;E/=10,A++);if(P=y-A,P<0)P+=c,k=y,q=X[V=0],C=i(q/te[A-k-1]%10);else if(V=n((P+1)/c),V>=X.length)if(I){for(;X.length<=V;X.push(0));q=C=0,A=1,P%=c,k=P-c+1}else break e;else{for(q=E=X[V],A=1;E>=10;E/=10,A++);P%=c,k=P-c+A,C=k<0?0:i(q/te[A-k-1]%10)}if(I=I||y<0||X[V+1]!=null||(k<0?q:q%te[A-k-1]),I=g<4?(C||I)&&(g==0||g==(l.s<0?3:2)):C>5||C==5&&(g==4||I||g==6&&(P>0?k>0?q/te[A-k]:0:X[V-1])%10&1||g==(l.s<0?8:7)),y<1||!X[0])return X.length=0,I?(y-=l.e+1,X[0]=te[(c-y%c)%c],l.e=-y||0):X[0]=l.e=0,l;if(P==0?(X.length=V,E=1,V--):(X.length=V+1,E=te[c-P],X[V]=k>0?i(q/te[A-k]%te[k])*E:0),I)for(;;)if(V==0){for(P=1,k=X[0];k>=10;k/=10,P++);for(k=X[0]+=E,E=1;k>=10;k/=10,E++);P!=E&&(l.e++,X[0]==a&&(X[0]=1));break}else{if(X[V]+=E,X[V]!=a)break;X[V--]=0,E=1}for(P=X.length;X[--P]===0;X.pop());}l.e>S?l.c=l.e=null:l.e<B&&(l.c=[l.e=0])}return l}function L(l){var y,g=l.e;return g===null?l.toString():(y=T(l.c),y=g<=w||g>=b?M(y,g):K(y,g,"0"),l.s<0?"-"+y:y)}return j.absoluteValue=j.abs=function(){var l=new U(this);return l.s<0&&(l.s=1),l},j.comparedTo=function(l,y){return O(this,new U(l,y))},j.decimalPlaces=j.dp=function(l,y){var g,I,A,P=this;if(l!=null)return R(l,0,m),y==null?y=ne:R(y,0,8),fe(new U(P),l+P.e+1,y);if(!(g=P.c))return null;if(I=((A=g.length-1)-u(this.e/c))*c,A=g[A])for(;A%10==0;A/=10,I--);return I<0&&(I=0),I},j.dividedBy=j.div=function(l,y){return $(this,new U(l,y),ee,ne)},j.dividedToIntegerBy=j.idiv=function(l,y){return $(this,new U(l,y),0,1)},j.exponentiatedBy=j.pow=function(l,y){var g,I,A,P,k,E,q,V,C,X=this;if(l=new U(l),l.c&&!l.isInteger())throw Error(s+"Exponent not an integer: "+L(l));if(y!=null&&(y=new U(y)),E=l.e>14,!X.c||!X.c[0]||X.c[0]==1&&!X.e&&X.c.length==1||!l.c||!l.c[0])return C=new U(Math.pow(+L(X),E?l.s*(2-F(l)):+L(l))),y?C.mod(y):C;if(q=l.s<0,y){if(y.c?!y.c[0]:!y.s)return new U(NaN);I=!q&&X.isInteger()&&y.isInteger(),I&&(X=X.mod(y))}else{if(l.e>9&&(X.e>0||X.e<-1||(X.e==0?X.c[0]>1||E&&X.c[1]>=24e7:X.c[0]<8e13||E&&X.c[0]<=9999975e7)))return P=X.s<0&&F(l)?-0:0,X.e>-1&&(P=1/P),new U(q?1/P:P);Z&&(P=n(Z/c+2))}for(E?(g=new U(.5),q&&(l.s=1),V=F(l)):(A=Math.abs(+L(l)),V=A%2),C=new U(ie);;){if(V){if(C=C.times(X),!C.c)break;P?C.c.length>P&&(C.c.length=P):I&&(C=C.mod(y))}if(A){if(A=i(A/2),A===0)break;V=A%2}else if(l=l.times(g),fe(l,l.e+1,1),l.e>14)V=F(l);else{if(A=+L(l),A===0)break;V=A%2}X=X.times(X),P?X.c&&X.c.length>P&&(X.c.length=P):I&&(X=X.mod(y))}return I?C:(q&&(C=ie.div(C)),y?C.mod(y):P?fe(C,Z,ne,k):C)},j.integerValue=function(l){var y=new U(this);return l==null?l=ne:R(l,0,8),fe(y,y.e+1,l)},j.isEqualTo=j.eq=function(l,y){return O(this,new U(l,y))===0},j.isFinite=function(){return!!this.c},j.isGreaterThan=j.gt=function(l,y){return O(this,new U(l,y))>0},j.isGreaterThanOrEqualTo=j.gte=function(l,y){return(y=O(this,new U(l,y)))===1||y===0},j.isInteger=function(){return!!this.c&&u(this.e/c)>this.c.length-2},j.isLessThan=j.lt=function(l,y){return O(this,new U(l,y))<0},j.isLessThanOrEqualTo=j.lte=function(l,y){return(y=O(this,new U(l,y)))===-1||y===0},j.isNaN=function(){return!this.s},j.isNegative=function(){return this.s<0},j.isPositive=function(){return this.s>0},j.isZero=function(){return!!this.c&&this.c[0]==0},j.minus=function(l,y){var g,I,A,P,k=this,E=k.s;if(l=new U(l,y),y=l.s,!E||!y)return new U(NaN);if(E!=y)return l.s=-y,k.plus(l);var q=k.e/c,V=l.e/c,C=k.c,X=l.c;if(!q||!V){if(!C||!X)return C?(l.s=-y,l):new U(X?k:NaN);if(!C[0]||!X[0])return X[0]?(l.s=-y,l):new U(C[0]?k:ne==3?-0:0)}if(q=u(q),V=u(V),C=C.slice(),E=q-V){for((P=E<0)?(E=-E,A=C):(V=q,A=X),A.reverse(),y=E;y--;A.push(0));A.reverse()}else for(I=(P=(E=C.length)<(y=X.length))?E:y,E=y=0;y<I;y++)if(C[y]!=X[y]){P=C[y]<X[y];break}if(P&&(A=C,C=X,X=A,l.s=-l.s),y=(I=X.length)-(g=C.length),y>0)for(;y--;C[g++]=0);for(y=a-1;I>E;){if(C[--I]<X[I]){for(g=I;g&&!C[--g];C[g]=y);--C[g],C[I]+=a}C[I]-=X[I]}for(;C[0]==0;C.splice(0,1),--V);return C[0]?re(l,C,V):(l.s=ne==3?-1:1,l.c=[l.e=0],l)},j.modulo=j.mod=function(l,y){var g,I,A=this;return l=new U(l,y),!A.c||!l.s||l.c&&!l.c[0]?new U(NaN):!l.c||A.c&&!A.c[0]?new U(A):(H==9?(I=l.s,l.s=1,g=$(A,l,0,3),l.s=I,g.s*=I):g=$(A,l,0,H),l=A.minus(g.times(l)),!l.c[0]&&H==1&&(l.s=A.s),l)},j.multipliedBy=j.times=function(l,y){var g,I,A,P,k,E,q,V,C,X,te,de,_e,Fe,$e,me=this,he=me.c,Xe=(l=new U(l,y)).c;if(!he||!Xe||!he[0]||!Xe[0])return!me.s||!l.s||he&&!he[0]&&!Xe||Xe&&!Xe[0]&&!he?l.c=l.e=l.s=null:(l.s*=me.s,!he||!Xe?l.c=l.e=null:(l.c=[0],l.e=0)),l;for(I=u(me.e/c)+u(l.e/c),l.s*=me.s,q=he.length,X=Xe.length,q<X&&(_e=he,he=Xe,Xe=_e,A=q,q=X,X=A),A=q+X,_e=[];A--;_e.push(0));for(Fe=a,$e=h,A=X;--A>=0;){for(g=0,te=Xe[A]%$e,de=Xe[A]/$e|0,k=q,P=A+k;P>A;)V=he[--k]%$e,C=he[k]/$e|0,E=de*V+C*te,V=te*V+E%$e*$e+_e[P]+g,g=(V/Fe|0)+(E/$e|0)+de*C,_e[P--]=V%Fe;_e[P]=g}return g?++I:_e.splice(0,1),re(l,_e,I)},j.negated=function(){var l=new U(this);return l.s=-l.s||null,l},j.plus=function(l,y){var g,I=this,A=I.s;if(l=new U(l,y),y=l.s,!A||!y)return new U(NaN);if(A!=y)return l.s=-y,I.minus(l);var P=I.e/c,k=l.e/c,E=I.c,q=l.c;if(!P||!k){if(!E||!q)return new U(A/0);if(!E[0]||!q[0])return q[0]?l:new U(E[0]?I:A*0)}if(P=u(P),k=u(k),E=E.slice(),A=P-k){for(A>0?(k=P,g=q):(A=-A,g=E),g.reverse();A--;g.push(0));g.reverse()}for(A=E.length,y=q.length,A-y<0&&(g=q,q=E,E=g,y=A),A=0;y;)A=(E[--y]=E[y]+q[y]+A)/a|0,E[y]=a===E[y]?0:E[y]%a;return A&&(E=[A].concat(E),++k),re(l,E,k)},j.precision=j.sd=function(l,y){var g,I,A,P=this;if(l!=null&&l!==!!l)return R(l,1,m),y==null?y=ne:R(y,0,8),fe(new U(P),l,y);if(!(g=P.c))return null;if(A=g.length-1,I=A*c+1,A=g[A]){for(;A%10==0;A/=10,I--);for(A=g[0];A>=10;A/=10,I++);}return l&&P.e+1>I&&(I=P.e+1),I},j.shiftedBy=function(l){return R(l,-f,f),this.times("1e"+l)},j.squareRoot=j.sqrt=function(){var l,y,g,I,A,P=this,k=P.c,E=P.s,q=P.e,V=ee+4,C=new U("0.5");if(E!==1||!k||!k[0])return new U(!E||E<0&&(!k||k[0])?NaN:k?P:1/0);if(E=Math.sqrt(+L(P)),E==0||E==1/0?(y=T(k),(y.length+q)%2==0&&(y+="0"),E=Math.sqrt(+y),q=u((q+1)/2)-(q<0||q%2),E==1/0?y="5e"+q:(y=E.toExponential(),y=y.slice(0,y.indexOf("e")+1)+q),g=new U(y)):g=new U(E+""),g.c[0]){for(q=g.e,E=q+V,E<3&&(E=0);;)if(A=g,g=C.times(A.plus($(P,A,V,1))),T(A.c).slice(0,E)===(y=T(g.c)).slice(0,E))if(g.e<q&&--E,y=y.slice(E-3,E+1),y=="9999"||!I&&y=="4999"){if(!I&&(fe(A,A.e+ee+2,0),A.times(A).eq(P))){g=A;break}V+=4,E+=4,I=1}else{(!+y||!+y.slice(1)&&y.charAt(0)=="5")&&(fe(g,g.e+ee+2,1),l=!g.times(g).eq(P));break}}return fe(g,g.e+ee+1,ne,l)},j.toExponential=function(l,y){return l!=null&&(R(l,0,m),l++),p(this,l,y,1)},j.toFixed=function(l,y){return l!=null&&(R(l,0,m),l=l+this.e+1),p(this,l,y)},j.toFormat=function(l,y,g){var I,A=this;if(g==null)l!=null&&y&&typeof y=="object"?(g=y,y=null):l&&typeof l=="object"?(g=l,l=y=null):g=ae;else if(typeof g!="object")throw Error(s+"Argument not an object: "+g);if(I=A.toFixed(l,y),A.c){var P,k=I.split("."),E=+g.groupSize,q=+g.secondaryGroupSize,V=g.groupSeparator||"",C=k[0],X=k[1],te=A.s<0,de=te?C.slice(1):C,_e=de.length;if(q&&(P=E,E=q,q=P,_e-=P),E>0&&_e>0){for(P=_e%E||E,C=de.substr(0,P);P<_e;P+=E)C+=V+de.substr(P,E);q>0&&(C+=V+de.slice(P)),te&&(C="-"+C)}I=X?C+(g.decimalSeparator||"")+((q=+g.fractionGroupSize)?X.replace(new RegExp("\\d{"+q+"}\\B","g"),"$&"+(g.fractionGroupSeparator||"")):X):C}return(g.prefix||"")+I+(g.suffix||"")},j.toFraction=function(l){var y,g,I,A,P,k,E,q,V,C,X,te,de=this,_e=de.c;if(l!=null&&(E=new U(l),!E.isInteger()&&(E.c||E.s!==1)||E.lt(ie)))throw Error(s+"Argument "+(E.isInteger()?"out of range: ":"not an integer: ")+L(E));if(!_e)return new U(de);for(y=new U(ie),V=g=new U(ie),I=q=new U(ie),te=T(_e),P=y.e=te.length-de.e-1,y.c[0]=d[(k=P%c)<0?c+k:k],l=!l||E.comparedTo(y)>0?P>0?y:V:E,k=S,S=1/0,E=new U(te),q.c[0]=0;C=$(E,y,0,1),A=g.plus(C.times(I)),A.comparedTo(l)!=1;)g=I,I=A,V=q.plus(C.times(A=V)),q=A,y=E.minus(C.times(A=y)),E=A;return A=$(l.minus(g),I,0,1),q=q.plus(A.times(V)),g=g.plus(A.times(I)),q.s=V.s=de.s,P=P*2,X=$(V,I,P,ne).minus(de).abs().comparedTo($(q,g,P,ne).minus(de).abs())<1?[V,I]:[q,g],S=k,X},j.toNumber=function(){return+L(this)},j.toPrecision=function(l,y){return l!=null&&R(l,1,m),p(this,l,y,2)},j.toString=function(l){var y,g=this,I=g.s,A=g.e;return A===null?I?(y="Infinity",I<0&&(y="-"+y)):y="NaN":(l==null?y=A<=w||A>=b?M(T(g.c),A):K(T(g.c),A,"0"):l===10&&z?(g=fe(new U(g),ee+A+1,ne),y=K(T(g.c),g.e,"0")):(R(l,2,oe.length,"Base"),y=W(K(T(g.c),A,"0"),10,l,I,!0)),I<0&&g.c[0]&&(y="-"+y)),y},j.valueOf=j.toJSON=function(){return L(this)},j._isBigNumber=!0,x!=null&&U.set(x),U}function u(x){var $=x|0;return x>0||x===$?$:$-1}function T(x){for(var $,W,D=1,j=x.length,ie=x[0]+"";D<j;){for($=x[D++]+"",W=c-$.length;W--;$="0"+$);ie+=$}for(j=ie.length;ie.charCodeAt(--j)===48;);return ie.slice(0,j+1||1)}function O(x,$){var W,D,j=x.c,ie=$.c,ee=x.s,ne=$.s,w=x.e,b=$.e;if(!ee||!ne)return null;if(W=j&&!j[0],D=ie&&!ie[0],W||D)return W?D?0:-ne:ee;if(ee!=ne)return ee;if(W=ee<0,D=w==b,!j||!ie)return D?0:!j^W?1:-1;if(!D)return w>b^W?1:-1;for(ne=(w=j.length)<(b=ie.length)?w:b,ee=0;ee<ne;ee++)if(j[ee]!=ie[ee])return j[ee]>ie[ee]^W?1:-1;return w==b?0:w>b^W?1:-1}function R(x,$,W,D){if(x<$||x>W||x!==i(x))throw Error(s+(D||"Argument")+(typeof x=="number"?x<$||x>W?" out of range: ":" not an integer: ":" not a primitive number: ")+String(x))}function F(x){var $=x.c.length-1;return u(x.e/c)==$&&x.c[$]%2!=0}function M(x,$){return(x.length>1?x.charAt(0)+"."+x.slice(1):x)+($<0?"e":"e+")+$}function K(x,$,W){var D,j;if($<0){for(j=W+".";++$;j+=W);x=j+x}else if(D=x.length,++$>D){for(j=W,$-=D;--$;j+=W);x+=j}else $<D&&(x=x.slice(0,$)+"."+x.slice($));return x}e=_(),e.default=e.BigNumber=e,typeof define=="function"&&define.amd?define(function(){return e}):typeof xo<"u"&&xo.exports?xo.exports=e:(t||(t=typeof self<"u"&&self?self:window),t.BigNumber=e)})(vd)});var Ad=Q((jx,Td)=>{Td.exports=function(e,r,n){var i=new e.Uint8Array(n),s=r.pushInt,o=r.pushInt32,a=r.pushInt32Neg,c=r.pushInt64,f=r.pushInt64Neg,d=r.pushFloat,h=r.pushFloatSingle,m=r.pushFloatDouble,_=r.pushTrue,u=r.pushFalse,T=r.pushUndefined,O=r.pushNull,R=r.pushInfinity,F=r.pushInfinityNeg,M=r.pushNaN,K=r.pushNaNNeg,x=r.pushArrayStart,$=r.pushArrayStartFixed,W=r.pushArrayStartFixed32,D=r.pushArrayStartFixed64,j=r.pushObjectStart,ie=r.pushObjectStartFixed,ee=r.pushObjectStartFixed32,ne=r.pushObjectStartFixed64,w=r.pushByteString,b=r.pushByteStringStart,B=r.pushUtf8String,S=r.pushUtf8StringStart,N=r.pushSimpleUnassigned,H=r.pushTagStart,Z=r.pushTagStart4,ae=r.pushTagStart8,oe=r.pushTagUnassigned,z=r.pushBreak,U=e.Math.pow,p=0,J=0,re=0;function fe(v){for(v=v|0,p=0,J=v;(p|0)<(J|0)&&(re=zy[i[p]&255](i[p]|0)|0,!((re|0)>0)););return re|0}function L(v){return v=v|0,((p|0)+(v|0)|0)<(J|0)?0:1}function l(v){return v=v|0,i[v|0]<<8|i[v+1|0]|0}function y(v){return v=v|0,i[v|0]<<24|i[v+1|0]<<16|i[v+2|0]<<8|i[v+3|0]|0}function g(v){return v=v|0,s(v|0),p=p+1|0,0}function I(v){return v=v|0,L(1)|0?1:(s(i[p+1|0]|0),p=p+2|0,0)}function A(v){return v=v|0,L(2)|0?1:(s(l(p+1|0)|0),p=p+3|0,0)}function P(v){return v=v|0,L(4)|0?1:(o(l(p+1|0)|0,l(p+3|0)|0),p=p+5|0,0)}function k(v){return v=v|0,L(8)|0?1:(c(l(p+1|0)|0,l(p+3|0)|0,l(p+5|0)|0,l(p+7|0)|0),p=p+9|0,0)}function E(v){return v=v|0,s(-1-(v-32|0)|0),p=p+1|0,0}function q(v){return v=v|0,L(1)|0?1:(s(-1-(i[p+1|0]|0)|0),p=p+2|0,0)}function V(v){v=v|0;var Te=0;return L(2)|0?1:(Te=l(p+1|0)|0,s(-1-(Te|0)|0),p=p+3|0,0)}function C(v){return v=v|0,L(4)|0?1:(a(l(p+1|0)|0,l(p+3|0)|0),p=p+5|0,0)}function X(v){return v=v|0,L(8)|0?1:(f(l(p+1|0)|0,l(p+3|0)|0,l(p+5|0)|0,l(p+7|0)|0),p=p+9|0,0)}function te(v){v=v|0;var Te=0,Be=0,xe=0;return xe=v-64|0,L(xe|0)|0?1:(Te=p+1|0,Be=(p+1|0)+(xe|0)|0,w(Te|0,Be|0),p=Be|0,0)}function de(v){v=v|0;var Te=0,Be=0,xe=0;return L(1)|0||(xe=i[p+1|0]|0,Te=p+2|0,Be=(p+2|0)+(xe|0)|0,L(xe+1|0)|0)?1:(w(Te|0,Be|0),p=Be|0,0)}function _e(v){v=v|0;var Te=0,Be=0,xe=0;return L(2)|0||(xe=l(p+1|0)|0,Te=p+3|0,Be=(p+3|0)+(xe|0)|0,L(xe+2|0)|0)?1:(w(Te|0,Be|0),p=Be|0,0)}function Fe(v){v=v|0;var Te=0,Be=0,xe=0;return L(4)|0||(xe=y(p+1|0)|0,Te=p+5|0,Be=(p+5|0)+(xe|0)|0,L(xe+4|0)|0)?1:(w(Te|0,Be|0),p=Be|0,0)}function $e(v){return v=v|0,1}function me(v){return v=v|0,b(),p=p+1|0,0}function he(v){v=v|0;var Te=0,Be=0,xe=0;return xe=v-96|0,L(xe|0)|0?1:(Te=p+1|0,Be=(p+1|0)+(xe|0)|0,B(Te|0,Be|0),p=Be|0,0)}function Xe(v){v=v|0;var Te=0,Be=0,xe=0;return L(1)|0||(xe=i[p+1|0]|0,Te=p+2|0,Be=(p+2|0)+(xe|0)|0,L(xe+1|0)|0)?1:(B(Te|0,Be|0),p=Be|0,0)}function Er(v){v=v|0;var Te=0,Be=0,xe=0;return L(2)|0||(xe=l(p+1|0)|0,Te=p+3|0,Be=(p+3|0)+(xe|0)|0,L(xe+2|0)|0)?1:(B(Te|0,Be|0),p=Be|0,0)}function Kr(v){v=v|0;var Te=0,Be=0,xe=0;return L(4)|0||(xe=y(p+1|0)|0,Te=p+5|0,Be=(p+5|0)+(xe|0)|0,L(xe+4|0)|0)?1:(B(Te|0,Be|0),p=Be|0,0)}function In(v){return v=v|0,1}function Qt(v){return v=v|0,S(),p=p+1|0,0}function Pe(v){return v=v|0,$(v-128|0),p=p+1|0,0}function jt(v){return v=v|0,L(1)|0?1:($(i[p+1|0]|0),p=p+2|0,0)}function gt(v){return v=v|0,L(2)|0?1:($(l(p+1|0)|0),p=p+3|0,0)}function We(v){return v=v|0,L(4)|0?1:(W(l(p+1|0)|0,l(p+3|0)|0),p=p+5|0,0)}function By(v){return v=v|0,L(8)|0?1:(D(l(p+1|0)|0,l(p+3|0)|0,l(p+5|0)|0,l(p+7|0)|0),p=p+9|0,0)}function Oy(v){return v=v|0,x(),p=p+1|0,0}function ze(v){v=v|0;var Te=0;return Te=v-160|0,L(Te|0)|0?1:(ie(Te|0),p=p+1|0,0)}function Ny(v){return v=v|0,L(1)|0?1:(ie(i[p+1|0]|0),p=p+2|0,0)}function Ry(v){return v=v|0,L(2)|0?1:(ie(l(p+1|0)|0),p=p+3|0,0)}function Py(v){return v=v|0,L(4)|0?1:(ee(l(p+1|0)|0,l(p+3|0)|0),p=p+5|0,0)}function Iy(v){return v=v|0,L(8)|0?1:(ne(l(p+1|0)|0,l(p+3|0)|0,l(p+5|0)|0,l(p+7|0)|0),p=p+9|0,0)}function Uy(v){return v=v|0,j(),p=p+1|0,0}function Qn(v){return v=v|0,H(v-192|0|0),p=p+1|0,0}function HE(v){return v=v|0,H(v|0),p=p+1|0,0}function VE(v){return v=v|0,H(v|0),p=p+1|0,0}function $E(v){return v=v|0,H(v|0),p=p+1|0,0}function KE(v){return v=v|0,H(v|0),p=p+1|0,0}function ut(v){return v=v|0,H(v-192|0|0),p=p+1|0,0}function GE(v){return v=v|0,H(v|0),p=p+1|0,0}function YE(v){return v=v|0,H(v|0),p=p+1|0,0}function WE(v){return v=v|0,H(v|0),p=p+1|0,0}function Fy(v){return v=v|0,L(1)|0?1:(H(i[p+1|0]|0),p=p+2|0,0)}function My(v){return v=v|0,L(2)|0?1:(H(l(p+1|0)|0),p=p+3|0,0)}function qy(v){return v=v|0,L(4)|0?1:(Z(l(p+1|0)|0,l(p+3|0)|0),p=p+5|0,0)}function Cy(v){return v=v|0,L(8)|0?1:(ae(l(p+1|0)|0,l(p+3|0)|0,l(p+5|0)|0,l(p+7|0)|0),p=p+9|0,0)}function tt(v){return v=v|0,N((v|0)-224|0),p=p+1|0,0}function jy(v){return v=v|0,u(),p=p+1|0,0}function ky(v){return v=v|0,_(),p=p+1|0,0}function Hy(v){return v=v|0,O(),p=p+1|0,0}function Vy(v){return v=v|0,T(),p=p+1|0,0}function $y(v){return v=v|0,L(1)|0?1:(N(i[p+1|0]|0),p=p+2|0,0)}function Ky(v){v=v|0;var Te=0,Be=0,xe=1,js=0,Hi=0,zE=0;return L(2)|0?1:(Te=i[p+1|0]|0,Be=i[p+2|0]|0,(Te|0)&128&&(xe=-1),js=+(((Te|0)&124)>>2),Hi=+(((Te|0)&3)<<8|Be),+js==0?d(+(+xe*5960464477539063e-23*+Hi)):+js==31?+xe==1?+Hi>0?M():R():+Hi>0?K():F():d(+(+xe*U(2,+(+js-25))*+(1024+Hi))),p=p+3|0,0)}function Gy(v){return v=v|0,L(4)|0?1:(h(i[p+1|0]|0,i[p+2|0]|0,i[p+3|0]|0,i[p+4|0]|0),p=p+5|0,0)}function Yy(v){return v=v|0,L(8)|0?1:(m(i[p+1|0]|0,i[p+2|0]|0,i[p+3|0]|0,i[p+4|0]|0,i[p+5|0]|0,i[p+6|0]|0,i[p+7|0]|0,i[p+8|0]|0),p=p+9|0,0)}function He(v){return v=v|0,1}function Wy(v){return v=v|0,z(),p=p+1|0,0}var zy=[g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,g,I,A,P,k,He,He,He,He,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,q,V,C,X,He,He,He,He,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,te,de,_e,Fe,$e,He,He,He,me,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,he,Xe,Er,Kr,In,He,He,He,Qt,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,jt,gt,We,By,He,He,He,Oy,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,ze,Ny,Ry,Py,Iy,He,He,He,Uy,Qn,Qn,Qn,Qn,Qn,Qn,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,ut,Fy,My,qy,Cy,He,He,He,He,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,jy,ky,Hy,Vy,$y,Ky,Gy,Yy,He,He,He,Wy];return{parse:fe}}});var Li=Q(Wt=>{"use strict";var Dc=Ji().BigNumber;Wt.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7};Wt.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};Wt.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31};Wt.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};Wt.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")};Wt.SHIFT32=Math.pow(2,32);Wt.SHIFT16=Math.pow(2,16);Wt.MAX_SAFE_HIGH=2097151;Wt.NEG_ONE=new Dc(-1);Wt.TEN=new Dc(10);Wt.TWO=new Dc(2);Wt.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}});var vo=Q(rr=>{"use strict";var{Buffer:eb}=ei("buffer"),Bd=Ji().BigNumber,Od=Li(),Sd=Od.SHIFT32,tb=Od.SHIFT16,rb=2097151;rr.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 nb(t){return t<16?"0"+t.toString(16):t.toString(16)}rr.arrayBufferToBignumber=function(t){let e=t.byteLength,r="";for(let n=0;n<e;n++)r+=nb(t[n]);return new Bd(r,16)};rr.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};rr.buildInt32=(t,e)=>t*tb+e;rr.buildInt64=(t,e,r,n)=>{let i=rr.buildInt32(t,e),s=rr.buildInt32(r,n);return i>rb?new Bd(i).times(Sd).plus(s):i*Sd+s};rr.writeHalf=function(e,r){let n=eb.allocUnsafe(4);n.writeFloatBE(r,0);let i=n.readUInt32BE(0);if(i&8191)return!1;var s=i>>16&32768;let o=i>>23&255,a=i&8388607;if(o>=113&&o<=142)s+=(o-112<<10)+(a>>13);else if(o>=103&&o<113){if(a&(1<<126-o)-1)return!1;s+=a+8388608>>126-o}else return!1;return e.writeUInt16BE(s,0),!0};rr.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])};rr.isNegativeZero=t=>t===0&&1/t<0;rr.nextPowerOf2=t=>{let e=0;if(t&&!(t&t-1))return t;for(;t!==0;)t>>=1,e+=1;return 1<<e}});var Lc=Q((Vx,Nd)=>{"use strict";var Jc=Li(),ib=Jc.MT,To=Jc.SIMPLE,Zc=Jc.SYMS,Xc=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,ib.SIMPLE_FLOAT)}static isSimple(e){return e instanceof t}static decode(e,r){switch(r==null&&(r=!0),e){case To.FALSE:return!1;case To.TRUE:return!0;case To.NULL:return r?null:Zc.NULL;case To.UNDEFINED:return r?void 0:Zc.UNDEFINED;case-1:if(!r)throw new Error("Invalid BREAK");return Zc.BREAK;default:return new t(e)}}};Nd.exports=Xc});var eu=Q(($x,Rd)=>{"use strict";var Qc=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}}};Rd.exports=Qc});var ru=Q((Kx,Id)=>{"use strict";var{URL:sb,URLSearchParams:ob,format:ab}=ei("url"),Pd="http://localhost",tu=class extends sb{constructor(e="",r=Pd){super(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}format(){return this.toString()}};Id.exports={URLWithLegacySupport:tu,URLSearchParams:ob,format:ab,defaultBase:Pd}});var Md=Q((Gx,Fd)=>{"use strict";var{URLWithLegacySupport:Ud,format:cb}=ru();Fd.exports=(t,e={},r={},n)=>{let i=e.protocol?e.protocol.replace(":",""):"http";i=(r[i]||n||i)+":";let s;try{s=new Ud(t)}catch{s={}}let o=Object.assign({},e,{protocol:i||s.protocol,host:e.host||s.host});return new Ud(t,cb(o)).toString()}});var nu=Q((Yx,qd)=>{"use strict";var{URLWithLegacySupport:ub,format:lb,URLSearchParams:fb,defaultBase:db}=ru(),hb=Md();qd.exports={URL:ub,URLSearchParams:fb,format:lb,relative:hb,defaultBase:db}});var iu=Q((Wx,jd)=>{"use strict";var{Buffer:bi}=ei("buffer"),Cd=pc(),pb=Ji().BigNumber,yb=Ad(),Pt=vo(),Ce=Li(),gb=Lc(),mb=eu(),{URL:bb}=nu(),Qi=class t{constructor(e){e=e||{},!e.size||e.size<65536?e.size=65536:e.size=Pt.nextPowerOf2(e.size),this._heap=new ArrayBuffer(e.size),this._heap8=new Uint8Array(this._heap),this._buffer=bi.from(this._heap),this._reset(),this._knownTags=Object.assign({0:r=>new Date(r),1:r=>new Date(r*1e3),2:r=>Pt.arrayBufferToBignumber(r),3:r=>Ce.NEG_ONE.minus(Pt.arrayBufferToBignumber(r)),4:r=>Ce.TEN.pow(r[0]).times(r[1]),5:r=>Ce.TWO.pow(r[0]).times(r[1]),32:r=>new bb(r),35:r=>new RegExp(r)},e.tags),this.parser=yb(global,{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 Ce.PARENT.TAG:this._push(this.createTag(e.ref[0],e.ref[1]));break;case Ce.PARENT.BYTE_STRING:this._push(this.createByteString(e.ref,e.length));break;case Ce.PARENT.UTF8_STRING:this._push(this.createUtf8String(e.ref,e.length));break;case Ce.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 Ce.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 Ce.PARENT.ARRAY:this._push(this.createArray(e.ref,e.length));break;default:break}this._currentParent&&this._currentParent.type===Ce.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 Ce.PARENT.ARRAY:case Ce.PARENT.BYTE_STRING:case Ce.PARENT.UTF8_STRING:n.length>-1?this._ref[this._ref.length-n.length]=e:this._ref.push(e),this._dec();break;case Ce.PARENT.OBJECT:n.tmpKey!=null?(this._ref[n.tmpKey]=e,n.tmpKey=null,this._dec()):(n.tmpKey=e,typeof n.tmpKey!="string"&&(n.type=Ce.PARENT.MAP,n.ref=Pt.buildMap(n.ref)));break;case Ce.PARENT.MAP:n.tmpKey!=null?(this._ref.set(n.tmpKey,e),n.tmpKey=null,this._dec()):n.tmpKey=e;break;case Ce.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:Ce.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(e,r){let n=this._knownTags[e];return n?n(r):new mb(e,r)}createMap(e,r){return e}createObject(e,r){return e}createArray(e,r){return e}createByteString(e,r){return bi.concat(e)}createByteStringFromHeap(e,r){return e===r?bi.alloc(0):bi.from(this._heap.slice(e,r))}createInt(e){return e}createInt32(e,r){return Pt.buildInt32(e,r)}createInt64(e,r,n,i){return Pt.buildInt64(e,r,n,i)}createFloat(e){return e}createFloatSingle(e,r,n,i){return Cd.read([e,r,n,i],0,!1,23,4)}createFloatDouble(e,r,n,i,s,o,a,c){return Cd.read([e,r,n,i,s,o,a,c],0,!1,52,8)}createInt32Neg(e,r){return-1-Pt.buildInt32(e,r)}createInt64Neg(e,r,n,i){let s=Pt.buildInt32(e,r),o=Pt.buildInt32(n,i);return s>Ce.MAX_SAFE_HIGH?Ce.NEG_ONE.minus(new pb(s).times(Ce.SHIFT32).plus(o)):-1-(s*Ce.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 gb(e)}pushInt(e){this._push(this.createInt(e))}pushInt32(e,r){this._push(this.createInt32(e,r))}pushInt64(e,r,n,i){this._push(this.createInt64(e,r,n,i))}pushFloat(e){this._push(this.createFloat(e))}pushFloatSingle(e,r,n,i){this._push(this.createFloatSingle(e,r,n,i))}pushFloatDouble(e,r,n,i,s,o,a,c){this._push(this.createFloatDouble(e,r,n,i,s,o,a,c))}pushInt32Neg(e,r){this._push(this.createInt32Neg(e,r))}pushInt64Neg(e,r,n,i){this._push(this.createInt64Neg(e,r,n,i))}pushTrue(){this._push(this.createTrue())}pushFalse(){this._push(this.createFalse())}pushNull(){this._push(this.createNull())}pushUndefined(){this._push(this.createUndefined())}pushInfinity(){this._push(this.createInfinity())}pushInfinityNeg(){this._push(this.createInfinityNeg())}pushNaN(){this._push(this.createNaN())}pushNaNNeg(){this._push(this.createNaNNeg())}pushArrayStart(){this._createParent([],Ce.PARENT.ARRAY,-1)}pushArrayStartFixed(e){this._createArrayStartFixed(e)}pushArrayStartFixed32(e,r){let n=Pt.buildInt32(e,r);this._createArrayStartFixed(n)}pushArrayStartFixed64(e,r,n,i){let s=Pt.buildInt64(e,r,n,i);this._createArrayStartFixed(s)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(e){this._createObjectStartFixed(e)}pushObjectStartFixed32(e,r){let n=Pt.buildInt32(e,r);this._createObjectStartFixed(n)}pushObjectStartFixed64(e,r,n,i){let s=Pt.buildInt64(e,r,n,i);this._createObjectStartFixed(s)}pushByteStringStart(){this._parents[this._depth]={type:Ce.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:Ce.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:Ce.PARENT.TAG,length:1,ref:[e]}}pushTagStart4(e,r){this.pushTagStart(Pt.buildInt32(e,r))}pushTagStart8(e,r,n,i){this.pushTagStart(Pt.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({},Ce.PARENT.OBJECT,e)}_createArrayStartFixed(e){if(e===0){this._push(this.createArray([]));return}this._createParent(new Array(e),Ce.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=bi.from(e,r||"hex")),new t({size:e.length}).decodeFirst(e)}static decodeAll(e,r){return typeof e=="string"&&(e=bi.from(e,r||"hex")),new t({size:e.length}).decodeAll(e)}};Qi.decodeFirst=Qi.decode;jd.exports=Qi});var Vd=Q((zx,Hd)=>{"use strict";var{Buffer:su}=ei("buffer"),_b=iu(),wb=vo(),ou=class t extends _b{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 wb.isNegativeZero(e)?"-0_1":`${r}_1`}createFloatSingle(e,r,n,i){return`${super.createFloatSingle(e,r,n,i)}_2`}createFloatDouble(e,r,n,i,s,o,a,c){return`${super.createFloatDouble(e,r,n,i,s,o,a,c)}_3`}createByteString(e,r){let n=e.join(", ");return r===-1?`(_ ${n})`:`h'${n}`}createByteStringFromHeap(e,r){return`h'${su.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(kd(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createObject(e,r){let n=super.createObject(e),i=Object.keys(n).reduce(kd(n),"");return r===-1?`{_ ${i}}`:`{${i}}`}createUtf8String(e,r){let n=e.join(", ");return r===-1?`(_ ${n})`:`"${n}"`}createUtf8StringFromHeap(e,r){return`"${su.from(super.createUtf8StringFromHeap(e,r)).toString("utf8")}"`}static diagnose(e,r){return typeof e=="string"&&(e=su.from(e,r||"hex")),new t().decodeFirst(e)}};Hd.exports=ou;function kd(t){return(e,r)=>e?`${e}, ${r}: ${t[r]}`:`${r}: ${t[r]}`}});var Wd=Q((Dx,Yd)=>{"use strict";var{Buffer:Pr}=ei("buffer"),{URL:Eb}=nu(),cu=Ji().BigNumber,au=vo(),st=Li(),ur=st.MT,Ao=st.NUMBYTES,$d=st.SHIFT32,Kd=st.SYMS,_i=st.TAG,xb=st.MT.SIMPLE_FLOAT<<5|st.NUMBYTES.TWO,vb=st.MT.SIMPLE_FLOAT<<5|st.NUMBYTES.FOUR,Tb=st.MT.SIMPLE_FLOAT<<5|st.NUMBYTES.EIGHT,Ab=st.MT.SIMPLE_FLOAT<<5|st.SIMPLE.TRUE,Sb=st.MT.SIMPLE_FLOAT<<5|st.SIMPLE.FALSE,Bb=st.MT.SIMPLE_FLOAT<<5|st.SIMPLE.UNDEFINED,Gd=st.MT.SIMPLE_FLOAT<<5|st.SIMPLE.NULL,Ob=new cu("0x20000000000000"),Nb=Pr.from("f97e00","hex"),Rb=Pr.from("f9fc00","hex"),Pb=Pr.from("f97c00","hex");function Ib(t){return{}.toString.call(t).slice(8,-1)}var uu=class t{constructor(e){e=e||{},this.streaming=typeof e.stream=="function",this.onData=e.stream,this.semanticTypes=[[Eb,this._pushUrl],[cu,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(Nb)}_pushInfinity(e){let r=e<0?Rb:Pb;return this.push(r)}_pushFloat(e){let r=Pr.allocUnsafe(2);if(au.writeHalf(r,e)&&au.parseHalf(r)===e)return this._pushUInt8(xb)&&this.push(r);let n=Pr.allocUnsafe(4);return n.writeFloatBE(e,0),n.readFloatBE(0)===e?this._pushUInt8(vb)&&this.push(n):this._pushUInt8(Tb)&&this._pushDoubleBE(e)}_pushInt(e,r,n){let i=r<<5;return e<24?this._pushUInt8(i|e):e<=255?this._pushUInt8(i|Ao.ONE)&&this._pushUInt8(e):e<=65535?this._pushUInt8(i|Ao.TWO)&&this._pushUInt16BE(e):e<=4294967295?this._pushUInt8(i|Ao.FOUR)&&this._pushUInt32BE(e):e<=Number.MAX_SAFE_INTEGER?this._pushUInt8(i|Ao.EIGHT)&&this._pushUInt32BE(Math.floor(e/$d))&&this._pushUInt32BE(e%$d):r===ur.NEG_INT?this._pushFloat(n):this._pushFloat(e)}_pushIntNum(e){return e<0?this._pushInt(-e-1,ur.NEG_INT,e):this._pushInt(e,ur.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=Pr.byteLength(e,"utf8");return this._pushInt(r,ur.UTF8_STRING)&&this.pushWrite(e,5,r)}_pushBoolean(e){return this._pushUInt8(e?Ab:Sb)}_pushUndefined(e){return this._pushUInt8(Bb)}_pushArray(e,r){let n=r.length;if(!e._pushInt(n,ur.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,ur.TAG)}_pushDate(e,r){return e._pushTag(_i.DATE_EPOCH)&&e.pushAny(Math.round(r/1e3))}_pushBuffer(e,r){return e._pushInt(r.length,ur.BYTE_STRING)&&e.push(r)}_pushNoFilter(e,r){return e._pushBuffer(e,r.slice())}_pushRegexp(e,r){return e._pushTag(_i.REGEXP)&&e.pushAny(r.source)}_pushSet(e,r){if(!e._pushInt(r.size,ur.ARRAY))return!1;for(let n of r)if(!e.pushAny(n))return!1;return!0}_pushUrl(e,r){return e._pushTag(_i.URI)&&e.pushAny(r.format())}_pushBigint(e){let r=_i.POS_BIGINT;e.isNegative()&&(e=e.negated().minus(1),r=_i.NEG_BIGINT);let n=e.toString(16);n.length%2&&(n="0"+n);let i=Pr.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(_i.DECIMAL_FRAC)&&e._pushInt(2,ur.ARRAY)))return!1;let n=r.decimalPlaces(),i=r.multipliedBy(new cu(10).pow(n));return e._pushIntNum(-n)?i.abs().isLessThan(Ob)?e._pushIntNum(i.toNumber()):e._pushBigint(i):!1}_pushMap(e,r){return e._pushInt(r.size,ur.MAP)?this._pushRawMap(r.size,Array.from(r)):!1}_pushObject(e){if(!e)return this._pushUInt8(Gd);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,ur.MAP)?this._pushRawMap(o,s.map(a=>[a,e[a]])):!1}_pushRawMap(e,r){r=r.map(function(i){return i[0]=t.encode(i[0]),i}).sort(au.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=Ib(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,Pr.isBuffer(e)?e:Pr.from(e));case"Null":return this._pushUInt8(Gd);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 Kd.NULL:return this._pushObject(null);case Kd.UNDEFINED:return this._pushUndefined(void 0);default:throw new Error("Unknown symbol: "+e.toString())}default:throw new Error("Unknown type: "+typeof e+", "+(e?e.toString():""))}}finalize(){if(this.offset===0)return null;for(var e=this.result,r=this.resultLength,n=this.resultMethod,i=this.offset,s=0,o=0;o<i;o++)s+=r[o];var a=Pr.allocUnsafe(s),c=0,f=0;for(o=0;o<i;o++){switch(f=r[o],n[o]){case 0:e[o].copy(a,c);break;case 1:a.writeUInt8(e[o],c,!0);break;case 2:a.writeUInt16BE(e[o],c,!0);break;case 3:a.writeUInt32BE(e[o],c,!0);break;case 4:a.writeDoubleBE(e[o],c,!0);break;case 5:a.write(e[o],c,f,"utf8");break;default:throw new Error("unkown method")}c+=f}var d=a;return this._reset(),d}_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()}};Yd.exports=uu});var So=Q(ot=>{"use strict";ot.Diagnose=Vd();ot.Decoder=iu();ot.Encoder=Wd();ot.Simple=Lc();ot.Tagged=eu();ot.decodeAll=ot.Decoder.decodeAll;ot.decodeFirst=ot.Decoder.decodeFirst;ot.diagnose=ot.Diagnose.diagnose;ot.encode=ot.Encoder.encode;ot.decode=ot.Decoder.decode;ot.leveldb={decode:ot.Decoder.decodeAll,encode:ot.Encoder.encode,buffer:!0,name:"cbor"}});var rs=Q(nr=>{"use strict";var Ub=nr&&nr.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(nr,"__esModule",{value:!0});nr.hashOfMap=nr.requestIdOf=nr.hashValue=nr.hash=void 0;var zd=mi(),Fb=Ub(So()),Mb=Ys(),es=Ht();function ln(t){return(0,es.uint8ToBuf)(Mb.sha256.create().update(new Uint8Array(t)).digest())}nr.hash=ln;function ts(t){if(t instanceof Fb.default.Tagged)return ts(t.value);if(typeof t=="string")return Dd(t);if(typeof t=="number")return ln((0,zd.lebEncode)(t));if(t instanceof ArrayBuffer||ArrayBuffer.isView(t))return ln(t);if(Array.isArray(t)){let e=t.map(ts);return ln((0,es.concat)(...e))}else{if(t&&typeof t=="object"&&t._isPrincipal)return ln(t.toUint8Array());if(typeof t=="object"&&t!==null&&typeof t.toHash=="function")return ts(t.toHash());if(typeof t=="object")return lu(t);if(typeof t=="bigint")return ln((0,zd.lebEncode)(t))}throw Object.assign(new Error(`Attempt to hash a value of unsupported type: ${t}`),{value:t})}nr.hashValue=ts;var Dd=t=>{let e=new TextEncoder().encode(t);return ln(e)};function qb(t){return lu(t)}nr.requestIdOf=qb;function lu(t){let n=Object.entries(t).filter(([,o])=>o!==void 0).map(([o,a])=>{let c=Dd(o),f=ts(a);return[c,f]}).sort(([o],[a])=>(0,es.compare)(o,a)),i=(0,es.concat)(...n.map(o=>(0,es.concat)(...o)));return ln(i)}nr.hashOfMap=lu});var hu=Q(Ir=>{"use strict";var Cb=Ir&&Ir.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r};Object.defineProperty(Ir,"__esModule",{value:!0});Ir.createIdentityDescriptor=Ir.AnonymousIdentity=Ir.SignIdentity=void 0;var Zd=Tt(),jb=rs(),Xd=Ht(),kb=new TextEncoder().encode(`
17
+ ic-request`),fu=class{getPrincipal(){return this._principal||(this._principal=Zd.Principal.selfAuthenticating(new Uint8Array(this.getPublicKey().toDer()))),this._principal}async transformRequest(e){let{body:r}=e,n=Cb(e,["body"]),i=await(0,jb.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_pubkey:this.getPublicKey().toDer(),sender_sig:await this.sign((0,Xd.concat)(kb,i))}})}};Ir.SignIdentity=fu;var du=class{getPrincipal(){return Zd.Principal.anonymous()}async transformRequest(e){return Object.assign(Object.assign({},e),{body:{content:e.body}})}};Ir.AnonymousIdentity=du;function Hb(t){return"getPublicKey"in t?{type:"PublicKeyIdentity",publicKey:(0,Xd.toHex)(t.getPublicKey().toDer())}:{type:"AnonymousIdentity"}}Ir.createIdentityDescriptor=Hb});var gu=Q(Ke=>{"use strict";Object.defineProperty(Ke,"__esModule",{value:!0});var Vb=9007199254740992;function Dr(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 lr(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 Bo(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 lr(t,r,e.toString(16))}}function Jd(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 Dr(new Uint8Array(Bo(3,t.length)),new Uint8Array(e))}function $b(t,e){if(t==14277111)return Dr(new Uint8Array([217,217,247]),e);if(t<24)return Dr(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}}Ke.tagged=$b;function ns(t){return new Uint8Array(t).buffer}Ke.raw=ns;function pu(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}Ke.uSmall=pu;function Ld(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),lr(0,24,t)}Ke.u8=Ld;function Qd(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),lr(0,25,t)}Ke.u16=Qd;function e0(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),lr(0,26,t)}Ke.u32=e0;function yu(t,e){if(typeof t=="string"&&e==16){if(t.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return lr(0,27,t)}if(t=parseInt(""+t,e),isNaN(t))throw new RangeError("Invalid number.");return t=Math.min(Math.max(0,t),Vb),t=t.toString(16),lr(0,27,t)}Ke.u64=yu;function t0(t){if(isNaN(t))throw new RangeError("Invalid number.");if(t===0)return pu(0);t=Math.min(Math.max(0,-t),24)-1;let e=[32+t];return new Uint8Array(e).buffer}Ke.iSmall=t0;function r0(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),lr(1,24,t)}Ke.i8=r0;function n0(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),lr(1,25,t)}Ke.i16=n0;function i0(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),lr(1,26,t)}Ke.i32=i0;function s0(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?lr(1,27,n):yu(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),lr(1,27,t)}Ke.i64=s0;function Kb(t){return t>=0?t<24?pu(t):t<=255?Ld(t):t<=65535?Qd(t):t<=4294967295?e0(t):yu(t):t>=-24?t0(t):t>=-255?r0(t):t>=-65535?n0(t):t>=-4294967295?i0(t):s0(t)}Ke.number=Kb;function Gb(t){return Dr(Bo(2,t.byteLength),t)}Ke.bytes=Gb;function Yb(t){return Jd(t)}Ke.string=Yb;function Wb(t){return Dr(Bo(4,t.length),...t)}Ke.array=Wb;function zb(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))),Dr(Bo(5,t.size),...r.map(([n,i])=>Dr(Jd(n),i)))}Ke.map=zb;function Db(t){let e=new Float32Array([t]);return Dr(new Uint8Array([250]),new Uint8Array(e.buffer))}Ke.singleFloat=Db;function Zb(t){let e=new Float64Array([t]);return Dr(new Uint8Array([251]),new Uint8Array(e.buffer))}Ke.doubleFloat=Zb;function Xb(t){return t?o0():a0()}Ke.bool=Xb;function o0(){return ns(new Uint8Array([245]))}Ke.true_=o0;function a0(){return ns(new Uint8Array([244]))}Ke.false_=a0;function Jb(){return ns(new Uint8Array([246]))}Ke.null_=Jb;function Lb(){return ns(new Uint8Array([247]))}Ke.undefined_=Lb});var c0=Q(fn=>{"use strict";var Qb=fn&&fn.__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(fn,"__esModule",{value:!0});var fr=Qb(gu()),e_=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],Oo=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 fr.undefined_();case"boolean":return fr.bool(e);case"number":return Math.floor(e)===e?fr.number(e):fr.doubleFloat(e);case"string":return fr.string(e);case"object":if(e===null)return fr.null_();if(Array.isArray(e))return fr.array(e.map(r=>this._serializer.serializeValue(r)));if(e_.find(r=>e instanceof r))return fr.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 fr.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 fr.map(r,this._stable)}default:throw new Error("Invalid value.")}}};fn.JsonDefaultCborEncoder=Oo;var No=class{constructor(){this.name="cborEncoder",this.priority=-90}match(e){return typeof e=="object"&&typeof e.toCBOR=="function"}encode(e){return e.toCBOR()}};fn.ToCborEncoder=No;var Ro=class{constructor(){this._encoders=new Set}static withDefaultEncoders(e=!1){let r=new this;return r.addEncoder(new Oo(r,e)),r.addEncoder(new No),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)}};fn.CborSerializer=Ro;var mu=class extends Ro{serialize(e){return fr.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(e))]))}};fn.SelfDescribeCborSerializer=mu});var is=Q(jn=>{"use strict";function t_(t){for(var e in t)jn.hasOwnProperty(e)||(jn[e]=t[e])}var r_=jn&&jn.__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(jn,"__esModule",{value:!0});t_(c0());var n_=r_(gu());jn.value=n_});var ss=Q(bt=>{"use strict";var i_=bt&&bt.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),s_=bt&&bt.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),o_=bt&&bt.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&i_(e,t,r);return s_(e,t),e},a_=bt&&bt.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(bt,"__esModule",{value:!0});bt.decode=bt.encode=bt.CborTag=void 0;var c_=a_(So()),wi=o_(is()),u_=is(),Po=Ht(),bu=class{get name(){return"Principal"}get priority(){return 0}match(e){return e&&e._isPrincipal===!0}encode(e){return wi.value.bytes(e.toUint8Array())}},_u=class{get name(){return"Buffer"}get priority(){return 1}match(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)}encode(e){return wi.value.bytes(new Uint8Array(e))}},wu=class{get name(){return"BigInt"}get priority(){return 1}match(e){return typeof e=="bigint"}encode(e){return e>BigInt(0)?wi.value.tagged(2,wi.value.bytes((0,Po.fromHex)(e.toString(16)))):wi.value.tagged(3,wi.value.bytes((0,Po.fromHex)((BigInt("-1")*e).toString(16))))}},Io=u_.SelfDescribeCborSerializer.withDefaultEncoders(!0);Io.addEncoder(new bu);Io.addEncoder(new _u);Io.addEncoder(new wu);var l0;(function(t){t[t.Uint64LittleEndian=71]="Uint64LittleEndian",t[t.Semantic=55799]="Semantic"})(l0=bt.CborTag||(bt.CborTag={}));function l_(t){return Io.serialize(t)}bt.encode=l_;function u0(t){let e=t.byteLength,r=BigInt(0);for(let n=0;n<e;n++)r=r*BigInt(256)+BigInt(t[n]);return r}var Eu=class extends c_.default.Decoder{createByteString(e){return(0,Po.concat)(...e)}createByteStringFromHeap(e,r){return e===r?new ArrayBuffer(0):new Uint8Array(this._heap.slice(e,r))}};function f_(t){let e=new Uint8Array(t),r=new Eu({size:e.byteLength,tags:{2:n=>u0(n),3:n=>-u0(n),[l0.Semantic]:n=>n}});try{return r.decodeFirst(e)}catch(n){throw new Error(`Failed to decode CBOR: ${n}, input: ${(0,Po.toHex)(e)}`)}}bt.decode=f_});var xu=Q(Uo=>{"use strict";Object.defineProperty(Uo,"__esModule",{value:!0});Uo.randomNumber=void 0;var d_=()=>{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)};Uo.randomNumber=d_});var os=Q(kn=>{"use strict";Object.defineProperty(kn,"__esModule",{value:!0});kn.makeNonce=kn.SubmitRequestType=void 0;var Fo=xu(),h_;(function(t){t.Call="call"})(h_=kn.SubmitRequestType||(kn.SubmitRequestType={}));function p_(){let t=new ArrayBuffer(16),e=new DataView(t),r=(0,Fo.randomNumber)(),n=(0,Fo.randomNumber)(),i=(0,Fo.randomNumber)(),s=(0,Fo.randomNumber)();return e.setUint32(0,r),e.setUint32(4,n),e.setUint32(8,i),e.setUint32(12,s),t}kn.makeNonce=p_});var qo=Q(Bt=>{"use strict";var y_=Bt&&Bt.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),g_=Bt&&Bt.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),m_=Bt&&Bt.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&y_(e,t,r);return g_(e,t),e};Object.defineProperty(Bt,"__esModule",{value:!0});Bt.httpHeadersTransform=Bt.makeExpiryTransform=Bt.makeNonceTransform=Bt.Expiry=void 0;var b_=mi(),__=m_(is()),w_=os(),f0=BigInt(1e6),E_=60*1e3,Mo=class{constructor(e){if(e<90*1e3){let a=BigInt(Date.now()+e)*f0/BigInt(1e9);this._value=a*BigInt(1e9);return}let s=BigInt(Math.floor(Date.now()+e-E_))*f0/BigInt(1e9)/BigInt(60)*BigInt(60)*BigInt(1e9);this._value=s}toCBOR(){return __.value.u64(this._value.toString(16),16)}toHash(){return(0,b_.lebEncode)(this._value)}};Bt.Expiry=Mo;function x_(t=w_.makeNonce){return async e=>{let r=e.request.headers;e.request.headers=r,e.endpoint==="call"&&(e.body.nonce=t())}}Bt.makeNonceTransform=x_;function v_(t){return async e=>{e.body.ingress_expiry=new Mo(t)}}Bt.makeExpiryTransform=v_;function T_(t){let e=[];return t.forEach((r,n)=>{e.push([n,r])}),e}Bt.httpHeadersTransform=T_});var Tu=Q(Co=>{"use strict";Object.defineProperty(Co,"__esModule",{value:!0});Co.AgentHTTPResponseError=void 0;var A_=li(),vu=class extends A_.AgentError{constructor(e,r){super(e),this.response=r,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};Co.AgentHTTPResponseError=vu});var zt=Q(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.notImplemented=Ie.bitMask=void 0;Ie.isBytes=ko;Ie.abytes=Ho;Ie.abool=B_;Ie.bytesToHex=Ou;Ie.numberToHexUnpadded=p0;Ie.hexToNumber=Nu;Ie.hexToBytes=Vo;Ie.bytesToNumberBE=N_;Ie.bytesToNumberLE=R_;Ie.numberToBytesBE=y0;Ie.numberToBytesLE=P_;Ie.numberToVarBytesBE=I_;Ie.ensureBytes=U_;Ie.concatBytes=g0;Ie.equalBytes=F_;Ie.utf8ToBytes=M_;Ie.inRange=m0;Ie.aInRange=q_;Ie.bitLen=C_;Ie.bitGet=j_;Ie.bitSet=k_;Ie.createHmacDrbg=V_;Ie.validateObject=K_;Ie.memoized=Y_;var Bu=BigInt(0),jo=BigInt(1),S_=BigInt(2);function ko(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Ho(t){if(!ko(t))throw new Error("Uint8Array expected")}function B_(t,e){if(typeof e!="boolean")throw new Error(`${t} must be valid boolean, got "${e}".`)}var O_=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Ou(t){Ho(t);let e="";for(let r=0;r<t.length;r++)e+=O_[t[r]];return e}function p0(t){let e=t.toString(16);return e.length&1?`0${e}`:e}function Nu(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}var Zr={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function d0(t){if(t>=Zr._0&&t<=Zr._9)return t-Zr._0;if(t>=Zr._A&&t<=Zr._F)return t-(Zr._A-10);if(t>=Zr._a&&t<=Zr._f)return t-(Zr._a-10)}function Vo(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=d0(t.charCodeAt(s)),a=d0(t.charCodeAt(s+1));if(o===void 0||a===void 0){let c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=o*16+a}return n}function N_(t){return Nu(Ou(t))}function R_(t){return Ho(t),Nu(Ou(Uint8Array.from(t).reverse()))}function y0(t,e){return Vo(t.toString(16).padStart(e*2,"0"))}function P_(t,e){return y0(t,e).reverse()}function I_(t){return Vo(p0(t))}function U_(t,e,r){let n;if(typeof e=="string")try{n=Vo(e)}catch(s){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${s}`)}else if(ko(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 g0(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];Ho(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 F_(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 M_(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}var Au=t=>typeof t=="bigint"&&Bu<=t;function m0(t,e,r){return Au(t)&&Au(e)&&Au(r)&&e<=t&&t<r}function q_(t,e,r,n){if(!m0(e,r,n))throw new Error(`expected valid ${t}: ${r} <= n < ${n}, got ${typeof e} ${e}`)}function C_(t){let e;for(e=0;t>Bu;t>>=jo,e+=1);return e}function j_(t,e){return t>>BigInt(e)&jo}function k_(t,e,r){return t|(r?jo:Bu)<<BigInt(e)}var H_=t=>(S_<<BigInt(t-1))-jo;Ie.bitMask=H_;var Su=t=>new Uint8Array(t),h0=t=>Uint8Array.from(t);function V_(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=Su(t),i=Su(t),s=0,o=()=>{n.fill(1),i.fill(0),s=0},a=(...h)=>r(i,n,...h),c=(h=Su())=>{i=a(h0([0]),h),n=a(),h.length!==0&&(i=a(h0([1]),h),n=a())},f=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let h=0,m=[];for(;h<e;){n=a();let _=n.slice();m.push(_),h+=n.length}return g0(...m)};return(h,m)=>{o(),c(h);let _;for(;!(_=m(f()));)c();return o(),_}}var $_={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"||ko(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 K_(t,e,r={}){let n=(i,s,o)=>{let a=$_[s];if(typeof a!="function")throw new Error(`Invalid validator "${s}", expected function`);let c=t[i];if(!(o&&c===void 0)&&!a(c,t))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${s}`)};for(let[i,s]of Object.entries(e))n(i,s,!1);for(let[i,s]of Object.entries(r))n(i,s,!0);return t}var G_=()=>{throw new Error("not implemented")};Ie.notImplemented=G_;function Y_(t){let e=new WeakMap;return(r,...n)=>{let i=e.get(r);if(i!==void 0)return i;let s=t(r,...n);return e.set(r,s),s}}});var Ur=Q(De=>{"use strict";Object.defineProperty(De,"__esModule",{value:!0});De.isNegativeLE=void 0;De.mod=Dt;De.pow=w0;De.pow2=Z_;De.invert=$o;De.tonelliShanks=E0;De.FpSqrt=x0;De.validateField=L_;De.FpPow=v0;De.FpInvertBatch=T0;De.FpDiv=Q_;De.FpLegendre=A0;De.FpIsSquare=e1;De.nLength=Pu;De.Field=t1;De.FpSqrtOdd=r1;De.FpSqrtEven=n1;De.hashToPrivateScalar=i1;De.getFieldBytesLength=Iu;De.getMinHashLength=S0;De.mapHashToField=s1;var Zt=zt(),at=BigInt(0),Ve=BigInt(1),dn=BigInt(2),W_=BigInt(3),Ru=BigInt(4),b0=BigInt(5),_0=BigInt(8),z_=BigInt(9),D_=BigInt(16);function Dt(t,e){let r=t%e;return r>=at?r:e+r}function w0(t,e,r){if(r<=at||e<at)throw new Error("Expected power/modulo > 0");if(r===Ve)return at;let n=Ve;for(;e>at;)e&Ve&&(n=n*t%r),t=t*t%r,e>>=Ve;return n}function Z_(t,e,r){let n=t;for(;e-- >at;)n*=n,n%=r;return n}function $o(t,e){if(t===at||e<=at)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=Dt(t,e),n=e,i=at,s=Ve,o=Ve,a=at;for(;r!==at;){let f=n/r,d=n%r,h=i-o*f,m=s-a*f;n=r,r=d,i=o,s=a,o=h,a=m}if(n!==Ve)throw new Error("invert: does not exist");return Dt(i,e)}function E0(t){let e=(t-Ve)/dn,r,n,i;for(r=t-Ve,n=0;r%dn===at;r/=dn,n++);for(i=dn;i<t&&w0(i,e,t)!==t-Ve;i++);if(n===1){let o=(t+Ve)/Ru;return function(c,f){let d=c.pow(f,o);if(!c.eql(c.sqr(d),f))throw new Error("Cannot find square root");return d}}let s=(r+Ve)/dn;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=n,d=a.pow(a.mul(a.ONE,i),r),h=a.pow(c,s),m=a.pow(c,r);for(;!a.eql(m,a.ONE);){if(a.eql(m,a.ZERO))return a.ZERO;let _=1;for(let T=a.sqr(m);_<f&&!a.eql(T,a.ONE);_++)T=a.sqr(T);let u=a.pow(d,Ve<<BigInt(f-_-1));d=a.sqr(u),h=a.mul(h,u),m=a.mul(m,d),f=_}return h}}function x0(t){if(t%Ru===W_){let e=(t+Ve)/Ru;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%_0===b0){let e=(t-b0)/_0;return function(n,i){let s=n.mul(i,dn),o=n.pow(s,e),a=n.mul(i,o),c=n.mul(n.mul(a,dn),o),f=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(f),i))throw new Error("Cannot find square root");return f}}return t%D_,E0(t)}var X_=(t,e)=>(Dt(t,e)&Ve)===Ve;De.isNegativeLE=X_;var J_=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function L_(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=J_.reduce((n,i)=>(n[i]="function",n),e);return(0,Zt.validateObject)(t,r)}function v0(t,e,r){if(r<at)throw new Error("Expected power > 0");if(r===at)return t.ONE;if(r===Ve)return e;let n=t.ONE,i=e;for(;r>at;)r&Ve&&(n=t.mul(n,i)),i=t.sqr(i),r>>=Ve;return n}function T0(t,e){let r=new Array(e.length),n=e.reduce((s,o,a)=>t.is0(o)?s:(r[a]=s,t.mul(s,o)),t.ONE),i=t.inv(n);return e.reduceRight((s,o,a)=>t.is0(o)?s:(r[a]=t.mul(s,r[a]),t.mul(s,o)),i),r}function Q_(t,e,r){return t.mul(e,typeof r=="bigint"?$o(r,t.ORDER):t.inv(r))}function A0(t){let e=(t-Ve)/dn;return(r,n)=>r.pow(n,e)}function e1(t){let e=A0(t.ORDER);return r=>{let n=e(t,r);return t.eql(n,t.ZERO)||t.eql(n,t.ONE)}}function Pu(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function t1(t,e,r=!1,n={}){if(t<=at)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:s}=Pu(t,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=x0(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:s,MASK:(0,Zt.bitMask)(i),ZERO:at,ONE:Ve,create:c=>Dt(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return at<=c&&c<t},is0:c=>c===at,isOdd:c=>(c&Ve)===Ve,neg:c=>Dt(-c,t),eql:(c,f)=>c===f,sqr:c=>Dt(c*c,t),add:(c,f)=>Dt(c+f,t),sub:(c,f)=>Dt(c-f,t),mul:(c,f)=>Dt(c*f,t),pow:(c,f)=>v0(a,c,f),div:(c,f)=>Dt(c*$o(f,t),t),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>$o(c,t),sqrt:n.sqrt||(c=>o(a,c)),invertBatch:c=>T0(a,c),cmov:(c,f,d)=>d?f:c,toBytes:c=>r?(0,Zt.numberToBytesLE)(c,s):(0,Zt.numberToBytesBE)(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return r?(0,Zt.bytesToNumberLE)(c):(0,Zt.bytesToNumberBE)(c)}});return Object.freeze(a)}function r1(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let r=t.sqrt(e);return t.isOdd(r)?r:t.neg(r)}function n1(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let r=t.sqrt(e);return t.isOdd(r)?t.neg(r):r}function i1(t,e,r=!1){t=(0,Zt.ensureBytes)("privateHash",t);let n=t.length,i=Pu(e).nByteLength+8;if(i<24||n<i||n>1024)throw new Error(`hashToPrivateScalar: expected ${i}-1024 bytes of input, got ${n}`);let s=r?(0,Zt.bytesToNumberLE)(t):(0,Zt.bytesToNumberBE)(t);return Dt(s,e-Ve)+Ve}function Iu(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 S0(t){let e=Iu(t);return e+Math.ceil(e/2)}function s1(t,e,r=!1){let n=t.length,i=Iu(e),s=S0(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let o=r?(0,Zt.bytesToNumberBE)(t):(0,Zt.bytesToNumberLE)(t),a=Dt(o,e-Ve)+Ve;return r?(0,Zt.numberToBytesLE)(a,i):(0,Zt.numberToBytesBE)(a,i)}});var Ko=Q(Hn=>{"use strict";Object.defineProperty(Hn,"__esModule",{value:!0});Hn.expand_message_xmd=B0;Hn.expand_message_xof=O0;Hn.hash_to_field=Uu;Hn.isogenyMap=u1;Hn.createHasher=l1;var o1=Ur(),Ot=zt(),a1=Ot.bytesToNumberBE;function hn(t,e){if(as(t),as(e),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 c1(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 as(t){if(!Number.isSafeInteger(t))throw new Error("number expected")}function B0(t,e,r,n){(0,Ot.abytes)(t),(0,Ot.abytes)(e),as(r),e.length>255&&(e=n((0,Ot.concatBytes)((0,Ot.utf8ToBytes)("H2C-OVERSIZE-DST-"),e)));let{outputLen:i,blockLen:s}=n,o=Math.ceil(r/i);if(r>65535||o>255)throw new Error("expand_message_xmd: invalid lenInBytes");let a=(0,Ot.concatBytes)(e,hn(e.length,1)),c=hn(0,s),f=hn(r,2),d=new Array(o),h=n((0,Ot.concatBytes)(c,t,f,hn(0,1),a));d[0]=n((0,Ot.concatBytes)(h,hn(1,1),a));for(let _=1;_<=o;_++){let u=[c1(h,d[_-1]),hn(_+1,1),a];d[_]=n((0,Ot.concatBytes)(...u))}return(0,Ot.concatBytes)(...d).slice(0,r)}function O0(t,e,r,n,i){if((0,Ot.abytes)(t),(0,Ot.abytes)(e),as(r),e.length>255){let s=Math.ceil(2*n/8);e=i.create({dkLen:s}).update((0,Ot.utf8ToBytes)("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(hn(r,2)).update(e).update(hn(e.length,1)).digest()}function Uu(t,e,r){(0,Ot.validateObject)(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;(0,Ot.abytes)(t),as(e);let f=typeof c=="string"?(0,Ot.utf8ToBytes)(c):c,d=n.toString(2).length,h=Math.ceil((d+i)/8),m=e*s*h,_;if(a==="xmd")_=B0(t,f,m,o);else if(a==="xof")_=O0(t,f,m,i,o);else if(a==="_internal_pass")_=t;else throw new Error('expand must be "xmd" or "xof"');let u=new Array(e);for(let T=0;T<e;T++){let O=new Array(s);for(let R=0;R<s;R++){let F=h*(R+T*s),M=_.subarray(F,F+h);O[R]=(0,o1.mod)(a1(M),n)}u[T]=O}return u}function u1(t,e){let r=e.map(n=>Array.from(n).reverse());return(n,i)=>{let[s,o,a,c]=r.map(f=>f.reduce((d,h)=>t.add(t.mul(d,n),h)));return n=t.div(s,o),i=t.mul(i,t.div(a,c)),{x:n,y:i}}}function l1(t,e,r){if(typeof e!="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){let s=Uu(n,2,{...r,DST:r.DST,...i}),o=t.fromAffine(e(s[0])),a=t.fromAffine(e(s[1])),c=o.add(a).clearCofactor();return c.assertValidity(),c},encodeToCurve(n,i){let s=Uu(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 qu=Q(cs=>{"use strict";Object.defineProperty(cs,"__esModule",{value:!0});cs.wNAF=d1;cs.pippenger=h1;cs.validateBasic=p1;var N0=Ur(),P0=zt(),f1=BigInt(0),Fu=BigInt(1),Mu=new WeakMap,R0=new WeakMap;function d1(t,e){let r=(s,o)=>{let a=o.negate();return s?a:o},n=s=>{if(!Number.isSafeInteger(s)||s<=0||s>e)throw new Error(`Wrong window size=${s}, should be [1..${e}]`)},i=s=>{n(s);let o=Math.ceil(e/s)+1,a=2**(s-1);return{windows:o,windowSize:a}};return{constTimeNegate:r,unsafeLadder(s,o){let a=t.ZERO,c=s;for(;o>f1;)o&Fu&&(a=a.add(c)),c=c.double(),o>>=Fu;return a},precomputeWindow(s,o){let{windows:a,windowSize:c}=i(o),f=[],d=s,h=d;for(let m=0;m<a;m++){h=d,f.push(h);for(let _=1;_<c;_++)h=h.add(d),f.push(h);d=h.double()}return f},wNAF(s,o,a){let{windows:c,windowSize:f}=i(s),d=t.ZERO,h=t.BASE,m=BigInt(2**s-1),_=2**s,u=BigInt(s);for(let T=0;T<c;T++){let O=T*f,R=Number(a&m);a>>=u,R>f&&(R-=_,a+=Fu);let F=O,M=O+Math.abs(R)-1,K=T%2!==0,x=R<0;R===0?h=h.add(r(K,o[F])):d=d.add(r(x,o[M]))}return{p:d,f:h}},wNAFCached(s,o,a){let c=R0.get(s)||1,f=Mu.get(s);return f||(f=this.precomputeWindow(s,c),c!==1&&Mu.set(s,a(f))),this.wNAF(c,f,o)},setWindowSize(s,o){n(o),R0.set(s,o),Mu.delete(s)}}}function h1(t,e,r,n){if(!Array.isArray(r)||!Array.isArray(n)||n.length!==r.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((d,h)=>{if(!e.isValid(d))throw new Error(`wrong scalar at index ${h}`)}),r.forEach((d,h)=>{if(!(d instanceof t))throw new Error(`wrong point at index ${h}`)});let i=(0,P0.bitLen)(BigInt(r.length)),s=i>12?i-3:i>4?i-2:i?2:1,o=(1<<s)-1,a=new Array(o+1).fill(t.ZERO),c=Math.floor((e.BITS-1)/s)*s,f=t.ZERO;for(let d=c;d>=0;d-=s){a.fill(t.ZERO);for(let m=0;m<n.length;m++){let _=n[m],u=Number(_>>BigInt(d)&BigInt(o));a[u]=a[u].add(r[m])}let h=t.ZERO;for(let m=a.length-1,_=t.ZERO;m>0;m--)_=_.add(a[m]),h=h.add(_);if(f=f.add(h),d!==0)for(let m=0;m<s;m++)f=f.double()}return f}function p1(t){return(0,N0.validateField)(t.Fp),(0,P0.validateObject)(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,N0.nLength)(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}});var Cu=Q(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.DER=void 0;wt.weierstrassPoints=F0;wt.weierstrass=_1;wt.SWUFpSqrtRatio=M0;wt.mapToCurveSimpleSWU=w1;var Go=qu(),Vn=Ur(),Ae=zt(),_t=zt();function I0(t){t.lowS!==void 0&&(0,_t.abool)("lowS",t.lowS),t.prehash!==void 0&&(0,_t.abool)("prehash",t.prehash)}function y1(t){let e=(0,Go.validateBasic)(t);Ae.validateObject(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})}var{bytesToNumberBE:g1,hexToBytes:m1}=Ae;wt.DER={Err:class extends Error{constructor(e=""){super(e)}},_tlv:{encode:(t,e)=>{let{Err:r}=wt.DER;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length&1)throw new r("tlv.encode: unpadded data");let n=e.length/2,i=Ae.numberToHexUnpadded(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");let s=n>127?Ae.numberToHexUnpadded(i.length/2|128):"";return`${Ae.numberToHexUnpadded(t)}${s}${i}${e}`},decode(t,e){let{Err:r}=wt.DER,n=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");let i=e[n++],s=!!(i&128),o=0;if(!s)o=i;else{let c=i&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let f=e.subarray(n,n+c);if(f.length!==c)throw new r("tlv.decode: length bytes not complete");if(f[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let d of f)o=o<<8|d;if(n+=c,o<128)throw new r("tlv.decode(long): not minimal encoding")}let a=e.subarray(n,n+o);if(a.length!==o)throw new r("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+o)}}},_int:{encode(t){let{Err:e}=wt.DER;if(t<dr)throw new e("integer: negative integers are not allowed");let r=Ae.numberToHexUnpadded(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected assertion");return r},decode(t){let{Err:e}=wt.DER;if(t[0]&128)throw new e("Invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return g1(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=wt.DER,i=typeof t=="string"?m1(t):t;Ae.abytes(i);let{v:s,l:o}=n.decode(48,i);if(o.length)throw new e("Invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,s),{v:f,l:d}=n.decode(2,c);if(d.length)throw new e("Invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(f)}},hexFromSig(t){let{_tlv:e,_int:r}=wt.DER,n=`${e.encode(2,r.encode(t.r))}${e.encode(2,r.encode(t.s))}`;return e.encode(48,n)}};var dr=BigInt(0),je=BigInt(1),pn=BigInt(2),Yo=BigInt(3),U0=BigInt(4);function F0(t){let e=y1(t),{Fp:r}=e,n=Vn.Field(e.n,e.nBitLength),i=e.toBytes||((T,O,R)=>{let F=O.toAffine();return Ae.concatBytes(Uint8Array.from([4]),r.toBytes(F.x),r.toBytes(F.y))}),s=e.fromBytes||(T=>{let O=T.subarray(1),R=r.fromBytes(O.subarray(0,r.BYTES)),F=r.fromBytes(O.subarray(r.BYTES,2*r.BYTES));return{x:R,y:F}});function o(T){let{a:O,b:R}=e,F=r.sqr(T),M=r.mul(F,T);return r.add(r.add(M,r.mul(T,O)),R)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function a(T){return Ae.inRange(T,je,e.n)}function c(T){let{allowedPrivateKeyLengths:O,nByteLength:R,wrapPrivateKey:F,n:M}=e;if(O&&typeof T!="bigint"){if(Ae.isBytes(T)&&(T=Ae.bytesToHex(T)),typeof T!="string"||!O.includes(T.length))throw new Error("Invalid key");T=T.padStart(R*2,"0")}let K;try{K=typeof T=="bigint"?T:Ae.bytesToNumberBE((0,_t.ensureBytes)("private key",T,R))}catch{throw new Error(`private key must be ${R} bytes, hex or bigint, not ${typeof T}`)}return F&&(K=Vn.mod(K,M)),Ae.aInRange("private key",K,je,M),K}function f(T){if(!(T instanceof m))throw new Error("ProjectivePoint expected")}let d=(0,_t.memoized)((T,O)=>{let{px:R,py:F,pz:M}=T;if(r.eql(M,r.ONE))return{x:R,y:F};let K=T.is0();O==null&&(O=K?r.ONE:r.inv(M));let x=r.mul(R,O),$=r.mul(F,O),W=r.mul(M,O);if(K)return{x:r.ZERO,y:r.ZERO};if(!r.eql(W,r.ONE))throw new Error("invZ was invalid");return{x,y:$}}),h=(0,_t.memoized)(T=>{if(T.is0()){if(e.allowInfinityPoint&&!r.is0(T.py))return;throw new Error("bad point: ZERO")}let{x:O,y:R}=T.toAffine();if(!r.isValid(O)||!r.isValid(R))throw new Error("bad point: x or y not FE");let F=r.sqr(R),M=o(O);if(!r.eql(F,M))throw new Error("bad point: equation left != right");if(!T.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class m{constructor(O,R,F){if(this.px=O,this.py=R,this.pz=F,O==null||!r.isValid(O))throw new Error("x required");if(R==null||!r.isValid(R))throw new Error("y required");if(F==null||!r.isValid(F))throw new Error("z required");Object.freeze(this)}static fromAffine(O){let{x:R,y:F}=O||{};if(!O||!r.isValid(R)||!r.isValid(F))throw new Error("invalid affine point");if(O instanceof m)throw new Error("projective point not allowed");let M=K=>r.eql(K,r.ZERO);return M(R)&&M(F)?m.ZERO:new m(R,F,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(O){let R=r.invertBatch(O.map(F=>F.pz));return O.map((F,M)=>F.toAffine(R[M])).map(m.fromAffine)}static fromHex(O){let R=m.fromAffine(s((0,_t.ensureBytes)("pointHex",O)));return R.assertValidity(),R}static fromPrivateKey(O){return m.BASE.multiply(c(O))}static msm(O,R){return(0,Go.pippenger)(m,n,O,R)}_setWindowSize(O){u.setWindowSize(this,O)}assertValidity(){h(this)}hasEvenY(){let{y:O}=this.toAffine();if(r.isOdd)return!r.isOdd(O);throw new Error("Field doesn't support isOdd")}equals(O){f(O);let{px:R,py:F,pz:M}=this,{px:K,py:x,pz:$}=O,W=r.eql(r.mul(R,$),r.mul(K,M)),D=r.eql(r.mul(F,$),r.mul(x,M));return W&&D}negate(){return new m(this.px,r.neg(this.py),this.pz)}double(){let{a:O,b:R}=e,F=r.mul(R,Yo),{px:M,py:K,pz:x}=this,$=r.ZERO,W=r.ZERO,D=r.ZERO,j=r.mul(M,M),ie=r.mul(K,K),ee=r.mul(x,x),ne=r.mul(M,K);return ne=r.add(ne,ne),D=r.mul(M,x),D=r.add(D,D),$=r.mul(O,D),W=r.mul(F,ee),W=r.add($,W),$=r.sub(ie,W),W=r.add(ie,W),W=r.mul($,W),$=r.mul(ne,$),D=r.mul(F,D),ee=r.mul(O,ee),ne=r.sub(j,ee),ne=r.mul(O,ne),ne=r.add(ne,D),D=r.add(j,j),j=r.add(D,j),j=r.add(j,ee),j=r.mul(j,ne),W=r.add(W,j),ee=r.mul(K,x),ee=r.add(ee,ee),j=r.mul(ee,ne),$=r.sub($,j),D=r.mul(ee,ie),D=r.add(D,D),D=r.add(D,D),new m($,W,D)}add(O){f(O);let{px:R,py:F,pz:M}=this,{px:K,py:x,pz:$}=O,W=r.ZERO,D=r.ZERO,j=r.ZERO,ie=e.a,ee=r.mul(e.b,Yo),ne=r.mul(R,K),w=r.mul(F,x),b=r.mul(M,$),B=r.add(R,F),S=r.add(K,x);B=r.mul(B,S),S=r.add(ne,w),B=r.sub(B,S),S=r.add(R,M);let N=r.add(K,$);return S=r.mul(S,N),N=r.add(ne,b),S=r.sub(S,N),N=r.add(F,M),W=r.add(x,$),N=r.mul(N,W),W=r.add(w,b),N=r.sub(N,W),j=r.mul(ie,S),W=r.mul(ee,b),j=r.add(W,j),W=r.sub(w,j),j=r.add(w,j),D=r.mul(W,j),w=r.add(ne,ne),w=r.add(w,ne),b=r.mul(ie,b),S=r.mul(ee,S),w=r.add(w,b),b=r.sub(ne,b),b=r.mul(ie,b),S=r.add(S,b),ne=r.mul(w,S),D=r.add(D,ne),ne=r.mul(N,S),W=r.mul(B,W),W=r.sub(W,ne),ne=r.mul(B,w),j=r.mul(N,j),j=r.add(j,ne),new m(W,D,j)}subtract(O){return this.add(O.negate())}is0(){return this.equals(m.ZERO)}wNAF(O){return u.wNAFCached(this,O,m.normalizeZ)}multiplyUnsafe(O){Ae.aInRange("scalar",O,dr,e.n);let R=m.ZERO;if(O===dr)return R;if(O===je)return this;let{endo:F}=e;if(!F)return u.unsafeLadder(this,O);let{k1neg:M,k1:K,k2neg:x,k2:$}=F.splitScalar(O),W=R,D=R,j=this;for(;K>dr||$>dr;)K&je&&(W=W.add(j)),$&je&&(D=D.add(j)),j=j.double(),K>>=je,$>>=je;return M&&(W=W.negate()),x&&(D=D.negate()),D=new m(r.mul(D.px,F.beta),D.py,D.pz),W.add(D)}multiply(O){let{endo:R,n:F}=e;Ae.aInRange("scalar",O,je,F);let M,K;if(R){let{k1neg:x,k1:$,k2neg:W,k2:D}=R.splitScalar(O),{p:j,f:ie}=this.wNAF($),{p:ee,f:ne}=this.wNAF(D);j=u.constTimeNegate(x,j),ee=u.constTimeNegate(W,ee),ee=new m(r.mul(ee.px,R.beta),ee.py,ee.pz),M=j.add(ee),K=ie.add(ne)}else{let{p:x,f:$}=this.wNAF(O);M=x,K=$}return m.normalizeZ([M,K])[0]}multiplyAndAddUnsafe(O,R,F){let M=m.BASE,K=($,W)=>W===dr||W===je||!$.equals(M)?$.multiplyUnsafe(W):$.multiply(W),x=K(this,R).add(K(O,F));return x.is0()?void 0:x}toAffine(O){return d(this,O)}isTorsionFree(){let{h:O,isTorsionFree:R}=e;if(O===je)return!0;if(R)return R(m,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:O,clearCofactor:R}=e;return O===je?this:R?R(m,this):this.multiplyUnsafe(e.h)}toRawBytes(O=!0){return(0,_t.abool)("isCompressed",O),this.assertValidity(),i(m,this,O)}toHex(O=!0){return(0,_t.abool)("isCompressed",O),Ae.bytesToHex(this.toRawBytes(O))}}m.BASE=new m(e.Gx,e.Gy,r.ONE),m.ZERO=new m(r.ZERO,r.ONE,r.ZERO);let _=e.nBitLength,u=(0,Go.wNAF)(m,e.endo?Math.ceil(_/2):_);return{CURVE:e,ProjectivePoint:m,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:a}}function b1(t){let e=(0,Go.validateBasic)(t);return Ae.validateObject(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function _1(t){let e=b1(t),{Fp:r,n}=e,i=r.BYTES+1,s=2*r.BYTES+1;function o(b){return Vn.mod(b,n)}function a(b){return Vn.invert(b,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:f,weierstrassEquation:d,isWithinCurveOrder:h}=F0({...e,toBytes(b,B,S){let N=B.toAffine(),H=r.toBytes(N.x),Z=Ae.concatBytes;return(0,_t.abool)("isCompressed",S),S?Z(Uint8Array.from([B.hasEvenY()?2:3]),H):Z(Uint8Array.from([4]),H,r.toBytes(N.y))},fromBytes(b){let B=b.length,S=b[0],N=b.subarray(1);if(B===i&&(S===2||S===3)){let H=Ae.bytesToNumberBE(N);if(!Ae.inRange(H,je,r.ORDER))throw new Error("Point is not on curve");let Z=d(H),ae;try{ae=r.sqrt(Z)}catch(U){let p=U instanceof Error?": "+U.message:"";throw new Error("Point is not on curve"+p)}let oe=(ae&je)===je;return(S&1)===1!==oe&&(ae=r.neg(ae)),{x:H,y:ae}}else if(B===s&&S===4){let H=r.fromBytes(N.subarray(0,r.BYTES)),Z=r.fromBytes(N.subarray(r.BYTES,2*r.BYTES));return{x:H,y:Z}}else throw new Error(`Point of length ${B} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}}),m=b=>Ae.bytesToHex(Ae.numberToBytesBE(b,e.nByteLength));function _(b){let B=n>>je;return b>B}function u(b){return _(b)?o(-b):b}let T=(b,B,S)=>Ae.bytesToNumberBE(b.slice(B,S));class O{constructor(B,S,N){this.r=B,this.s=S,this.recovery=N,this.assertValidity()}static fromCompact(B){let S=e.nByteLength;return B=(0,_t.ensureBytes)("compactSignature",B,S*2),new O(T(B,0,S),T(B,S,2*S))}static fromDER(B){let{r:S,s:N}=wt.DER.toSig((0,_t.ensureBytes)("DER",B));return new O(S,N)}assertValidity(){Ae.aInRange("r",this.r,je,n),Ae.aInRange("s",this.s,je,n)}addRecoveryBit(B){return new O(this.r,this.s,B)}recoverPublicKey(B){let{r:S,s:N,recovery:H}=this,Z=$((0,_t.ensureBytes)("msgHash",B));if(H==null||![0,1,2,3].includes(H))throw new Error("recovery id invalid");let ae=H===2||H===3?S+e.n:S;if(ae>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let oe=H&1?"03":"02",z=c.fromHex(oe+m(ae)),U=a(ae),p=o(-Z*U),J=o(N*U),re=c.BASE.multiplyAndAddUnsafe(z,p,J);if(!re)throw new Error("point at infinify");return re.assertValidity(),re}hasHighS(){return _(this.s)}normalizeS(){return this.hasHighS()?new O(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Ae.hexToBytes(this.toDERHex())}toDERHex(){return wt.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Ae.hexToBytes(this.toCompactHex())}toCompactHex(){return m(this.r)+m(this.s)}}let R={isValidPrivateKey(b){try{return f(b),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let b=Vn.getMinHashLength(e.n);return Vn.mapHashToField(e.randomBytes(b),e.n)},precompute(b=8,B=c.BASE){return B._setWindowSize(b),B.multiply(BigInt(3)),B}};function F(b,B=!0){return c.fromPrivateKey(b).toRawBytes(B)}function M(b){let B=Ae.isBytes(b),S=typeof b=="string",N=(B||S)&&b.length;return B?N===i||N===s:S?N===2*i||N===2*s:b instanceof c}function K(b,B,S=!0){if(M(b))throw new Error("first arg must be private key");if(!M(B))throw new Error("second arg must be public key");return c.fromHex(B).multiply(f(b)).toRawBytes(S)}let x=e.bits2int||function(b){let B=Ae.bytesToNumberBE(b),S=b.length*8-e.nBitLength;return S>0?B>>BigInt(S):B},$=e.bits2int_modN||function(b){return o(x(b))},W=Ae.bitMask(e.nBitLength);function D(b){return Ae.aInRange(`num < 2^${e.nBitLength}`,b,dr,W),Ae.numberToBytesBE(b,e.nByteLength)}function j(b,B,S=ie){if(["recovered","canonical"].some(L=>L in S))throw new Error("sign() legacy options not supported");let{hash:N,randomBytes:H}=e,{lowS:Z,prehash:ae,extraEntropy:oe}=S;Z==null&&(Z=!0),b=(0,_t.ensureBytes)("msgHash",b),I0(S),ae&&(b=(0,_t.ensureBytes)("prehashed msgHash",N(b)));let z=$(b),U=f(B),p=[D(U),D(z)];if(oe!=null&&oe!==!1){let L=oe===!0?H(r.BYTES):oe;p.push((0,_t.ensureBytes)("extraEntropy",L))}let J=Ae.concatBytes(...p),re=z;function fe(L){let l=x(L);if(!h(l))return;let y=a(l),g=c.BASE.multiply(l).toAffine(),I=o(g.x);if(I===dr)return;let A=o(y*o(re+I*U));if(A===dr)return;let P=(g.x===I?0:2)|Number(g.y&je),k=A;return Z&&_(A)&&(k=u(A),P^=1),new O(I,k,P)}return{seed:J,k2sig:fe}}let ie={lowS:e.lowS,prehash:!1},ee={lowS:e.lowS,prehash:!1};function ne(b,B,S=ie){let{seed:N,k2sig:H}=j(b,B,S),Z=e;return Ae.createHmacDrbg(Z.hash.outputLen,Z.nByteLength,Z.hmac)(N,H)}c.BASE._setWindowSize(8);function w(b,B,S,N=ee){let H=b;if(B=(0,_t.ensureBytes)("msgHash",B),S=(0,_t.ensureBytes)("publicKey",S),"strict"in N)throw new Error("options.strict was renamed to lowS");I0(N);let{lowS:Z,prehash:ae}=N,oe,z;try{if(typeof H=="string"||Ae.isBytes(H))try{oe=O.fromDER(H)}catch(g){if(!(g instanceof wt.DER.Err))throw g;oe=O.fromCompact(H)}else if(typeof H=="object"&&typeof H.r=="bigint"&&typeof H.s=="bigint"){let{r:g,s:I}=H;oe=new O(g,I)}else throw new Error("PARSE");z=c.fromHex(S)}catch(g){if(g.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(Z&&oe.hasHighS())return!1;ae&&(B=e.hash(B));let{r:U,s:p}=oe,J=$(B),re=a(p),fe=o(J*re),L=o(U*re),l=c.BASE.multiplyAndAddUnsafe(z,fe,L)?.toAffine();return l?o(l.x)===U:!1}return{CURVE:e,getPublicKey:F,getSharedSecret:K,sign:ne,verify:w,ProjectivePoint:c,Signature:O,utils:R}}function M0(t,e){let r=t.ORDER,n=dr;for(let u=r-je;u%pn===dr;u/=pn)n+=je;let i=n,s=pn<<i-je-je,o=s*pn,a=(r-je)/o,c=(a-je)/pn,f=o-je,d=s,h=t.pow(e,a),m=t.pow(e,(a+je)/pn),_=(u,T)=>{let O=h,R=t.pow(T,f),F=t.sqr(R);F=t.mul(F,T);let M=t.mul(u,F);M=t.pow(M,c),M=t.mul(M,R),R=t.mul(M,T),F=t.mul(M,u);let K=t.mul(F,R);M=t.pow(K,d);let x=t.eql(M,t.ONE);R=t.mul(F,m),M=t.mul(K,O),F=t.cmov(R,F,x),K=t.cmov(M,K,x);for(let $=i;$>je;$--){let W=$-pn;W=pn<<W-je;let D=t.pow(K,W),j=t.eql(D,t.ONE);R=t.mul(F,O),O=t.mul(O,O),D=t.mul(K,O),F=t.cmov(R,F,j),K=t.cmov(D,K,j)}return{isValid:x,value:F}};if(t.ORDER%U0===Yo){let u=(t.ORDER-Yo)/U0,T=t.sqrt(t.neg(e));_=(O,R)=>{let F=t.sqr(R),M=t.mul(O,R);F=t.mul(F,M);let K=t.pow(F,u);K=t.mul(K,M);let x=t.mul(K,T),$=t.mul(t.sqr(K),R),W=t.eql($,O),D=t.cmov(x,K,W);return{isValid:W,value:D}}}return _}function w1(t,e){if(Vn.validateField(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let r=M0(t,e.Z);if(!t.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,s,o,a,c,f,d,h;i=t.sqr(n),i=t.mul(i,e.Z),s=t.sqr(i),s=t.add(s,i),o=t.add(s,t.ONE),o=t.mul(o,e.B),a=t.cmov(e.Z,t.neg(s),!t.eql(s,t.ZERO)),a=t.mul(a,e.A),s=t.sqr(o),f=t.sqr(a),c=t.mul(f,e.A),s=t.add(s,c),s=t.mul(s,o),f=t.mul(f,a),c=t.mul(f,e.B),s=t.add(s,c),d=t.mul(i,o);let{isValid:m,value:_}=r(s,f);h=t.mul(i,n),h=t.mul(h,_),d=t.cmov(d,o,m),h=t.cmov(h,_,m);let u=t.isOdd(n)===t.isOdd(h);return h=t.cmov(t.neg(h),h,u),d=t.div(d,a),{x:d,y:h}}}});var H0=Q(ku=>{"use strict";Object.defineProperty(ku,"__esModule",{value:!0});ku.bls=v1;var q0=Ur(),ju=zt(),C0=Ko(),j0=Cu(),E1=BigInt(0),Wo=BigInt(1),k0=BigInt(2),Ei=BigInt(3);function x1(t){let e=[];for(;t>Wo;t>>=Wo)(t&Wo)===E1?e.unshift(0):(t&Ei)===Ei?(e.unshift(-1),t+=Wo):e.unshift(1);return e}function v1(t){let{Fp:e,Fr:r,Fp2:n,Fp6:i,Fp12:s}=t.fields,o=t.params.xNegative,a=t.params.twistType,c=(0,j0.weierstrassPoints)({n:r.ORDER,...t.G1}),f=Object.assign(c,(0,C0.createHasher)(c.ProjectivePoint,t.G1.mapToCurve,{...t.htfDefaults,...t.G1.htfDefaults})),d=(0,j0.weierstrassPoints)({n:r.ORDER,...t.G2}),h=Object.assign(d,(0,C0.createHasher)(d.ProjectivePoint,t.G2.mapToCurve,{...t.htfDefaults,...t.G2.htfDefaults})),m;if(a==="multiplicative")m=(z,U,p,J,re,fe)=>s.mul014(J,z,n.mul(U,re),n.mul(p,fe));else if(a==="divisive")m=(z,U,p,J,re,fe)=>s.mul034(J,n.mul(p,fe),n.mul(U,re),z);else throw new Error("bls: unknown twist type");let _=n.div(n.ONE,n.mul(n.ONE,k0));function u(z,U,p,J){let re=n.sqr(p),fe=n.sqr(J),L=n.mulByB(n.mul(fe,Ei)),l=n.mul(L,Ei),y=n.sub(n.sub(n.sqr(n.add(p,J)),fe),re),g=n.sub(L,re),I=n.mul(n.sqr(U),Ei),A=n.neg(y);return z.push([g,I,A]),U=n.mul(n.mul(n.mul(n.sub(re,l),U),p),_),p=n.sub(n.sqr(n.mul(n.add(re,l),_)),n.mul(n.sqr(L),Ei)),J=n.mul(re,y),{Rx:U,Ry:p,Rz:J}}function T(z,U,p,J,re,fe){let L=n.sub(p,n.mul(fe,J)),l=n.sub(U,n.mul(re,J)),y=n.sub(n.mul(L,re),n.mul(l,fe)),g=n.neg(L),I=l;z.push([y,g,I]);let A=n.sqr(l),P=n.mul(A,l),k=n.mul(A,U),E=n.add(n.sub(P,n.mul(k,k0)),n.mul(n.sqr(L),J));return U=n.mul(l,E),p=n.sub(n.mul(n.sub(k,E),L),n.mul(P,p)),J=n.mul(J,P),{Rx:U,Ry:p,Rz:J}}let O=x1(t.params.ateLoopSize),R=(0,ju.memoized)(z=>{let U=z,{x:p,y:J}=U.toAffine(),re=p,fe=J,L=n.neg(J),l=re,y=fe,g=n.ONE,I=[];for(let A of O){let P=[];({Rx:l,Ry:y,Rz:g}=u(P,l,y,g)),A&&({Rx:l,Ry:y,Rz:g}=T(P,l,y,g,re,A===-1?L:fe)),I.push(P)}if(t.postPrecompute){let A=I[I.length-1];t.postPrecompute(l,y,g,re,fe,T.bind(null,A))}return I});function F(z,U=!1){let p=s.ONE;if(z.length){let J=z[0][0].length;for(let re=0;re<J;re++){p=s.sqr(p);for(let[fe,L,l]of z)for(let[y,g,I]of fe[re])p=m(y,g,I,p,L,l)}}return o&&(p=s.conjugate(p)),U?s.finalExponentiate(p):p}function M(z,U=!0){let p=[];f.ProjectivePoint.normalizeZ(z.map(({g1:J})=>J)),h.ProjectivePoint.normalizeZ(z.map(({g2:J})=>J));for(let{g1:J,g2:re}of z){if(J.equals(f.ProjectivePoint.ZERO)||re.equals(h.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");J.assertValidity(),re.assertValidity();let fe=J.toAffine();p.push([R(re),fe.x,fe.y])}return F(p,U)}function K(z,U,p=!0){return M([{g1:z,g2:U}],p)}let x={randomPrivateKey:()=>{let z=(0,q0.getMinHashLength)(r.ORDER);return(0,q0.mapHashToField)(t.randomBytes(z),r.ORDER)},calcPairingPrecomputes:R},{ShortSignature:$}=t.G1,{Signature:W}=t.G2;function D(z){return z instanceof f.ProjectivePoint?z:f.ProjectivePoint.fromHex(z)}function j(z,U){return z instanceof f.ProjectivePoint?z:f.hashToCurve((0,ju.ensureBytes)("point",z),U)}function ie(z){return z instanceof h.ProjectivePoint?z:W.fromHex(z)}function ee(z,U){return z instanceof h.ProjectivePoint?z:h.hashToCurve((0,ju.ensureBytes)("point",z),U)}function ne(z){return f.ProjectivePoint.fromPrivateKey(z).toRawBytes(!0)}function w(z){return h.ProjectivePoint.fromPrivateKey(z).toRawBytes(!0)}function b(z,U,p){let J=ee(z,p);J.assertValidity();let re=J.multiply(f.normPrivateKeyToScalar(U));return z instanceof h.ProjectivePoint?re:W.toRawBytes(re)}function B(z,U,p){let J=j(z,p);J.assertValidity();let re=J.multiply(f.normPrivateKeyToScalar(U));return z instanceof f.ProjectivePoint?re:$.toRawBytes(re)}function S(z,U,p,J){let re=D(p),fe=ee(U,J),L=f.ProjectivePoint.BASE,l=ie(z),y=M([{g1:re.negate(),g2:fe},{g1:L,g2:l}]);return s.eql(y,s.ONE)}function N(z,U,p,J){let re=ie(p),fe=j(U,J),L=h.ProjectivePoint.BASE,l=D(z),y=M([{g1:fe,g2:re},{g1:l,g2:L.negate()}]);return s.eql(y,s.ONE)}function H(z){if(!z.length)throw new Error("Expected non-empty array");let p=z.map(D).reduce((J,re)=>J.add(re),f.ProjectivePoint.ZERO);return z[0]instanceof f.ProjectivePoint?(p.assertValidity(),p):p.toRawBytes(!0)}function Z(z){if(!z.length)throw new Error("Expected non-empty array");let p=z.map(ie).reduce((J,re)=>J.add(re),h.ProjectivePoint.ZERO);return z[0]instanceof h.ProjectivePoint?(p.assertValidity(),p):W.toRawBytes(p)}function ae(z){if(!z.length)throw new Error("Expected non-empty array");let p=z.map(D).reduce((J,re)=>J.add(re),f.ProjectivePoint.ZERO);return z[0]instanceof f.ProjectivePoint?(p.assertValidity(),p):$.toRawBytes(p)}function oe(z,U,p,J){if(!U.length)throw new Error("Expected non-empty messages array");if(p.length!==U.length)throw new Error("Pubkey count should equal msg count");let re=ie(z),fe=U.map(g=>ee(g,J)),L=p.map(D),l=new Map;for(let g=0;g<L.length;g++){let I=L[g],A=fe[g],P=l.get(A);P===void 0&&(P=[],l.set(A,P)),P.push(I)}let y=[];try{for(let[g,I]of l){let A=I.reduce((P,k)=>P.add(k));y.push({g1:A,g2:g})}return y.push({g1:f.ProjectivePoint.BASE.negate(),g2:re}),s.eql(M(y),s.ONE)}catch{return!1}}return f.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:ne,getPublicKeyForShortSignatures:w,sign:b,signShortSignature:B,verify:S,verifyBatch:oe,verifyShortSignature:N,aggregatePublicKeys:H,aggregateSignatures:Z,aggregateShortSignatures:ae,millerLoopBatch:F,pairing:K,pairingBatch:M,G1:f,G2:h,Signature:W,ShortSignature:$,fields:{Fr:r,Fp:e,Fp2:n,Fp6:i,Fp12:s},params:{ateLoopSize:t.params.ateLoopSize,r:t.params.r,G1b:t.G1.b,G2b:t.G2.b},utils:x}}});var $0=Q(zo=>{"use strict";Object.defineProperty(zo,"__esModule",{value:!0});zo.psiFrobenius=A1;zo.tower12=S1;var yn=Ur(),hr=zt(),T1=BigInt(0),xi=BigInt(1),Xr=BigInt(2),V0=BigInt(3);function Hu(t,e,r,n,i=1,s){let o=BigInt(s===void 0?n:s),a=r**BigInt(n),c=[];for(let f=0;f<i;f++){let d=BigInt(f+1),h=[];for(let m=0,_=xi;m<n;m++){let u=(d*_-d)/o%a;h.push(t.pow(e,u)),_*=r}c.push(h)}return c}function A1(t,e,r){let n=e.pow(r,(t.ORDER-xi)/V0),i=e.pow(r,(t.ORDER-xi)/Xr);function s(m,_){let u=e.mul(e.frobeniusMap(m,1),n),T=e.mul(e.frobeniusMap(_,1),i);return[u,T]}let o=e.pow(r,(t.ORDER**Xr-xi)/V0),a=e.pow(r,(t.ORDER**Xr-xi)/Xr);if(!e.eql(a,e.neg(e.ONE)))throw new Error("psiFrobenius: PSI2_Y!==-1");function c(m,_){return[e.mul(m,o),e.neg(_)]}let f=m=>(_,u)=>{let T=u.toAffine(),O=m(T.x,T.y);return _.fromAffine({x:O[0],y:O[1]})},d=f(s),h=f(c);return{psi:s,psi2:c,G2psi:d,G2psi2:h,PSI_X:n,PSI_Y:i,PSI2_X:o,PSI2_Y:a}}function S1(t){let{ORDER:e}=t,r=yn.Field(e),n=r.create(t.NONRESIDUE||BigInt(-1)),i=yn.FpLegendre(e),s=r.div(r.ONE,Xr),o=Hu(r,n,r.ORDER,2)[0],a=({c0:w,c1:b},{c0:B,c1:S})=>({c0:r.add(w,B),c1:r.add(b,S)}),c=({c0:w,c1:b},{c0:B,c1:S})=>({c0:r.sub(w,B),c1:r.sub(b,S)}),f=({c0:w,c1:b},B)=>{if(typeof B=="bigint")return{c0:r.mul(w,B),c1:r.mul(b,B)};let{c0:S,c1:N}=B,H=r.mul(w,S),Z=r.mul(b,N),ae=r.sub(H,Z),oe=r.sub(r.mul(r.add(w,b),r.add(S,N)),r.add(H,Z));return{c0:ae,c1:oe}},d=({c0:w,c1:b})=>{let B=r.add(w,b),S=r.sub(w,b),N=r.add(w,w);return{c0:r.mul(B,S),c1:r.mul(N,b)}},h=w=>{if(w.length!==2)throw new Error("Invalid tuple");let b=w.map(B=>r.create(B));return{c0:b[0],c1:b[1]}},m=e*e,_=h(t.FP2_NONRESIDUE),u={ORDER:m,NONRESIDUE:_,BITS:(0,hr.bitLen)(m),BYTES:Math.ceil((0,hr.bitLen)(m)/8),MASK:(0,hr.bitMask)((0,hr.bitLen)(m)),ZERO:{c0:r.ZERO,c1:r.ZERO},ONE:{c0:r.ONE,c1:r.ZERO},create:w=>w,isValid:({c0:w,c1:b})=>typeof w=="bigint"&&typeof b=="bigint",is0:({c0:w,c1:b})=>r.is0(w)&&r.is0(b),eql:({c0:w,c1:b},{c0:B,c1:S})=>r.eql(w,B)&&r.eql(b,S),neg:({c0:w,c1:b})=>({c0:r.neg(w),c1:r.neg(b)}),pow:(w,b)=>yn.FpPow(u,w,b),invertBatch:w=>yn.FpInvertBatch(u,w),add:a,sub:c,mul:f,sqr:d,addN:a,subN:c,mulN:f,sqrN:d,div:(w,b)=>u.mul(w,typeof b=="bigint"?r.inv(r.create(b)):u.inv(b)),inv:({c0:w,c1:b})=>{let B=r.inv(r.create(w*w+b*b));return{c0:r.mul(B,r.create(w)),c1:r.mul(B,r.create(-b))}},sqrt:w=>{if(t.Fp2sqrt)return t.Fp2sqrt(w);let{c0:b,c1:B}=w;if(r.is0(B))return r.eql(i(r,b),r.ONE)?u.create({c0:r.sqrt(b),c1:r.ZERO}):u.create({c0:r.ZERO,c1:r.sqrt(r.div(b,n))});let S=r.sqrt(r.sub(r.sqr(b),r.mul(r.sqr(B),n))),N=r.mul(r.add(S,b),s),H=i(r,N);!r.is0(H)&&!r.eql(H,r.ONE)&&(N=r.sub(N,S));let Z=r.sqrt(N),ae=u.create({c0:Z,c1:r.div(r.mul(B,s),Z)});if(!u.eql(u.sqr(ae),w))throw new Error("Cannot find square root");let oe=ae,z=u.neg(oe),{re:U,im:p}=u.reim(oe),{re:J,im:re}=u.reim(z);return p>re||p===re&&U>J?oe:z},isOdd:w=>{let{re:b,im:B}=u.reim(w),S=b%Xr,N=b===T1,H=B%Xr;return BigInt(S||N&&H)==xi},fromBytes(w){if(w.length!==u.BYTES)throw new Error(`fromBytes wrong length=${w.length}`);return{c0:r.fromBytes(w.subarray(0,r.BYTES)),c1:r.fromBytes(w.subarray(r.BYTES))}},toBytes:({c0:w,c1:b})=>(0,hr.concatBytes)(r.toBytes(w),r.toBytes(b)),cmov:({c0:w,c1:b},{c0:B,c1:S},N)=>({c0:r.cmov(w,B,N),c1:r.cmov(b,S,N)}),reim:({c0:w,c1:b})=>({re:w,im:b}),mulByNonresidue:({c0:w,c1:b})=>u.mul({c0:w,c1:b},_),mulByB:t.Fp2mulByB,fromBigTuple:h,frobeniusMap:({c0:w,c1:b},B)=>({c0:w,c1:r.mul(b,o[B%2])})},T=({c0:w,c1:b,c2:B},{c0:S,c1:N,c2:H})=>({c0:u.add(w,S),c1:u.add(b,N),c2:u.add(B,H)}),O=({c0:w,c1:b,c2:B},{c0:S,c1:N,c2:H})=>({c0:u.sub(w,S),c1:u.sub(b,N),c2:u.sub(B,H)}),R=({c0:w,c1:b,c2:B},S)=>{if(typeof S=="bigint")return{c0:u.mul(w,S),c1:u.mul(b,S),c2:u.mul(B,S)};let{c0:N,c1:H,c2:Z}=S,ae=u.mul(w,N),oe=u.mul(b,H),z=u.mul(B,Z);return{c0:u.add(ae,u.mulByNonresidue(u.sub(u.mul(u.add(b,B),u.add(H,Z)),u.add(oe,z)))),c1:u.add(u.sub(u.mul(u.add(w,b),u.add(N,H)),u.add(ae,oe)),u.mulByNonresidue(z)),c2:u.sub(u.add(oe,u.mul(u.add(w,B),u.add(N,Z))),u.add(ae,z))}},F=({c0:w,c1:b,c2:B})=>{let S=u.sqr(w),N=u.mul(u.mul(w,b),Xr),H=u.mul(u.mul(b,B),Xr),Z=u.sqr(B);return{c0:u.add(u.mulByNonresidue(H),S),c1:u.add(u.mulByNonresidue(Z),N),c2:u.sub(u.sub(u.add(u.add(N,u.sqr(u.add(u.sub(w,b),B))),H),S),Z)}},[M,K]=Hu(u,_,r.ORDER,6,2,3),x={ORDER:u.ORDER,BITS:3*u.BITS,BYTES:3*u.BYTES,MASK:(0,hr.bitMask)(3*u.BITS),ZERO:{c0:u.ZERO,c1:u.ZERO,c2:u.ZERO},ONE:{c0:u.ONE,c1:u.ZERO,c2:u.ZERO},create:w=>w,isValid:({c0:w,c1:b,c2:B})=>u.isValid(w)&&u.isValid(b)&&u.isValid(B),is0:({c0:w,c1:b,c2:B})=>u.is0(w)&&u.is0(b)&&u.is0(B),neg:({c0:w,c1:b,c2:B})=>({c0:u.neg(w),c1:u.neg(b),c2:u.neg(B)}),eql:({c0:w,c1:b,c2:B},{c0:S,c1:N,c2:H})=>u.eql(w,S)&&u.eql(b,N)&&u.eql(B,H),sqrt:hr.notImplemented,div:(w,b)=>x.mul(w,typeof b=="bigint"?r.inv(r.create(b)):x.inv(b)),pow:(w,b)=>yn.FpPow(x,w,b),invertBatch:w=>yn.FpInvertBatch(x,w),add:T,sub:O,mul:R,sqr:F,addN:T,subN:O,mulN:R,sqrN:F,inv:({c0:w,c1:b,c2:B})=>{let S=u.sub(u.sqr(w),u.mulByNonresidue(u.mul(B,b))),N=u.sub(u.mulByNonresidue(u.sqr(B)),u.mul(w,b)),H=u.sub(u.sqr(b),u.mul(w,B)),Z=u.inv(u.add(u.mulByNonresidue(u.add(u.mul(B,N),u.mul(b,H))),u.mul(w,S)));return{c0:u.mul(Z,S),c1:u.mul(Z,N),c2:u.mul(Z,H)}},fromBytes:w=>{if(w.length!==x.BYTES)throw new Error(`fromBytes wrong length=${w.length}`);return{c0:u.fromBytes(w.subarray(0,u.BYTES)),c1:u.fromBytes(w.subarray(u.BYTES,2*u.BYTES)),c2:u.fromBytes(w.subarray(2*u.BYTES))}},toBytes:({c0:w,c1:b,c2:B})=>(0,hr.concatBytes)(u.toBytes(w),u.toBytes(b),u.toBytes(B)),cmov:({c0:w,c1:b,c2:B},{c0:S,c1:N,c2:H},Z)=>({c0:u.cmov(w,S,Z),c1:u.cmov(b,N,Z),c2:u.cmov(B,H,Z)}),fromBigSix:w=>{if(!Array.isArray(w)||w.length!==6)throw new Error("Invalid Fp6 usage");return{c0:u.fromBigTuple(w.slice(0,2)),c1:u.fromBigTuple(w.slice(2,4)),c2:u.fromBigTuple(w.slice(4,6))}},frobeniusMap:({c0:w,c1:b,c2:B},S)=>({c0:u.frobeniusMap(w,S),c1:u.mul(u.frobeniusMap(b,S),M[S%6]),c2:u.mul(u.frobeniusMap(B,S),K[S%6])}),mulByFp2:({c0:w,c1:b,c2:B},S)=>({c0:u.mul(w,S),c1:u.mul(b,S),c2:u.mul(B,S)}),mulByNonresidue:({c0:w,c1:b,c2:B})=>({c0:u.mulByNonresidue(B),c1:w,c2:b}),mul1:({c0:w,c1:b,c2:B},S)=>({c0:u.mulByNonresidue(u.mul(B,S)),c1:u.mul(w,S),c2:u.mul(b,S)}),mul01({c0:w,c1:b,c2:B},S,N){let H=u.mul(w,S),Z=u.mul(b,N);return{c0:u.add(u.mulByNonresidue(u.sub(u.mul(u.add(b,B),N),Z)),H),c1:u.sub(u.sub(u.mul(u.add(S,N),u.add(w,b)),H),Z),c2:u.add(u.sub(u.mul(u.add(w,B),S),H),Z)}}},$=Hu(u,_,r.ORDER,12,1,6)[0],W=({c0:w,c1:b},{c0:B,c1:S})=>({c0:x.add(w,B),c1:x.add(b,S)}),D=({c0:w,c1:b},{c0:B,c1:S})=>({c0:x.sub(w,B),c1:x.sub(b,S)}),j=({c0:w,c1:b},B)=>{if(typeof B=="bigint")return{c0:x.mul(w,B),c1:x.mul(b,B)};let{c0:S,c1:N}=B,H=x.mul(w,S),Z=x.mul(b,N);return{c0:x.add(H,x.mulByNonresidue(Z)),c1:x.sub(x.mul(x.add(w,b),x.add(S,N)),x.add(H,Z))}},ie=({c0:w,c1:b})=>{let B=x.mul(w,b);return{c0:x.sub(x.sub(x.mul(x.add(x.mulByNonresidue(b),w),x.add(w,b)),B),x.mulByNonresidue(B)),c1:x.add(B,B)}};function ee(w,b){let B=u.sqr(w),S=u.sqr(b);return{first:u.add(u.mulByNonresidue(S),B),second:u.sub(u.sub(u.sqr(u.add(w,b)),B),S)}}let ne={ORDER:u.ORDER,BITS:2*u.BITS,BYTES:2*u.BYTES,MASK:(0,hr.bitMask)(2*u.BITS),ZERO:{c0:x.ZERO,c1:x.ZERO},ONE:{c0:x.ONE,c1:x.ZERO},create:w=>w,isValid:({c0:w,c1:b})=>x.isValid(w)&&x.isValid(b),is0:({c0:w,c1:b})=>x.is0(w)&&x.is0(b),neg:({c0:w,c1:b})=>({c0:x.neg(w),c1:x.neg(b)}),eql:({c0:w,c1:b},{c0:B,c1:S})=>x.eql(w,B)&&x.eql(b,S),sqrt:hr.notImplemented,inv:({c0:w,c1:b})=>{let B=x.inv(x.sub(x.sqr(w),x.mulByNonresidue(x.sqr(b))));return{c0:x.mul(w,B),c1:x.neg(x.mul(b,B))}},div:(w,b)=>ne.mul(w,typeof b=="bigint"?r.inv(r.create(b)):ne.inv(b)),pow:(w,b)=>yn.FpPow(ne,w,b),invertBatch:w=>yn.FpInvertBatch(ne,w),add:W,sub:D,mul:j,sqr:ie,addN:W,subN:D,mulN:j,sqrN:ie,fromBytes:w=>{if(w.length!==ne.BYTES)throw new Error(`fromBytes wrong length=${w.length}`);return{c0:x.fromBytes(w.subarray(0,x.BYTES)),c1:x.fromBytes(w.subarray(x.BYTES))}},toBytes:({c0:w,c1:b})=>(0,hr.concatBytes)(x.toBytes(w),x.toBytes(b)),cmov:({c0:w,c1:b},{c0:B,c1:S},N)=>({c0:x.cmov(w,B,N),c1:x.cmov(b,S,N)}),fromBigTwelve:w=>({c0:x.fromBigSix(w.slice(0,6)),c1:x.fromBigSix(w.slice(6,12))}),frobeniusMap(w,b){let{c0:B,c1:S,c2:N}=x.frobeniusMap(w.c1,b),H=$[b%12];return{c0:x.frobeniusMap(w.c0,b),c1:x.create({c0:u.mul(B,H),c1:u.mul(S,H),c2:u.mul(N,H)})}},mulByFp2:({c0:w,c1:b},B)=>({c0:x.mulByFp2(w,B),c1:x.mulByFp2(b,B)}),conjugate:({c0:w,c1:b})=>({c0:w,c1:x.neg(b)}),mul014:({c0:w,c1:b},B,S,N)=>{let H=x.mul01(w,B,S),Z=x.mul1(b,N);return{c0:x.add(x.mulByNonresidue(Z),H),c1:x.sub(x.sub(x.mul01(x.add(b,w),B,u.add(S,N)),H),Z)}},mul034:({c0:w,c1:b},B,S,N)=>{let H=x.create({c0:u.mul(w.c0,B),c1:u.mul(w.c1,B),c2:u.mul(w.c2,B)}),Z=x.mul01(b,S,N),ae=x.mul01(x.add(w,b),u.add(B,S),N);return{c0:x.add(x.mulByNonresidue(Z),H),c1:x.sub(ae,x.add(H,Z))}},_cyclotomicSquare:t.Fp12cyclotomicSquare,_cyclotomicExp:t.Fp12cyclotomicExp,finalExponentiate:t.Fp12finalExponentiate};return{Fp:r,Fp2:u,Fp6:x,Fp4Square:ee,Fp12:ne}}});var J0=Q(Ut=>{"use strict";Object.defineProperty(Ut,"__esModule",{value:!0});Ut.bls12_381=void 0;var z0=Ys(),B1=Fn(),O1=H0(),N1=Ur(),Se=zt(),D0=Ko(),Z0=Cu(),X0=$0(),It=BigInt(0),Xo=BigInt(1),ht=BigInt(2),Do=BigInt(3),us=BigInt(4),gn=BigInt("0xd201000000010000"),R1=(0,Se.bitLen)(gn),{Fp:le,Fp2:pe,Fp6:Ku,Fp4Square:Vu,Fp12:ve}=(0,X0.tower12)({ORDER:BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),FP2_NONRESIDUE:[Xo,Xo],Fp2mulByB:({c0:t,c1:e})=>{let r=le.mul(t,us),n=le.mul(e,us);return{c0:le.sub(r,n),c1:le.add(r,n)}},Fp12cyclotomicSquare:({c0:t,c1:e})=>{let{c0:r,c1:n,c2:i}=t,{c0:s,c1:o,c2:a}=e,{first:c,second:f}=Vu(r,o),{first:d,second:h}=Vu(s,i),{first:m,second:_}=Vu(n,a),u=pe.mulByNonresidue(_);return{c0:Ku.create({c0:pe.add(pe.mul(pe.sub(c,r),ht),c),c1:pe.add(pe.mul(pe.sub(d,n),ht),d),c2:pe.add(pe.mul(pe.sub(m,i),ht),m)}),c1:Ku.create({c0:pe.add(pe.mul(pe.add(u,s),ht),u),c1:pe.add(pe.mul(pe.add(f,o),ht),f),c2:pe.add(pe.mul(pe.add(h,a),ht),h)})}},Fp12cyclotomicExp(t,e){let r=ve.ONE;for(let n=R1-1;n>=0;n--)r=ve._cyclotomicSquare(r),(0,Se.bitGet)(e,n)&&(r=ve.mul(r,t));return r},Fp12finalExponentiate:t=>{let e=gn,r=ve.div(ve.frobeniusMap(t,6),t),n=ve.mul(ve.frobeniusMap(r,2),r),i=ve.conjugate(ve._cyclotomicExp(n,e)),s=ve.mul(ve.conjugate(ve._cyclotomicSquare(n)),i),o=ve.conjugate(ve._cyclotomicExp(s,e)),a=ve.conjugate(ve._cyclotomicExp(o,e)),c=ve.mul(ve.conjugate(ve._cyclotomicExp(a,e)),ve._cyclotomicSquare(i)),f=ve.conjugate(ve._cyclotomicExp(c,e)),d=ve.frobeniusMap(ve.mul(i,a),2),h=ve.frobeniusMap(ve.mul(o,n),3),m=ve.frobeniusMap(ve.mul(c,ve.conjugate(n)),1),_=ve.mul(ve.mul(f,ve.conjugate(s)),n);return ve.mul(ve.mul(ve.mul(d,h),m),_)}}),K0=N1.Field(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),P1=(0,D0.isogenyMap)(pe,[[["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=>pe.fromBigTuple(e.map(BigInt))))),I1=(0,D0.isogenyMap)(le,[["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)))),U1=(0,Z0.mapToCurveSimpleSWU)(pe,{A:pe.create({c0:le.create(It),c1:le.create(BigInt(240))}),B:pe.create({c0:le.create(BigInt(1012)),c1:le.create(BigInt(1012))}),Z:pe.create({c0:le.create(BigInt(-2)),c1:le.create(BigInt(-1))})}),F1=(0,Z0.mapToCurveSimpleSWU)(le,{A:le.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:le.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:le.create(BigInt(11))}),{G2psi:G0,G2psi2:M1}=(0,X0.psiFrobenius)(le,pe,pe.div(pe.ONE,pe.NONRESIDUE)),$u=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:le.ORDER,m:2,k:128,expand:"xmd",hash:z0.sha256}),Jo=ls(le.toBytes(It),{infinity:!0,compressed:!0});function Zo(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 ls(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 Y0(t){t.assertValidity();let e=t.equals(Ut.bls12_381.G1.ProjectivePoint.ZERO),{x:r,y:n}=t.toAffine();if(e)return Jo.slice();let i=le.ORDER,s=!!(n*ht/i);return ls((0,Se.numberToBytesBE)(r,le.BYTES),{compressed:!0,sort:s})}function W0(t){t.assertValidity();let e=le.BYTES;if(t.equals(Ut.bls12_381.G2.ProjectivePoint.ZERO))return(0,Se.concatBytes)(Jo,(0,Se.numberToBytesBE)(It,e));let{x:r,y:n}=t.toAffine(),{re:i,im:s}=pe.reim(r),{re:o,im:a}=pe.reim(n),f=!!((a>It?a*ht:o*ht)/le.ORDER&Xo),d=i;return(0,Se.concatBytes)(ls((0,Se.numberToBytesBE)(s,e),{sort:f,compressed:!0}),(0,Se.numberToBytesBE)(d,e))}Ut.bls12_381=(0,O1.bls)({fields:{Fp:le,Fp2:pe,Fp6:Ku,Fp12:ve,Fr:K0},G1:{Fp:le,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:le.ZERO,b:us,htfDefaults:{...$u,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(le.mul(e.px,r),e.py,e.pz);return e.multiplyUnsafe(gn).negate().multiplyUnsafe(gn).equals(n)},clearCofactor:(t,e)=>e.multiplyUnsafe(gn).add(e),mapToCurve:t=>{let{x:e,y:r}=F1(le.create(t[0]));return I1(e,r)},fromBytes:t=>{let{compressed:e,infinity:r,sort:n,value:i}=Zo(t);if(i.length===48&&e){let s=le.ORDER,o=(0,Se.bytesToNumberBE)(i),a=le.create(o&le.MASK);if(r){if(a!==It)throw new Error("G1: non-empty compressed point at infinity");return{x:It,y:It}}let c=le.add(le.pow(a,Do),le.create(Ut.bls12_381.params.G1b)),f=le.sqrt(c);if(!f)throw new Error("Invalid compressed G1 point");return f*ht/s!==BigInt(n)&&(f=le.neg(f)),{x:le.create(a),y:le.create(f)}}else if(i.length===96&&!e){let s=(0,Se.bytesToNumberBE)(i.subarray(0,le.BYTES)),o=(0,Se.bytesToNumberBE)(i.subarray(le.BYTES));if(r){if(s!==It||o!==It)throw new Error("G1: non-empty point at infinity");return Ut.bls12_381.G1.ProjectivePoint.ZERO.toAffine()}return{x:le.create(s),y:le.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 Jo.slice();let o=le.ORDER,a=!!(s*ht/o);return ls((0,Se.numberToBytesBE)(i,le.BYTES),{compressed:!0,sort:a})}else return n?(0,Se.concatBytes)(new Uint8Array([64]),new Uint8Array(2*le.BYTES-1)):(0,Se.concatBytes)((0,Se.numberToBytesBE)(i,le.BYTES),(0,Se.numberToBytesBE)(s,le.BYTES))},ShortSignature:{fromHex(t){let{infinity:e,sort:r,value:n}=Zo((0,Se.ensureBytes)("signatureHex",t,48)),i=le.ORDER,s=(0,Se.bytesToNumberBE)(n);if(e)return Ut.bls12_381.G1.ProjectivePoint.ZERO;let o=le.create(s&le.MASK),a=le.add(le.pow(o,Do),le.create(Ut.bls12_381.params.G1b)),c=le.sqrt(a);if(!c)throw new Error("Invalid compressed G1 point");let f=BigInt(r);c*ht/i!==f&&(c=le.neg(c));let d=Ut.bls12_381.G1.ProjectivePoint.fromAffine({x:o,y:c});return d.assertValidity(),d},toRawBytes(t){return Y0(t)},toHex(t){return(0,Se.bytesToHex)(Y0(t))}}},G2:{Fp:pe,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),Gx:pe.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:pe.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")]),a:pe.ZERO,b:pe.fromBigTuple([us,us]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...$u},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:t=>{let{x:e,y:r}=U1(pe.fromBigTuple(t));return P1(e,r)},isTorsionFree:(t,e)=>e.multiplyUnsafe(gn).negate().equals(G0(t,e)),clearCofactor:(t,e)=>{let r=gn,n=e.multiplyUnsafe(r).negate(),i=G0(t,e),s=e.double();return s=M1(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}=Zo(t);if(!e&&!r&&n||!e&&r&&n||n&&r&&e)throw new Error("Invalid encoding flag: "+(t[0]&224));let s=le.BYTES,o=(a,c,f)=>(0,Se.bytesToNumberBE)(a.slice(c,f));if(i.length===96&&e){let a=Ut.bls12_381.params.G2b,c=le.ORDER;if(r){if(i.reduce((T,O)=>T!==0?O+1:O,0)>0)throw new Error("Invalid compressed G2 point");return{x:pe.ZERO,y:pe.ZERO}}let f=o(i,0,s),d=o(i,s,2*s),h=pe.create({c0:le.create(d),c1:le.create(f)}),m=pe.add(pe.pow(h,Do),a),_=pe.sqrt(m),u=_.c1===It?_.c0*ht/c:_.c1*ht/c?Xo:It;return _=n&&u>0?_:pe.neg(_),{x:h,y:_}}else if(i.length===192&&!e){if(r){if(i.reduce((h,m)=>h!==0?m+1:m,0)>0)throw new Error("Invalid uncompressed G2 point");return{x:pe.ZERO,y:pe.ZERO}}let a=o(i,0,s),c=o(i,s,2*s),f=o(i,2*s,3*s),d=o(i,3*s,4*s);return{x:pe.fromBigTuple([c,a]),y:pe.fromBigTuple([d,f])}}else throw new Error("Invalid point G2, expected 96/192 bytes")},toBytes:(t,e,r)=>{let{BYTES:n,ORDER:i}=le,s=e.equals(t.ZERO),{x:o,y:a}=e.toAffine();if(r){if(s)return(0,Se.concatBytes)(Jo,(0,Se.numberToBytesBE)(It,n));let c=!!(a.c1===It?a.c0*ht/i:a.c1*ht/i);return(0,Se.concatBytes)(ls((0,Se.numberToBytesBE)(o.c1,n),{compressed:!0,sort:c}),(0,Se.numberToBytesBE)(o.c0,n))}else{if(s)return(0,Se.concatBytes)(new Uint8Array([64]),new Uint8Array(4*n-1));let{re:c,im:f}=pe.reim(o),{re:d,im:h}=pe.reim(a);return(0,Se.concatBytes)((0,Se.numberToBytesBE)(f,n),(0,Se.numberToBytesBE)(c,n),(0,Se.numberToBytesBE)(h,n),(0,Se.numberToBytesBE)(d,n))}},Signature:{fromHex(t){let{infinity:e,sort:r,value:n}=Zo((0,Se.ensureBytes)("signatureHex",t)),i=le.ORDER,s=n.length/2;if(s!==48&&s!==96)throw new Error("Invalid compressed signature length, must be 96 or 192");let o=(0,Se.bytesToNumberBE)(n.slice(0,s)),a=(0,Se.bytesToNumberBE)(n.slice(s));if(e)return Ut.bls12_381.G2.ProjectivePoint.ZERO;let c=le.create(o&le.MASK),f=le.create(a),d=pe.create({c0:f,c1:c}),h=pe.add(pe.pow(d,Do),Ut.bls12_381.params.G2b),m=pe.sqrt(h);if(!m)throw new Error("Failed to find a square root");let{re:_,im:u}=pe.reim(m),T=BigInt(r),O=u>It&&u*ht/i!==T,R=u===It&&_*ht/i!==T;(O||R)&&(m=pe.neg(m));let F=Ut.bls12_381.G2.ProjectivePoint.fromAffine({x:d,y:m});return F.assertValidity(),F},toRawBytes(t){return W0(t)},toHex(t){return(0,Se.bytesToHex)(W0(t))}}},params:{ateLoopSize:gn,r:K0.ORDER,xNegative:!0,twistType:"multiplicative"},htfDefaults:$u,hash:z0.sha256,randomBytes:B1.randomBytes})});var Yu=Q(fs=>{"use strict";Object.defineProperty(fs,"__esModule",{value:!0});fs.blsVerify=fs.verify=void 0;var q1=J0(),Gu=Ht();function C1(t,e,r){let n=typeof t=="string"?t:(0,Gu.toHex)(t),i=typeof e=="string"?e:(0,Gu.toHex)(e),s=typeof r=="string"?r:(0,Gu.toHex)(r);return q1.bls12_381.verifyShortSignature(i,s,n)}fs.blsVerify=C1});var Lo=Q($n=>{"use strict";Object.defineProperty($n,"__esModule",{value:!0});$n.decodeTime=$n.decodeLeb128=void 0;var L0=mi(),j1=t=>(0,L0.lebDecode)(new L0.PipeArrayBuffer(t));$n.decodeLeb128=j1;var k1=t=>{let e=(0,$n.decodeLeb128)(t);return new Date(Number(e)/1e6)};$n.decodeTime=k1});var vi=Q(Oe=>{"use strict";var H1=Oe&&Oe.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),V1=Oe&&Oe.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Q0=Oe&&Oe.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&H1(e,t,r);return V1(e,t),e};Object.defineProperty(Oe,"__esModule",{value:!0});Oe.check_canister_ranges=Oe.find_label=Oe.flatten_forks=Oe.lookup_path=Oe.LookupStatus=Oe.reconstruct=Oe.lookupResultToBuffer=Oe.Certificate=Oe.hashTreeToString=Oe.NodeType=Oe.CertificateVerificationError=void 0;var eh=Q0(ss()),$1=li(),Qo=rs(),pr=Ht(),Wu=Tt(),K1=Q0(Yu()),G1=Lo(),Y1=gs(),Jr=class extends $1.AgentError{constructor(e){super(`Invalid certificate: ${e}`)}};Oe.CertificateVerificationError=Jr;var Et;(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"})(Et=Oe.NodeType||(Oe.NodeType={}));function ea(t){let e=n=>n.split(`
17
18
  `).map(i=>" "+i).join(`
18
- `);function r(n){let i=new TextDecoder(void 0,{fatal:!0});try{return JSON.stringify(i.decode(n))}catch{return`data(...${n.byteLength} bytes)`}}switch(t[0]){case wt.Empty:return"()";case wt.Fork:if(t[1]instanceof Array&&t[2]instanceof ArrayBuffer){let n=$o(t[1]),i=$o(t[2]);return`sub(
19
+ `);function r(n){let i=new TextDecoder(void 0,{fatal:!0});try{return JSON.stringify(i.decode(n))}catch{return`data(...${n.byteLength} bytes)`}}switch(t[0]){case Et.Empty:return"()";case Et.Fork:if(t[1]instanceof Array&&t[2]instanceof ArrayBuffer){let n=ea(t[1]),i=ea(t[2]);return`sub(
19
20
  left:
20
21
  ${e(n)}
21
22
  ---
22
23
  right:
23
24
  ${e(i)}
24
- )`}else throw new Error("Invalid tree structure for fork");case wt.Labeled:if(t[1]instanceof ArrayBuffer&&t[2]instanceof ArrayBuffer){let n=r(t[1]),i=$o(t[2]);return`label(
25
+ )`}else throw new Error("Invalid tree structure for fork");case Et.Labeled:if(t[1]instanceof ArrayBuffer&&t[2]instanceof ArrayBuffer){let n=r(t[1]),i=ea(t[2]);return`label(
25
26
  label:
26
27
  ${e(n)}
27
28
  sub:
28
29
  ${e(i)}
29
- )`}else throw new Error("Invalid tree structure for labeled");case wt.Leaf:{if(t[1]){if(Array.isArray(t[1]))return JSON.stringify(t[1])}else throw new Error("Invalid tree structure for leaf");return`leaf(...${t[1].byteLength} bytes)`}case wt.Pruned:{if(t[1]){if(Array.isArray(t[1]))return JSON.stringify(t[1])}else throw new Error("Invalid tree structure for pruned");return`pruned(${(0,hr.toHex)(new Uint8Array(t[1]))}`}default:return`unknown(${JSON.stringify(t[0])})`}}Be.hashTreeToString=$o;function U1(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}var Uu=class t{constructor(e,r,n,i,s=5){this._rootKey=r,this._canisterId=n,this._blsVerify=i,this._maxAgeInMinutes=s,this.cert=$0.decode(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=R1.blsVerify),new t(e.certificate,e.rootKey,e.canisterId,r,e.maxAgeInMinutes)}lookup(e){return Ko(e,this.cert.tree)}lookup_label(e){return this.lookup([e])}async verify(){let e=await is(this.cert.tree),r=await this._checkDelegationAndGetKey(this.cert.delegation),n=this.cert.signature,i=M1(r),s=(0,hr.concat)(ns("ic-state-root"),e),o=!1,a=Fu(this.lookup(["time"]));if(!a)throw new Dr("Certificate does not contain a time");let c=5*60*1e3,f=this._maxAgeInMinutes*60*1e3,d=Date.now(),h=d-f,S=d+c,w=(0,I1.decodeTime)(a);if(w.getTime()<h)throw new Dr(`Certificate is signed more than ${this._maxAgeInMinutes} minutes in the past. Certificate time: `+w.toISOString()+" Current time: "+new Date(d).toISOString());if(w.getTime()>S)throw new Dr("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 Dr("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 Dr("Delegation certificates cannot be nested");if(await r.verify(),!K0({canisterId:this._canisterId,subnetId:Iu.Principal.fromUint8Array(new Uint8Array(e.subnet_id)),tree:r.cert.tree}))throw new Dr(`Canister ${this._canisterId} not in range of delegations for subnet 0x${(0,hr.toHex)(e.subnet_id)}`);let i=Fu(r.lookup(["subnet",e.subnet_id,"public_key"]));if(!i)throw new Error(`Could not find subnet key for subnet 0x${(0,hr.toHex)(e.subnet_id)}`);return i}};Be.Certificate=Uu;var rs=(0,hr.fromHex)("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"),F1=96;function M1(t){let e=rs.byteLength+F1;if(t.byteLength!==e)throw new TypeError(`BLS DER-encoded public key must be ${e} bytes long`);let r=t.slice(0,rs.byteLength);if(!(0,hr.bufEquals)(r,rs))throw new TypeError(`BLS DER-encoded public key is invalid. Expect the following prefix: ${rs}, but get ${r}`);return t.slice(rs.byteLength)}function Fu(t){if(t.status===Ft.Found){if(t.value instanceof ArrayBuffer)return t.value;if(t.value instanceof Uint8Array)return t.value.buffer}}Be.lookupResultToBuffer=Fu;async function is(t){switch(t[0]){case wt.Empty:return(0,Ho.hash)(ns("ic-hashtree-empty"));case wt.Pruned:return t[1];case wt.Leaf:return(0,Ho.hash)((0,hr.concat)(ns("ic-hashtree-leaf"),t[1]));case wt.Labeled:return(0,Ho.hash)((0,hr.concat)(ns("ic-hashtree-labeled"),t[1],await is(t[2])));case wt.Fork:return(0,Ho.hash)((0,hr.concat)(ns("ic-hashtree-fork"),await is(t[1]),await is(t[2])));default:throw new Error("unreachable")}}Be.reconstruct=is;function ns(t){let e=new Uint8Array([t.length]),r=new TextEncoder().encode(t);return(0,hr.concat)(e,r)}var Ft;(function(t){t.Unknown="unknown",t.Absent="absent",t.Found="found"})(Ft=Be.LookupStatus||(Be.LookupStatus={}));var Zr;(function(t){t.Less="less",t.Greater="greater"})(Zr||(Zr={}));function Ko(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:Ft.Found,value:e[1]}:e[1]instanceof Uint8Array?{status:Ft.Found,value:e[1].buffer}:{status:Ft.Found,value:e[1]}}default:return{status:Ft.Found,value:e}}let r=typeof t[0]=="string"?new TextEncoder().encode(t[0]):t[0],n=ss(r,e);switch(n.status){case Ft.Found:return Ko(t.slice(1),n.value);case Zr.Greater:case Zr.Less:return{status:Ft.Absent};default:return n}}Be.lookup_path=Ko;function Mu(t){switch(t[0]){case wt.Empty:return[];case wt.Fork:return Mu(t[1]).concat(Mu(t[2]));default:return[t]}}Be.flatten_forks=Mu;function ss(t,e){switch(e[0]){case wt.Labeled:return U1(t,e[1])?{status:Zr.Greater}:(0,hr.bufEquals)(t,e[1])?{status:Ft.Found,value:e[2]}:{status:Zr.Less};case wt.Fork:let r=ss(t,e[1]);switch(r.status){case Zr.Greater:{let n=ss(t,e[2]);return n.status===Zr.Less?{status:Ft.Absent}:n}case Ft.Unknown:{let n=ss(t,e[2]);return n.status===Zr.Less?{status:Ft.Unknown}:n}default:return r}case wt.Pruned:return{status:Ft.Unknown};default:return{status:Ft.Absent}}}Be.find_label=ss;function K0(t){let{canisterId:e,subnetId:r,tree:n}=t,i=Ko(["subnet",r.toUint8Array(),"canister_ranges"],n);if(i.status!==Ft.Found||!(i.value instanceof ArrayBuffer))throw new Error(`Could not find canister ranges for subnet ${r}`);return $0.decode(i.value).map(c=>[Iu.Principal.fromUint8Array(c[0]),Iu.Principal.fromUint8Array(c[1])]).some(c=>c[0].ltEq(e)&&c[1].gtEq(e))}Be.check_canister_ranges=K0});var as=L(ct=>{"use strict";var C1=ct&&ct.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),q1=ct&&ct.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),j1=ct&&ct.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&C1(e,t,r);return q1(e,t),e};Object.defineProperty(ct,"__esModule",{value:!0});ct.encodePath=ct.fetchNodeKeys=ct.request=ct.CustomPath=void 0;var dn=Nt(),k1=ii(),hn=os(),V1=Yt(),W0=j1(Ji()),G0=Vo(),Cu=class{constructor(e,r,n){this.key=e,this.path=r,this.decodeStrategy=n}};ct.CustomPath=Cu;var H1=async t=>{let{agent:e,paths:r}=t,n=dn.Principal.from(t.canisterId),i=[...new Set(r)],s=i.map(c=>(0,ct.encodePath)(c,n)),o=new Map,a=i.map((c,f)=>(async()=>{var d;try{let h=await e.readState(n,{paths:[s[f]]}),S=await hn.Certificate.create({certificate:h.certificate,rootKey:e.rootKey,canisterId:n}),w=(U,F)=>{if(F==="subnet"){let N=(0,ct.fetchNodeKeys)(h.certificate,n,e.rootKey);return{path:F,data:N}}else return{path:F,data:(0,hn.lookupResultToBuffer)(U.lookup((0,ct.encodePath)(F,n)))}},{path:u,data:g}=w(S,i[f]);if(!g)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,(0,G0.decodeTime)(g));break}case"controllers":{o.set(u,Y1(g));break}case"module_hash":{o.set(u,Y0(g));break}case"subnet":{o.set(u,g);break}case"candid":{o.set(u,new TextDecoder().decode(g));break}default:if(typeof u!="string"&&"key"in u&&"path"in u)switch(u.decodeStrategy){case"raw":o.set(u.key,g);break;case"leb128":{o.set(u.key,(0,G0.decodeLeb128)(g));break}case"cbor":{o.set(u.key,z0(g));break}case"hex":{o.set(u.key,Y0(g));break}case"utf-8":o.set(u.key,G1(g))}}}catch(h){if(!((d=h?.message)===null||d===void 0)&&d.includes("Invalid certificate"))throw new k1.AgentError(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};ct.request=H1;var $1=(t,e,r)=>{if(!e._isPrincipal)throw new Error("Invalid canisterId");let n=W0.decode(new Uint8Array(t)),i=n.tree,s=n.delegation,o;if(s&&s.subnet_id?o=dn.Principal.fromUint8Array(new Uint8Array(s.subnet_id)):!s&&typeof r<"u"?(o=dn.Principal.selfAuthenticating(new Uint8Array(r)),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}):(o=dn.Principal.selfAuthenticating(dn.Principal.fromText("tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe").toUint8Array()),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}),!(0,hn.check_canister_ranges)({canisterId:e,subnetId:o,tree:i}))throw new Error("Canister not in range");let c=(0,hn.lookup_path)(["subnet",s.subnet_id,"node"],i);if(c.status!==hn.LookupStatus.Found)throw new Error("Node not found");if(c.value instanceof ArrayBuffer)throw new Error("Invalid node tree");let f=(0,hn.flatten_forks)(c.value),d=new Map;return f.forEach(h=>{let S=dn.Principal.from(new Uint8Array(h[1])).toText(),w=(0,hn.lookup_path)(["public_key"],h[2]);if(w.status!==hn.LookupStatus.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(S,u)}),{subnetId:dn.Principal.fromUint8Array(new Uint8Array(s.subnet_id)).toText(),nodeKeys:d}};ct.fetchNodeKeys=$1;var K1=(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.`)};ct.encodePath=K1;var Y0=t=>(0,V1.toHex)(t),z0=t=>W0.decode(t),G1=t=>new TextDecoder().decode(t),Y1=t=>z0(t).map(r=>dn.Principal.fromUint8Array(new Uint8Array(r)))});var yh=L(me=>{"use strict";Object.defineProperty(me,"__esModule",{value:!0});me.add5L=me.add5H=me.add4H=me.add4L=me.add3H=me.add3L=me.add=me.rotlBL=me.rotlBH=me.rotlSL=me.rotlSH=me.rotr32L=me.rotr32H=me.rotrBL=me.rotrBH=me.rotrSL=me.rotrSH=me.shrSL=me.shrSH=me.toBig=me.split=me.fromBig=void 0;var Go=BigInt(2**32-1),qu=BigInt(32);function ju(t,e=!1){return e?{h:Number(t&Go),l:Number(t>>qu&Go)}:{h:Number(t>>qu&Go)|0,l:Number(t&Go)|0}}me.fromBig=ju;function D0(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}=ju(t[i],e);[r[i],n[i]]=[s,o]}return[r,n]}me.split=D0;var Z0=(t,e)=>BigInt(t>>>0)<<qu|BigInt(e>>>0);me.toBig=Z0;var X0=(t,e,r)=>t>>>r;me.shrSH=X0;var J0=(t,e,r)=>t<<32-r|e>>>r;me.shrSL=J0;var L0=(t,e,r)=>t>>>r|e<<32-r;me.rotrSH=L0;var Q0=(t,e,r)=>t<<32-r|e>>>r;me.rotrSL=Q0;var eh=(t,e,r)=>t<<64-r|e>>>r-32;me.rotrBH=eh;var th=(t,e,r)=>t>>>r-32|e<<64-r;me.rotrBL=th;var rh=(t,e)=>e;me.rotr32H=rh;var nh=(t,e)=>t;me.rotr32L=nh;var ih=(t,e,r)=>t<<r|e>>>32-r;me.rotlSH=ih;var sh=(t,e,r)=>e<<r|t>>>32-r;me.rotlSL=sh;var oh=(t,e,r)=>e<<r-32|t>>>64-r;me.rotlBH=oh;var ah=(t,e,r)=>t<<r-32|e>>>64-r;me.rotlBL=ah;function ch(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}me.add=ch;var uh=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0);me.add3L=uh;var lh=(t,e,r,n)=>e+r+n+(t/2**32|0)|0;me.add3H=lh;var fh=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0);me.add4L=fh;var dh=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0;me.add4H=dh;var hh=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0);me.add5L=hh;var ph=(t,e,r,n,i,s)=>e+r+n+i+s+(t/2**32|0)|0;me.add5H=ph;var W1={fromBig:ju,split:D0,toBig:Z0,shrSH:X0,shrSL:J0,rotrSH:L0,rotrSL:Q0,rotrBH:eh,rotrBL:th,rotr32H:rh,rotr32L:nh,rotlSH:ih,rotlSL:sh,rotlBH:oh,rotlBL:ah,add:ch,add3L:uh,add3H:lh,add4L:fh,add4H:dh,add5H:ph,add5L:hh};me.default=W1});var mh=L(ir=>{"use strict";Object.defineProperty(ir,"__esModule",{value:!0});ir.sha384=ir.sha512_256=ir.sha512_224=ir.sha512=ir.SHA512=void 0;var z1=Ka(),be=yh(),Yo=Bn(),[D1,Z1]=be.default.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))),pn=new Uint32Array(80),yn=new Uint32Array(80),Mn=class extends z1.HashMD{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:r,Bh:n,Bl:i,Ch:s,Cl:o,Dh:a,Dl:c,Eh:f,El:d,Fh:h,Fl:S,Gh:w,Gl:u,Hh:g,Hl:U}=this;return[e,r,n,i,s,o,a,c,f,d,h,S,w,u,g,U]}set(e,r,n,i,s,o,a,c,f,d,h,S,w,u,g,U){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=d|0,this.Fh=h|0,this.Fl=S|0,this.Gh=w|0,this.Gl=u|0,this.Hh=g|0,this.Hl=U|0}process(e,r){for(let V=0;V<16;V++,r+=4)pn[V]=e.getUint32(r),yn[V]=e.getUint32(r+=4);for(let V=16;V<80;V++){let W=pn[V-15]|0,T=yn[V-15]|0,C=be.default.rotrSH(W,T,1)^be.default.rotrSH(W,T,8)^be.default.shrSH(W,T,7),z=be.default.rotrSL(W,T,1)^be.default.rotrSL(W,T,8)^be.default.shrSL(W,T,7),D=pn[V-2]|0,G=yn[V-2]|0,ne=be.default.rotrSH(D,G,19)^be.default.rotrBH(D,G,61)^be.default.shrSH(D,G,6),Q=be.default.rotrSL(D,G,19)^be.default.rotrBL(D,G,61)^be.default.shrSL(D,G,6),le=be.default.add4L(z,Q,yn[V-7],yn[V-16]),E=be.default.add4H(le,C,ne,pn[V-7],pn[V-16]);pn[V]=E|0,yn[V]=le|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:a,Cl:c,Dh:f,Dl:d,Eh:h,El:S,Fh:w,Fl:u,Gh:g,Gl:U,Hh:F,Hl:N}=this;for(let V=0;V<80;V++){let W=be.default.rotrSH(h,S,14)^be.default.rotrSH(h,S,18)^be.default.rotrBH(h,S,41),T=be.default.rotrSL(h,S,14)^be.default.rotrSL(h,S,18)^be.default.rotrBL(h,S,41),C=h&w^~h&g,z=S&u^~S&U,D=be.default.add5L(N,T,z,Z1[V],yn[V]),G=be.default.add5H(D,F,W,C,D1[V],pn[V]),ne=D|0,Q=be.default.rotrSH(n,i,28)^be.default.rotrBH(n,i,34)^be.default.rotrBH(n,i,39),le=be.default.rotrSL(n,i,28)^be.default.rotrBL(n,i,34)^be.default.rotrBL(n,i,39),E=n&s^n&a^s&a,_=i&o^i&c^o&c;F=g|0,N=U|0,g=w|0,U=u|0,w=h|0,u=S|0,{h,l:S}=be.default.add(f|0,d|0,G|0,ne|0),f=a|0,d=c|0,a=s|0,c=o|0,s=n|0,o=i|0;let b=be.default.add3L(ne,le,_);n=be.default.add3H(b,G,Q,E),i=b|0}({h:n,l:i}=be.default.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=be.default.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:c}=be.default.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:d}=be.default.add(this.Dh|0,this.Dl|0,f|0,d|0),{h,l:S}=be.default.add(this.Eh|0,this.El|0,h|0,S|0),{h:w,l:u}=be.default.add(this.Fh|0,this.Fl|0,w|0,u|0),{h:g,l:U}=be.default.add(this.Gh|0,this.Gl|0,g|0,U|0),{h:F,l:N}=be.default.add(this.Hh|0,this.Hl|0,F|0,N|0),this.set(n,i,s,o,a,c,f,d,h,S,w,u,g,U,F,N)}roundClean(){pn.fill(0),yn.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)}};ir.SHA512=Mn;var ku=class extends Mn{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}},Vu=class extends Mn{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}},Hu=class extends Mn{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}};ir.sha512=(0,Yo.wrapConstructor)(()=>new Mn);ir.sha512_224=(0,Yo.wrapConstructor)(()=>new ku);ir.sha512_256=(0,Yo.wrapConstructor)(()=>new Vu);ir.sha384=(0,Yo.wrapConstructor)(()=>new Hu)});var bh=L($u=>{"use strict";Object.defineProperty($u,"__esModule",{value:!0});$u.twistedEdwards=ew;var gh=Eu(),X1=Or(),Ht=Wt(),Zt=Wt(),pr=BigInt(0),Vt=BigInt(1),Wo=BigInt(2),J1=BigInt(8),L1={zip215:!0};function Q1(t){let e=(0,gh.validateBasic)(t);return Ht.validateObject(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function ew(t){let e=Q1(t),{Fp:r,n,prehash:i,hash:s,randomBytes:o,nByteLength:a,h:c}=e,f=Wo<<BigInt(a*8)-Vt,d=r.create,h=e.uvRatio||((b,x)=>{try{return{isValid:!0,value:r.sqrt(b*r.inv(x))}}catch{return{isValid:!1,value:pr}}}),S=e.adjustScalarBytes||(b=>b),w=e.domain||((b,x,j)=>{if((0,Zt.abool)("phflag",j),x.length||j)throw new Error("Contexts/pre-hash are not supported");return b});function u(b,x){Ht.aInRange("coordinate "+b,x,pr,f)}function g(b){if(!(b instanceof N))throw new Error("ExtendedPoint expected")}let U=(0,Zt.memoized)((b,x)=>{let{ex:j,ey:H,ez:X}=b,oe=b.is0();x==null&&(x=oe?J1:r.inv(X));let ae=d(j*x),Y=d(H*x),R=d(X*x);if(oe)return{x:pr,y:Vt};if(R!==Vt)throw new Error("invZ was invalid");return{x:ae,y:Y}}),F=(0,Zt.memoized)(b=>{let{a:x,d:j}=e;if(b.is0())throw new Error("bad point: ZERO");let{ex:H,ey:X,ez:oe,et:ae}=b,Y=d(H*H),R=d(X*X),p=d(oe*oe),ee=d(p*p),re=d(Y*x),de=d(p*d(re+R)),J=d(ee+d(j*d(Y*R)));if(de!==J)throw new Error("bad point: equation left != right (1)");let l=d(H*X),y=d(oe*ae);if(l!==y)throw new Error("bad point: equation left != right (2)");return!0});class N{constructor(x,j,H,X){this.ex=x,this.ey=j,this.ez=H,this.et=X,u("x",x),u("y",j),u("z",H),u("t",X),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(x){if(x instanceof N)throw new Error("extended point not allowed");let{x:j,y:H}=x||{};return u("x",j),u("y",H),new N(j,H,Vt,d(j*H))}static normalizeZ(x){let j=r.invertBatch(x.map(H=>H.ez));return x.map((H,X)=>H.toAffine(j[X])).map(N.fromAffine)}_setWindowSize(x){T.setWindowSize(this,x)}assertValidity(){F(this)}equals(x){g(x);let{ex:j,ey:H,ez:X}=this,{ex:oe,ey:ae,ez:Y}=x,R=d(j*Y),p=d(oe*X),ee=d(H*Y),re=d(ae*X);return R===p&&ee===re}is0(){return this.equals(N.ZERO)}negate(){return new N(d(-this.ex),this.ey,this.ez,d(-this.et))}double(){let{a:x}=e,{ex:j,ey:H,ez:X}=this,oe=d(j*j),ae=d(H*H),Y=d(Wo*d(X*X)),R=d(x*oe),p=j+H,ee=d(d(p*p)-oe-ae),re=R+ae,de=re-Y,J=R-ae,l=d(ee*de),y=d(re*J),m=d(ee*J),P=d(de*re);return new N(l,y,P,m)}add(x){g(x);let{a:j,d:H}=e,{ex:X,ey:oe,ez:ae,et:Y}=this,{ex:R,ey:p,ez:ee,et:re}=x;if(j===BigInt(-1)){let M=d((oe-X)*(p+R)),Z=d((oe+X)*(p-R)),te=d(Z-M);if(te===pr)return this.double();let fe=d(ae*Wo*re),_e=d(Y*Wo*ee),Fe=_e+fe,$e=Z+M,we=_e-fe,pe=d(Fe*te),et=d($e*we),Jr=d(Fe*we),An=d(te*$e);return new N(pe,et,An,Jr)}let de=d(X*R),J=d(oe*p),l=d(Y*H*re),y=d(ae*ee),m=d((X+oe)*(R+p)-de-J),P=y-l,B=y+l,O=d(J-j*de),q=d(m*P),v=d(B*O),I=d(m*O),k=d(P*B);return new N(q,v,k,I)}subtract(x){return this.add(x.negate())}wNAF(x){return T.wNAFCached(this,x,N.normalizeZ)}multiply(x){let j=x;Ht.aInRange("scalar",j,Vt,n);let{p:H,f:X}=this.wNAF(j);return N.normalizeZ([H,X])[0]}multiplyUnsafe(x){let j=x;return Ht.aInRange("scalar",j,pr,n),j===pr?W:this.equals(W)||j===Vt?this:this.equals(V)?this.wNAF(j).p:T.unsafeLadder(this,j)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return T.unsafeLadder(this,n).is0()}toAffine(x){return U(this,x)}clearCofactor(){let{h:x}=e;return x===Vt?this:this.multiplyUnsafe(x)}static fromHex(x,j=!1){let{d:H,a:X}=e,oe=r.BYTES;x=(0,Zt.ensureBytes)("pointHex",x,oe),(0,Zt.abool)("zip215",j);let ae=x.slice(),Y=x[oe-1];ae[oe-1]=Y&-129;let R=Ht.bytesToNumberLE(ae),p=j?f:r.ORDER;Ht.aInRange("pointHex.y",R,pr,p);let ee=d(R*R),re=d(ee-Vt),de=d(H*ee-X),{isValid:J,value:l}=h(re,de);if(!J)throw new Error("Point.fromHex: invalid y coordinate");let y=(l&Vt)===Vt,m=(Y&128)!==0;if(!j&&l===pr&&m)throw new Error("Point.fromHex: x=0 and x_0=1");return m!==y&&(l=d(-l)),N.fromAffine({x:l,y:R})}static fromPrivateKey(x){return D(x).point}toRawBytes(){let{x,y:j}=this.toAffine(),H=Ht.numberToBytesLE(j,r.BYTES);return H[H.length-1]|=x&Vt?128:0,H}toHex(){return Ht.bytesToHex(this.toRawBytes())}}N.BASE=new N(e.Gx,e.Gy,Vt,d(e.Gx*e.Gy)),N.ZERO=new N(pr,Vt,Vt,pr);let{BASE:V,ZERO:W}=N,T=(0,gh.wNAF)(N,a*8);function C(b){return(0,X1.mod)(b,n)}function z(b){return C(Ht.bytesToNumberLE(b))}function D(b){let x=a;b=(0,Zt.ensureBytes)("private key",b,x);let j=(0,Zt.ensureBytes)("hashed private key",s(b),2*x),H=S(j.slice(0,x)),X=j.slice(x,2*x),oe=z(H),ae=V.multiply(oe),Y=ae.toRawBytes();return{head:H,prefix:X,scalar:oe,point:ae,pointBytes:Y}}function G(b){return D(b).pointBytes}function ne(b=new Uint8Array,...x){let j=Ht.concatBytes(...x);return z(s(w(j,(0,Zt.ensureBytes)("context",b),!!i)))}function Q(b,x,j={}){b=(0,Zt.ensureBytes)("message",b),i&&(b=i(b));let{prefix:H,scalar:X,pointBytes:oe}=D(x),ae=ne(j.context,H,b),Y=V.multiply(ae).toRawBytes(),R=ne(j.context,Y,oe,b),p=C(ae+R*X);Ht.aInRange("signature.s",p,pr,n);let ee=Ht.concatBytes(Y,Ht.numberToBytesLE(p,r.BYTES));return(0,Zt.ensureBytes)("result",ee,a*2)}let le=L1;function E(b,x,j,H=le){let{context:X,zip215:oe}=H,ae=r.BYTES;b=(0,Zt.ensureBytes)("signature",b,2*ae),x=(0,Zt.ensureBytes)("message",x),oe!==void 0&&(0,Zt.abool)("zip215",oe),i&&(x=i(x));let Y=Ht.bytesToNumberLE(b.slice(ae,2*ae)),R,p,ee;try{R=N.fromHex(j,oe),p=N.fromHex(b.slice(0,ae),oe),ee=V.multiplyUnsafe(Y)}catch{return!1}if(!oe&&R.isSmallOrder())return!1;let re=ne(X,p.toRawBytes(),R.toRawBytes(),x);return p.add(R.multiplyUnsafe(re)).subtract(ee).clearCofactor().equals(N.ZERO)}return V._setWindowSize(8),{CURVE:e,getPublicKey:G,sign:Q,verify:E,ExtendedPoint:N,utils:{getExtendedPublicKey:D,randomPrivateKey:()=>o(r.BYTES),precompute(b=8,x=N.BASE){return x._setWindowSize(b),x.multiply(BigInt(3)),x}}}}});var wh=L(Gu=>{"use strict";Object.defineProperty(Gu,"__esModule",{value:!0});Gu.montgomery=rw;var _h=Or(),mn=Wt(),bi=BigInt(0),Ku=BigInt(1);function tw(t){return(0,mn.validateObject)(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function rw(t){let e=tw(t),{P:r}=e,n=N=>(0,_h.mod)(N,r),i=e.montgomeryBits,s=Math.ceil(i/8),o=e.nByteLength,a=e.adjustScalarBytes||(N=>N),c=e.powPminus2||(N=>(0,_h.pow)(N,r-BigInt(2),r));function f(N,V,W){let T=n(N*(V-W));return V=n(V-T),W=n(W+T),[V,W]}let d=(e.a-BigInt(2))/BigInt(4);function h(N,V){(0,mn.aInRange)("u",N,bi,r),(0,mn.aInRange)("scalar",V,bi,r);let W=V,T=N,C=Ku,z=bi,D=N,G=Ku,ne=bi,Q;for(let E=BigInt(i-1);E>=bi;E--){let _=W>>E&Ku;ne^=_,Q=f(ne,C,D),C=Q[0],D=Q[1],Q=f(ne,z,G),z=Q[0],G=Q[1],ne=_;let b=C+z,x=n(b*b),j=C-z,H=n(j*j),X=x-H,oe=D+G,ae=D-G,Y=n(ae*b),R=n(oe*j),p=Y+R,ee=Y-R;D=n(p*p),G=n(T*n(ee*ee)),C=n(x*H),z=n(X*(x+n(d*X)))}Q=f(ne,C,D),C=Q[0],D=Q[1],Q=f(ne,z,G),z=Q[0],G=Q[1];let le=c(z);return n(C*le)}function S(N){return(0,mn.numberToBytesLE)(n(N),s)}function w(N){let V=(0,mn.ensureBytes)("u coordinate",N,s);return o===32&&(V[31]&=127),(0,mn.bytesToNumberLE)(V)}function u(N){let V=(0,mn.ensureBytes)("scalar",N),W=V.length;if(W!==s&&W!==o)throw new Error(`Expected ${s} or ${o} bytes, got ${W}`);return(0,mn.bytesToNumberLE)(a(V))}function g(N,V){let W=w(V),T=u(N),C=h(W,T);if(C===bi)throw new Error("Invalid private or public key received");return S(C)}let U=S(e.Gu);function F(N){return g(N,U)}return{scalarMult:g,scalarMultBase:F,getSharedSecret:(N,V)=>g(N,V),getPublicKey:N=>F(N),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:U}}});var Lu=L(ge=>{"use strict";Object.defineProperty(ge,"__esModule",{value:!0});ge.hash_to_ristretto255=ge.hashToRistretto255=ge.RistrettoPoint=ge.encodeToCurve=ge.hashToCurve=ge.edwardsToMontgomery=ge.x25519=ge.ed25519ph=ge.ed25519ctx=ge.ed25519=ge.ED25519_TORSION_SUBGROUP=void 0;ge.edwardsToMontgomeryPub=Ph;ge.edwardsToMontgomeryPriv=sw;var Do=mh(),cs=Bn(),Zu=bh(),Th=Ro(),Ie=Or(),nw=wh(),Cn=Wt(),us=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),zu=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),iw=BigInt(0),Pr=BigInt(1),zo=BigInt(2),Ah=BigInt(3),Sh=BigInt(5),Xu=BigInt(8);function Bh(t){let e=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),s=us,a=t*t%s*t%s,c=(0,Ie.pow2)(a,zo,s)*a%s,f=(0,Ie.pow2)(c,Pr,s)*t%s,d=(0,Ie.pow2)(f,Sh,s)*f%s,h=(0,Ie.pow2)(d,e,s)*d%s,S=(0,Ie.pow2)(h,r,s)*h%s,w=(0,Ie.pow2)(S,n,s)*S%s,u=(0,Ie.pow2)(w,i,s)*w%s,g=(0,Ie.pow2)(u,i,s)*w%s,U=(0,Ie.pow2)(g,e,s)*d%s;return{pow_p_5_8:(0,Ie.pow2)(U,zo,s)*t%s,b2:a}}function Oh(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function Ju(t,e){let r=us,n=(0,Ie.mod)(e*e*e,r),i=(0,Ie.mod)(n*n*e,r),s=Bh(t*i).pow_p_5_8,o=(0,Ie.mod)(t*n*s,r),a=(0,Ie.mod)(e*o*o,r),c=o,f=(0,Ie.mod)(o*zu,r),d=a===t,h=a===(0,Ie.mod)(-t,r),S=a===(0,Ie.mod)(-t*zu,r);return d&&(o=c),(h||S)&&(o=f),(0,Ie.isNegativeLE)(o,r)&&(o=(0,Ie.mod)(-o,r)),{isValid:d||h,value:o}}ge.ED25519_TORSION_SUBGROUP=["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"];var se=(0,Ie.Field)(us,void 0,!0),ls={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:se,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Xu,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Do.sha512,randomBytes:cs.randomBytes,adjustScalarBytes:Oh,uvRatio:Ju};ge.ed25519=(0,Zu.twistedEdwards)(ls);function Nh(t,e,r){if(e.length>255)throw new Error("Context is too big");return(0,cs.concatBytes)((0,cs.utf8ToBytes)("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}ge.ed25519ctx=(0,Zu.twistedEdwards)({...ls,domain:Nh});ge.ed25519ph=(0,Zu.twistedEdwards)(Object.assign({},ls,{domain:Nh,prehash:Do.sha512}));ge.x25519=(0,nw.montgomery)({P:us,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{let e=us,{pow_p_5_8:r,b2:n}=Bh(t);return(0,Ie.mod)((0,Ie.pow2)(r,Ah,e)*n,e)},adjustScalarBytes:Oh,randomBytes:cs.randomBytes});function Ph(t){let{y:e}=ge.ed25519.ExtendedPoint.fromHex(t),r=BigInt(1);return se.toBytes(se.create((r+e)*se.inv(r-e)))}ge.edwardsToMontgomery=Ph;function sw(t){let e=ls.hash(t.subarray(0,32));return ls.adjustScalarBytes(e).subarray(0,32)}var ow=(se.ORDER+Ah)/Xu,aw=se.pow(zo,ow),Eh=se.sqrt(se.neg(se.ONE));function cw(t){let e=(se.ORDER-Sh)/Xu,r=BigInt(486662),n=se.sqr(t);n=se.mul(n,zo);let i=se.add(n,se.ONE),s=se.neg(r),o=se.sqr(i),a=se.mul(o,i),c=se.mul(n,r);c=se.mul(c,s),c=se.add(c,o),c=se.mul(c,s);let f=se.sqr(a);o=se.sqr(f),f=se.mul(f,a),f=se.mul(f,c),o=se.mul(o,f);let d=se.pow(o,e);d=se.mul(d,f);let h=se.mul(d,Eh);o=se.sqr(d),o=se.mul(o,a);let S=se.eql(o,c),w=se.cmov(h,d,S),u=se.mul(s,n),g=se.mul(d,t);g=se.mul(g,aw);let U=se.mul(g,Eh),F=se.mul(c,n);o=se.sqr(g),o=se.mul(o,a);let N=se.eql(o,F),V=se.cmov(U,g,N);o=se.sqr(w),o=se.mul(o,a);let W=se.eql(o,c),T=se.cmov(u,s,W),C=se.cmov(V,w,W),z=se.isOdd(C);return C=se.cmov(C,se.neg(C),W!==z),{xMn:T,xMd:i,yMn:C,yMd:Pr}}var uw=(0,Ie.FpSqrtEven)(se,se.neg(BigInt(486664)));function lw(t){let{xMn:e,xMd:r,yMn:n,yMd:i}=cw(t),s=se.mul(e,i);s=se.mul(s,uw);let o=se.mul(r,n),a=se.sub(e,r),c=se.add(e,r),f=se.mul(o,c),d=se.eql(f,se.ZERO);s=se.cmov(s,se.ZERO,d),o=se.cmov(o,se.ONE,d),a=se.cmov(a,se.ONE,d),c=se.cmov(c,se.ONE,d);let h=se.invertBatch([o,c]);return{x:se.mul(s,h[0]),y:se.mul(a,h[1])}}var Rh=(0,Th.createHasher)(ge.ed25519.ExtendedPoint,t=>lw(t[0]),{DST:"edwards25519_XMD:SHA-512_ELL2_RO_",encodeDST:"edwards25519_XMD:SHA-512_ELL2_NU_",p:se.ORDER,m:1,k:128,expand:"xmd",hash:Do.sha512});ge.hashToCurve=Rh.hashToCurve;ge.encodeToCurve=Rh.encodeToCurve;function Yu(t){if(!(t instanceof yr))throw new Error("RistrettoPoint expected")}var Du=zu,fw=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),dw=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),hw=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),pw=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),xh=t=>Ju(Pr,t),yw=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Wu=t=>ge.ed25519.CURVE.Fp.create((0,Cn.bytesToNumberLE)(t)&yw);function vh(t){let{d:e}=ge.ed25519.CURVE,r=ge.ed25519.CURVE.Fp.ORDER,n=ge.ed25519.CURVE.Fp.create,i=n(Du*t*t),s=n((i+Pr)*hw),o=BigInt(-1),a=n((o-e*i)*n(i+e)),{isValid:c,value:f}=Ju(s,a),d=n(f*t);(0,Ie.isNegativeLE)(d,r)||(d=n(-d)),c||(f=d),c||(o=i);let h=n(o*(i-Pr)*pw-a),S=f*f,w=n((f+f)*a),u=n(h*fw),g=n(Pr-S),U=n(Pr+S);return new ge.ed25519.ExtendedPoint(n(w*U),n(g*u),n(u*U),n(w*g))}var yr=class t{constructor(e){this.ep=e}static fromAffine(e){return new t(ge.ed25519.ExtendedPoint.fromAffine(e))}static hashToCurve(e){e=(0,Cn.ensureBytes)("ristrettoHash",e,64);let r=Wu(e.slice(0,32)),n=vh(r),i=Wu(e.slice(32,64)),s=vh(i);return new t(n.add(s))}static fromHex(e){e=(0,Cn.ensureBytes)("ristrettoHex",e,32);let{a:r,d:n}=ge.ed25519.CURVE,i=ge.ed25519.CURVE.Fp.ORDER,s=ge.ed25519.CURVE.Fp.create,o="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",a=Wu(e);if(!(0,Cn.equalBytes)((0,Cn.numberToBytesLE)(a,32),e)||(0,Ie.isNegativeLE)(a,i))throw new Error(o);let c=s(a*a),f=s(Pr+r*c),d=s(Pr-r*c),h=s(f*f),S=s(d*d),w=s(r*n*h-S),{isValid:u,value:g}=xh(s(w*S)),U=s(g*d),F=s(g*U*w),N=s((a+a)*U);(0,Ie.isNegativeLE)(N,i)&&(N=s(-N));let V=s(f*F),W=s(N*V);if(!u||(0,Ie.isNegativeLE)(W,i)||V===iw)throw new Error(o);return new t(new ge.ed25519.ExtendedPoint(N,V,Pr,W))}toRawBytes(){let{ex:e,ey:r,ez:n,et:i}=this.ep,s=ge.ed25519.CURVE.Fp.ORDER,o=ge.ed25519.CURVE.Fp.create,a=o(o(n+r)*o(n-r)),c=o(e*r),f=o(c*c),{value:d}=xh(o(a*f)),h=o(d*a),S=o(d*c),w=o(h*S*i),u;if((0,Ie.isNegativeLE)(i*w,s)){let U=o(r*Du),F=o(e*Du);e=U,r=F,u=o(h*dw)}else u=S;(0,Ie.isNegativeLE)(e*w,s)&&(r=o(-r));let g=o((n-r)*u);return(0,Ie.isNegativeLE)(g,s)&&(g=o(-g)),(0,Cn.numberToBytesLE)(g,32)}toHex(){return(0,Cn.bytesToHex)(this.toRawBytes())}toString(){return this.toHex()}equals(e){Yu(e);let{ex:r,ey:n}=this.ep,{ex:i,ey:s}=e.ep,o=ge.ed25519.CURVE.Fp.create,a=o(r*s)===o(n*i),c=o(n*s)===o(r*i);return a||c}add(e){return Yu(e),new t(this.ep.add(e.ep))}subtract(e){return Yu(e),new t(this.ep.subtract(e.ep))}multiply(e){return new t(this.ep.multiply(e))}multiplyUnsafe(e){return new t(this.ep.multiplyUnsafe(e))}double(){return new t(this.ep.double())}negate(){return new t(this.ep.negate())}};ge.RistrettoPoint=(yr.BASE||(yr.BASE=new yr(ge.ed25519.ExtendedPoint.BASE)),yr.ZERO||(yr.ZERO=new yr(ge.ed25519.ExtendedPoint.ZERO)),yr);var mw=(t,e)=>{let r=e.DST,n=typeof r=="string"?(0,cs.utf8ToBytes)(r):r,i=(0,Th.expand_message_xmd)(t,n,64,Do.sha512);return yr.hashToCurve(i)};ge.hashToRistretto255=mw;ge.hash_to_ristretto255=ge.hashToRistretto255});var Mh=L(gn=>{"use strict";var Ih=gn&&gn.__classPrivateFieldSet||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},Mt=gn&&gn.__classPrivateFieldGet||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)},Bt,fs,Uh,Fh;Object.defineProperty(gn,"__esModule",{value:!0});gn.ExpirableMap=void 0;var Qu=class{constructor(e={}){Bt.set(this,void 0),fs.set(this,void 0),this[Uh]=this.entries.bind(this),this[Fh]="ExpirableMap";let{source:r=[],expirationTime:n=10*60*1e3}=e,i=Date.now();Ih(this,Bt,new Map([...r].map(([s,o])=>[s,{value:o,timestamp:i}])),"f"),Ih(this,fs,n,"f")}prune(){let e=Date.now();for(let[r,n]of Mt(this,Bt,"f").entries())e-n.timestamp>Mt(this,fs,"f")&&Mt(this,Bt,"f").delete(r);return this}set(e,r){this.prune();let n={value:r,timestamp:Date.now()};return Mt(this,Bt,"f").set(e,n),this}get(e){let r=Mt(this,Bt,"f").get(e);if(r!==void 0){if(Date.now()-r.timestamp>Mt(this,fs,"f")){Mt(this,Bt,"f").delete(e);return}return r.value}}clear(){Mt(this,Bt,"f").clear()}entries(){let e=Mt(this,Bt,"f").entries();return function*(){for(let[n,i]of e)yield[n,i.value]}()}values(){let e=Mt(this,Bt,"f").values();return function*(){for(let n of e)yield n.value}()}keys(){return Mt(this,Bt,"f").keys()}forEach(e,r){for(let[n,i]of Mt(this,Bt,"f").entries())e.call(r,i.value,n,this)}has(e){return Mt(this,Bt,"f").has(e)}delete(e){return Mt(this,Bt,"f").delete(e)}get size(){return Mt(this,Bt,"f").size}};gn.ExpirableMap=Qu;Bt=new WeakMap,fs=new WeakMap,Uh=Symbol.iterator,Fh=Symbol.toStringTag});var el=L(ke=>{"use strict";Object.defineProperty(ke,"__esModule",{value:!0});ke.unwrapDER=ke.wrapDER=ke.SECP256K1_OID=ke.ED25519_OID=ke.DER_COSE_OID=ke.decodeLen=ke.decodeLenBytes=ke.encodeLen=ke.encodeLenBytes=void 0;var gw=Yt(),bw=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)")};ke.encodeLenBytes=bw;var _w=(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)")};ke.encodeLen=_w;var ww=(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)")};ke.decodeLenBytes=ww;var Ew=(t,e)=>{let r=(0,ke.decodeLenBytes)(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)")};ke.decodeLen=Ew;ke.DER_COSE_OID=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]);ke.ED25519_OID=Uint8Array.from([48,5,6,3,43,101,112]);ke.SECP256K1_OID=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function xw(t,e){let r=2+(0,ke.encodeLenBytes)(t.byteLength+1),n=e.byteLength+r+t.byteLength,i=0,s=new Uint8Array(1+(0,ke.encodeLenBytes)(n)+n);return s[i++]=48,i+=(0,ke.encodeLen)(s,i,n),s.set(e,i),i+=e.byteLength,s[i++]=3,i+=(0,ke.encodeLen)(s,i,t.byteLength+1),s[i++]=0,s.set(new Uint8Array(t),i),s}ke.wrapDER=xw;var vw=(t,e)=>{let r=0,n=(a,c)=>{if(i[r++]!==a)throw new Error("Expected: "+c)},i=new Uint8Array(t);if(n(48,"sequence"),r+=(0,ke.decodeLenBytes)(i,r),!(0,gw.bufEquals)(i.slice(r,r+e.byteLength),e))throw new Error("Not the expected OID.");r+=e.byteLength,n(3,"bit string");let s=(0,ke.decodeLen)(i,r)-1;r+=(0,ke.decodeLenBytes)(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};ke.unwrapDER=vw});var tl=L(bn=>{"use strict";var Ch=bn&&bn.__classPrivateFieldSet||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},qh=bn&&bn.__classPrivateFieldGet||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)},Xo,Jo;Object.defineProperty(bn,"__esModule",{value:!0});bn.Ed25519PublicKey=void 0;var Zo=el(),Lo=class t{constructor(e){if(Xo.set(this,void 0),Jo.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Ch(this,Xo,e,"f"),Ch(this,Jo,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(0,Zo.wrapDER)(e,Zo.ED25519_OID).buffer}static derDecode(e){let r=(0,Zo.unwrapDER)(e,Zo.ED25519_OID);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return qh(this,Xo,"f")}get derKey(){return qh(this,Jo,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};bn.Ed25519PublicKey=Lo;Xo=new WeakMap,Jo=new WeakMap;Lo.RAW_KEY_LENGTH=32});var jh=L(_i=>{"use strict";Object.defineProperty(_i,"__esModule",{value:!0});_i.ObservableLog=_i.Observable=void 0;var Qo=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))}};_i.Observable=Qo;var rl=class extends Qo{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)}};_i.ObservableLog=rl});var Yh=L(Ur=>{"use strict";var Rr=Ur&&Ur.__classPrivateFieldSet||function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Ot=Ur&&Ur.__classPrivateFieldGet||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)},Ir,ea,ta,ra,na,ia,sa,oa,wi;Object.defineProperty(Ur,"__esModule",{value:!0});Ur.exponentialBackoff=Ur.ExponentialBackoff=void 0;var kh=.5,Vh=1.5,Hh=500,$h=6e4,Kh=9e5,Gh=10,Ei=class t{constructor(e=t.default){Ir.set(this,void 0),ea.set(this,void 0),ta.set(this,void 0),ra.set(this,void 0),na.set(this,void 0),ia.set(this,void 0),sa.set(this,void 0),oa.set(this,void 0),wi.set(this,0);let{initialInterval:r=Hh,randomizationFactor:n=kh,multiplier:i=Vh,maxInterval:s=$h,maxElapsedTime:o=Kh,maxIterations:a=Gh,date:c=Date}=e;Rr(this,Ir,r,"f"),Rr(this,ea,n,"f"),Rr(this,ta,i,"f"),Rr(this,ra,s,"f"),Rr(this,oa,c,"f"),Rr(this,na,c.now(),"f"),Rr(this,ia,o,"f"),Rr(this,sa,a,"f")}get ellapsedTimeInMsec(){return Ot(this,oa,"f").now()-Ot(this,na,"f")}get currentInterval(){return Ot(this,Ir,"f")}get count(){return Ot(this,wi,"f")}get randomValueFromInterval(){let e=Ot(this,ea,"f")*Ot(this,Ir,"f"),r=Ot(this,Ir,"f")-e,n=Ot(this,Ir,"f")+e;return Math.random()*(n-r)+r}incrementCurrentInterval(){var e;return Rr(this,Ir,Math.min(Ot(this,Ir,"f")*Ot(this,ta,"f"),Ot(this,ra,"f")),"f"),Rr(this,wi,(e=Ot(this,wi,"f"),e++,e),"f"),Ot(this,Ir,"f")}next(){return this.ellapsedTimeInMsec>=Ot(this,ia,"f")||Ot(this,wi,"f")>=Ot(this,sa,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};Ur.ExponentialBackoff=Ei;Ir=new WeakMap,ea=new WeakMap,ta=new WeakMap,ra=new WeakMap,na=new WeakMap,ia=new WeakMap,sa=new WeakMap,oa=new WeakMap,wi=new WeakMap;Ei.default={initialInterval:Hh,randomizationFactor:kh,multiplier:Vh,maxInterval:$h,maxElapsedTime:Kh,maxIterations:Gh,date:Date};function*Tw(t=Ei.default){let e=new Ei(t),r=e.next();for(;r;)yield r,r=e.next()}Ur.exponentialBackoff=Tw});var ol=L(Ce=>{"use strict";var zh=Ce&&Ce.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Aw=Ce&&Ce.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Dh=Ce&&Ce.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&zh(e,t,r);return Aw(e,t),e},Sw=Ce&&Ce.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&zh(e,t,r)},Xt=Ce&&Ce.__classPrivateFieldSet||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},ce=Ce&&Ce.__classPrivateFieldGet||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)},Cr,Fr,kn,Ai,ua,ds,mr,la,gr,qn,fa,vi,Ti,jn,Vn,Zh,da,ha;Object.defineProperty(Ce,"__esModule",{value:!0});Ce.HttpAgent=Ce.IdentityInvalidError=Ce.MANAGEMENT_CANISTER_ID=Ce.IC_ROOT_KEY=Ce.RequestStatusResponseStatus=Ce.makeNonce=void 0;var sr=Nt(),Hn=ii(),Bw=Jc(),_n=Dh(Ji()),aa=Di(),nl=Yt(),Mr=To(),il=Li(),Wh=cu(),Ow=as(),xi=os(),Nw=Lu(),Pw=Mh(),Rw=tl(),Iw=Vo(),Uw=jh(),Fw=Yh();Sw(To(),Ce);var Mw=Li();Object.defineProperty(Ce,"makeNonce",{enumerable:!0,get:function(){return Mw.makeNonce}});var Cw;(function(t){t.Received="received",t.Processing="processing",t.Replied="replied",t.Rejected="rejected",t.Unknown="unknown",t.Done="done"})(Cw=Ce.RequestStatusResponseStatus||(Ce.RequestStatusResponseStatus={}));var ca=5*60*1e3;Ce.IC_ROOT_KEY="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae";Ce.MANAGEMENT_CANISTER_ID="aaaaa-aa";var qw="ic0.app",jw=".ic0.app",kw="icp0.io",Vw=".icp0.io",Hw="icp-api.io",$w=".icp-api.io",hs=class extends Hn.AgentError{constructor(e){super(e),this.message=e}},$n=class extends Hn.AgentError{constructor(e){super(e),this.message=e}};Ce.IdentityInvalidError=$n;function Kw(){let t;if(typeof window<"u")if(window.fetch)t=window.fetch.bind(window);else throw new hs("Fetch implementation was not available. You appear to be in a browser context, but window.fetch was not present.");else if(typeof global<"u")if(global.fetch)t=global.fetch.bind(global);else throw new hs("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 hs("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}function Gw(t){let e;if(t!==void 0)!t.match(/^[a-z]+:/)&&typeof window<"u"?e=new URL(window.location.protocol+"//"+t):e=new URL(t);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?e=new URL(`${i.protocol}//${o}${i.port?":"+i.port:""}`):e=new URL("https://icp-api.io")}return e.toString()}var sl=class t{constructor(e={}){var r;Cr.add(this),this.rootKey=(0,nl.fromHex)(Ce.IC_ROOT_KEY),Fr.set(this,void 0),kn.set(this,void 0),Ai.set(this,void 0),ua.set(this,void 0),ds.set(this,0),mr.set(this,void 0),la.set(this,!1),gr.set(this,void 0),qn.set(this,void 0),this._isAgent=!0,this.config={},fa.set(this,0),this.log=new Uw.ObservableLog,vi.set(this,[]),Ti.set(this,[]),jn.set(this,new Pw.ExpirableMap({expirationTime:5*60*1e3})),Vn.set(this,!0),ha.set(this,(s,o)=>{if(ce(this,Vn,"f")===!1)return s;if(!o)throw new xi.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let{status:a,signatures:c=[],requestId:f}=s,d=new TextEncoder().encode("\vic-response");for(let h of c){let{timestamp:S,identity:w}=h,u=sr.Principal.fromUint8Array(w).toText(),g;if(a==="replied"){let{reply:W}=s;g=(0,aa.hashOfMap)({status:a,reply:W,timestamp:BigInt(S),request_id:f})}else if(a==="rejected"){let{reject_code:W,reject_message:T,error_code:C}=s;g=(0,aa.hashOfMap)({status:a,reject_code:W,reject_message:T,error_code:C,timestamp:BigInt(S),request_id:f})}else throw new Error(`Unknown status: ${a}`);let U=(0,nl.concat)(d,new Uint8Array(g)),F=o?.nodeKeys.get(u);if(!F)throw new xi.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let N=Rw.Ed25519PublicKey.fromDer(F).rawKey;if(Nw.ed25519.verify(h.signature,new Uint8Array(U),new Uint8Array(N)))return s;throw new xi.CertificateVerificationError(`Invalid signature from replica ${u} signed query.`)}return s}),this.config=e,Xt(this,kn,e.fetch||Kw()||fetch.bind(global),"f"),Xt(this,Ai,e.fetchOptions,"f"),Xt(this,ua,e.callOptions,"f");let n=Gw(e.host);this.host=new URL(n),e.verifyQuerySignatures!==void 0&&Xt(this,Vn,e.verifyQuerySignatures,"f"),Xt(this,gr,(r=e.retryTimes)!==null&&r!==void 0?r:3,"f");let i=()=>new Fw.ExponentialBackoff({maxIterations:ce(this,gr,"f")});if(Xt(this,qn,e.backoffStrategy||i,"f"),this.host.hostname.endsWith(jw)?this.host.hostname=qw:this.host.hostname.endsWith(Vw)?this.host.hostname=kw:this.host.hostname.endsWith($w)&&(this.host.hostname=Hw),e.credentials){let{name:s,password:o}=e.credentials;Xt(this,mr,`${s}${o?":"+o:""}`,"f")}Xt(this,Fr,Promise.resolve(e.identity||new Bw.AnonymousIdentity),"f"),this.addTransform("update",(0,Mr.makeNonceTransform)(il.makeNonce)),e.useQueryNonces&&this.addTransform("query",(0,Mr.makeNonceTransform)(il.makeNonce)),e.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 ce(this,fa,"f")}static createSync(e={}){return new this(Object.assign({},e))}static async create(e={shouldFetchRootKey:!1}){let r=t.createSync(e),n=[r.syncTime()];return r.host.toString()!=="https://icp-api.io"&&e.shouldFetchRootKey&&n.push(r.fetchRootKey()),await Promise.all(n),r}static async from(e){var r;try{return"config"in e?await t.create(e.config):await t.create({fetch:e._fetch,fetchOptions:e._fetchOptions,callOptions:e._callOptions,host:e._host.toString(),identity:(r=e._identity)!==null&&r!==void 0?r:void 0})}catch{throw new Hn.AgentError("Failed to create agent from provided agent")}}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=ce(this,Ti,"f").findIndex(s=>(s.priority||0)<n);ce(this,Ti,"f").splice(i>=0?i:ce(this,Ti,"f").length,0,Object.assign(r,{priority:n}))}else if(e==="query"){let i=ce(this,vi,"f").findIndex(s=>(s.priority||0)<n);ce(this,vi,"f").splice(i>=0?i:ce(this,vi,"f").length,0,Object.assign(r,{priority:n}))}}async getPrincipal(){if(!ce(this,Fr,"f"))throw new $n("This identity has expired due this application's security policy. Please refresh your authentication.");return(await ce(this,Fr,"f")).getPrincipal()}async call(e,r,n){let i=await(n!==void 0?await n:await ce(this,Fr,"f"));if(!i)throw new $n("This identity has expired due this application's security policy. Please refresh your authentication.");let s=sr.Principal.from(e),o=r.effectiveCanisterId?sr.Principal.from(r.effectiveCanisterId):s,a=i.getPrincipal()||sr.Principal.anonymous(),c=new Mr.Expiry(ca);Math.abs(ce(this,ds,"f"))>1e3*30&&(c=new Mr.Expiry(ca+ce(this,ds,"f")));let f={request_type:il.SubmitRequestType.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"},ce(this,mr,"f")?{Authorization:"Basic "+btoa(ce(this,mr,"f"))}:{})},endpoint:"call",body:f}),h=d.body.nonce?S(d.body.nonce):void 0;f.nonce=h;function S(W){return new Uint8Array(W)}d=await i.transformRequest(d);let w=_n.encode(d.body);this.log.print(`fetching "/api/v2/canister/${o.toText()}/call" with request:`,d);let u=ce(this,qn,"f").call(this),g=ce(this,Cr,"m",da).call(this,{request:()=>ce(this,kn,"f").call(this,""+new URL(`/api/v2/canister/${o.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},ce(this,ua,"f")),d.request),{body:w})),backoff:u,tries:0}),[U,F]=await Promise.all([g,(0,aa.requestIdOf)(f)]),N=await U.arrayBuffer(),V=U.status===200&&N.byteLength>0?_n.decode(N):null;return{requestId:F,response:{ok:U.ok,status:U.status,statusText:U.statusText,body:V,headers:(0,Mr.httpHeadersTransform)(U.headers)},requestDetails:f}}async query(e,r,n){let i=ce(this,qn,"f").call(this),s=r.effectiveCanisterId?sr.Principal.from(r.effectiveCanisterId):sr.Principal.from(e);this.log.print(`ecid ${s.toString()}`),this.log.print(`canisterId ${e.toString()}`);let o=async()=>{let w=await(n!==void 0?await n:await ce(this,Fr,"f"));if(!w)throw new $n("This identity has expired due this application's security policy. Please refresh your authentication.");let u=sr.Principal.from(e),g=w?.getPrincipal()||sr.Principal.anonymous(),U={request_type:"query",canister_id:u,method_name:r.methodName,arg:r.arg,sender:g,ingress_expiry:new Mr.Expiry(ca)},F=await(0,aa.requestIdOf)(U),N=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ce(this,mr,"f")?{Authorization:"Basic "+btoa(ce(this,mr,"f"))}:{})},endpoint:"read",body:U});N=await w?.transformRequest(N);let V=_n.encode(N.body),W={canister:u.toText(),ecid:s,transformedRequest:N,body:V,requestId:F,backoff:i,tries:0};return{requestDetails:U,query:await ce(this,Cr,"m",Zh).call(this,W)}},a=async()=>{if(!ce(this,Vn,"f"))return;let w=ce(this,jn,"f").get(s.toString());return w||(await this.fetchSubnetKeys(s.toString()),ce(this,jn,"f").get(s.toString()))},[c,f]=await Promise.all([o(),a()]),{requestDetails:d,query:h}=c,S=Object.assign(Object.assign({},h),{requestDetails:d});if(this.log.print("Query response:",S),!ce(this,Vn,"f"))return S;try{return ce(this,ha,"f").call(this,S,f)}catch{this.log.warn("Query response verification failed. Retrying with fresh subnet keys."),ce(this,jn,"f").delete(e.toString()),await this.fetchSubnetKeys(s.toString());let u=ce(this,jn,"f").get(e.toString());if(!u)throw new xi.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");return ce(this,ha,"f").call(this,S,u)}}async createReadStateRequest(e,r){let n=await(r!==void 0?await r:await ce(this,Fr,"f"));if(!n)throw new $n("This identity has expired due this application's security policy. Please refresh your authentication.");let i=n?.getPrincipal()||sr.Principal.anonymous(),s=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ce(this,mr,"f")?{Authorization:"Basic "+btoa(ce(this,mr,"f"))}:{})},endpoint:"read_state",body:{request_type:"read_state",paths:e.paths,sender:i,ingress_expiry:new Mr.Expiry(ca)}});return n?.transformRequest(s)}async readState(e,r,n,i){let s=typeof e=="string"?sr.Principal.fromText(e):e,o=i??await this.createReadStateRequest(r,n),a=_n.encode(o.body);this.log.print(`fetching "/api/v2/canister/${s}/read_state" with request:`,o);let c=ce(this,qn,"f").call(this),f=await ce(this,Cr,"m",da).call(this,{request:()=>ce(this,kn,"f").call(this,""+new URL(`/api/v2/canister/${s.toString()}/read_state`,this.host),Object.assign(Object.assign(Object.assign({},ce(this,Ai,"f")),o.request),{body:a})),backoff:c,tries:0});if(!f.ok)throw new Error(`Server returned an error:
30
- Code: ${f.status} (${f.statusText})
31
- Body: ${await f.text()}
32
- `);let d=_n.decode(await f.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),Xt(this,fa,h,"f")),d}async parseTimeFromResponse(e){let r;if(e.certificate){let n=_n.decode(e.certificate);if(n&&"tree"in n)r=n.tree;else throw new Error("Could not decode time from response");let i=(0,xi.lookup_path)(["time"],r);if(i.status!==xi.LookupStatus.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=(0,Iw.decodeTime)((0,nl.bufFromBufLike)(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(e){let r=await Promise.resolve().then(()=>Dh(as())),n=Date.now();try{e||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:e??sr.Principal.from("ryjl3-tyaaa-aaaaa-aaaba-cai"),agent:this,paths:["time"]})).get("time");s&&Xt(this,ds,Number(s)-Number(n),"f")}catch(i){this.log.error("Caught exception while attempting to sync time",i)}}async status(){let e=ce(this,mr,"f")?{Authorization:"Basic "+btoa(ce(this,mr,"f"))}:{};this.log.print('fetching "/api/v2/status"');let r=ce(this,qn,"f").call(this),n=await ce(this,Cr,"m",da).call(this,{backoff:r,request:()=>ce(this,kn,"f").call(this,""+new URL("/api/v2/status",this.host),Object.assign({headers:e},ce(this,Ai,"f"))),tries:0});return _n.decode(await n.arrayBuffer())}async fetchRootKey(){return ce(this,la,"f")||(this.rootKey=(await this.status()).root_key,Xt(this,la,!0,"f")),this.rootKey}invalidateIdentity(){Xt(this,Fr,null,"f")}replaceIdentity(e){Xt(this,Fr,Promise.resolve(e),"f")}async fetchSubnetKeys(e){let r=sr.Principal.from(e),i=(await(0,Ow.request)({canisterId:r,paths:["subnet"],agent:this})).get("subnet");if(i&&typeof i=="object"&&"nodeKeys"in i)return ce(this,jn,"f").set(r.toText(),i),i}_transform(e){let r=Promise.resolve(e);if(e.endpoint==="call")for(let n of ce(this,Ti,"f"))r=r.then(i=>n(i).then(s=>s||i));else for(let n of ce(this,vi,"f"))r=r.then(i=>n(i).then(s=>s||i));return r}};Ce.HttpAgent=sl;Fr=new WeakMap,kn=new WeakMap,Ai=new WeakMap,ua=new WeakMap,ds=new WeakMap,mr=new WeakMap,la=new WeakMap,gr=new WeakMap,qn=new WeakMap,fa=new WeakMap,vi=new WeakMap,Ti=new WeakMap,jn=new WeakMap,Vn=new WeakMap,ha=new WeakMap,Cr=new WeakSet,Zh=async function t(e){var r,n;let{ecid:i,transformedRequest:s,body:o,requestId:a,backoff:c,tries:f}=e,d=f===0?0:c.next();if(this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with tries:`,{tries:f,backoff:c,delay:d}),d===null)throw new Hn.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ce(this,gr,"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 ce(this,kn,"f").call(this,""+new URL(`/api/v2/canister/${i.toString()}/query`,this.host),Object.assign(Object.assign(Object.assign({},ce(this,Ai,"f")),s.request),{body:o}));if(u.status===200){let g=_n.decode(await u.arrayBuffer());h=Object.assign(Object.assign({},g),{httpDetails:{ok:u.ok,status:u.status,statusText:u.statusText,headers:(0,Mr.httpHeadersTransform)(u.headers)},requestId:a})}else throw new Wh.AgentHTTPResponseError(`Gateway returned an error:
30
+ )`}else throw new Error("Invalid tree structure for labeled");case Et.Leaf:{if(t[1]){if(Array.isArray(t[1]))return JSON.stringify(t[1])}else throw new Error("Invalid tree structure for leaf");return`leaf(...${t[1].byteLength} bytes)`}case Et.Pruned:{if(t[1]){if(Array.isArray(t[1]))return JSON.stringify(t[1])}else throw new Error("Invalid tree structure for pruned");return`pruned(${(0,pr.toHex)(new Uint8Array(t[1]))}`}default:return`unknown(${JSON.stringify(t[0])})`}}Oe.hashTreeToString=ea;function W1(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}var zu=class t{constructor(e,r,n,i,s=5){this._rootKey=r,this._canisterId=n,this._blsVerify=i,this._maxAgeInMinutes=s,this.cert=eh.decode(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=K1.blsVerify),new t(e.certificate,e.rootKey,e.canisterId,r,e.maxAgeInMinutes)}lookup(e){return ta(e,this.cert.tree)}lookup_label(e){return this.lookup([e])}async verify(){let e=await ps(this.cert.tree),r=await this._checkDelegationAndGetKey(this.cert.delegation),n=this.cert.signature,i=D1(r),s=(0,pr.concat)(hs("ic-state-root"),e),o=!1,a=Du(this.lookup(["time"]));if(!a)throw new Jr("Certificate does not contain a time");let c=5*60*1e3,f=this._maxAgeInMinutes*60*1e3,d=Date.now(),h=d-f,m=d+c,_=(0,G1.decodeTime)(a);if(_.getTime()<h)throw new Jr(`Certificate is signed more than ${this._maxAgeInMinutes} minutes in the past. Certificate time: `+_.toISOString()+" Current time: "+new Date(d).toISOString());if(_.getTime()>m)throw new Jr("Certificate is signed more than 5 minutes in the future. Certificate time: "+_.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 Jr("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 Jr("Delegation certificates cannot be nested");if(await r.verify(),this._canisterId.toString()!==Y1.MANAGEMENT_CANISTER_ID&&!th({canisterId:this._canisterId,subnetId:Wu.Principal.fromUint8Array(new Uint8Array(e.subnet_id)),tree:r.cert.tree}))throw new Jr(`Canister ${this._canisterId} not in range of delegations for subnet 0x${(0,pr.toHex)(e.subnet_id)}`);let n=Du(r.lookup(["subnet",e.subnet_id,"public_key"]));if(!n)throw new Error(`Could not find subnet key for subnet 0x${(0,pr.toHex)(e.subnet_id)}`);return n}};Oe.Certificate=zu;var ds=(0,pr.fromHex)("308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100"),z1=96;function D1(t){let e=ds.byteLength+z1;if(t.byteLength!==e)throw new TypeError(`BLS DER-encoded public key must be ${e} bytes long`);let r=t.slice(0,ds.byteLength);if(!(0,pr.bufEquals)(r,ds))throw new TypeError(`BLS DER-encoded public key is invalid. Expect the following prefix: ${ds}, but get ${r}`);return t.slice(ds.byteLength)}function Du(t){if(t.status===Ft.Found){if(t.value instanceof ArrayBuffer)return t.value;if(t.value instanceof Uint8Array)return t.value.buffer}}Oe.lookupResultToBuffer=Du;async function ps(t){switch(t[0]){case Et.Empty:return(0,Qo.hash)(hs("ic-hashtree-empty"));case Et.Pruned:return t[1];case Et.Leaf:return(0,Qo.hash)((0,pr.concat)(hs("ic-hashtree-leaf"),t[1]));case Et.Labeled:return(0,Qo.hash)((0,pr.concat)(hs("ic-hashtree-labeled"),t[1],await ps(t[2])));case Et.Fork:return(0,Qo.hash)((0,pr.concat)(hs("ic-hashtree-fork"),await ps(t[1]),await ps(t[2])));default:throw new Error("unreachable")}}Oe.reconstruct=ps;function hs(t){let e=new Uint8Array([t.length]),r=new TextEncoder().encode(t);return(0,pr.concat)(e,r)}var Ft;(function(t){t.Unknown="unknown",t.Absent="absent",t.Found="found"})(Ft=Oe.LookupStatus||(Oe.LookupStatus={}));var Lr;(function(t){t.Less="less",t.Greater="greater"})(Lr||(Lr={}));function ta(t,e){if(t.length===0)switch(e[0]){case Et.Leaf:{if(!e[1])throw new Error("Invalid tree structure for leaf");return e[1]instanceof ArrayBuffer?{status:Ft.Found,value:e[1]}:e[1]instanceof Uint8Array?{status:Ft.Found,value:e[1].buffer}:{status:Ft.Found,value:e[1]}}default:return{status:Ft.Found,value:e}}let r=typeof t[0]=="string"?new TextEncoder().encode(t[0]):t[0],n=ys(r,e);switch(n.status){case Ft.Found:return ta(t.slice(1),n.value);case Lr.Greater:case Lr.Less:return{status:Ft.Absent};default:return n}}Oe.lookup_path=ta;function Zu(t){switch(t[0]){case Et.Empty:return[];case Et.Fork:return Zu(t[1]).concat(Zu(t[2]));default:return[t]}}Oe.flatten_forks=Zu;function ys(t,e){switch(e[0]){case Et.Labeled:return W1(t,e[1])?{status:Lr.Greater}:(0,pr.bufEquals)(t,e[1])?{status:Ft.Found,value:e[2]}:{status:Lr.Less};case Et.Fork:let r=ys(t,e[1]);switch(r.status){case Lr.Greater:{let n=ys(t,e[2]);return n.status===Lr.Less?{status:Ft.Absent}:n}case Ft.Unknown:{let n=ys(t,e[2]);return n.status===Lr.Less?{status:Ft.Unknown}:n}default:return r}case Et.Pruned:return{status:Ft.Unknown};default:return{status:Ft.Absent}}}Oe.find_label=ys;function th(t){let{canisterId:e,subnetId:r,tree:n}=t,i=ta(["subnet",r.toUint8Array(),"canister_ranges"],n);if(i.status!==Ft.Found||!(i.value instanceof ArrayBuffer))throw new Error(`Could not find canister ranges for subnet ${r}`);return eh.decode(i.value).map(c=>[Wu.Principal.fromUint8Array(c[0]),Wu.Principal.fromUint8Array(c[1])]).some(c=>c[0].ltEq(e)&&c[1].gtEq(e))}Oe.check_canister_ranges=th});var ms=Q(ct=>{"use strict";var Z1=ct&&ct.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),X1=ct&&ct.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),J1=ct&&ct.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Z1(e,t,r);return X1(e,t),e};Object.defineProperty(ct,"__esModule",{value:!0});ct.encodePath=ct.fetchNodeKeys=ct.request=ct.CustomPath=void 0;var mn=Tt(),L1=li(),bn=vi(),Q1=Ht(),ih=J1(ss()),rh=Lo(),Xu=class{constructor(e,r,n){this.key=e,this.path=r,this.decodeStrategy=n}};ct.CustomPath=Xu;var ew=async t=>{let{agent:e,paths:r}=t,n=mn.Principal.from(t.canisterId),i=[...new Set(r)],s=i.map(c=>(0,ct.encodePath)(c,n)),o=new Map,a=i.map((c,f)=>(async()=>{var d;try{let h=await e.readState(n,{paths:[s[f]]}),m=await bn.Certificate.create({certificate:h.certificate,rootKey:e.rootKey,canisterId:n}),_=(O,R)=>{if(R==="subnet"){let F=(0,ct.fetchNodeKeys)(h.certificate,n,e.rootKey);return{path:R,data:F}}else return{path:R,data:(0,bn.lookupResultToBuffer)(O.lookup((0,ct.encodePath)(R,n)))}},{path:u,data:T}=_(m,i[f]);if(!T)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,(0,rh.decodeTime)(T));break}case"controllers":{o.set(u,iw(T));break}case"module_hash":{o.set(u,nh(T));break}case"subnet":{o.set(u,T);break}case"candid":{o.set(u,new TextDecoder().decode(T));break}default:if(typeof u!="string"&&"key"in u&&"path"in u)switch(u.decodeStrategy){case"raw":o.set(u.key,T);break;case"leb128":{o.set(u.key,(0,rh.decodeLeb128)(T));break}case"cbor":{o.set(u.key,sh(T));break}case"hex":{o.set(u.key,nh(T));break}case"utf-8":o.set(u.key,nw(T))}}}catch(h){if(!((d=h?.message)===null||d===void 0)&&d.includes("Invalid certificate"))throw new L1.AgentError(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};ct.request=ew;var tw=(t,e,r)=>{if(!e._isPrincipal)throw new Error("Invalid canisterId");let n=ih.decode(new Uint8Array(t)),i=n.tree,s=n.delegation,o;if(s&&s.subnet_id?o=mn.Principal.fromUint8Array(new Uint8Array(s.subnet_id)):!s&&typeof r<"u"?(o=mn.Principal.selfAuthenticating(new Uint8Array(r)),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}):(o=mn.Principal.selfAuthenticating(mn.Principal.fromText("tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe").toUint8Array()),s={subnet_id:o.toUint8Array(),certificate:new ArrayBuffer(0)}),!(0,bn.check_canister_ranges)({canisterId:e,subnetId:o,tree:i}))throw new Error("Canister not in range");let c=(0,bn.lookup_path)(["subnet",s.subnet_id,"node"],i);if(c.status!==bn.LookupStatus.Found)throw new Error("Node not found");if(c.value instanceof ArrayBuffer)throw new Error("Invalid node tree");let f=(0,bn.flatten_forks)(c.value),d=new Map;return f.forEach(h=>{let m=mn.Principal.from(new Uint8Array(h[1])).toText(),_=(0,bn.lookup_path)(["public_key"],h[2]);if(_.status!==bn.LookupStatus.Found)throw new Error("Public key not found");let u=_.value;if(u.byteLength!==44)throw new Error("Invalid public key length");d.set(m,u)}),{subnetId:mn.Principal.fromUint8Array(new Uint8Array(s.subnet_id)).toText(),nodeKeys:d}};ct.fetchNodeKeys=tw;var rw=(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.`)};ct.encodePath=rw;var nh=t=>(0,Q1.toHex)(t),sh=t=>ih.decode(t),nw=t=>new TextDecoder().decode(t),iw=t=>sh(t).map(r=>mn.Principal.fromUint8Array(new Uint8Array(r)))});var Bh=Q(ye=>{"use strict";Object.defineProperty(ye,"__esModule",{value:!0});ye.add5L=ye.add5H=ye.add4H=ye.add4L=ye.add3H=ye.add3L=ye.rotlBL=ye.rotlBH=ye.rotlSL=ye.rotlSH=ye.rotr32L=ye.rotr32H=ye.rotrBL=ye.rotrBH=ye.rotrSL=ye.rotrSH=ye.shrSL=ye.shrSH=ye.toBig=void 0;ye.fromBig=Lu;ye.split=oh;ye.add=wh;var ra=BigInt(2**32-1),Ju=BigInt(32);function Lu(t,e=!1){return e?{h:Number(t&ra),l:Number(t>>Ju&ra)}:{h:Number(t>>Ju&ra)|0,l:Number(t&ra)|0}}function oh(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}=Lu(t[i],e);[r[i],n[i]]=[s,o]}return[r,n]}var ah=(t,e)=>BigInt(t>>>0)<<Ju|BigInt(e>>>0);ye.toBig=ah;var ch=(t,e,r)=>t>>>r;ye.shrSH=ch;var uh=(t,e,r)=>t<<32-r|e>>>r;ye.shrSL=uh;var lh=(t,e,r)=>t>>>r|e<<32-r;ye.rotrSH=lh;var fh=(t,e,r)=>t<<32-r|e>>>r;ye.rotrSL=fh;var dh=(t,e,r)=>t<<64-r|e>>>r-32;ye.rotrBH=dh;var hh=(t,e,r)=>t>>>r-32|e<<64-r;ye.rotrBL=hh;var ph=(t,e)=>e;ye.rotr32H=ph;var yh=(t,e)=>t;ye.rotr32L=yh;var gh=(t,e,r)=>t<<r|e>>>32-r;ye.rotlSH=gh;var mh=(t,e,r)=>e<<r|t>>>32-r;ye.rotlSL=mh;var bh=(t,e,r)=>e<<r-32|t>>>64-r;ye.rotlBH=bh;var _h=(t,e,r)=>t<<r-32|e>>>64-r;ye.rotlBL=_h;function wh(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}var Eh=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0);ye.add3L=Eh;var xh=(t,e,r,n)=>e+r+n+(t/2**32|0)|0;ye.add3H=xh;var vh=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0);ye.add4L=vh;var Th=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0;ye.add4H=Th;var Ah=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0);ye.add5L=Ah;var Sh=(t,e,r,n,i,s)=>e+r+n+i+s+(t/2**32|0)|0;ye.add5H=Sh;var sw={fromBig:Lu,split:oh,toBig:ah,shrSH:ch,shrSL:uh,rotrSH:lh,rotrSL:fh,rotrBH:dh,rotrBL:hh,rotr32H:ph,rotr32L:yh,rotlSH:gh,rotlSL:mh,rotlBH:bh,rotlBL:_h,add:wh,add3L:Eh,add3H:xh,add4L:vh,add4H:Th,add5H:Sh,add5L:Ah};ye.default=sw});var Oh=Q(pt=>{"use strict";Object.defineProperty(pt,"__esModule",{value:!0});pt.sha384=pt.sha512_256=pt.sha512_224=pt.sha512=pt.SHA384=pt.SHA512_256=pt.SHA512_224=pt.SHA512=void 0;var ow=rc(),be=Bh(),oa=Fn(),[aw,cw]=be.default.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))),_n=new Uint32Array(80),wn=new Uint32Array(80),Kn=class extends ow.HashMD{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:r,Bh:n,Bl:i,Ch:s,Cl:o,Dh:a,Dl:c,Eh:f,El:d,Fh:h,Fl:m,Gh:_,Gl:u,Hh:T,Hl:O}=this;return[e,r,n,i,s,o,a,c,f,d,h,m,_,u,T,O]}set(e,r,n,i,s,o,a,c,f,d,h,m,_,u,T,O){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=s|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=d|0,this.Fh=h|0,this.Fl=m|0,this.Gh=_|0,this.Gl=u|0,this.Hh=T|0,this.Hl=O|0}process(e,r){for(let M=0;M<16;M++,r+=4)_n[M]=e.getUint32(r),wn[M]=e.getUint32(r+=4);for(let M=16;M<80;M++){let K=_n[M-15]|0,x=wn[M-15]|0,$=be.default.rotrSH(K,x,1)^be.default.rotrSH(K,x,8)^be.default.shrSH(K,x,7),W=be.default.rotrSL(K,x,1)^be.default.rotrSL(K,x,8)^be.default.shrSL(K,x,7),D=_n[M-2]|0,j=wn[M-2]|0,ie=be.default.rotrSH(D,j,19)^be.default.rotrBH(D,j,61)^be.default.shrSH(D,j,6),ee=be.default.rotrSL(D,j,19)^be.default.rotrBL(D,j,61)^be.default.shrSL(D,j,6),ne=be.default.add4L(W,ee,wn[M-7],wn[M-16]),w=be.default.add4H(ne,$,ie,_n[M-7],_n[M-16]);_n[M]=w|0,wn[M]=ne|0}let{Ah:n,Al:i,Bh:s,Bl:o,Ch:a,Cl:c,Dh:f,Dl:d,Eh:h,El:m,Fh:_,Fl:u,Gh:T,Gl:O,Hh:R,Hl:F}=this;for(let M=0;M<80;M++){let K=be.default.rotrSH(h,m,14)^be.default.rotrSH(h,m,18)^be.default.rotrBH(h,m,41),x=be.default.rotrSL(h,m,14)^be.default.rotrSL(h,m,18)^be.default.rotrBL(h,m,41),$=h&_^~h&T,W=m&u^~m&O,D=be.default.add5L(F,x,W,cw[M],wn[M]),j=be.default.add5H(D,R,K,$,aw[M],_n[M]),ie=D|0,ee=be.default.rotrSH(n,i,28)^be.default.rotrBH(n,i,34)^be.default.rotrBH(n,i,39),ne=be.default.rotrSL(n,i,28)^be.default.rotrBL(n,i,34)^be.default.rotrBL(n,i,39),w=n&s^n&a^s&a,b=i&o^i&c^o&c;R=T|0,F=O|0,T=_|0,O=u|0,_=h|0,u=m|0,{h,l:m}=be.default.add(f|0,d|0,j|0,ie|0),f=a|0,d=c|0,a=s|0,c=o|0,s=n|0,o=i|0;let B=be.default.add3L(ie,ne,b);n=be.default.add3H(B,j,ee,w),i=B|0}({h:n,l:i}=be.default.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:s,l:o}=be.default.add(this.Bh|0,this.Bl|0,s|0,o|0),{h:a,l:c}=be.default.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:d}=be.default.add(this.Dh|0,this.Dl|0,f|0,d|0),{h,l:m}=be.default.add(this.Eh|0,this.El|0,h|0,m|0),{h:_,l:u}=be.default.add(this.Fh|0,this.Fl|0,_|0,u|0),{h:T,l:O}=be.default.add(this.Gh|0,this.Gl|0,T|0,O|0),{h:R,l:F}=be.default.add(this.Hh|0,this.Hl|0,R|0,F|0),this.set(n,i,s,o,a,c,f,d,h,m,_,u,T,O,R,F)}roundClean(){_n.fill(0),wn.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)}};pt.SHA512=Kn;var na=class extends Kn{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}};pt.SHA512_224=na;var ia=class extends Kn{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}};pt.SHA512_256=ia;var sa=class extends Kn{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}};pt.SHA384=sa;pt.sha512=(0,oa.wrapConstructor)(()=>new Kn);pt.sha512_224=(0,oa.wrapConstructor)(()=>new na);pt.sha512_256=(0,oa.wrapConstructor)(()=>new ia);pt.sha384=(0,oa.wrapConstructor)(()=>new sa)});var Rh=Q(el=>{"use strict";Object.defineProperty(el,"__esModule",{value:!0});el.twistedEdwards=dw;var Qu=qu(),Nh=Ur(),Gt=zt(),Xt=zt(),yr=BigInt(0),Kt=BigInt(1),aa=BigInt(2),uw=BigInt(8),lw={zip215:!0};function fw(t){let e=(0,Qu.validateBasic)(t);return Gt.validateObject(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function dw(t){let e=fw(t),{Fp:r,n,prehash:i,hash:s,randomBytes:o,nByteLength:a,h:c}=e,f=aa<<BigInt(a*8)-Kt,d=r.create,h=(0,Nh.Field)(e.n,e.nBitLength),m=e.uvRatio||((S,N)=>{try{return{isValid:!0,value:r.sqrt(S*r.inv(N))}}catch{return{isValid:!1,value:yr}}}),_=e.adjustScalarBytes||(S=>S),u=e.domain||((S,N,H)=>{if((0,Xt.abool)("phflag",H),N.length||H)throw new Error("Contexts/pre-hash are not supported");return S});function T(S,N){Gt.aInRange("coordinate "+S,N,yr,f)}function O(S){if(!(S instanceof M))throw new Error("ExtendedPoint expected")}let R=(0,Xt.memoized)((S,N)=>{let{ex:H,ey:Z,ez:ae}=S,oe=S.is0();N==null&&(N=oe?uw:r.inv(ae));let z=d(H*N),U=d(Z*N),p=d(ae*N);if(oe)return{x:yr,y:Kt};if(p!==Kt)throw new Error("invZ was invalid");return{x:z,y:U}}),F=(0,Xt.memoized)(S=>{let{a:N,d:H}=e;if(S.is0())throw new Error("bad point: ZERO");let{ex:Z,ey:ae,ez:oe,et:z}=S,U=d(Z*Z),p=d(ae*ae),J=d(oe*oe),re=d(J*J),fe=d(U*N),L=d(J*d(fe+p)),l=d(re+d(H*d(U*p)));if(L!==l)throw new Error("bad point: equation left != right (1)");let y=d(Z*ae),g=d(oe*z);if(y!==g)throw new Error("bad point: equation left != right (2)");return!0});class M{constructor(N,H,Z,ae){this.ex=N,this.ey=H,this.ez=Z,this.et=ae,T("x",N),T("y",H),T("z",Z),T("t",ae),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(N){if(N instanceof M)throw new Error("extended point not allowed");let{x:H,y:Z}=N||{};return T("x",H),T("y",Z),new M(H,Z,Kt,d(H*Z))}static normalizeZ(N){let H=r.invertBatch(N.map(Z=>Z.ez));return N.map((Z,ae)=>Z.toAffine(H[ae])).map(M.fromAffine)}static msm(N,H){return(0,Qu.pippenger)(M,h,N,H)}_setWindowSize(N){$.setWindowSize(this,N)}assertValidity(){F(this)}equals(N){O(N);let{ex:H,ey:Z,ez:ae}=this,{ex:oe,ey:z,ez:U}=N,p=d(H*U),J=d(oe*ae),re=d(Z*U),fe=d(z*ae);return p===J&&re===fe}is0(){return this.equals(M.ZERO)}negate(){return new M(d(-this.ex),this.ey,this.ez,d(-this.et))}double(){let{a:N}=e,{ex:H,ey:Z,ez:ae}=this,oe=d(H*H),z=d(Z*Z),U=d(aa*d(ae*ae)),p=d(N*oe),J=H+Z,re=d(d(J*J)-oe-z),fe=p+z,L=fe-U,l=p-z,y=d(re*L),g=d(fe*l),I=d(re*l),A=d(L*fe);return new M(y,g,A,I)}add(N){O(N);let{a:H,d:Z}=e,{ex:ae,ey:oe,ez:z,et:U}=this,{ex:p,ey:J,ez:re,et:fe}=N;if(H===BigInt(-1)){let X=d((oe-ae)*(J+p)),te=d((oe+ae)*(J-p)),de=d(te-X);if(de===yr)return this.double();let _e=d(z*aa*fe),Fe=d(U*aa*re),$e=Fe+_e,me=te+X,he=Fe-_e,Xe=d($e*de),Er=d(me*he),Kr=d($e*he),In=d(de*me);return new M(Xe,Er,In,Kr)}let L=d(ae*p),l=d(oe*J),y=d(U*Z*fe),g=d(z*re),I=d((ae+oe)*(p+J)-L-l),A=g-y,P=g+y,k=d(l-H*L),E=d(I*A),q=d(P*k),V=d(I*k),C=d(A*P);return new M(E,q,C,V)}subtract(N){return this.add(N.negate())}wNAF(N){return $.wNAFCached(this,N,M.normalizeZ)}multiply(N){let H=N;Gt.aInRange("scalar",H,Kt,n);let{p:Z,f:ae}=this.wNAF(H);return M.normalizeZ([Z,ae])[0]}multiplyUnsafe(N){let H=N;return Gt.aInRange("scalar",H,yr,n),H===yr?x:this.equals(x)||H===Kt?this:this.equals(K)?this.wNAF(H).p:$.unsafeLadder(this,H)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return $.unsafeLadder(this,n).is0()}toAffine(N){return R(this,N)}clearCofactor(){let{h:N}=e;return N===Kt?this:this.multiplyUnsafe(N)}static fromHex(N,H=!1){let{d:Z,a:ae}=e,oe=r.BYTES;N=(0,Xt.ensureBytes)("pointHex",N,oe),(0,Xt.abool)("zip215",H);let z=N.slice(),U=N[oe-1];z[oe-1]=U&-129;let p=Gt.bytesToNumberLE(z),J=H?f:r.ORDER;Gt.aInRange("pointHex.y",p,yr,J);let re=d(p*p),fe=d(re-Kt),L=d(Z*re-ae),{isValid:l,value:y}=m(fe,L);if(!l)throw new Error("Point.fromHex: invalid y coordinate");let g=(y&Kt)===Kt,I=(U&128)!==0;if(!H&&y===yr&&I)throw new Error("Point.fromHex: x=0 and x_0=1");return I!==g&&(y=d(-y)),M.fromAffine({x:y,y:p})}static fromPrivateKey(N){return j(N).point}toRawBytes(){let{x:N,y:H}=this.toAffine(),Z=Gt.numberToBytesLE(H,r.BYTES);return Z[Z.length-1]|=N&Kt?128:0,Z}toHex(){return Gt.bytesToHex(this.toRawBytes())}}M.BASE=new M(e.Gx,e.Gy,Kt,d(e.Gx*e.Gy)),M.ZERO=new M(yr,Kt,Kt,yr);let{BASE:K,ZERO:x}=M,$=(0,Qu.wNAF)(M,a*8);function W(S){return(0,Nh.mod)(S,n)}function D(S){return W(Gt.bytesToNumberLE(S))}function j(S){let N=a;S=(0,Xt.ensureBytes)("private key",S,N);let H=(0,Xt.ensureBytes)("hashed private key",s(S),2*N),Z=_(H.slice(0,N)),ae=H.slice(N,2*N),oe=D(Z),z=K.multiply(oe),U=z.toRawBytes();return{head:Z,prefix:ae,scalar:oe,point:z,pointBytes:U}}function ie(S){return j(S).pointBytes}function ee(S=new Uint8Array,...N){let H=Gt.concatBytes(...N);return D(s(u(H,(0,Xt.ensureBytes)("context",S),!!i)))}function ne(S,N,H={}){S=(0,Xt.ensureBytes)("message",S),i&&(S=i(S));let{prefix:Z,scalar:ae,pointBytes:oe}=j(N),z=ee(H.context,Z,S),U=K.multiply(z).toRawBytes(),p=ee(H.context,U,oe,S),J=W(z+p*ae);Gt.aInRange("signature.s",J,yr,n);let re=Gt.concatBytes(U,Gt.numberToBytesLE(J,r.BYTES));return(0,Xt.ensureBytes)("result",re,a*2)}let w=lw;function b(S,N,H,Z=w){let{context:ae,zip215:oe}=Z,z=r.BYTES;S=(0,Xt.ensureBytes)("signature",S,2*z),N=(0,Xt.ensureBytes)("message",N),oe!==void 0&&(0,Xt.abool)("zip215",oe),i&&(N=i(N));let U=Gt.bytesToNumberLE(S.slice(z,2*z)),p,J,re;try{p=M.fromHex(H,oe),J=M.fromHex(S.slice(0,z),oe),re=K.multiplyUnsafe(U)}catch{return!1}if(!oe&&p.isSmallOrder())return!1;let fe=ee(ae,J.toRawBytes(),p.toRawBytes(),N);return J.add(p.multiplyUnsafe(fe)).subtract(re).clearCofactor().equals(M.ZERO)}return K._setWindowSize(8),{CURVE:e,getPublicKey:ie,sign:ne,verify:b,ExtendedPoint:M,utils:{getExtendedPublicKey:j,randomPrivateKey:()=>o(r.BYTES),precompute(S=8,N=M.BASE){return N._setWindowSize(S),N.multiply(BigInt(3)),N}}}}});var Ih=Q(rl=>{"use strict";Object.defineProperty(rl,"__esModule",{value:!0});rl.montgomery=pw;var Ph=Ur(),En=zt(),Ti=BigInt(0),tl=BigInt(1);function hw(t){return(0,En.validateObject)(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function pw(t){let e=hw(t),{P:r}=e,n=F=>(0,Ph.mod)(F,r),i=e.montgomeryBits,s=Math.ceil(i/8),o=e.nByteLength,a=e.adjustScalarBytes||(F=>F),c=e.powPminus2||(F=>(0,Ph.pow)(F,r-BigInt(2),r));function f(F,M,K){let x=n(F*(M-K));return M=n(M-x),K=n(K+x),[M,K]}let d=(e.a-BigInt(2))/BigInt(4);function h(F,M){(0,En.aInRange)("u",F,Ti,r),(0,En.aInRange)("scalar",M,Ti,r);let K=M,x=F,$=tl,W=Ti,D=F,j=tl,ie=Ti,ee;for(let w=BigInt(i-1);w>=Ti;w--){let b=K>>w&tl;ie^=b,ee=f(ie,$,D),$=ee[0],D=ee[1],ee=f(ie,W,j),W=ee[0],j=ee[1],ie=b;let B=$+W,S=n(B*B),N=$-W,H=n(N*N),Z=S-H,ae=D+j,oe=D-j,z=n(oe*B),U=n(ae*N),p=z+U,J=z-U;D=n(p*p),j=n(x*n(J*J)),$=n(S*H),W=n(Z*(S+n(d*Z)))}ee=f(ie,$,D),$=ee[0],D=ee[1],ee=f(ie,W,j),W=ee[0],j=ee[1];let ne=c(W);return n($*ne)}function m(F){return(0,En.numberToBytesLE)(n(F),s)}function _(F){let M=(0,En.ensureBytes)("u coordinate",F,s);return o===32&&(M[31]&=127),(0,En.bytesToNumberLE)(M)}function u(F){let M=(0,En.ensureBytes)("scalar",F),K=M.length;if(K!==s&&K!==o)throw new Error(`Expected ${s} or ${o} bytes, got ${K}`);return(0,En.bytesToNumberLE)(a(M))}function T(F,M){let K=_(M),x=u(F),$=h(K,x);if($===Ti)throw new Error("Invalid private or public key received");return m($)}let O=m(e.Gu);function R(F){return T(F,O)}return{scalarMult:T,scalarMultBase:R,getSharedSecret:(F,M)=>T(F,M),getPublicKey:F=>R(F),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:O}}});var ll=Q(ge=>{"use strict";Object.defineProperty(ge,"__esModule",{value:!0});ge.hash_to_ristretto255=ge.hashToRistretto255=ge.RistrettoPoint=ge.encodeToCurve=ge.hashToCurve=ge.edwardsToMontgomery=ge.x25519=ge.ed25519ph=ge.ed25519ctx=ge.ed25519=ge.ED25519_TORSION_SUBGROUP=void 0;ge.edwardsToMontgomeryPub=$h;ge.edwardsToMontgomeryPriv=mw;var ua=Oh(),bs=Fn(),al=Rh(),qh=Ko(),Ue=Ur(),yw=Ih(),Gn=zt(),_s=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),sl=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),gw=BigInt(0),Fr=BigInt(1),ca=BigInt(2),Ch=BigInt(3),jh=BigInt(5),cl=BigInt(8);function kh(t){let e=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),s=_s,a=t*t%s*t%s,c=(0,Ue.pow2)(a,ca,s)*a%s,f=(0,Ue.pow2)(c,Fr,s)*t%s,d=(0,Ue.pow2)(f,jh,s)*f%s,h=(0,Ue.pow2)(d,e,s)*d%s,m=(0,Ue.pow2)(h,r,s)*h%s,_=(0,Ue.pow2)(m,n,s)*m%s,u=(0,Ue.pow2)(_,i,s)*_%s,T=(0,Ue.pow2)(u,i,s)*_%s,O=(0,Ue.pow2)(T,e,s)*d%s;return{pow_p_5_8:(0,Ue.pow2)(O,ca,s)*t%s,b2:a}}function Hh(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function ul(t,e){let r=_s,n=(0,Ue.mod)(e*e*e,r),i=(0,Ue.mod)(n*n*e,r),s=kh(t*i).pow_p_5_8,o=(0,Ue.mod)(t*n*s,r),a=(0,Ue.mod)(e*o*o,r),c=o,f=(0,Ue.mod)(o*sl,r),d=a===t,h=a===(0,Ue.mod)(-t,r),m=a===(0,Ue.mod)(-t*sl,r);return d&&(o=c),(h||m)&&(o=f),(0,Ue.isNegativeLE)(o,r)&&(o=(0,Ue.mod)(-o,r)),{isValid:d||h,value:o}}ge.ED25519_TORSION_SUBGROUP=["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"];var ce=(0,Ue.Field)(_s,void 0,!0),ws={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:ce,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:cl,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:ua.sha512,randomBytes:bs.randomBytes,adjustScalarBytes:Hh,uvRatio:ul};ge.ed25519=(0,al.twistedEdwards)(ws);function Vh(t,e,r){if(e.length>255)throw new Error("Context is too big");return(0,bs.concatBytes)((0,bs.utf8ToBytes)("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}ge.ed25519ctx=(0,al.twistedEdwards)({...ws,domain:Vh});ge.ed25519ph=(0,al.twistedEdwards)(Object.assign({},ws,{domain:Vh,prehash:ua.sha512}));ge.x25519=(0,yw.montgomery)({P:_s,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{let e=_s,{pow_p_5_8:r,b2:n}=kh(t);return(0,Ue.mod)((0,Ue.pow2)(r,Ch,e)*n,e)},adjustScalarBytes:Hh,randomBytes:bs.randomBytes});function $h(t){let{y:e}=ge.ed25519.ExtendedPoint.fromHex(t),r=BigInt(1);return ce.toBytes(ce.create((r+e)*ce.inv(r-e)))}ge.edwardsToMontgomery=$h;function mw(t){let e=ws.hash(t.subarray(0,32));return ws.adjustScalarBytes(e).subarray(0,32)}var bw=(ce.ORDER+Ch)/cl,_w=ce.pow(ca,bw),Uh=ce.sqrt(ce.neg(ce.ONE));function ww(t){let e=(ce.ORDER-jh)/cl,r=BigInt(486662),n=ce.sqr(t);n=ce.mul(n,ca);let i=ce.add(n,ce.ONE),s=ce.neg(r),o=ce.sqr(i),a=ce.mul(o,i),c=ce.mul(n,r);c=ce.mul(c,s),c=ce.add(c,o),c=ce.mul(c,s);let f=ce.sqr(a);o=ce.sqr(f),f=ce.mul(f,a),f=ce.mul(f,c),o=ce.mul(o,f);let d=ce.pow(o,e);d=ce.mul(d,f);let h=ce.mul(d,Uh);o=ce.sqr(d),o=ce.mul(o,a);let m=ce.eql(o,c),_=ce.cmov(h,d,m),u=ce.mul(s,n),T=ce.mul(d,t);T=ce.mul(T,_w);let O=ce.mul(T,Uh),R=ce.mul(c,n);o=ce.sqr(T),o=ce.mul(o,a);let F=ce.eql(o,R),M=ce.cmov(O,T,F);o=ce.sqr(_),o=ce.mul(o,a);let K=ce.eql(o,c),x=ce.cmov(u,s,K),$=ce.cmov(M,_,K),W=ce.isOdd($);return $=ce.cmov($,ce.neg($),K!==W),{xMn:x,xMd:i,yMn:$,yMd:Fr}}var Ew=(0,Ue.FpSqrtEven)(ce,ce.neg(BigInt(486664)));function xw(t){let{xMn:e,xMd:r,yMn:n,yMd:i}=ww(t),s=ce.mul(e,i);s=ce.mul(s,Ew);let o=ce.mul(r,n),a=ce.sub(e,r),c=ce.add(e,r),f=ce.mul(o,c),d=ce.eql(f,ce.ZERO);s=ce.cmov(s,ce.ZERO,d),o=ce.cmov(o,ce.ONE,d),a=ce.cmov(a,ce.ONE,d),c=ce.cmov(c,ce.ONE,d);let h=ce.invertBatch([o,c]);return{x:ce.mul(s,h[0]),y:ce.mul(a,h[1])}}var Kh=(0,qh.createHasher)(ge.ed25519.ExtendedPoint,t=>xw(t[0]),{DST:"edwards25519_XMD:SHA-512_ELL2_RO_",encodeDST:"edwards25519_XMD:SHA-512_ELL2_NU_",p:ce.ORDER,m:1,k:128,expand:"xmd",hash:ua.sha512});ge.hashToCurve=Kh.hashToCurve;ge.encodeToCurve=Kh.encodeToCurve;function nl(t){if(!(t instanceof gr))throw new Error("RistrettoPoint expected")}var ol=sl,vw=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),Tw=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),Aw=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Sw=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),Fh=t=>ul(Fr,t),Bw=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),il=t=>ge.ed25519.CURVE.Fp.create((0,Gn.bytesToNumberLE)(t)&Bw);function Mh(t){let{d:e}=ge.ed25519.CURVE,r=ge.ed25519.CURVE.Fp.ORDER,n=ge.ed25519.CURVE.Fp.create,i=n(ol*t*t),s=n((i+Fr)*Aw),o=BigInt(-1),a=n((o-e*i)*n(i+e)),{isValid:c,value:f}=ul(s,a),d=n(f*t);(0,Ue.isNegativeLE)(d,r)||(d=n(-d)),c||(f=d),c||(o=i);let h=n(o*(i-Fr)*Sw-a),m=f*f,_=n((f+f)*a),u=n(h*vw),T=n(Fr-m),O=n(Fr+m);return new ge.ed25519.ExtendedPoint(n(_*O),n(T*u),n(u*O),n(_*T))}var gr=class t{constructor(e){this.ep=e}static fromAffine(e){return new t(ge.ed25519.ExtendedPoint.fromAffine(e))}static hashToCurve(e){e=(0,Gn.ensureBytes)("ristrettoHash",e,64);let r=il(e.slice(0,32)),n=Mh(r),i=il(e.slice(32,64)),s=Mh(i);return new t(n.add(s))}static fromHex(e){e=(0,Gn.ensureBytes)("ristrettoHex",e,32);let{a:r,d:n}=ge.ed25519.CURVE,i=ge.ed25519.CURVE.Fp.ORDER,s=ge.ed25519.CURVE.Fp.create,o="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",a=il(e);if(!(0,Gn.equalBytes)((0,Gn.numberToBytesLE)(a,32),e)||(0,Ue.isNegativeLE)(a,i))throw new Error(o);let c=s(a*a),f=s(Fr+r*c),d=s(Fr-r*c),h=s(f*f),m=s(d*d),_=s(r*n*h-m),{isValid:u,value:T}=Fh(s(_*m)),O=s(T*d),R=s(T*O*_),F=s((a+a)*O);(0,Ue.isNegativeLE)(F,i)&&(F=s(-F));let M=s(f*R),K=s(F*M);if(!u||(0,Ue.isNegativeLE)(K,i)||M===gw)throw new Error(o);return new t(new ge.ed25519.ExtendedPoint(F,M,Fr,K))}toRawBytes(){let{ex:e,ey:r,ez:n,et:i}=this.ep,s=ge.ed25519.CURVE.Fp.ORDER,o=ge.ed25519.CURVE.Fp.create,a=o(o(n+r)*o(n-r)),c=o(e*r),f=o(c*c),{value:d}=Fh(o(a*f)),h=o(d*a),m=o(d*c),_=o(h*m*i),u;if((0,Ue.isNegativeLE)(i*_,s)){let O=o(r*ol),R=o(e*ol);e=O,r=R,u=o(h*Tw)}else u=m;(0,Ue.isNegativeLE)(e*_,s)&&(r=o(-r));let T=o((n-r)*u);return(0,Ue.isNegativeLE)(T,s)&&(T=o(-T)),(0,Gn.numberToBytesLE)(T,32)}toHex(){return(0,Gn.bytesToHex)(this.toRawBytes())}toString(){return this.toHex()}equals(e){nl(e);let{ex:r,ey:n}=this.ep,{ex:i,ey:s}=e.ep,o=ge.ed25519.CURVE.Fp.create,a=o(r*s)===o(n*i),c=o(n*s)===o(r*i);return a||c}add(e){return nl(e),new t(this.ep.add(e.ep))}subtract(e){return nl(e),new t(this.ep.subtract(e.ep))}multiply(e){return new t(this.ep.multiply(e))}multiplyUnsafe(e){return new t(this.ep.multiplyUnsafe(e))}double(){return new t(this.ep.double())}negate(){return new t(this.ep.negate())}};ge.RistrettoPoint=(gr.BASE||(gr.BASE=new gr(ge.ed25519.ExtendedPoint.BASE)),gr.ZERO||(gr.ZERO=new gr(ge.ed25519.ExtendedPoint.ZERO)),gr);var Ow=(t,e)=>{let r=e.DST,n=typeof r=="string"?(0,bs.utf8ToBytes)(r):r,i=(0,qh.expand_message_xmd)(t,n,64,ua.sha512);return gr.hashToCurve(i)};ge.hashToRistretto255=Ow;ge.hash_to_ristretto255=ge.hashToRistretto255});var zh=Q(xn=>{"use strict";var Gh=xn&&xn.__classPrivateFieldSet||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},Mt=xn&&xn.__classPrivateFieldGet||function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Nt,Es,Yh,Wh;Object.defineProperty(xn,"__esModule",{value:!0});xn.ExpirableMap=void 0;var fl=class{constructor(e={}){Nt.set(this,void 0),Es.set(this,void 0),this[Yh]=this.entries.bind(this),this[Wh]="ExpirableMap";let{source:r=[],expirationTime:n=10*60*1e3}=e,i=Date.now();Gh(this,Nt,new Map([...r].map(([s,o])=>[s,{value:o,timestamp:i}])),"f"),Gh(this,Es,n,"f")}prune(){let e=Date.now();for(let[r,n]of Mt(this,Nt,"f").entries())e-n.timestamp>Mt(this,Es,"f")&&Mt(this,Nt,"f").delete(r);return this}set(e,r){this.prune();let n={value:r,timestamp:Date.now()};return Mt(this,Nt,"f").set(e,n),this}get(e){let r=Mt(this,Nt,"f").get(e);if(r!==void 0){if(Date.now()-r.timestamp>Mt(this,Es,"f")){Mt(this,Nt,"f").delete(e);return}return r.value}}clear(){Mt(this,Nt,"f").clear()}entries(){let e=Mt(this,Nt,"f").entries();return function*(){for(let[n,i]of e)yield[n,i.value]}()}values(){let e=Mt(this,Nt,"f").values();return function*(){for(let n of e)yield n.value}()}keys(){return Mt(this,Nt,"f").keys()}forEach(e,r){for(let[n,i]of Mt(this,Nt,"f").entries())e.call(r,i.value,n,this)}has(e){return Mt(this,Nt,"f").has(e)}delete(e){return Mt(this,Nt,"f").delete(e)}get size(){return Mt(this,Nt,"f").size}};xn.ExpirableMap=fl;Nt=new WeakMap,Es=new WeakMap,Yh=Symbol.iterator,Wh=Symbol.toStringTag});var dl=Q(ke=>{"use strict";Object.defineProperty(ke,"__esModule",{value:!0});ke.unwrapDER=ke.wrapDER=ke.SECP256K1_OID=ke.ED25519_OID=ke.DER_COSE_OID=ke.decodeLen=ke.decodeLenBytes=ke.encodeLen=ke.encodeLenBytes=void 0;var Nw=Ht(),Rw=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)")};ke.encodeLenBytes=Rw;var Pw=(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)")};ke.encodeLen=Pw;var Iw=(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)")};ke.decodeLenBytes=Iw;var Uw=(t,e)=>{let r=(0,ke.decodeLenBytes)(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)")};ke.decodeLen=Uw;ke.DER_COSE_OID=Uint8Array.from([48,12,6,10,43,6,1,4,1,131,184,67,1,1]);ke.ED25519_OID=Uint8Array.from([48,5,6,3,43,101,112]);ke.SECP256K1_OID=Uint8Array.from([48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10]);function Fw(t,e){let r=2+(0,ke.encodeLenBytes)(t.byteLength+1),n=e.byteLength+r+t.byteLength,i=0,s=new Uint8Array(1+(0,ke.encodeLenBytes)(n)+n);return s[i++]=48,i+=(0,ke.encodeLen)(s,i,n),s.set(e,i),i+=e.byteLength,s[i++]=3,i+=(0,ke.encodeLen)(s,i,t.byteLength+1),s[i++]=0,s.set(new Uint8Array(t),i),s}ke.wrapDER=Fw;var Mw=(t,e)=>{let r=0,n=(a,c)=>{if(i[r++]!==a)throw new Error("Expected: "+c)},i=new Uint8Array(t);if(n(48,"sequence"),r+=(0,ke.decodeLenBytes)(i,r),!(0,Nw.bufEquals)(i.slice(r,r+e.byteLength),e))throw new Error("Not the expected OID.");r+=e.byteLength,n(3,"bit string");let s=(0,ke.decodeLen)(i,r)-1;r+=(0,ke.decodeLenBytes)(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};ke.unwrapDER=Mw});var hl=Q(vn=>{"use strict";var Dh=vn&&vn.__classPrivateFieldSet||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},Zh=vn&&vn.__classPrivateFieldGet||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)},fa,da;Object.defineProperty(vn,"__esModule",{value:!0});vn.Ed25519PublicKey=void 0;var la=dl(),ha=class t{constructor(e){if(fa.set(this,void 0),da.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");Dh(this,fa,e,"f"),Dh(this,da,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(0,la.wrapDER)(e,la.ED25519_OID).buffer}static derDecode(e){let r=(0,la.unwrapDER)(e,la.ED25519_OID);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return Zh(this,fa,"f")}get derKey(){return Zh(this,da,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};vn.Ed25519PublicKey=ha;fa=new WeakMap,da=new WeakMap;ha.RAW_KEY_LENGTH=32});var Xh=Q(Ai=>{"use strict";Object.defineProperty(Ai,"__esModule",{value:!0});Ai.ObservableLog=Ai.Observable=void 0;var pa=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))}};Ai.Observable=pa;var pl=class extends pa{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)}};Ai.ObservableLog=pl});var np=Q(Cr=>{"use strict";var Mr=Cr&&Cr.__classPrivateFieldSet||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},Rt=Cr&&Cr.__classPrivateFieldGet||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)},qr,ya,ga,ma,ba,_a,wa,Ea,Si;Object.defineProperty(Cr,"__esModule",{value:!0});Cr.exponentialBackoff=Cr.ExponentialBackoff=void 0;var Jh=.5,Lh=1.5,Qh=500,ep=6e4,tp=9e5,rp=10,Bi=class t{constructor(e=t.default){qr.set(this,void 0),ya.set(this,void 0),ga.set(this,void 0),ma.set(this,void 0),ba.set(this,void 0),_a.set(this,void 0),wa.set(this,void 0),Ea.set(this,void 0),Si.set(this,0);let{initialInterval:r=Qh,randomizationFactor:n=Jh,multiplier:i=Lh,maxInterval:s=ep,maxElapsedTime:o=tp,maxIterations:a=rp,date:c=Date}=e;Mr(this,qr,r,"f"),Mr(this,ya,n,"f"),Mr(this,ga,i,"f"),Mr(this,ma,s,"f"),Mr(this,Ea,c,"f"),Mr(this,ba,c.now(),"f"),Mr(this,_a,o,"f"),Mr(this,wa,a,"f")}get ellapsedTimeInMsec(){return Rt(this,Ea,"f").now()-Rt(this,ba,"f")}get currentInterval(){return Rt(this,qr,"f")}get count(){return Rt(this,Si,"f")}get randomValueFromInterval(){let e=Rt(this,ya,"f")*Rt(this,qr,"f"),r=Rt(this,qr,"f")-e,n=Rt(this,qr,"f")+e;return Math.random()*(n-r)+r}incrementCurrentInterval(){var e;return Mr(this,qr,Math.min(Rt(this,qr,"f")*Rt(this,ga,"f"),Rt(this,ma,"f")),"f"),Mr(this,Si,(e=Rt(this,Si,"f"),e++,e),"f"),Rt(this,qr,"f")}next(){return this.ellapsedTimeInMsec>=Rt(this,_a,"f")||Rt(this,Si,"f")>=Rt(this,wa,"f")?null:(this.incrementCurrentInterval(),this.randomValueFromInterval)}};Cr.ExponentialBackoff=Bi;qr=new WeakMap,ya=new WeakMap,ga=new WeakMap,ma=new WeakMap,ba=new WeakMap,_a=new WeakMap,wa=new WeakMap,Ea=new WeakMap,Si=new WeakMap;Bi.default={initialInterval:Qh,randomizationFactor:Jh,multiplier:Lh,maxInterval:ep,maxElapsedTime:tp,maxIterations:rp,date:Date};function*qw(t=Bi.default){let e=new Bi(t),r=e.next();for(;r;)yield r,r=e.next()}Cr.exponentialBackoff=qw});var yl=Q(xa=>{"use strict";Object.defineProperty(xa,"__esModule",{value:!0});xa.DEFAULT_INGRESS_EXPIRY_DELTA_IN_MSECS=void 0;xa.DEFAULT_INGRESS_EXPIRY_DELTA_IN_MSECS=5*60*1e3});var wl=Q(qe=>{"use strict";var ip=qe&&qe.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Cw=qe&&qe.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),sp=qe&&qe.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&ip(e,t,r);return Cw(e,t),e},jw=qe&&qe.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&ip(e,t,r)},qt=qe&&qe.__classPrivateFieldSet||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},ue=qe&&qe.__classPrivateFieldGet||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)},kr,jr,An,Pi,xs,vs,mr,Aa,br,Yn,Wn,Ts,Ni,Ri,zn,Dn,op,Sa,Ba;Object.defineProperty(qe,"__esModule",{value:!0});qe.HttpAgent=qe.IdentityInvalidError=qe.MANAGEMENT_CANISTER_ID=qe.IC_ROOT_KEY=qe.RequestStatusResponseStatus=qe.makeNonce=void 0;var ir=Tt(),Qr=li(),kw=hu(),Tn=sp(ss()),va=rs(),gl=Ht(),sr=qo(),ml=os(),bl=Tu(),Hw=ms(),Oi=vi(),Vw=ll(),$w=zh(),Kw=hl(),Gw=Lo(),Yw=Xh(),Ww=np(),zw=yl();jw(qo(),qe);var Dw=os();Object.defineProperty(qe,"makeNonce",{enumerable:!0,get:function(){return Dw.makeNonce}});var Zw;(function(t){t.Received="received",t.Processing="processing",t.Replied="replied",t.Rejected="rejected",t.Unknown="unknown",t.Done="done"})(Zw=qe.RequestStatusResponseStatus||(qe.RequestStatusResponseStatus={}));var Ta=60*1e3;qe.IC_ROOT_KEY="308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae";qe.MANAGEMENT_CANISTER_ID="aaaaa-aa";var Xw="ic0.app",Jw=".ic0.app",Lw="icp0.io",Qw=".icp0.io",e2="icp-api.io",t2=".icp-api.io",As=class extends Qr.AgentError{constructor(e){super(e),this.message=e}},Zn=class extends Qr.AgentError{constructor(e){super(e),this.message=e}};qe.IdentityInvalidError=Zn;function r2(){let t;if(typeof window<"u")if(window.fetch)t=window.fetch.bind(window);else throw new As("Fetch implementation was not available. You appear to be in a browser context, but window.fetch was not present.");else if(typeof global<"u")if(global.fetch)t=global.fetch.bind(global);else throw new As("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 As("Fetch implementation was not available. Please provide fetch to the HttpAgent constructor, or ensure it is available in the window or global context.")}function n2(t){let e;if(t!==void 0)!t.match(/^[a-z]+:/)&&typeof window<"u"?e=new URL(window.location.protocol+"//"+t):e=new URL(t);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?e=new URL(`${i.protocol}//${o}${i.port?":"+i.port:""}`):e=new URL("https://icp-api.io")}return e.toString()}var _l=class t{constructor(e={}){var r;kr.add(this),jr.set(this,void 0),An.set(this,void 0),Pi.set(this,void 0),xs.set(this,void 0),vs.set(this,0),mr.set(this,void 0),Aa.set(this,!1),br.set(this,void 0),Yn.set(this,void 0),Wn.set(this,void 0),this._isAgent=!0,this.config={},Ts.set(this,0),this.log=new Yw.ObservableLog,Ni.set(this,[]),Ri.set(this,[]),zn.set(this,new $w.ExpirableMap({expirationTime:5*60*1e3})),Dn.set(this,!0),Ba.set(this,(s,o)=>{if(ue(this,Dn,"f")===!1)return s;if(!o)throw new Oi.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let{status:a,signatures:c=[],requestId:f}=s,d=new TextEncoder().encode("\vic-response");for(let h of c){let{timestamp:m,identity:_}=h,u=ir.Principal.fromUint8Array(_).toText(),T;if(a==="replied"){let{reply:K}=s;T=(0,va.hashOfMap)({status:a,reply:K,timestamp:BigInt(m),request_id:f})}else if(a==="rejected"){let{reject_code:K,reject_message:x,error_code:$}=s;T=(0,va.hashOfMap)({status:a,reject_code:K,reject_message:x,error_code:$,timestamp:BigInt(m),request_id:f})}else throw new Error(`Unknown status: ${a}`);let O=(0,gl.concat)(d,new Uint8Array(T)),R=o?.nodeKeys.get(u);if(!R)throw new Oi.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");let F=Kw.Ed25519PublicKey.fromDer(R).rawKey;if(Vw.ed25519.verify(h.signature,new Uint8Array(O),new Uint8Array(F)))return s;throw new Oi.CertificateVerificationError(`Invalid signature from replica ${u} signed query.`)}return s}),this.config=e,qt(this,An,e.fetch||r2()||fetch.bind(global),"f"),qt(this,Pi,e.fetchOptions,"f"),qt(this,xs,e.callOptions,"f"),this.rootKey=e.rootKey?e.rootKey:(0,gl.fromHex)(qe.IC_ROOT_KEY);let n=n2(e.host);this.host=new URL(n),e.verifyQuerySignatures!==void 0&&qt(this,Dn,e.verifyQuerySignatures,"f"),qt(this,br,(r=e.retryTimes)!==null&&r!==void 0?r:3,"f");let i=()=>new Ww.ExponentialBackoff({maxIterations:ue(this,br,"f")});if(qt(this,Yn,e.backoffStrategy||i,"f"),this.host.hostname.endsWith(Jw)?this.host.hostname=Xw:this.host.hostname.endsWith(Qw)?this.host.hostname=Lw:this.host.hostname.endsWith(t2)&&(this.host.hostname=e2),e.credentials){let{name:s,password:o}=e.credentials;qt(this,mr,`${s}${o?":"+o:""}`,"f")}if(qt(this,jr,Promise.resolve(e.identity||new kw.AnonymousIdentity),"f"),e.ingressExpiryInMinutes&&e.ingressExpiryInMinutes>5)throw new Qr.AgentError(`The maximum ingress expiry time is 5 minutes. Provided ingress expiry time is ${e.ingressExpiryInMinutes} minutes.`);if(e.ingressExpiryInMinutes&&e.ingressExpiryInMinutes<=0)throw new Qr.AgentError(`Ingress expiry time must be greater than 0. Provided ingress expiry time is ${e.ingressExpiryInMinutes} minutes.`);qt(this,Wn,e.ingressExpiryInMinutes||5,"f"),this.addTransform("update",(0,sr.makeNonceTransform)(ml.makeNonce)),e.useQueryNonces&&this.addTransform("query",(0,sr.makeNonceTransform)(ml.makeNonce)),e.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 ue(this,Ts,"f")}static createSync(e={}){return new this(Object.assign({},e))}static async create(e={shouldFetchRootKey:!1}){let r=t.createSync(e),n=[r.syncTime()];return r.host.toString()!=="https://icp-api.io"&&e.shouldFetchRootKey&&n.push(r.fetchRootKey()),await Promise.all(n),r}static async from(e){var r;try{return"config"in e?await t.create(e.config):await t.create({fetch:e._fetch,fetchOptions:e._fetchOptions,callOptions:e._callOptions,host:e._host.toString(),identity:(r=e._identity)!==null&&r!==void 0?r:void 0})}catch{throw new Qr.AgentError("Failed to create agent from provided agent")}}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=ue(this,Ri,"f").findIndex(s=>(s.priority||0)<n);ue(this,Ri,"f").splice(i>=0?i:ue(this,Ri,"f").length,0,Object.assign(r,{priority:n}))}else if(e==="query"){let i=ue(this,Ni,"f").findIndex(s=>(s.priority||0)<n);ue(this,Ni,"f").splice(i>=0?i:ue(this,Ni,"f").length,0,Object.assign(r,{priority:n}))}}async getPrincipal(){if(!ue(this,jr,"f"))throw new Zn("This identity has expired due this application's security policy. Please refresh your authentication.");return(await ue(this,jr,"f")).getPrincipal()}async call(e,r,n){var i;let s=(i=r.callSync)!==null&&i!==void 0?i:!0,o=await(n!==void 0?await n:await ue(this,jr,"f"));if(!o)throw new Zn("This identity has expired due this application's security policy. Please refresh your authentication.");let a=ir.Principal.from(e),c=r.effectiveCanisterId?ir.Principal.from(r.effectiveCanisterId):a,f=o.getPrincipal()||ir.Principal.anonymous(),d=new sr.Expiry(ue(this,Wn,"f")*Ta);Math.abs(ue(this,vs,"f"))>1e3*30&&(d=new sr.Expiry(ue(this,Wn,"f")*Ta+ue(this,vs,"f")));let h={request_type:ml.SubmitRequestType.Call,canister_id:a,method_name:r.methodName,arg:r.arg,sender:f,ingress_expiry:d},m=await this._transform({request:{body:null,method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ue(this,mr,"f")?{Authorization:"Basic "+btoa(ue(this,mr,"f"))}:{})},endpoint:"call",body:h}),_=m.body.nonce?u(m.body.nonce):void 0;h.nonce=_;function u(R){return new Uint8Array(R)}m=await o.transformRequest(m);let T=Tn.encode(m.body),O=ue(this,Yn,"f").call(this);try{let R=()=>(this.log.print(`fetching "/api/v3/canister/${c.toText()}/call" with request:`,m),ue(this,An,"f").call(this,""+new URL(`/api/v3/canister/${c.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},ue(this,xs,"f")),m.request),{body:T}))),F=()=>(this.log.print(`fetching "/api/v2/canister/${c.toText()}/call" with request:`,m),ue(this,An,"f").call(this,""+new URL(`/api/v2/canister/${c.toText()}/call`,this.host),Object.assign(Object.assign(Object.assign({},ue(this,xs,"f")),m.request),{body:T}))),M=ue(this,kr,"m",Sa).call(this,{request:s?R:F,backoff:O,tries:0}),[K,x]=await Promise.all([M,(0,va.requestIdOf)(h)]),$=await K.arrayBuffer(),W=K.status===200&&$.byteLength>0?Tn.decode($):null;if(W&&"certificate"in W){let D=await this.parseTimeFromResponse({certificate:W.certificate});qt(this,Ts,D,"f")}return{requestId:x,response:{ok:K.ok,status:K.status,statusText:K.statusText,body:W,headers:(0,sr.httpHeadersTransform)(K.headers)},requestDetails:h}}catch(R){if(R.message.includes("v3 api not supported."))return this.log.warn("v3 api not supported. Fall back to v2"),this.call(e,Object.assign(Object.assign({},r),{callSync:!1}),n);throw this.log.error("Error while making call:",R),R}}async query(e,r,n){let i=ue(this,Yn,"f").call(this),s=r.effectiveCanisterId?ir.Principal.from(r.effectiveCanisterId):ir.Principal.from(e);this.log.print(`ecid ${s.toString()}`),this.log.print(`canisterId ${e.toString()}`);let o=async()=>{let _=await(n!==void 0?n:ue(this,jr,"f"));if(!_)throw new Zn("This identity has expired due this application's security policy. Please refresh your authentication.");let u=ir.Principal.from(e),T=_?.getPrincipal()||ir.Principal.anonymous(),O={request_type:"query",canister_id:u,method_name:r.methodName,arg:r.arg,sender:T,ingress_expiry:new sr.Expiry(ue(this,Wn,"f")*Ta)},R=await(0,va.requestIdOf)(O),F=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ue(this,mr,"f")?{Authorization:"Basic "+btoa(ue(this,mr,"f"))}:{})},endpoint:"read",body:O});F=await _?.transformRequest(F);let M=Tn.encode(F.body),K={canister:u.toText(),ecid:s,transformedRequest:F,body:M,requestId:R,backoff:i,tries:0};return{requestDetails:O,query:await ue(this,kr,"m",op).call(this,K)}},a=async()=>{if(!ue(this,Dn,"f"))return;let _=ue(this,zn,"f").get(s.toString());return _||(await this.fetchSubnetKeys(s.toString()),ue(this,zn,"f").get(s.toString()))},[c,f]=await Promise.all([o(),a()]),{requestDetails:d,query:h}=c,m=Object.assign(Object.assign({},h),{requestDetails:d});if(this.log.print("Query response:",m),!ue(this,Dn,"f"))return m;try{return ue(this,Ba,"f").call(this,m,f)}catch{this.log.warn("Query response verification failed. Retrying with fresh subnet keys."),ue(this,zn,"f").delete(e.toString()),await this.fetchSubnetKeys(s.toString());let u=ue(this,zn,"f").get(e.toString());if(!u)throw new Oi.CertificateVerificationError("Invalid signature from replica signed query: no matching node key found.");return ue(this,Ba,"f").call(this,m,u)}}async createReadStateRequest(e,r){let n=await(r!==void 0?await r:await ue(this,jr,"f"));if(!n)throw new Zn("This identity has expired due this application's security policy. Please refresh your authentication.");let i=n?.getPrincipal()||ir.Principal.anonymous(),s=await this._transform({request:{method:"POST",headers:Object.assign({"Content-Type":"application/cbor"},ue(this,mr,"f")?{Authorization:"Basic "+btoa(ue(this,mr,"f"))}:{})},endpoint:"read_state",body:{request_type:"read_state",paths:e.paths,sender:i,ingress_expiry:new sr.Expiry(ue(this,Wn,"f")*Ta)}});return n?.transformRequest(s)}async readState(e,r,n,i){let s=typeof e=="string"?ir.Principal.fromText(e):e,o=i??await this.createReadStateRequest(r,n),a=Object.assign(Object.assign({},o.body),{ingress_expiry:new sr.Expiry(zw.DEFAULT_INGRESS_EXPIRY_DELTA_IN_MSECS)}),c=Tn.encode(a);this.log.print(`fetching "/api/v2/canister/${s}/read_state" with request:`,o);let f=ue(this,Yn,"f").call(this);try{let d=await ue(this,kr,"m",Sa).call(this,{request:()=>ue(this,An,"f").call(this,""+new URL(`/api/v2/canister/${s.toString()}/read_state`,this.host),Object.assign(Object.assign(Object.assign({},ue(this,Pi,"f")),o.request),{body:c})),backoff:f,tries:0});if(!d.ok)throw new Error(`Server returned an error:
31
+ Code: ${d.status} (${d.statusText})
32
+ Body: ${await d.text()}
33
+ `);let h=Tn.decode(await d.arrayBuffer());this.log.print("Read state response:",h);let m=await this.parseTimeFromResponse(h);return m>0&&(this.log.print("Read state response time:",m),qt(this,Ts,m,"f")),h}catch(d){throw this.log.error("Caught exception while attempting to read state",d),d}}async parseTimeFromResponse(e){let r;if(e.certificate){let n=Tn.decode(e.certificate);if(n&&"tree"in n)r=n.tree;else throw new Error("Could not decode time from response");let i=(0,Oi.lookup_path)(["time"],r);if(i.status!==Oi.LookupStatus.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=(0,Gw.decodeTime)((0,gl.bufFromBufLike)(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(e){let r=await Promise.resolve().then(()=>sp(ms())),n=Date.now();try{e||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:e??ir.Principal.from("ryjl3-tyaaa-aaaaa-aaaba-cai"),agent:this,paths:["time"]})).get("time");s&&qt(this,vs,Number(s)-Number(n),"f")}catch(i){this.log.error("Caught exception while attempting to sync time",i)}}async status(){let e=ue(this,mr,"f")?{Authorization:"Basic "+btoa(ue(this,mr,"f"))}:{};this.log.print('fetching "/api/v2/status"');let r=ue(this,Yn,"f").call(this),n=await ue(this,kr,"m",Sa).call(this,{backoff:r,request:()=>ue(this,An,"f").call(this,""+new URL("/api/v2/status",this.host),Object.assign({headers:e},ue(this,Pi,"f"))),tries:0});return Tn.decode(await n.arrayBuffer())}async fetchRootKey(){if(!ue(this,Aa,"f")){let e=await this.status();this.rootKey=e.root_key,qt(this,Aa,!0,"f")}return this.rootKey}invalidateIdentity(){qt(this,jr,null,"f")}replaceIdentity(e){qt(this,jr,Promise.resolve(e),"f")}async fetchSubnetKeys(e){let r=ir.Principal.from(e),i=(await(0,Hw.request)({canisterId:r,paths:["subnet"],agent:this})).get("subnet");if(i&&typeof i=="object"&&"nodeKeys"in i)return ue(this,zn,"f").set(r.toText(),i),i}_transform(e){let r=Promise.resolve(e);if(e.endpoint==="call")for(let n of ue(this,Ri,"f"))r=r.then(i=>n(i).then(s=>s||i));else for(let n of ue(this,Ni,"f"))r=r.then(i=>n(i).then(s=>s||i));return r}};qe.HttpAgent=_l;jr=new WeakMap,An=new WeakMap,Pi=new WeakMap,xs=new WeakMap,vs=new WeakMap,mr=new WeakMap,Aa=new WeakMap,br=new WeakMap,Yn=new WeakMap,Wn=new WeakMap,Ts=new WeakMap,Ni=new WeakMap,Ri=new WeakMap,zn=new WeakMap,Dn=new WeakMap,Ba=new WeakMap,kr=new WeakSet,op=async function t(e){var r,n;let{ecid:i,transformedRequest:s,body:o,requestId:a,backoff:c,tries:f}=e,d=f===0?0:c.next();if(this.log.print(`fetching "/api/v2/canister/${i.toString()}/query" with tries:`,{tries:f,backoff:c,delay:d}),d===null)throw new Qr.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ue(this,br,"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 ue(this,An,"f").call(this,""+new URL(`/api/v2/canister/${i.toString()}/query`,this.host),Object.assign(Object.assign(Object.assign({},ue(this,Pi,"f")),s.request),{body:o}));if(u.status===200){let T=Tn.decode(await u.arrayBuffer());h=Object.assign(Object.assign({},T),{httpDetails:{ok:u.ok,status:u.status,statusText:u.statusText,headers:(0,sr.httpHeadersTransform)(u.headers)},requestId:a})}else throw new bl.AgentHTTPResponseError(`Gateway returned an error:
33
34
  Code: ${u.status} (${u.statusText})
34
35
  Body: ${await u.text()}
35
- `,{ok:u.ok,status:u.status,statusText:u.statusText,headers:(0,Mr.httpHeadersTransform)(u.headers)})}catch(u){if(f<ce(this,gr,"f"))return this.log.warn(`Caught exception while attempting to make query:
36
+ `,{ok:u.ok,status:u.status,statusText:u.statusText,headers:(0,sr.httpHeadersTransform)(u.headers)})}catch(u){if(f<ue(this,br,"f"))return this.log.warn(`Caught exception while attempting to make query:
36
37
  ${u}
37
- Retrying query.`),await ce(this,Cr,"m",t).call(this,Object.assign(Object.assign({},e),{tries:f+1}));throw u}let S=(n=(r=h.signatures)===null||r===void 0?void 0:r[0])===null||n===void 0?void 0:n.timestamp;if(!ce(this,Vn,"f"))return h;if(!S)throw new Error("Timestamp not found in query response. This suggests a malformed or malicious response.");let w=Number(BigInt(S)/BigInt(1e6));if(this.log.print("watermark and timestamp",{waterMark:this.waterMark,timestamp:w}),Number(this.waterMark)>w){let u=new Hn.AgentError("Timestamp is below the watermark. Retrying query.");if(this.log.error("Timestamp is below",u,{timestamp:S,waterMark:this.waterMark}),f<ce(this,gr,"f"))return await ce(this,Cr,"m",t).call(this,Object.assign(Object.assign({},e),{tries:f+1}));throw new Hn.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ce(this,gr,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`)}return h},da=async function t(e){let{request:r,backoff:n,tries:i}=e,s=i===0?0:n.next();if(s===null)throw new Hn.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ce(this,gr,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);s>0&&await new Promise(f=>setTimeout(f,s));let o;try{o=await r()}catch(f){if(ce(this,gr,"f")>i)return this.log.warn(`Caught exception while attempting to make request:
38
+ Retrying query.`),await ue(this,kr,"m",t).call(this,Object.assign(Object.assign({},e),{tries:f+1}));throw u}let m=(n=(r=h.signatures)===null||r===void 0?void 0:r[0])===null||n===void 0?void 0:n.timestamp;if(!ue(this,Dn,"f"))return h;if(!m)throw new Error("Timestamp not found in query response. This suggests a malformed or malicious response.");let _=Number(BigInt(m)/BigInt(1e6));if(this.log.print("watermark and timestamp",{waterMark:this.waterMark,timestamp:_}),Number(this.waterMark)>_){let u=new Qr.AgentError("Timestamp is below the watermark. Retrying query.");if(this.log.error("Timestamp is below",u,{timestamp:m,waterMark:this.waterMark}),f<ue(this,br,"f"))return await ue(this,kr,"m",t).call(this,Object.assign(Object.assign({},e),{tries:f+1}));throw new Qr.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ue(this,br,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`)}return h},Sa=async function t(e){let{request:r,backoff:n,tries:i}=e,s=i===0?0:n.next();if(s===null)throw new Qr.AgentError(`Timestamp failed to pass the watermark after retrying the configured ${ue(this,br,"f")} times. We cannot guarantee the integrity of the response since it could be a replay attack.`);s>0&&await new Promise(f=>setTimeout(f,s));let o;try{o=await r()}catch(f){if(ue(this,br,"f")>i)return this.log.warn(`Caught exception while attempting to make request:
38
39
  ${f}
39
- Retrying request.`),await ce(this,Cr,"m",t).call(this,{request:r,backoff:n,tries:i+1});throw f}if(o.ok)return o;let a=await o.clone().text(),c=`Server returned an error:
40
+ Retrying request.`),await ue(this,kr,"m",t).call(this,{request:r,backoff:n,tries:i+1});throw f}if(o.ok)return o;let a=await o.clone().text(),c=`Server returned an error:
40
41
  Code: ${o.status} (${o.statusText})
41
42
  Body: ${a}
42
- `;if(i<ce(this,gr,"f"))return await ce(this,Cr,"m",t).call(this,{request:r,backoff:n,tries:i+1});throw new Wh.AgentHTTPResponseError(c,{ok:o.ok,status:o.status,statusText:o.statusText,headers:(0,Mr.httpHeadersTransform)(o.headers)})}});var Xh=L(Xr=>{"use strict";Object.defineProperty(Xr,"__esModule",{value:!0});Xr.ProxyAgent=Xr.ProxyStubAgent=Xr.ProxyMessageKind=void 0;var Yw=Nt(),Je;(function(t){t.Error="err",t.GetPrincipal="gp",t.GetPrincipalResponse="gpr",t.Query="q",t.QueryResponse="qr",t.Call="c",t.CallResponse="cr",t.ReadState="rs",t.ReadStateResponse="rsr",t.Status="s",t.StatusResponse="sr"})(Je=Xr.ProxyMessageKind||(Xr.ProxyMessageKind={}));var al=class{constructor(e,r){this._frontend=e,this._agent=r}onmessage(e){switch(e.type){case Je.GetPrincipal:this._agent.getPrincipal().then(r=>{this._frontend({id:e.id,type:Je.GetPrincipalResponse,response:r.toText()})});break;case Je.Query:this._agent.query(...e.args).then(r=>{this._frontend({id:e.id,type:Je.QueryResponse,response:r})});break;case Je.Call:this._agent.call(...e.args).then(r=>{this._frontend({id:e.id,type:Je.CallResponse,response:r})});break;case Je.ReadState:this._agent.readState(...e.args).then(r=>{this._frontend({id:e.id,type:Je.ReadStateResponse,response:r})});break;case Je.Status:this._agent.status().then(r=>{this._frontend({id:e.id,type:Je.StatusResponse,response:r})});break;default:throw new Error(`Invalid message received: ${JSON.stringify(e)}`)}}};Xr.ProxyStubAgent=al;var cl=class{constructor(e){this._backend=e,this._nextId=0,this._pendingCalls=new Map,this.rootKey=null}onmessage(e){let r=e.id,n=this._pendingCalls.get(r);if(!n)throw new Error("A proxy get the same message twice...");this._pendingCalls.delete(r);let[i,s]=n;switch(e.type){case Je.Error:return s(e.error);case Je.GetPrincipalResponse:case Je.CallResponse:case Je.QueryResponse:case Je.ReadStateResponse:case Je.StatusResponse:return i(e.response);default:throw new Error(`Invalid message being sent to ProxyAgent: ${JSON.stringify(e)}`)}}async getPrincipal(){return this._sendAndWait({id:this._nextId++,type:Je.GetPrincipal}).then(e=>{if(typeof e!="string")throw new Error("Invalid principal received.");return Yw.Principal.fromText(e)})}readState(e,r){return this._sendAndWait({id:this._nextId++,type:Je.ReadState,args:[e.toString(),r]})}call(e,r){return this._sendAndWait({id:this._nextId++,type:Je.Call,args:[e.toString(),r]})}status(){return this._sendAndWait({id:this._nextId++,type:Je.Status})}query(e,r){return this._sendAndWait({id:this._nextId++,type:Je.Query,args:[e.toString(),r]})}async _sendAndWait(e){return new Promise((r,n)=>{this._pendingCalls.set(e.id,[r,n]),this._backend(e)})}async fetchRootKey(){let e=(await this.status()).root_key;return this.rootKey=e,e}};Xr.ProxyAgent=cl});var ya=L(or=>{"use strict";var Ww=or&&or.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),pa=or&&or.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Ww(e,t,r)};Object.defineProperty(or,"__esModule",{value:!0});or.getDefaultAgent=void 0;pa(Gf(),or);pa(ol(),or);pa(cu(),or);pa(Xh(),or);function zw(){let t=typeof window>"u"?typeof global>"u"?typeof self>"u"?void 0:self.ic.agent:global.ic.agent:window.ic.agent;if(!t)throw new Error("No Agent could be found.");return t}or.getDefaultAgent=zw});var ul=L(pt=>{"use strict";Object.defineProperty(pt,"__esModule",{value:!0});pt.chain=pt.backoff=pt.timeout=pt.throttle=pt.maxAttempts=pt.conditionalDelay=pt.once=pt.defaultStrategy=void 0;var Jh=Yt(),Dw=5*60*1e3;function Zw(){return rp(Qh(Lh(),1e3),tp(1e3,1.2),ep(Dw))}pt.defaultStrategy=Zw;function Lh(){let t=!0;return async()=>t?(t=!1,!0):!1}pt.once=Lh;function Qh(t,e){return async(r,n,i)=>{if(await t(r,n,i))return new Promise(s=>setTimeout(s,e))}}pt.conditionalDelay=Qh;function Xw(t){let e=t;return async(r,n,i)=>{if(--e<=0)throw new Error(`Failed to retrieve a reply for request after ${t} attempts:
43
- Request ID: ${(0,Jh.toHex)(n)}
43
+ `;if(o.status===404&&o.url.includes("api/v3"))throw new bl.AgentHTTPResponseError("v3 api not supported. Fall back to v2",{ok:o.ok,status:o.status,statusText:o.statusText,headers:(0,sr.httpHeadersTransform)(o.headers)});if(i<ue(this,br,"f"))return await ue(this,kr,"m",t).call(this,{request:r,backoff:n,tries:i+1});throw new bl.AgentHTTPResponseError(c,{ok:o.ok,status:o.status,statusText:o.statusText,headers:(0,sr.httpHeadersTransform)(o.headers)})}});var ap=Q(en=>{"use strict";Object.defineProperty(en,"__esModule",{value:!0});en.ProxyAgent=en.ProxyStubAgent=en.ProxyMessageKind=void 0;var i2=Tt(),Le;(function(t){t.Error="err",t.GetPrincipal="gp",t.GetPrincipalResponse="gpr",t.Query="q",t.QueryResponse="qr",t.Call="c",t.CallResponse="cr",t.ReadState="rs",t.ReadStateResponse="rsr",t.Status="s",t.StatusResponse="sr"})(Le=en.ProxyMessageKind||(en.ProxyMessageKind={}));var El=class{constructor(e,r){this._frontend=e,this._agent=r}onmessage(e){switch(e.type){case Le.GetPrincipal:this._agent.getPrincipal().then(r=>{this._frontend({id:e.id,type:Le.GetPrincipalResponse,response:r.toText()})});break;case Le.Query:this._agent.query(...e.args).then(r=>{this._frontend({id:e.id,type:Le.QueryResponse,response:r})});break;case Le.Call:this._agent.call(...e.args).then(r=>{this._frontend({id:e.id,type:Le.CallResponse,response:r})});break;case Le.ReadState:this._agent.readState(...e.args).then(r=>{this._frontend({id:e.id,type:Le.ReadStateResponse,response:r})});break;case Le.Status:this._agent.status().then(r=>{this._frontend({id:e.id,type:Le.StatusResponse,response:r})});break;default:throw new Error(`Invalid message received: ${JSON.stringify(e)}`)}}};en.ProxyStubAgent=El;var xl=class{constructor(e){this._backend=e,this._nextId=0,this._pendingCalls=new Map,this.rootKey=null}onmessage(e){let r=e.id,n=this._pendingCalls.get(r);if(!n)throw new Error("A proxy get the same message twice...");this._pendingCalls.delete(r);let[i,s]=n;switch(e.type){case Le.Error:return s(e.error);case Le.GetPrincipalResponse:case Le.CallResponse:case Le.QueryResponse:case Le.ReadStateResponse:case Le.StatusResponse:return i(e.response);default:throw new Error(`Invalid message being sent to ProxyAgent: ${JSON.stringify(e)}`)}}async getPrincipal(){return this._sendAndWait({id:this._nextId++,type:Le.GetPrincipal}).then(e=>{if(typeof e!="string")throw new Error("Invalid principal received.");return i2.Principal.fromText(e)})}readState(e,r){return this._sendAndWait({id:this._nextId++,type:Le.ReadState,args:[e.toString(),r]})}call(e,r){return this._sendAndWait({id:this._nextId++,type:Le.Call,args:[e.toString(),r]})}status(){return this._sendAndWait({id:this._nextId++,type:Le.Status})}query(e,r){return this._sendAndWait({id:this._nextId++,type:Le.Query,args:[e.toString(),r]})}async _sendAndWait(e){return new Promise((r,n)=>{this._pendingCalls.set(e.id,[r,n]),this._backend(e)})}async fetchRootKey(){let e=(await this.status()).root_key;return this.rootKey=e,e}};en.ProxyAgent=xl});var gs=Q(or=>{"use strict";var s2=or&&or.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Oa=or&&or.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&s2(e,t,r)};Object.defineProperty(or,"__esModule",{value:!0});or.getDefaultAgent=void 0;Oa(vc(),or);Oa(wl(),or);Oa(Tu(),or);Oa(ap(),or);function o2(){let t=typeof window>"u"?typeof global>"u"?typeof self>"u"?void 0:self.ic.agent:global.ic.agent:window.ic.agent;if(!t)throw new Error("No Agent could be found.");return t}or.getDefaultAgent=o2});var Na=Q(yt=>{"use strict";Object.defineProperty(yt,"__esModule",{value:!0});yt.chain=yt.backoff=yt.timeout=yt.throttle=yt.maxAttempts=yt.conditionalDelay=yt.once=yt.defaultStrategy=void 0;var cp=Ht(),a2=5*60*1e3;function c2(){return hp(lp(up(),1e3),dp(1e3,1.2),fp(a2))}yt.defaultStrategy=c2;function up(){let t=!0;return async()=>t?(t=!1,!0):!1}yt.once=up;function lp(t,e){return async(r,n,i)=>{if(await t(r,n,i))return new Promise(s=>setTimeout(s,e))}}yt.conditionalDelay=lp;function u2(t){let e=t;return async(r,n,i)=>{if(--e<=0)throw new Error(`Failed to retrieve a reply for request after ${t} attempts:
44
+ Request ID: ${(0,cp.toHex)(n)}
44
45
  Request status: ${i}
45
- `)}}pt.maxAttempts=Xw;function Jw(t){return()=>new Promise(e=>setTimeout(e,t))}pt.throttle=Jw;function ep(t){let e=Date.now()+t;return async(r,n,i)=>{if(Date.now()>e)throw new Error(`Request timed out after ${t} msec:
46
- Request ID: ${(0,Jh.toHex)(n)}
46
+ `)}}yt.maxAttempts=u2;function l2(t){return()=>new Promise(e=>setTimeout(e,t))}yt.throttle=l2;function fp(t){let e=Date.now()+t;return async(r,n,i)=>{if(Date.now()>e)throw new Error(`Request timed out after ${t} msec:
47
+ Request ID: ${(0,cp.toHex)(n)}
47
48
  Request status: ${i}
48
- `)}}pt.timeout=ep;function tp(t,e){let r=t;return()=>new Promise(n=>setTimeout(()=>{r*=e,n()},r))}pt.backoff=tp;function rp(...t){return async(e,r,n)=>{for(let i of t)await i(e,r,n)}}pt.chain=rp});var ll=L($t=>{"use strict";var Lw=$t&&$t.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Qw=$t&&$t.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),e2=$t&&$t.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&Lw(e,t,r);return Qw(e,t),e};Object.defineProperty($t,"__esModule",{value:!0});$t.pollForResponse=$t.defaultStrategy=$t.strategy=void 0;var Kn=ya(),ps=os(),np=Yt();$t.strategy=e2(ul());var t2=ul();Object.defineProperty($t,"defaultStrategy",{enumerable:!0,get:function(){return t2.defaultStrategy}});async function ip(t,e,r,n,i,s){var o;let a=[new TextEncoder().encode("request_status"),r],c=i??await((o=t.createReadStateRequest)===null||o===void 0?void 0:o.call(t,{paths:[a]})),f=await t.readState(e,{paths:[a]},void 0,c);if(t.rootKey==null)throw new Error("Agent root key not initialized before polling");let d=await ps.Certificate.create({certificate:f.certificate,rootKey:t.rootKey,canisterId:e,blsVerify:s}),h=(0,ps.lookupResultToBuffer)(d.lookup([...a,new TextEncoder().encode("status")])),S;switch(typeof h>"u"?S=Kn.RequestStatusResponseStatus.Unknown:S=new TextDecoder().decode(h),S){case Kn.RequestStatusResponseStatus.Replied:return{reply:(0,ps.lookupResultToBuffer)(d.lookup([...a,"reply"])),certificate:d};case Kn.RequestStatusResponseStatus.Received:case Kn.RequestStatusResponseStatus.Unknown:case Kn.RequestStatusResponseStatus.Processing:return await n(e,r,S),ip(t,e,r,n,c);case Kn.RequestStatusResponseStatus.Rejected:{let w=new Uint8Array((0,ps.lookupResultToBuffer)(d.lookup([...a,"reject_code"])))[0],u=new TextDecoder().decode((0,ps.lookupResultToBuffer)(d.lookup([...a,"reject_message"])));throw new Error(`Call was rejected:
49
- Request ID: ${(0,np.toHex)(r)}
50
- Reject code: ${w}
49
+ `)}}yt.timeout=fp;function dp(t,e){let r=t;return()=>new Promise(n=>setTimeout(()=>{r*=e,n()},r))}yt.backoff=dp;function hp(...t){return async(e,r,n)=>{for(let i of t)await i(e,r,n)}}yt.chain=hp});var Ra=Q(Yt=>{"use strict";var f2=Yt&&Yt.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),d2=Yt&&Yt.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),h2=Yt&&Yt.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&f2(e,t,r);return d2(e,t),e};Object.defineProperty(Yt,"__esModule",{value:!0});Yt.pollForResponse=Yt.defaultStrategy=Yt.strategy=void 0;var Sn=gs(),Ss=vi(),pp=Ht();Yt.strategy=h2(Na());var p2=Na(),y2=yl(),g2=Na();Object.defineProperty(Yt,"defaultStrategy",{enumerable:!0,get:function(){return g2.defaultStrategy}});async function yp(t,e,r,n=(0,p2.defaultStrategy)(),i,s){var o;let a=[new TextEncoder().encode("request_status"),r],c=i??await((o=t.createReadStateRequest)===null||o===void 0?void 0:o.call(t,{paths:[a]}));c.body.content.ingress_expiry=new Sn.Expiry(y2.DEFAULT_INGRESS_EXPIRY_DELTA_IN_MSECS);let f=await t.readState(e,{paths:[a]},void 0,c);if(t.rootKey==null)throw new Error("Agent root key not initialized before polling");let d=await Ss.Certificate.create({certificate:f.certificate,rootKey:t.rootKey,canisterId:e,blsVerify:s}),h=(0,Ss.lookupResultToBuffer)(d.lookup([...a,new TextEncoder().encode("status")])),m;switch(typeof h>"u"?m=Sn.RequestStatusResponseStatus.Unknown:m=new TextDecoder().decode(h),m){case Sn.RequestStatusResponseStatus.Replied:return{reply:(0,Ss.lookupResultToBuffer)(d.lookup([...a,"reply"])),certificate:d};case Sn.RequestStatusResponseStatus.Received:case Sn.RequestStatusResponseStatus.Unknown:case Sn.RequestStatusResponseStatus.Processing:return await n(e,r,m),yp(t,e,r,n,c,s);case Sn.RequestStatusResponseStatus.Rejected:{let _=new Uint8Array((0,Ss.lookupResultToBuffer)(d.lookup([...a,"reject_code"])))[0],u=new TextDecoder().decode((0,Ss.lookupResultToBuffer)(d.lookup([...a,"reject_message"])));throw new Error(`Call was rejected:
50
+ Request ID: ${(0,pp.toHex)(r)}
51
+ Reject code: ${_}
51
52
  Reject text: ${u}
52
- `)}case Kn.RequestStatusResponseStatus.Done:throw new Error(`Call was marked as done but we never saw the reply:
53
- Request ID: ${(0,np.toHex)(r)}
54
- `)}throw new Error("unreachable")}$t.pollForResponse=ip});var sp=L(fl=>{"use strict";Object.defineProperty(fl,"__esModule",{value:!0});fl.default=({IDL:t})=>{let e=t.Variant({mainnet:t.Null,testnet:t.Null}),r=t.Text,n=t.Record({network:e,address:r,min_confirmations:t.Opt(t.Nat32)}),i=t.Nat64,s=i,o=t.Record({network:e}),a=t.Nat64,c=t.Vec(a),f=t.Record({network:e,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:r}),d=t.Vec(t.Nat8),h=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),S=t.Record({height:t.Nat32,value:i,outpoint:h}),w=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:t.Nat32,tip_block_hash:d,utxos:t.Vec(S)}),u=t.Record({transaction:t.Vec(t.Nat8),network:e}),g=t.Principal,U=t.Record({canister_id:g,num_requested_changes:t.Opt(t.Nat64)}),F=t.Variant({from_user:t.Record({user_id:t.Principal}),from_canister:t.Record({canister_version:t.Opt(t.Nat64),canister_id:t.Principal})}),N=t.Variant({creation:t.Record({controllers:t.Vec(t.Principal)}),code_deployment:t.Record({mode:t.Variant({reinstall:t.Null,upgrade:t.Null,install:t.Null}),module_hash:t.Vec(t.Nat8)}),controllers_change:t.Record({controllers:t.Vec(t.Principal)}),code_uninstall:t.Null}),V=t.Record({timestamp_nanos:t.Nat64,canister_version:t.Nat64,origin:F,details:N}),W=t.Record({controllers:t.Vec(t.Principal),module_hash:t.Opt(t.Vec(t.Nat8)),recent_changes:t.Vec(V),total_num_changes:t.Nat64}),T=t.Record({canister_id:g}),C=t.Variant({controllers:t.Null,public:t.Null}),z=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,log_visibility:C,wasm_memory_limit:t.Nat,memory_allocation:t.Nat,compute_allocation:t.Nat}),D=t.Record({status:t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),memory_size:t.Nat,cycles:t.Nat,settings:z,query_stats:t.Record({response_payload_bytes_total:t.Nat,num_instructions_total:t.Nat,num_calls_total:t.Nat,request_payload_bytes_total:t.Nat}),idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8)),reserved_cycles:t.Nat}),G=t.Record({canister_id:g}),ne=t.Record({freezing_threshold:t.Opt(t.Nat),controllers:t.Opt(t.Vec(t.Principal)),reserved_cycles_limit:t.Opt(t.Nat),log_visibility:t.Opt(C),wasm_memory_limit:t.Opt(t.Nat),memory_allocation:t.Opt(t.Nat),compute_allocation:t.Opt(t.Nat)}),Q=t.Record({settings:t.Opt(ne),sender_canister_version:t.Opt(t.Nat64)}),le=t.Record({canister_id:g}),E=t.Record({canister_id:g}),_=t.Record({canister_id:g}),b=t.Variant({secp256k1:t.Null}),x=t.Record({key_id:t.Record({name:t.Text,curve:b}),canister_id:t.Opt(g),derivation_path:t.Vec(t.Vec(t.Nat8))}),j=t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)}),H=t.Record({canister_id:g}),X=t.Record({idx:t.Nat64,timestamp_nanos:t.Nat64,content:t.Vec(t.Nat8)}),oe=t.Record({canister_log_records:t.Vec(X)}),ae=t.Record({value:t.Text,name:t.Text}),Y=t.Record({status:t.Nat,body:t.Vec(t.Nat8),headers:t.Vec(ae)}),R=t.Record({url:t.Text,method:t.Variant({get:t.Null,head:t.Null,post:t.Null}),max_response_bytes:t.Opt(t.Nat64),body:t.Opt(t.Vec(t.Nat8)),transform:t.Opt(t.Record({function:t.Func([t.Record({context:t.Vec(t.Nat8),response:Y})],[Y],["query"]),context:t.Vec(t.Nat8)})),headers:t.Vec(ae)}),p=t.Variant({reinstall:t.Null,upgrade:t.Opt(t.Record({wasm_memory_persistence:t.Opt(t.Variant({keep:t.Null,replace:t.Null})),skip_pre_upgrade:t.Opt(t.Bool)})),install:t.Null}),ee=t.Record({hash:t.Vec(t.Nat8)}),re=t.Record({arg:t.Vec(t.Nat8),wasm_module_hash:t.Vec(t.Nat8),mode:p,chunk_hashes_list:t.Vec(ee),target_canister:g,store_canister:t.Opt(g),sender_canister_version:t.Opt(t.Nat64)}),de=t.Vec(t.Nat8),J=t.Record({arg:t.Vec(t.Nat8),wasm_module:de,mode:p,canister_id:g,sender_canister_version:t.Opt(t.Nat64)}),l=t.Record({start_at_timestamp_nanos:t.Nat64,subnet_id:t.Principal}),y=t.Record({num_block_failures_total:t.Nat64,node_id:t.Principal,num_blocks_proposed_total:t.Nat64}),m=t.Vec(t.Record({timestamp_nanos:t.Nat64,node_metrics:t.Vec(y)})),P=t.Record({settings:t.Opt(ne),specified_id:t.Opt(g),amount:t.Opt(t.Nat),sender_canister_version:t.Opt(t.Nat64)}),B=t.Record({canister_id:g}),O=t.Record({canister_id:g,amount:t.Nat}),q=t.Vec(t.Nat8),v=t.Record({key_id:t.Record({name:t.Text,curve:b}),derivation_path:t.Vec(t.Vec(t.Nat8)),message_hash:t.Vec(t.Nat8)}),I=t.Record({signature:t.Vec(t.Nat8)}),k=t.Record({canister_id:g}),M=t.Record({canister_id:g}),Z=t.Record({canister_id:g}),te=t.Vec(ee),fe=t.Record({canister_id:g,sender_canister_version:t.Opt(t.Nat64)}),_e=t.Record({canister_id:t.Principal,settings:ne,sender_canister_version:t.Opt(t.Nat64)}),Fe=t.Record({chunk:t.Vec(t.Nat8),canister_id:t.Principal}),$e=ee;return t.Service({bitcoin_get_balance:t.Func([n],[s],[]),bitcoin_get_current_fee_percentiles:t.Func([o],[c],[]),bitcoin_get_utxos:t.Func([f],[w],[]),bitcoin_send_transaction:t.Func([u],[],[]),canister_info:t.Func([U],[W],[]),canister_status:t.Func([T],[D],[]),clear_chunk_store:t.Func([G],[],[]),create_canister:t.Func([Q],[le],[]),delete_canister:t.Func([E],[],[]),deposit_cycles:t.Func([_],[],[]),ecdsa_public_key:t.Func([x],[j],[]),fetch_canister_logs:t.Func([H],[oe],["query"]),http_request:t.Func([R],[Y],[]),install_chunked_code:t.Func([re],[],[]),install_code:t.Func([J],[],[]),node_metrics_history:t.Func([l],[m],[]),provisional_create_canister_with_cycles:t.Func([P],[B],[]),provisional_top_up_canister:t.Func([O],[],[]),raw_rand:t.Func([],[q],[]),sign_with_ecdsa:t.Func([v],[I],[]),start_canister:t.Func([k],[],[]),stop_canister:t.Func([M],[],[]),stored_chunks:t.Func([Z],[te],[]),uninstall_code:t.Func([fe],[],[]),update_settings:t.Func([_e],[],[]),upload_chunk:t.Func([Fe],[$e],[])})}});var _a=L(Ge=>{"use strict";var r2=Ge&&Ge.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Ge,"__esModule",{value:!0});Ge.AdvancedActor=Ge.getManagementCanister=Ge.ACTOR_METHOD_WITH_CERTIFICATE=Ge.ACTOR_METHOD_WITH_HTTP_DETAILS=Ge.Actor=Ge.UpdateCallRejectedError=Ge.QueryCallRejectedError=Ge.ActorCallError=void 0;var n2=Kf(),dl=ya(),hl=ii(),ma=fi(),op=ll(),qr=Nt(),i2=Yt(),s2=r2(sp()),ys=class extends hl.AgentError{constructor(e,r,n,i){super(["Call failed:",` Canister: ${e.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(i).map(s=>` "${s}": ${JSON.stringify(i[s])}`)].join(`
55
- `)),this.canisterId=e,this.methodName=r,this.type=n,this.props=i}};Ge.ActorCallError=ys;var ga=class extends ys{constructor(e,r,n){var i;super(e,r,"query",{Status:n.status,Code:(i=dl.ReplicaRejectCode[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}};Ge.QueryCallRejectedError=ga;var ba=class extends ys{constructor(e,r,n,i){super(e,r,"update",Object.assign({"Request ID":(0,i2.toHex)(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}};Ge.UpdateCallRejectedError=ba;var ar=Symbol.for("ic-agent-metadata"),ms=class t{constructor(e){this[ar]=Object.freeze(e)}static agentOf(e){return e[ar].config.agent}static interfaceOf(e){return e[ar].service}static canisterIdOf(e){return qr.Principal.from(e[ar].config.canisterId)}static async install(e,r){let n=e.mode===void 0?{install:null}:e.mode,i=e.arg?[...new Uint8Array(e.arg)]:[],s=[...new Uint8Array(e.module)],o=typeof r.canisterId=="string"?qr.Principal.fromText(r.canisterId):r.canisterId;await pl(r).install_code({mode:n,arg:i,wasm_module:s,canister_id:o,sender_canister_version:[]})}static async createCanister(e,r){function n(s){return[{controllers:s.controllers?[s.controllers]:[],compute_allocation:s.compute_allocation?[s.compute_allocation]:[],freezing_threshold:s.freezing_threshold?[s.freezing_threshold]:[],memory_allocation:s.memory_allocation?[s.memory_allocation]:[],reserved_cycles_limit:[],log_visibility:[],wasm_memory_limit:[]}]}let{canister_id:i}=await pl(e||{}).provisional_create_canister_with_cycles({amount:[],settings:n(r||{}),specified_id:[],sender_canister_version:[]});return i}static async createAndInstallCanister(e,r,n){let i=await this.createCanister(n);return await this.install(Object.assign({},r),Object.assign(Object.assign({},n),{canisterId:i})),this.createActor(e,Object.assign(Object.assign({},n),{canisterId:i}))}static createActorClass(e,r){let n=e({IDL:ma.IDL});class i extends t{constructor(o){if(!o.canisterId)throw new hl.AgentError(`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"?qr.Principal.fromText(o.canisterId):o.canisterId;super({config:Object.assign(Object.assign(Object.assign({},ap),o),{canisterId:a}),service:n});for(let[c,f]of n._fields)r?.httpDetails&&f.annotations.push(Ge.ACTOR_METHOD_WITH_HTTP_DETAILS),r?.certificate&&f.annotations.push(Ge.ACTOR_METHOD_WITH_CERTIFICATE),this[c]=o2(this,c,f,o.blsVerify)}}return i}static createActor(e,r){if(!r.canisterId)throw new hl.AgentError(`Canister ID is required, but received ${typeof r.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);return new(this.createActorClass(e))(r)}static createActorWithHttpDetails(e,r){return new(this.createActorClass(e,{httpDetails:!0}))(r)}static createActorWithExtendedDetails(e,r,n={httpDetails:!0,certificate:!0}){return new(this.createActorClass(e,n))(r)}};Ge.Actor=ms;function Si(t,e){let r=ma.IDL.decode(t,n2.Buffer.from(e));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var ap={pollingStrategyFactory:op.strategy.defaultStrategy};Ge.ACTOR_METHOD_WITH_HTTP_DETAILS="http-details";Ge.ACTOR_METHOD_WITH_CERTIFICATE="certificate";function o2(t,e,r,n){let i;r.annotations.includes("query")||r.annotations.includes("composite_query")?i=async(o,...a)=>{var c,f;o=Object.assign(Object.assign({},o),(f=(c=t[ar].config).queryTransform)===null||f===void 0?void 0:f.call(c,e,a,Object.assign(Object.assign({},t[ar].config),o)));let d=o.agent||t[ar].config.agent||(0,dl.getDefaultAgent)(),h=qr.Principal.from(o.canisterId||t[ar].config.canisterId),S=ma.IDL.encode(r.argTypes,a),w=await d.query(h,{methodName:e,arg:S,effectiveCanisterId:o.effectiveCanisterId}),u=Object.assign(Object.assign({},w.httpDetails),{requestDetails:w.requestDetails});switch(w.status){case"rejected":throw new ga(h,e,w);case"replied":return r.annotations.includes(Ge.ACTOR_METHOD_WITH_HTTP_DETAILS)?{httpDetails:u,result:Si(r.retTypes,w.reply.arg)}:Si(r.retTypes,w.reply.arg)}}:i=async(o,...a)=>{var c,f;o=Object.assign(Object.assign({},o),(f=(c=t[ar].config).callTransform)===null||f===void 0?void 0:f.call(c,e,a,Object.assign(Object.assign({},t[ar].config),o)));let d=o.agent||t[ar].config.agent||(0,dl.getDefaultAgent)(),{canisterId:h,effectiveCanisterId:S,pollingStrategyFactory:w}=Object.assign(Object.assign(Object.assign({},ap),t[ar].config),o),u=qr.Principal.from(h),g=S!==void 0?qr.Principal.from(S):u,U=ma.IDL.encode(r.argTypes,a),{requestId:F,response:N,requestDetails:V}=await d.call(u,{methodName:e,arg:U,effectiveCanisterId:g});if(!N.ok||N.body)throw new ba(u,e,F,N);let W=w(),{certificate:T,reply:C}=await(0,op.pollForResponse)(d,g,F,W,n),z=r.annotations.includes(Ge.ACTOR_METHOD_WITH_HTTP_DETAILS),D=r.annotations.includes(Ge.ACTOR_METHOD_WITH_CERTIFICATE),G=Object.assign(Object.assign({},N),{requestDetails:V});if(C!==void 0)return z&&D?{httpDetails:G,certificate:T,result:Si(r.retTypes,C)}:D?{certificate:T,result:Si(r.retTypes,C)}:z?{httpDetails:G,result:Si(r.retTypes,C)}:Si(r.retTypes,C);if(r.retTypes.length===0)return z?{httpDetails:N,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 pl(t){function e(r,n){if(t.effectiveCanisterId)return{effectiveCanisterId:qr.Principal.from(t.effectiveCanisterId)};let i=n[0],s=qr.Principal.fromHex("");return i&&typeof i=="object"&&i.canister_id&&(s=qr.Principal.from(i.canister_id)),{effectiveCanisterId:s}}return ms.createActor(s2.default,Object.assign(Object.assign(Object.assign({},t),{canisterId:qr.Principal.fromHex("")}),{callTransform:e,queryTransform:e}))}Ge.getManagementCanister=pl;var yl=class extends ms{constructor(e){super(e)}};Ge.AdvancedActor=yl});var cp=L(ml=>{"use strict";Object.defineProperty(ml,"__esModule",{value:!0});ml.default=({IDL:t})=>t.Service({retrieve:t.Func([t.Text],[t.Vec(t.Nat8)],["query"]),store:t.Func([t.Text,t.Vec(t.Nat8)],[],[])})});var up=L(Bi=>{"use strict";var a2=Bi&&Bi.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Bi,"__esModule",{value:!0});Bi.createAssetCanisterActor=void 0;var c2=_a(),u2=a2(cp());function l2(t){return c2.Actor.createActor(u2.default,t)}Bi.createAssetCanisterActor=l2});var lp=L(jr=>{"use strict";var f2=jr&&jr.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),d2=jr&&jr.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),h2=jr&&jr.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&f2(e,t,r);return d2(e,t),e};Object.defineProperty(jr,"__esModule",{value:!0});jr.fetchCandid=void 0;var p2=Nt(),y2=h2(as()),m2=ol(),g2=_a();async function b2(t,e){e||(e=await m2.HttpAgent.create());let n=(await y2.request({agent:e,canisterId:p2.Principal.fromText(t),paths:["candid"]})).get("candid");if(n)return n;let i=({IDL:o})=>o.Service({__get_candid_interface_tmp_hack:o.Func([],[o.Text],["query"])});return await g2.Actor.createActor(i,{agent:e,canisterId:t}).__get_candid_interface_tmp_hack()}jr.fetchCandid=b2});var br=L(Ue=>{"use strict";var fp=Ue&&Ue.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),_2=Ue&&Ue.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Kt=Ue&&Ue.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&fp(e,t,r)},gl=Ue&&Ue.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&fp(e,t,r);return _2(e,t),e};Object.defineProperty(Ue,"__esModule",{value:!0});Ue.Cbor=Ue.CanisterStatus=Ue.polling=void 0;Kt(_a(),Ue);Kt(ya(),Ue);Kt(To(),Ue);Kt(Li(),Ue);Kt(Jc(),Ue);Kt(up(),Ue);Kt(os(),Ue);Kt(el(),Ue);Kt(lp(),Ue);Kt(tl(),Ue);Kt(Di(),Ue);Kt(Ru(),Ue);Kt(Yt(),Ue);Kt(ou(),Ue);Ue.polling=gl(ll());Ue.CanisterStatus=gl(as());Ue.Cbor=gl(Ji())});var yp=L(kr=>{"use strict";var xa=kr&&kr.__classPrivateFieldSet||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},wn=kr&&kr.__classPrivateFieldGet||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)},wa,Ea,Pi,Ri;Object.defineProperty(kr,"__esModule",{value:!0});kr.Ed25519KeyIdentity=kr.Ed25519PublicKey=void 0;var w2=br(),Jt=br(),gs=Lu();function pp(t){return t!==null&&typeof t=="object"}var Gn=class t{constructor(e){if(wa.set(this,void 0),Ea.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");xa(this,wa,e,"f"),xa(this,Ea,t.derEncode(e),"f")}static from(e){if(typeof e=="string"){let r=(0,Jt.fromHex)(e);return this.fromRaw(r)}else if(pp(e)){let r=e;if(pp(r)&&Object.hasOwnProperty.call(r,"__derEncodedPublicKey__"))return this.fromDer(r);if(ArrayBuffer.isView(r)){let n=r;return this.fromRaw((0,Jt.bufFromBufLike)(n.buffer))}else{if(r instanceof ArrayBuffer)return this.fromRaw(r);if("rawKey"in r)return this.fromRaw(r.rawKey);if("derKey"in r)return this.fromDer(r.derKey);if("toDer"in r)return this.fromDer(r.toDer())}}throw new Error("Cannot construct Ed25519PublicKey from the provided key.")}static fromRaw(e){return new t(e)}static fromDer(e){return new t(this.derDecode(e))}static derEncode(e){let r=(0,Jt.wrapDER)(e,Jt.ED25519_OID).buffer;return r.__derEncodedPublicKey__=void 0,r}static derDecode(e){let r=(0,Jt.unwrapDER)(e,Jt.ED25519_OID);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return wn(this,wa,"f")}get derKey(){return wn(this,Ea,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};kr.Ed25519PublicKey=Gn;wa=new WeakMap,Ea=new WeakMap;Gn.RAW_KEY_LENGTH=32;var bl=class t extends Jt.SignIdentity{constructor(e,r){super(),Pi.set(this,void 0),Ri.set(this,void 0),xa(this,Pi,Gn.from(e),"f"),xa(this,Ri,new Uint8Array(r),"f")}static generate(e){if(e&&e.length!==32)throw new Error("Ed25519 Seed needs to be 32 bytes long.");e||(e=gs.ed25519.utils.randomPrivateKey()),(0,w2.bufEquals)(e,new Uint8Array(new Array(32).fill(0)))&&console.warn("Seed is all zeros. This is not a secure seed. Please provide a seed with sufficient entropy if this is a production environment.");let r=new Uint8Array(32);for(let i=0;i<32;i++)r[i]=new Uint8Array(e)[i];let n=gs.ed25519.getPublicKey(r);return t.fromKeyPair(n,r)}static fromParsedJson(e){let[r,n]=e;return new t(Gn.fromDer((0,Jt.fromHex)(r)),(0,Jt.fromHex)(n))}static fromJSON(e){let r=JSON.parse(e);if(Array.isArray(r)){if(typeof r[0]=="string"&&typeof r[1]=="string")return this.fromParsedJson([r[0],r[1]]);throw new Error("Deserialization error: JSON must have at least 2 items.")}throw new Error(`Deserialization error: Invalid JSON type for string: ${JSON.stringify(e)}`)}static fromKeyPair(e,r){return new t(Gn.fromRaw(e),r)}static fromSecretKey(e){let r=gs.ed25519.getPublicKey(new Uint8Array(e));return t.fromKeyPair(r,e)}toJSON(){return[(0,Jt.toHex)(wn(this,Pi,"f").toDer()),(0,Jt.toHex)(wn(this,Ri,"f"))]}getKeyPair(){return{secretKey:wn(this,Ri,"f"),publicKey:wn(this,Pi,"f")}}getPublicKey(){return wn(this,Pi,"f")}async sign(e){let r=new Uint8Array(e),n=(0,Jt.uint8ToBuf)(gs.ed25519.sign(r,wn(this,Ri,"f").slice(0,32)));return Object.defineProperty(n,"__signature__",{enumerable:!1,value:void 0}),n}static verify(e,r,n){let[i,s,o]=[e,r,n].map(a=>(typeof a=="string"&&(a=(0,Jt.fromHex)(a)),a instanceof Uint8Array&&(a=a.buffer),new Uint8Array(a)));return gs.ed25519.verify(s,i,o)}};kr.Ed25519KeyIdentity=bl;Pi=new WeakMap,Ri=new WeakMap});var gp=L(Yn=>{"use strict";Object.defineProperty(Yn,"__esModule",{value:!0});Yn.ECDSAKeyIdentity=Yn.CryptoError=void 0;var E2=br(),va=class t extends Error{constructor(e){super(e),this.message=e,Object.setPrototypeOf(this,t.prototype)}};Yn.CryptoError=va;function mp(t){if(typeof global<"u"&&global.crypto&&global.crypto.subtle)return global.crypto.subtle;if(t)return t;if(typeof crypto<"u"&&crypto.subtle)return crypto.subtle;throw new va("Global crypto was not available and none was provided. Please inlcude a SubtleCrypto implementation. See https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto")}var Ta=class t extends E2.SignIdentity{constructor(e,r,n){super(),this._keyPair=e,this._derKey=r,this._subtleCrypto=n}static async generate(e){let{extractable:r=!1,keyUsages:n=["sign","verify"],subtleCrypto:i}=e??{},s=mp(i),o=await s.generateKey({name:"ECDSA",namedCurve:"P-256"},r,n),a=await s.exportKey("spki",o.publicKey);return new this(o,a,s)}static async fromKeyPair(e,r){let n=mp(r),i=await n.exportKey("spki",e.publicKey);return new t(e,i,n)}getKeyPair(){return this._keyPair}getPublicKey(){let e=this._derKey,r=Object.create(this._keyPair.publicKey);return r.toDer=function(){return e},r}async sign(e){let r={name:"ECDSA",hash:{name:"SHA-256"}};return this._keyPair.privateKey,await this._subtleCrypto.sign(r,this._keyPair.privateKey,e)}};Yn.ECDSAKeyIdentity=Ta;Yn.default=Ta});var wl=L(xn=>{"use strict";var x2=xn&&xn.__classPrivateFieldSet||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},bs=xn&&xn.__classPrivateFieldGet||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)},En;Object.defineProperty(xn,"__esModule",{value:!0});xn.PartialIdentity=void 0;var v2=Nt(),_l=class{constructor(e){En.set(this,void 0),x2(this,En,e,"f")}get rawKey(){return bs(this,En,"f").rawKey}get derKey(){return bs(this,En,"f").derKey}toDer(){return bs(this,En,"f").toDer()}getPublicKey(){return bs(this,En,"f")}getPrincipal(){return v2.Principal.from(bs(this,En,"f").rawKey)}transformRequest(){return Promise.reject("Not implemented. You are attempting to use a partial identity to sign calls, but this identity only has access to the public key.To sign calls, use a DelegationIdentity instead.")}};xn.PartialIdentity=_l;En=new WeakMap});var bp=L(Ze=>{"use strict";var T2=Ze&&Ze.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),A2=Ze&&Ze.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),S2=Ze&&Ze.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&T2(e,t,r);return A2(e,t),e},B2=Ze&&Ze.__classPrivateFieldSet||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},O2=Ze&&Ze.__classPrivateFieldGet||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)},N2=Ze&&Ze.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},Aa;Object.defineProperty(Ze,"__esModule",{value:!0});Ze.isDelegationValid=Ze.PartialDelegationIdentity=Ze.DelegationIdentity=Ze.DelegationChain=Ze.Delegation=void 0;var vn=br(),xl=Nt(),_s=S2(Xi()),P2=wl(),R2=new TextEncoder().encode("ic-request-auth-delegation"),I2=new TextEncoder().encode(`
56
- ic-request`);function El(t){if(typeof t!="string"||t.length<64)throw new Error("Invalid public key.");return(0,vn.fromHex)(t)}var ws=class{constructor(e,r,n){this.pubkey=e,this.expiration=r,this.targets=n}toCBOR(){return _s.value.map(Object.assign({pubkey:_s.value.bytes(this.pubkey),expiration:_s.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:_s.value.array(this.targets.map(e=>_s.value.bytes(e.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:(0,vn.toHex)(this.pubkey)},this.targets&&{targets:this.targets.map(e=>e.toHex())})}};Ze.Delegation=ws;async function U2(t,e,r,n){let i=new ws(e.toDer(),BigInt(+r)*BigInt(1e6),n),s=new Uint8Array([...R2,...new Uint8Array((0,vn.requestIdOf)(i))]),o=await t.sign(s);return{delegation:i,signature:o}}var vl=class t{constructor(e,r){this.delegations=e,this.publicKey=r}static async create(e,r,n=new Date(Date.now()+15*60*1e3),i={}){var s,o;let a=await U2(e,r,n,i.targets);return new t([...((s=i.previous)===null||s===void 0?void 0:s.delegations)||[],a],((o=i.previous)===null||o===void 0?void 0:o.publicKey)||e.getPublicKey().toDer())}static fromJSON(e){let{publicKey:r,delegations:n}=typeof e=="string"?JSON.parse(e):e;if(!Array.isArray(n))throw new Error("Invalid delegations.");let i=n.map(s=>{let{delegation:o,signature:a}=s,{pubkey:c,expiration:f,targets:d}=o;if(d!==void 0&&!Array.isArray(d))throw new Error("Invalid targets.");return{delegation:new ws(El(c),BigInt("0x"+f),d&&d.map(h=>{if(typeof h!="string")throw new Error("Invalid target.");return xl.Principal.fromHex(h)})),signature:El(a)}});return new this(i,El(r))}static fromDelegations(e,r){return new this(e,r)}toJSON(){return{delegations:this.delegations.map(e=>{let{delegation:r,signature:n}=e,{targets:i}=r;return{delegation:Object.assign({expiration:r.expiration.toString(16),pubkey:(0,vn.toHex)(r.pubkey)},i&&{targets:i.map(s=>s.toHex())}),signature:(0,vn.toHex)(n)}}),publicKey:(0,vn.toHex)(this.publicKey)}}};Ze.DelegationChain=vl;var Tl=class extends vn.SignIdentity{constructor(e,r){super(),this._inner=e,this._delegation=r}static fromDelegation(e,r){return new this(e,r)}getDelegation(){return this._delegation}getPublicKey(){return{derKey:this._delegation.publicKey,toDer:()=>this._delegation.publicKey}}sign(e){return this._inner.sign(e)}async transformRequest(e){let{body:r}=e,n=N2(e,["body"]),i=await(0,vn.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_sig:await this.sign(new Uint8Array([...I2,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}};Ze.DelegationIdentity=Tl;var Al=class t extends P2.PartialIdentity{constructor(e,r){super(e),Aa.set(this,void 0),B2(this,Aa,r,"f")}get delegation(){return O2(this,Aa,"f")}static fromDelegation(e,r){return new t(e,r)}};Ze.PartialDelegationIdentity=Al;Aa=new WeakMap;function F2(t,e){for(let{delegation:i}of t.delegations)if(+new Date(Number(i.expiration/BigInt(1e6)))<=+Date.now())return!1;let r=[],n=e?.scope;n&&(Array.isArray(n)?r.push(...n.map(i=>typeof i=="string"?xl.Principal.fromText(i):i)):r.push(typeof n=="string"?xl.Principal.fromText(n):n));for(let i of r){let s=i.toText();for(let{delegation:o}of t.delegations){if(o.targets===void 0)continue;let a=!0;for(let c of o.targets)if(c.toText()===s){a=!1;break}if(a)return!1}}return!0}Ze.isDelegationValid=F2});var _p=L(Tn=>{"use strict";var M2=Tn&&Tn.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Tn,"__esModule",{value:!0});Tn.WebAuthnIdentity=Tn.CosePublicKey=void 0;var Wn=br(),Sl=M2(ho()),C2=Bn(),q2=fi();function j2(t){return(0,Wn.wrapDER)(t,Wn.DER_COSE_OID).buffer}function k2(t){let e=new DataView(new ArrayBuffer(2)),r=t.slice(53,55);[...new Uint8Array(r)].forEach((i,s)=>e.setUint8(s,i));let n=e.getUint16(0);return t.slice(55+n)}var Sa=class{constructor(e){this._cose=e,this._encodedKey=j2(e)}toDer(){return this._encodedKey}getCose(){return this._cose}};Tn.CosePublicKey=Sa;function V2(t="<ic0.app>"){return typeof t=="string"?Uint8Array.from(t,e=>e.charCodeAt(0)):t}async function H2(t){let e=await navigator.credentials.create(t??{publicKey:{authenticatorSelection:{userVerification:"preferred"},attestation:"direct",challenge:V2(),pubKeyCredParams:[{type:"public-key",alg:Bl.ECDSA_WITH_SHA256}],rp:{name:"Internet Identity Service"},user:{id:(0,C2.randomBytes)(16),name:"Internet Identity",displayName:"Internet Identity"}}});return e===null?null:{id:e.id,response:e.response,type:e.type,authenticatorAttachment:e.authenticatorAttachment,getClientExtensionResults:e.getClientExtensionResults,rawId:(0,q2.bufFromBufLike)(e.rawId)}}var Bl;(function(t){t[t.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(Bl||(Bl={}));var Ol=class extends Wn.SignIdentity{constructor(e,r,n){super(),this.rawId=e,this.authenticatorAttachment=n,this._publicKey=new Sa(r)}static fromJSON(e){let{publicKey:r,rawId:n}=JSON.parse(e);if(typeof r!="string"||typeof n!="string")throw new Error("Invalid JSON string.");return new this((0,Wn.fromHex)(n),(0,Wn.fromHex)(r),void 0)}static async create(e){var r;let n=await H2(e);if(!n||n.type!=="public-key")throw new Error("Could not create credentials.");let i=n.response;if(i.attestationObject===void 0)throw new Error("Was expecting an attestation response.");let s=Sl.default.decodeFirst(new Uint8Array(i.attestationObject));return new this(n.rawId,k2(s.authData),(r=n.authenticatorAttachment)!==null&&r!==void 0?r:void 0)}getPublicKey(){return this._publicKey}getAuthenticatorAttachment(){return this.authenticatorAttachment}async sign(e){let r=await navigator.credentials.get({publicKey:{allowCredentials:[{type:"public-key",id:this.rawId}],challenge:e,userVerification:"preferred"}});r.authenticatorAttachment!==null&&(this.authenticatorAttachment=r.authenticatorAttachment);let n=r.response,i=Sl.default.encode(new Sl.default.Tagged(55799,{authenticator_data:new Uint8Array(n.authenticatorData),client_data_json:new TextDecoder().decode(n.clientDataJSON),signature:new Uint8Array(n.signature)}));if(!i)throw new Error("failed to encode cbor");return i.buffer}toJSON(){return{publicKey:(0,Wn.toHex)(this._publicKey.getCose()),rawId:(0,Wn.toHex)(this.rawId)}}};Tn.WebAuthnIdentity=Ol});var Ep=L(Ye=>{"use strict";var $2=Ye&&Ye.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Pl=Ye&&Ye.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&$2(e,t,r)};Object.defineProperty(Ye,"__esModule",{value:!0});Ye.Secp256k1KeyIdentity=Ye.ED25519_OID=Ye.DER_COSE_OID=Ye.unwrapDER=Ye.wrapDER=Ye.WebAuthnIdentity=Ye.Ed25519PublicKey=Ye.Ed25519KeyIdentity=void 0;var wp=yp();Object.defineProperty(Ye,"Ed25519KeyIdentity",{enumerable:!0,get:function(){return wp.Ed25519KeyIdentity}});Object.defineProperty(Ye,"Ed25519PublicKey",{enumerable:!0,get:function(){return wp.Ed25519PublicKey}});Pl(gp(),Ye);Pl(bp(),Ye);Pl(wl(),Ye);var K2=_p();Object.defineProperty(Ye,"WebAuthnIdentity",{enumerable:!0,get:function(){return K2.WebAuthnIdentity}});var Ba=br();Object.defineProperty(Ye,"wrapDER",{enumerable:!0,get:function(){return Ba.wrapDER}});Object.defineProperty(Ye,"unwrapDER",{enumerable:!0,get:function(){return Ba.unwrapDER}});Object.defineProperty(Ye,"DER_COSE_OID",{enumerable:!0,get:function(){return Ba.DER_COSE_OID}});Object.defineProperty(Ye,"ED25519_OID",{enumerable:!0,get:function(){return Ba.ED25519_OID}});var Nl=class{constructor(){throw new Error("Secp256k1KeyIdentity has been moved to a new repo: @dfinity/identity-secp256k1")}};Ye.Secp256k1KeyIdentity=Nl});var Il=L(Oa=>{"use strict";Object.defineProperty(Oa,"__esModule",{value:!0});Oa.IdleManager=void 0;var xp=["mousedown","mousemove","keydown","touchstart","wheel"],Rl=class{constructor(e={}){var r;this.callbacks=[],this.idleTimeout=10*60*1e3,this.timeoutID=void 0;let{onIdle:n,idleTimeout:i=10*60*1e3}=e||{};this.callbacks=n?[n]:[],this.idleTimeout=i;let s=this._resetTimer.bind(this);window.addEventListener("load",s,!0),xp.forEach(function(a){document.addEventListener(a,s,!0)});let o=(a,c)=>{let f;return(...d)=>{let h=this,S=function(){f=void 0,a.apply(h,d)};clearTimeout(f),f=window.setTimeout(S,c)}};if(e?.captureScroll){let a=o(s,(r=e?.scrollDebounce)!==null&&r!==void 0?r:100);window.addEventListener("scroll",a,!0)}s()}static create(e={}){return new this(e)}registerCallback(e){this.callbacks.push(e)}exit(){clearTimeout(this.timeoutID),window.removeEventListener("load",this._resetTimer,!0);let e=this._resetTimer.bind(this);xp.forEach(function(r){document.removeEventListener(r,e,!0)}),this.callbacks.forEach(r=>r())}_resetTimer(){let e=this.exit.bind(this);window.clearTimeout(this.timeoutID),this.timeoutID=window.setTimeout(e,this.idleTimeout)}};Oa.IdleManager=Rl});function Y2(){return vp||(vp=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function W2(){return Tp||(Tp=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}function z2(t){let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("success",s),t.removeEventListener("error",o)},s=()=>{r(cr(t.result)),i()},o=()=>{n(t.error),i()};t.addEventListener("success",s),t.addEventListener("error",o)});return e.then(r=>{r instanceof IDBCursor&&Ap.set(r,t)}).catch(()=>{}),Cl.set(e,t),e}function D2(t){if(Fl.has(t))return;let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("complete",s),t.removeEventListener("error",o),t.removeEventListener("abort",o)},s=()=>{r(),i()},o=()=>{n(t.error||new DOMException("AbortError","AbortError")),i()};t.addEventListener("complete",s),t.addEventListener("error",o),t.addEventListener("abort",o)});Fl.set(t,e)}function Bp(t){Ml=t(Ml)}function Z2(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){let n=t.call(Es(this),e,...r);return Sp.set(n,e.sort?e.sort():[e]),cr(n)}:W2().includes(t)?function(...e){return t.apply(Es(this),e),cr(Ap.get(this))}:function(...e){return cr(t.apply(Es(this),e))}}function X2(t){return typeof t=="function"?Z2(t):(t instanceof IDBTransaction&&D2(t),G2(t,Y2())?new Proxy(t,Ml):t)}function cr(t){if(t instanceof IDBRequest)return z2(t);if(Ul.has(t))return Ul.get(t);let e=X2(t);return e!==t&&(Ul.set(t,e),Cl.set(e,t)),e}var G2,vp,Tp,Ap,Fl,Sp,Ul,Cl,Ml,Es,ql=Ql(()=>{G2=(t,e)=>e.some(r=>t instanceof r);Ap=new WeakMap,Fl=new WeakMap,Sp=new WeakMap,Ul=new WeakMap,Cl=new WeakMap;Ml={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return Fl.get(t);if(e==="objectStoreNames")return t.objectStoreNames||Sp.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return cr(t[e])},set(t,e,r){return t[e]=r,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};Es=t=>Cl.get(t)});var Np={};$y(Np,{deleteDB:()=>L2,openDB:()=>J2,unwrap:()=>Es,wrap:()=>cr});function J2(t,e,{blocked:r,upgrade:n,blocking:i,terminated:s}={}){let o=indexedDB.open(t,e),a=cr(o);return n&&o.addEventListener("upgradeneeded",c=>{n(cr(o.result),c.oldVersion,c.newVersion,cr(o.transaction),c)}),r&&o.addEventListener("blocked",c=>r(c.oldVersion,c.newVersion,c)),a.then(c=>{s&&c.addEventListener("close",()=>s()),i&&c.addEventListener("versionchange",f=>i(f.oldVersion,f.newVersion,f))}).catch(()=>{}),a}function L2(t,{blocked:e}={}){let r=indexedDB.deleteDatabase(t);return e&&r.addEventListener("blocked",n=>e(n.oldVersion,n)),cr(r).then(()=>{})}function Op(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(jl.get(e))return jl.get(e);let r=e.replace(/FromIndex$/,""),n=e!==r,i=eE.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(i||Q2.includes(r)))return;let s=async function(o,...a){let c=this.transaction(o,i?"readwrite":"readonly"),f=c.store;return n&&(f=f.index(a.shift())),(await Promise.all([f[r](...a),i&&c.done]))[0]};return jl.set(e,s),s}var Q2,eE,jl,Pp=Ql(()=>{ql();ql();Q2=["get","getKey","getAll","getAllKeys","count"],eE=["put","add","delete","clear"],jl=new Map;Bp(t=>({...t,get:(e,r,n)=>Op(e,r)||t.get(e,r,n),has:(e,r)=>!!Op(e,r)||t.has(e,r)}))});var Vl=L(Na=>{"use strict";Object.defineProperty(Na,"__esModule",{value:!0});Na.IdbKeyVal=void 0;var tE=(Pp(),Ky(Np)),xs=Pa(),Rp="auth-client-db",Ip="ic-keyval",rE=async(t=Rp,e=Ip,r)=>(xs.isBrowser&&(localStorage!=null&&localStorage.getItem(xs.KEY_STORAGE_DELEGATION))&&(localStorage.removeItem(xs.KEY_STORAGE_DELEGATION),localStorage.removeItem(xs.KEY_STORAGE_KEY)),await(0,tE.openDB)(t,r,{upgrade:n=>{n.objectStoreNames,n.objectStoreNames.contains(e)&&n.clear(e),n.createObjectStore(e)}}));async function nE(t,e,r){return await t.get(e,r)}async function iE(t,e,r,n){return await t.put(e,n,r)}async function sE(t,e,r){return await t.delete(e,r)}var kl=class t{constructor(e,r){this._db=e,this._storeName=r}static async create(e){let{dbName:r=Rp,storeName:n=Ip,version:i=xs.DB_VERSION}=e??{},s=await rE(r,n,i);return new t(s,n)}async set(e,r){return await iE(this._db,this._storeName,e,r)}async get(e){var r;return(r=await nE(this._db,this._storeName,e))!==null&&r!==void 0?r:null}async remove(e){return await sE(this._db,this._storeName,e)}};Na.IdbKeyVal=kl});var Pa=L(nt=>{"use strict";var oE=nt&&nt.__classPrivateFieldSet||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},aE=nt&&nt.__classPrivateFieldGet||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)},Ra;Object.defineProperty(nt,"__esModule",{value:!0});nt.IdbStorage=nt.LocalStorage=nt.isBrowser=nt.DB_VERSION=nt.KEY_VECTOR=nt.KEY_STORAGE_DELEGATION=nt.KEY_STORAGE_KEY=void 0;var cE=Vl();nt.KEY_STORAGE_KEY="identity";nt.KEY_STORAGE_DELEGATION="delegation";nt.KEY_VECTOR="iv";nt.DB_VERSION=1;nt.isBrowser=typeof window<"u";var Hl=class{constructor(e="ic-",r){this.prefix=e,this._localStorage=r}get(e){return Promise.resolve(this._getLocalStorage().getItem(this.prefix+e))}set(e,r){return this._getLocalStorage().setItem(this.prefix+e,r),Promise.resolve()}remove(e){return this._getLocalStorage().removeItem(this.prefix+e),Promise.resolve()}_getLocalStorage(){if(this._localStorage)return this._localStorage;let e=typeof window>"u"?typeof global>"u"?typeof self>"u"?void 0:self.localStorage:global.localStorage:window.localStorage;if(!e)throw new Error("Could not find local storage.");return e}};nt.LocalStorage=Hl;var $l=class{constructor(e){Ra.set(this,void 0),oE(this,Ra,e??{},"f")}get _db(){return new Promise(e=>{if(this.initializedDb){e(this.initializedDb);return}cE.IdbKeyVal.create(aE(this,Ra,"f")).then(r=>{this.initializedDb=r,e(r)})})}async get(e){return await(await this._db).get(e)}async set(e,r){await(await this._db).set(e,r)}async remove(e){await(await this._db).remove(e)}};nt.IdbStorage=$l;Ra=new WeakMap});var Mp=L(Le=>{"use strict";var uE=Le&&Le.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),lE=Le&&Le.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&uE(e,t,r)};Object.defineProperty(Le,"__esModule",{value:!0});Le.AuthClient=Le.ERROR_USER_INTERRUPT=Le.IdbKeyVal=Le.KEY_STORAGE_KEY=Le.KEY_STORAGE_DELEGATION=Le.LocalStorage=Le.IdbStorage=void 0;var Up=br(),Lt=Ep(),Fp=Il(),Et=Pa(),Ia=Pa();Object.defineProperty(Le,"IdbStorage",{enumerable:!0,get:function(){return Ia.IdbStorage}});Object.defineProperty(Le,"LocalStorage",{enumerable:!0,get:function(){return Ia.LocalStorage}});Object.defineProperty(Le,"KEY_STORAGE_DELEGATION",{enumerable:!0,get:function(){return Ia.KEY_STORAGE_DELEGATION}});Object.defineProperty(Le,"KEY_STORAGE_KEY",{enumerable:!0,get:function(){return Ia.KEY_STORAGE_KEY}});var fE=Vl();Object.defineProperty(Le,"IdbKeyVal",{enumerable:!0,get:function(){return fE.IdbKeyVal}});var dE="https://identity.ic0.app",hE="#authorize",Kl="ECDSA",Gl="Ed25519",pE=500;Le.ERROR_USER_INTERRUPT="UserInterrupt";lE(Il(),Le);var Wl=class{constructor(e,r,n,i,s,o,a,c){this._identity=e,this._key=r,this._chain=n,this._storage=i,this.idleManager=s,this._createOptions=o,this._idpWindow=a,this._eventHandler=c,this._registerDefaultIdleCallback()}static async create(e={}){var r,n,i;let s=(r=e.storage)!==null&&r!==void 0?r:new Et.IdbStorage,o=(n=e.keyType)!==null&&n!==void 0?n:Kl,a=null;if(e.identity)a=e.identity;else{let h=await s.get(Et.KEY_STORAGE_KEY);if(!h&&Et.isBrowser)try{let S=new Et.LocalStorage,w=await S.get(Et.KEY_STORAGE_DELEGATION),u=await S.get(Et.KEY_STORAGE_KEY);w&&u&&o===Kl&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await s.set(Et.KEY_STORAGE_DELEGATION,w),await s.set(Et.KEY_STORAGE_KEY,u),h=w,await S.remove(Et.KEY_STORAGE_DELEGATION),await S.remove(Et.KEY_STORAGE_KEY))}catch(S){console.error("error while attempting to recover localstorage: "+S)}if(h)try{typeof h=="object"?o===Gl&&typeof h=="string"?a=await Lt.Ed25519KeyIdentity.fromJSON(h):a=await Lt.ECDSAKeyIdentity.fromKeyPair(h):typeof h=="string"&&(a=Lt.Ed25519KeyIdentity.fromJSON(h))}catch{}}let c=new Up.AnonymousIdentity,f=null;if(a)try{let h=await s.get(Et.KEY_STORAGE_DELEGATION);if(typeof h=="object"&&h!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");e.identity?c=e.identity:h&&(f=Lt.DelegationChain.fromJSON(h),(0,Lt.isDelegationValid)(f)?"toDer"in a?c=Lt.PartialDelegationIdentity.fromDelegation(a,f):c=Lt.DelegationIdentity.fromDelegation(a,f):(await Yl(s),a=null))}catch(h){console.error(h),await Yl(s),a=null}let d;return!((i=e.idleOptions)===null||i===void 0)&&i.disableIdle?d=void 0:(f||e.identity)&&(d=Fp.IdleManager.create(e.idleOptions)),a||(o===Gl?(a=await Lt.Ed25519KeyIdentity.generate(),await s.set(Et.KEY_STORAGE_KEY,JSON.stringify(a.toJSON()))):(e.storage&&o===Kl&&console.warn(`You are using a custom storage provider that may not support CryptoKey storage. If you are using a custom storage provider that does not support CryptoKey storage, you should use '${Gl}' as the key type, as it can serialize to a string`),a=await Lt.ECDSAKeyIdentity.generate(),await s.set(Et.KEY_STORAGE_KEY,a.getKeyPair()))),new this(c,a,f,s,d,e)}_registerDefaultIdleCallback(){var e,r;let n=(e=this._createOptions)===null||e===void 0?void 0:e.idleOptions;!n?.onIdle&&!n?.disableDefaultIdleCallback&&((r=this.idleManager)===null||r===void 0||r.registerCallback(()=>{this.logout(),location.reload()}))}async _handleSuccess(e,r){var n,i;let s=e.delegations.map(f=>({delegation:new Lt.Delegation(f.delegation.pubkey,f.delegation.expiration,f.delegation.targets),signature:f.signature.buffer})),o=Lt.DelegationChain.fromDelegations(s,e.userPublicKey.buffer),a=this._key;if(!a)return;this._chain=o,"toDer"in a?this._identity=Lt.PartialDelegationIdentity.fromDelegation(a,this._chain):this._identity=Lt.DelegationIdentity.fromDelegation(a,this._chain),(n=this._idpWindow)===null||n===void 0||n.close();let c=(i=this._createOptions)===null||i===void 0?void 0:i.idleOptions;!this.idleManager&&!c?.disableIdle&&(this.idleManager=Fp.IdleManager.create(c),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(Et.KEY_STORAGE_DELEGATION,JSON.stringify(this._chain.toJSON())),r?.(e)}getIdentity(){return this._identity}async isAuthenticated(){return!this.getIdentity().getPrincipal().isAnonymous()&&this._chain!==null}async login(e){var r,n,i,s;let o=BigInt(8)*BigInt(36e11),a=new URL(((r=e?.identityProvider)===null||r===void 0?void 0:r.toString())||dE);a.hash=hE,(n=this._idpWindow)===null||n===void 0||n.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(a,Object.assign({maxTimeToLive:(i=e?.maxTimeToLive)!==null&&i!==void 0?i:o},e)),window.addEventListener("message",this._eventHandler),this._idpWindow=(s=window.open(a.toString(),"idpWindow",e?.windowOpenerFeatures))!==null&&s!==void 0?s:void 0;let c=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(Le.ERROR_USER_INTERRUPT,e?.onError):setTimeout(c,pE))};c()}_getEventHandler(e,r){return async n=>{var i,s,o;if(n.origin!==e.origin){console.warn(`WARNING: expected origin '${e.origin}', got '${n.origin}' (ignoring)`);return}let a=n.data;switch(a.kind){case"authorize-ready":{let c=Object.assign({kind:"authorize-client",sessionPublicKey:new Uint8Array((i=this._key)===null||i===void 0?void 0:i.getPublicKey().toDer()),maxTimeToLive:r?.maxTimeToLive,allowPinAuthentication:r?.allowPinAuthentication,derivationOrigin:(s=r?.derivationOrigin)===null||s===void 0?void 0:s.toString()},r?.customValues);(o=this._idpWindow)===null||o===void 0||o.postMessage(c,e.origin);break}case"authorize-client-success":try{await this._handleSuccess(a,r?.onSuccess)}catch(c){this._handleFailure(c.message,r?.onError)}break;case"authorize-client-failure":this._handleFailure(a.text,r?.onError);break;default:break}}}_handleFailure(e,r){var n;(n=this._idpWindow)===null||n===void 0||n.close(),r?.(e),this._removeEventListener(),delete this._idpWindow}_removeEventListener(){this._eventHandler&&window.removeEventListener("message",this._eventHandler),this._eventHandler=void 0}async logout(e={}){if(await Yl(this._storage),this._identity=new Up.AnonymousIdentity,this._chain=null,e.returnTo)try{window.history.pushState({},"",e.returnTo)}catch{window.location.href=e.returnTo}}};Le.AuthClient=Wl;async function Yl(t){await t.remove(Et.KEY_STORAGE_KEY),await t.remove(Et.KEY_STORAGE_DELEGATION),await t.remove(Et.KEY_VECTOR)}});var Xa=Sn(Nt(),1);var Me=t=>t==null,rt=t=>!Me(t),Bm=class extends Error{},Ms=(t,e)=>{if(Me(t))throw new Bm(e)},za="__bigint__",Da="__principal__",Za="__uint8array__",Om=(t,e)=>typeof e=="bigint"?{[za]:`${e}`}:rt(e)&&e instanceof Xa.Principal?{[Da]:e.toText()}:rt(e)&&e instanceof Uint8Array?{[Za]:Array.from(e)}:e,Nm=(t,e)=>{let r=n=>e[n];return rt(e)&&typeof e=="object"&&za in e?BigInt(r(za)):rt(e)&&typeof e=="object"&&Da in e?Xa.Principal.fromText(r(Da)):rt(e)&&typeof e=="object"&&Za in e?Uint8Array.from(r(Za)):e},gt=t=>rt(t)?[t]:[],lt=t=>t?.[0],yf=async t=>{let e=new Blob([JSON.stringify(t,Om)],{type:"application/json; charset=utf-8"});return new Uint8Array(await e.arrayBuffer())},Cs=async t=>{let e=new Blob([t instanceof Uint8Array?t:new Uint8Array(t)],{type:"application/json; charset=utf-8"});return JSON.parse(await e.text(),Nm)},mf=()=>typeof window<"u";var Ln=class{callbacks=[];populate(e){this.callbacks.forEach(({callback:r})=>r(e))}subscribe(e){let r=Symbol();return this.callbacks.push({id:r,callback:e}),()=>this.callbacks=this.callbacks.filter(({id:n})=>n!==r)}};var $r=class t extends Ln{static instance;authUser=null;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.authUser=e,this.populate(e)}get(){return this.authUser}subscribe(e){let r=super.subscribe(e);return e(this.authUser),r}reset(){this.authUser=null,this.populate(this.authUser)}};var Ja=({message:t,detail:e})=>{let r=new CustomEvent(t,{detail:e,bubbles:!0});document.dispatchEvent(r)};var gf=BigInt(144e11),bf=!1,_f={width:576,height:576},wf={width:505,height:705},Ef="internetcomputer.org";var Qn="http://127.0.0.1:5987",xf="rdmx6-jaaaa-aaaaa-aaadq-cai";var wr=class t extends Ln{static instance;env;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.env=e,this.populate(e)}get(){return this.env}subscribe(e){let r=super.subscribe(e);return e(this.env),r}};var La=({width:t,height:e})=>{if(!mf()||Me(window)||Me(window.top))return;let{top:{innerWidth:r,innerHeight:n}}=window,i=n/2+screenY-e/2,s=r/2+screenX-t/2;return`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=${t}, height=${e}, top=${i}, left=${s}`};var qs=class{#e;constructor({domain:e}){this.#e=e}get id(){return"internet_identity"}signInOptions({windowed:e}){let r=()=>{let n=wr.getInstance().get()?.container;if(Me(n)||n===!1)return`https://identity.${this.#e??Ef}`;let i=wr.getInstance().get(),s=rt(i)&&rt(i?.internetIdentityId)?i.internetIdentityId:xf,{host:o,protocol:a}=new URL(n===!0?Qn:n);return/apple/i.test(navigator?.vendor)?`${a}//${o}?canisterId=${s}`:`${a}//${s}.${o.replace("127.0.0.1","localhost")}`};return{...e!==!1&&{windowOpenerFeatures:La(_f)},identityProvider:r()}}},vf=class{#e;#t;constructor({appName:e,logoUrl:r}){this.#e=e,this.#t=r}get id(){return"nfid"}signInOptions({windowed:e}){return{...e!==!1&&{windowOpenerFeatures:La(wf)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#e)}&applicationLogo=${encodeURI(this.#t)}`}}};var hp=Sn(br(),1);var dp=Sn(br(),1);var Oi=class t{static instance;#e=void 0;constructor(){}static getInstance(){return Me(t.instance)&&(t.instance=new t),t.instance}async getAgent({identity:e,...r}){let n=e.getPrincipal().toText();if(Me(this.#e)||Me(this.#e[n])){let i=await this.createAgent({identity:e,...r});return this.#e={...this.#e??{},[n]:i},i}return this.#e[n]}reset(){this.#e=null}async createAgent({identity:e,fetch:r,container:n}){let s=rt(n)&&n!==!1?n===!0?Qn:n:"https://icp-api.io",o=rt(n);return await dp.HttpAgent.create({identity:e,shouldFetchRootKey:o,host:s,...r&&{fetch:r}})}};var Ni=class t{static instance;#e=void 0;constructor(){}static getInstance(){return Me(t.instance)&&(t.instance=new t),t.instance}async getActor({satelliteId:e,identity:r,buildType:n,...i}){let s=`${n}#${r.getPrincipal().toText()}#${e};`;if(Me(this.#e)||Me(this.#e[s])){let o=await this.createActor({satelliteId:e,identity:r,...i});return this.#e={...this.#e??{},[s]:o},o}return this.#e[s]}reset(){this.#e=null}async createActor({idlFactory:e,satelliteId:r,...n}){let i=await Oi.getInstance().getAgent(n);return hp.Actor.createActor(e,{agent:i,canisterId:r})}};var Cp=Sn(Mp(),1),Ua=()=>Cp.AuthClient.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var qp=async({data:t})=>{try{return await Cs(t)}catch(e){console.error("The data parsing has failed, mapping to undefined as a fallback.",e);return}};var zl=async t=>{let{data:e,version:r,description:n}=t;return{description:gt(n),data:await yf(e),version:gt(r)}},Dl=t=>{let{version:e}=t;return{version:gt(e)}},vs=async({doc:t,key:e})=>{let{owner:r,version:n,description:i,data:s,...o}=t;return{key:e,description:lt(i),owner:r.toText(),data:await Cs(s),version:lt(n),...o}};var kp=Sn(Nt(),1);var jp=t=>{if(Me(t))return gt();switch(t.matcher){case"equal":return gt({Equal:t.timestamp});case"greaterThan":return gt({GreaterThan:t.timestamp});case"lessThan":return gt({LessThan:t.timestamp});case"between":return gt({Between:[t.timestamps.start,t.timestamps.end]});default:throw new Error("Invalid list matcher for timestamp",t)}},Ii=({matcher:t,paginate:e,order:r,owner:n})=>({matcher:Me(t)?[]:[{key:gt(t.key),description:gt(t.description),created_at:jp(t.createdAt),updated_at:jp(t.updatedAt)}],paginate:gt(Me(e)?void 0:{start_after:gt(e.startAfter),limit:gt(Me(e.limit)?void 0:BigInt(e.limit))}),order:gt(Me(r)?void 0:{desc:r.desc,field:r.field==="created_at"?{CreatedAt:null}:r.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:gt(Me(n)?void 0:typeof n=="string"?kp.Principal.fromText(n):n)});var Vp=({IDL:t})=>{let e=t.Record({batch_id:t.Nat,headers:t.Vec(t.Tuple(t.Text,t.Text)),chunk_ids:t.Vec(t.Nat)}),r=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),n=t.Record({field:r,desc:t.Bool}),i=t.Variant({Equal:t.Nat64,Between:t.Tuple(t.Nat64,t.Nat64),GreaterThan:t.Nat64,LessThan:t.Nat64}),s=t.Record({key:t.Opt(t.Text),updated_at:t.Opt(i),description:t.Opt(t.Text),created_at:t.Opt(i)}),o=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),a=t.Record({order:t.Opt(n),owner:t.Opt(t.Principal),matcher:t.Opt(s),paginate:t.Opt(o)}),c=t.Record({controllers:t.Vec(t.Principal)}),f=t.Variant({Write:t.Null,Admin:t.Null}),d=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:f,expires_at:t.Opt(t.Nat64)}),h=t.Record({version:t.Opt(t.Nat64)}),S=t.Variant({Db:t.Null,Storage:t.Null}),w=t.Record({version:t.Opt(t.Nat64)}),u=t.Record({cycles:t.Nat,destination_id:t.Principal}),g=t.Record({token:t.Opt(t.Text),collection:t.Text,owner:t.Principal,name:t.Text,description:t.Opt(t.Text),full_path:t.Text}),U=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),F=t.Record({key:g,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,U)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),N=t.Record({derivation_origin:t.Opt(t.Text)}),V=t.Record({internet_identity:t.Opt(N)}),W=t.Record({stable:t.Opt(t.Nat64),heap:t.Opt(t.Nat64)}),T=t.Record({max_memory_size:t.Opt(W)}),C=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),z=t.Variant({Deny:t.Null,Allow:t.Null}),D=t.Record({status_code:t.Nat16,location:t.Text}),G=t.Record({iframe:t.Opt(C),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),max_memory_size:t.Opt(W),raw_access:t.Opt(z),redirects:t.Opt(t.Vec(t.Tuple(t.Text,D)))}),ne=t.Record({db:t.Opt(T),authentication:t.Opt(V),storage:G}),Q=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),description:t.Opt(t.Text),created_at:t.Nat64,version:t.Opt(t.Nat64)}),le=t.Record({url:t.Text,method:t.Text,body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),certificate_version:t.Opt(t.Nat16)}),E=t.Variant({Heap:t.Null,Stable:t.Null}),_=t.Record({memory:E,token:t.Opt(t.Text),sha256:t.Opt(t.Vec(t.Nat8)),headers:t.Vec(t.Tuple(t.Text,t.Text)),index:t.Nat64,encoding_type:t.Text,full_path:t.Text}),b=t.Variant({Callback:t.Record({token:_,callback:t.Func([],[],["query"])})}),x=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(b),status_code:t.Nat16}),j=t.Record({token:t.Opt(_),body:t.Vec(t.Nat8)}),H=t.Record({token:t.Opt(t.Text),collection:t.Text,name:t.Text,description:t.Opt(t.Text),encoding_type:t.Opt(t.Text),full_path:t.Text}),X=t.Record({batch_id:t.Nat}),oe=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,F)),items_length:t.Nat64}),ae=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),Y=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,Q)),items_length:t.Nat64}),R=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),p=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(E),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:R,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),write:R}),ee=t.Record({stable:t.Nat64,heap:t.Nat64}),re=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:f,expires_at:t.Opt(t.Nat64)}),de=t.Record({controller:re,controllers:t.Vec(t.Principal)}),J=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),l=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(E),max_size:t.Opt(t.Nat),read:R,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),write:R}),y=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),m=t.Record({chunk_id:t.Nat});return t.Service({build_version:t.Func([],[t.Text],["query"]),commit_asset_upload:t.Func([e],[],[]),count_assets:t.Func([t.Text,a],[t.Nat64],["query"]),count_collection_assets:t.Func([t.Text],[t.Nat64],["query"]),count_collection_docs:t.Func([t.Text],[t.Nat64],["query"]),count_docs:t.Func([t.Text,a],[t.Nat64],["query"]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([c],[t.Vec(t.Tuple(t.Principal,d))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,h],[],[]),del_docs:t.Func([t.Text],[],[]),del_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[],[]),del_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,h))],[],[]),del_rule:t.Func([S,t.Text,w],[],[]),deposit_cycles:t.Func([u],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(F)],["query"]),get_auth_config:t.Func([],[t.Opt(V)],["query"]),get_config:t.Func([],[ne],[]),get_db_config:t.Func([],[t.Opt(T)],["query"]),get_doc:t.Func([t.Text,t.Text],[t.Opt(Q)],["query"]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(F)))],["query"]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(Q)))],["query"]),get_storage_config:t.Func([],[G],["query"]),http_request:t.Func([le],[x],["query"]),http_request_streaming_callback:t.Func([_],[j],["query"]),init_asset_upload:t.Func([H],[X],[]),list_assets:t.Func([t.Text,a],[oe],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,d))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,ae))],["query"]),list_docs:t.Func([t.Text,a],[Y],["query"]),list_rules:t.Func([S],[t.Vec(t.Tuple(t.Text,p))],["query"]),memory_size:t.Func([],[ee],["query"]),set_auth_config:t.Func([V],[],[]),set_controllers:t.Func([de],[t.Vec(t.Tuple(t.Principal,d))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_db_config:t.Func([T],[],[]),set_doc:t.Func([t.Text,t.Text,J],[Q],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,J))],[t.Vec(t.Tuple(t.Text,Q))],[]),set_rule:t.Func([S,t.Text,l],[],[]),set_storage_config:t.Func([G],[],[]),upload_asset_chunk:t.Func([y],[m],[]),version:t.Func([],[t.Text],["query"])})};var Hp=({satelliteId:t,container:e})=>{let{satelliteId:r}=Zl({satelliteId:t}),{container:n}=Xl({container:e});if(rt(n)&&n!==!1){let{host:i,protocol:s}=new URL(n===!0?Qn:n);return`${s}//${r??"unknown"}.${i.replace("127.0.0.1","localhost")}`}return`https://${r??"unknown"}.icp0.io`},Zl=({satelliteId:t})=>rt(t)?{satelliteId:t}:wr.getInstance().get()??{satelliteId:void 0},Xl=({container:t})=>rt(t)?{container:t}:wr.getInstance().get()??{container:void 0};var xt=async t=>Kp({idlFactory:Vp,buildType:"stock",...t}),$p=async({idlFactory:t,...e})=>Kp({idlFactory:t,buildType:"extended",...e}),Kp=async({satelliteId:t,container:e,...r})=>{let{satelliteId:n}=Zl({satelliteId:t});Ms(n,"No satellite ID defined. Did you initialize Juno?");let{container:i}=Xl({container:e});return await Ni.getInstance().getActor({satelliteId:n,container:i,...r})};var Gp=async({collection:t,key:e,satellite:r})=>{let{get_doc:n}=await xt(r),i=lt(await n(t,e));if(!Me(i))return vs({doc:i,key:e})},Yp=async({docs:t,satellite:e})=>{let{get_many_docs:r}=await xt(e),n=t.map(({collection:o,key:a})=>[o,a]),i=await r(n),s=[];for(let[o,a]of i){let c=lt(a);s.push(rt(c)?await vs({key:o,doc:c}):void 0)}return s},Wp=async({collection:t,doc:e,satellite:r})=>{let{set_doc:n}=await xt(r),{key:i}=e,s=await zl(e),o=await n(t,i,s);return await vs({key:i,doc:o})},zp=async({docs:t,satellite:e})=>{let{set_many_docs:r}=await xt(e),n=[];for(let{collection:o,doc:a}of t){let{key:c}=a;n.push([o,c,await zl(a)])}let i=await r(n),s=[];for(let[o,a]of i)s.push(await vs({key:o,doc:a}));return s},Dp=async({collection:t,doc:e,satellite:r})=>{let{del_doc:n}=await xt(r),{key:i}=e;return n(t,i,Dl(e))},Zp=async({docs:t,satellite:e})=>{let{del_many_docs:r}=await xt(e),n=t.map(({collection:i,doc:s})=>[i,s.key,Dl(s)]);await r(n)},Xp=async({collection:t,filter:e,satellite:r})=>{let{list_docs:n}=await xt(r),{items:i,items_page:s,items_length:o,matches_length:a,matches_pages:c}=await n(t,Ii(e)),f=[];for(let[d,h]of i){let{data:S,owner:w,description:u,version:g,...U}=h;f.push({key:d,description:lt(u),owner:w.toText(),data:await qp({data:S}),version:lt(g),...U})}return{items:f,items_length:o,items_page:lt(s),matches_length:a,matches_pages:lt(c)}},Jp=async({collection:t,filter:e,satellite:r})=>{let{count_docs:n}=await xt(r);return n(t,Ii(e))};var Lp=Sn(br(),1);var it=t=>t!==void 0?t:Fa()??new Lp.AnonymousIdentity;var Qp=async({satellite:t,...e})=>{let r=it(t?.identity);return Gp({...e,satellite:{...t,identity:r}})},g8=async({satellite:t,...e})=>{let r=it(t?.identity);return Yp({...e,satellite:{...t,identity:r}})},ey=async({satellite:t,...e})=>{let r=it(t?.identity);return Wp({...e,satellite:{...t,identity:r}})},b8=async({satellite:t,...e})=>{let r=it(t?.identity);return zp({...e,satellite:{...t,identity:r}})},_8=async({satellite:t,...e})=>{let r=it(t?.identity);return Dp({...e,satellite:{...t,identity:r}})},w8=async({satellite:t,...e})=>{let r=it(t?.identity);return Zp({...e,satellite:{...t,identity:r}})},E8=async({satellite:t,filter:e,...r})=>{let n=it(t?.identity);return Xp({...r,filter:e??{},satellite:{...t,identity:n}})},x8=async({satellite:t,filter:e,...r})=>{let n=it(t?.identity);return Jp({...r,filter:e??{},satellite:{...t,identity:n}})};var ty=async t=>{let e=Fa();if(Me(e))throw new Error("No identity to initialize the user. Have you initialized Juno?");let r=e.getPrincipal().toText(),n=await Qp({collection:"#user",key:r});return Me(n)?await yE({userId:r,provider:t}):n},yE=async({userId:t,...e})=>ey({collection:"#user",doc:{key:t,data:e}});var Vr,Jl=async t=>{if(Vr=Vr??await Ua(),!(await Vr?.isAuthenticated()??!1))return;let r=await ty(t);$r.getInstance().set(r)},mE=async t=>new Promise(async(e,r)=>{Vr=Vr??await Ua();let n=t?.provider??new qs({});await Vr.login({onSuccess:async()=>{await Jl(n.id),e()},onError:i=>r(i),maxTimeToLive:t?.maxTimeToLive??gf,allowPinAuthentication:t?.allowPin??bf,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...n.signInOptions({windowed:t?.windowed})})}),Ll=async()=>{await Vr?.logout(),Vr=void 0,$r.getInstance().reset(),Ni.getInstance().reset(),Oi.getInstance().reset()},Fa=()=>Vr?.getIdentity(),gE=async()=>(Vr??await Ua()).getIdentity();var ry=t=>{let e=t===!0?"./workers/auth.worker.js":t,r=new Worker(e),n=async()=>{Ja({message:"junoSignOutAuthTimer"}),await Ll()};return r.onmessage=async({data:i})=>{let{msg:s,data:o}=i;switch(s){case"junoSignOutAuthTimer":await n();return;case"junoDelegationRemainingTime":Ja({message:"junoDelegationRemainingTime",detail:o?.authRemainingTime});return}},$r.getInstance().subscribe(i=>{if(Me(i)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var ny=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_SATELLITE_ID??import.meta.env?.PUBLIC_SATELLITE_ID:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_SATELLITE_ID??t():t()},iy=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_CONTAINER??import.meta.env?.PUBLIC_CONTAINER:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_CONTAINER??t():t()};var G8=async({idlFactory:t,satellite:e})=>{let r=it(e?.identity);return $p({idlFactory:t,...e,identity:r})};var W8=Sn(Nt(),1),bE=t=>t==null,_E=t=>!bE(t),Ma=t=>_E(t)?[t]:[],wE=()=>typeof window<"u",sy=async({asset:{data:t,filename:e,collection:r,headers:n,token:i,fullPath:s,encoding:o,description:a},actor:c,init_asset_upload:f})=>{let{batch_id:d}=await f({collection:r,full_path:s,name:e,token:Ma(i),encoding_type:Ma(o),description:Ma(a)}),h=19e5,S=[],w=wE()?new Blob([await t.arrayBuffer()]):t,u=0n;for(let F=0;F<w.size;F+=h){let N=w.slice(F,F+h);S.push({batchId:d,chunk:N,actor:c,orderId:u}),u++}let g=[];for await(let F of EE({uploadChunks:S}))g=[...g,...F];let U=n.find(([F,N])=>F.toLowerCase()==="content-type")===void 0&&t.type!==void 0&&t.type!==""?[["Content-Type",t.type]]:void 0;await c.commit_asset_upload({batch_id:d,chunk_ids:g.map(({chunk_id:F})=>F),headers:[...n,...U||[]]})};async function*EE({uploadChunks:t,limit:e=12}){for(let r=0;r<t.length;r=r+e){let n=t.slice(r,r+e);yield await Promise.all(n.map(i=>xE(i)))}}var xE=async({batchId:t,chunk:e,actor:r,orderId:n})=>r.upload_asset_chunk({batch_id:t,content:new Uint8Array(await e.arrayBuffer()),order_id:Ma(n)});var oy=async({satellite:t,...e})=>{let r=await xt(t);await sy({actor:r,asset:e,init_asset_upload:async i=>await r.init_asset_upload(i)})},ay=async({collection:t,satellite:e,filter:r})=>{let{list_assets:n}=await xt(e),{items:i,items_length:s,items_page:o,matches_length:a,matches_pages:c}=await n(t,Ii(r));return{items:i.map(([f,d])=>d),items_length:s,items_page:lt(o),matches_length:a,matches_pages:lt(c)}},cy=async({collection:t,satellite:e,filter:r})=>{let{count_assets:n}=await xt(e);return n(t,Ii(r))},uy=async({collection:t,fullPath:e,satellite:r})=>(await xt(r)).del_asset(t,e),ly=async({assets:t,satellite:e})=>{let{del_many_assets:r}=await xt(e),n=t.map(({collection:i,fullPath:s})=>[i,s]);await r(n)},fy=async({collection:t,fullPath:e,satellite:r})=>{let{get_asset:n}=await xt(r);return lt(await n(t,e))},dy=async({assets:t,satellite:e})=>{let{get_many_assets:r}=await xt(e),n=t.map(({collection:s,fullPath:o})=>[s,o]);return(await r(n)).map(([s,o])=>lt(o))};var hy=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var oT=async t=>py(t),aT=async t=>py({filename:t.data.name,...t}),py=async({filename:t,data:e,collection:r,headers:n=[],fullPath:i,token:s,satellite:o,encoding:a,description:c})=>{let f=it(o?.identity),d=decodeURI(t),h=i??`/${r}/${d}`,S={...o,identity:f};return await oy({data:e,filename:d,collection:r,token:s,headers:n,fullPath:h,encoding:a,satellite:S,description:c}),{downloadUrl:yy({satellite:S,assetKey:{fullPath:h,token:s}}),fullPath:h,name:d}},cT=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:it(e?.identity)},{items:i,...s}=await ay({collection:t,satellite:n,filter:r??{}}),o=i.map(({key:{full_path:a,token:c,name:f,owner:d,description:h},headers:S,encodings:w,created_at:u,updated_at:g})=>{let U=lt(c);return{fullPath:a,description:lt(h),name:f,downloadUrl:yy({satellite:n,assetKey:{fullPath:a,token:U}}),token:U,headers:S,encodings:w.reduce((F,[N,{modified:V,sha256:W,total_length:T}])=>({...F,[N]:{modified:V,sha256:hy(W),total_length:T}}),{}),owner:d.toText(),created_at:u,updated_at:g}});return{items:o,assets:o,...s}},uT=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:it(e?.identity)};return cy({collection:t,satellite:n,filter:r??{}})},lT=async({collection:t,fullPath:e,satellite:r})=>uy({collection:t,fullPath:e,satellite:{...r,identity:it(r?.identity)}}),fT=async({assets:t,satellite:e})=>ly({assets:t,satellite:{...e,identity:it(e?.identity)}}),dT=async({satellite:t,...e})=>{let r=it(t?.identity);return fy({...e,satellite:{...t,identity:r}})},hT=async({satellite:t,...e})=>{let r=it(t?.identity);return dy({...e,satellite:{...t,identity:r}})},yy=({assetKey:{fullPath:t,token:e},satellite:r})=>{let n={...r,identity:it(r?.identity)};return`${Hp(n)}${t}${rt(e)?`?token=${e}`:""}`};var vE=t=>{let e=t?.satelliteId??ny();Ms(e,"Satellite ID is not configured. Juno cannot be initialized.");let r=t?.container??iy();return{satelliteId:e,internetIdentityId:t?.internetIdentityId,workers:t?.workers,container:r}},ET=async t=>TE(t),TE=async t=>{let e=vE(t);wr.getInstance().set(e),await Jl();let r=e.workers?.auth!==void 0?ry(e.workers.auth):void 0;return[...r?[r]:[]]},xT=t=>$r.getInstance().subscribe(t);export{qs as InternetIdentityProvider,vf as NFIDProvider,xT as authSubscribe,uT as countAssets,x8 as countDocs,lT as deleteAsset,_8 as deleteDoc,fT as deleteManyAssets,w8 as deleteManyDocs,yy as downloadUrl,dT as getAsset,Qp as getDoc,hT as getManyAssets,g8 as getManyDocs,G8 as getSatelliteExtendedActor,ET as initJuno,TE as initSatellite,cT as listAssets,E8 as listDocs,ey as setDoc,b8 as setManyDocs,mE as signIn,Ll as signOut,gE as unsafeIdentity,oT as uploadBlob,aT as uploadFile};
53
+ `)}case Sn.RequestStatusResponseStatus.Done:throw new Error(`Call was marked as done but we never saw the reply:
54
+ Request ID: ${(0,pp.toHex)(r)}
55
+ `)}throw new Error("unreachable")}Yt.pollForResponse=yp});var gp=Q(vl=>{"use strict";Object.defineProperty(vl,"__esModule",{value:!0});vl.default=({IDL:t})=>{let e=t.Variant({mainnet:t.Null,testnet:t.Null}),r=t.Text,n=t.Record({network:e,address:r,min_confirmations:t.Opt(t.Nat32)}),i=t.Nat64,s=i,o=t.Record({network:e}),a=t.Nat64,c=t.Vec(a),f=t.Record({network:e,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:r}),d=t.Vec(t.Nat8),h=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),m=t.Record({height:t.Nat32,value:i,outpoint:h}),_=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:t.Nat32,tip_block_hash:d,utxos:t.Vec(m)}),u=t.Record({transaction:t.Vec(t.Nat8),network:e}),T=t.Principal,O=t.Record({canister_id:T,num_requested_changes:t.Opt(t.Nat64)}),R=t.Variant({from_user:t.Record({user_id:t.Principal}),from_canister:t.Record({canister_version:t.Opt(t.Nat64),canister_id:t.Principal})}),F=t.Variant({creation:t.Record({controllers:t.Vec(t.Principal)}),code_deployment:t.Record({mode:t.Variant({reinstall:t.Null,upgrade:t.Null,install:t.Null}),module_hash:t.Vec(t.Nat8)}),controllers_change:t.Record({controllers:t.Vec(t.Principal)}),code_uninstall:t.Null}),M=t.Record({timestamp_nanos:t.Nat64,canister_version:t.Nat64,origin:R,details:F}),K=t.Record({controllers:t.Vec(t.Principal),module_hash:t.Opt(t.Vec(t.Nat8)),recent_changes:t.Vec(M),total_num_changes:t.Nat64}),x=t.Record({canister_id:T}),$=t.Variant({controllers:t.Null,public:t.Null}),W=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,log_visibility:$,wasm_memory_limit:t.Nat,memory_allocation:t.Nat,compute_allocation:t.Nat}),D=t.Record({status:t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),memory_size:t.Nat,cycles:t.Nat,settings:W,query_stats:t.Record({response_payload_bytes_total:t.Nat,num_instructions_total:t.Nat,num_calls_total:t.Nat,request_payload_bytes_total:t.Nat}),idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8)),reserved_cycles:t.Nat}),j=t.Record({canister_id:T}),ie=t.Record({freezing_threshold:t.Opt(t.Nat),controllers:t.Opt(t.Vec(t.Principal)),reserved_cycles_limit:t.Opt(t.Nat),log_visibility:t.Opt($),wasm_memory_limit:t.Opt(t.Nat),memory_allocation:t.Opt(t.Nat),compute_allocation:t.Opt(t.Nat)}),ee=t.Record({settings:t.Opt(ie),sender_canister_version:t.Opt(t.Nat64)}),ne=t.Record({canister_id:T}),w=t.Record({canister_id:T}),b=t.Record({canister_id:T}),B=t.Variant({secp256k1:t.Null}),S=t.Record({key_id:t.Record({name:t.Text,curve:B}),canister_id:t.Opt(T),derivation_path:t.Vec(t.Vec(t.Nat8))}),N=t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)}),H=t.Record({canister_id:T}),Z=t.Record({idx:t.Nat64,timestamp_nanos:t.Nat64,content:t.Vec(t.Nat8)}),ae=t.Record({canister_log_records:t.Vec(Z)}),oe=t.Record({value:t.Text,name:t.Text}),z=t.Record({status:t.Nat,body:t.Vec(t.Nat8),headers:t.Vec(oe)}),U=t.Record({url:t.Text,method:t.Variant({get:t.Null,head:t.Null,post:t.Null}),max_response_bytes:t.Opt(t.Nat64),body:t.Opt(t.Vec(t.Nat8)),transform:t.Opt(t.Record({function:t.Func([t.Record({context:t.Vec(t.Nat8),response:z})],[z],["query"]),context:t.Vec(t.Nat8)})),headers:t.Vec(oe)}),p=t.Variant({reinstall:t.Null,upgrade:t.Opt(t.Record({wasm_memory_persistence:t.Opt(t.Variant({keep:t.Null,replace:t.Null})),skip_pre_upgrade:t.Opt(t.Bool)})),install:t.Null}),J=t.Record({hash:t.Vec(t.Nat8)}),re=t.Record({arg:t.Vec(t.Nat8),wasm_module_hash:t.Vec(t.Nat8),mode:p,chunk_hashes_list:t.Vec(J),target_canister:T,store_canister:t.Opt(T),sender_canister_version:t.Opt(t.Nat64)}),fe=t.Vec(t.Nat8),L=t.Record({arg:t.Vec(t.Nat8),wasm_module:fe,mode:p,canister_id:T,sender_canister_version:t.Opt(t.Nat64)}),l=t.Record({start_at_timestamp_nanos:t.Nat64,subnet_id:t.Principal}),y=t.Record({num_block_failures_total:t.Nat64,node_id:t.Principal,num_blocks_proposed_total:t.Nat64}),g=t.Vec(t.Record({timestamp_nanos:t.Nat64,node_metrics:t.Vec(y)})),I=t.Record({settings:t.Opt(ie),specified_id:t.Opt(T),amount:t.Opt(t.Nat),sender_canister_version:t.Opt(t.Nat64)}),A=t.Record({canister_id:T}),P=t.Record({canister_id:T,amount:t.Nat}),k=t.Vec(t.Nat8),E=t.Variant({ed25519:t.Null,bip340secp256k1:t.Null}),q=t.Record({key_id:t.Record({algorithm:E,name:t.Text}),canister_id:t.Opt(T),derivation_path:t.Vec(t.Vec(t.Nat8))}),V=t.Record({public_key:t.Vec(t.Nat8),chain_code:t.Vec(t.Nat8)}),C=t.Record({key_id:t.Record({name:t.Text,curve:B}),derivation_path:t.Vec(t.Vec(t.Nat8)),message_hash:t.Vec(t.Nat8)}),X=t.Record({signature:t.Vec(t.Nat8)}),te=t.Record({key_id:t.Record({algorithm:E,name:t.Text}),derivation_path:t.Vec(t.Vec(t.Nat8)),message:t.Vec(t.Nat8)}),de=t.Record({signature:t.Vec(t.Nat8)}),_e=t.Record({canister_id:T}),Fe=t.Record({canister_id:T}),$e=t.Record({canister_id:T}),me=t.Vec(J),he=t.Record({canister_id:T,sender_canister_version:t.Opt(t.Nat64)}),Xe=t.Record({canister_id:t.Principal,settings:ie,sender_canister_version:t.Opt(t.Nat64)}),Er=t.Record({chunk:t.Vec(t.Nat8),canister_id:t.Principal}),Kr=J;return t.Service({bitcoin_get_balance:t.Func([n],[s],[]),bitcoin_get_current_fee_percentiles:t.Func([o],[c],[]),bitcoin_get_utxos:t.Func([f],[_],[]),bitcoin_send_transaction:t.Func([u],[],[]),canister_info:t.Func([O],[K],[]),canister_status:t.Func([x],[D],[]),clear_chunk_store:t.Func([j],[],[]),create_canister:t.Func([ee],[ne],[]),delete_canister:t.Func([w],[],[]),deposit_cycles:t.Func([b],[],[]),ecdsa_public_key:t.Func([S],[N],[]),fetch_canister_logs:t.Func([H],[ae],["query"]),http_request:t.Func([U],[z],[]),install_chunked_code:t.Func([re],[],[]),install_code:t.Func([L],[],[]),node_metrics_history:t.Func([l],[g],[]),provisional_create_canister_with_cycles:t.Func([I],[A],[]),provisional_top_up_canister:t.Func([P],[],[]),raw_rand:t.Func([],[k],[]),schnorr_public_key:t.Func([q],[V],[]),sign_with_ecdsa:t.Func([C],[X],[]),sign_with_schnorr:t.Func([te],[de],[]),start_canister:t.Func([_e],[],[]),stop_canister:t.Func([Fe],[],[]),stored_chunks:t.Func([$e],[me],[]),uninstall_code:t.Func([he],[],[]),update_settings:t.Func([Xe],[],[]),upload_chunk:t.Func([Er],[Kr],[])})}});var Ua=Q(Ge=>{"use strict";var m2=Ge&&Ge.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Ge,"__esModule",{value:!0});Ge.AdvancedActor=Ge.getManagementCanister=Ge.ACTOR_METHOD_WITH_CERTIFICATE=Ge.ACTOR_METHOD_WITH_HTTP_DETAILS=Ge.Actor=Ge.UpdateCallRejectedError=Ge.QueryCallRejectedError=Ge.ActorCallError=void 0;var b2=ed(),Tl=gs(),Pa=li(),Bs=mi(),mp=Ra(),_r=Tt(),_2=Ht(),Ii=vi(),w2=m2(gp()),Os=class extends Pa.AgentError{constructor(e,r,n,i){super(["Call failed:",` Canister: ${e.toText()}`,` Method: ${r} (${n})`,...Object.getOwnPropertyNames(i).map(s=>` "${s}": ${JSON.stringify(i[s])}`)].join(`
56
+ `)),this.canisterId=e,this.methodName=r,this.type=n,this.props=i}};Ge.ActorCallError=Os;var Ia=class extends Os{constructor(e,r,n){var i;super(e,r,"query",{Status:n.status,Code:(i=Tl.ReplicaRejectCode[n.reject_code])!==null&&i!==void 0?i:`Unknown Code "${n.reject_code}"`,Message:n.reject_message}),this.result=n}};Ge.QueryCallRejectedError=Ia;var Ns=class extends Os{constructor(e,r,n,i,s,o,a){super(e,r,"update",Object.assign({"Request ID":(0,_2.toHex)(n)},i.body?Object.assign(Object.assign({},a?{"Error code":a}:{}),{"Reject code":String(s),"Reject message":o}):{"HTTP status code":i.status.toString(),"HTTP status text":i.statusText})),this.requestId=n,this.response=i,this.reject_code=s,this.reject_message=o,this.error_code=a}};Ge.UpdateCallRejectedError=Ns;var ar=Symbol.for("ic-agent-metadata"),Rs=class t{constructor(e){this[ar]=Object.freeze(e)}static agentOf(e){return e[ar].config.agent}static interfaceOf(e){return e[ar].service}static canisterIdOf(e){return _r.Principal.from(e[ar].config.canisterId)}static async install(e,r){let n=e.mode===void 0?{install:null}:e.mode,i=e.arg?[...new Uint8Array(e.arg)]:[],s=[...new Uint8Array(e.module)],o=typeof r.canisterId=="string"?_r.Principal.fromText(r.canisterId):r.canisterId;await Al(r).install_code({mode:n,arg:i,wasm_module:s,canister_id:o,sender_canister_version:[]})}static async createCanister(e,r){function n(s){return[{controllers:s.controllers?[s.controllers]:[],compute_allocation:s.compute_allocation?[s.compute_allocation]:[],freezing_threshold:s.freezing_threshold?[s.freezing_threshold]:[],memory_allocation:s.memory_allocation?[s.memory_allocation]:[],reserved_cycles_limit:[],log_visibility:[],wasm_memory_limit:[]}]}let{canister_id:i}=await Al(e||{}).provisional_create_canister_with_cycles({amount:[],settings:n(r||{}),specified_id:[],sender_canister_version:[]});return i}static async createAndInstallCanister(e,r,n){let i=await this.createCanister(n);return await this.install(Object.assign({},r),Object.assign(Object.assign({},n),{canisterId:i})),this.createActor(e,Object.assign(Object.assign({},n),{canisterId:i}))}static createActorClass(e,r){let n=e({IDL:Bs.IDL});class i extends t{constructor(o){if(!o.canisterId)throw new Pa.AgentError(`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"?_r.Principal.fromText(o.canisterId):o.canisterId;super({config:Object.assign(Object.assign(Object.assign({},bp),o),{canisterId:a}),service:n});for(let[c,f]of n._fields)r?.httpDetails&&f.annotations.push(Ge.ACTOR_METHOD_WITH_HTTP_DETAILS),r?.certificate&&f.annotations.push(Ge.ACTOR_METHOD_WITH_CERTIFICATE),this[c]=E2(this,c,f,o.blsVerify)}}return i}static createActor(e,r){if(!r.canisterId)throw new Pa.AgentError(`Canister ID is required, but received ${typeof r.canisterId} instead. If you are using automatically generated declarations, this may be because your application is not setting the canister ID in process.env correctly.`);return new(this.createActorClass(e))(r)}static createActorWithHttpDetails(e,r){return new(this.createActorClass(e,{httpDetails:!0}))(r)}static createActorWithExtendedDetails(e,r,n={httpDetails:!0,certificate:!0}){return new(this.createActorClass(e,n))(r)}};Ge.Actor=Rs;function Ui(t,e){let r=Bs.IDL.decode(t,b2.Buffer.from(e));switch(r.length){case 0:return;case 1:return r[0];default:return r}}var bp={pollingStrategyFactory:mp.strategy.defaultStrategy};Ge.ACTOR_METHOD_WITH_HTTP_DETAILS="http-details";Ge.ACTOR_METHOD_WITH_CERTIFICATE="certificate";function E2(t,e,r,n){let i;r.annotations.includes("query")||r.annotations.includes("composite_query")?i=async(o,...a)=>{var c,f;o=Object.assign(Object.assign({},o),(f=(c=t[ar].config).queryTransform)===null||f===void 0?void 0:f.call(c,e,a,Object.assign(Object.assign({},t[ar].config),o)));let d=o.agent||t[ar].config.agent||(0,Tl.getDefaultAgent)(),h=_r.Principal.from(o.canisterId||t[ar].config.canisterId),m=Bs.IDL.encode(r.argTypes,a),_=await d.query(h,{methodName:e,arg:m,effectiveCanisterId:o.effectiveCanisterId}),u=Object.assign(Object.assign({},_.httpDetails),{requestDetails:_.requestDetails});switch(_.status){case"rejected":throw new Ia(h,e,_);case"replied":return r.annotations.includes(Ge.ACTOR_METHOD_WITH_HTTP_DETAILS)?{httpDetails:u,result:Ui(r.retTypes,_.reply.arg)}:Ui(r.retTypes,_.reply.arg)}}:i=async(o,...a)=>{var c,f;o=Object.assign(Object.assign({},o),(f=(c=t[ar].config).callTransform)===null||f===void 0?void 0:f.call(c,e,a,Object.assign(Object.assign({},t[ar].config),o)));let d=o.agent||t[ar].config.agent||(0,Tl.getDefaultAgent)(),{canisterId:h,effectiveCanisterId:m,pollingStrategyFactory:_}=Object.assign(Object.assign(Object.assign({},bp),t[ar].config),o),u=_r.Principal.from(h),T=m!==void 0?_r.Principal.from(m):u,O=Bs.IDL.encode(r.argTypes,a);if(d.rootKey==null)throw new Pa.AgentError("Agent root key not initialized before making call");let{requestId:R,response:F,requestDetails:M}=await d.call(u,{methodName:e,arg:O,effectiveCanisterId:T}),K,x;if(F.body&&F.body.certificate){let j=F.body.certificate;x=await Ii.Certificate.create({certificate:(0,Bs.bufFromBufLike)(j),rootKey:d.rootKey,canisterId:_r.Principal.from(h),blsVerify:n});let ie=[new TextEncoder().encode("request_status"),R];switch(new TextDecoder().decode((0,Ii.lookupResultToBuffer)(x.lookup([...ie,"status"])))){case"replied":K=(0,Ii.lookupResultToBuffer)(x.lookup([...ie,"reply"]));break;case"rejected":{let ne=new Uint8Array((0,Ii.lookupResultToBuffer)(x.lookup([...ie,"reject_code"])))[0],w=new TextDecoder().decode((0,Ii.lookupResultToBuffer)(x.lookup([...ie,"reject_message"]))),b=(0,Ii.lookupResultToBuffer)(x.lookup([...ie,"error_code"])),B=b?new TextDecoder().decode(b):void 0;throw new Ns(u,e,R,F,ne,w,B)}}}else if(F.body&&"reject_message"in F.body){let{reject_code:j,reject_message:ie,error_code:ee}=F.body;throw new Ns(u,e,R,F,j,ie,ee)}if(F.status===202){let j=_(),ie=await(0,mp.pollForResponse)(d,T,R,j,n);x=ie.certificate,K=ie.reply}let $=r.annotations.includes(Ge.ACTOR_METHOD_WITH_HTTP_DETAILS),W=r.annotations.includes(Ge.ACTOR_METHOD_WITH_CERTIFICATE),D=Object.assign(Object.assign({},F),{requestDetails:M});if(K!==void 0)return $&&W?{httpDetails:D,certificate:x,result:Ui(r.retTypes,K)}:W?{certificate:x,result:Ui(r.retTypes,K)}:$?{httpDetails:D,result:Ui(r.retTypes,K)}:Ui(r.retTypes,K);if(r.retTypes.length===0)return $?{httpDetails:F,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 Al(t){function e(r,n){if(t.effectiveCanisterId)return{effectiveCanisterId:_r.Principal.from(t.effectiveCanisterId)};let i=n[0],s=_r.Principal.fromHex("");return i&&typeof i=="object"&&i.canister_id&&(s=_r.Principal.from(i.canister_id)),{effectiveCanisterId:s}}return Rs.createActor(w2.default,Object.assign(Object.assign(Object.assign({},t),{canisterId:_r.Principal.fromHex("")}),{callTransform:e,queryTransform:e}))}Ge.getManagementCanister=Al;var Sl=class extends Rs{constructor(e){super(e)}};Ge.AdvancedActor=Sl});var _p=Q(Bl=>{"use strict";Object.defineProperty(Bl,"__esModule",{value:!0});Bl.default=({IDL:t})=>t.Service({retrieve:t.Func([t.Text],[t.Vec(t.Nat8)],["query"]),store:t.Func([t.Text,t.Vec(t.Nat8)],[],[])})});var wp=Q(Fi=>{"use strict";var x2=Fi&&Fi.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Fi,"__esModule",{value:!0});Fi.createAssetCanisterActor=void 0;var v2=Ua(),T2=x2(_p());function A2(t){return v2.Actor.createActor(T2.default,t)}Fi.createAssetCanisterActor=A2});var Ep=Q(Hr=>{"use strict";var S2=Hr&&Hr.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),B2=Hr&&Hr.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),O2=Hr&&Hr.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&S2(e,t,r);return B2(e,t),e};Object.defineProperty(Hr,"__esModule",{value:!0});Hr.fetchCandid=void 0;var N2=Tt(),R2=O2(ms()),P2=wl(),I2=Ua();async function U2(t,e){e||(e=await P2.HttpAgent.create());let n=(await R2.request({agent:e,canisterId:N2.Principal.fromText(t),paths:["candid"]})).get("candid");if(n)return n;let i=({IDL:o})=>o.Service({__get_candid_interface_tmp_hack:o.Func([],[o.Text],["query"])});return await I2.Actor.createActor(i,{agent:e,canisterId:t}).__get_candid_interface_tmp_hack()}Hr.fetchCandid=U2});var wr=Q(Re=>{"use strict";var xp=Re&&Re.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),F2=Re&&Re.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Ct=Re&&Re.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&xp(e,t,r)},Ol=Re&&Re.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&xp(e,t,r);return F2(e,t),e};Object.defineProperty(Re,"__esModule",{value:!0});Re.Cbor=Re.CanisterStatus=Re.polling=void 0;Ct(Ua(),Re);Ct(gs(),Re);Ct(qo(),Re);Ct(os(),Re);Ct(hu(),Re);Ct(wp(),Re);Ct(vi(),Re);Ct(dl(),Re);Ct(Ep(),Re);Ct(hl(),Re);Ct(rs(),Re);Ct(Yu(),Re);Ct(Ht(),Re);Ct(xu(),Re);Re.polling=Ol(Ra());Re.CanisterStatus=Ol(ms());Re.Cbor=Ol(ss());Ct(Ra(),Re)});var Sp=Q(Vr=>{"use strict";var qa=Vr&&Vr.__classPrivateFieldSet||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},Bn=Vr&&Vr.__classPrivateFieldGet||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)},Fa,Ma,Ci,ji;Object.defineProperty(Vr,"__esModule",{value:!0});Vr.Ed25519KeyIdentity=Vr.Ed25519PublicKey=void 0;var M2=wr(),Jt=wr(),Ps=ll();function Ap(t){return t!==null&&typeof t=="object"}var Xn=class t{constructor(e){if(Fa.set(this,void 0),Ma.set(this,void 0),e.byteLength!==t.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");qa(this,Fa,e,"f"),qa(this,Ma,t.derEncode(e),"f")}static from(e){if(typeof e=="string"){let r=(0,Jt.fromHex)(e);return this.fromRaw(r)}else if(Ap(e)){let r=e;if(Ap(r)&&Object.hasOwnProperty.call(r,"__derEncodedPublicKey__"))return this.fromDer(r);if(ArrayBuffer.isView(r)){let n=r;return this.fromRaw((0,Jt.bufFromBufLike)(n.buffer))}else{if(r instanceof ArrayBuffer)return this.fromRaw(r);if("rawKey"in r)return this.fromRaw(r.rawKey);if("derKey"in r)return this.fromDer(r.derKey);if("toDer"in r)return this.fromDer(r.toDer())}}throw new Error("Cannot construct Ed25519PublicKey from the provided key.")}static fromRaw(e){return new t(e)}static fromDer(e){return new t(this.derDecode(e))}static derEncode(e){let r=(0,Jt.wrapDER)(e,Jt.ED25519_OID).buffer;return r.__derEncodedPublicKey__=void 0,r}static derDecode(e){let r=(0,Jt.unwrapDER)(e,Jt.ED25519_OID);if(r.length!==this.RAW_KEY_LENGTH)throw new Error("An Ed25519 public key must be exactly 32bytes long");return r}get rawKey(){return Bn(this,Fa,"f")}get derKey(){return Bn(this,Ma,"f")}toDer(){return this.derKey}toRaw(){return this.rawKey}};Vr.Ed25519PublicKey=Xn;Fa=new WeakMap,Ma=new WeakMap;Xn.RAW_KEY_LENGTH=32;var Nl=class t extends Jt.SignIdentity{constructor(e,r){super(),Ci.set(this,void 0),ji.set(this,void 0),qa(this,Ci,Xn.from(e),"f"),qa(this,ji,new Uint8Array(r),"f")}static generate(e){if(e&&e.length!==32)throw new Error("Ed25519 Seed needs to be 32 bytes long.");e||(e=Ps.ed25519.utils.randomPrivateKey()),(0,M2.bufEquals)(e,new Uint8Array(new Array(32).fill(0)))&&console.warn("Seed is all zeros. This is not a secure seed. Please provide a seed with sufficient entropy if this is a production environment.");let r=new Uint8Array(32);for(let i=0;i<32;i++)r[i]=new Uint8Array(e)[i];let n=Ps.ed25519.getPublicKey(r);return t.fromKeyPair(n,r)}static fromParsedJson(e){let[r,n]=e;return new t(Xn.fromDer((0,Jt.fromHex)(r)),(0,Jt.fromHex)(n))}static fromJSON(e){let r=JSON.parse(e);if(Array.isArray(r)){if(typeof r[0]=="string"&&typeof r[1]=="string")return this.fromParsedJson([r[0],r[1]]);throw new Error("Deserialization error: JSON must have at least 2 items.")}throw new Error(`Deserialization error: Invalid JSON type for string: ${JSON.stringify(e)}`)}static fromKeyPair(e,r){return new t(Xn.fromRaw(e),r)}static fromSecretKey(e){let r=Ps.ed25519.getPublicKey(new Uint8Array(e));return t.fromKeyPair(r,e)}toJSON(){return[(0,Jt.toHex)(Bn(this,Ci,"f").toDer()),(0,Jt.toHex)(Bn(this,ji,"f"))]}getKeyPair(){return{secretKey:Bn(this,ji,"f"),publicKey:Bn(this,Ci,"f")}}getPublicKey(){return Bn(this,Ci,"f")}async sign(e){let r=new Uint8Array(e),n=(0,Jt.uint8ToBuf)(Ps.ed25519.sign(r,Bn(this,ji,"f").slice(0,32)));return Object.defineProperty(n,"__signature__",{enumerable:!1,value:void 0}),n}static verify(e,r,n){let[i,s,o]=[e,r,n].map(a=>(typeof a=="string"&&(a=(0,Jt.fromHex)(a)),a instanceof Uint8Array&&(a=a.buffer),new Uint8Array(a)));return Ps.ed25519.verify(s,i,o)}};Vr.Ed25519KeyIdentity=Nl;Ci=new WeakMap,ji=new WeakMap});var Op=Q(Jn=>{"use strict";Object.defineProperty(Jn,"__esModule",{value:!0});Jn.ECDSAKeyIdentity=Jn.CryptoError=void 0;var q2=wr(),Ca=class t extends Error{constructor(e){super(e),this.message=e,Object.setPrototypeOf(this,t.prototype)}};Jn.CryptoError=Ca;function Bp(t){if(typeof global<"u"&&global.crypto&&global.crypto.subtle)return global.crypto.subtle;if(t)return t;if(typeof crypto<"u"&&crypto.subtle)return crypto.subtle;throw new Ca("Global crypto was not available and none was provided. Please inlcude a SubtleCrypto implementation. See https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto")}var ja=class t extends q2.SignIdentity{constructor(e,r,n){super(),this._keyPair=e,this._derKey=r,this._subtleCrypto=n}static async generate(e){let{extractable:r=!1,keyUsages:n=["sign","verify"],subtleCrypto:i}=e??{},s=Bp(i),o=await s.generateKey({name:"ECDSA",namedCurve:"P-256"},r,n),a=await s.exportKey("spki",o.publicKey);return new this(o,a,s)}static async fromKeyPair(e,r){let n=Bp(r),i=await n.exportKey("spki",e.publicKey);return new t(e,i,n)}getKeyPair(){return this._keyPair}getPublicKey(){let e=this._derKey,r=Object.create(this._keyPair.publicKey);return r.toDer=function(){return e},r}async sign(e){let r={name:"ECDSA",hash:{name:"SHA-256"}};return await this._subtleCrypto.sign(r,this._keyPair.privateKey,e)}};Jn.ECDSAKeyIdentity=ja;Jn.default=ja});var Pl=Q(Nn=>{"use strict";var C2=Nn&&Nn.__classPrivateFieldSet||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},Is=Nn&&Nn.__classPrivateFieldGet||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)},On;Object.defineProperty(Nn,"__esModule",{value:!0});Nn.PartialIdentity=void 0;var j2=Tt(),Rl=class{constructor(e){On.set(this,void 0),C2(this,On,e,"f")}get rawKey(){return Is(this,On,"f").rawKey}get derKey(){return Is(this,On,"f").derKey}toDer(){return Is(this,On,"f").toDer()}getPublicKey(){return Is(this,On,"f")}getPrincipal(){return j2.Principal.from(Is(this,On,"f").rawKey)}transformRequest(){return Promise.reject("Not implemented. You are attempting to use a partial identity to sign calls, but this identity only has access to the public key.To sign calls, use a DelegationIdentity instead.")}};Nn.PartialIdentity=Rl;On=new WeakMap});var Np=Q(Ze=>{"use strict";var k2=Ze&&Ze.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),H2=Ze&&Ze.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),V2=Ze&&Ze.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&k2(e,t,r);return H2(e,t),e},$2=Ze&&Ze.__classPrivateFieldSet||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},K2=Ze&&Ze.__classPrivateFieldGet||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)},G2=Ze&&Ze.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},ka;Object.defineProperty(Ze,"__esModule",{value:!0});Ze.isDelegationValid=Ze.PartialDelegationIdentity=Ze.DelegationIdentity=Ze.DelegationChain=Ze.Delegation=void 0;var Rn=wr(),Ul=Tt(),Us=V2(is()),Y2=Pl(),W2=new TextEncoder().encode("ic-request-auth-delegation"),z2=new TextEncoder().encode(`
57
+ ic-request`);function Il(t){if(typeof t!="string"||t.length<64)throw new Error("Invalid public key.");return(0,Rn.fromHex)(t)}var Fs=class{constructor(e,r,n){this.pubkey=e,this.expiration=r,this.targets=n}toCBOR(){return Us.value.map(Object.assign({pubkey:Us.value.bytes(this.pubkey),expiration:Us.value.u64(this.expiration.toString(16),16)},this.targets&&{targets:Us.value.array(this.targets.map(e=>Us.value.bytes(e.toUint8Array())))}))}toJSON(){return Object.assign({expiration:this.expiration.toString(16),pubkey:(0,Rn.toHex)(this.pubkey)},this.targets&&{targets:this.targets.map(e=>e.toHex())})}};Ze.Delegation=Fs;async function D2(t,e,r,n){let i=new Fs(e.toDer(),BigInt(+r)*BigInt(1e6),n),s=new Uint8Array([...W2,...new Uint8Array((0,Rn.requestIdOf)(i))]),o=await t.sign(s);return{delegation:i,signature:o}}var Fl=class t{constructor(e,r){this.delegations=e,this.publicKey=r}static async create(e,r,n=new Date(Date.now()+15*60*1e3),i={}){var s,o;let a=await D2(e,r,n,i.targets);return new t([...((s=i.previous)===null||s===void 0?void 0:s.delegations)||[],a],((o=i.previous)===null||o===void 0?void 0:o.publicKey)||e.getPublicKey().toDer())}static fromJSON(e){let{publicKey:r,delegations:n}=typeof e=="string"?JSON.parse(e):e;if(!Array.isArray(n))throw new Error("Invalid delegations.");let i=n.map(s=>{let{delegation:o,signature:a}=s,{pubkey:c,expiration:f,targets:d}=o;if(d!==void 0&&!Array.isArray(d))throw new Error("Invalid targets.");return{delegation:new Fs(Il(c),BigInt("0x"+f),d&&d.map(h=>{if(typeof h!="string")throw new Error("Invalid target.");return Ul.Principal.fromHex(h)})),signature:Il(a)}});return new this(i,Il(r))}static fromDelegations(e,r){return new this(e,r)}toJSON(){return{delegations:this.delegations.map(e=>{let{delegation:r,signature:n}=e,{targets:i}=r;return{delegation:Object.assign({expiration:r.expiration.toString(16),pubkey:(0,Rn.toHex)(r.pubkey)},i&&{targets:i.map(s=>s.toHex())}),signature:(0,Rn.toHex)(n)}}),publicKey:(0,Rn.toHex)(this.publicKey)}}};Ze.DelegationChain=Fl;var Ml=class extends Rn.SignIdentity{constructor(e,r){super(),this._inner=e,this._delegation=r}static fromDelegation(e,r){return new this(e,r)}getDelegation(){return this._delegation}getPublicKey(){return{derKey:this._delegation.publicKey,toDer:()=>this._delegation.publicKey}}sign(e){return this._inner.sign(e)}async transformRequest(e){let{body:r}=e,n=G2(e,["body"]),i=await(0,Rn.requestIdOf)(r);return Object.assign(Object.assign({},n),{body:{content:r,sender_sig:await this.sign(new Uint8Array([...z2,...new Uint8Array(i)])),sender_delegation:this._delegation.delegations,sender_pubkey:this._delegation.publicKey}})}};Ze.DelegationIdentity=Ml;var ql=class t extends Y2.PartialIdentity{constructor(e,r){super(e),ka.set(this,void 0),$2(this,ka,r,"f")}get delegation(){return K2(this,ka,"f")}static fromDelegation(e,r){return new t(e,r)}};Ze.PartialDelegationIdentity=ql;ka=new WeakMap;function Z2(t,e){for(let{delegation:i}of t.delegations)if(+new Date(Number(i.expiration/BigInt(1e6)))<=+Date.now())return!1;let r=[],n=e?.scope;n&&(Array.isArray(n)?r.push(...n.map(i=>typeof i=="string"?Ul.Principal.fromText(i):i)):r.push(typeof n=="string"?Ul.Principal.fromText(n):n));for(let i of r){let s=i.toText();for(let{delegation:o}of t.delegations){if(o.targets===void 0)continue;let a=!0;for(let c of o.targets)if(c.toText()===s){a=!1;break}if(a)return!1}}return!0}Ze.isDelegationValid=Z2});var Rp=Q(Pn=>{"use strict";var X2=Pn&&Pn.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Pn,"__esModule",{value:!0});Pn.WebAuthnIdentity=Pn.CosePublicKey=void 0;var Ln=wr(),Cl=X2(So()),J2=Fn(),L2=mi();function Q2(t){return(0,Ln.wrapDER)(t,Ln.DER_COSE_OID).buffer}function eE(t){let e=new DataView(new ArrayBuffer(2)),r=t.slice(53,55);[...new Uint8Array(r)].forEach((i,s)=>e.setUint8(s,i));let n=e.getUint16(0);return t.slice(55+n)}var Ha=class{constructor(e){this._cose=e,this._encodedKey=Q2(e)}toDer(){return this._encodedKey}getCose(){return this._cose}};Pn.CosePublicKey=Ha;function tE(t="<ic0.app>"){return typeof t=="string"?Uint8Array.from(t,e=>e.charCodeAt(0)):t}async function rE(t){let e=await navigator.credentials.create(t??{publicKey:{authenticatorSelection:{userVerification:"preferred"},attestation:"direct",challenge:tE(),pubKeyCredParams:[{type:"public-key",alg:jl.ECDSA_WITH_SHA256}],rp:{name:"Internet Identity Service"},user:{id:(0,J2.randomBytes)(16),name:"Internet Identity",displayName:"Internet Identity"}}});return e===null?null:{id:e.id,response:e.response,type:e.type,authenticatorAttachment:e.authenticatorAttachment,getClientExtensionResults:e.getClientExtensionResults,rawId:(0,L2.bufFromBufLike)(e.rawId)}}var jl;(function(t){t[t.ECDSA_WITH_SHA256=-7]="ECDSA_WITH_SHA256"})(jl||(jl={}));var kl=class extends Ln.SignIdentity{constructor(e,r,n){super(),this.rawId=e,this.authenticatorAttachment=n,this._publicKey=new Ha(r)}static fromJSON(e){let{publicKey:r,rawId:n}=JSON.parse(e);if(typeof r!="string"||typeof n!="string")throw new Error("Invalid JSON string.");return new this((0,Ln.fromHex)(n),(0,Ln.fromHex)(r),void 0)}static async create(e){var r;let n=await rE(e);if(!n||n.type!=="public-key")throw new Error("Could not create credentials.");let i=n.response;if(i.attestationObject===void 0)throw new Error("Was expecting an attestation response.");let s=Cl.default.decodeFirst(new Uint8Array(i.attestationObject));return new this(n.rawId,eE(s.authData),(r=n.authenticatorAttachment)!==null&&r!==void 0?r:void 0)}getPublicKey(){return this._publicKey}getAuthenticatorAttachment(){return this.authenticatorAttachment}async sign(e){let r=await navigator.credentials.get({publicKey:{allowCredentials:[{type:"public-key",id:this.rawId}],challenge:e,userVerification:"preferred"}});r.authenticatorAttachment!==null&&(this.authenticatorAttachment=r.authenticatorAttachment);let n=r.response,i=Cl.default.encode(new Cl.default.Tagged(55799,{authenticator_data:new Uint8Array(n.authenticatorData),client_data_json:new TextDecoder().decode(n.clientDataJSON),signature:new Uint8Array(n.signature)}));if(!i)throw new Error("failed to encode cbor");return i.buffer}toJSON(){return{publicKey:(0,Ln.toHex)(this._publicKey.getCose()),rawId:(0,Ln.toHex)(this.rawId)}}};Pn.WebAuthnIdentity=kl});var Ip=Q(Ye=>{"use strict";var nE=Ye&&Ye.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Vl=Ye&&Ye.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&nE(e,t,r)};Object.defineProperty(Ye,"__esModule",{value:!0});Ye.Secp256k1KeyIdentity=Ye.ED25519_OID=Ye.DER_COSE_OID=Ye.unwrapDER=Ye.wrapDER=Ye.WebAuthnIdentity=Ye.Ed25519PublicKey=Ye.Ed25519KeyIdentity=void 0;var Pp=Sp();Object.defineProperty(Ye,"Ed25519KeyIdentity",{enumerable:!0,get:function(){return Pp.Ed25519KeyIdentity}});Object.defineProperty(Ye,"Ed25519PublicKey",{enumerable:!0,get:function(){return Pp.Ed25519PublicKey}});Vl(Op(),Ye);Vl(Np(),Ye);Vl(Pl(),Ye);var iE=Rp();Object.defineProperty(Ye,"WebAuthnIdentity",{enumerable:!0,get:function(){return iE.WebAuthnIdentity}});var Va=wr();Object.defineProperty(Ye,"wrapDER",{enumerable:!0,get:function(){return Va.wrapDER}});Object.defineProperty(Ye,"unwrapDER",{enumerable:!0,get:function(){return Va.unwrapDER}});Object.defineProperty(Ye,"DER_COSE_OID",{enumerable:!0,get:function(){return Va.DER_COSE_OID}});Object.defineProperty(Ye,"ED25519_OID",{enumerable:!0,get:function(){return Va.ED25519_OID}});var Hl=class{constructor(){throw new Error("Secp256k1KeyIdentity has been moved to a new repo: @dfinity/identity-secp256k1")}};Ye.Secp256k1KeyIdentity=Hl});var Kl=Q($a=>{"use strict";Object.defineProperty($a,"__esModule",{value:!0});$a.IdleManager=void 0;var Up=["mousedown","mousemove","keydown","touchstart","wheel"],$l=class{constructor(e={}){var r;this.callbacks=[],this.idleTimeout=10*60*1e3,this.timeoutID=void 0;let{onIdle:n,idleTimeout:i=10*60*1e3}=e||{};this.callbacks=n?[n]:[],this.idleTimeout=i;let s=this._resetTimer.bind(this);window.addEventListener("load",s,!0),Up.forEach(function(a){document.addEventListener(a,s,!0)});let o=(a,c)=>{let f;return(...d)=>{let h=this,m=function(){f=void 0,a.apply(h,d)};clearTimeout(f),f=window.setTimeout(m,c)}};if(e?.captureScroll){let a=o(s,(r=e?.scrollDebounce)!==null&&r!==void 0?r:100);window.addEventListener("scroll",a,!0)}s()}static create(e={}){return new this(e)}registerCallback(e){this.callbacks.push(e)}exit(){clearTimeout(this.timeoutID),window.removeEventListener("load",this._resetTimer,!0);let e=this._resetTimer.bind(this);Up.forEach(function(r){document.removeEventListener(r,e,!0)}),this.callbacks.forEach(r=>r())}_resetTimer(){let e=this.exit.bind(this);window.clearTimeout(this.timeoutID),this.timeoutID=window.setTimeout(e,this.idleTimeout)}};$a.IdleManager=$l});function oE(){return Fp||(Fp=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function aE(){return Mp||(Mp=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}function cE(t){let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("success",s),t.removeEventListener("error",o)},s=()=>{r(cr(t.result)),i()},o=()=>{n(t.error),i()};t.addEventListener("success",s),t.addEventListener("error",o)});return e.then(r=>{r instanceof IDBCursor&&qp.set(r,t)}).catch(()=>{}),zl.set(e,t),e}function uE(t){if(Yl.has(t))return;let e=new Promise((r,n)=>{let i=()=>{t.removeEventListener("complete",s),t.removeEventListener("error",o),t.removeEventListener("abort",o)},s=()=>{r(),i()},o=()=>{n(t.error||new DOMException("AbortError","AbortError")),i()};t.addEventListener("complete",s),t.addEventListener("error",o),t.addEventListener("abort",o)});Yl.set(t,e)}function jp(t){Wl=t(Wl)}function lE(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){let n=t.call(Ms(this),e,...r);return Cp.set(n,e.sort?e.sort():[e]),cr(n)}:aE().includes(t)?function(...e){return t.apply(Ms(this),e),cr(qp.get(this))}:function(...e){return cr(t.apply(Ms(this),e))}}function fE(t){return typeof t=="function"?lE(t):(t instanceof IDBTransaction&&uE(t),sE(t,oE())?new Proxy(t,Wl):t)}function cr(t){if(t instanceof IDBRequest)return cE(t);if(Gl.has(t))return Gl.get(t);let e=fE(t);return e!==t&&(Gl.set(t,e),zl.set(e,t)),e}var sE,Fp,Mp,qp,Yl,Cp,Gl,zl,Wl,Ms,Dl=ff(()=>{sE=(t,e)=>e.some(r=>t instanceof r);qp=new WeakMap,Yl=new WeakMap,Cp=new WeakMap,Gl=new WeakMap,zl=new WeakMap;Wl={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return Yl.get(t);if(e==="objectStoreNames")return t.objectStoreNames||Cp.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return cr(t[e])},set(t,e,r){return t[e]=r,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};Ms=t=>zl.get(t)});var Hp={};Qy(Hp,{deleteDB:()=>hE,openDB:()=>dE,unwrap:()=>Ms,wrap:()=>cr});function dE(t,e,{blocked:r,upgrade:n,blocking:i,terminated:s}={}){let o=indexedDB.open(t,e),a=cr(o);return n&&o.addEventListener("upgradeneeded",c=>{n(cr(o.result),c.oldVersion,c.newVersion,cr(o.transaction),c)}),r&&o.addEventListener("blocked",c=>r(c.oldVersion,c.newVersion,c)),a.then(c=>{s&&c.addEventListener("close",()=>s()),i&&c.addEventListener("versionchange",f=>i(f.oldVersion,f.newVersion,f))}).catch(()=>{}),a}function hE(t,{blocked:e}={}){let r=indexedDB.deleteDatabase(t);return e&&r.addEventListener("blocked",n=>e(n.oldVersion,n)),cr(r).then(()=>{})}function kp(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(Zl.get(e))return Zl.get(e);let r=e.replace(/FromIndex$/,""),n=e!==r,i=yE.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(i||pE.includes(r)))return;let s=async function(o,...a){let c=this.transaction(o,i?"readwrite":"readonly"),f=c.store;return n&&(f=f.index(a.shift())),(await Promise.all([f[r](...a),i&&c.done]))[0]};return Zl.set(e,s),s}var pE,yE,Zl,Vp=ff(()=>{Dl();Dl();pE=["get","getKey","getAll","getAllKeys","count"],yE=["put","add","delete","clear"],Zl=new Map;jp(t=>({...t,get:(e,r,n)=>kp(e,r)||t.get(e,r,n),has:(e,r)=>!!kp(e,r)||t.has(e,r)}))});var Jl=Q(Ka=>{"use strict";Object.defineProperty(Ka,"__esModule",{value:!0});Ka.IdbKeyVal=void 0;var gE=(Vp(),eg(Hp)),qs=Ga(),$p="auth-client-db",Kp="ic-keyval",mE=async(t=$p,e=Kp,r)=>(qs.isBrowser&&(localStorage!=null&&localStorage.getItem(qs.KEY_STORAGE_DELEGATION))&&(localStorage.removeItem(qs.KEY_STORAGE_DELEGATION),localStorage.removeItem(qs.KEY_STORAGE_KEY)),await(0,gE.openDB)(t,r,{upgrade:n=>{n.objectStoreNames.contains(e)&&n.clear(e),n.createObjectStore(e)}}));async function bE(t,e,r){return await t.get(e,r)}async function _E(t,e,r,n){return await t.put(e,n,r)}async function wE(t,e,r){return await t.delete(e,r)}var Xl=class t{constructor(e,r){this._db=e,this._storeName=r}static async create(e){let{dbName:r=$p,storeName:n=Kp,version:i=qs.DB_VERSION}=e??{},s=await mE(r,n,i);return new t(s,n)}async set(e,r){return await _E(this._db,this._storeName,e,r)}async get(e){var r;return(r=await bE(this._db,this._storeName,e))!==null&&r!==void 0?r:null}async remove(e){return await wE(this._db,this._storeName,e)}};Ka.IdbKeyVal=Xl});var Ga=Q(nt=>{"use strict";var EE=nt&&nt.__classPrivateFieldSet||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},xE=nt&&nt.__classPrivateFieldGet||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)},Ya;Object.defineProperty(nt,"__esModule",{value:!0});nt.IdbStorage=nt.LocalStorage=nt.isBrowser=nt.DB_VERSION=nt.KEY_VECTOR=nt.KEY_STORAGE_DELEGATION=nt.KEY_STORAGE_KEY=void 0;var vE=Jl();nt.KEY_STORAGE_KEY="identity";nt.KEY_STORAGE_DELEGATION="delegation";nt.KEY_VECTOR="iv";nt.DB_VERSION=1;nt.isBrowser=typeof window<"u";var Ll=class{constructor(e="ic-",r){this.prefix=e,this._localStorage=r}get(e){return Promise.resolve(this._getLocalStorage().getItem(this.prefix+e))}set(e,r){return this._getLocalStorage().setItem(this.prefix+e,r),Promise.resolve()}remove(e){return this._getLocalStorage().removeItem(this.prefix+e),Promise.resolve()}_getLocalStorage(){if(this._localStorage)return this._localStorage;let e=typeof window>"u"?typeof global>"u"?typeof self>"u"?void 0:self.localStorage:global.localStorage:window.localStorage;if(!e)throw new Error("Could not find local storage.");return e}};nt.LocalStorage=Ll;var Ql=class{constructor(e){Ya.set(this,void 0),EE(this,Ya,e??{},"f")}get _db(){return new Promise(e=>{if(this.initializedDb){e(this.initializedDb);return}vE.IdbKeyVal.create(xE(this,Ya,"f")).then(r=>{this.initializedDb=r,e(r)})})}async get(e){return await(await this._db).get(e)}async set(e,r){await(await this._db).set(e,r)}async remove(e){await(await this._db).remove(e)}};nt.IdbStorage=Ql;Ya=new WeakMap});var Wp=Q(Qe=>{"use strict";var TE=Qe&&Qe.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),AE=Qe&&Qe.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&TE(e,t,r)};Object.defineProperty(Qe,"__esModule",{value:!0});Qe.AuthClient=Qe.ERROR_USER_INTERRUPT=Qe.IdbKeyVal=Qe.KEY_STORAGE_KEY=Qe.KEY_STORAGE_DELEGATION=Qe.LocalStorage=Qe.IdbStorage=void 0;var Gp=wr(),Lt=Ip(),Yp=Kl(),xt=Ga(),Wa=Ga();Object.defineProperty(Qe,"IdbStorage",{enumerable:!0,get:function(){return Wa.IdbStorage}});Object.defineProperty(Qe,"LocalStorage",{enumerable:!0,get:function(){return Wa.LocalStorage}});Object.defineProperty(Qe,"KEY_STORAGE_DELEGATION",{enumerable:!0,get:function(){return Wa.KEY_STORAGE_DELEGATION}});Object.defineProperty(Qe,"KEY_STORAGE_KEY",{enumerable:!0,get:function(){return Wa.KEY_STORAGE_KEY}});var SE=Jl();Object.defineProperty(Qe,"IdbKeyVal",{enumerable:!0,get:function(){return SE.IdbKeyVal}});var BE="https://identity.ic0.app",OE="#authorize",ef="ECDSA",tf="Ed25519",NE=500;Qe.ERROR_USER_INTERRUPT="UserInterrupt";AE(Kl(),Qe);var nf=class{constructor(e,r,n,i,s,o,a,c){this._identity=e,this._key=r,this._chain=n,this._storage=i,this.idleManager=s,this._createOptions=o,this._idpWindow=a,this._eventHandler=c,this._registerDefaultIdleCallback()}static async create(e={}){var r,n,i;let s=(r=e.storage)!==null&&r!==void 0?r:new xt.IdbStorage,o=(n=e.keyType)!==null&&n!==void 0?n:ef,a=null;if(e.identity)a=e.identity;else{let h=await s.get(xt.KEY_STORAGE_KEY);if(!h&&xt.isBrowser)try{let m=new xt.LocalStorage,_=await m.get(xt.KEY_STORAGE_DELEGATION),u=await m.get(xt.KEY_STORAGE_KEY);_&&u&&o===ef&&(console.log("Discovered an identity stored in localstorage. Migrating to IndexedDB"),await s.set(xt.KEY_STORAGE_DELEGATION,_),await s.set(xt.KEY_STORAGE_KEY,u),h=_,await m.remove(xt.KEY_STORAGE_DELEGATION),await m.remove(xt.KEY_STORAGE_KEY))}catch(m){console.error("error while attempting to recover localstorage: "+m)}if(h)try{typeof h=="object"?o===tf&&typeof h=="string"?a=await Lt.Ed25519KeyIdentity.fromJSON(h):a=await Lt.ECDSAKeyIdentity.fromKeyPair(h):typeof h=="string"&&(a=Lt.Ed25519KeyIdentity.fromJSON(h))}catch{}}let c=new Gp.AnonymousIdentity,f=null;if(a)try{let h=await s.get(xt.KEY_STORAGE_DELEGATION);if(typeof h=="object"&&h!==null)throw new Error("Delegation chain is incorrectly stored. A delegation chain should be stored as a string.");e.identity?c=e.identity:h&&(f=Lt.DelegationChain.fromJSON(h),(0,Lt.isDelegationValid)(f)?"toDer"in a?c=Lt.PartialDelegationIdentity.fromDelegation(a,f):c=Lt.DelegationIdentity.fromDelegation(a,f):(await rf(s),a=null))}catch(h){console.error(h),await rf(s),a=null}let d;return!((i=e.idleOptions)===null||i===void 0)&&i.disableIdle?d=void 0:(f||e.identity)&&(d=Yp.IdleManager.create(e.idleOptions)),a||(o===tf?(a=await Lt.Ed25519KeyIdentity.generate(),await s.set(xt.KEY_STORAGE_KEY,JSON.stringify(a.toJSON()))):(e.storage&&o===ef&&console.warn(`You are using a custom storage provider that may not support CryptoKey storage. If you are using a custom storage provider that does not support CryptoKey storage, you should use '${tf}' as the key type, as it can serialize to a string`),a=await Lt.ECDSAKeyIdentity.generate(),await s.set(xt.KEY_STORAGE_KEY,a.getKeyPair()))),new this(c,a,f,s,d,e)}_registerDefaultIdleCallback(){var e,r;let n=(e=this._createOptions)===null||e===void 0?void 0:e.idleOptions;!n?.onIdle&&!n?.disableDefaultIdleCallback&&((r=this.idleManager)===null||r===void 0||r.registerCallback(()=>{this.logout(),location.reload()}))}async _handleSuccess(e,r){var n,i;let s=e.delegations.map(f=>({delegation:new Lt.Delegation(f.delegation.pubkey,f.delegation.expiration,f.delegation.targets),signature:f.signature.buffer})),o=Lt.DelegationChain.fromDelegations(s,e.userPublicKey.buffer),a=this._key;if(!a)return;this._chain=o,"toDer"in a?this._identity=Lt.PartialDelegationIdentity.fromDelegation(a,this._chain):this._identity=Lt.DelegationIdentity.fromDelegation(a,this._chain),(n=this._idpWindow)===null||n===void 0||n.close();let c=(i=this._createOptions)===null||i===void 0?void 0:i.idleOptions;!this.idleManager&&!c?.disableIdle&&(this.idleManager=Yp.IdleManager.create(c),this._registerDefaultIdleCallback()),this._removeEventListener(),delete this._idpWindow,this._chain&&await this._storage.set(xt.KEY_STORAGE_DELEGATION,JSON.stringify(this._chain.toJSON())),r?.(e)}getIdentity(){return this._identity}async isAuthenticated(){return!this.getIdentity().getPrincipal().isAnonymous()&&this._chain!==null}async login(e){var r,n,i,s;let o=BigInt(8)*BigInt(36e11),a=new URL(((r=e?.identityProvider)===null||r===void 0?void 0:r.toString())||BE);a.hash=OE,(n=this._idpWindow)===null||n===void 0||n.close(),this._removeEventListener(),this._eventHandler=this._getEventHandler(a,Object.assign({maxTimeToLive:(i=e?.maxTimeToLive)!==null&&i!==void 0?i:o},e)),window.addEventListener("message",this._eventHandler),this._idpWindow=(s=window.open(a.toString(),"idpWindow",e?.windowOpenerFeatures))!==null&&s!==void 0?s:void 0;let c=()=>{this._idpWindow&&(this._idpWindow.closed?this._handleFailure(Qe.ERROR_USER_INTERRUPT,e?.onError):setTimeout(c,NE))};c()}_getEventHandler(e,r){return async n=>{var i,s,o;if(n.origin!==e.origin){console.warn(`WARNING: expected origin '${e.origin}', got '${n.origin}' (ignoring)`);return}let a=n.data;switch(a.kind){case"authorize-ready":{let c=Object.assign({kind:"authorize-client",sessionPublicKey:new Uint8Array((i=this._key)===null||i===void 0?void 0:i.getPublicKey().toDer()),maxTimeToLive:r?.maxTimeToLive,allowPinAuthentication:r?.allowPinAuthentication,derivationOrigin:(s=r?.derivationOrigin)===null||s===void 0?void 0:s.toString()},r?.customValues);(o=this._idpWindow)===null||o===void 0||o.postMessage(c,e.origin);break}case"authorize-client-success":try{await this._handleSuccess(a,r?.onSuccess)}catch(c){this._handleFailure(c.message,r?.onError)}break;case"authorize-client-failure":this._handleFailure(a.text,r?.onError);break;default:break}}}_handleFailure(e,r){var n;(n=this._idpWindow)===null||n===void 0||n.close(),r?.(e),this._removeEventListener(),delete this._idpWindow}_removeEventListener(){this._eventHandler&&window.removeEventListener("message",this._eventHandler),this._eventHandler=void 0}async logout(e={}){if(await rf(this._storage),this._identity=new Gp.AnonymousIdentity,this._chain=null,e.returnTo)try{window.history.pushState({},"",e.returnTo)}catch{window.location.href=e.returnTo}}};Qe.AuthClient=nf;async function rf(t){await t.remove(xt.KEY_STORAGE_KEY),await t.remove(xt.KEY_STORAGE_DELEGATION),await t.remove(xt.KEY_VECTOR)}});var uc=Un(Tt(),1);var Me=t=>t==null,rt=t=>!Me(t),jg=class extends Error{},zs=(t,e)=>{if(Me(t))throw new jg(e)},oc="__bigint__",ac="__principal__",cc="__uint8array__",kg=(t,e)=>typeof e=="bigint"?{[oc]:`${e}`}:rt(e)&&e instanceof uc.Principal?{[ac]:e.toText()}:rt(e)&&e instanceof Uint8Array?{[cc]:Array.from(e)}:e,Hg=(t,e)=>{let r=n=>e[n];return rt(e)&&typeof e=="object"&&oc in e?BigInt(r(oc)):rt(e)&&typeof e=="object"&&ac in e?uc.Principal.fromText(r(ac)):rt(e)&&typeof e=="object"&&cc in e?Uint8Array.from(r(cc)):e},mt=t=>rt(t)?[t]:[],lt=t=>t?.[0],Sf=async t=>{let e=new Blob([JSON.stringify(t,kg)],{type:"application/json; charset=utf-8"});return new Uint8Array(await e.arrayBuffer())},Ds=async t=>{let e=new Blob([t instanceof Uint8Array?t:new Uint8Array(t)],{type:"application/json; charset=utf-8"});return JSON.parse(await e.text(),Hg)},Bf=()=>typeof window<"u";var ii=class{callbacks=[];populate(e){this.callbacks.forEach(({callback:r})=>r(e))}subscribe(e){let r=Symbol();return this.callbacks.push({id:r,callback:e}),()=>this.callbacks=this.callbacks.filter(({id:n})=>n!==r)}};var Yr=class t extends ii{static instance;authUser=null;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.authUser=e,this.populate(e)}get(){return this.authUser}subscribe(e){let r=super.subscribe(e);return e(this.authUser),r}reset(){this.authUser=null,this.populate(this.authUser)}};var lc=({message:t,detail:e})=>{let r=new CustomEvent(t,{detail:e,bubbles:!0});document.dispatchEvent(r)};var Of=BigInt(144e11),Nf=!1,Rf={width:576,height:576},Pf={width:505,height:705},If="internetcomputer.org";var si="http://127.0.0.1:5987",Uf="rdmx6-jaaaa-aaaaa-aaadq-cai";var Tr=class t extends ii{static instance;env;constructor(){super()}static getInstance(){return t.instance||(t.instance=new t),t.instance}set(e){this.env=e,this.populate(e)}get(){return this.env}subscribe(e){let r=super.subscribe(e);return e(this.env),r}};var fc=({width:t,height:e})=>{if(!Bf()||Me(window)||Me(window.top))return;let{top:{innerWidth:r,innerHeight:n}}=window,i=n/2+screenY-e/2,s=r/2+screenX-t/2;return`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=${t}, height=${e}, top=${i}, left=${s}`};var Zs=class{#e;constructor({domain:e}){this.#e=e}get id(){return"internet_identity"}signInOptions({windowed:e}){let r=()=>{let n=Tr.getInstance().get()?.container;if(Me(n)||n===!1)return`https://identity.${this.#e??If}`;let i=Tr.getInstance().get(),s=rt(i)&&rt(i?.internetIdentityId)?i.internetIdentityId:Uf,{host:o,protocol:a}=new URL(n===!0?si:n);return/apple/i.test(navigator?.vendor)?`${a}//${o}?canisterId=${s}`:`${a}//${s}.${o.replace("127.0.0.1","localhost")}`};return{...e!==!1&&{windowOpenerFeatures:fc(Rf)},identityProvider:r()}}},Ff=class{#e;#t;constructor({appName:e,logoUrl:r}){this.#e=e,this.#t=r}get id(){return"nfid"}signInOptions({windowed:e}){return{...e!==!1&&{windowOpenerFeatures:fc(Pf)},identityProvider:`https://nfid.one/authenticate/?applicationName=${encodeURI(this.#e)}&applicationLogo=${encodeURI(this.#t)}`}}};var Tp=Un(wr(),1);var vp=Un(wr(),1);var Mi=class t{static instance;#e=void 0;constructor(){}static getInstance(){return Me(t.instance)&&(t.instance=new t),t.instance}async getAgent({identity:e,...r}){let n=e.getPrincipal().toText();if(Me(this.#e)||Me(this.#e[n])){let i=await this.createAgent({identity:e,...r});return this.#e={...this.#e??{},[n]:i},i}return this.#e[n]}reset(){this.#e=null}async createAgent({identity:e,fetch:r,container:n}){let s=rt(n)&&n!==!1?n===!0?si:n:"https://icp-api.io",o=rt(n);return await vp.HttpAgent.create({identity:e,shouldFetchRootKey:o,host:s,...r&&{fetch:r}})}};var qi=class t{static instance;#e=void 0;constructor(){}static getInstance(){return Me(t.instance)&&(t.instance=new t),t.instance}async getActor({satelliteId:e,identity:r,buildType:n,...i}){let s=`${n}#${r.getPrincipal().toText()}#${e};`;if(Me(this.#e)||Me(this.#e[s])){let o=await this.createActor({satelliteId:e,identity:r,...i});return this.#e={...this.#e??{},[s]:o},o}return this.#e[s]}reset(){this.#e=null}async createActor({idlFactory:e,satelliteId:r,...n}){let i=await Mi.getInstance().getAgent(n);return Tp.Actor.createActor(e,{agent:i,canisterId:r})}};var zp=Un(Wp(),1),za=()=>zp.AuthClient.create({idleOptions:{disableIdle:!0,disableDefaultIdleCallback:!0}});var Dp=async({data:t})=>{try{return await Ds(t)}catch(e){console.error("The data parsing has failed, mapping to undefined as a fallback.",e);return}};var sf=async t=>{let{data:e,version:r,description:n}=t;return{description:mt(n),data:await Sf(e),version:mt(r)}},of=t=>{let{version:e}=t;return{version:mt(e)}},Cs=async({doc:t,key:e})=>{let{owner:r,version:n,description:i,data:s,...o}=t;return{key:e,description:lt(i),owner:r.toText(),data:await Ds(s),version:lt(n),...o}};var Xp=Un(Tt(),1);var Zp=t=>{if(Me(t))return mt();switch(t.matcher){case"equal":return mt({Equal:t.timestamp});case"greaterThan":return mt({GreaterThan:t.timestamp});case"lessThan":return mt({LessThan:t.timestamp});case"between":return mt({Between:[t.timestamps.start,t.timestamps.end]});default:throw new Error("Invalid list matcher for timestamp",t)}},ki=({matcher:t,paginate:e,order:r,owner:n})=>({matcher:Me(t)?[]:[{key:mt(t.key),description:mt(t.description),created_at:Zp(t.createdAt),updated_at:Zp(t.updatedAt)}],paginate:mt(Me(e)?void 0:{start_after:mt(e.startAfter),limit:mt(Me(e.limit)?void 0:BigInt(e.limit))}),order:mt(Me(r)?void 0:{desc:r.desc,field:r.field==="created_at"?{CreatedAt:null}:r.field==="updated_at"?{UpdatedAt:null}:{Keys:null}}),owner:mt(Me(n)?void 0:typeof n=="string"?Xp.Principal.fromText(n):n)});var Jp=({IDL:t})=>{let e=t.Record({batch_id:t.Nat,headers:t.Vec(t.Tuple(t.Text,t.Text)),chunk_ids:t.Vec(t.Nat)}),r=t.Variant({UpdatedAt:t.Null,Keys:t.Null,CreatedAt:t.Null}),n=t.Record({field:r,desc:t.Bool}),i=t.Variant({Equal:t.Nat64,Between:t.Tuple(t.Nat64,t.Nat64),GreaterThan:t.Nat64,LessThan:t.Nat64}),s=t.Record({key:t.Opt(t.Text),updated_at:t.Opt(i),description:t.Opt(t.Text),created_at:t.Opt(i)}),o=t.Record({start_after:t.Opt(t.Text),limit:t.Opt(t.Nat64)}),a=t.Record({order:t.Opt(n),owner:t.Opt(t.Principal),matcher:t.Opt(s),paginate:t.Opt(o)}),c=t.Record({controllers:t.Vec(t.Principal)}),f=t.Variant({Write:t.Null,Admin:t.Null}),d=t.Record({updated_at:t.Nat64,metadata:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,scope:f,expires_at:t.Opt(t.Nat64)}),h=t.Record({version:t.Opt(t.Nat64)}),m=t.Variant({Db:t.Null,Storage:t.Null}),_=t.Record({version:t.Opt(t.Nat64)}),u=t.Record({cycles:t.Nat,destination_id:t.Principal}),T=t.Record({token:t.Opt(t.Text),collection:t.Text,owner:t.Principal,name:t.Text,description:t.Opt(t.Text),full_path:t.Text}),O=t.Record({modified:t.Nat64,sha256:t.Vec(t.Nat8),total_length:t.Nat}),R=t.Record({key:T,updated_at:t.Nat64,encodings:t.Vec(t.Tuple(t.Text,O)),headers:t.Vec(t.Tuple(t.Text,t.Text)),created_at:t.Nat64,version:t.Opt(t.Nat64)}),F=t.Record({derivation_origin:t.Opt(t.Text)}),M=t.Record({internet_identity:t.Opt(F)}),K=t.Record({stable:t.Opt(t.Nat64),heap:t.Opt(t.Nat64)}),x=t.Record({max_memory_size:t.Opt(K)}),$=t.Variant({Deny:t.Null,AllowAny:t.Null,SameOrigin:t.Null}),W=t.Variant({Deny:t.Null,Allow:t.Null}),D=t.Record({status_code:t.Nat16,location:t.Text}),j=t.Record({iframe:t.Opt($),rewrites:t.Vec(t.Tuple(t.Text,t.Text)),headers:t.Vec(t.Tuple(t.Text,t.Vec(t.Tuple(t.Text,t.Text)))),max_memory_size:t.Opt(K),raw_access:t.Opt(W),redirects:t.Opt(t.Vec(t.Tuple(t.Text,D)))}),ie=t.Record({db:t.Opt(x),authentication:t.Opt(M),storage:j}),ee=t.Record({updated_at:t.Nat64,owner:t.Principal,data:t.Vec(t.Nat8),description:t.Opt(t.Text),created_at:t.Nat64,version:t.Opt(t.Nat64)}),ne=t.Record({url:t.Text,method:t.Text,body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),certificate_version:t.Opt(t.Nat16)}),w=t.Variant({Heap:t.Null,Stable:t.Null}),b=t.Record({memory:w,token:t.Opt(t.Text),sha256:t.Opt(t.Vec(t.Nat8)),headers:t.Vec(t.Tuple(t.Text,t.Text)),index:t.Nat64,encoding_type:t.Text,full_path:t.Text}),B=t.Variant({Callback:t.Record({token:b,callback:t.Func([],[],["query"])})}),S=t.Record({body:t.Vec(t.Nat8),headers:t.Vec(t.Tuple(t.Text,t.Text)),streaming_strategy:t.Opt(B),status_code:t.Nat16}),N=t.Record({token:t.Opt(b),body:t.Vec(t.Nat8)}),H=t.Record({token:t.Opt(t.Text),collection:t.Text,name:t.Text,description:t.Opt(t.Text),encoding_type:t.Opt(t.Text),full_path:t.Text}),Z=t.Record({batch_id:t.Nat}),ae=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,R)),items_length:t.Nat64}),oe=t.Record({updated_at:t.Nat64,created_at:t.Nat64,version:t.Opt(t.Nat64),bn_id:t.Opt(t.Text)}),z=t.Record({matches_pages:t.Opt(t.Nat64),matches_length:t.Nat64,items_page:t.Opt(t.Nat64),items:t.Vec(t.Tuple(t.Text,ee)),items_length:t.Nat64}),U=t.Variant({Controllers:t.Null,Private:t.Null,Public:t.Null,Managed:t.Null}),p=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(w),updated_at:t.Nat64,max_size:t.Opt(t.Nat),read:U,created_at:t.Nat64,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),write:U}),J=t.Record({stable:t.Nat64,heap:t.Nat64}),re=t.Record({metadata:t.Vec(t.Tuple(t.Text,t.Text)),scope:f,expires_at:t.Opt(t.Nat64)}),fe=t.Record({controller:re,controllers:t.Vec(t.Principal)}),L=t.Record({data:t.Vec(t.Nat8),description:t.Opt(t.Text),version:t.Opt(t.Nat64)}),l=t.Record({max_capacity:t.Opt(t.Nat32),memory:t.Opt(w),max_size:t.Opt(t.Nat),read:U,version:t.Opt(t.Nat64),mutable_permissions:t.Opt(t.Bool),write:U}),y=t.Record({content:t.Vec(t.Nat8),batch_id:t.Nat,order_id:t.Opt(t.Nat)}),g=t.Record({chunk_id:t.Nat});return t.Service({build_version:t.Func([],[t.Text],["query"]),commit_asset_upload:t.Func([e],[],[]),count_assets:t.Func([t.Text,a],[t.Nat64],["query"]),count_collection_assets:t.Func([t.Text],[t.Nat64],["query"]),count_collection_docs:t.Func([t.Text],[t.Nat64],["query"]),count_docs:t.Func([t.Text,a],[t.Nat64],["query"]),del_asset:t.Func([t.Text,t.Text],[],[]),del_assets:t.Func([t.Text],[],[]),del_controllers:t.Func([c],[t.Vec(t.Tuple(t.Principal,d))],[]),del_custom_domain:t.Func([t.Text],[],[]),del_doc:t.Func([t.Text,t.Text,h],[],[]),del_docs:t.Func([t.Text],[],[]),del_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[],[]),del_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,h))],[],[]),del_rule:t.Func([m,t.Text,_],[],[]),deposit_cycles:t.Func([u],[],[]),get_asset:t.Func([t.Text,t.Text],[t.Opt(R)],["query"]),get_auth_config:t.Func([],[t.Opt(M)],["query"]),get_config:t.Func([],[ie],[]),get_db_config:t.Func([],[t.Opt(x)],["query"]),get_doc:t.Func([t.Text,t.Text],[t.Opt(ee)],["query"]),get_many_assets:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(R)))],["query"]),get_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text))],[t.Vec(t.Tuple(t.Text,t.Opt(ee)))],["query"]),get_storage_config:t.Func([],[j],["query"]),http_request:t.Func([ne],[S],["query"]),http_request_streaming_callback:t.Func([b],[N],["query"]),init_asset_upload:t.Func([H],[Z],[]),list_assets:t.Func([t.Text,a],[ae],["query"]),list_controllers:t.Func([],[t.Vec(t.Tuple(t.Principal,d))],["query"]),list_custom_domains:t.Func([],[t.Vec(t.Tuple(t.Text,oe))],["query"]),list_docs:t.Func([t.Text,a],[z],["query"]),list_rules:t.Func([m],[t.Vec(t.Tuple(t.Text,p))],["query"]),memory_size:t.Func([],[J],["query"]),set_auth_config:t.Func([M],[],[]),set_controllers:t.Func([fe],[t.Vec(t.Tuple(t.Principal,d))],[]),set_custom_domain:t.Func([t.Text,t.Opt(t.Text)],[],[]),set_db_config:t.Func([x],[],[]),set_doc:t.Func([t.Text,t.Text,L],[ee],[]),set_many_docs:t.Func([t.Vec(t.Tuple(t.Text,t.Text,L))],[t.Vec(t.Tuple(t.Text,ee))],[]),set_rule:t.Func([m,t.Text,l],[],[]),set_storage_config:t.Func([j],[],[]),upload_asset_chunk:t.Func([y],[g],[]),version:t.Func([],[t.Text],["query"])})};var Lp=({satelliteId:t,container:e})=>{let{satelliteId:r}=af({satelliteId:t}),{container:n}=cf({container:e});if(rt(n)&&n!==!1){let{host:i,protocol:s}=new URL(n===!0?si:n);return`${s}//${r??"unknown"}.${i.replace("127.0.0.1","localhost")}`}return`https://${r??"unknown"}.icp0.io`},af=({satelliteId:t})=>rt(t)?{satelliteId:t}:Tr.getInstance().get()??{satelliteId:void 0},cf=({container:t})=>rt(t)?{container:t}:Tr.getInstance().get()??{container:void 0};var vt=async t=>ey({idlFactory:Jp,buildType:"stock",...t}),Qp=async({idlFactory:t,...e})=>ey({idlFactory:t,buildType:"extended",...e}),ey=async({satelliteId:t,container:e,...r})=>{let{satelliteId:n}=af({satelliteId:t});zs(n,"No satellite ID defined. Did you initialize Juno?");let{container:i}=cf({container:e});return await qi.getInstance().getActor({satelliteId:n,container:i,...r})};var ty=async({collection:t,key:e,satellite:r})=>{let{get_doc:n}=await vt(r),i=lt(await n(t,e));if(!Me(i))return Cs({doc:i,key:e})},ry=async({docs:t,satellite:e})=>{let{get_many_docs:r}=await vt(e),n=t.map(({collection:o,key:a})=>[o,a]),i=await r(n),s=[];for(let[o,a]of i){let c=lt(a);s.push(rt(c)?await Cs({key:o,doc:c}):void 0)}return s},ny=async({collection:t,doc:e,satellite:r})=>{let{set_doc:n}=await vt(r),{key:i}=e,s=await sf(e),o=await n(t,i,s);return await Cs({key:i,doc:o})},iy=async({docs:t,satellite:e})=>{let{set_many_docs:r}=await vt(e),n=[];for(let{collection:o,doc:a}of t){let{key:c}=a;n.push([o,c,await sf(a)])}let i=await r(n),s=[];for(let[o,a]of i)s.push(await Cs({key:o,doc:a}));return s},sy=async({collection:t,doc:e,satellite:r})=>{let{del_doc:n}=await vt(r),{key:i}=e;return n(t,i,of(e))},oy=async({docs:t,satellite:e})=>{let{del_many_docs:r}=await vt(e),n=t.map(({collection:i,doc:s})=>[i,s.key,of(s)]);await r(n)},ay=async({collection:t,filter:e,satellite:r})=>{let{list_docs:n}=await vt(r),{items:i,items_page:s,items_length:o,matches_length:a,matches_pages:c}=await n(t,ki(e)),f=[];for(let[d,h]of i){let{data:m,owner:_,description:u,version:T,...O}=h;f.push({key:d,description:lt(u),owner:_.toText(),data:await Dp({data:m}),version:lt(T),...O})}return{items:f,items_length:o,items_page:lt(s),matches_length:a,matches_pages:lt(c)}},cy=async({collection:t,filter:e,satellite:r})=>{let{count_docs:n}=await vt(r);return n(t,ki(e))};var uy=Un(wr(),1);var it=t=>t!==void 0?t:Da()??new uy.AnonymousIdentity;var ly=async({satellite:t,...e})=>{let r=it(t?.identity);return ty({...e,satellite:{...t,identity:r}})},U8=async({satellite:t,...e})=>{let r=it(t?.identity);return ry({...e,satellite:{...t,identity:r}})},fy=async({satellite:t,...e})=>{let r=it(t?.identity);return ny({...e,satellite:{...t,identity:r}})},F8=async({satellite:t,...e})=>{let r=it(t?.identity);return iy({...e,satellite:{...t,identity:r}})},M8=async({satellite:t,...e})=>{let r=it(t?.identity);return sy({...e,satellite:{...t,identity:r}})},q8=async({satellite:t,...e})=>{let r=it(t?.identity);return oy({...e,satellite:{...t,identity:r}})},C8=async({satellite:t,filter:e,...r})=>{let n=it(t?.identity);return ay({...r,filter:e??{},satellite:{...t,identity:n}})},j8=async({satellite:t,filter:e,...r})=>{let n=it(t?.identity);return cy({...r,filter:e??{},satellite:{...t,identity:n}})};var dy=async t=>{let e=Da();if(Me(e))throw new Error("No identity to initialize the user. Have you initialized Juno?");let r=e.getPrincipal().toText(),n=await ly({collection:"#user",key:r});return Me(n)?await RE({userId:r,provider:t}):n},RE=async({userId:t,...e})=>fy({collection:"#user",doc:{key:t,data:e}});var $r,uf=async t=>{if($r=$r??await za(),!(await $r?.isAuthenticated()??!1))return;let r=await dy(t);Yr.getInstance().set(r)},PE=async t=>new Promise(async(e,r)=>{$r=$r??await za();let n=t?.provider??new Zs({});await $r.login({onSuccess:async()=>{await uf(n.id),e()},onError:i=>r(i),maxTimeToLive:t?.maxTimeToLive??Of,allowPinAuthentication:t?.allowPin??Nf,...t?.derivationOrigin!==void 0&&{derivationOrigin:t.derivationOrigin},...n.signInOptions({windowed:t?.windowed})})}),lf=async()=>{await $r?.logout(),$r=void 0,Yr.getInstance().reset(),qi.getInstance().reset(),Mi.getInstance().reset()},Da=()=>$r?.getIdentity(),IE=async()=>($r??await za()).getIdentity();var hy=t=>{let e=t===!0?"./workers/auth.worker.js":t,r=new Worker(e),n=async()=>{lc({message:"junoSignOutAuthTimer"}),await lf()};return r.onmessage=async({data:i})=>{let{msg:s,data:o}=i;switch(s){case"junoSignOutAuthTimer":await n();return;case"junoDelegationRemainingTime":lc({message:"junoDelegationRemainingTime",detail:o?.authRemainingTime});return}},Yr.getInstance().subscribe(i=>{if(Me(i)){r.postMessage({msg:"junoStopAuthTimer"});return}r.postMessage({msg:"junoStartAuthTimer"})})};var py=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_SATELLITE_ID??import.meta.env?.PUBLIC_SATELLITE_ID:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_SATELLITE_ID??t():t()},yy=()=>{let t=()=>typeof import.meta<"u"&&typeof import.meta.env<"u"?import.meta.env?.VITE_CONTAINER??import.meta.env?.PUBLIC_CONTAINER:void 0;return typeof process<"u"?process.env?.NEXT_PUBLIC_CONTAINER??t():t()};var oT=async({idlFactory:t,satellite:e})=>{let r=it(e?.identity);return Qp({idlFactory:t,...e,identity:r})};var cT=Un(Tt(),1),UE=t=>t==null,FE=t=>!UE(t),Za=t=>FE(t)?[t]:[],ME=()=>typeof window<"u",gy=async({asset:{data:t,filename:e,collection:r,headers:n,token:i,fullPath:s,encoding:o,description:a},actor:c,init_asset_upload:f})=>{let{batch_id:d}=await f({collection:r,full_path:s,name:e,token:Za(i),encoding_type:Za(o),description:Za(a)}),h=19e5,m=[],_=ME()?new Blob([await t.arrayBuffer()]):t,u=0n;for(let R=0;R<_.size;R+=h){let F=_.slice(R,R+h);m.push({batchId:d,chunk:F,actor:c,orderId:u}),u++}let T=[];for await(let R of qE({uploadChunks:m}))T=[...T,...R];let O=n.find(([R,F])=>R.toLowerCase()==="content-type")===void 0&&t.type!==void 0&&t.type!==""?[["Content-Type",t.type]]:void 0;await c.commit_asset_upload({batch_id:d,chunk_ids:T.map(({chunk_id:R})=>R),headers:[...n,...O||[]]})};async function*qE({uploadChunks:t,limit:e=12}){for(let r=0;r<t.length;r=r+e){let n=t.slice(r,r+e);yield await Promise.all(n.map(i=>CE(i)))}}var CE=async({batchId:t,chunk:e,actor:r,orderId:n})=>r.upload_asset_chunk({batch_id:t,content:new Uint8Array(await e.arrayBuffer()),order_id:Za(n)});var my=async({satellite:t,...e})=>{let r=await vt(t);await gy({actor:r,asset:e,init_asset_upload:async i=>await r.init_asset_upload(i)})},by=async({collection:t,satellite:e,filter:r})=>{let{list_assets:n}=await vt(e),{items:i,items_length:s,items_page:o,matches_length:a,matches_pages:c}=await n(t,ki(r));return{items:i.map(([f,d])=>d),items_length:s,items_page:lt(o),matches_length:a,matches_pages:lt(c)}},_y=async({collection:t,satellite:e,filter:r})=>{let{count_assets:n}=await vt(e);return n(t,ki(r))},wy=async({collection:t,fullPath:e,satellite:r})=>(await vt(r)).del_asset(t,e),Ey=async({assets:t,satellite:e})=>{let{del_many_assets:r}=await vt(e),n=t.map(({collection:i,fullPath:s})=>[i,s]);await r(n)},xy=async({collection:t,fullPath:e,satellite:r})=>{let{get_asset:n}=await vt(r);return lt(await n(t,e))},vy=async({assets:t,satellite:e})=>{let{get_many_assets:r}=await vt(e),n=t.map(({collection:s,fullPath:o})=>[s,o]);return(await r(n)).map(([s,o])=>lt(o))};var Ty=t=>btoa([...t].map(e=>String.fromCharCode(e)).join(""));var xT=async t=>Ay(t),vT=async t=>Ay({filename:t.data.name,...t}),Ay=async({filename:t,data:e,collection:r,headers:n=[],fullPath:i,token:s,satellite:o,encoding:a,description:c})=>{let f=it(o?.identity),d=decodeURI(t),h=i??`/${r}/${d}`,m={...o,identity:f};return await my({data:e,filename:d,collection:r,token:s,headers:n,fullPath:h,encoding:a,satellite:m,description:c}),{downloadUrl:Sy({satellite:m,assetKey:{fullPath:h,token:s}}),fullPath:h,name:d}},TT=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:it(e?.identity)},{items:i,...s}=await by({collection:t,satellite:n,filter:r??{}}),o=i.map(({key:{full_path:a,token:c,name:f,owner:d,description:h},headers:m,encodings:_,created_at:u,updated_at:T})=>{let O=lt(c);return{fullPath:a,description:lt(h),name:f,downloadUrl:Sy({satellite:n,assetKey:{fullPath:a,token:O}}),token:O,headers:m,encodings:_.reduce((R,[F,{modified:M,sha256:K,total_length:x}])=>({...R,[F]:{modified:M,sha256:Ty(K),total_length:x}}),{}),owner:d.toText(),created_at:u,updated_at:T}});return{items:o,assets:o,...s}},AT=async({collection:t,satellite:e,filter:r})=>{let n={...e,identity:it(e?.identity)};return _y({collection:t,satellite:n,filter:r??{}})},ST=async({collection:t,fullPath:e,satellite:r})=>wy({collection:t,fullPath:e,satellite:{...r,identity:it(r?.identity)}}),BT=async({assets:t,satellite:e})=>Ey({assets:t,satellite:{...e,identity:it(e?.identity)}}),OT=async({satellite:t,...e})=>{let r=it(t?.identity);return xy({...e,satellite:{...t,identity:r}})},NT=async({satellite:t,...e})=>{let r=it(t?.identity);return vy({...e,satellite:{...t,identity:r}})},Sy=({assetKey:{fullPath:t,token:e},satellite:r})=>{let n={...r,identity:it(r?.identity)};return`${Lp(n)}${t}${rt(e)?`?token=${e}`:""}`};var jE=t=>{let e=t?.satelliteId??py();zs(e,"Satellite ID is not configured. Juno cannot be initialized.");let r=t?.container??yy();return{satelliteId:e,internetIdentityId:t?.internetIdentityId,workers:t?.workers,container:r}},CT=async t=>kE(t),kE=async t=>{let e=jE(t);Tr.getInstance().set(e),await uf();let r=e.workers?.auth!==void 0?hy(e.workers.auth):void 0;return[...r?[r]:[]]},jT=t=>Yr.getInstance().subscribe(t);export{Zs as InternetIdentityProvider,Ff as NFIDProvider,jT as authSubscribe,AT as countAssets,j8 as countDocs,ST as deleteAsset,M8 as deleteDoc,BT as deleteManyAssets,q8 as deleteManyDocs,Sy as downloadUrl,OT as getAsset,ly as getDoc,NT as getManyAssets,U8 as getManyDocs,oT as getSatelliteExtendedActor,CT as initJuno,kE as initSatellite,TT as listAssets,C8 as listDocs,fy as setDoc,F8 as setManyDocs,PE as signIn,lf as signOut,IE as unsafeIdentity,xT as uploadBlob,vT as uploadFile};
57
58
  /*! Bundled license information:
58
59
 
59
60
  @noble/hashes/utils.js:
@@ -85,6 +86,9 @@ buffer/index.js:
85
86
  @noble/curves/abstract/bls.js:
86
87
  (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
87
88
 
89
+ @noble/curves/abstract/tower.js:
90
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
91
+
88
92
  @noble/curves/bls12-381.js:
89
93
  (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
90
94